semiotic 3.4.1 → 3.5.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 (164) hide show
  1. package/CLAUDE.md +114 -9
  2. package/README.md +45 -4
  3. package/ai/behaviorContracts.cjs +311 -0
  4. package/ai/chartSuggestions.cjs +291 -0
  5. package/ai/cli.js +255 -30
  6. package/ai/componentMetadata.cjs +107 -0
  7. package/ai/dist/mcp-server.js +907 -227
  8. package/ai/schema.json +3954 -2537
  9. package/ai/system-prompt.md +23 -4
  10. package/dist/components/LinkedCharts.d.ts +5 -1
  11. package/dist/components/Tooltip/Tooltip.d.ts +1 -1
  12. package/dist/components/charts/custom/NetworkCustomChart.d.ts +64 -0
  13. package/dist/components/charts/custom/OrdinalCustomChart.d.ts +71 -0
  14. package/dist/components/charts/custom/XYCustomChart.d.ts +59 -0
  15. package/dist/components/charts/geo/ChoroplethMap.d.ts +93 -2
  16. package/dist/components/charts/geo/DistanceCartogram.d.ts +51 -4
  17. package/dist/components/charts/geo/FlowMap.d.ts +55 -0
  18. package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +53 -0
  19. package/dist/components/charts/index.d.ts +6 -0
  20. package/dist/components/charts/network/ChordDiagram.d.ts +34 -2
  21. package/dist/components/charts/network/CirclePack.d.ts +36 -1
  22. package/dist/components/charts/network/ForceDirectedGraph.d.ts +130 -2
  23. package/dist/components/charts/network/OrbitDiagram.d.ts +37 -0
  24. package/dist/components/charts/network/SankeyDiagram.d.ts +51 -2
  25. package/dist/components/charts/network/TreeDiagram.d.ts +37 -2
  26. package/dist/components/charts/network/Treemap.d.ts +36 -2
  27. package/dist/components/charts/ordinal/BarChart.d.ts +111 -1
  28. package/dist/components/charts/ordinal/BoxPlot.d.ts +31 -0
  29. package/dist/components/charts/ordinal/DonutChart.d.ts +36 -0
  30. package/dist/components/charts/ordinal/DotPlot.d.ts +31 -0
  31. package/dist/components/charts/ordinal/FunnelChart.d.ts +40 -0
  32. package/dist/components/charts/ordinal/GaugeChart.d.ts +45 -0
  33. package/dist/components/charts/ordinal/GroupedBarChart.d.ts +38 -0
  34. package/dist/components/charts/ordinal/Histogram.d.ts +95 -0
  35. package/dist/components/charts/ordinal/LikertChart.d.ts +42 -0
  36. package/dist/components/charts/ordinal/PieChart.d.ts +90 -1
  37. package/dist/components/charts/ordinal/RidgelinePlot.d.ts +27 -0
  38. package/dist/components/charts/ordinal/StackedBarChart.d.ts +38 -0
  39. package/dist/components/charts/ordinal/SwarmPlot.d.ts +36 -0
  40. package/dist/components/charts/ordinal/SwimlaneChart.d.ts +60 -0
  41. package/dist/components/charts/ordinal/ViolinPlot.d.ts +32 -0
  42. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +22 -4
  43. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +5 -2
  44. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +24 -3
  45. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +12 -0
  46. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +14 -0
  47. package/dist/components/charts/realtime/defaultRealtimeTooltip.d.ts +43 -0
  48. package/dist/components/charts/realtime/resolveWindowSize.d.ts +26 -0
  49. package/dist/components/charts/shared/chartSpecs.d.ts +91 -0
  50. package/dist/components/charts/shared/colorPalettes.d.ts +62 -0
  51. package/dist/components/charts/shared/colorUtils.d.ts +9 -10
  52. package/dist/components/charts/shared/numberFormat.d.ts +58 -0
  53. package/dist/components/charts/shared/sparseArray.d.ts +27 -0
  54. package/dist/components/charts/shared/streamPropsHelpers.d.ts +113 -0
  55. package/dist/components/charts/shared/timeFormat.d.ts +60 -0
  56. package/dist/components/charts/shared/useChartSetup.d.ts +8 -0
  57. package/dist/components/charts/shared/useCustomChartSetup.d.ts +84 -0
  58. package/dist/components/charts/shared/useFrameImperativeHandle.d.ts +28 -0
  59. package/dist/components/charts/shared/useOrdinalStreaming.d.ts +6 -19
  60. package/dist/components/charts/shared/useStreamingLegend.d.ts +27 -11
  61. package/dist/components/charts/shared/validateProps.d.ts +2 -2
  62. package/dist/components/charts/shared/validationMap.d.ts +2 -1
  63. package/dist/components/charts/shared/withChartWrapper.d.ts +13 -4
  64. package/dist/components/charts/xy/AreaChart.d.ts +30 -1
  65. package/dist/components/charts/xy/CandlestickChart.d.ts +33 -6
  66. package/dist/components/charts/xy/ConnectedScatterplot.d.ts +24 -0
  67. package/dist/components/charts/xy/MinimapChart.d.ts +51 -0
  68. package/dist/components/charts/xy/MultiAxisLineChart.d.ts +27 -0
  69. package/dist/components/charts/xy/QuadrantChart.d.ts +21 -0
  70. package/dist/components/charts/xy/Scatterplot.d.ts +34 -2
  71. package/dist/components/charts/xy/ScatterplotMatrix.d.ts +16 -0
  72. package/dist/components/charts/xy/StackedAreaChart.d.ts +49 -1
  73. package/dist/components/export/selectionSerializer.d.ts +1 -1
  74. package/dist/components/realtime/types.d.ts +7 -9
  75. package/dist/components/recipes/bullet.d.ts +86 -0
  76. package/dist/components/recipes/calendar.d.ts +43 -0
  77. package/dist/components/recipes/dagre.d.ts +56 -0
  78. package/dist/components/recipes/flextree.d.ts +55 -0
  79. package/dist/components/recipes/marimekko.d.ts +55 -0
  80. package/dist/components/recipes/parallelCoordinates.d.ts +97 -0
  81. package/dist/components/recipes/recipeUtils.d.ts +27 -0
  82. package/dist/components/recipes/waffle.d.ts +46 -0
  83. package/dist/components/semiotic-ai.d.ts +4 -0
  84. package/dist/components/semiotic-network.d.ts +3 -0
  85. package/dist/components/semiotic-ordinal.d.ts +3 -0
  86. package/dist/components/semiotic-recipes.d.ts +24 -0
  87. package/dist/components/semiotic-xy.d.ts +3 -0
  88. package/dist/components/semiotic.d.ts +2 -2
  89. package/dist/components/server/renderToStaticSVG.d.ts +8 -2
  90. package/dist/components/server/serverChartConfigs.d.ts +47 -1
  91. package/dist/components/server/staticAnnotations.d.ts +6 -0
  92. package/dist/components/store/ObservationStore.d.ts +1 -3
  93. package/dist/components/store/SelectionStore.d.ts +2 -4
  94. package/dist/components/store/ThemeStore.d.ts +4 -4
  95. package/dist/components/store/TooltipStore.d.ts +5 -3
  96. package/dist/components/store/createStore.d.ts +4 -2
  97. package/dist/components/store/useSelection.d.ts +7 -4
  98. package/dist/components/stream/CanvasHitTester.d.ts +10 -8
  99. package/dist/components/stream/DataSourceAdapter.d.ts +9 -0
  100. package/dist/components/stream/GeoPipelineStore.d.ts +9 -0
  101. package/dist/components/stream/GeoTileRenderer.d.ts +14 -0
  102. package/dist/components/stream/NetworkPipelineStore.d.ts +25 -0
  103. package/dist/components/stream/NetworkSVGOverlay.d.ts +18 -12
  104. package/dist/components/stream/OrdinalPipelineStore.d.ts +12 -0
  105. package/dist/components/stream/PipelineStore.d.ts +51 -0
  106. package/dist/components/stream/SVGOverlay.d.ts +12 -0
  107. package/dist/components/stream/SceneGraph.d.ts +15 -1
  108. package/dist/components/stream/SceneToSVG.d.ts +1 -1
  109. package/dist/components/stream/categoryDomain.d.ts +4 -0
  110. package/dist/components/stream/composeOverlays.d.ts +15 -0
  111. package/dist/components/stream/customLayout.d.ts +76 -0
  112. package/dist/components/stream/customLayoutPalette.d.ts +29 -0
  113. package/dist/components/stream/geoTypes.d.ts +33 -8
  114. package/dist/components/stream/hoverUtils.d.ts +4 -10
  115. package/dist/components/stream/keyboardNav.d.ts +18 -6
  116. package/dist/components/stream/networkCustomLayout.d.ts +67 -0
  117. package/dist/components/stream/networkTypes.d.ts +87 -21
  118. package/dist/components/stream/ordinalCustomLayout.d.ts +84 -0
  119. package/dist/components/stream/ordinalTypes.d.ts +47 -13
  120. package/dist/components/stream/renderers/barFunnelCanvasRenderer.d.ts +9 -1
  121. package/dist/components/stream/renderers/canvasRenderHelpers.d.ts +92 -0
  122. package/dist/components/stream/sampleCurvePath.d.ts +9 -0
  123. package/dist/components/stream/types.d.ts +57 -10
  124. package/dist/components/stream/useHydration.d.ts +89 -0
  125. package/dist/components/stream/useStableShallow.d.ts +1 -0
  126. package/dist/components/stream/xySceneBuilders/types.d.ts +4 -0
  127. package/dist/geo.min.js +2 -1
  128. package/dist/geo.module.min.js +2 -1
  129. package/dist/network.min.js +2 -1
  130. package/dist/network.module.min.js +2 -1
  131. package/dist/ordinal.min.js +2 -1
  132. package/dist/ordinal.module.min.js +2 -1
  133. package/dist/realtime.min.js +2 -1
  134. package/dist/realtime.module.min.js +2 -1
  135. package/dist/semiotic-ai.d.ts +69 -65
  136. package/dist/semiotic-ai.min.js +2 -1
  137. package/dist/semiotic-ai.module.min.js +2 -1
  138. package/dist/semiotic-data.d.ts +4 -4
  139. package/dist/semiotic-geo.d.ts +15 -15
  140. package/dist/semiotic-network.d.ts +19 -16
  141. package/dist/semiotic-ordinal.d.ts +31 -28
  142. package/dist/semiotic-realtime.d.ts +17 -17
  143. package/dist/semiotic-recipes.d.ts +24 -0
  144. package/dist/semiotic-recipes.min.js +1 -0
  145. package/dist/semiotic-recipes.module.min.js +1 -0
  146. package/dist/semiotic-server.d.ts +6 -6
  147. package/dist/semiotic-statisticalOverlays-C3DsOgr_.js +1 -0
  148. package/dist/semiotic-themes.d.ts +3 -3
  149. package/dist/semiotic-themes.min.js +2 -1
  150. package/dist/semiotic-themes.module.min.js +2 -1
  151. package/dist/semiotic-utils.d.ts +23 -23
  152. package/dist/semiotic-utils.min.js +2 -1
  153. package/dist/semiotic-utils.module.min.js +2 -1
  154. package/dist/semiotic-xy.d.ts +27 -24
  155. package/dist/semiotic.d.ts +63 -63
  156. package/dist/semiotic.min.js +2 -1
  157. package/dist/semiotic.module.min.js +2 -1
  158. package/dist/server.min.js +1 -1
  159. package/dist/server.module.min.js +1 -1
  160. package/dist/test-utils/canvasMock.d.ts +34 -5
  161. package/dist/xy.min.js +2 -1
  162. package/dist/xy.module.min.js +2 -1
  163. package/package.json +40 -20
  164. package/dist/semiotic-statisticalOverlays-Ckd_jM8z.js +0 -1
@@ -1 +1 @@
1
- "use strict";const t=require("react/jsx-runtime"),e=require("react-dom/server"),i=require("d3-scale"),o=require("d3-quadtree"),r=require("d3-scale-chromatic"),n=require("d3-array"),s=require("d3-interpolate"),a=require("d3-force"),c=require("d3-chord"),l=require("d3-shape"),u=require("d3-hierarchy"),h=require("d3-geo"),d=require("react");function f(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const i in t)if("default"!==i){const o=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:function(){return t[i]}})}return e.default=t,Object.freeze(e)}const g=f(e),y=f(d);function p(t,e,i,o){return new(i||(i=Promise))(function(r,n){function s(t){try{c(o.next(t))}catch(t){n(t)}}function a(t){try{c(o.throw(t))}catch(t){n(t)}}function c(t){t.done?r(t.value):function(t){return t instanceof i?t:new i(function(e){e(t)})}(t.value).then(s,a)}c((o=o.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class m{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const i of t){const t=this.push(i);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;return{next:()=>this._size>t?{done:!1,value:this.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)t(this.buffer[(e+i)%this._capacity],i)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)t[i]=this.buffer[(e+i)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),i=[];for(;e.length>t;)i.push(e.shift());this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(const t of e)this.push(t);return i}update(t,e){const i=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++){const n=(o+r)%this._capacity,s=this.buffer[n];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:Object.assign({},s),i.push(t),this.buffer[n]=e(s)}}return i}remove(t){const e=[],i=[];if(this.forEach(o=>{t(o)?i.push(o):e.push(o)}),0===i.length)return i;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return i}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class x{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isNaN(t)||(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const 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 v(t,e,i,o,r){const n=new Map;for(const s of t){const t=e(s),a=i(s);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const c=Math.floor(t/o)*o;let l=n.get(c);if(l||(l={start:c,end:c+o,total:0,categories:new Map},n.set(c,l)),l.total+=a,r){const t=r(s);l.categories.set(t,(l.categories.get(t)||0)+a)}}return n}function b(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function k(t,e){if("function"==typeof t)return e=>+t(e);const i=t||e;return t=>+t[i]}function A(t,e){if("function"==typeof t)return t;const i=t||e;return t=>t[i]}function w(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}const S={category10:r.schemeCategory10,tableau10:r.schemeTableau10,set3:r.schemeSet3,blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,oranges:r.interpolateOranges,purples:r.interpolatePurples,viridis:r.interpolateViridis,plasma:r.interpolatePlasma},_=r.schemeCategory10,P=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],j=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function M(t,e,o="category10"){const r=Array.from(new Set(t.map(t=>null==t?void 0:t[e]).filter(t=>null!=t))),n=r.every(t=>"number"==typeof t||!isNaN(Number(t)));if(Array.isArray(o))return i.scaleOrdinal().domain(r).range(o).unknown("#999");const s=S[o]||S.category10;if(n&&"function"==typeof s){let t=-1/0;for(const e of r){const i=Number(e);i>t&&(t=i)}return e=>s(Number(e)/t)}{const t=Array.isArray(s)?s:_;return i.scaleOrdinal().domain(r).range(t).unknown("#999")}}function O(t,e,i){var o,r,n;if(1>=i)return 1;const s=null!==(o=t.minOpacity)&&void 0!==o?o:.1,a=i-1-e;switch(t.type){case"linear":return s+(1-a/(i-1))*(1-s);case"exponential":{const e=null!==(r=t.halfLife)&&void 0!==r?r:i/2;return s+Math.pow(.5,a/e)*(1-s)}case"step":return(null!==(n=t.stepThreshold)&&void 0!==n?n:.5*i)>a?1:s;default:return 1}}function T(t,e,i){var o;const r=null!==(o=t.duration)&&void 0!==o?o:500,n=i-e;return r>n?1-n/r:0}function L(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function E(t,e){return Math.min((t-e.startTime)/e.duration,1)}function D(t,e,i){return t+(e-t)*i}function z(){return"undefined"!=typeof performance?performance.now():Date.now()}function $(t,e,i){var o,r,n,s;if(e._transitionKey)return e._transitionKey;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const i=t.getX(e.datum),o=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${i}:${o}`;if(null!=i&&null!=o)return`p:${i}:${o}`}return"p:"+i;case"rect":return`r:${e.group||""}:${null!==(s=null!==(r=null===(o=e.datum)||void 0===o?void 0:o.binStart)&&void 0!==r?r:null===(n=e.datum)||void 0===n?void 0:n.category)&&void 0!==s?s:i}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+i:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function C(t,e,i,o,r,n){const s=[];for(const r of t){const t=i(r),n=o(r);null==t||null==n||Number.isNaN(t)||Number.isNaN(n)||s.push({px:e.x(t),py:e.y(n),rawY:n,d:r})}s.sort((t,e)=>t.px-e.px);const a=Array(s.length),c=Array(s.length),l=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];a[t]=[e.px,e.py],c[t]=e.rawY,l[t]=e.d}return{type:"line",path:a,rawValues:c,style:r,datum:l,group:n}}function R(t,e,i,o,r,n,s,a){const c=[];for(const n of t){const t=i(n),s=o(n);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))continue;const l=e.x(t),u=a?a(n):r;c.push({px:l,topY:e.y(s),botY:e.y(u)})}c.sort((t,e)=>t.px-e.px);const l=Array(c.length),u=Array(c.length);for(let t=0;c.length>t;t++){const e=c[t];l[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:l,bottomPath:u,style:n,datum:t,group:s}}function N(t,e,i,o,r,n,s){const a=i(t),c=o(t);if(null==a||null==c||Number.isNaN(a)||Number.isNaN(c))return null;const l={type:"point",x:e.x(a),y:e.y(c),r:r,style:n,datum:t};return void 0!==s&&(l.pointId=s),l}function B(t,e,i,o,r,n,s){return{type:"rect",x:t,y:e,w:i,h:o,style:r,datum:n,group:s}}function W(t,e,i,o,r,n,s){const a={type:"heatcell",x:t,y:e,w:i,h:o,fill:r,datum:n};return(null==s?void 0:s.showValues)&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function F(t,e,i){if(!t.getBounds||!t.scales)return null;const o=[],r=[];for(const i of e){const e=t.getX(i),n=t.getY(i);if(null==e||null==n||Number.isNaN(e)||Number.isNaN(n))continue;const s=t.getBounds(i),a=t.scales.x(e);if(s&&0!==s)o.push([a,t.scales.y(n+s)]),r.push([a,t.scales.y(n-s)]);else{const e=t.scales.y(n);o.push([a,e]),r.push([a,e])}}return 2>o.length?null:{type:"area",topPath:o,bottomPath:r,style:t.resolveBoundsStyle(i,e[0]),datum:e,group:i,interactive:!1}}function Y(t,e,i,o){var r;if(!t.config.pointStyle)return;const n=null!=o?o:t.getY;for(const o of e){const e=t.resolveGroupColor(o.key);for(const s of o.data){let o=t.config.pointStyle(s);!o.fill&&e&&(o=Object.assign(Object.assign({},o),{fill:e}));const a=null!==(r=o.r)&&void 0!==r?r:3,c=t.getPointId?t.getPointId(s)+"":void 0,l=N(s,t.scales,t.getX,n,a,o,c);l&&i.push(l)}}}const I={blues:r.interpolateBlues,reds:r.interpolateReds,greens:r.interpolateGreens,viridis:r.interpolateViridis,oranges:r.interpolateOranges,purples:r.interpolatePurples,greys:r.interpolateGreys,plasma:r.interpolatePlasma,inferno:r.interpolateInferno,magma:r.interpolateMagma,cividis:r.interpolateCividis,turbo:r.interpolateTurbo},X=new Map;class q{constructor(t){if(this.xExtent=new x,this.yExtent=new x,this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.xIsDate=!1,this._quadtree=null,this._maxPointRadius=0,this.config=t,this.buffer=new m(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=k(t.timeAccessor||t.xAccessor,"time"),this.getY=k(t.valueAccessor||t.yAccessor,"value")):(this.getX=k(t.xAccessor,"x"),this.getY=k(t.yAccessor,"y")),this.getGroup=w(t.groupAccessor),this.getCategory=w(t.categoryAccessor),this.getSize=t.sizeAccessor?k(t.sizeAccessor,"size"):void 0,this.getColor=w(t.colorAccessor),this.getBounds=t.boundsAccessor?k(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?k(t.y0Accessor,"y0"):void 0,this.getPointId=w(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,i=null!=t.closeAccessor;this.getOpen=e?k(t.openAccessor,"open"):void 0,this.getHigh=k(t.highAccessor,"high"),this.getLow=k(t.lowAccessor,"low"),this.getClose=i?k(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!i}t.pulse&&(this.timestampBuffer=new m(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?k(this.config.timeAccessor||this.config.xAccessor,"time"):k(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],i=this.config.xAccessor,o="function"==typeof i?i(e):e[i||"x"],r=o instanceof Date,n="string"==typeof o&&o.length>=10&&!isNaN(new Date(o).getTime())&&isNaN(Number(o));if(this.xIsDate=r||n,n){const t="string"==typeof i?i:void 0;this.getX=t?e=>+new Date(e[t]):t=>+(i(t)instanceof Date?i(t):new Date(i(t)))}}const i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(i)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(i)),this.yExtent.push(this.getLow(i))):(this.yExtent.push(this.getY(i)),this.getY0&&this.yExtent.push(this.getY0(i)))}else for(const i of t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity||1e6;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const t=this.buffer.push(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(i)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(i)),this.yExtent.push(this.getLow(i))):(this.yExtent.push(this.getY(i)),this.getY0&&this.yExtent.push(this.getY0(i))),null!=t&&(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):this.yExtent.evict(this.getY(t)))}return!0}computeScene(t){var e,o,r,n,s,a,c;const{config:l,buffer:u}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(e=this.config.scalePadding)&&void 0!==e?e:0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);if(this.xExtent.dirty&&this.xExtent.recalculate(u,this.getX),this.yExtent.dirty)if("candlestick"===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(),d=this.xExtent.extent,f=this.yExtent.extent;let g=l.xExtent?[null!==(o=l.xExtent[0])&&void 0!==o?o:d[0],null!==(r=l.xExtent[1])&&void 0!==r?r:d[1]]:d,y=l.yExtent?[null!==(n=l.yExtent[0])&&void 0!==n?n:f[0],null!==(s=l.yExtent[1])&&void 0!==s?s:f[1]]:f;const p=l.yExtent&&null!=l.yExtent[0]&&null!=l.yExtent[1];if("stackedarea"===l.chartType&&!p&&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;let o=0;for(const t of e)for(const e of t.data){const t=this.getX(e),r=this.getY(e);if(null==t||null==r||Number.isNaN(t)||Number.isNaN(r))continue;const n=(i.get(t)||0)+r;i.set(t,n),n>o&&(o=n)}y=[0,o+(o>0?o*l.extentPadding:1)],this._stackExtentCache={key:t,yDomain:y}}}else if("bar"===l.chartType&&l.binSize&&!p&&u.size>0){const[,t]=function(t,e,i,o,r){const n=v(t,e,i,o,r);if(0===n.size)return[0,0];let s=0;for(const t of n.values())t.total>s&&(s=t.total);return[0,s]}(u,this.getX,this.getY,l.binSize,this.getCategory);y=[0,t+t*l.extentPadding]}else if("waterfall"===l.chartType&&!p&&u.size>0){const[t,e]=function(t,e){let i=0,o=0,r=0;for(const n of t){const t=e(n);null==t||Number.isNaN(t)||(r+=t,i>r&&(i=r),r>o&&(o=r))}return[i,o]}(u,this.getY),i=e-t,o=i>0?i*l.extentPadding:1;y=[Math.min(0,t-Math.abs(o)),Math.max(0,e+Math.abs(o))]}else if(!p&&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===(a=l.yExtent)||void 0===a?void 0:a[0],o=null===(c=l.yExtent)||void 0===c?void 0:c[1];y=[null!=i?y[0]:y[0]-e,null!=o?y[1]:y[1]+e],"log"===l.yScaleType&&0>=y[0]&&f[0]>0&&(y[0]=null!=i?y[0]:f[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 m="streaming"===l.runtimeMode,x=Math.max(0,Math.min(l.scalePadding||0,Math.min(t.width,t.height)/2-1));if(m)if("x"==("up"===(b=l.arrowOfTime)||"down"===b?"y":"x")){const e="right"===l.arrowOfTime?[x,t.width-x]:[t.width-x,x];this.scales={x:i.scaleLinear().domain(g).range(e),y:i.scaleLinear().domain(y).range([t.height-x,x])}}else{const e="down"===l.arrowOfTime?[x,t.height-x]:[t.height-x,x];this.scales={x:i.scaleLinear().domain(y).range([x,t.width-x]),y:i.scaleLinear().domain(g).range(e)}}else{const e=(t,e,o)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return i.scaleLog().domain(t).range(o).clamp(!0)}return"time"===t?i.scaleTime().domain([new Date(e[0]),new Date(e[1])]).range(o):i.scaleLinear().domain(e).range(o)};this.scales={x:e(l.xScaleType,g,[x,t.width-x]),y:e(l.yScaleType,y,[t.height-x,x])}}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._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}rebuildQuadtree(){const t=this.config.chartType;if("scatter"!==t&&"bubble"!==t)return this._quadtree=null,void(this._maxPointRadius=0);let e=0,i=0;for(const t of this.scene)"point"===t.type&&(e++,t.r>i&&(i=t.r));if(this._maxPointRadius=i,q.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const r=Array(e);let n=0;for(const t of this.scene)"point"===t.type&&(r[n++]=t);this._quadtree=o.quadtree().x(t=>t.x).y(t=>t.y).addAll(r)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}remapScene(t){const e=t.width/this.lastLayout.width,o=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const i of t.path)i[0]*=e,i[1]*=o;break;case"area":for(const i of t.topPath)i[0]*=e,i[1]*=o;for(const i of t.bottomPath)i[0]*=e,i[1]*=o;break;case"point":t.x*=e,t.y*=o;break;case"rect":case"heatcell":t.x*=e,t.y*=o,t.w*=e,t.h*=o;break;case"candlestick":t.x*=e,t.openY*=o,t.closeY*=o,t.highY*=o,t.lowY*=o}const r=this.scales.x.domain(),n=this.scales.y.domain(),s=this.scales.x.range(),a=this.scales.y.range(),c=(t,e,o)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return i.scaleLog().domain(t).range(o).clamp(!0)}return"time"===t?i.scaleTime().domain([new Date(e[0]),new Date(e[1])]).range(o):i.scaleLinear().domain(e).range(o)},l=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),u=a[1]>a[0];this.scales={x:c(this.config.xScaleType,r,s[0]>s[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 s={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 o=t.groupData(e),r=[],n=null===(i=t.config.annotations)||void 0===i?void 0:i.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.getBounds)for(const e of o){const i=F(t,e.data,e.key);i&&r.push(i)}for(const e of o){const i=t.resolveLineStyle(e.key,e.data[0]),o=C(e.data,t.scales,t.getX,t.getY,i,e.key);n&&n.length>0&&(o.colorThresholds=n),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),r.push(o)}return Y(t,o,r),r}(s,e);case"area":return function(t,e){const i=t.groupData(e),o=[],r=t.scales.y.domain()[0],n=t.getY0?e=>{const i=t.getY0(e);return null==i?r:i}:void 0;for(const e of i){const i=t.resolveAreaStyle(e.key,e.data[0]),s=R(e.data,t.scales,t.getX,t.getY,r,i,e.key,n);t.config.gradientFill&&(s.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),o.push(s)}return Y(t,i,o),o}(s,e);case"mixed":return function(t,e){const i=t.groupData(e),o=[],r=t.config.areaGroups||new Set,n=t.scales.y.domain()[0],s=t.getY0?e=>{const i=t.getY0(e);return null==i?n:i}:void 0;for(const e of i)if(r.has(e.key)){const i=t.resolveAreaStyle(e.key,e.data[0]),r=R(e.data,t.scales,t.getX,t.getY,n,i,e.key,s);t.config.gradientFill&&(r.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}else{const i=t.resolveLineStyle(e.key,e.data[0]),r=C(e.data,t.scales,t.getX,t.getY,i,e.key);t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}return Y(t,i,o),o}(s,e);case"stackedarea":return function(t,e){const i=t.groupData(e);i.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);const o=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,{nodes:r,stackedTops:n}=function(t,e,i,o,r,n,s){var a;const c=new Set;for(const e of t)for(const t of e.data){const e=i(t);null==e||Number.isNaN(e)||c.add(e)}const l=Array.from(c).sort((t,e)=>t-e),u=new Map;for(const e of t){const t=new Map;for(const r of e.data){const e=i(r),n=o(r);null==e||null==n||Number.isNaN(e)||Number.isNaN(n)||t.set(e,(t.get(e)||0)+n)}u.set(e.key,t)}let h;if(n){h=new Map;for(const e of l){let i=0;for(const o of t)i+=(null===(a=u.get(o.key))||void 0===a?void 0:a.get(e))||0;h.set(e,i||1)}}const d=[],f=new Map,g=new Map;for(const t of l)g.set(t,0);for(const i of t){const t=u.get(i.key),o=[],a=[],c=new Map;for(const i of l){let r=t.get(i)||0;const s=g.get(i);n&&(r/=h.get(i));const l=s+r,u=e.x(i);a.push([u,e.y(s)]),o.push([u,e.y(l)]),g.set(i,l),c.set(i,l)}f.set(i.key,c);const y={type:"area",topPath:o,bottomPath:a,style:r(i.key,i.data[0]),datum:i.data,group:i.key};s&&(y.curve=s),d.push(y)}return{nodes:d,stackedTops:f}}(i,t.scales,t.getX,t.getY,(e,i)=>t.resolveAreaStyle(e,i),t.config.normalize,o),s=r;if(t.config.pointStyle){const e=new WeakMap;for(const o of i){const i=n.get(o.key);if(i)for(const r of o.data){const o=t.getX(r),n=t.getY(r);null==o||Number.isNaN(o)||null==n||Number.isNaN(n)||!i.has(o)||e.set(r,i.get(o))}}const o=i=>{var o;return null!==(o=e.get(i))&&void 0!==o?o:t.getY(i)};Y(t,i,s,o)}return s}(s,e);case"scatter":case"bubble":return function(t,e){var i;const o=[],r="bubble"===t.config.chartType?10:5,n=t.config.sizeRange||[3,15];let s=null;if(t.getSize&&!t.config.pointStyle){const i=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(i.length>0){let t=1/0,e=-1/0;for(const o of i)t>o&&(t=o),o>e&&(e=o);s=i=>t===e?(n[0]+n[1])/2:n[0]+(i-t)/(e-t)*(n[1]-n[0])}}const a=t.getColor?t.resolveColorMap(e):null,c=(null===(i=t.config.themeSemantic)||void 0===i?void 0:i.primary)||"#4e79a7";for(const i of e){let e=t.config.pointStyle?t.config.pointStyle(i):{fill:c,opacity:.8},n=e.r||r;if(s&&t.getSize){const e=t.getSize(i);null==e||Number.isNaN(e)||(n=s(e))}if(a&&t.getColor&&!e.fill){const o=t.getColor(i);o&&a.has(o)&&(e=Object.assign(Object.assign({},e),{fill:a.get(o)}))}const l=t.getPointId?t.getPointId(i)+"":void 0,u=N(i,t.scales,t.getX,t.getY,n,e,l);u&&o.push(u)}return o}(s,e);case"heatmap":return function(t,e,i){if(t.config.heatmapAggregation)return function(t,e,i){var o,r,n;const s=Math.max(1,Math.floor(null!==(o=t.config.heatmapXBins)&&void 0!==o?o:20)),a=Math.max(1,Math.floor(null!==(r=t.config.heatmapYBins)&&void 0!==r?r:20)),c=null!==(n=t.config.heatmapAggregation)&&void 0!==n?n:"count",l=k(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,h]=t.scales.x.domain(),[d,f]=t.scales.y.domain(),g=(h-u||1)/s,y=(f-d||1)/a,p=s*a;if(p>1e6)return[];const m=new Int32Array(p),x=new Float64Array(p);for(let i=0;e.length>i;i++){const o=e[i],r=t.getX(o),n=t.getY(o);if(!isFinite(r)||!isFinite(n))continue;const c=Math.min(Math.floor((r-u)/g),s-1),h=Math.min(Math.floor((n-d)/y),a-1);if(0>c||0>h)continue;const f=h*s+c;m[f]++;const p=l(o);x[f]+=isFinite(p)?p:0}let v=1/0,b=-1/0;for(let t=0;p>t;t++){if(0===m[t])continue;let e;switch(c){case"sum":e=x[t];break;case"mean":e=x[t]/m[t];break;default:e=m[t]}v>e&&(v=e),e>b&&(b=e)}if(!isFinite(v))return[];const A=b-v||1,w=i.width/s,S=i.height/a,_=t.config.showValues,P=t.config.heatmapValueFormat,j=[];for(let t=0;a>t;t++){const e=t*s;for(let i=0;s>i;i++){const o=e+i;if(0===m[o])continue;let r;switch(c){case"sum":r=x[o];break;case"mean":r=x[o]/m[o];break;default:r=m[o]}const n=(r-v)/A;j.push(W(i*w,(a-1-t)*S,w,S,`rgb(${220-(180*n+.5)|0},${220-(100*n+.5)|0},${255-(50*n+.5)|0})`,{xi:i,yi:t,value:r,count:m[o],sum:x[o]},_?{value:r,showValues:!0,valueFormat:P}:void 0))}}return j}(t,e,i);if(0===e.length)return[];const o=k(t.config.valueAccessor,"value"),n=A(t.config.xAccessor,"x"),s=A(t.config.yAccessor,"y"),a=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],o=n(i),r=s(i);l[t]=o,u[t]=r,a.has(o)||a.set(o,a.size),c.has(r)||c.set(r,c.size)}const h=a.size,d=c.size;if(0===h||0===d)return[];const f=Array.from(a.keys()),g=Array.from(c.keys()),y=f.every(t=>"number"==typeof t&&!isNaN(t)),p=g.every(t=>"number"==typeof t&&!isNaN(t));if(y){f.sort((t,e)=>t-e),a.clear();for(let t=0;f.length>t;t++)a.set(f[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),x=new Float64Array(e.length),v=Array(e.length),b=new Map;let w=0;for(let t=0;e.length>t;t++){const i=e[t],r=a.get(l[t]),n=c.get(u[t]);if(void 0===r||void 0===n)continue;const s=o(i),d=n*h+r,f=b.get(d);let g;void 0!==f?g=f:(g=w++,b.set(d,g)),m[g]=d,x[g]=s,v[g]=i}let S=1/0,_=-1/0;for(let t=0;w>t;t++){const e=x[t];isFinite(e)&&(S>e&&(S=e),e>_&&(_=e))}if(!isFinite(S)||!isFinite(_))return[];const P=function(t){const e=t in I?t:"blues";let i=X.get(e);if(i)return i;i=Array(256);const o=I[e]||r.interpolateBlues;for(let t=0;256>t;t++)i[t]=o(t/255);return X.set(e,i),i}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),j=255/(_-S||1),M=i.width/h,O=i.height/d,T=t.config.showValues,L=t.config.heatmapValueFormat,E=[];for(let t=0;w>t;t++){const e=x[t];if(!isFinite(e))continue;const i=m[t],o=i%h;E.push(W(o*M,(d-1-(i-o)/h)*O,M,O,P[Math.min((e-S)*j+.5|0,255)],v[t],T?{value:e,showValues:!0,valueFormat:L}:void 0))}return E}(s,e,t);case"bar":{const t=function(t,e){var i,o;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const r=v(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===r.size)return{nodes:[],binBoundaries:[]};let n=null;if(t.getCategory){const e=new Set;for(const t of r.values())for(const i of t.categories.keys())e.add(i);const i=t.config.barColors?Object.keys(t.config.barColors):[],o=new Set(i),s=Array.from(e).filter(t=>!o.has(t)).sort(),a=i.filter(t=>e.has(t)),c=a.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===c?n=t.barCategoryCache.order:(n=[...a,...s],t.barCategoryCache={key:c,order:n})}const s=[],a=t.scales,[c,l]=a.x.domain(),u=t.config.barStyle,h=null===(i=t.config.themeSemantic)||void 0===i?void 0:i.primary,d=null==u?void 0:u.gap,f="number"!=typeof d||0>d?1:d,g={};(null==u?void 0:u.stroke)&&(g.stroke=u.stroke),"number"==typeof(null==u?void 0:u.strokeWidth)&&(g.strokeWidth=u.strokeWidth),"number"==typeof(null==u?void 0:u.opacity)&&(g.opacity=u.opacity);for(const e of r.values()){const i=Math.max(e.start,c),r=Math.min(e.end,l);if(i>=r)continue;const d=a.x(i),y=a.x(r),p=Math.abs(y-d),m=p>f+1?f:0,x=Math.min(d,y)+m/2,v=Math.max(p-m,1);if(v>0)if(n&&e.categories.size>0){let i=0;for(const r of n){const n=e.categories.get(r)||0;if(0===n)continue;const c=a.y(i),l=a.y(i+n),d=(null===(o=t.config.barColors)||void 0===o?void 0:o[r])||(null==u?void 0:u.fill)||h||"#4e79a7";s.push(B(x,Math.min(c,l),v,Math.abs(c-l),Object.assign({fill:d},g),{binStart:e.start,binEnd:e.end,total:e.total,category:r,categoryValue:n},r)),i+=n}}else{const t=a.y(0),i=a.y(e.total);s.push(B(x,Math.min(t,i),v,Math.abs(t-i),Object.assign({fill:(null==u?void 0:u.fill)||h||"#007bff"},g),{binStart:e.start,binEnd:e.end,total:e.total}))}}const y=new Set;for(const t of r.values())y.add(t.start),y.add(t.end);return{nodes:s,binBoundaries:Array.from(y).sort((t,e)=>t-e)}}(s,e);return this._barCategoryCache=null!==(i=s.barCategoryCache)&&void 0!==i?i:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var i,o,r,n,s,a;const c=[],l=t.config.swarmStyle||{},u=null!==(i=l.radius)&&void 0!==i?i:3,h=null!==(n=null!==(o=l.fill)&&void 0!==o?o:null===(r=t.config.themeSemantic)||void 0===r?void 0:r.primary)&&void 0!==n?n:"#007bff",d=null!==(s=l.opacity)&&void 0!==s?s:.7,f=l.stroke,g=l.strokeWidth;for(const i of e){const e=t.getX(i),o=t.getY(i);if(null==o||Number.isNaN(o))continue;const r=t.scales.x(e),n=t.scales.y(o);let s=h;if(t.getCategory){const e=t.getCategory(i);s=(null===(a=t.config.barColors)||void 0===a?void 0:a[e])||s}const l={type:"point",x:r,y:n,r:u,style:{fill:s,opacity:d,stroke:f,strokeWidth:g},datum:i};t.getPointId&&(l.pointId=t.getPointId(i)+""),c.push(l)}return c}(s,e);case"waterfall":return function(t,e,i){var o,r,n,s,a,c,l;const u=[],h=t.scales,d=t.config.waterfallStyle,f=e.filter(e=>{const i=t.getY(e),o=t.getX(e);return null!=i&&!Number.isNaN(i)&&null!=o&&isFinite(o)});if(0===f.length)return u;const g=null!==(n=null!==(o=null==d?void 0:d.positiveColor)&&void 0!==o?o:null===(r=t.config.themeSemantic)||void 0===r?void 0:r.success)&&void 0!==n?n:"#28a745",y=null!==(c=null!==(s=null==d?void 0:d.negativeColor)&&void 0!==s?s:null===(a=t.config.themeSemantic)||void 0===a?void 0:a.danger)&&void 0!==c?c:"#dc3545",p=null!==(l=null==d?void 0:d.gap)&&void 0!==l?l:1,m=null==d?void 0:d.stroke,x=null==d?void 0:d.strokeWidth,v=null==d?void 0:d.opacity;let b=0;for(let e=0;f.length>e;e++){const o=f[e],r=t.getX(o),n=t.getY(o),s=b+n;let a;a=f.length-1>e?t.getX(f[e+1])-r:e>0?r-t.getX(f[e-1]):0;const c=h.x(r),l=0!==a?h.x(r+a):c+i.width/10,k=Math.min(c,l)+p/2,A=Math.max(c,l)-p/2-k;if(0>=A){b=s;continue}const w=h.y(b),S=h.y(s),_=Math.min(w,S),P=Math.abs(w-S),j={fill:0>n?y:g,stroke:m,strokeWidth:x};null!=v&&(j.opacity=v),u.push(B(k,_,A,P,j,Object.assign(Object.assign({},o),{baseline:b,cumEnd:s,delta:n,_connectorStroke:null==d?void 0:d.connectorStroke,_connectorWidth:null==d?void 0:d.connectorWidth}))),b=s}return u}(s,e,t);case"candlestick":return function(t,e){var i,o;if(!t.getHigh||!t.getLow||!t.scales)return[];const r=null!==(i=t.config.candlestickRangeMode)&&void 0!==i&&i;if(!(r||t.getOpen&&t.getClose))return[];const n=[],s=t.config.candlestickStyle||{},a=s.rangeColor||"#6366f1",c=r?a:s.upColor||"#28a745",l=r?a:s.downColor||"#dc3545",u=r?a:s.wickColor||"#333",h=s.wickWidth||(r?2:1),d=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let f=null!==(o=s.bodyWidth)&&void 0!==o?o:0;if(null==s.bodyWidth)if(d.length>1){let e=1/0;for(let i=1;d.length>i;i++){const o=Math.abs(t.scales.x(d[i])-t.scales.x(d[i-1]));o>0&&e>o&&(e=o)}f=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else f=6;for(const i of e){const e=t.getX(i);if(null==e||Number.isNaN(e))continue;const o=t.getHigh(i),s=t.getLow(i);if(null==o||Number.isNaN(o)||null==s||Number.isNaN(s))continue;const a=r?o:t.getOpen(i),d=r?s:t.getClose(i);if(!r&&[a,d].some(t=>null==t||Number.isNaN(t)))continue;const g=d>=a,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(a),closeY:t.scales.y(d),highY:t.scales.y(o),lowY:t.scales.y(s),bodyWidth:f,upColor:c,downColor:l,wickColor:u,wickWidth:h,isUp:g,datum:i};r&&(y.isRange=!0),n.push(y)}return n}(s,e);default:return[]}}resolveBoundsStyle(t,e){var i;const o=this.config.boundsStyle;return"function"==typeof o?o(e||{},t):o&&"object"==typeof o?o:{fill:this.resolveLineStyle(t,e).stroke||(null===(i=this.config.themeSemantic)||void 0===i?void 0:i.primary)||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?O(i,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,i){var o,r;const n=i.length;if(1>=n)return;const s=new Map;for(let t=0;i.length>t;t++)s.set(i[t],t);for(const i of e){if("line"===i.type){const e=Array.isArray(i.datum)?i.datum:[];if(2>e.length)continue;const o=Array(e.length);let r=!1;for(let i=0;e.length>i;i++){const a=s.get(e[i]);null!=a?(o[i]=O(t,a,n),1>o[i]&&(r=!0)):o[i]=1}r&&(i._decayOpacities=o);continue}if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[],o=i.topPath?i.topPath.length:e.length;if(2>o)continue;if(e.length===o){const r=Array(o);let a=!1;for(let i=0;e.length>i;i++){const o=s.get(e[i]);null!=o?(r[i]=O(t,o,n),1>r[i]&&(a=!0)):r[i]=1}a&&(i._decayOpacities=r)}else{let r=1;for(const i of e){const e=s.get(i);if(null!=e){const i=O(t,e,n);r>i&&(r=i)}}if(1>r){const t=Array(o);t.fill(r),i._decayOpacities=t}}continue}const e=s.get(i.datum);if(null==e)continue;const a=O(t,e,n);if("heatcell"===i.type)i.style={opacity:a};else if("candlestick"===i.type)i._decayOpacity=a;else{const t=null!==(r=null===(o=i.style)||void 0===o?void 0:o.opacity)&&void 0!==r?r:1;i.style=Object.assign(Object.assign({},i.style),{opacity:t*a})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,i,o){var r,n;const s="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(r=t.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",c=null!==(n=t.glowRadius)&&void 0!==n?n:4,l=new Map;for(let t=0;i.length>t;t++)l.set(i[t],t);for(const i of e){if("line"===i.type)continue;if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[i.datum];let r=0;for(const i of e){const e=l.get(i);if(null==e)continue;const n=o.get(e);if(null==n)continue;const a=T(t,n,s);a>r&&(r=a)}r>0&&(i._pulseIntensity=r,i._pulseColor=a);continue}const e=l.get(i.datum);if(null==e)continue;const r=o.get(e);if(null==r)continue;const n=T(t,r,s);n>0&&(i._pulseIntensity=n,i._pulseColor=a,i._pulseGlowRadius=c)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(t,e){var i;if(!e||0===e.size)return!1;const o="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(i=t.duration)&&void 0!==i?i:500,n=e.peek();return null!=n&&r>o-n}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,i,o){var r,n,s,a;i.clear(),o.clear();for(let c=0;e.length>c;c++){const l=e[c],u=$(t,l,c);u&&("point"===l.type?i.set(u,{x:l.x,y:l.y,r:l.r,opacity:l.style.opacity}):"rect"===l.type?i.set(u,{x:l.x,y:l.y,w:l.w,h:l.h,opacity:l.style.opacity}):"heatcell"===l.type?i.set(u,{x:l.x,y:l.y,w:l.w,h:l.h,opacity:null===(r=l.style)||void 0===r?void 0:r.opacity}):"candlestick"===l.type?i.set(u,{x:l.x,y:l.openY,w:l.bodyWidth,openY:l.openY,closeY:l.closeY,highY:l.highY,lowY:l.lowY,opacity:null===(n=l.style)||void 0===n?void 0:n.opacity}):"line"===l.type?o.set(u,{path:l.path.map(t=>[t[0],t[1]]),opacity:null===(s=l.style)||void 0===s?void 0:s.opacity}):"area"===l.type&&o.set(u,{topPath:l.topPath.map(t=>[t[0],t[1]]),bottomPath:l.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(a=l.style)||void 0===a?void 0:a.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){var t,e,i;this.prevPositionMap.clear(),this.prevPathMap.clear();const o=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.y(0))&&void 0!==e?e:0;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],r=$(this.transitionContext,e,t);r&&("point"===e.type?this.prevPositionMap.set(r,{x:e.x,y:e.y,r:0,opacity:0}):"rect"===e.type?this.prevPositionMap.set(r,{x:e.x,y:o,w:e.w,h:0,opacity:null!==(i=e.style.opacity)&&void 0!==i?i:1}):"heatcell"===e.type?this.prevPositionMap.set(r,{x:e.x,y:e.y,w:e.w,h:e.h,opacity:0}):"line"===e.type?(e._introClipFraction=0,this.prevPathMap.set(r,{path:e.path.map(t=>[t[0],t[1]]),opacity:e.style.opacity})):"area"===e.type&&(e._introClipFraction=0,this.prevPathMap.set(r,{topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),opacity:e.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,i,o,r){var n,s,a,c,l,u,h,d,f,g,y,p,m,x,v,b,k,A,w,S,_,P,j,M,O,T,L,E,D,C,R,N,B,W,F,Y,I,X,q,G,V;if(0===o.size&&0===r.size)return i;const H=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 Q=!1;const U=new Set,Z=new Set;for(let e=0;i.scene.length>e;e++){const n=i.scene[e],T=$(t,n,e);if(!T)continue;if(n._transitionKey=T,"line"===n.type||"area"===n.type){const t=r.get(T);if(t){if(Z.add(T),"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]];Q=!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]];Q=!0}n._targetOpacity=null!==(s=n.style.opacity)&&void 0!==s?s:1,n._startOpacity=null!==(c=null!==(a=t.opacity)&&void 0!==a?a:n.style.opacity)&&void 0!==c?c:1}else n._targetOpacity=null!==(l=n.style.opacity)&&void 0!==l?l:1,n._startOpacity=0,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),Q=!0;continue}const L=o.get(T);if("point"===n.type)if(L){U.add(T);const t={x:n.x,y:n.y,r:n.r};n._targetOpacity=null!==(u=n.style.opacity)&&void 0!==u?u:1,L.x===t.x&&L.y===t.y&&L.r===t.r||(n._targetX=t.x,n._targetY=t.y,n._targetR=t.r,n.x=L.x,n.y=L.y,n.r=null!==(h=L.r)&&void 0!==h?h:n.r,Q=!0)}else n._targetOpacity=null!==(d=n.style.opacity)&&void 0!==d?d:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),Q=!0;else if("rect"===n.type)if(L){U.add(T);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=null!==(f=n.style.opacity)&&void 0!==f?f:1,L.x===t.x&&L.y===t.y&&L.w===t.w&&L.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=L.x,n.y=L.y,n.w=null!==(g=L.w)&&void 0!==g?g:n.w,n.h=null!==(y=L.h)&&void 0!==y?y:n.h,Q=!0)}else n._targetOpacity=null!==(p=n.style.opacity)&&void 0!==p?p:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),Q=!0;else if("heatcell"===n.type)if(L){U.add(T);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,L.x===t.x&&L.y===t.y&&L.w===t.w&&L.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=L.x,n.y=L.y,n.w=null!==(v=L.w)&&void 0!==v?v:n.w,n.h=null!==(b=L.h)&&void 0!==b?b:n.h,Q=!0)}else n._targetOpacity=null!==(A=null===(k=n.style)||void 0===k?void 0:k.opacity)&&void 0!==A?A:1,n.style=Object.assign(Object.assign({},n.style||{}),{opacity:0}),Q=!0;else if("candlestick"===n.type)if(L&&null!=L.openY){U.add(T);const t={x:n.x,openY:n.openY,closeY:n.closeY,highY:n.highY,lowY:n.lowY};n._targetOpacity=null!==(S=null===(w=n.style)||void 0===w?void 0:w.opacity)&&void 0!==S?S:1,(L.x!==t.x||L.openY!==t.openY||L.closeY!==t.closeY||L.highY!==t.highY||L.lowY!==t.lowY)&&(n._targetX=t.x,n._targetOpenY=t.openY,n._targetCloseY=t.closeY,n._targetHighY=t.highY,n._targetLowY=t.lowY,n.x=L.x,n.openY=L.openY,n.closeY=null!==(_=L.closeY)&&void 0!==_?_:n.closeY,n.highY=null!==(P=L.highY)&&void 0!==P?P:n.highY,n.lowY=null!==(j=L.lowY)&&void 0!==j?j:n.lowY,Q=!0)}else n._targetOpacity=null!==(O=null===(M=n.style)||void 0===M?void 0:M.opacity)&&void 0!==O?O:1,n.style=Object.assign(Object.assign({},n.style||{}),{opacity:0}),Q=!0}for(const[t,e]of r)if(!Z.has(t))if(t.startsWith("l:")&&e.path){const o={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(T=e.opacity)&&void 0!==T?T:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),Q=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const o={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:null!==(L=e.opacity)&&void 0!==L?L:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),Q=!0}for(const[t,e]of o)if(!U.has(t)){if(t.startsWith("p:")){const o={type:"point",x:e.x,y:e.y,r:null!==(E=e.r)&&void 0!==E?E:3,style:{opacity:null!==(D=e.opacity)&&void 0!==D?D:1},datum:null,_targetOpacity:0,_transitionKey:t};i.exitNodes.push(o)}else if(t.startsWith("r:")){const o={type:"rect",x:e.x,y:e.y,w:null!==(C=e.w)&&void 0!==C?C:0,h:null!==(R=e.h)&&void 0!==R?R:0,style:{opacity:null!==(N=e.opacity)&&void 0!==N?N:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};i.exitNodes.push(o)}else if(t.startsWith("h:")){const o={type:"heatcell",x:e.x,y:e.y,w:null!==(B=e.w)&&void 0!==B?B:0,h:null!==(W=e.h)&&void 0!==W?W:0,fill:"#999",datum:null,style:{opacity:null!==(F=e.opacity)&&void 0!==F?F:1},_targetOpacity:0,_transitionKey:t};i.exitNodes.push(o)}else if(t.startsWith("c:")){const o=null!==(Y=e.openY)&&void 0!==Y?Y:e.y,r={type:"candlestick",x:e.x,openY:o,closeY:null!==(I=e.closeY)&&void 0!==I?I:o,highY:null!==(X=e.highY)&&void 0!==X?X:o,lowY:null!==(q=e.lowY)&&void 0!==q?q:o,bodyWidth:null!==(G=e.w)&&void 0!==G?G:6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:null!==(V=e.opacity)&&void 0!==V?V:1},_targetOpacity:0,_transitionKey:t};i.exitNodes.push(r)}Q=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),Q&&(i.activeTransition={startTime:z(),duration:H}),i}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},i=function(t,e,i,o){var r,n,s,a,c,l;if(!i.activeTransition)return!1;const u=E(t,i.activeTransition),h=L(u,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of i.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,n=i?null!==(r=i.opacity)&&void 0!==r?r:1:0;t.style.opacity=D(n,t._targetOpacity,h)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=D(i.x,t._targetX,h),t.y=D(i.y,t._targetY,h),void 0!==t._targetR&&void 0!==i.r&&(t.r=D(i.r,t._targetR,h))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,r=i?null!==(n=i.opacity)&&void 0!==n?n:1:0;t.style.opacity=D(r,t._targetOpacity,h)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=D(i.x,t._targetX,h),t.y=D(i.y,t._targetY,h),void 0!==i.w&&(t.w=D(i.w,t._targetW,h)),void 0!==i.h&&(t.h=D(i.h,t._targetH,h))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,r=i?null!==(s=i.opacity)&&void 0!==s?s:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:D(r,t._targetOpacity,h)})}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=D(i.x,t._targetX,h),t.y=D(i.y,t._targetY,h),void 0!==i.w&&(t.w=D(i.w,t._targetW,h)),void 0!==i.h&&(t.h=D(i.h,t._targetH,h))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,r=i?null!==(a=i.opacity)&&void 0!==a?a:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:D(r,t._targetOpacity,h)})}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=D(i.x,t._targetX,h),void 0!==i.openY&&(t.openY=D(i.openY,t._targetOpenY,h)),void 0!==i.closeY&&(t.closeY=D(i.closeY,t._targetCloseY,h)),void 0!==i.highY&&(t.highY=D(i.highY,t._targetHighY,h)),void 0!==i.lowY&&(t.lowY=D(i.lowY,t._targetLowY,h))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=null!==(c=t._startOpacity)&&void 0!==c?c:0;t.style=Object.assign(Object.assign({},t.style),{opacity:D(e,t._targetOpacity,h)})}void 0!==t._introClipFraction&&(t._introClipFraction=h);const e=t._prevPath,i=t._targetPath;if(e&&i&&e.length===t.path.length)for(let o=0;t.path.length>o;o++)t.path[o][0]=D(e[o][0],i[o][0],h),t.path[o][1]=D(e[o][1],i[o][1],h)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(l=t._startOpacity)&&void 0!==l?l:0;t.style=Object.assign(Object.assign({},t.style),{opacity:D(e,t._targetOpacity,h)})}void 0!==t._introClipFraction&&(t._introClipFraction=h);const e=t._prevTopPath,i=t._prevBottomPath,o=t._targetTopPath,r=t._targetBottomPath;if(e&&o&&e.length===t.topPath.length)for(let i=0;t.topPath.length>i;i++)t.topPath[i][0]=D(e[i][0],o[i][0],h),t.topPath[i][1]=D(e[i][1],o[i][1],h);if(i&&r&&i.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=D(i[e][0],r[e][0],h),t.bottomPath[e][1]=D(i[e][1],r[e][1],h)}}if(u>=1){for(const t of i.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style=Object.assign(Object.assign({},"line"===t.type||"area"===t.type?t.style:t.style||{}),{opacity:0===e?0:e}),t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("candlestick"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let i=0;t.path.length>i;i++)t.path[i]=e[i];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,i=t._targetBottomPath;if(e)for(let i=0;t.topPath.length>i;i++)t.topPath[i]=e[i];if(i)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=i[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}return i.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,i}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const i of t){const t=this.getGroup(i);e.has(t)||e.set(t,[]),e.get(t).push(i)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveColorMap(t){if(this._colorMapCache&&this._colorMapCache.version===this._ingestVersion)return this._colorMapCache.map;const e=new Set;for(const i of t){const t=this.getColor(i);t&&e.add(t)}const i=Array.from(e).sort(),o=i.join("\0");if(this._colorMapCache&&this._colorMapCache.key===o)return this._colorMapCache.version=this._ingestVersion,this._colorMapCache.map;const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||P,n=new Map;for(let t=0;i.length>t;t++)n.set(i[t],r[t%r.length]);return this._colorMapCache={key:o,map:n,version:this._ingestVersion},n}resolveLineStyle(t,e){var i;const o=this.config.lineStyle;if("function"==typeof o){const i=o(e||{},t);if(i&&!i.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{stroke:e})}return i}const r=null===(i=this.config.themeSemantic)||void 0===i?void 0:i.primary;return o&&"object"==typeof o?{stroke:o.stroke||r||"#007bff",strokeWidth:o.strokeWidth||2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity}:{stroke:this.resolveGroupColor(t)||r||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var i,o;if(this.config.areaStyle){const i=this.config.areaStyle(e||{});if(i&&!i.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{fill:e,stroke:i.stroke||e})}return i}const r=this.config.lineStyle;if("function"==typeof r){const i=r(e||{},t);if(i&&!i.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{fill:e,stroke:i.stroke||e})}return i}const n=null===(i=this.config.themeSemantic)||void 0===i?void 0:i.primary;if(r&&"object"==typeof r)return{fill:r.fill||r.stroke||n||"#4e79a7",fillOpacity:null!==(o=r.fillOpacity)&&void 0!==o?o:.7,stroke:r.stroke||n||"#4e79a7",strokeWidth:r.strokeWidth||2};const s=this.resolveGroupColor(t)||n||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}resolveGroupColor(t){if(this._colorMapCache){const e=this._colorMapCache.map.get(t);if(e)return e}const e=this._groupColorMap.get(t);if(e)return e;const i=(Array.isArray(this.config.colorScheme)&&this.config.colorScheme.length>0?this.config.colorScheme:null)||(Array.isArray(this.config.themeCategorical)&&this.config.themeCategorical.length>0?this.config.themeCategorical:null)||P;if(0===i.length)return null;const o=i[this._groupColorCounter%i.length];if(this._groupColorCounter++,this._groupColorMap.set(t,o),this._groupColorMap.size>q.GROUP_COLOR_MAP_CAP){const t=this._groupColorMap.keys().next().value;void 0!==t&&this._groupColorMap.delete(t)}return o}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),i=this.getPointId,o=t=>e.has(i(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,i)=>{o(t)&&e.add(i)}),this.timestampBuffer.clear();for(let i=0;t.length>i;i++)e.has(i)||this.timestampBuffer.push(t[i])}const r=this.buffer.remove(o);if(0===r.length)return r;for(const t of r)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,r}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const i=new Set(Array.isArray(t)?t:[t]),o=this.getPointId,r=new Set;this.buffer.forEach((t,e)=>{i.has(o(t))&&r.add(e)});const n=this.buffer.update(t=>i.has(o(t)),e);if(0===n.length)return n;for(const t of n)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.buffer.forEach((t,e)=>{r.has(e)&&(this.xExtent.push(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))):(this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,n}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._maxPointRadius=0,this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(t){var e,i,o,r;const n=Object.assign({},this.config);("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(this._stackExtentCache=null);let s=!1;Object.assign(this.config,t);const a="chartType"in t&&t.chartType!==n.chartType||"runtimeMode"in t&&t.runtimeMode!==n.runtimeMode;if(a||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const c=a||!b(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(i=n.xAccessor)&&void 0!==i?i:n.timeAccessor),l=a||!b(null!==(o=t.yAccessor)&&void 0!==o?o:t.valueAccessor,null!==(r=n.yAccessor)&&void 0!==r?r:n.valueAccessor);(c||l)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=k(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=k(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=k(this.config.xAccessor,"x"),this.getY=k(this.config.yAccessor,"y")),s=!0)}if("groupAccessor"in t&&!b(t.groupAccessor,n.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?w(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!b(t.categoryAccessor,n.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?w(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!b(t.sizeAccessor,n.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?k(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in t&&!b(t.colorAccessor,n.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?w(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!b(t.y0Accessor,n.y0Accessor)&&(this.getY0=this.config.y0Accessor?k(this.config.y0Accessor,"y0"):void 0,s=!0),"pointIdAccessor"in t&&!b(t.pointIdAccessor,n.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?w(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&("openAccessor"in t&&!b(t.openAccessor,n.openAccessor)||"closeAccessor"in t&&!b(t.closeAccessor,n.closeAccessor)||"highAccessor"in t&&!b(t.highAccessor,n.highAccessor)||"lowAccessor"in t&&!b(t.lowAccessor,n.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?k(this.config.openAccessor,"open"):void 0,this.getHigh=k(this.config.highAccessor,"high"),this.getLow=k(this.config.lowAccessor,"low"),this.getClose=e?k(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,s=!0}if(!s){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const i of e)if(t[i]!==n[i]){s=!0;break}}s&&(this.needsFullRebuild=!0)}}function G(t,e){var i=t.get(e);if(!i)throw Error("missing: "+e);return i}function V(t,e){var i,o=[],r=[],n=[],s={},a=[];function c(t){n[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],n[e]&&c(e)})}function l(t){var e,o,h=!1;for(r.push(t),n[t]=!0,e=0;a[t].length>e;e++)(o=a[t][e])===i?(u(i,r),h=!0):n[o]||(h=l(o));if(h)c(t);else for(e=0;a[t].length>e;e++){var d=s[o=a[t][e]];d||(s[o]=d={}),d[o]=!0}return r.pop(),h}function u(t,e){var i=[].concat(e).concat(t);o.push(i)}function h(e){!function(e){for(var i=0;t.length>i;i++)i>=e&&t[i]||(t[i]=[]),t[i]=t[i].filter(function(t){return t>=e})}(e);for(var i,o=function(t){for(var e=t.length,i=Array(e),o=Array(e),r=Array(e),n=Array(e),s=Array(e),a=Array(e),c=0;e>c;++c)i[c]=-1,o[c]=0,r[c]=!1,n[c]=0,s[c]=-1,a[c]=[];var l,u=0,h=[],d=[];function f(e){var c=[e],l=[e];for(i[e]=o[e]=u,r[e]=!0,u+=1;l.length>0;){var f=t[e=l[l.length-1]];if(f.length>n[e]){for(var g=n[e];f.length>g;++g){var y=f[g];if(0>i[y]){i[y]=o[y]=u,r[y]=!0,u+=1,c.push(y),l.push(y);break}r[y]&&(o[e]=0|Math.min(o[e],o[y])),0>s[y]||a[e].push(s[y])}n[e]=g}else{if(o[e]===i[e]){var p=[],m=[],x=0;for(g=c.length-1;g>=0;--g){var v=c[g];if(r[v]=!1,p.push(v),m.push(a[v]),x+=a[v].length,s[v]=h.length,v===e){c.length=g;break}}h.push(p);var b=Array(x);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)b[--x]=m[g][k];d.push(b)}l.pop()}}}for(c=0;e>c;++c)0>i[c]&&f(c);for(c=0;d.length>c;c++){var g=d[c];if(0!==g.length){g.sort(function(t,e){return t-e}),l=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&l.push(g[y]);d[c]=l}}return{components:h,adjacencyList:d}}(t),r=o.components.filter(function(t){return t.length>1}),n=1/0,s=0;r.length>s;s++)for(var a=0;r[s].length>a;a++)n>r[s][a]&&(n=r[s][a],i=s);var c=r[i];if(!c)return!1;var l=t.map(function(t,e){return-1===c.indexOf(e)?[]:t.filter(function(t){return-1!==c.indexOf(t)})});return{leastVertex:n,adjList:l}}i=0;for(var d=t.length;d>i;){var f=h(i);if(i=f.leastVertex,a=f.adjList){for(var g=0;a.length>g;g++)for(var y=0;a[g].length>y;y++){var p=a[g][y];n[+p]=!1,s[p]={}}l(i),i+=1}else i=d}return o}function H(t){return t.y0-t.y1>0?"up":"down"}function Q(t,e){return e(t.source)==e(t.target)}function U(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 Z(t){return t.target.x0-t.source.x1}function K(t,e){var i=tt(t),o=Z(e)/Math.tan(i);return"up"==H(t)?t.y1-o:t.y1+o}function J(t,e){var i=tt(t),o=Z(e)/Math.tan(i);return"up"==H(t)?t.y1+o:t.y1-o}function tt(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function et(t,e){return e(t)}function it(t){return rt(t.source)}function ot(t){return rt(t.target)}function rt(t){return(t.y0+t.y1)/2}function nt(t){return t.virtual?0:t.value}function st(t,e){var i=0;t.sourceLinks.forEach(function(t){i=t.circular&&!Q(t,e)?i+1:i});var o=0;return t.targetLinks.forEach(function(t){o=t.circular&&!Q(t,e)?o+1:o}),i+o}function at(t){return t.target.depth}function ct(t,e){return t.sourceLinks.length?t.depth:e-1}function lt(t,e){return t.y0-e.y0}function ut(t,e){return e.y0-t.y0}function ht(t,e){return t.y1-e.y1}function dt(t,e){return e.y1-t.y1}function ft(t,e){return yt(t.source,e.source)||t.index-e.index}function gt(t,e){return yt(t.target,e.target)||t.index-e.index}function yt(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function pt(t,e){return mt(t)==mt(e)?"bottom"==t.circularLinkType?ut(t,e):lt(t,e):mt(e)-mt(t)}function mt(t){return t.target.column-t.source.column}function xt(t,e){return vt(t)==vt(e)}function vt(t){return t.y0-t.y1>0?"up":"down"}function bt(t,e,i,o,r){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=n.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}),kt(s.links.filter(function(t){return"top"==t.circularLinkType}),e,i),kt(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+o,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,Q(t,e)&&U(t))t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+r+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-r-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var n=t.source.column,a=t.circularLinkType,l=s.links.filter(function(t){return t.source.column==n&&t.circularLinkType==a});l.sort("bottom"==t.circularLinkType?ut:lt);var u=0;l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2+r*i+u),u+=e._circularWidth||e.width}),n=t.target.column,(l=s.links.filter(function(t){return t.target.column==n&&t.circularLinkType==a})).sort("bottom"==t.circularLinkType?dt:ht),u=0,l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2+r*i+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(s.y1,t.source.y1,t.target.y1)+r+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=c-r-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,i=t.y0,o=t.target.x0,r=t.y1,n=(e+o)/2;return"M"+e+","+i+"C"+n+","+i+" "+n+","+r+" "+o+","+r}(t)}),s}function kt(t,e,i){t.sort(pt);var o=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,r){var n=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(Q(t,e)&&U(t))t.circularPathData.verticalBuffer=n+t._circularWidth/2;else{for(var s=0;o.length>s;s++){var a=o[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&At(t,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+i;n=c>n?c:n}}t.circularPathData.verticalBuffer=n+t._circularWidth/2}}),t}function At(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function wt(t){return function(){return t}}function St(t){return t.index}function _t(t){return t.nodes}function Pt(t){return t.links}function jt(t,e,i){var o=n.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});o.forEach(function(r,n){var s=r.length;if(e)r.sort(e);else if(n>0){var a=new Map;r.forEach(function(t,e){var i,o,r,n=(o=0,r=0,(i=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=rt(t.source)*e,o+=e}}),i.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=rt(t.target)*e,o+=e}}),o>0?r/o:NaN);a.set(t,{bc:n,idx:e})}),r.sort(function(t,e){var i=a.get(t),o=a.get(e),r=i.bc,n=o.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(r)||isNaN(n)?isNaN(r)?isNaN(n)?i.idx-o.idx:1:-1:r-n})}else r.sort(function(t,e){return t.circularLinkType==e.circularLinkType?st(e,i)-st(t,i):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});r.forEach(function(e,r){e.depth==o.length-1&&1==s||0==e.depth&&1==s?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==st(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 Mt(t,e,i,o,r,s){var a=n.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 o=a.length;a.forEach(function(r){var s=r.length,a=r[0].depth;r.forEach(function(r){var c;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&st(r,i)>0){var l=n.mean(r.sourceLinks,ot),u=n.mean(r.targetLinks,it),h=l&&u?(l+u)/2:l||u;if(h){var d=(h-rt(r))*e*.3;r.y0+=d,r.y1+=d}}else if(0==a&&1==s)r.y0=t.y1/2-(c=r.y1-r.y0)/2,r.y1=t.y1/2+c/2;else if(a==o-1&&1==s)r.y0=t.y1/2-(c=r.y1-r.y0)/2,r.y1=t.y1/2+c/2;else if(1==r.targetLinks.length&&1==r.targetLinks[0].source.sourceLinks.length)c=r.y1-r.y0,r.y0=r.targetLinks[0].source.y0,r.y1=r.y0+c;else{var f=n.mean(r.sourceLinks,ot),g=n.mean(r.targetLinks,it),y=((f&&g?(f+g)/2:f||g)-rt(r))*e;r.y0+=y,r.y1+=y}})})}function h(){a.forEach(function(i){var n,s,a,c=t.y0,l=i.length;for(i.sort(e||yt),a=0;l>a;++a)(s=c-(n=i[a]).y0)>0&&(n.y0+=s,n.y1+=s),c=n.y1+o;if((s=c-o-t.y1)>0)for(c=n.y0-=s,n.y1-=s,a=l-2;a>=0;--a)(s=(n=i[a]).y1+r-c)>0&&(n.y0-=s,n.y1-=s),c=n.y0})}}function Ot(t){t.nodes.forEach(function(t){t.sourceLinks.sort(gt),t.targetLinks.sort(ft)}),t.nodes.forEach(function(t){var e=t.y0,i=e,o=t.y1,r=o;t.sourceLinks.forEach(function(t){t.circular?(t.y0=o-t.width/2,o-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=r-t.width/2,r-=t.width):(t.y1=i+t.width/2,i+=t.width)})})}function Tt(){var t=0,e=0,i=1,o=1,r=24,s=8,a=null,c=St,l=ct,u=void 0,h=32,d=2,f=_t,g=Pt;function y(){var y={nodes:f.apply(null,arguments),links:g.apply(null,arguments)};return function(f){f.x0=t,f.y0=e,f.x1=i,f.y1=o,f.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var i=function(t,e){var i=new Map;return n.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 o=t.source,r=t.target;"object"!=typeof o&&(o=t.source=G(i,o)),"object"!=typeof r&&(r=t.target=G(i,r)),o.sourceLinks.push(t),r.targetLinks.push(t)})}(f,c),function(t,e){var i=0;if(null==e){for(var o=[],r=0;t.links.length>r;r++){var n=t.links[r],s=n.source.index,a=n.target.index;o[s]||(o[s]=[]),o[a]||(o[a]=[]),-1===o[s].indexOf(a)&&o[s].push(a)}var c=V(o);c.sort(function(t,e){return t.length-e.length});var l={};for(r=0;c.length>r;r++){var u=c[r].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,o=t.source.index;e===o||l[o]&&l[o][e]?(t.circular=!0,t.circularLinkID=i++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=i++)})}(f,u),function(t,e){var i=0,o=0;t.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:o>i?"top":"bottom","top"==r.circularLinkType?i++:o++,t.nodes.forEach(function(t){et(t,e)!=et(r.source,e)&&et(t,e)!=et(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),Q(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(f,c),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(n.sum(t.sourceLinks,nt),n.sum(t.targetLinks,nt)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(f),function(t,e,i){var o,r,n;if(null!=e){t.nodes.sort(function(t,i){return e(t)<e(i)?-1:1});var s=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==a?s:s+1,a=e(t)==a?a:e(t),t.column=s})}for(o=t.nodes,r=[],n=0;o.length;++n,o=r,r=[])o.forEach(function(t){t.depth=n,t.sourceLinks.forEach(function(t){0>r.indexOf(t.target)&&!t.circular&&r.push(t.target)})});for(o=t.nodes,r=[],n=0;o.length;++n,o=r,r=[])o.forEach(function(t){t.height=n,t.targetLinks.forEach(function(t){0>r.indexOf(t.source)&&!t.circular&&r.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?i(t,n):t.column})}(f,u,l);var g=s;if(null!==a){var y=n.groups(f.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=n.max(y,function(t){return t.length});p>1&&(g=Math.max(1,(o-e)*a/(p-1)))}(function(t,e,i){var o=n.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var r=n.min(o,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/n.sum(e,function(t){return t.value})});t.ky=r,t.links.forEach(function(e){e.width=e.value*t.ky});var s=n.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})})(f,g,r),jt(f,u,c),Mt(f,u,c,g,g,h),Ot(f),bt(f,c,d,10,8),jt(f,u,c),Mt(f,u,c,g,g,h),Ot(f),bt(f,c,d,10,8),function(t,e){let i=t;i.nodes.forEach(function(t){t.y+(t.y1-t.y0)>i.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-i.y1));var o=i.links.filter(function(i){return et(i.source,e)==et(t,e)}),r=o.length;r>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!xt(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var i=K(e,t);return t.y1-i}if(e.target.column>t.target.column)return K(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var n=t.y0;o.forEach(function(t){t.y0=n+t.width/2,n+=t.width}),o.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var n=i+1,s=0;r>n;n++)s+=o[n].width;e.y0=t.y1-s-e.width/2}})})}(f,c),function(t,e){let i=t;i.nodes.forEach(function(t){var o=i.links.filter(function(i){return et(i.target,e)==et(t,e)}),r=o.length;r>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!xt(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var i=J(e,t);return t.y0-i}if(e.source.column>t.source.column)return J(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var n=t.y0;o.forEach(function(t){t.y1=n+t.width/2,n+=t.width}),o.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var n=i+1,s=0;r>n;n++)s+=o[n].width;e.y1=t.y1-s-e.width/2}})})}(f,c),function(t){var e=t.nodes,i=t.links,o=!1,r=!1;if(i.forEach(function(t){"top"==t.circularLinkType?o=!0:"bottom"==t.circularLinkType&&(r=!0)}),0==o||0==r){var s=n.min(e,function(t){return t.y0}),a=n.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})})}}(f),bt(f,c,d,10,8)}(y),y}return y.update=function(t){return Ot(t),bt(t,c,d,10,8),t},y.nodeWidth=function(t){return arguments.length?(r=+t,y):r},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?(f="function"==typeof t?t:wt(t),y):f},y.links=function(t){return arguments.length?(g="function"==typeof t?t:wt(t),y):g},y.nodeId=function(t){return arguments.length?(c="function"==typeof t?t:wt(t),y):c},y.nodeAlign=function(t){return arguments.length?(l="function"==typeof t?t:wt(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?(d=+t,y):d},y.extent=function(r){return arguments.length?(t=+r[0][0],e=+r[0][1],i=+r[1][0],o=+r[1][1],y):[[t,e],[i,o]]},y.size=function(r){return arguments.length?(t=e=0,i=+r[0],o=+r[1],y):[i-t,o-e]},y}q.GROUP_COLOR_MAP_CAP=1e3,q.QUADTREE_THRESHOLD=500;const Lt=t=>{let e,i,o,r,n,a,c,l,u;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,i=t.y1-t.sankeyWidth/2,o=t.y1+t.sankeyWidth/2,r=t.y0+t.sankeyWidth/2,n=t.source.x1,a=t.target.x0,c=s.interpolateNumber(n,a),l=c(.5),u=c(.5),`M${e},${n}C${e},${l} ${i},${u} ${i},${a}L${o},${a}C${o},${u} ${r},${l} ${r},${n}Z`):(e=t.source.x1,i=t.target.x0,c=s.interpolateNumber(e,i),o=c(.5),r=c(.5),n=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},${n}C${o},${n} ${r},${a} ${i},${a}L${i},${l}C${r},${l} ${o},${u} ${e},${u}Z`)};function Et(t){var e;const i=t.sankeyWidth/2,o=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,r=t.circularPathData;if(!r)return null;if("down"===t.direction)return null;if(t._circularStub){const e=r.sourceX,o=r.sourceY,n=r.targetX,s=r.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(r.rightFullExtent-e))),c=Math.max(15,Math.min(40,.33*(n-r.leftFullExtent)));return`M${e},${o-i}L${e+a},${o-i}L${e+a},${o+i}L${e},${o+i}ZM${n},${s-i}L${n-c},${s-i}L${n-c},${s+i}L${n},${s+i}Z`}const n=r.sourceX,s=r.sourceY,a=r.targetX,c=r.targetY,l=r.rightFullExtent,u=r.leftFullExtent,h=r.verticalFullExtent,d="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(o,15));return`M${n},${s-d*i}L${l},${s-d*i}L${l+o},${s-d*i+d*f}L${l+o},${h+d*o-d*f}L${l+o-f},${h+d*o}L${u-o+f},${h+d*o}L${u-o},${h+d*o-d*f}L${u-o},${c-d*i+d*f}L${u-o+f},${c-d*i}L${a},${c-d*i}L${a},${c+d*i}L${u+o},${c+d*i}L${u+o},${h-d*o}L${l-o},${h-d*o}L${l-o},${s+d*i}L${n},${s+d*i}Z`}const Dt=new Set,zt=new WeakMap;function $t(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let i=zt.get(t);if(i){const t=i.get(e);if(t)return t}else i=new Map,zt.set(t,i);const o=new Proxy(t,{get(t,i,o){if("string"==typeof i&&!(i in t)&&t.data&&i in t.data){const t=`${e}:${i}`;Dt.has(t)||(Dt.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${i}" on the wrapper object, but it only exists on ".data". Use d.data.${i} (or d.data?.${i}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,i,o)}});return i.set(e,o),o}const Ct={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(at))-1:0},justify:ct},Rt={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,o){var r,n,s,a,c,l,u;if(0===t.length)return;const h="vertical"===i.orientation?"down":"right",d=i.nodeAlign||"justify",f=null!==(r=i.nodeWidth)&&void 0!==r?r:15,g=null!==(n=i.nodePaddingRatio)&&void 0!==n?n:.05,y=null!==(s=i.iterations)&&void 0!==s?s:100,p=t.map(t=>Object.assign({},t)),m=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let x;x="down"===h?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const v=Tt().extent(x).links(m).nodes(p).nodeAlign(Ct[d]||ct).nodeId(t=>t.id).nodeWidth(f).iterations(y);v.nodePaddingRatio&&v.nodePaddingRatio(g),v();{let t=1/0,e=-1/0,i=1/0,r=-1/0;for(const o of p)t>o.x0&&(t=o.x0),o.x1>e&&(e=o.x1),i>o.y0&&(i=o.y0),o.y1>r&&(r=o.y1);for(const o of m){if(!o.circular||!o.circularPathData)continue;const n=o.circularPathData,s=(null!==(c=null!==(a=o._circularWidth)&&void 0!==a?a:o.width)&&void 0!==c?c:0)/2;t>n.leftFullExtent-s&&(t=n.leftFullExtent-s),n.rightFullExtent+s>e&&(e=n.rightFullExtent+s),i>n.verticalFullExtent-s&&(i=n.verticalFullExtent-s),n.verticalFullExtent+s>r&&(r=n.verticalFullExtent+s)}const n=e-t,s=r-i,u=o[0],h=o[1];if(n>0&&s>0&&(0>t||0>i||e>u||r>h)){const e=Math.min(u/n,h/s),o=-t*e+(u-n*e)/2,r=-i*e+(h-s*e)/2;for(const t of p)t.x0=t.x0*e+o,t.x1=t.x1*e+o,t.y0=t.y0*e+r,t.y1=t.y1*e+r;for(const t of m)if(t.y0=t.y0*e+r,t.y1=t.y1*e+r,t.width=(null!==(l=t.width)&&void 0!==l?l:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const i=t.circularPathData;i.sourceX=i.sourceX*e+o,i.targetX=i.targetX*e+o,i.sourceY=i.sourceY*e+r,i.targetY=i.targetY*e+r,i.rightFullExtent=i.rightFullExtent*e+o,i.leftFullExtent=i.leftFullExtent*e+o,i.verticalFullExtent=i.verticalFullExtent*e+r,i.rightInnerExtent=i.rightInnerExtent*e+o,i.leftInnerExtent=i.leftInnerExtent*e+o,i.verticalRightInnerExtent=i.verticalRightInnerExtent*e+r,i.verticalLeftInnerExtent=i.verticalLeftInnerExtent*e+r,i.rightSmallArcRadius*=e,i.rightLargeArcRadius*=e,i.leftSmallArcRadius*=e,i.leftLargeArcRadius*=e,i.sourceWidth*=e,i.rightNodeBuffer*=e,i.leftNodeBuffer*=e,i.arcRadius*=e}}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of p){const e=b.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const k=new Map;for(const t of e)k.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of m){const e=t.source,i=t.target,o="object"==typeof e&&null!==e?e.id:e+"",r="object"==typeof i&&null!==i?i.id:i+"",n=k.get(t._edgeKey?t._edgeKey:`${o}\0${r}`);if(n){n.y0=t.y0,n.y1=t.y1,n.sankeyWidth=null!==(u=t.width)&&void 0!==u?u:0,n.circular=!!t.circular,n.circularPathData=t.circularPathData,n._circularWidth=t._circularWidth,n._circularStub=t._circularStub,n.path=t.path,n.circularLinkType=t.circularLinkType,n.direction=h;const e=b.get(o),i=b.get(r);e&&(n.source=e),i&&(n.target=i)}}},buildScene(t,e,i,o){var n,s,a,c,l,u;const h="vertical"===i.orientation?"down":"right",d=i.nodeStyle,f=i.edgeStyle,g=null!==(n=i.edgeOpacity)&&void 0!==n?n:.5,y=i.edgeColorBy||"source",p=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:r.schemeCategory10,m=new Map;t.forEach((t,e)=>{m.set(t.id,p[e%p.length])});const x=[],v=[],b=[],k=new Map;for(const e of t){const t=e.x1-e.x0,i=e.y1-e.y0;if(0>=t||0>=i)continue;const o=d?d($t(e,"nodeStyle")):{},r={fill:o.fill||m.get(e.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};k.set(e.id,("string"==typeof r.fill?r.fill:null)||m.get(e.id)||"#4d430c"),x.push("down"===h?{type:"rect",x:e.y0,y:e.x0,w:i,h:t,style:r,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:i,style:r,datum:e,id:e.id,label:e.id})}const A=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of A){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let r=(null===(s=i.themeSemantic)||void 0===s?void 0:s.border)||(null===(a=i.themeSemantic)||void 0===a?void 0:a.secondary)||"#999";r="function"==typeof y?y(t)||r:"target"===y?k.get(o.id)||m.get(o.id)||r:k.get(e.id)||m.get(e.id)||r;const n=f?f($t(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))),s=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),a=n.fill||r;v.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-i}L${e.sourceX+o},${e.sourceY-i}L${e.sourceX+o},${e.sourceY+i}L${e.sourceX},${e.sourceY+i}Z`,style:{fill:a,fillOpacity:null!==(c=n.fillOpacity)&&void 0!==c?c:g,stroke:"none",opacity:n.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+o}}),v.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-i}L${e.targetX-s},${e.targetY-i}L${e.targetX-s},${e.targetY+i}L${e.targetX},${e.targetY+i}Z`,style:{fill:a,fillOpacity:null!==(l=n.fillOpacity)&&void 0!==l?l:g,stroke:"none",opacity:n.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-s,x1:e.targetX}});continue}let h;if(h=t.circular&&t.circularPathData?Et(t):Lt(t),!h)continue;const d={fill:n.fill||r,fillOpacity:null!==(u=n.fillOpacity)&&void 0!==u?u:g,stroke:n.stroke||"none",strokeWidth:n.strokeWidth,opacity:n.opacity};v.push({type:"bezier",pathD:h,bezierCache:t.bezier,style:d,datum:t})}if(!1!==i.showLabels){const e=(w=i.nodeLabel)?"function"==typeof w?w:t=>t[w]||t.id:null;for(const i of t){const t=i.x1-i.x0,r=i.y1-i.y0;if(0>=t||0>=r)continue;const n=e?e(i):i.id;if(!n)continue;let s,a,c;"down"===h?(s=i.y0+(i.y1-i.y0)/2,a=i.x1+14,c="middle"):(o[0]/2>i.x0+t/2?(s=i.x0-6,c="end"):(s=i.x1+6,c="start"),a=i.y0+r/2),b.push({x:s,y:a,text:n+"",anchor:c,baseline:"middle",fontSize:11})}}var w;return{sceneNodes:x,sceneEdges:v,labels:b}}},Nt={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,o){var r,n;if(0===t.length)return;const s=null!==(r=i.forceStrength)&&void 0!==r?r:.1,c=o[0]/2,l=o[1]/2,u=i.__previousPositions;let h=0;const d=[];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++):d.push(e)}const f=h>0&&.3>=(t.length>0?d.length/t.length:1);if(f){const i=new Map;for(const e of t)i.set(e.id,e);for(const t of d){const o=Bt(t.id,e,i);if(o.length>0){let e=0,i=0;for(const t of o)e+=t.x,i+=t.y;const r=Wt(t.id),n=r%360*(Math.PI/180),s=10+r%20;t.x=e/o.length+s*Math.cos(n),t.y=i/o.length+s*Math.sin(n)}else{const e=Wt(t.id),i=e%360*(Math.PI/180),o=15+e%30;t.x=c+o*Math.cos(i),t.y=l+o*Math.sin(i)}}}else{const e=2.399963229728653;for(let i=0;t.length>i;i++){const o=t[i];if(null==o.x||null==o.y||0===o.x&&0===o.y){const t=10*Math.sqrt(i+.5),r=i*e;o.x=c+t*Math.cos(r),o.y=l+t*Math.sin(r)}}}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:f?40:g,p=Ft(i.nodeSize,i.nodeSizeRange,t),m=t=>p(t);if(y>0){const i=a.forceLink().strength(t=>{const e=t.weight;return Math.min(2.5,e?e*s:s)}).id(t=>t.id),o=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(o.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));o.force("link",i),o.force("link").links(t)}f?o.alpha(.3):.1>o.alpha()&&o.alpha(1),o.stop();for(let t=0;y>t;++t)o.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(o[0]-t,e.x)),e.y=Math.max(t,Math.min(o[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const 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,s,a,c,l,u,h;const d=i.nodeStyle,f=i.edgeStyle,g=Ft(i.nodeSize,i.nodeSizeRange,t),y=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:r.schemeCategory10,p=new Map;t.forEach((t,e)=>{p.set(t.id,y[e%y.length])});const m=[],x=[],v=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=g($t(e,"nodeSize")),o=d?d($t(e,"nodeStyle")):{},r={fill:o.fill||p.get(e.id)||(null===(n=i.themeSemantic)||void 0===n?void 0:n.primary)||"#007bff",stroke:o.stroke||(null===(s=i.themeSemantic)||void 0===s?void 0:s.surface)||"#fff",strokeWidth:null!==(a=o.strokeWidth)&&void 0!==a?a:2,opacity:o.opacity};m.push({type:"circle",cx:e.x,cy:e.y,r:t,style:r,datum:e,id:e.id,label:e.id})}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:b.get(t.source),o="object"==typeof t.target?t.target:b.get(t.target);if(!e||!o)continue;if(null==e.x||null==e.y)continue;if(null==o.x||null==o.y)continue;const r=f?f($t(t,"edgeStyle")):{},n={stroke:r.stroke||(null===(c=i.themeSemantic)||void 0===c?void 0:c.border)||(null===(l=i.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",strokeWidth:null!==(u=r.strokeWidth)&&void 0!==u?u:1,opacity:null!==(h=r.opacity)&&void 0!==h?h:.6};x.push({type:"line",x1:e.x,y1:e.y,x2:o.x,y2:o.y,style:n,datum:t})}if(!1!==i.showLabels){const e=(k=i.nodeLabel)?"function"==typeof k?k:t=>t[k]||t.id:null;for(const i of t){if(null==i.x||null==i.y)continue;const t=e?e(i):i.id;if(!t)continue;const o=g($t(i,"nodeSize"));v.push({x:i.x,y:i.y-o-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var k;return{sceneNodes:m,sceneEdges:x,labels:v}}};function Bt(t,e,i){const o=[];for(const r of e){const e="string"==typeof r.source?r.source:r.source.id,n="string"==typeof r.target?r.target:r.target.id;let s=null;if(e===t?s=n:n===t&&(s=e),s){const t=i.get(s);!t||0===t.x&&0===t.y||o.push({x:t.x,y:t.y})}}return o}function Wt(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 Ft(t,e,o){var r,s;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const a=e||[5,20],c=o.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!==(r=n.min(c))&&void 0!==r?r:0,u=null!==(s=n.max(c))&&void 0!==s?s:1;if(l===u)return()=>(a[0]+a[1])/2;const h=i.scaleLinear().domain([l,u]).range(a).clamp(!0);return e=>{var i;const o=null===(i=e.data)||void 0===i?void 0:i[t];return null==o||"number"!=typeof o?a[0]:h(o)}}const Yt=r.schemeCategory10,It={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,i,o){if(0===t.length)return;const{padAngle:r=.01,groupWidth:n=20,sortGroups:s}=i,a=Math.min(o[0],o[1])/2,u=a-n,h=o[0]/2,d=o[1]/2,f=(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),o=y.get(e);if(void 0===i||void 0===o)continue;const r=f(t);m[i][o]=r}const x=c.chord().padAngle(r);s&&x.sortGroups(s);const v=x(m),b=v.groups,k=l.arc().innerRadius(u).outerRadius(a);for(const e of b){const i=t[e.index],o=k.centroid(e);i.x=o[0]+h,i.y=o[1]+d,i.arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const A=new Map;for(const e of t)A.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,i=A.get("string"==typeof t.source?t.source:t.source.id),o=A.get(e);i&&(t.source=i),o&&(t.target=o)}const w=new Map;for(const t of e)w.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,o=t[e.target.index].id,r=w.get(`${i}\0${o}`)||w.get(`${o}\0${i}`);r&&(r.chordData=e)}},buildScene(t,e,i,o){var r,n,s,a;const{groupWidth:l=20,edgeOpacity:u=.5}=i,h=Math.min(o[0],o[1])/2,d=h-l,f=o[0]/2,g=o[1]/2,y=i.nodeStyle,p=i.edgeStyle,m=i.edgeColorBy||"source",x=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:Yt,v=new Map;t.forEach((t,e)=>{v.set(t.id,x[e%x.length])});const b=c.ribbon().radius(d),k=[],A=[],w=[];for(let e=0;t.length>e;e++){const i=t[e],o=i.arcData;if(!o)continue;let n;n=y?y($t(i,"nodeStyle")).fill||v.get(i.id)||x[e%x.length]:v.get(i.id)||x[e%x.length];const s=y?y($t(i,"nodeStyle")):{},a={fill:n,stroke:s.stroke||"black",strokeWidth:null!==(r=s.strokeWidth)&&void 0!==r?r:1,opacity:s.opacity};k.push({type:"arc",cx:f,cy:g,innerR:d,outerR:h,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:a,datum:i,id:i.id,label:i.id})}for(const t of e){const e=t.chordData;if(!e)continue;const o=b(e);if(!o)continue;const r=Xt(o,f,g);let c=(null===(n=i.themeSemantic)||void 0===n?void 0:n.border)||(null===(s=i.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";if(p)c=p($t(t,"edgeStyle")).fill||c;else{const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;"target"===m&&i?c=v.get(i.id)||c:e&&(c=v.get(e.id)||c)}const l=p?p($t(t,"edgeStyle")):{},h={fill:c,fillOpacity:null!==(a=l.fillOpacity)&&void 0!==a?a:u,stroke:l.stroke||"none",strokeWidth:l.strokeWidth,opacity:l.opacity};A.push({type:"ribbon",pathD:r,style:h,datum:t})}if(!1!==i.showLabels){const e=(S=i.nodeLabel)?"function"==typeof S?S:t=>t[S]||t.id:null,o=h+12;for(const i of t){const t=i.arcData;if(!t)continue;const r=e?e(i):i.id;if(!r)continue;const n=(t.startAngle+t.endAngle)/2,s=n-Math.PI/2;w.push({x:f+Math.cos(s)*o,y:g+Math.sin(s)*o,text:r+"",anchor:n>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var S;return{sceneNodes:k,sceneEdges:A,labels:w}}};function Xt(t,e,i){const o=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return t;const r=[];let n=0;for(;o.length>n;){const t=o[n];if("M"===t||"L"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)r.push(Number(o[n])+e+""),n++,o.length>n&&!isNaN(Number(o[n]))&&(r.push(Number(o[n])+i+""),n++);else if("C"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)for(let t=0;3>t&&o.length>n&&!isNaN(Number(o[n]));t++)r.push(Number(o[n])+e+""),n++,o.length>n&&!isNaN(Number(o[n]))&&(r.push(Number(o[n])+i+""),n++);else if("Q"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)for(let t=0;2>t&&o.length>n&&!isNaN(Number(o[n]));t++)r.push(Number(o[n])+e+""),n++,o.length>n&&!isNaN(Number(o[n]))&&(r.push(Number(o[n])+i+""),n++);else if("A"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&(r.push(Number(o[n])+e+""),n++),o.length>n&&(r.push(Number(o[n])+i+""),n++);else"Z"===t||"z"===t?(r.push(t),n++):(r.push(o[n]),n++)}return r.join(" ")}const qt=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Gt(t){const[e,i,o]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*i+.114*o>150?"#222":"#fff"}function Vt(t,e,i){const o=e.nodeIDAccessor;return"function"==typeof o?o(t.data)+"":"string"==typeof o&&void 0!==t.data[o]?t.data[o]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+i}function Ht(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 Qt(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:qt}function Ut(t){var e;return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)?t.themeSemantic.primary:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical[0]:"#4d430c"}function Zt(t,e,i,o,r){if("horizontal"===r){const r=(t+i)/2;return`M ${t},${e} C ${r},${e} ${r},${o} ${i},${o}`}if("radial"===r){const r=(t+i)/2;return`M ${t},${e} Q ${r},${e} ${r},${(e+o)/2} T ${i},${o}`}{const r=(e+o)/2;return`M ${t},${e} C ${t},${r} ${i},${r} ${i},${o}`}}const Kt={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,i,o){var r;const n=i.__hierarchyRoot;if(!n)return;const s=i.chartType,a=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(i.childrenAccessor),c=i.hierarchySum,l="function"==typeof c?c:"string"==typeof c?t=>{var e;return null!==(e=t[c])&&void 0!==e?e:0}:t=>{var e;return null!==(e=t.value)&&void 0!==e?e:0},h=u.hierarchy(n,a);h.sum(l),h.sort((t,e)=>{var i,o;return(null!==(i=e.value)&&void 0!==i?i:0)-(null!==(o=t.value)&&void 0!==o?o:0)});const[d,f]=o;switch(s){case"tree":!function(t,e,i,o){const r=e.treeOrientation||"vertical",n=u.tree();n.size("horizontal"===r?[o,i]:"radial"===r?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),n(t)}(h,i,d,f);break;case"cluster":!function(t,e,i,o){const r=e.treeOrientation||"vertical",n=u.cluster();n.size("horizontal"===r?[o,i]:"radial"===r?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),n(t)}(h,i,d,f);break;case"treemap":!function(t,e,i,o){var r,n;const s=null!==(r=e.padding)&&void 0!==r?r:4,a=null!==(n=e.paddingTop)&&void 0!==n?n:0,c=u.treemap().size([i,o]).tile(u.treemapBinary).padding(s);a>0&&c.paddingTop(a),c(t)}(h,i,d,f);break;case"circlepack":!function(t,e,i,o){var r;const n=null!==(r=e.padding)&&void 0!==r?r:4;u.pack().size([i,o]).padding(n)(t)}(h,i,d,f);break;case"partition":!function(t,e,i,o){var r;u.partition().size([i,o]).padding(null!==(r=e.padding)&&void 0!==r?r:1)(t)}(h,i,d,f)}const g=h.descendants();t.length=0,e.length=0;const y=new Map;for(let e=0;g.length>e;e++){const o=g[e],n={id:Vt(o,i,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(r=o.value)&&void 0!==r?r:0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===s||"cluster"===s?Jt(n,o,i):"treemap"===s||"partition"===s?te(n,o):"circlepack"===s&&ee(n,o),n.__hierarchyNode=o,t.push(n),y.set(o,n)}if("tree"===s||"cluster"===s)for(const t of g)if(t.parent){const i=y.get(t.parent),o=y.get(t);i&&o&&e.push({source:i,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,i,o){const r=i.nodeStyle||(()=>({})),n=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return function(t,e,i,o,r,n){var s,a,c,l,u,h,d,f;const g=[],y=[],p=[],m=i.treeOrientation||"vertical",x="radial"===m,v=o[0]/2,b=o[1]/2,k="number"==typeof(A=i.nodeSize)?A:5;var A;for(const e of t){let t=e.x,o=e.y;x&&(t+=v,o+=b);const n=r($t(e,"nodeStyle"));let c=n.fill||Ut(i);if(i.colorByDepth&&void 0!==e.depth){const t=Qt(i);c=t[e.depth%t.length]}const l={fill:c,stroke:n.stroke||(null===(s=i.themeSemantic)||void 0===s?void 0:s.surface)||"#fff",strokeWidth:null!==(a=n.strokeWidth)&&void 0!==a?a:1,opacity:n.opacity};g.push({type:"circle",cx:t,cy:o,r:k,style:l,datum:e,id:e.id,label:e.id,depth:e.depth})}const w=null!==(c=i.edgeOpacity)&&void 0!==c?c:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let r=e.x,s=e.y,a=o.x,c=o.y;x&&(r+=v,s+=b,a+=v,c+=b);const f=Zt(r,s,a,c,m),g=n($t(t,"edgeStyle")),p={fill:"none",stroke:g.stroke||(null===(l=i.themeSemantic)||void 0===l?void 0:l.border)||(null===(u=i.themeSemantic)||void 0===u?void 0:u.secondary)||"#999",strokeWidth:null!==(h=g.strokeWidth)&&void 0!==h?h:1.5,opacity:null!==(d=g.opacity)&&void 0!==d?d:w};y.push({type:"curved",pathD:f,style:p,datum:t})}if(!1!==i.showLabels){const e=Ht(i.nodeLabel);for(const i of t){const t=e?e(i):i.id;if(!t)continue;let o,r,n,s=i.x,a=i.y;if(x&&(s+=v,a+=b),x){const t=s-v,e=a-b,i=Math.sqrt(t*t+e*e);i>0?(o=s+t/i*10,r=a+e/i*10,n=0>t?"end":"start"):(o=s,r=a-12,n="middle")}else"horizontal"===m?((null===(f=i.data)||void 0===f?void 0:f.children)&&0!==i.data.children.length?(o=s-k-6,n="end"):(o=s+k+6,n="start"),r=a):(o=s,r=a+k+14,n="middle");p.push({x:o,y:r,text:t+"",anchor:n,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:y,labels:p}}(t,e,i,o,r,n);case"treemap":case"partition":return function(t,e,i,o){var r,n,s,a,c;const l=[],u=[];for(const i of t){const t=i.x1-i.x0,s=i.y1-i.y0;if(0>=t||0>=s)continue;const a=o($t(i,"nodeStyle"));let c=a.fill||Ut(e);if(e.colorByDepth&&void 0!==i.depth){const t=Qt(e);c=t[i.depth%t.length]}const u={fill:c,stroke:a.stroke||(null===(r=e.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(n=a.strokeWidth)&&void 0!==n?n:1,opacity:a.opacity};l.push({type:"rect",x:i.x0,y:i.y0,w:t,h:s,style:u,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Ht(e.nodeLabel),r=e.labelMode||"leaf",n="partition"===e.chartType;for(const l of t){const t=l.x1-l.x0,h=l.y1-l.y0;if(0>=t||0>=h)continue;const d=!((null===(s=l.data)||void 0===s?void 0:s.children)&&l.data.children.length>0);if(!n){if("leaf"===r&&!d)continue;if("parent"===r&&d)continue}const f=i?i(l):l.id;if(!f)continue;if((d?30:40)>t||(d?16:14)>h)continue;let g=o($t(l,"nodeStyle")).fill||Ut(e);if(e.colorByDepth&&void 0!==l.depth){const t=Qt(e);g=t[l.depth%t.length]}const y="string"==typeof g?Gt(g):null!==(c=null===(a=e.themeSemantic)||void 0===a?void 0:a.text)&&void 0!==c?c:"#000";u.push(d?{x:l.x0+t/2,y:l.y0+h/2,text:f+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,h)/6)),fill:y}:{x:l.x0+4,y:l.y0+12,text:f+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}return{sceneNodes:l,sceneEdges:[],labels:u}}(t,i,0,r);case"circlepack":return function(t,e,i,o){var r,n,s,a,c,l,u,h,d,f;const g=[],y=[];for(const i of t){const t=null!==(r=i.__radius)&&void 0!==r?r:5;if(0>=t)continue;const c=o($t(i,"nodeStyle"));let l=c.fill||Ut(e);if(e.colorByDepth&&void 0!==i.depth){const t=Qt(e);l=t[i.depth%t.length]}const u={fill:l,stroke:c.stroke||(null===(n=e.themeSemantic)||void 0===n?void 0:n.surface)||"#fff",strokeWidth:null!==(s=c.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=c.opacity)&&void 0!==a?a:.7};g.push({type:"circle",cx:i.x,cy:i.y,r:t,style:u,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=Ht(e.nodeLabel);for(const r of t){const t=null!==(c=r.__radius)&&void 0!==c?c:5,n=i?i(r):r.id;if(!n)continue;if(15>t)continue;const s=!((null===(l=r.data)||void 0===l?void 0:l.children)&&r.data.children.length>0);let a=o($t(r,"nodeStyle")).fill||Ut(e);if(e.colorByDepth&&void 0!==r.depth){const t=Qt(e);a=t[r.depth%t.length]}if(s){const i="string"==typeof a?Gt(a):null!==(h=null===(u=e.themeSemantic)||void 0===u?void 0:u.text)&&void 0!==h?h:"#000";y.push({x:r.x,y:r.y,text:n+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:i})}else y.push({x:r.x,y:r.y-t+14,text:n+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:(null===(d=e.themeSemantic)||void 0===d?void 0:d.text)||"#000",stroke:(null===(f=e.themeSemantic)||void 0===f?void 0:f.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:g,sceneEdges:[],labels:y}}(t,i,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Jt(t,e,i){const o=i.treeOrientation||"vertical";if("radial"===o){const i=e.x,o=e.y;t.x=o*Math.cos(i-Math.PI/2),t.y=o*Math.sin(i-Math.PI/2)}else"horizontal"===o?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function te(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 ee(t,e){var i;const o=null!==(i=e.r)&&void 0!==i?i:0;t.x=e.x,t.y=e.y,t.x0=e.x-o,t.x1=e.x+o,t.y0=e.y-o,t.y1=e.y+o,t.width=2*o,t.height=2*o,t.__radius=o}function ie(t){const e=t;return e.__orbitState||(e.__orbitState={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()}),e.__orbitState}const oe={sankey:Rt,force:Nt,chord:It,tree:Kt,cluster:Kt,treemap:Kt,circlepack:Kt,partition:Kt,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,i,o){const r=i.__hierarchyRoot;r&&function(t,e,i,o,r){var n,s;const a=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(i.childrenAccessor),c=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>{var i;return(null!==(i=t[e])&&void 0!==i?i:"")+""}}(i.nodeIDAccessor),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,d=null!==(s=i.orbitEccentricity)&&void 0!==s?s:1,f="number"==typeof h?()=>h:h,g="number"==typeof d?()=>d:d,y=ie(i);y.metaMap.clear(),o.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 x=e[0]/2,v=e[1]/2,b=Math.min(e[0],e[1])/2*.85,k=m(c(t));o.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,s,h,d,p){const x=a(e);if(!(null==x?void 0:x.length))return;const v=x.length;let b=0,k=0,A=0;for(;v>k;)k+=u[Math.min(A,u.length-1)],A++,b++;let w=0;for(let v=0;b>v;v++){const k=u[Math.min(v,u.length-1)],A=x.slice(w,w+k);if(!A.length)break;const S=(v+1)/b,_={id:i,depth:d,data:e,parentId:i},P=p?h/f(_)*S:h*S,j=l.pie().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),M=j(A),O=g(_);for(let e=0;A.length>e;e++){const a=(M[e].startAngle+M[e].endAngle)/2,l=A[e],u=m(c(l)),h=n+P*Math.sin(a),f=s+P*Math.cos(a)*O;o.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:d,data:l}),y.metaMap.set(u,{ring:P,angle:a,depth:d,parentId:i,eccentricity:O}),r.push({source:i,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:u}}),t(l,u,h,f,P,d+1,!0)}w+=k}}(t,k,x,v,b,1,!1)}(r,o,i,t,e)},buildScene(t,e,i,o){var r,n,s,a,c,l,u;const h=i.nodeStyle,d=i.nodeSize,f="number"==typeof d?()=>d:"function"==typeof d?d:()=>6,g=[],y=[],p=[];if(!1!==i.orbitShowRings){const e=ie(i),o=new Map;for(const e of t)o.set(e.id,e);const r=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=o.get(t.parentId);if(!e)continue;const i=`${t.parentId}:${t.ring}`;r.has(i)||r.set(i,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const n=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:i,ecc:o}]of r)for(let r=0;n>r;r++){const a=r/n*Math.PI*2,c=(r+1)/n*Math.PI*2;y.push({type:"line",x1:t+i*Math.sin(a),y1:e+i*Math.cos(a)*o,x2:t+i*Math.sin(c),y2:e+i*Math.cos(c)*o,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=f($t(e,"nodeSize")),o=h?h($t(e,"nodeStyle")):{},l={fill:o.fill||(null===(r=i.themeSemantic)||void 0===r?void 0:r.primary)||"#6366f1",stroke:o.stroke||(null===(n=i.themeSemantic)||void 0===n?void 0:n.surface)||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=o.opacity)&&void 0!==a?a:0===(null!==(c=e.depth)&&void 0!==c?c:0)?1:.85};g.push({type:"circle",cx:e.x,cy:e.y,r:t,style:l,datum:e,id:e.id,label:e.id,depth:e.depth})}const m=new Map;for(const e of t)m.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:m.get(t.source),i="object"==typeof t.target?t.target:m.get(t.target);e&&i&&(null!=e.x&&null!=i.x&&y.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(i.showLabels){const e=i.nodeLabel;for(const i of t){const t=f($t(i,"nodeSize"));if(4>=t)continue;const o="function"==typeof e?e(i):e&&null!==(u=null===(l=i.data)||void 0===l?void 0:l[e])&&void 0!==u?u:i.id;p.push({x:i.x,y:i.y+t+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:y,labels:p}},tick:(t,e,i,o,r)=>!1!==i.orbitAnimated&&(function(t,e){var i,o;const r=ie(e),n=null!==(i=e.orbitSpeed)&&void 0!==i?i:.25,s=null!==(o=e.orbitRevolution)&&void 0!==o?o:function(t){switch(t){case"decay":return t=>{var e;return Math.pow(.6,null!==(e=t.depth)&&void 0!==e?e:0)};case"alternate":return t=>{var e;const i=null!==(e=t.depth)&&void 0!==e?e:0;return(i%2==0?1:-1)/(i+1)};default:return t=>{var e;return 1/((null!==(e=t.depth)&&void 0!==e?e:0)+1)}}}(e.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-r.startTime)/1e3,c=n*(Math.PI/6),l=new Map;for(const e of t)l.set(e.id,e);for(const e of t){const t=r.metaMap.get(e.id);if(!t||!t.parentId)continue;const i=l.get(t.parentId);if(!i)continue;const o=t.angle+a*c*s({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=i.x+t.ring*Math.sin(o),e.y=i.y+t.ring*Math.cos(o)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,i),!0)}};function re(t,e){const{columns:i,config:o,resolvePieceStyle:r}=t,n=[],s=Math.min(e.width,e.height)/2-4,a="donut"===o.chartType?o.innerRadius||60:0,c=-Math.PI/2+(o.startAngle||0)*Math.PI/180,l=null!=o.sweepAngle?o.sweepAngle*Math.PI/180:2*Math.PI;for(const t of Object.values(i)){const e=c+t.pctStart*l,i=c+(t.pctStart+t.pct)*l,u=r(t.pieceData[0],t.name);n.push(Object.assign(Object.assign({type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:e,endAngle:i},o.cornerRadius&&{cornerRadius:o.cornerRadius}),{style:u,datum:t.pieceData,category:t.name}))}return n}function ne(t){var e,i,o;const r=t.length,s=t[0],a=t[r-1];return{n:r,min:s,q1:null!==(e=n.quantile(t,.25))&&void 0!==e?e:s,median:null!==(i=n.quantile(t,.5))&&void 0!==i?i:(s+a)/2,q3:null!==(o=n.quantile(t,.75))&&void 0!==o?o:a,max:a,mean:t.reduce((t,e)=>t+e,0)/r}}const se={bar:function(t,e){var i,o,r;const{scales:n,columns:s,config:a,getR:c,getStack:l,resolvePieceStyle:u}=t,{r:h,projection:d}=n,f=[],g="vertical"===d,y="horizontal"===d,p=a.normalize,m=[];if(l){const t=new Set;for(const e of Object.values(s))for(const i of e.pieceData){const e=l(i);t.has(e)||(t.add(e),m.push(e))}}else m.push("_default");for(const t of Object.values(s)){const e=new Map;for(const i of t.pieceData){const t=l?l(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t);o.total+=c(i),o.pieces.push(i)}let i=0;if(p)for(const t of e.values())i+=Math.abs(t.total);let o=0,r=0;for(const n of m){const s=e.get(n);if(!s)continue;let a=s.total;p&&i>0&&(a/=i);const c=u(s.pieces[0],l?n:t.name),d=Object.assign(Object.assign({},s.pieces[0]),{__aggregateValue:s.total,__pieceCount:s.pieces.length,category:t.name});if(g){const e=h(0>a?r:o+a),i=0>a?h(r+a)-h(r):h(o)-h(o+a);f.push(B(t.x,e,t.width,Math.abs(i),c,d,n)),0>a?r+=a:o+=a}else if(y){const e=h(0>a?r+a:o),i=0>a?h(r)-h(r+a):h(o+a)-h(o);f.push(B(e,t.x,Math.abs(i),t.width,c,d,n)),0>a?r+=a:o+=a}}}const x="vertical"===d,v=a.roundedTop&&a.roundedTop>0?Math.max(0,a.roundedTop):0;for(const t of f){if("rect"!==t.type)continue;const e=null!==(o=null===(i=t.datum)||void 0===i?void 0:i.__aggregateValue)&&void 0!==o?o:0;t.roundedEdge=x?0>e?"bottom":"top":0>e?"left":"right",a.gradientFill&&(t.fillGradient=a.gradientFill)}if(v>0){const t=new Map;for(const e of f){if("rect"!==e.type)continue;const i=(null===(r=e.datum)||void 0===r?void 0:r.category)||"";t.has(i)||t.set(i,[]),t.get(i).push(e)}for(const e of t.values()){if(0===e.length)continue;const t=e.filter(t=>{var e,i;return(null!==(i=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==i?i:0)>=0}),i=e.filter(t=>{var e,i;return 0>(null!==(i=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==i?i:0)});t.length>0&&(t.reduce(x?(t,e)=>e.y>t.y?t:e:(t,e)=>t.x+t.w>e.x+e.w?t:e).roundedTop=v),i.length>0&&(i.reduce(x?(t,e)=>t.y+t.h>e.y+e.h?t:e:(t,e)=>e.x>t.x?t:e).roundedTop=v)}}return f},clusterbar:function(t,e){const{scales:i,columns:o,config:r,getR:n,getGroup:s,resolvePieceStyle:a}=t,{r:c,projection:l}=i,u=[],h="vertical"===l,d=[],f=new Set;for(const t of Object.values(o))for(const e of t.pieceData){const t=s?s(e):"_default";f.has(t)||(f.add(t),d.push(t))}const g=d.length||1;for(const t of Object.values(o)){const e=t.width/g,i=.2*e,o=e-i,r=new Map;for(const e of t.pieceData){const t=s?s(e):"_default";r.has(t)||r.set(t,[]),r.get(t).push(e)}for(let s=0;d.length>s;s++){const l=r.get(d[s])||[];for(const r of l){const l=n(r),f=a(r,d[s]);if(h){const n=t.x+s*e+i/2,a=c(0),h=c(l);u.push(B(n,Math.min(a,h),o,Math.abs(a-h),f,r,d[s]))}else{const n=t.x+s*e+i/2,a=c(0),h=c(l);u.push(B(Math.min(a,h),n,Math.abs(h-a),o,f,r,d[s]))}}}}const y=r.roundedTop&&r.roundedTop>0?Math.max(0,r.roundedTop):0;for(const t of u){if("rect"!==t.type)continue;const e=n(t.datum);y>0&&(t.roundedTop=y),t.roundedEdge=h?0>e?"bottom":"top":0>e?"left":"right",r.gradientFill&&(t.fillGradient=r.gradientFill)}return u},point:function(t,e){var i,o;const{scales:r,columns:n,getR:s,multiScales:a,resolvePieceStyle:c}=t,{r:l,projection:u}=r,h=[],d="vertical"===u,f="radial"===u,g=a.length>0,y=2*Math.PI,p=-Math.PI/2;for(const t of Object.values(n))for(const e of t.pieceData){const r=null!==(i=e.__rIndex)&&void 0!==i?i:0,n=null!==(o=e.__rValue)&&void 0!==o?o:s(e),u=g&&a[r]||l,m=c(e,t.name),x=m.r||5;let v,b;if(f){const e=p+(t.pctStart+t.pct/2)*y,i=u(n);v=Math.cos(e)*i,b=Math.sin(e)*i}else d?(v=t.middle,b=u(n)):(v=u(n),b=t.middle);h.push({type:"point",x:v,y:b,r:x,style:m,datum:e})}return h},swarm:function(t,e){const{scales:i,columns:o,getR:r,resolvePieceStyle:n}=t,{r:s,projection:a}=i,c=[],l="vertical"===a;for(const t of Object.values(o)){const e=t.width/2;for(let i=0;t.pieceData.length>i;i++){const o=t.pieceData[i],a=r(o),u=n(o,t.name),h=u.r||4,d=(7919*i%100/100-.5)*e*.8,f=l?t.middle+d:s(a),g=l?s(a):t.middle+d;c.push({type:"point",x:f,y:g,r:h,style:u,datum:o})}}return c},pie:re,donut:re,boxplot:function(t,e){var i,o,r,s,a,c;const{scales:l,columns:u,config:h,getR:d,resolveSummaryStyle:f}=t,{r:g,projection:y}=l,p=[],m="vertical"===y,x=!1!==h.showOutliers;for(const e of Object.values(u)){const l=e.pieceData.map(t=>d(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===l.length)continue;const u=l[0],h=l[l.length-1],y=null!==(i=n.quantile(l,.25))&&void 0!==i?i:u,v=null!==(o=n.quantile(l,.5))&&void 0!==o?o:(u+h)/2,b=null!==(r=n.quantile(l,.75))&&void 0!==r?r:h,k=b-y,A=y-1.5*k,w=b+1.5*k,S=null!==(s=l.find(t=>t>=A))&&void 0!==s?s:u,_=null!==(a=[...l].reverse().find(t=>w>=t))&&void 0!==a?a:h,P=f(e.pieceData[0],e.name),j=[];if(x)for(const t of e.pieceData){const i=d(t);if(A>i||i>w){const o=m?e.middle:g(i),r=m?g(i):e.middle;j.push({px:o,py:r,value:i,datum:t})}}if(p.push({type:"boxplot",x:m?e.middle:0,y:m?0:e.middle,projection:m?"vertical":"horizontal",columnWidth:.6*e.width,minPos:g(S),q1Pos:g(y),medianPos:g(v),q3Pos:g(b),maxPos:g(_),stats:{n:l.length,min:S,q1:y,median:v,q3:b,max:_,mean:l.reduce((t,e)=>t+e,0)/l.length},style:P,datum:e.pieceData,category:e.name,outliers:j}),x)for(const e of j)p.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:P.fill||(null===(c=t.config.themeSemantic)||void 0===c?void 0:c.secondary)||"#999",opacity:.6},datum:e.datum})}return p},violin:function(t,e){var i,o,r;const{scales:s,columns:a,config:c,getR:l,resolveSummaryStyle:u}=t,{r:h,projection:d}=s,f=[],g="vertical"===d,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,d=Array(y).fill(0);for(const t of e)d[Math.min(Math.floor((t-s)/c),y-1)]++;const m=Math.max(...d,1),x=t.width/2*.9;let v="";if(g){v=`M ${t.middle} ${h(s)}`;for(let e=0;y>e;e++){const i=h(s+(e+.5)*c);v+=` L ${t.middle+d[e]/m*x} ${i}`}v+=` L ${t.middle} ${h(a)}`;for(let e=y-1;e>=0;e--){const i=h(s+(e+.5)*c);v+=` L ${t.middle-d[e]/m*x} ${i}`}v+=" Z"}else{v=`M ${h(s)} ${t.middle}`;for(let e=0;y>e;e++)v+=` L ${h(s+(e+.5)*c)} ${t.middle-d[e]/m*x}`;v+=` L ${h(a)} ${t.middle}`;for(let e=y-1;e>=0;e--)v+=` L ${h(s+(e+.5)*c)} ${t.middle+d[e]/m*x}`;v+=" Z"}const b=u(t.pieceData[0],t.name);let k;if(p&&e.length>=4){const c=null!==(i=n.quantile(e,.25))&&void 0!==i?i:s,l=null!==(o=n.quantile(e,.5))&&void 0!==o?o:(s+a)/2,u=null!==(r=n.quantile(e,.75))&&void 0!==r?r:a;k={q1Pos:h(c),medianPos:h(l),q3Pos:h(u),centerPos:t.middle,isVertical:g}}const A=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};f.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:A,iqrLine:k,stats:ne(e),style:b,datum:t.pieceData,category:t.name})}return f},histogram:function(t,e){var i;const{scales:o,columns:r,config:n,getR:s,resolveSummaryStyle:a}=t,{r:c}=o,l=[],u=n.bins||25,h=n.normalize,d=null===(i=c.domain)||void 0===i?void 0:i.call(c),f=d?+d[0]:void 0,g=d?+d[1]:void 0;for(const t of Object.values(r)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const i=null!=f&&isFinite(f)?f:Math.min(...e),o=null!=g&&isFinite(g)?g:Math.max(...e),r=(o-i)/u||1,n=Array(u).fill(0);for(const t of e)i>t||t>o||n[Math.min(Math.floor((t-i)/r),u-1)]++;const d=e.length,y=Math.max(...n,1),p=a(t.pieceData[0],t.name);for(let e=0;u>e;e++){if(0===n[e])continue;const o=(h?n[e]/d:n[e]/y)*t.width*.9,s=c(i+e*r),a=c(i+(e+1)*r);l.push(B(Math.min(s,a),t.x+t.width-o,Math.abs(a-s),o,p,{bin:e,count:n[e],range:[i+e*r,i+(e+1)*r],category:t.name},t.name))}}return l},ridgeline:function(t,e){var i;const{scales:o,columns:r,config:n,getR:s,resolveSummaryStyle:a}=t,{r:c,projection:l}=o,u=[],h=n.bins||20,d="horizontal"===l,f=n.amplitude||1.5;for(const t of Object.values(r)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const o=e[0],r=e[e.length-1],n=(r-o)/h||1,l=Array(h).fill(0);for(const t of e)o>t||t>r||l[Math.min(Math.floor((t-o)/n),h-1)]++;const g=Math.max(...l,1),y=a(t.pieceData[0],t.name),p=t.width*f;let m="";if(d){const e=t.x+t.width;m=`M ${c(o)} ${e}`;for(let t=0;h>t;t++)m+=` L ${c(o+(t+.5)*n)} ${e-l[t]/g*p}`;m+=` L ${c(r)} ${e} Z`}else{const e=t.x;m=`M ${e} ${c(o)}`;for(let t=0;h>t;t++){const i=c(o+(t+.5)*n);m+=` L ${e+l[t]/g*p} ${i}`}m+=` L ${e} ${c(r)} Z`}const x=d?{x:Math.min(c(o),c(r)),y:t.x,width:Math.abs(c(r)-c(o)),height:t.width}:{x:t.x,y:Math.min(c(r),c(o)),width:t.width,height:Math.abs(c(r)-c(o))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:x,stats:ne(e),style:Object.assign(Object.assign({},y),{fillOpacity:null!==(i=y.fillOpacity)&&void 0!==i?i:.5}),datum:t.pieceData,category:t.name})}return u},timeline:function(t,e){const{scales:i,columns:o,getRawRange:r,resolvePieceStyle:n}=t,{r:s,projection:a}=i,c=[],l="horizontal"===a;for(const t of Object.values(o))for(const e of t.pieceData){const i=r(e);if(!i)continue;const[o,a]=i,u=n(e,t.name);if(l){const i=s(Math.min(o,a)),r=s(Math.max(o,a));c.push(B(i,t.x,r-i,t.width,u,e,t.name))}else{const i=s(Math.max(o,a)),r=s(Math.min(o,a));c.push(B(t.x,i,t.width,r-i,u,e,t.name))}}return c},funnel:function(t,e){var o,r,n,s,a,c,l,u;const{columns:h,getR:d,getStack:f,resolvePieceStyle:g}=t,y=[],p=e.width/2,m=!1!==t.config.showLabels,x=t.scales.o.domain().map(t=>h[t]).filter(Boolean);if(0===x.length)return y;const v=[],b=new Set;for(const t of x)for(const e of t.pieceData){const t=f?f(e):"_default";b.has(t)||(b.add(t),v.push(t))}const k=v.length>1&&"_default"!==v[0],A=[];let w=0;for(const t of x){const e=new Map;let i=0;for(const o of t.pieceData){const t=f?f(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t),n=d(o);r.total+=n,r.pieces.push(o),i+=n}A.push({col:t,groups:e,stepTotal:i}),k||i>w&&(w=i)}if(k)for(const t of A){let e=0,i=0;for(let o=0;v.length>o;o++){const r=t.groups.get(v[o]);r&&(o%2==0?e+=r.total:i+=r.total)}const o=Math.max(e,i);o>w&&(w=o)}if(0===w)return y;const S=new Map;for(const t of v){const e=A[0].groups.get(t);S.set(t,null!==(o=null==e?void 0:e.total)&&void 0!==o?o:0)}const _=A[0].stepTotal,P=k?.95*p:.9*e.width,j=i.scaleLinear().domain([0,w]).range([0,P]),M=null!==(r=t.config.connectorOpacity)&&void 0!==r?r:.3;let O=new Map;for(let e=0;A.length>e;e++){const i=A[e],o=i.col,r=0===e,h=o.width,d=.55*h,f=o.x+(h-d)/2,x=new Map;if(k){let t=0;for(const e of v){const o=i.groups.get(e);o&&(t+=j(o.total))}let e=p,n=p;for(let s=0;v.length>s;s++){const c=v[s],l=i.groups.get(c);if(!l)continue;const u=j(l.total),h=s%2==0,b=h?e:n-u;h?e+=u:n-=u;const k=g(l.pieces[0],c),A=null!==(a=S.get(c))&&void 0!==a?a:l.total,w=A>0?l.total/A*100:0,_=Object.assign(Object.assign({},l.pieces[0]),{__funnelValue:l.total,__funnelPercent:w,__funnelStep:o.name,__funnelIsFirstStep:r,__aggregateValue:l.total,__pieceCount:l.pieces.length,category:c});m&&(0===s&&(_.__funnelStepLabel=o.name,_.__funnelStepLabelX=p,_.__funnelStepLabelY=f,_.__funnelRowWidth=t),_.__funnelValueLabelX=b+u/2,_.__funnelValueLabelY=f,_.__funnelBarW=u),y.push(B(b,f,u,d,k,_,c)),x.set(c,{x:b,y:f,w:u,h:d})}}else{const t=i.stepTotal,e=j(t),a=p-e/2,c=v[0],l="_default"!==c,u=null!==(s=null===(n=i.groups.get(c))||void 0===n?void 0:n.pieces[0])&&void 0!==s?s:o.pieceData[0],h=l?c:o.name,b=g(u,h),k=_>0?t/_*100:0,A=Object.assign(Object.assign({},u),{__funnelValue:t,__funnelPercent:k,__funnelStep:o.name,__funnelIsFirstStep:r,category:l?c:o.name});m&&(A.__funnelStepLabel=o.name,A.__funnelStepLabelX=p,A.__funnelStepLabelY=f,A.__funnelRowWidth=e,A.__funnelValueLabelX=p,A.__funnelValueLabelY=f,A.__funnelBarW=e),y.push(B(a,f,e,d,b,A,h)),x.set(c,{x:a,y:f,w:e,h:d})}if(e>0&&O.size>0){const e=k?v:[v[0]];for(const r of e){const e=O.get(r),n=x.get(r);if(!e||!n)continue;const s=(()=>{const t=i.groups.get(r);return g(t?t.pieces[0]:o.pieceData[0],"_default"===r?o.name:r)})(),a={type:"trapezoid",points:[[e.x,e.y+e.h],[e.x+e.w,e.y+e.h],[n.x+n.w,n.y],[n.x,n.y]],style:{fill:s.fill||(null===(c=t.config.themeSemantic)||void 0===c?void 0:c.secondary)||"#999",opacity:M},datum:null!==(u=null===(l=i.groups.get(r))||void 0===l?void 0:l.pieces[0])&&void 0!==u?u:o.pieceData[0],category:"_default"===r?o.name:r};y.push(a)}}O=x}return y},"bar-funnel":function(t,e){var i,o,r,n;const{columns:s,getR:a,getStack:c,resolvePieceStyle:l,scales:u}=t,h=[],d=u.o.domain().map(t=>s[t]).filter(Boolean);if(0===d.length)return h;const f=[],g=new Set;for(const t of d)for(const e of t.pieceData){const t=c?c(e):"_default";g.has(t)||(g.add(t),f.push(t))}const y=f.length>1&&"_default"!==f[0],p=[];for(const t of d){const e=new Map;let i=0;for(const o of t.pieceData){const t=c?c(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t),n=a(o);r.total+=n,r.pieces.push(o),i+=n}p.push({col:t,groups:e,stepTotal:i})}const m=new Map;for(const t of f){const e=null===(i=p[0])||void 0===i?void 0:i.groups.get(t);m.set(t,null!==(o=null==e?void 0:e.total)&&void 0!==o?o:0)}const x=u.r,v=y?f.length:1,b=y?.15:0;for(let t=0;p.length>t;t++){const e=p[t],i=e.col,o=0===t,s=t>0?p[t-1]:null,a=i.width/v,c=a*b,u=a-c;for(let t=0;f.length>t;t++){const d=f[t],g=e.groups.get(d);if(!g)continue;const p=g.total,v=null!==(r=m.get(d))&&void 0!==r?r:p,b=v>0?p/v*100:0,k=null==s?void 0:s.groups.get(d),A=null!==(n=null==k?void 0:k.total)&&void 0!==n?n:p,w=o?0:Math.max(0,A-p),S=i.x+t*a+c/2,_=x(p),P=x(0)-_,j=l(g.pieces[0],y?d:i.name),M=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:p,__barFunnelPercent:b,__barFunnelIsFirstStep:o,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:w,__barFunnelCategory:"_default"===d?void 0:d,category:y?d:i.name,__barFunnelLabelX:S+u/2,__barFunnelLabelY:x(p+w)});if(h.push(B(S,_,u,P,j,M,y?d:i.name)),w>0){const t=x(p+w),e=_-t,o=Object.assign({},j),r=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:w,__barFunnelPercent:v>0?w/v*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===d?void 0:d,category:y?d:i.name});h.push(B(S,t,u,e,o,r,y?d:i.name))}}}return h},swimlane:function(t,e){const{scales:i,columns:o,getR:r,getStack:n,resolvePieceStyle:s}=t,{r:a,projection:c}=i,l=[],u="horizontal"===c;for(const t of Object.values(o)){let e=0;for(const i of t.pieceData){const o=Math.abs(r(i));if(0===o)continue;const c=n?n(i):t.name,h=s(i,c);if(u){const r=a(e),n=a(e+o);l.push(B(r,t.x,n-r,t.width,h,i,c))}else{const r=a(e+o),n=a(e);l.push(B(t.x,r,t.width,n-r,h,i,c))}e+=o}}return l}};class ae{constructor(t){this.rExtent=new x,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.version=0,this._dataVersion=0,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=t,this.buffer=new m(t.windowSize),this.getO=w(t.categoryAccessor||t.oAccessor,"category");const e=t.valueAccessor||t.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(t=>k(t,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new x)):(this.getR=k(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=w(t.stackBy),this.getGroup=w(t.groupBy),this.getColor=w(t.colorAccessor),this.getConnector=w(t.connectorAccessor),this.getDataId=w(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new m(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this._dataVersion++,t.bounded){this.buffer.clear(),this.rExtent.clear();for(const t of this.rExtents)t.clear();t.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else{this._hasStreamingData=!0;for(const i of t.inserts){const t=this.buffer.push(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i),null!=t&&this.evictValueExtent(t)}}return!0}pushValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.push(e[0]),this.rExtent.push(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].push(this.rAccessors[e](t));this.rExtent.push(this.getR(t))}else this.rExtent.push(this.getR(t))}evictValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.evict(e[0]),this.rExtent.evict(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].evict(this.rAccessors[e](t));this.rExtent.evict(this.getR(t))}else this.rExtent.evict(this.getR(t))}getRawRange(t){const e=this.config.valueAccessor||this.config.rAccessor;if(!e)return null;const i="function"==typeof e?e(t):t[e];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(t){const{config:e,buffer:o}=this;if(0===o.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(o,this.getR);const r=o.toArray(),n=e.projection||"vertical",s=e.oExtent||this.resolveCategories(r),a=this.computeValueDomain(r,s),c="horizontal"===n,l="radial"===n,u=Math.min(.9,Math.max(0,null!=e.barPadding?e.barPadding/("vertical"===n?t.width:t.height):.1));let h,d;if(l){h=i.scaleBand().domain(s).range([0,1]).padding(0);const o=Math.min(t.width,t.height)/2,r=e.innerRadius||0;d=i.scaleLinear().domain(a).range([r,o])}else c?(h=i.scaleBand().domain(s).range([0,t.height]).padding(u),d=i.scaleLinear().domain(a).range([0,t.width])):(h=i.scaleBand().domain(s).range([0,t.width]).padding(u),d=i.scaleLinear().domain(a).range([t.height,0]));this.scales={o:h,r:d,projection:n},this.multiScales=this.rAccessors.length>1&&e.multiAxis?this.rAccessors.map((r,n)=>{var s;const a=this.rExtents[n];a.dirty&&a.recalculate(o,r);let[l,u]=a.extent;l===1/0&&(l=0,u=1);const h=null!==(s=e.extentPadding)&&void 0!==s?s:.05,d=u-l,f=d>0?d*h:1;return l-=f,u+=f,l>0&&(l=0),c?i.scaleLinear().domain([l,u]).range([0,t.width]):i.scaleLinear().domain([l,u]).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,h,n,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(f,t),this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,r),this.config.pulse&&this.applyPulse(this.scene,r),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(t){const e=this.config.valueAccessor||this.config.rAccessor,i=Array.isArray(e)?e[t]:e;return"string"==typeof i?i:"value"+t}resolveCategories(t){const e=this.config.oSort,i="streaming"===this.config.runtimeMode||this._hasStreamingData,o="auto"===e?void 0:e;let r=null;if(i){r=new Set;for(const e of t)r.add(this.getO(e))}const n=r?Array.from(this.categories).filter(t=>r.has(t)):Array.from(this.categories);if(i&&void 0===o){const t=Math.max(50,3*r.size);if(this.categories.size>t){let e=this.categories.size-t;for(const t of this.categories){if(0>=e)break;r.has(t)||(this.categories.delete(t),e--)}}return n}if(!1===o)return n;if("function"==typeof o)return n.sort(o);const s=new Map;for(const e of t){const t=this.getO(e);s.set(t,(s.get(t)||0)+Math.abs(this.getR(e)))}return n.sort("asc"===o?(t,e)=>(s.get(t)||0)-(s.get(e)||0):(t,e)=>(s.get(e)||0)-(s.get(t)||0))}computeValueDomain(t,e){var i,o,r,n,s;const a=this.config.chartType,c=null!==(i=this.config.extentPadding)&&void 0!==i?i:.05;if("radial"===this.config.projection&&("pie"===a||"donut"===a))return[0,1];let l=0,u=0;if("bar"===a&&this.getStack&&this.config.normalize)l=0,u=1;else if("bar"===a&&this.getStack){const e=new Map,i=new Map;for(const o of t){const t=this.getO(o),r=this.getR(o);0>r?i.set(t,(i.get(t)||0)+r):e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>u&&(u=t);for(const t of i.values())l>t&&(l=t)}else if("bar"===a){const e=new Map;for(const i of t){const t=this.getO(i),o=this.getR(i);e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>u&&(u=t),l>t&&(l=t)}else if("swimlane"===a){const e=new Map;for(const i of t){const t=this.getO(i),o=Math.abs(this.getR(i));e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>u&&(u=t)}else if("clusterbar"===a||"bar-funnel"===a)for(const e of t){const t=this.getR(e);t>u&&(u=t),l>t&&(l=t)}else{const t=this.rExtent.extent[0],e=this.rExtent.extent[1];t!==1/0&&(l=t),e!==-1/0&&(u=e)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(l=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(u=this.config.rExtent[1]));const h="bar"===a||"clusterbar"===a||"bar-funnel"===a||"swimlane"===a;if(h&&null==(null===(o=this.config.rExtent)||void 0===o?void 0:o[0])&&null==(null===(r=this.config.rExtent)||void 0===r?void 0:r[1])&&(l>0&&(l=0),0>u&&(u=0)),"bar-funnel"!==a){const t=u-l,e=t>0?t*c:1;null!=(null===(n=this.config.rExtent)||void 0===n?void 0:n[0])||h&&!this.config.baselinePadding&&0===l||(l-=e),null!=(null===(s=this.config.rExtent)||void 0===s?void 0:s[1])||h&&!this.config.baselinePadding&&0===u||"swimlane"===a||(u+=e)}return[l,u]}buildColumns(t,e,i,o,r){var n;const s={},a=new Map;for(const e of t){const t=this.getO(e);a.has(t)||a.set(t,[]),a.get(t).push(e)}let c=0;if("radial"===o)for(const e of t)c+=Math.abs(this.getR(e));const l=this.config.dynamicColumnWidth;let u=null;if(l&&"radial"!==o){u=new Map;let t=0;for(const i of e){const e=a.get(i)||[];let o;o="string"==typeof l?e.reduce((t,e)=>t+(Number(e[l])||0),0):l(e),u.set(i,o),t+=o}const n=("horizontal"===o?r.height:r.width)-i.padding()*i.step()*e.length;if(t>0)for(const[e,i]of u)u.set(e,i/t*n)}let h=0,d=0;for(const t of e){const e=a.get(t)||[],o=e.reduce((t,e)=>t+Math.abs(this.getR(e)),0),r=c>0?o/c:0;let l,f;u?(l=d,f=u.get(t)||i.bandwidth(),d+=f+i.padding()*i.step()):(l=null!==(n=i(t))&&void 0!==n?n:0,f=i.bandwidth()),s[t]={name:t,x:l,y:0,width:f,middle:l+f/2,padding:i.padding()*i.step(),pieceData:e,pct:r,pctStart:h},h+=r}return s}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(t,e)=>this.resolvePieceStyle(t,e),resolveSummaryStyle:(t,e)=>this.resolveSummaryStyle(t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){if(!this.scales)return[];const i=this.getSceneContext(),o=se[this.config.chartType];let r=o?o(i,e):[];if(this.getConnector&&this.scales){const t=function(t,e){var i,o;const{scales:r,config:n,getConnector:s,getO:a}=t;if(!s||!r)return[];const c=[],{projection:l}=r,u=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const i=s(e);if(!i)continue;let o,r;"point"===t.type?(o=t.x,r=t.y):(o=t.x+t.w/2,r=t.y+("vertical"===l?0:t.h/2)),u.has(i)||u.set(i,[]),u.get(i).push({x:o,y:r,datum:e,category:a(e)})}const h=r.o.domain(),d=n.connectorStyle;for(const[e,r]of u)if(r.length>=2){r.sort((t,e)=>h.indexOf(t.category)-h.indexOf(e.category));for(let n=0;r.length-1>n;n++){const s=r[n],a=r[n+1],l="function"==typeof d?d(s.datum):d||{stroke:(null===(i=t.config.themeSemantic)||void 0===i?void 0:i.border)||(null===(o=t.config.themeSemantic)||void 0===o?void 0:o.secondary)||"#999",strokeWidth:1,opacity:.5};c.push({type:"connector",x1:s.x,y1:s.y,x2:a.x,y2:a.y,style:l,datum:s.datum,group:e})}}return c}(i,r);r=[...t,...r]}return r}resolvePieceStyle(t,e){if("function"==typeof this.config.pieceStyle){const i=this.config.pieceStyle(t,e);return i&&!i.fill&&e?Object.assign(Object.assign({},i),{fill:this.getColorFromScheme(e)}):i}return this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&e?{fill:this.config.barColors[e]||"#007bff"}:e?{fill:this.getColorFromScheme(e)}:{fill:"#007bff"}}getColorFromScheme(t){this._colorSchemeMap||(this._colorSchemeMap=new Map);const e=this._colorSchemeMap.get(t);if(e)return e;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||P,o=i[this._colorSchemeIndex%i.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(t,o),o}resolveSummaryStyle(t,e){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(t,e):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?O(i,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const e=new Map;for(let i=0;t.length>i;i++)e.set(t[i],i);return this._datumIndexCache={version:this._dataVersion,map:e},e}getCategoryIndexMap(t){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const e=this.config.categoryAccessor||this.config.oAccessor,i="function"==typeof e,o=i?null:e||"category",r=new Map;for(let n=0;t.length>n;n++){const s=t[n],a=i?e(s):s[o];let c=r.get(a);c||(c=[],r.set(a,c)),c.push(n)}return this._categoryIndexCache={version:this._dataVersion,map:r},r}rebuildPointQuadtree(){let t=0,e=0;for(const i of this.scene)"point"===i.type&&(t++,i.r>e&&(e=i.r));if(this._maxPointRadius=e,ae.QUADTREE_THRESHOLD>=t)return void(this._pointQuadtree=null);const i=Array(t);let r=0;for(const t of this.scene)"point"===t.type&&(i[r++]=t);this._pointQuadtree=o.quadtree().x(t=>t.x).y(t=>t.y).addAll(i)}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(t,e){var i,o;if(!this.config.decay)return;const r=e.length;if(1>=r)return;const n=this.getDatumIndexMap(e);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;const t=n.get(e.datum);if(null==t)continue;const s=this.computeDecayOpacity(t,r),a=null!==(o=null===(i=e.style)||void 0===i?void 0:i.opacity)&&void 0!==o?o:1;e.style=Object.assign(Object.assign({},e.style),{opacity:a*s})}}applyPulse(t,e){var i,o,r;if(!this.config.pulse||!this.timestampBuffer)return;const n="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(i=this.config.pulse.duration)&&void 0!==i?i:500,a=null!==(o=this.config.pulse.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",c=null!==(r=this.config.pulse.glowRadius)&&void 0!==r?r:4,l=this.getDatumIndexMap(e);let u=null;for(const i of t){if("connector"===i.type||"violin"===i.type||"boxplot"===i.type)continue;if("wedge"===i.type){const t=i.category;if(!t)continue;u||(u=this.getCategoryIndexMap(e));const o=u.get(t);if(!o)continue;let r=0;for(let t=0;o.length>t;t++){const e=this.timestampBuffer.get(o[t]);if(null==e)continue;const i=n-e;if(s>i){const t=1-i/s;t>r&&(r=t)}}r>0&&(i._pulseIntensity=r,i._pulseColor=a);continue}const t=l.get(i.datum);if(null==t)continue;const o=this.timestampBuffer.get(t);if(null==o)continue;const r=n-o;s>r&&(i._pulseIntensity=1-r/s,i._pulseColor=a,i._pulseGlowRadius=c)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,o=this.timestampBuffer.peek();return null!=o&&i>e-o}synthesizeIntroPositions(){var t,e,i,o,r;this.prevPositionMap.clear();const n=new Map,s=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.r(0))&&void 0!==e?e:0,a="horizontal"!==(null===(i=this.scales)||void 0===i?void 0:i.projection);let c;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],i=this.getNodeKey(e,n);i&&("rect"===e.type?this.prevPositionMap.set(i,a?{x:e.x,y:s,w:e.w,h:0,opacity:null!==(o=e.style.opacity)&&void 0!==o?o:1}:{x:s,y:e.y,w:0,h:e.h,opacity:null!==(r=e.style.opacity)&&void 0!==r?r:1}):"point"===e.type?this.prevPositionMap.set(i,{x:e.x,y:e.y,r:0,opacity:0}):"wedge"===e.type&&(void 0===c&&(c=e.startAngle),this.prevPositionMap.set(i,{x:e.cx,y:e.cy,startAngle:c,endAngle:c,innerRadius:e.innerRadius,outerRadius:e.outerRadius,opacity:0})))}}getNodeKey(t,e){var i,o,r;if("point"===t.type){const i=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,o=e.get(i)||0;return e.set(i,o+1),`${i}:${o}`}return"rect"===t.type?`r:${t.group||""}:${null!==(o=null===(i=t.datum)||void 0===i?void 0:i.category)&&void 0!==o?o:""}`:"wedge"===t.type?"w:"+(null!==(r=t.category)&&void 0!==r?r:""):null}snapshotPositions(){var t;this.prevPositionMap.clear();const e=new Map;for(let i=0;this.scene.length>i;i++){const o=this.scene[i],r=this.getNodeKey(o,e);r&&("point"===o.type?this.prevPositionMap.set(r,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity}):"rect"===o.type?this.prevPositionMap.set(r,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity}):"wedge"===o.type&&this.prevPositionMap.set(r,{x:o.cx,y:o.cy,startAngle:o.startAngle,endAngle:o.endAngle,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:null!==(t=o.style.opacity)&&void 0!==t?t:1}))}}startTransition(){var t,e,i,o,r,n,s,a,c,l,u,h,d,f,g,y,p,m,x,v,b;if(!this.config.transition||0===this.prevPositionMap.size)return;const k=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}let A=!1;const w=new Set,S=new Map;for(let t=0;this.scene.length>t;t++){const l=this.scene[t],u=this.getNodeKey(l,S);if(!u)continue;l._transitionKey=u;const h=this.prevPositionMap.get(u);if("point"===l.type)h?(w.add(u),l._targetOpacity=null!==(e=l.style.opacity)&&void 0!==e?e:1,(h.x!==l.x||h.y!==l.y||void 0!==h.r&&h.r!==l.r)&&(l._targetX=l.x,l._targetY=l.y,l._targetR=l.r,l.x=h.x,l.y=h.y,void 0!==h.r&&(l.r=h.r),A=!0)):(l._targetOpacity=null!==(i=l.style.opacity)&&void 0!==i?i:1,l._targetR=l.r,l.r=0,l.style=Object.assign(Object.assign({},l.style),{opacity:0}),A=!0);else if("rect"===l.type)h?(w.add(u),l._targetOpacity=null!==(o=l.style.opacity)&&void 0!==o?o:1,h.x===l.x&&h.y===l.y&&h.w===l.w&&h.h===l.h||(l._targetX=l.x,l._targetY=l.y,l._targetW=l.w,l._targetH=l.h,l.x=h.x,l.y=h.y,l.w=null!==(r=h.w)&&void 0!==r?r:l.w,l.h=null!==(n=h.h)&&void 0!==n?n:l.h,A=!0)):(l._targetOpacity=null!==(s=l.style.opacity)&&void 0!==s?s:1,l.style=Object.assign(Object.assign({},l.style),{opacity:0}),A=!0);else if("wedge"===l.type)if(h)w.add(u),l._targetOpacity=null!==(a=l.style.opacity)&&void 0!==a?a:1,h.startAngle===l.startAngle&&h.endAngle===l.endAngle||(l._targetStartAngle=l.startAngle,l._targetEndAngle=l.endAngle,l.startAngle=h.startAngle,l.endAngle=h.endAngle,A=!0);else{l._targetOpacity=null!==(c=l.style.opacity)&&void 0!==c?c:1,l._targetStartAngle=l.startAngle,l._targetEndAngle=l.endAngle;const t=l.startAngle;l.startAngle=t,l.endAngle=t,l.style=Object.assign(Object.assign({},l.style),{opacity:0}),this.prevPositionMap.set(u,{x:l.cx,y:l.cy,startAngle:t,endAngle:t,innerRadius:l.innerRadius,outerRadius:l.outerRadius,opacity:0}),A=!0}}this.exitNodes=[];for(const[t,e]of this.prevPositionMap)if(!w.has(t)){if(t.startsWith("p:"))this.exitNodes.push({type:"point",x:e.x,y:e.y,r:null!==(l=e.r)&&void 0!==l?l:3,style:{opacity:null!==(u=e.opacity)&&void 0!==u?u:1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))this.exitNodes.push({type:"rect",x:e.x,y:e.y,w:null!==(h=e.w)&&void 0!==h?h:0,h:null!==(d=e.h)&&void 0!==d?d:0,style:{opacity:null!==(f=e.opacity)&&void 0!==f?f:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("w:")){const i=((null!==(g=e.startAngle)&&void 0!==g?g:0)+(null!==(y=e.endAngle)&&void 0!==y?y:0))/2;this.exitNodes.push({type:"wedge",cx:e.x,cy:e.y,innerRadius:null!==(p=e.innerRadius)&&void 0!==p?p:0,outerRadius:null!==(m=e.outerRadius)&&void 0!==m?m:100,startAngle:null!==(x=e.startAngle)&&void 0!==x?x:0,endAngle:null!==(v=e.endAngle)&&void 0!==v?v:0,style:{opacity:null!==(b=e.opacity)&&void 0!==b?b:1},datum:null,category:t.slice(2),_targetStartAngle:i,_targetEndAngle:i,_targetOpacity:0,_transitionKey:t})}A=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),A&&(this.activeTransition={startTime:z(),duration:k})}advanceTransition(t){var e,i,o,r;if(!this.activeTransition)return!1;const n=E(t,this.activeTransition),s=L(n,"linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?"linear":"ease-out-cubic");for(const t of this.scene){const e=t._transitionKey;if(e)if("point"===t.type){if(void 0!==t._targetOpacity){const o=this.prevPositionMap.get(e),r=o?null!==(i=o.opacity)&&void 0!==i?i:1:0;t.style.opacity=D(r,t._targetOpacity,s)}const o=this.prevPositionMap.get(e);void 0!==t._targetX&&o&&(t.x=D(o.x,t._targetX,s),t.y=D(o.y,t._targetY,s)),void 0!==t._targetR&&void 0!==(null==o?void 0:o.r)&&(t.r=D(o.r,t._targetR,s))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e),r=i?null!==(o=i.opacity)&&void 0!==o?o:1:0;t.style.opacity=D(r,t._targetOpacity,s)}if(void 0===t._targetX)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=D(i.x,t._targetX,s),t.y=D(i.y,t._targetY,s),void 0!==i.w&&(t.w=D(i.w,t._targetW,s),t.h=D(i.h,t._targetH,s))}else if("wedge"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e),o=i?null!==(r=i.opacity)&&void 0!==r?r:1:0;t.style=Object.assign(Object.assign({},t.style),{opacity:D(o,t._targetOpacity,s)})}if(void 0!==t._targetStartAngle&&void 0!==t._targetEndAngle){const i=this.prevPositionMap.get(e);i&&void 0!==i.startAngle&&(t.startAngle=D(i.startAngle,t._targetStartAngle,s),t.endAngle=D(i.endAngle,t._targetEndAngle,s))}}}if(n>=1){for(const t of this.scene)if(void 0!==t._targetOpacity&&(t.style=Object.assign(Object.assign({},t.style||{}),{opacity:0===t._targetOpacity?0:t._targetOpacity}),t._targetOpacity=void 0),"point"===t.type){if(void 0===t._targetX&&void 0===t._targetR)continue;void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY),void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=void 0);if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}getData(){return this.buffer.toArray()}remove(t){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),i=this.getDataId,o=t=>e.has(i(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,i)=>{o(t)&&e.add(i)}),this.timestampBuffer.clear();for(let i=0;t.length>i;i++)e.has(i)||this.timestampBuffer.push(t[i])}const r=this.buffer.remove(o);if(0===r.length)return r;for(const t of r)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach(t=>this.categories.add(this.getO(t))),this._dataVersion++,this.version++,r}update(t,e){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const i=new Set(Array.isArray(t)?t:[t]),o=this.getDataId,r=new Set;this.buffer.forEach((t,e)=>{i.has(o(t))&&r.add(e)});const n=this.buffer.update(t=>i.has(o(t)),e);if(0===n.length)return n;for(const t of n)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach((t,e)=>{this.categories.add(this.getO(t)),r.has(e)&&this.pushValueExtent(t)}),this._dataVersion++,this.version++,n}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this._pointQuadtree=null,this._maxPointRadius=0,this._dataVersion++,this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}updateConfig(t){const e=Object.assign({},this.config);if(("colorScheme"in t&&t.colorScheme!==e.colorScheme||"themeCategorical"in t&&t.themeCategorical!==e.themeCategorical||"colorAccessor"in t&&!b(t.colorAccessor,e.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in t&&!b(t.categoryAccessor,e.categoryAccessor)||"oAccessor"in t&&!b(t.oAccessor,e.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,t),("categoryAccessor"in t||"oAccessor"in t)&&(b(t.categoryAccessor||t.oAccessor,e.categoryAccessor||e.oAccessor)||(this.getO=w(this.config.categoryAccessor||this.config.oAccessor,"category"),this.categories.clear())),"valueAccessor"in t||"rAccessor"in t){const i=t.valueAccessor||t.rAccessor,o=e.valueAccessor||e.rAccessor,r=Array.isArray(i)?i:[i],n=Array.isArray(o)?o:[o];if(r.length!==n.length||r.some((t,e)=>!b(t,n[e]))){const t=this.config.valueAccessor||this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>k(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new x)):(this.getR=k(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!b(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?w(this.config.stackBy):void 0),"groupBy"in t&&!b(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?w(this.config.groupBy):void 0),"colorAccessor"in t&&!b(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?w(this.config.colorAccessor):void 0),"connectorAccessor"in t&&!b(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?w(this.config.connectorAccessor):void 0)}}ae.QUADTREE_THRESHOLD=500;const ce={mercator:h.geoMercator,equalEarth:h.geoEqualEarth,albersUsa:h.geoAlbersUsa,orthographic:h.geoOrthographic,naturalEarth:h.geoNaturalEarth1,equirectangular:h.geoEquirectangular};function le(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function ue(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function he(t,e,i){return t?Object.assign(Object.assign({},i),"function"==typeof t?t(e):t):Object.assign({},i)}function de(t,e){if(2>t.length)return[t];const i=.4*e,o=[];let r=[t[0]];for(let e=1;t.length>e;e++){const n=t[e];Math.abs(n[0]-t[e-1][0])>i?(2>r.length||o.push(r),r=[n]):r.push(n)}return 2>r.length||o.push(r),o}function fe(t,e,i=24){const o=e[0]-t[0],r=e[1]-t[1],n=Math.sqrt(o*o+r*r);if(0===n)return[t,e];const s=-r/n,a=o/n,c=Math.min(.3*n,80),l=(t[0]+e[0])/2+s*c,u=(t[1]+e[1])/2+a*c,h=[];for(let o=0;i>=o;o++){const r=o/i,n=1-r;h.push([n*n*t[0]+2*n*r*l+r*r*e[0],n*n*t[1]+2*n*r*u+r*r*e[1]])}return h}function ge(t,e){if(2>t.length)return t;const i=e/2+1,o=[];for(let e=0;t.length>e;e++){const r=t[e];let n,s;0===e?(n=t[1][0]-r[0],s=t[1][1]-r[1]):e===t.length-1?(n=r[0]-t[e-1][0],s=r[1]-t[e-1][1]):(n=t[e+1][0]-t[e-1][0],s=t[e+1][1]-t[e-1][1]);const a=Math.sqrt(n*n+s*s)||1;o.push([r[0]+s/a*i,r[1]+-n/a*i])}return o}function ye(t,e,i,o,r){const n=e[0]-t[0],s=e[1]-t[1],a=Math.sqrt(n*n+s*s);if(0===a)return[t,e];const c=s/a,l=-n/a,u=r/2+1;return[[t[0]+c*u,t[1]+l*u],[e[0]+c*u,e[1]+l*u]]}class pe{constructor(t){this.scene=[],this.scales=null,this.version=0,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this.config=t}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}setAreas(t){this.areas=t}setPoints(t){this.pointData=t,this.streaming=!1}setLines(t){this.lineData=t}initStreaming(t=500){this.pointBuffer=new m(t),this.timestampBuffer=new m(t),this.streaming=!0}pushPoint(t){this.pointBuffer||this.initStreaming(),this.pointBuffer.push(t),this.timestampBuffer.push(performance.now()),this.lastIngestTime=performance.now()}pushMany(t){this.pointBuffer||this.initStreaming();const e=performance.now();for(const i of t)this.pointBuffer.push(i),this.timestampBuffer.push(e);this.lastIngestTime=e}removePoint(t){const{pointIdAccessor:e}=this.config;if(!e)throw Error("removePoint() requires pointIdAccessor to be configured");const i="function"==typeof e?e:t=>t[e],o=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>o.has(i(t)+"");if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),i=new Set;this.pointBuffer.forEach((e,o)=>{t(e)&&i.add(o)}),this.timestampBuffer.clear();for(let t=0;e.length>t;t++)i.has(t)||this.timestampBuffer.push(e[t])}const e=this.pointBuffer.remove(t);return e.length>0&&this.version++,e}{const t=[];return this.pointData=this.pointData.filter(e=>!o.has(i(e)+"")||(t.push(e),!1)),t.length>0&&this.version++,t}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.version++}computeScene(t){const{config:e}=this;this.projection=function(t){if(!t)return h.geoEqualEarth();if("string"==typeof t){const e=ce[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),h.geoEqualEarth())}if("object"==typeof t&&"type"in t){const e=ce[t.type],i=e?e():h.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=h.geoPath(this.projection),this.fitProjection(t),this.geoPath=h.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 o=this.scene;if(this.scene=this.buildSceneNodes(t),this.rebuildQuadtree(),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&!this._hasRenderedOnce&&this.scene.length>0&&e.introAnimation){const e=t.width/2,i=t.height/2,o=this.scene.filter(t=>"point"===t.type).map(t=>Object.assign(Object.assign({},t),{x:e,y:i}));o.length>0&&this.startTransition(o)}this._hasRenderedOnce=!0,e.transition&&o.length>0&&this.startTransition(o),this.version++}fitProjection(t){var e,i,o,r,n;const s=this.projection,a=this.config,c=[...this.areas],l=le(a.xAccessor,"lon"),u=le(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 d=ue(a.lineDataAccessor);for(const t of this.lineData){const e=d(t);if(e&&e.length>0){const t=e.map(t=>[l(t),u(t)]);c.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==c.length){if(a.projectionExtent){const[[e,i],[o,r]]=a.projectionExtent;s.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[e,i],[o,i],[o,r],[e,r],[e,i]]]}})}else if(s.clipAngle&&(null!==(e=s.clipAngle())&&void 0!==e?e:0)>0){const e=null!==(i=a.fitPadding)&&void 0!==i?i:0,o=Math.min(t.width,t.height);s.scale(o/2-o*e),s.translate([t.width/2,t.height/2])}else{const e=null!==(o=a.fitPadding)&&void 0!==o?o:0,i=t.width*e,r=t.height*e;s.fitExtent([[i,r],[t.width-i,t.height-r]],{type:"FeatureCollection",features:c})}this.baseScale=s.scale(),this.baseTranslate=s.translate(),this.baseRotation=null!==(n=null===(r=s.rotate)||void 0===r?void 0:r.call(s))&&void 0!==n?n:[0,0,0]}}applyZoomTransform(t,e){const i=this.projection;i&&(i.scale(this.baseScale*t.k),i.translate([this.baseTranslate[0]*t.k+t.x,this.baseTranslate[1]*t.k+t.y]),this.currentZoom=t.k,this.geoPath=h.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.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyZoomScale(t,e){const i=this.projection;i&&(i.scale(this.baseScale*t),i.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=h.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.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyRotation(t,e){const i=this.projection;i&&i.rotate&&(i.rotate(t),this.geoPath=h.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.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}setRotation(t){const e=this.projection;e&&e.rotate&&e.rotate(t)}getRotation(){var t,e,i;return null!==(i=null===(e=null===(t=this.projection)||void 0===t?void 0:t.rotate)||void 0===e?void 0:e.call(t))&&void 0!==i?i:this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let t=0,e=0;for(const i of this.scene)"point"===i.type&&(e++,i.r>t&&(t=i.r));if(this._maxPointRadius=t,pe.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const i=Array(e);let r=0;for(const t of this.scene)"point"===t.type&&(i[r++]=t);this._quadtree=o.quadtree().x(t=>t.x).y(t=>t.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(t){var e,i,o;const r=[],{config:n}=this,s=this.projection,a=this.geoPath,c=le(n.xAccessor,"lon"),l=le(n.yAccessor,"lat"),u=function(t){var e,i;return{fill:(null===(e=t.themeSemantic)||void 0===e?void 0:e.surface)||"#e0e0e0",stroke:(null===(i=t.themeSemantic)||void 0===i?void 0:i.border)||"#999",strokeWidth:.5,fillOpacity:1}}(n),d=function(t){var e;return{stroke:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",strokeWidth:1.5,fill:"none"}}(n),f=function(t){var e;return{fill:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",r:4,fillOpacity:.8}}(n);if(n.graticule){const e=!0===n.graticule?{}:n.graticule,i=h.geoGraticule();e.step&&i.step(e.step);const o=a(i())||"";o&&r.push({type:"geoarea",pathData:o,centroid:[t.width/2,t.height/2],bounds:[[0,0],[t.width,t.height]],screenArea:0,style:{fill:"none",stroke:e.stroke||"#e0e0e0",strokeWidth:e.strokeWidth||.5,strokeDasharray:e.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const t of this.areas){const e=a(t);if(!e)continue;const i=a.centroid(t),o=a.bounds(t),s=a.area(t),c=he(n.areaStyle,t,u);r.push({type:"geoarea",pathData:e,centroid:i,bounds:o,screenArea:s,style:c,datum:t,interactive:!0})}const g=ue(n.lineDataAccessor);for(const e of this.lineData){const i=g(e);if(!i||2>i.length)continue;let o=[];if("geo"===n.lineType){const t=Array(i.length);for(let e=0;i.length>e;e++)t[e]=[c(i[e]),l(i[e])];for(let e=0;t.length-1>e;e++){const i=t[e],r=t[e+1],n=h.geoDistance(i,r)||0,a=Math.max(2,Math.ceil(n/(Math.PI/180))),c=h.geoInterpolate(i,r);for(let t=0;a>=t;t++){if(e>0&&0===t)continue;const i=s(c(t/a));null!=i&&o.push(i)}}}else for(let t=0;i.length>t;t++){const e=i[t],r=s([c(e),l(e)]);null!=r&&o.push(r)}if(2>o.length)continue;const a=he(n.lineStyle,e,d),u="number"==typeof a.strokeWidth?a.strokeWidth:1;2!==i.length||2>o.length||"arc"!==n.flowStyle?2!==i.length||2>o.length||"offset"!==n.flowStyle||(o="geo"===n.lineType?ge(o,u):ye(o[0],o[o.length-1],0,0,u)):o=fe(o[0],o[o.length-1]);const f=de(o,t.width);if(f.length>1)for(const t of f){if(2>t.length)continue;const i={type:"line",path:t,style:Object.assign(Object.assign({},a),{_edgeFade:!0}),datum:e};r.push(i)}else r.push({type:"line",path:2>o.length&&f[0]||o,style:a,datum:e})}const y=this.getPoints(),p=n.pointIdAccessor?"function"==typeof n.pointIdAccessor?n.pointIdAccessor:t=>t[n.pointIdAccessor]:null,m=s.clipAngle&&null!==(e=s.clipAngle())&&void 0!==e?e:0,x=m>0?m*Math.PI/180:null,v=s.rotate?s.rotate():[0,0,0],b="function"==typeof s.center?s.center():[0,0],k=[(null!==(i=b[0])&&void 0!==i?i:0)-v[0],(null!==(o=b[1])&&void 0!==o?o:0)-v[1]];for(let t=0;y.length>t;t++){const e=y[t],i=c(e),o=l(e);if(null!=x&&h.geoDistance([i,o],k)>x)continue;const a=s([i,o]);if(!a)continue;const u=n.pointStyle?n.pointStyle(e):Object.assign({},f),d={type:"point",x:a[0],y:a[1],r:u.r||4,style:u,datum:e,pointId:p?p(e)+"":void 0};r.push(d)}return r}applyCartogramTransform(t,e){var o,r,n;const s=this.scene.filter(t=>"point"===t.type);if(2>s.length)return;const a=null!==(o=t.strength)&&void 0!==o?o: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,d=u.y,f=s.map(t=>l(t.datum)).filter(t=>isFinite(t)&&t>=0),g=Math.max(...f,1),y=Math.min(e.width,e.height)/2,p=i.scaleLinear().domain([0,g]).range([0,y]);this.cartogramLayout={cx:h,cy:d,maxCost:g,availableRadius:y},this.areas.length>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them."),this.scene=this.scene.filter(t=>"geoarea"!==t.type||!t.interactive);for(const t of s){if(t===u)continue;const e=Math.atan2(t.y-d,t.x-h),i=Math.sqrt(Math.pow(t.x-h,2)+Math.pow(t.y-d,2)),o=l(t.datum),r=i+((isFinite(o)?p(o):i)-i)*a;t.x=h+Math.cos(e)*r,t.y=d+Math.sin(e)*r}const m=e.width/2,x=e.height/2,v=m-u.x,b=x-u.y;if(Math.abs(v)>.5||Math.abs(b)>.5)for(const t of s)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 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,o=null===(n=e.datum)||void 0===n?void 0:n.target;if(i&&o){const r=t.get(i+""),n=t.get(o+"");r&&n&&(e.path=[r,n])}}}}applyDecay(){const t=this.config.decay;if(!t||!this.pointBuffer)return;const e=this.pointBuffer.size;if(0===e)return;const i=this.scene.filter(t=>"point"===t.type);for(let o=0;i.length>o;o++){const r=O(t,o,e);i[o]._decayOpacity=r,i[o].style=Object.assign(Object.assign({},i[o].style),{opacity:r})}}applyPulse(){var t,e;const i=this.config.pulse;if(!i||!this.timestampBuffer)return;const o=null!==(t=i.duration)&&void 0!==t?t:500,r=performance.now(),n=this.scene.filter(t=>"point"===t.type),s=this.timestampBuffer.toArray();for(let t=0;n.length>t&&s.length>t;t++){const a=r-s[t];o>a&&(n[t]._pulseIntensity=1-a/o,n[t]._pulseColor=i.color||"rgba(255,255,255,0.6)",n[t]._pulseGlowRadius=null!==(e=i.glowRadius)&&void 0!==e?e:4)}}get hasActivePulses(){var t,e;if(!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const i=null!==(e=null===(t=this.config.pulse)||void 0===t?void 0:t.duration)&&void 0!==e?e:500,o=this.timestampBuffer.toArray()[this.timestampBuffer.size-1];return performance.now()-o<i}startTransition(t){var e,i;const o=null!==(i=null===(e=this.config.transition)||void 0===e?void 0:e.duration)&&void 0!==i?i:300;if(0>=o)return;const r=new Map;for(const e of t)"point"===e.type&&e.pointId&&r.set(e.pointId,[e.x,e.y]);const n=this.scene.filter(t=>"point"===t.type);let s=!1;for(const t of n)if(t.pointId){const e=r.get(t.pointId);e&&(t._targetX=t.x,t._targetY=t.y,t.x=e[0],t.y=e[1],(Math.abs(e[0]-t._targetX)>.5||Math.abs(e[1]-t._targetY)>.5)&&(s=!0))}s&&(this.activeTransition={startTime:performance.now(),duration:o})}advanceTransition(t){if(!this.activeTransition)return!1;const e=E(t,this.activeTransition),i=L(e),o=this.scene.filter(t=>"point"===t.type);for(const t of o)if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=D(t.x,t._targetX,i),t.y=D(e,t._targetY,i)}if(e>=1){for(const t of o)null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0);return this.activeTransition=null,!1}return!0}}function me(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}function xe(e,i){var o,r,n;switch(e.type){case"line":{const o=e;if(0===o.path.length)return null;const r="M"+o.path.map(([t,e])=>`${t},${e}`).join("L");return t.jsx("path",{d:r,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||2,strokeDasharray:o.style.strokeDasharray,opacity:o.style.opacity},"line-"+i)}case"area":{const n=e;if(0===n.topPath.length)return null;const s=n.topPath.map(([t,e])=>`${t},${e}`).join("L"),a=[...n.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L");return t.jsx("path",{d:`M${s}L${a}Z`,fill:me(n.style.fill),fillOpacity:null!==(r=null!==(o=n.style.fillOpacity)&&void 0!==o?o:n.style.opacity)&&void 0!==r?r:.7,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},"area-"+i)}case"point":{const o=e;return t.jsx("circle",{cx:o.x,cy:o.y,r:o.r,fill:me(o.style.fill),opacity:null!==(n=o.style.opacity)&&void 0!==n?n:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},"point-"+i)}case"rect":{const o=e;return t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:me(o.style.fill),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},"rect-"+i)}case"heatcell":{const o=e;if(o.showValues&&null!=o.value&&o.w>=20&&o.h>=20){const e=o.valueFormat?o.valueFormat(o.value):Number.isInteger(o.value)?o.value+"":100>Math.abs(o.value)?1>Math.abs(o.value)?o.value.toPrecision(3):o.value.toFixed(1):o.value.toFixed(0),[r,n,s]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(o.fill),a=.299*r+.587*n+.114*s>128?"#000":"#fff",c=Math.max(10,Math.min(16,.3*Math.min(o.w,o.h)));return t.jsxs("g",{children:[t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill}),t.jsx("text",{x:o.x+o.w/2,y:o.y+o.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:c+"px",children:e})]},"heatcell-"+i)}return t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill},"heatcell-"+i)}case"candlestick":{const o=e,r=Math.min(o.openY,o.closeY),n=Math.max(Math.abs(o.openY-o.closeY),1),s=o.isUp?o.upColor:o.downColor;return t.jsxs("g",{children:[t.jsx("line",{x1:o.x,y1:o.highY,x2:o.x,y2:o.lowY,stroke:o.wickColor,strokeWidth:o.wickWidth}),t.jsx("rect",{x:o.x-o.bodyWidth/2,y:r,width:o.bodyWidth,height:n,fill:s,stroke:s,strokeWidth:1})]},"candle-"+i)}default:return null}}function ve(e,i){var o,r,n,s,a;const c=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",u=t=>`ord-${e.type}-${c}-${i}-${t}`,h=`ord-${e.type}-${c}-${i}`;switch(e.type){case"rect":{const i=e,o=function(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}(h)+"-grad",r=function(e,i){const o=e.fillGradient;if(!o)return null;let r=e.x,n=e.y,s=e.x,a=e.y+e.h;"bottom"===e.roundedEdge?(n=e.y+e.h,a=e.y):"right"===e.roundedEdge?(r=e.x+e.w,n=e.y,s=e.x,a=e.y):"left"===e.roundedEdge&&(r=e.x,n=e.y,s=e.x+e.w,a=e.y);const c=[];if("colorStops"in o){const e=o.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>e.length)return null;for(let i=0;e.length>i;i++)c.push(t.jsx("stop",{offset:e[i].offset,stopColor:e[i].color},i))}else{const i=me(e.style.fill);c.push(t.jsx("stop",{offset:0,stopColor:i,stopOpacity:o.topOpacity},"0")),c.push(t.jsx("stop",{offset:1,stopColor:i,stopOpacity:o.bottomOpacity},"1"))}return t.jsx("linearGradient",{id:i,gradientUnits:"userSpaceOnUse",x1:r,y1:n,x2:s,y2:a,children:c})}(i,o),n=r?`url(#${o})`:me(i.style.fill);if(i.roundedTop&&i.roundedTop>0){const e=Math.min(i.roundedTop,i.w/2,i.h/2),{x:o,y:s,w:a,h:c}=i;let l;switch(i.roundedEdge){case"right":l=`M${o},${s} L${o+a-e},${s} A${e},${e} 0 0 1 ${o+a},${s+e} L${o+a},${s+c-e} A${e},${e} 0 0 1 ${o+a-e},${s+c} L${o},${s+c} Z`;break;case"left":l=`M${o+a},${s} L${o+e},${s} A${e},${e} 0 0 0 ${o},${s+e} L${o},${s+c-e} A${e},${e} 0 0 0 ${o+e},${s+c} L${o+a},${s+c} Z`;break;case"bottom":l=`M${o},${s} L${o+a},${s} L${o+a},${s+c-e} A${e},${e} 0 0 1 ${o+a-e},${s+c} L${o+e},${s+c} A${e},${e} 0 0 1 ${o},${s+c-e} Z`;break;default:l=`M${o},${s+c} L${o},${s+e} A${e},${e} 0 0 1 ${o+e},${s} L${o+a-e},${s} A${e},${e} 0 0 1 ${o+a},${s+e} L${o+a},${s+c} Z`}return t.jsxs(y.Fragment,{children:[r&&t.jsx("defs",{children:r}),t.jsx("path",{d:l,fill:n,opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},h)}return t.jsxs(y.Fragment,{children:[r&&t.jsx("defs",{children:r}),t.jsx("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:n,opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},h)}case"point":{const i=e;return t.jsx("circle",{cx:i.x,cy:i.y,r:i.r,fill:me(i.style.fill),opacity:null!==(o=i.style.opacity)&&void 0!==o?o:.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth},h)}case"wedge":{const i=e,o=l.arc().innerRadius(i.innerRadius).outerRadius(i.outerRadius).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2);i.cornerRadius&&o.cornerRadius(i.cornerRadius);const r=o({})||"";return t.jsx("path",{d:r,transform:`translate(${i.cx},${i.cy})`,fill:me(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},h)}case"boxplot":{const i=e,o=i.columnWidth/2;return t.jsxs("g","vertical"===i.projection?{children:[t.jsx("line",{x1:i.x,y1:i.minPos,x2:i.x,y2:i.maxPos,stroke:i.style.stroke||"#333",strokeWidth:1}),t.jsx("rect",{x:i.x-o,y:Math.min(i.q1Pos,i.q3Pos),width:i.columnWidth,height:Math.abs(i.q3Pos-i.q1Pos),fill:me(i.style.fill),fillOpacity:null!==(r=i.style.fillOpacity)&&void 0!==r?r:.6,stroke:i.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:i.x-o,y1:i.medianPos,x2:i.x+o,y2:i.medianPos,stroke:i.style.stroke||"#333",strokeWidth:2}),t.jsx("line",{x1:i.x-.5*o,y1:i.minPos,x2:i.x+.5*o,y2:i.minPos,stroke:i.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:i.x-.5*o,y1:i.maxPos,x2:i.x+.5*o,y2:i.maxPos,stroke:i.style.stroke||"#333",strokeWidth:1})]}:{children:[t.jsx("line",{x1:i.minPos,y1:i.y,x2:i.maxPos,y2:i.y,stroke:i.style.stroke||"#333",strokeWidth:1}),t.jsx("rect",{x:Math.min(i.q1Pos,i.q3Pos),y:i.y-o,width:Math.abs(i.q3Pos-i.q1Pos),height:i.columnWidth,fill:me(i.style.fill),fillOpacity:null!==(n=i.style.fillOpacity)&&void 0!==n?n:.6,stroke:i.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:i.medianPos,y1:i.y-o,x2:i.medianPos,y2:i.y+o,stroke:i.style.stroke||"#333",strokeWidth:2}),t.jsx("line",{x1:i.minPos,y1:i.y-.5*o,x2:i.minPos,y2:i.y+.5*o,stroke:i.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:i.maxPos,y1:i.y-.5*o,x2:i.maxPos,y2:i.y+.5*o,stroke:i.style.stroke||"#333",strokeWidth:1})]},h)}case"violin":{const i=e,o=[t.jsx("path",{d:i.pathString,transform:i.translateX||i.translateY?`translate(${i.translateX},${i.translateY})`:void 0,fill:me(i.style.fill),fillOpacity:null!==(s=i.style.fillOpacity)&&void 0!==s?s:.6,stroke:i.style.stroke||"#333",strokeWidth:i.style.strokeWidth||1},u("path"))];if(i.iqrLine&&i.bounds){const e=i.bounds,r=e.x+e.width/2,n=e.y+e.height/2;e.height>e.width?o.push(t.jsx("line",{x1:r,y1:i.iqrLine.q1Pos,x2:r,y2:i.iqrLine.q3Pos,stroke:i.style.stroke||"#333",strokeWidth:2},u("iqr")),t.jsx("circle",{cx:r,cy:i.iqrLine.medianPos,r:3,fill:"white",stroke:i.style.stroke||"#333",strokeWidth:1},u("med"))):o.push(t.jsx("line",{x1:i.iqrLine.q1Pos,y1:n,x2:i.iqrLine.q3Pos,y2:n,stroke:i.style.stroke||"#333",strokeWidth:2},u("iqr")),t.jsx("circle",{cx:i.iqrLine.medianPos,cy:n,r:3,fill:"white",stroke:i.style.stroke||"#333",strokeWidth:1},u("med")))}return t.jsx("g",{children:o},h)}case"connector":return t.jsx("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:null!==(a=e.style.opacity)&&void 0!==a?a:.5},h);case"trapezoid":{const i=e,o=i.points.map(t=>`${t[0]},${t[1]}`).join(" ");return t.jsx("polygon",{points:o,fill:me(i.style.fill,"#999"),opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth},h)}default:return null}}function be(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{categorical:ke})})),t.accessibility.highContrast){const t="dark"===e.mode;e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{text:t?"#ffffff":"#000000",textSecondary:t?"#cccccc":"#333333",grid:t?"#666666":"#999999",border:t?"#888888":"#000000"})})}return e}pe.QUADTREE_THRESHOLD=500;const ke=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],Ae={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},we={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},Se={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:ke,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};d.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:Ae,setTheme(e){t(t=>{if("light"===e)return{theme:Ae};if("dark"===e)return{theme:we};if("high-contrast"===e)return{theme:Se};if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?we:Ae;return{theme:be(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:be(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 _e={light:Ae,dark:we,"high-contrast":Se,pastels:{mode:"light",colors:{primary:"#c9a0dc",secondary:"#b8a8c8",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",surface:"#fff5ee",text:"#4a3728",textSecondary:"#8b7355",grid:"#e8d5c4",border:"#e8d5c4",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#9ad4a3",danger:"#e8869a",warning:"#f0c888",error:"#c86070",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",secondary:"#a899c0",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",surface:"#251e35",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#88d4ab",danger:"#f0a0c0",warning:"#f0c888",error:"#e87690",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",secondary:"#6b7280",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",surface:"#ffffff",text:"#2c3e50",textSecondary:"#7f8c9b",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb",annotation:"#2563eb",success:"#10b981",danger:"#ef4444",warning:"#f59e0b",error:"#dc2626",info:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",secondary:"#9ca3af",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",surface:"#1f2937",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6",annotation:"#3b82f6",success:"#34d399",danger:"#f87171",warning:"#fbbf24",error:"#ef4444",info:"#60a5fa"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",secondary:"#666666",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",surface:"#ffffff",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000",annotation:"#cc0000",success:"#556b2f",danger:"#cc0000",warning:"#c8a415",error:"#8b0000",info:"#4682b4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",secondary:"#aaaaaa",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",surface:"#1a1a1a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333",annotation:"#ff3333",success:"#7a8b5a",danger:"#ff3333",warning:"#d4a843",error:"#cc0000",info:"#6aa4d4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",secondary:"#555555",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",surface:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000",success:"#556b2f",danger:"#8b0000",warning:"#b88700",error:"#6b0000",info:"#4a5568"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",secondary:"#a09880",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",surface:"#262520",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050",annotation:"#c05050",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",secondary:"#666666",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",surface:"#f8f8f8",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#e45050",success:"#2d7a3d",danger:"#c8303a",warning:"#d4a843",error:"#a02028",info:"#3a86c8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:18,labelSize:12,tickSize:10,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",secondary:"#a0a0a0",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",surface:"#1e1e1e",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b",annotation:"#ff6b6b",success:"#6fba78",danger:"#ff6b6b",warning:"#e0c060",error:"#d04040",info:"#5a9fd8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",secondary:"#7c5a9e",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",surface:"#ffffff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6",annotation:"#8b5cf6",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",secondary:"#b8a0d8",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",surface:"#1f1138",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa",annotation:"#a78bfa",success:"#4ade80",danger:"#fb7185",warning:"#fbbf24",error:"#f43f5e",info:"#22d3ee"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",secondary:"#525252",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe",annotation:"#0f62fe",success:"#24a148",danger:"#da1e28",warning:"#f1c21b",error:"#a2191f",info:"#0043ce"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",secondary:"#a8a8a8",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",surface:"#262626",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff",annotation:"#4589ff",success:"#42be65",danger:"#fa4d56",warning:"#f1c21b",error:"#da1e28",info:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function Pe(t){if(!t)return Ae;if("string"==typeof t){if("light"===t)return Ae;if("dark"===t)return we;if("high-contrast"===t)return Se;return _e[t]||Ae}const e="dark"===t.mode?we:Ae;return be(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 je(t){var e,i,o,r;return{background:t.colors.background,text:t.colors.text,textSecondary:t.colors.textSecondary,grid:t.colors.grid,border:t.colors.border,primary:t.colors.primary,fontFamily:t.typography.fontFamily,titleSize:t.typography.titleSize,labelSize:t.typography.labelSize,tickSize:t.typography.tickSize,categorical:t.colors.categorical,annotation:null!==(e=t.colors.annotation)&&void 0!==e?e:t.colors.text,legendSize:null!==(i=t.typography.legendSize)&&void 0!==i?i:t.typography.labelSize,titleFontSize:null!==(o=t.typography.titleFontSize)&&void 0!==o?o:t.typography.titleSize,tickFontFamily:null!==(r=t.typography.tickFontFamily)&&void 0!==r?r:t.typography.fontFamily}}function Me(e){const{categories:o,colorScheme:n,theme:s,position:a="right",totalWidth:c,totalHeight:l,margin:u,hasTitle:h=!1}=e;if(!o||0===o.length)return null;const d=function(t,e,o){const n=Array.isArray(e)?e:o.colors.categorical.length>0?o.colors.categorical:r.schemeCategory10;return i.scaleOrdinal().domain(t).range(n)}(o,n,s),f="top"===a||"bottom"===a;let g,y;if("left"===a?(g=4,y=u.top):"top"===a?(g=u.left,y=h?32:8):"bottom"===a?(g=u.left,y=Math.min(l-u.bottom+38,l-16)):(g=c-u.right+10,y=u.top),f){let e=0;const i=o.map((i,o)=>{const r=e;return e+=22+6.5*i.length+8,t.jsxs("g",{transform:`translate(${r},0)`,children:[t.jsx("rect",{width:14,height:14,fill:d(i),rx:2}),t.jsx("text",{x:20,y:7,dominantBaseline:"central",fontSize:s.typography.tickSize,fill:s.colors.text,fontFamily:s.typography.fontFamily,children:i})]},"legend-"+o)});return t.jsx("g",{className:"semiotic-legend",transform:`translate(${g},${y})`,children:i})}const p=o.map((e,i)=>t.jsxs("g",{transform:`translate(0,${20*i})`,children:[t.jsx("rect",{width:14,height:14,fill:d(e),rx:2}),t.jsx("text",{x:20,y:7,dominantBaseline:"central",fontSize:s.typography.tickSize,fill:s.colors.text,fontFamily:s.typography.fontFamily,children:e})]},"legend-"+i));return t.jsx("g",{className:"semiotic-legend",transform:`translate(${g},${y})`,children:p})}function Oe(t,e){if(!e||!t||0===t.length)return[];const i="function"==typeof e?e:t=>t[e],o=new Set;for(const e of t){const t=i(e);null!=t&&o.add(t+"")}return Array.from(o)}function Te(t,e){return t.color||e.colors.annotation||e.colors.text}function Le(e){const{annotations:i}=e;if(!i||0===i.length)return null;const o=[];for(let t=0;i.length>t;t++){const r=Ee(i[t],t,e);r&&o.push(r)}return o.length>0?t.jsx("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:o}):null}function Ee(e,i,o){var r,n,s,a;const{scales:c,layout:l,theme:u,xAccessor:h,yAccessor:d}=o;switch(e.type){case"y-threshold":{const n=e.value;if(null==n)return null;const s=Te(e,u),a=e.label,h=e.labelPosition||"right",d=e.strokeDasharray||"6,4",f=null!==(r=e.strokeWidth)&&void 0!==r?r:1.5;if("horizontal"===o.projection&&c.r){const e=c.r(n);return null==e?null:t.jsxs("g",{children:[t.jsx("line",{x1:e,y1:0,x2:e,y2:l.height,stroke:s,strokeWidth:f,strokeDasharray:d}),a&&t.jsx("text",{x:e+4,y:12,textAnchor:"start",fontSize:u.typography.tickSize,fill:s,fontFamily:u.typography.fontFamily,children:a})]},"ann-ythresh-"+i)}const g=c.y?c.y(n):c.r?c.r(n):null;return null==g?null:t.jsxs("g",{children:[t.jsx("line",{x1:0,y1:g,x2:l.width,y2:g,stroke:s,strokeWidth:f,strokeDasharray:d}),a&&t.jsx("text",{x:"left"===h?4:"center"===h?l.width/2:l.width-4,y:g-6,textAnchor:"left"===h?"start":"center"===h?"middle":"end",fontSize:u.typography.tickSize,fill:s,fontFamily:u.typography.fontFamily,children:a})]},"ann-ythresh-"+i)}case"x-threshold":{const o=e.value;if(null==o||!c.x)return null;const r=c.x(o);if(null==r)return null;const s=Te(e,u),a=e.label,h=e.labelPosition||"top",d=null!==(n=e.strokeWidth)&&void 0!==n?n:1.5;return t.jsxs("g",{children:[t.jsx("line",{x1:r,y1:0,x2:r,y2:l.height,stroke:s,strokeWidth:d,strokeDasharray:e.strokeDasharray||"6,4"}),a&&t.jsx("text",{x:r+4,y:"bottom"===h?l.height-4:"center"===h?l.height/2:12,textAnchor:"start",fontSize:u.typography.tickSize,fill:s,fontFamily:u.typography.fontFamily,children:a})]},"ann-xthresh-"+i)}case"band":{const o=null!=e.y0&&c.y?c.y(e.y0):null,r=null!=e.y1&&c.y?c.y(e.y1):null;if(null==o||null==r)return null;const n=Math.min(o,r),a=Math.abs(r-o),h=e.fill||Te(e,u),d=null!==(s=e.opacity)&&void 0!==s?s:.1;return t.jsxs("g",{children:[t.jsx("rect",{x:0,y:n,width:l.width,height:a,fill:h,opacity:d}),e.label&&t.jsx("text",{x:l.width-4,y:n+12,textAnchor:"end",fontSize:u.typography.tickSize,fill:h,fontFamily:u.typography.fontFamily,children:e.label})]},"ann-band-"+i)}case"category-highlight":{if(!e.category||!c.o)return null;const r=c.o(e.category);if(null==r)return null;const n=c.o.bandwidth?c.o.bandwidth():40,s=Te(e,u),h=null!==(a=e.opacity)&&void 0!==a?a:.1;return t.jsx("rect","horizontal"===o.projection?{x:0,y:r,width:l.width,height:n,fill:s,opacity:h}:{x:r,y:0,width:n,height:l.height,fill:s,opacity:h},"ann-cathighlight-"+i)}case"label":case"text":{const o=function(t,e,i){return null!=t.x&&e.x?e.x(t.x):i&&null!=t[i]&&e.x?e.x(t[i]):null}(e,c,h),r=function(t,e,i){return null!=t.y&&e.y?e.y(t.y):i&&null!=t[i]&&e.y?e.y(t[i]):null}(e,c,d);if(null==o||null==r)return null;const n=e.dx||0,s=e.dy||0,a=e.color||u.colors.text;return t.jsxs("g",{children:["label"===e.type&&t.jsx("line",{x1:o,y1:r,x2:o+n,y2:r+s,stroke:u.colors.textSecondary,strokeWidth:1}),t.jsx("text",{x:o+n,y:r+s,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||u.typography.labelSize,fill:a,fontFamily:u.typography.fontFamily,fontWeight:e.fontWeight,children:e.label||e.title})]},"ann-label-"+i)}default:return null}}const De={Sparkline:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign(Object.assign({chartType:"line",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.lineBy||e,colorAccessor:e},o),{showAxes:!1,margin:o.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0})},LineChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"line",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.lineBy||e,colorAccessor:e,colorScheme:i,lineStyle:r.lineStyle},o)},AreaChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"area",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",y0Accessor:r.y0Accessor,groupAccessor:r.areaBy||e,colorAccessor:e,colorScheme:i},o)},StackedAreaChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"stackedarea",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.areaBy,colorAccessor:e||r.areaBy,colorScheme:i,normalize:r.normalize},o)},Scatterplot:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"scatter",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,sizeAccessor:r.sizeBy,colorScheme:i},o)},CandlestickChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"candlestick",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.highAccessor||"high",highAccessor:r.highAccessor||"high",lowAccessor:r.lowAccessor||"low",openAccessor:r.openAccessor,closeAccessor:r.closeAccessor,candlestickStyle:r.candlestickStyle},o)},BubbleChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"scatter",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange||[5,40],colorScheme:i},o)},ConnectedScatterplot:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"line",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,colorScheme:i,showPoints:!0},o)},Heatmap:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"heatmap",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",valueAccessor:r.valueAccessor,colorScheme:i||r.colorScheme||"blues",showValues:r.showValues,cellBorderColor:r.cellBorderColor},o)},BarChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:null!==(n=r.sort)&&void 0!==n&&n,colorAccessor:e,colorScheme:i,barPadding:r.barPadding},null!=r.roundedTop&&{roundedTop:r.roundedTop}),o)}},StackedBarChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.stackBy,colorAccessor:e||r.stackBy,colorScheme:i,projection:"horizontal"===r.orientation?"horizontal":"vertical",normalize:r.normalize,oSort:null!==(n=r.sort)&&void 0!==n&&n},null!=r.roundedTop&&{roundedTop:r.roundedTop}),o)}},GroupedBarChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"clusterbar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",groupBy:r.groupBy,colorAccessor:e||r.groupBy,colorScheme:i,projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:null!==(n=r.sort)&&void 0!==n&&n,barPadding:r.barPadding},null!=r.roundedTop&&{roundedTop:r.roundedTop}),o)}},PieChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign(Object.assign({chartType:"pie",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",colorAccessor:e||r.categoryAccessor,colorScheme:i},null!=r.cornerRadius&&{cornerRadius:r.cornerRadius}),o)},DonutChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign(Object.assign({chartType:"donut",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",innerRadius:r.innerRadius||60,colorAccessor:e||r.categoryAccessor,colorScheme:i},null!=r.cornerRadius&&{cornerRadius:r.cornerRadius}),o)},Histogram:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"histogram",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"horizontal",bins:r.bins,colorAccessor:e,colorScheme:i},o)},BoxPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"boxplot",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorScheme:i},o)},ViolinPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"violin",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",bins:r.bins,colorScheme:i},o)},SwarmPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"swarm",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:e,colorScheme:i},o)},DotPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"point",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:e,colorScheme:i},o),{showGrid:null===(n=o.showGrid)||void 0===n||n})}},SwimlaneChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"swimlane",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.subcategoryAccessor,colorAccessor:e||r.subcategoryAccessor,categoryAccessor:r.categoryAccessor,subcategoryAccessor:r.subcategoryAccessor,colorScheme:i,projection:"horizontal"===r.orientation?"horizontal":"vertical"},o)},RidgelinePlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"ridgeline",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",bins:r.bins,amplitude:r.amplitude},o)},LikertChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"bar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.levelAccessor||"level",colorAccessor:e||r.levelAccessor||"level",colorScheme:i,normalize:!0,projection:"vertical"===r.orientation?"vertical":"horizontal"},o)},FunnelChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{const n="vertical"===r.orientation;return Object.assign({chartType:n?"bar-funnel":"funnel",data:t,oAccessor:r.stepAccessor||"step",rAccessor:r.valueAccessor||"value",colorAccessor:e||r.categoryAccessor,categoryAccessor:r.categoryAccessor,projection:n?"vertical":"horizontal",connectorAccessor:r.connectorAccessor,connectorStyle:r.connectorStyle,colorScheme:i},o)}},GaugeChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n,s,a,c;const l=null!==(n=r.min)&&void 0!==n?n:0,u=null!==(s=r.max)&&void 0!==s?s:100,h=null!==(a=r.sweep)&&void 0!==a?a:240,d=null!==(c=r.arcWidth)&&void 0!==c?c:.3,f=180+(360-h)/2,g=r.thresholds||[{value:u,color:"#4e79a7"}],y=g.map((t,e)=>({category:t.label||"zone-"+e,value:t.value-(e>0?g[e-1].value:l)})),p={};g.forEach((t,e)=>{p[t.label||"zone-"+e]=t.color||"#4e79a7"});const m=o.margin||{top:20,right:20,bottom:30,left:40},[x,v]=o.size||[300,300];return Object.assign(Object.assign({chartType:"donut",data:y,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:Math.max(10,Math.min(x-(m.left||0)-(m.right||0),v-(m.top||0)-(m.bottom||0))/2*(1-d)),sweepAngle:h,startAngle:f,oSort:!1,pieceStyle:(t,e)=>({fill:p[e||""]||"#4e79a7"})},o),{showAxes:!1,__gauge:{gMin:l,gMax:u,sweep:h,arcWidth:d,value:r.value,startAngleDeg:f,thresholds:g}})}},ForceDirectedGraph:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"force",nodes:r.nodes,edges:r.edges,nodeIDAccessor:r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,colorBy:e,colorScheme:i,iterations:r.iterations,forceStrength:r.forceStrength,showLabels:r.showLabels,nodeLabel:r.nodeLabel,nodeSize:r.nodeSize,nodeSizeRange:r.nodeSizeRange,nodeStyle:r.nodeStyle,edgeStyle:r.edgeStyle},o)},SankeyDiagram:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"sankey",nodes:r.nodes,edges:r.edges,nodeIDAccessor:r.nodeIdAccessor||r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,valueAccessor:r.valueAccessor,orientation:r.orientation,nodeAlign:r.nodeAlign,nodeWidth:r.nodeWidth,nodePaddingRatio:r.nodePaddingRatio,showLabels:r.showLabels,nodeLabel:r.nodeLabel,colorBy:e,edgeColorBy:r.edgeColorBy,edgeOpacity:r.edgeOpacity,nodeStyle:r.nodeStyle,edgeStyle:r.edgeStyle,colorScheme:i},o)},ChordDiagram:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"chord",nodes:r.nodes,edges:r.edges,valueAccessor:r.valueAccessor,padAngle:r.padAngle,groupWidth:r.groupWidth,showLabels:r.showLabels,colorBy:e,edgeColorBy:r.edgeColorBy,colorScheme:i},o)},TreeDiagram:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"cluster"===r.layout?"cluster":"tree",data:t,childrenAccessor:r.childrenAccessor,colorBy:e,colorByDepth:r.colorByDepth,orientation:r.orientation,showLabels:r.showLabels,colorScheme:i},o)},Treemap:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"treemap",data:t,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:e,colorByDepth:r.colorByDepth,showLabels:r.showLabels,colorScheme:i},o)},CirclePack:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"circlepack",data:t,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:e,colorByDepth:r.colorByDepth,colorScheme:i},o)},ChoroplethMap:{frameType:"geo",buildProps:(t,e,i,o,r)=>Object.assign({areas:r.areas,projection:r.projection||"equalEarth",areaStyle:r.areaStyle,valueAccessor:r.valueAccessor,colorScheme:i||"blues",graticule:r.graticule,fitPadding:r.fitPadding},o)},ProportionalSymbolMap:{frameType:"geo",buildProps:(t,e,i,o,r)=>Object.assign({points:t||r.points,xAccessor:r.xAccessor||"lon",yAccessor:r.yAccessor||"lat",areas:r.areas,areaStyle:r.areaStyle,sizeBy:r.sizeBy,colorBy:e,colorScheme:i,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding},o)},FlowMap:{frameType:"geo",buildProps:(t,e,i,o,r)=>{var n,s,a,c,l;const u=(Array.isArray(t)?t:null)||r.flows||[],h=r.nodeIdAccessor||"id",d=r.valueAccessor||"value",f=r.xAccessor||"lon",g=r.yAccessor||"lat",y="function"==typeof f?f:t=>t[f],p="function"==typeof g?g:t=>t[g],m=(r.nodes||[]).map(t=>Object.assign(Object.assign({},t),{x:y(t),y:p(t)})),x=new Map;for(const t of m)x.set(t[h]+"",t);const v=null!==(n=r.edgeColorBy)&&void 0!==n?n:e,b="function"==typeof v,k=u.map(t=>{if(!t||null==t.source||null==t.target)return null;const e=x.get(t.source+""),i=x.get(t.target+"");return e&&i?Object.assign(Object.assign({},t),{coordinates:[{x:e.x,y:e.y},{x:i.x,y:i.y}]}):null}).filter(Boolean),A="__flowMapEdgeColor",w=v?b?M(k.map(t=>({[A]:v(t)})),A,i||"category10"):M(k,v,i||"category10"):null,S=t=>v&&w?function(t,e,i){if("function"==typeof e){const o=e(t);return i&&o&&"string"==typeof o&&!function(t){const e=t.toLowerCase();return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")||j.has(e)}(o)?i(o):o}const o=null==t?void 0:t[e];return i?i(o):_[Math.abs(function(t){let e=0;for(let i=0;t.length>i;i++)e=(e<<5)-e+t.charCodeAt(i),e&=e;return Math.abs(e)}(o+""))%_.length]}(t,v,w):"#007bff";let P=1/0,O=-1/0;for(const t of k){const e=Number(null!==(s=t[d])&&void 0!==s?s:0);isFinite(e)&&(P>e&&(P=e),e>O&&(O=e))}const T=O>P?O-P:0,[L,E]=null!==(a=r.edgeWidthRange)&&void 0!==a?a:[1,8],D=E-L,z=null!==(c=r.edgeOpacity)&&void 0!==c?c:.6,$=null!==(l=r.edgeLinecap)&&void 0!==l?l:"round";return Object.assign({lines:k,points:m,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:r.lineType||"geo",flowStyle:r.flowStyle||"basic",areas:r.areas,areaStyle:r.areaStyle,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding,colorScheme:i,lineStyle:t=>{const e=Number(null==t?void 0:t[d]),i=L+Math.max(0,Math.min(1,T>0?((Number.isFinite(e)?e:P)-P)/T:0))*D;return{stroke:S(t),strokeWidth:i,strokeLinecap:$,opacity:z,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8})},o)}}};function ze(t){return Math.round(100*t)/100+""}function $e(e,i){const o=je(i.theme),r=i.idPrefix?i.idPrefix+"-":"",n="string"==typeof i.title?i.title:void 0,s=n?r+"semiotic-title":void 0,a=i.description?r+"semiotic-desc":void 0,c=[s,a].filter(Boolean).join(" ")||void 0;return t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:i.className,width:i.width,height:i.height,role:"img","aria-labelledby":c,style:{fontFamily:o.fontFamily},children:[n&&t.jsx("title",{id:s,children:n}),i.description&&t.jsx("desc",{id:a,children:i.description}),i.defs&&t.jsx("defs",{children:i.defs}),i.background&&"transparent"!==i.background&&t.jsx("rect",{x:0,y:0,width:i.width,height:i.height,fill:i.background}),t.jsx("g",{id:r+"data-area",transform:i.innerTransform,children:e}),n&&t.jsx("text",{id:r+"chart-title",x:i.width/2,y:16,textAnchor:"middle",fontSize:o.titleSize,fontWeight:"bold",fill:o.text,fontFamily:o.fontFamily,children:n}),i.legend&&t.jsx("g",{id:r+"legend",children:i.legend}),i.outerElements]})}function Ce(e){var i,o,r,n;const s=Pe(e.theme),a=e.size||[500,300],c=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),e.margin),l=e.legendPosition;e.showLegend&&(l&&"right"!==l?"left"===l?c.left=Math.max(c.left,100):"bottom"===l?c.bottom=Math.max(c.bottom,70):"top"===l&&(c.top=Math.max(c.top,40)):c.right=Math.max(c.right,100));const u=a[0]-c.left-c.right,h=a[1]-c.top-c.bottom,d="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),f={chartType:e.chartType,windowSize:null!==(i=e.windowSize)&&void 0!==i?i:200,windowMode:null!==(o=e.windowMode)&&void 0!==o?o:"sliding",arrowOfTime:d&&null!==(r=e.arrowOfTime)&&void 0!==r?r:"right",extentPadding:null!==(n=e.extentPadding)&&void 0!==n?n:.1,xAccessor:d?void 0:e.xAccessor,yAccessor:d?void 0:e.yAccessor,timeAccessor:d?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,groupAccessor:e.groupAccessor,categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,sizeRange:e.sizeRange,binSize:e.binSize,normalize:e.normalize,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,openAccessor:e.openAccessor,highAccessor:e.highAccessor,lowAccessor:e.lowAccessor,closeAccessor:e.closeAccessor,candlestickStyle:e.candlestickStyle,lineStyle:e.lineStyle,pointStyle:e.pointStyle,areaStyle:e.areaStyle,colorScheme:e.colorScheme||s.colors.categorical,barColors:e.barColors},y=new q(f);if(e.data&&y.ingest({inserts:e.data,bounded:!0}),y.computeScene({width:u,height:h}),!y.scales||0===y.scene.length)return g.renderToStaticMarkup($e(null,{width:a[0],height:a[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:s,innerTransform:`translate(${c.left},${c.top})`,idPrefix:e._idPrefix}));const p=e._idPrefix,m=e.showGrid?function(e,i,o,r){const{grid:n}=je(o),s=r?r+"-":"",a=e.x.ticks(5),c=e.y.ticks(5);return t.jsxs("g",{id:s+"grid",className:"semiotic-grid",opacity:.8,children:[a.map((o,r)=>{const s=e.x(o);return t.jsx("line",{x1:s,y1:0,x2:s,y2:i.height,stroke:n,strokeWidth:.5},"gx-"+r)}),c.map((o,r)=>{const s=e.y(o);return t.jsx("line",{x1:0,y1:s,x2:i.width,y2:s,stroke:n,strokeWidth:.5},"gy-"+r)})]})}(y.scales,{width:u,height:h},s,p):null,x=y.scene.map((t,e)=>xe(t,e)).filter(Boolean),v=!1!==e.showAxes?function(e,i,o,r,n){var s,a,c,l;const u=je(r),h=e.x.ticks(5).map(t=>({pixel:e.x(t),label:(o.xFormat||o.tickFormatTime||ze)(t)})),d=e.y.ticks(5).map(t=>({pixel:e.y(t),label:(o.yFormat||o.tickFormatValue||ze)(t)}));return t.jsxs("g",{id:(n?n+"-":"")+"axes",className:"stream-axes",children:[t.jsx("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:u.border,strokeWidth:1}),h.map((e,o)=>t.jsxs("g",{transform:`translate(${e.pixel},${i.height})`,children:[t.jsx("line",{y2:5,stroke:u.border,strokeWidth:1}),t.jsx("text",{y:18,textAnchor:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label})]},"xtick-"+o)),o.xLabel&&t.jsx("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,children:o.xLabel}),t.jsx("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:u.border,strokeWidth:1}),d.map((e,i)=>t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:u.border,strokeWidth:1}),t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label})]},"ytick-"+i)),o.yLabel&&t.jsx("text",{x:15-(null!==(a=null===(s=o.margin)||void 0===s?void 0:s.left)&&void 0!==a?a:40),y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-(null!==(l=null===(c=o.margin)||void 0===c?void 0:c.left)&&void 0!==l?l:40)}, ${i.height/2})`,children:o.yLabel})]})}(y.scales,{width:u,height:h},e,s,p):null,b=e.annotations?Le({annotations:e.annotations,scales:{x:y.scales.x,y:y.scales.y},layout:{width:u,height:h},theme:s,xAccessor:"string"==typeof e.xAccessor?e.xAccessor:void 0,yAccessor:"string"==typeof e.yAccessor?e.yAccessor:void 0,idPrefix:p}):null,k=e.showLegend?(()=>{const t=Oe(e.data||[],e.colorAccessor||e.groupAccessor);return 0===t.length?null:Me({categories:t,colorScheme:e.colorScheme,theme:s,position:e.legendPosition||"right",totalWidth:a[0],totalHeight:a[1],margin:c,hasTitle:!!e.title})})():null,A=t.jsxs(t.Fragment,{children:[m,b,x,v]});return g.renderToStaticMarkup($e(A,{width:a[0],height:a[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:s,innerTransform:`translate(${c.left},${c.top})`,legend:k,idPrefix:e._idPrefix}))}function Re(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const Ne=new Set(["tree","cluster","treemap","circlepack","partition"]);function Be(e){const i=Pe(e.theme),o=e.chartType||"force",r=e.size||[500,500],n=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),e.margin),s=r[0]-n.left-n.right,a=r[1]-n.top-n.bottom,c=function(t){return oe[t]}(o);if(!c)throw Error(`No layout plugin found for chart type: "${o}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const u={chartType:o,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,colorBy:e.colorBy,colorScheme:e.colorScheme||i.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange};let h,d;if(Ne.has(o)){const t=e.data||e.edges;if(!t||Array.isArray(t))return g.renderToStaticMarkup($e(null,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,idPrefix:e._idPrefix}));u.__hierarchyRoot=t,h=[],d=[]}else{const t=e.nodes||[],o=Array.isArray(e.edges)?e.edges:[];if(0===t.length&&0===o.length)return g.renderToStaticMarkup($e(null,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,idPrefix:e._idPrefix}));if(d=function(t,e){const i=Re(e.sourceAccessor,"source"),o=Re(e.targetAccessor,"target"),r=Re(e.valueAccessor,"value");return t.map(t=>({source:i(t)+"",target:o(t)+"",value:Number(r(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(o,u),0===t.length&&d.length>0){const t=new Set;for(const e of d){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)}h=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 h=function(t,e){const i=Re(e.nodeIDAccessor,"id");return t.map(t=>{var e,o;return{id:i(t)+"",x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(o=t.y)&&void 0!==o?o:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}})}(t,u)}c.computeLayout(h,d,u,[s,a]);const{sceneNodes:f,sceneEdges:y,labels:p}=c.buildScene(h,d,u,[s,a]),m=je(i);for(const t of p)t.fill||(t.fill=m.text);const x=y.map((e,i)=>function(e,i){switch(e.type){case"line":return t.jsx("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+i);case"bezier":{const o=e;return t.jsx("path",{d:o.pathD,fill:me(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+i)}case"ribbon":{const o=e;return t.jsx("path",{d:o.pathD,fill:me(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+i)}case"curved":{const o=e;return t.jsx("path",{d:o.pathD,fill:me(o.style.fill,"none"),stroke:o.style.stroke||"#999",strokeWidth:o.style.strokeWidth||1,opacity:o.style.opacity},"net-edge-"+i)}default:return null}}(e,i)).filter(Boolean),v=f.map((e,i)=>function(e,i){switch(e.type){case"circle":{const o=e;return t.jsx("circle",{cx:o.cx,cy:o.cy,r:o.r,fill:me(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-circle-"+i)}case"rect":{const o=e;return t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:me(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-rect-"+i)}case"arc":{const o=e,r=l.arc().innerRadius(o.innerR).outerRadius(o.outerR).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2)({})||"";return t.jsx("path",{d:r,transform:`translate(${o.cx},${o.cy})`,fill:me(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-arc-"+i)}default:return null}}(e,i)).filter(Boolean),b=p.map((e,i)=>function(e,i){return t.jsx("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"#333",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+i)}(e,i)).filter(Boolean),k=t.jsxs(t.Fragment,{children:[x,v,b]});return g.renderToStaticMarkup($e(k,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,idPrefix:e._idPrefix}))}function We(e){var i,o,r,n,s;const a=Pe(e.theme),c=e.size||[500,400],l=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),e.margin),u=e.legendPosition;e.showLegend&&(u&&"right"!==u?"left"===u?l.left=Math.max(l.left,100):"bottom"===u?l.bottom=Math.max(l.bottom,70):"top"===u&&(l.top=Math.max(l.top,40)):l.right=Math.max(l.right,100));const h=c[0]-l.left-l.right,d=c[1]-l.top-l.bottom,f=e.projection||"vertical",y="radial"===f,p={chartType:e.chartType,windowSize:null!==(i=e.windowSize)&&void 0!==i?i:1e4,windowMode:null!==(o=e.windowMode)&&void 0!==o?o:"sliding",extentPadding:null!==(r=e.extentPadding)&&void 0!==r?r:.05,projection:f,oAccessor:e.oAccessor,rAccessor:e.rAccessor,colorAccessor:e.colorAccessor,stackBy:e.stackBy,groupBy:e.groupBy,categoryAccessor:e.categoryAccessor,valueAccessor:e.valueAccessor,timeAccessor:e.timeAccessor,rExtent:e.rExtent,oExtent:e.oExtent,barPadding:e.barPadding,roundedTop:e.roundedTop,innerRadius:e.innerRadius,cornerRadius:e.cornerRadius,normalize:e.normalize,startAngle:e.startAngle,sweepAngle:e.sweepAngle,bins:e.bins,showOutliers:e.showOutliers,showIQR:e.showIQR,amplitude:e.amplitude,oSort:e.oSort,connectorAccessor:e.connectorAccessor,connectorStyle:e.connectorStyle,dynamicColumnWidth:e.dynamicColumnWidth,pieceStyle:e.pieceStyle,summaryStyle:e.summaryStyle,colorScheme:e.colorScheme||a.colors.categorical,barColors:e.barColors},m=new ae(p);if(e.data&&m.ingest({inserts:e.data,bounded:!0}),m.computeScene({width:h,height:d}),!m.scales||0===m.scene.length)return g.renderToStaticMarkup($e(null,{width:c[0],height:c[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:a,innerTransform:`translate(${l.left},${l.top})`,idPrefix:e._idPrefix}));const x=e._idPrefix,v=e.showGrid?function(e,i,o,r){const n=e.scales;if(!n||"radial"===n.projection)return null;const{grid:s}=je(o),a=r?r+"-":"",c="vertical"===n.projection,l=n.r.ticks(5);return t.jsx("g",c?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,o)=>{const r=n.r(e);return t.jsx("line",{x1:0,y1:r,x2:i.width,y2:r,stroke:s,strokeWidth:.5},"gr-"+o)})}:{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,o)=>{const r=n.r(e);return t.jsx("line",{x1:r,y1:0,x2:r,y2:i.height,stroke:s,strokeWidth:.5},"gr-"+o)})})}(m,{width:h,height:d},a,x):null,b=m.scene.some(t=>{var e;return"rect"===t.type&&(null===(e=t.datum)||void 0===e?void 0:e.__barFunnelIsDropoff)});let k=null;if(b){const i=function(t){const e=t._idPrefix||t.chartId;if(e){const t=(e+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(t)?t:"c"+t}const i=`${t.chartType||""}:${t.title||""}:${Array.isArray(t.data)?t.data.length:0}`;let o=0;for(let t=0;i.length>t;t++)o=31*o+i.charCodeAt(t)|0;return"c"+(o>>>0).toString(36)}(e),o=new Set;for(const t of m.scene)"rect"===t.type&&(null===(n=t.datum)||void 0===n?void 0:n.__barFunnelIsDropoff)&&o.add("string"==typeof t.style.fill?t.style.fill:"#666");k=Array.from(o).map((e,o)=>function(e){const{id:i,background:o="transparent",stroke:r="#000",lineWidth:n=1.5,spacing:s=6,angle:a=45}=e,c=Math.max(8,Math.ceil(2*s));return t.jsxs("pattern",{id:i,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==a?`rotate(${a})`:void 0,children:[o&&"transparent"!==o&&t.jsx("rect",{width:c,height:c,fill:o}),t.jsx("line",{x1:0,y1:0,x2:0,y2:c,stroke:r,strokeWidth:n}),t.jsx("line",{x1:s,y1:0,x2:s,y2:c,stroke:r,strokeWidth:n})]},i)}({id:`funnel-hatch-${i}-${o}`,background:e,stroke:"transparent"===a.colors.background?"#fff":a.colors.background,lineWidth:1.5,spacing:5,angle:45}));const r=new Map;Array.from(o).forEach((t,e)=>r.set(t,`funnel-hatch-${i}-${e}`));for(const t of m.scene)if("rect"===t.type&&(null===(s=t.datum)||void 0===s?void 0:s.__barFunnelIsDropoff)){const e="string"==typeof t.style.fill?t.style.fill:"#666";t.style=Object.assign(Object.assign({},t.style),{fill:`url(#${r.get(e)})`})}}const A=m.scene.map((t,e)=>ve(t,e)).filter(Boolean),w=!1!==e.showAxes?function(e,i,o,r,n){var s,a,c,l,u,h,d,f;const g=e.scales;if(!g)return null;if("radial"===g.projection)return null;const y=je(r),p="vertical"===g.projection,m=o.categoryFormat||o.oFormat,x=o.valueFormat||o.rFormat,v=o.categoryLabel||o.oLabel,b=o.valueLabel||o.rLabel,k=Object.values(e.columns).map(t=>({pixel:t.middle,label:(m||String)(t.name)})),A=g.r.ticks(5).map(t=>({pixel:g.r(t),label:(x||ze)(t)}));return t.jsxs("g",p?{id:(n?n+"-":"")+"axes",className:"ordinal-axes",children:[t.jsx("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:y.border,strokeWidth:1}),k.map((e,o)=>t.jsxs("g",{transform:`translate(${e.pixel},${i.height})`,children:[t.jsx("line",{y2:5,stroke:y.border,strokeWidth:1}),t.jsx("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:e.label})]},"oxtick-"+o)),v&&t.jsx("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,children:v}),t.jsx("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:y.border,strokeWidth:1}),A.map((e,i)=>t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:y.border,strokeWidth:1}),t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:e.label})]},"oytick-"+i)),b&&t.jsx("text",{x:15-(null!==(a=null===(s=o.margin)||void 0===s?void 0:s.left)&&void 0!==a?a:40),y:i.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(l=null===(c=o.margin)||void 0===c?void 0:c.left)&&void 0!==l?l:40)}, ${i.height/2})`,children:b})]}:{id:(n?n+"-":"")+"axes",className:"ordinal-axes",children:[t.jsx("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:y.border,strokeWidth:1}),A.map((e,o)=>t.jsxs("g",{transform:`translate(${e.pixel},${i.height})`,children:[t.jsx("line",{y2:5,stroke:y.border,strokeWidth:1}),t.jsx("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:e.label})]},"oxtick-"+o)),b&&t.jsx("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,children:b}),t.jsx("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:y.border,strokeWidth:1}),k.map((e,i)=>t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:y.border,strokeWidth:1}),t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:e.label})]},"oytick-"+i)),v&&t.jsx("text",{x:15-(null!==(h=null===(u=o.margin)||void 0===u?void 0:u.left)&&void 0!==h?h:40),y:i.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(f=null===(d=o.margin)||void 0===d?void 0:d.left)&&void 0!==f?f:40)}, ${i.height/2})`,children:v})]})}(m,{width:h,height:d},e,a,x):null,S=e.annotations?Le({annotations:e.annotations,scales:{r:m.scales.r,y:"vertical"===m.scales.projection?m.scales.r:void 0},layout:{width:h,height:d},theme:a,projection:f,idPrefix:x}):null,_=e.showLegend?(()=>{const t=Oe(e.data||[],e.colorAccessor||e.stackBy||e.groupBy);return 0===t.length?null:Me({categories:t,colorScheme:e.colorScheme,theme:a,position:e.legendPosition||"right",totalWidth:c[0],totalHeight:c[1],margin:l,hasTitle:!!e.title})})():null,P=y?l.left+h/2:l.left,j=y?l.top+d/2:l.top,M=t.jsxs(t.Fragment,{children:[v,S,A,w]});return g.renderToStaticMarkup($e(M,{width:c[0],height:c[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:a,innerTransform:`translate(${P},${j})`,legend:_,defs:k,idPrefix:e._idPrefix}))}function Fe(e){var i,o,r,n,s,a,c,l;const u=Pe(e.theme),h=e.size||[e.width||600,e.height||400],d=Object.assign(Object.assign({},{top:10,right:10,bottom:10,left:10}),e.margin),f=h[0]-(null!==(i=d.left)&&void 0!==i?i:0)-(null!==(o=d.right)&&void 0!==o?o:0),y=h[1]-(null!==(r=d.top)&&void 0!==r?r:0)-(null!==(n=d.bottom)&&void 0!==n?n:0),p=new pe({projection:e.projection||"equalEarth",xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineType:e.lineType,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform});if(e.areas){if("string"==typeof e.areas)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${e.areas}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${e.areas}')\` before calling renderGeoToStaticSVG.`);p.setAreas(e.areas)}if(e.points&&p.setPoints(e.points),e.lines&&p.setLines(e.lines),p.computeScene({width:f,height:y}),0===p.scene.length)return g.renderToStaticMarkup($e(null,{width:h[0],height:h[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:u,innerTransform:`translate(${null!==(s=d.left)&&void 0!==s?s:0},${null!==(a=d.top)&&void 0!==a?a:0})`,idPrefix:e._idPrefix}));const m=p.scene.map((e,i)=>function(e,i){var o,r,n,s,a,c;switch(e.type){case"geoarea":{const n=e;return n.pathData?t.jsx("path",{d:n.pathData,fill:me(n.style.fill,"#e0e0e0"),fillOpacity:null!==(o=n.style.fillOpacity)&&void 0!==o?o:1,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth||.5,strokeDasharray:n.style.strokeDasharray,opacity:null!==(r=n._decayOpacity)&&void 0!==r?r:1},"geoarea-"+i):null}case"point":{const o=e;return t.jsx("circle",{cx:o.x,cy:o.y,r:o.r,fill:me(o.style.fill),fillOpacity:null!==(n=o.style.fillOpacity)&&void 0!==n?n:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:null!==(s=o._decayOpacity)&&void 0!==s?s:null!==(a=o.style.opacity)&&void 0!==a?a:1},"point-"+i)}case"line":{const o=e;if(2>o.path.length)return null;const r="M"+o.path.map(t=>`${t[0]},${t[1]}`).join("L");return t.jsx("path",{d:r,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||1.5,strokeDasharray:o.style.strokeDasharray,opacity:null!==(c=o.style.opacity)&&void 0!==c?c:1},"line-"+i)}default:return null}}(e,i)).filter(Boolean),x=t.jsx(t.Fragment,{children:m});return g.renderToStaticMarkup($e(x,{width:h[0],height:h[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:u,innerTransform:`translate(${null!==(c=d.left)&&void 0!==c?c:0},${null!==(l=d.top)&&void 0!==l?l:0})`,idPrefix:e._idPrefix}))}function Ye(t,e){switch(t){case"xy":return Ce(e);case"ordinal":return We(e);case"network":return Be(e);case"geo":return Fe(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", or "geo".`)}}function Ie(e,i,o){var r;const{data:n,width:s=600,height:a=400,theme:c,title:l,description:u,showLegend:h,showGrid:d,background:f,className:y,annotations:p,margin:m,colorScheme:x,colorBy:v,legendPosition:b}=i,k=function(t,e){var i={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&0>e.indexOf(o)&&(i[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);o.length>r;r++)0>e.indexOf(o[r])&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(i[o[r]]=t[o[r]])}return i}(i,["data","width","height","theme","title","description","showLegend","showGrid","background","className","annotations","margin","colorScheme","colorBy","legendPosition"]),A=[s,a],w=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},k.frameProps||{}),{theme:c,title:l,description:u,showLegend:h,showGrid:d,background:f,className:y,annotations:p,size:A}),void 0!==m&&{margin:m}),void 0!==x&&{colorScheme:x}),void 0!==b&&{legendPosition:b}),{_idPrefix:k._idPrefix}),S=De[e];if(!S)throw Error(`Unknown chart component: "${e}". See CLAUDE.md for supported chart types.`);const _=S.buildProps(n,v,x,w,k);let P=(0,{xy:Ce,ordinal:We,network:Be,geo:Fe}[S.frameType])(_);if("GaugeChart"===e&&_.__gauge){const e=_.__gauge,i=w.margin||{top:20,right:20,bottom:30,left:40},o=(s||300)-i.left-i.right,n=(a||300)-i.top-i.bottom,l=Math.min(o,n)/2*.85,u=i.left+o/2,h=i.top+n/2,d=Math.max(e.gMin,Math.min(e.gMax,null!==(r=e.value)&&void 0!==r?r:e.gMin)),f=(e.startAngleDeg+(e.gMax===e.gMin?0:(d-e.gMin)/(e.gMax-e.gMin))*e.sweep-90)*Math.PI/180,y=Pe(c).colors.text,p=g.renderToStaticMarkup(t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:u,y1:h,x2:u+l*Math.cos(f),y2:h+l*Math.sin(f),stroke:y,strokeWidth:2.5,strokeLinecap:"round"}),t.jsx("circle",{cx:u,cy:h,r:4,fill:y})]}));P=P.replace("</svg>",p+"</svg>")}return P}function Xe(t,e,i,o={}){const{stepSize:r,windowSize:n,frameCount:s,xExtent:a,yExtent:c,transitionFrames:l=4,fps:u=12,easing:h="ease-out",decay:d}=o,f=i.width||600,g=i.height||400,y=Pe(i.theme),p=Object.assign(Object.assign(Object.assign({},i),a&&{xExtent:a}),c&&{yExtent:c});if(!e||0===e.length)return[];const m=r||Math.max(1,Math.ceil(e.length/(s||Math.min(60,Math.max(10,e.length))))),x=[];for(let t=m;e.length>=t;t+=m)x.push(t);x[x.length-1]!==e.length&&x.push(e.length);const v=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(t),b=Object.assign({top:20,right:20,bottom:30,left:40},i.margin),k=f-b.left-b.right,A=g-b.top-b.bottom,w=[];if(v)for(let o=0;x.length>o;o++){const r=x[o],s=e.slice(n?Math.max(0,r-n):0,r),a=Object.assign({chartType:t,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:i.projection||"vertical",oAccessor:i.oAccessor||i.categoryAccessor||"category",rAccessor:i.rAccessor||i.valueAccessor||"value",colorAccessor:i.colorAccessor||i.colorBy,stackBy:i.stackBy,groupBy:i.groupBy,barPadding:i.barPadding,innerRadius:i.innerRadius,normalize:i.normalize,bins:i.bins,colorScheme:i.colorScheme||y.colors.categorical},d&&{decay:d}),c=new ae(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:k,height:A}),c.scene.length>0&&w.push(Ve(c.scene,f,g,y,p))}else for(let o=0;x.length>o;o++){const r=x[o],s=e.slice(n?Math.max(0,r-n):0,r),m=Object.assign(Object.assign({chartType:t,windowSize:s.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:i.colorAccessor||i.colorBy,groupAccessor:i.groupAccessor||i.lineBy,lineDataAccessor:i.lineDataAccessor,xExtent:a,yExtent:c,colorScheme:i.colorScheme||y.colors.categorical,lineStyle:i.lineStyle,pointStyle:i.pointStyle,areaStyle:i.areaStyle,sizeAccessor:i.sizeAccessor||i.sizeBy,sizeRange:i.sizeRange},d&&{decay:d}),l>0&&{transition:{duration:l*(1e3/u),easing:h}}),v=new q(m);if(v.ingest({inserts:s,bounded:!0}),v.computeScene({width:k,height:A}),0===v.scene.length)continue;const b=v.scales?{y:v.scales.y}:void 0;if(w.push(Ge(v.scene,f,g,y,p,b)),l>0&&o>0&&v.activeTransition){const t=l*(1e3/u);for(let e=1;l>=e;e++)v.advanceTransition(v.activeTransition.startTime+e/l*t),w.push(Ge(v.scene,f,g,y,p,b))}}return w}function qe(t,e){const i=t.background||e.colors.background;return i&&"transparent"!==i?i:null}function Ge(e,i,o,r,n,s){const a=je(r),c=Object.assign({top:20,right:20,bottom:30,left:40},n.margin),l=i-c.left-c.right,u=o-c.top-c.bottom,h=qe(n,r),d=e.map((t,e)=>xe(t,e)).filter(Boolean),f=function(e,i,o,r,n,s){var a;if(!e||0===e.length)return null;const c=je(r),l=[];for(let r=0;e.length>r;r++){const u=e[r];if("y-threshold"===u.type&&null!=u.value){let e=null;if(s)e=s(u.value);else if(n){const[t,i]=n,r=i-t;if(0===r)continue;e=o-(u.value-t)/r*o}if(null==e)continue;const h=u.color||c.primary,d=null!==(a=u.strokeWidth)&&void 0!==a?a:1.5,f=u.labelPosition||"right";l.push(t.jsxs("g",{children:[t.jsx("line",{x1:0,y1:e,x2:i,y2:e,stroke:h,strokeWidth:d,strokeDasharray:u.strokeDasharray||"6,4"}),u.label&&t.jsx("text",{x:"left"===f?4:"center"===f?i/2:i-4,y:e-5,textAnchor:"left"===f?"start":"center"===f?"middle":"end",fontSize:c.tickSize,fill:h,fontFamily:c.fontFamily,children:u.label})]},"ann-"+r))}}return l.length>0?t.jsx(t.Fragment,{children:l}):null}(n.annotations,l,u,r,n.yExtent,null==s?void 0:s.y),y="string"==typeof n.title?n.title:void 0,p="string"==typeof n.description?n.description:void 0,m=y?"semiotic-title":void 0,x=p?"semiotic-desc":void 0,v=[m,x].filter(Boolean).join(" ")||void 0,b=t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:i,height:o,role:"img","aria-labelledby":v,style:{fontFamily:a.fontFamily},children:[y&&t.jsx("title",{id:m,children:y}),p&&t.jsx("desc",{id:x,children:p}),h&&t.jsx("rect",{x:0,y:0,width:i,height:o,fill:h}),t.jsxs("g",{transform:`translate(${c.left},${c.top})`,children:[f,d]}),y&&t.jsx("text",{x:i/2,y:16,textAnchor:"middle",fontSize:a.titleSize,fontWeight:"bold",fill:a.text,fontFamily:a.fontFamily,children:y})]});return g.renderToStaticMarkup(b)}function Ve(e,i,o,r,n){const s=je(r),a=Object.assign({top:20,right:20,bottom:30,left:40},n.margin),c="radial"===n.projection,l=c?a.left+(i-a.left-a.right)/2:a.left,u=c?a.top+(o-a.top-a.bottom)/2:a.top,h=qe(n,r),d=e.map((t,e)=>ve(t,e)).filter(Boolean),f="string"==typeof n.title?n.title:void 0,y="string"==typeof n.description?n.description:void 0,p=f?"semiotic-title":void 0,m=y?"semiotic-desc":void 0,x=[p,m].filter(Boolean).join(" ")||void 0,v=t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:i,height:o,role:"img","aria-labelledby":x,style:{fontFamily:s.fontFamily},children:[f&&t.jsx("title",{id:p,children:f}),y&&t.jsx("desc",{id:m,children:y}),h&&t.jsx("rect",{x:0,y:0,width:i,height:o,fill:h}),t.jsx("g",{transform:`translate(${l},${u})`,children:d}),f&&t.jsx("text",{x:i/2,y:16,textAnchor:"middle",fontSize:s.titleSize,fontWeight:"bold",fill:s.text,fontFamily:s.fontFamily,children:f})]});return g.renderToStaticMarkup(v)}exports.generateFrameSVGs=Xe,exports.generateFrameSequence=function(t,e,i={}){return e.map(e=>{try{return Ie(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=Ie,exports.renderDashboard=function(e,i={}){var o;const{title:r,subtitle:n,theme:s,width:a=1200,height:c,layout:l={},background:u}=i,h=je(Pe(s)),d=l.columns||2,f=null!==(o=l.gap)&&void 0!==o?o:16;let y=0;r&&(y+=30),n&&(y+=20),y>0&&(y+=10);const p=Math.floor((a-f-f*(d-1))/d),m=[];let x=0,v=y+f,b=0;for(const t of e){const e=Math.min(t.colSpan||1,d),i=t.props.height||300;x+e>d&&(v+=b+f,x=0,b=0),m.push({chart:t,x:f/2+x*(p+f),y:v,w:p*e+f*(e-1),h:i}),b=Math.max(b,i),x+=e}const k=c||v+b+f,A=m.map((e,i)=>{const{chart:o,x:r,y:n,w:a,h:c}=e,l=Object.assign(Object.assign({},o.props),{width:a,height:c,theme:s,_idPrefix:"chart-"+i});let u;return u=o.component?Ie(o.component,l):o.frameType?Ye(o.frameType,l):`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${c}"></svg>`,t.jsx("g",{transform:`translate(${r},${n})`,children:t.jsx("foreignObject",{width:a,height:c,children:t.jsx("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:u}})})},"dashboard-chart-"+i)}),w=t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:a,height:k,role:"img","aria-label":r||"Dashboard",style:{fontFamily:h.fontFamily},children:[r&&t.jsx("title",{children:r}),u&&t.jsx("rect",{x:0,y:0,width:a,height:k,fill:u}),r&&t.jsx("text",{x:a/2,y:24,textAnchor:"middle",fontSize:h.titleSize+4,fontWeight:"bold",fill:h.text,fontFamily:h.fontFamily,children:r}),n&&t.jsx("text",{x:a/2,y:r?46:20,textAnchor:"middle",fontSize:h.labelSize,fill:h.textSecondary,fontFamily:h.fontFamily,children:n}),A]});return g.renderToStaticMarkup(w)},exports.renderGeoToStaticSVG=function(t){return Fe(t)},exports.renderNetworkToStaticSVG=function(t){return Be(t)},exports.renderOrdinalToStaticSVG=function(t){return We(t)},exports.renderToAnimatedGif=function(t,e,i){return p(this,arguments,void 0,function*(t,e,i,o={}){const{fps:r=12,loop:n=!0,scale:s=1,background:a}=o,c=i.height||400,l=Math.round((i.width||600)*s),u=Math.round(c*s),h=Xe(t,e,a?Object.assign(Object.assign({},i),{background:a}):i,o);if(0===h.length)throw Error("No frames generated — check that data is not empty");let d,f,g,y;try{d=require("sharp")}catch(t){throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t=require("gifenc");f=t.GIFEncoder,g=t.quantize,y=t.applyPalette}catch(t){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc')}const p=Math.round(1e3/r),m=f();for(let t=0;h.length>t;t++){const e=h[t],i=yield d(Buffer.from(e),{density:72*s}).resize(l,u).ensureAlpha().raw().toBuffer(),o=new Uint8Array(i),r=g(o,256),a=y(o,r);m.writeFrame(a,l,u,{palette:r,delay:p,repeat:n?0:-1})}return m.finish(),Buffer.from(m.bytes())})},exports.renderToImage=function(t,e){return p(this,arguments,void 0,function*(t,e,i={}){var o,r;const{format:n="png",scale:s=1,background:a}=i;let c,l;c=["xy","ordinal","network","geo"].includes(t)?Ye(t,e):Ie(t,e),a&&(c=c.replace(/<svg /,`<svg style="background:${a}" `));try{l=require("sharp")}catch(t){throw Error('Image export requires the "sharp" package and a Node.js runtime. Install it:\n npm install sharp\nsharp is listed as an optional dependency of semiotic.')}const u=e.width||(null===(o=e.size)||void 0===o?void 0:o[0])||600,h=e.height||(null===(r=e.size)||void 0===r?void 0:r[1])||400,d=l(void 0!==globalThis.Buffer?globalThis.Buffer.from(c):(new TextEncoder).encode(c),{density:72*s}).resize(Math.round(u*s),Math.round(h*s));return"jpeg"===n?d.jpeg({quality:90}).toBuffer():d.png().toBuffer()})},exports.renderToStaticSVG=Ye,exports.renderXYToStaticSVG=function(t){return Ce(t)},exports.resolveTheme=Pe,exports.themeStyles=je;
1
+ "use strict";const t=require("react/jsx-runtime"),e=require("react"),i=require("react-dom/server"),o=require("d3-scale"),r=require("d3-quadtree"),n=require("d3-array"),s=require("d3-interpolate"),a=require("d3-force"),c=require("d3-chord"),l=require("d3-shape"),u=require("d3-hierarchy"),h=require("d3-geo");function d(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const i in t)if("default"!==i){const o=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:function(){return t[i]}})}return e.default=t,Object.freeze(e)}const f=d(e),g=d(i);function y(t,e,i,o){return new(i||(i=Promise))(function(r,n){function s(t){try{c(o.next(t))}catch(t){n(t)}}function a(t){try{c(o.throw(t))}catch(t){n(t)}}function c(t){t.done?r(t.value):function(t){return t instanceof i?t:new i(function(e){e(t)})}(t.value).then(s,a)}c((o=o.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class p{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const i of t){const t=this.push(i);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;return{next:()=>this._size>t?{done:!1,value:this.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)t(this.buffer[(e+i)%this._capacity],i)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)t[i]=this.buffer[(e+i)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray(),i=[];for(;e.length>t;)i.push(e.shift());this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(const t of e)this.push(t);return i}update(t,e){const i=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++){const n=(o+r)%this._capacity,s=this.buffer[n];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:Object.assign({},s),i.push(t),this.buffer[n]=e(s)}}return i}remove(t){const e=[],i=[];if(this.forEach(o=>{t(o)?i.push(o):e.push(o)}),0===i.length)return i;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return i}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class m{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isFinite(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.isFinite(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 x(t,e,i,o,r){const n=new Map;for(const s of t){const t=e(s),a=i(s);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const c=Math.floor(t/o)*o;let l=n.get(c);if(l||(l={start:c,end:c+o,total:0,categories:new Map},n.set(c,l)),l.total+=a,r){const t=r(s);l.categories.set(t,(l.categories.get(t)||0)+a)}}return n}function v(t,e,i,o,r,n){const s=[];for(const r of t){const t=i(r),n=o(r);Number.isFinite(t)&&Number.isFinite(n)&&s.push({px:e.x(t),py:e.y(n),rawY:n,d:r})}s.sort((t,e)=>t.px-e.px);const a=Array(s.length),c=Array(s.length),l=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];a[t]=[e.px,e.py],c[t]=e.rawY,l[t]=e.d}return{type:"line",path:a,rawValues:c,style:r,datum:l,group:n}}function b(t,e,i,o,r,n,s,a){const c=[];for(const n of t){const t=i(n),s=o(n);if(!Number.isFinite(t)||!Number.isFinite(s))continue;const l=e.x(t),u=a?a(n):r;c.push({px:l,topY:e.y(s),botY:e.y(u)})}c.sort((t,e)=>t.px-e.px);const l=Array(c.length),u=Array(c.length);for(let t=0;c.length>t;t++){const e=c[t];l[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:l,bottomPath:u,style:n,datum:t,group:s}}function k(t,e,i,o){var r,n,s;const a=new Map;if("silhouette"===o)for(const o of t){let t=0;for(const r of e)t+=i(r,o)||0;a.set(o,-t/2)}else if("wiggle"===o){t.length>0&&a.set(t[0],0);for(let o=1;t.length>o;o++){const n=t[o-1],s=t[o];let c=0,l=0,u=0;for(const t of e){const e=i(t,s)||0;c+=(2*u+e)*(e-(i(t,n)||0)),l+=e,u+=e}const h=null!==(r=a.get(n))&&void 0!==r?r:0;a.set(s,h-(l>0?c/(2*l):0))}if(t.length>0){let o=0;for(const r of t){let t=0;for(const o of e)t+=i(o,r)||0;o+=(null!==(n=a.get(r))&&void 0!==n?n:0)+t/2}const r=o/t.length;for(const e of t)a.set(e,(null!==(s=a.get(e))&&void 0!==s?s:0)-r)}}else for(const e of t)a.set(e,0);return a}function A(t,e,i,o,r,n,s){const a=i(t),c=o(t);if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l={type:"point",x:e.x(a),y:e.y(c),r:r,style:n,datum:t};return void 0!==s&&(l.pointId=s),l}function w(t,e,i,o,r,n,s){return{type:"rect",x:t,y:e,w:i,h:o,style:r,datum:n,group:s}}function S(t,e,i,o,r,n,s){const a={type:"heatcell",x:t,y:e,w:i,h:o,fill:r,datum:n};return(null==s?void 0:s.showValues)&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function _(t,e){return t===e||typeof t==typeof e&&"function"==typeof t&&"function"==typeof e&&""+t==""+e}function P(t,e){if("function"==typeof t)return e=>+t(e);const i=t||e;return t=>+t[i]}function j(t,e){if("function"==typeof t)return t;const i=t||e;return t=>t[i]}function M(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}function O(t){return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function L(t,e,i){const o=t=>t.toString(16).padStart(2,"0");return`#${o(t)}${o(e)}${o(i)}`}function E(t){const e=t.map(O),i=e.length-1;return t=>{if(0>=t){const[t,i,o]=e[0];return L(t,i,o)}if(t>=1){const[t,o,r]=e[i];return L(t,o,r)}const o=t*i,r=Math.floor(o),n=o-r,[s,a,c]=e[r],[l,u,h]=e[r+1];return L(Math.round(s+(l-s)*n),Math.round(a+(u-a)*n),Math.round(c+(h-c)*n))}}const T=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],D=E(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),z=E(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),$=E(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),R=E(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),C=E(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),N=E(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),F=E(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),B=E(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),W=E(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),Y=E(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),I=E(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),X=E(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]);E(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),E(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),E(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),E(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),E(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),E(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),E(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);const q={category10:T,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],blues:D,reds:z,greens:$,oranges:R,purples:C,viridis:F,plasma:B},G=T,V=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],H=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function Q(t,e,i="category10"){const r=Array.from(new Set(t.map(t=>null==t?void 0:t[e]).filter(t=>null!=t).map(t=>t+""))),n=r.every(t=>!isNaN(Number(t)));if(Array.isArray(i))return o.scaleOrdinal().domain(r).range(i).unknown("#999");const s=q[i]||q.category10;if(n&&"function"==typeof s){let t=-1/0;for(const e of r){const i=Number(e);i>t&&(t=i)}return e=>s(Number(e)/t)}{const t=Array.isArray(s)?s:G;return o.scaleOrdinal().domain(r).range(t).unknown("#999")}}function U(t,e,i){var o,r,n;if(1>=i)return 1;const s=null!==(o=t.minOpacity)&&void 0!==o?o:.1,a=i-1-e;switch(t.type){case"linear":return s+(1-a/(i-1))*(1-s);case"exponential":{const e=null!==(r=t.halfLife)&&void 0!==r?r:i/2;return s+Math.pow(.5,a/e)*(1-s)}case"step":return(null!==(n=t.stepThreshold)&&void 0!==n?n:.5*i)>a?1:s;default:return 1}}function Z(t,e,i){var o;const r=null!==(o=t.duration)&&void 0!==o?o:500,n=i-e;return r>n?1-n/r:0}function K(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function J(t,e){return Math.min((t-e.startTime)/e.duration,1)}function tt(t,e,i){return t+(e-t)*i}function et(){return"undefined"!=typeof performance?performance.now():Date.now()}function it(t,e,i){var o,r,n,s;if(e._transitionKey)return e._transitionKey;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const i=t.getX(e.datum),o=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${i}:${o}`;if(null!=i&&null!=o)return`p:${i}:${o}`}return"p:"+i;case"rect":return`r:${e.group||""}:${null!==(s=null!==(r=null===(o=e.datum)||void 0===o?void 0:o.binStart)&&void 0!==r?r:null===(n=e.datum)||void 0===n?void 0:n.category)&&void 0!==s?s:i}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+i:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function ot(t,e,i){if(!t.getBounds||!t.scales)return null;const o=[],r=[];for(const i of e){const e=t.getX(i),n=t.getY(i);if(null==e||null==n||Number.isNaN(e)||Number.isNaN(n))continue;const s=t.getBounds(i),a=t.scales.x(e);if(s&&0!==s)o.push([a,t.scales.y(n+s)]),r.push([a,t.scales.y(n-s)]);else{const e=t.scales.y(n);o.push([a,e]),r.push([a,e])}}return 2>o.length?null:{type:"area",topPath:o,bottomPath:r,style:t.resolveBoundsStyle(i,e[0]),datum:e,group:i,interactive:!1}}function rt(t,e,i,o){var r;if(!t.config.pointStyle)return;const n=null!=o?o:t.getY;for(const o of e){const e=t.resolveGroupColor(o.key);for(const s of o.data){let o=t.config.pointStyle(s);!o.fill&&e&&(o=Object.assign(Object.assign({},o),{fill:e}));const a=null!==(r=o.r)&&void 0!==r?r:3,c=t.getPointId?t.getPointId(s)+"":void 0,l=A(s,t.scales,t.getX,n,a,o,c);l&&i.push(l)}}}const nt={blues:D,reds:z,greens:$,viridis:F,oranges:R,purples:C,greys:N,plasma:B,inferno:W,magma:Y,cividis:I,turbo:X},st=new Map;class at{constructor(t){if(this.xExtent=new m,this.yExtent=new m,this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this.xIsDate=!1,this._quadtree=null,this._maxPointRadius=0,this._lastBoundedInsertsRef=null,this.config=t,this.buffer=new p(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=P(t.timeAccessor||t.xAccessor,"time"),this.getY=P(t.valueAccessor||t.yAccessor,"value")):(this.getX=P(t.xAccessor,"x"),this.getY=P(t.yAccessor,"y")),this.getGroup=M(t.groupAccessor),this.getCategory=M(t.categoryAccessor),this.getSize=t.sizeAccessor?P(t.sizeAccessor,"size"):void 0,this.getColor=M(t.colorAccessor),this.getBounds=t.boundsAccessor?P(t.boundsAccessor,"bounds"):void 0,this.getY0=t.y0Accessor?P(t.y0Accessor,"y0"):void 0,this.getPointId=M(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,i=null!=t.closeAccessor;this.getOpen=e?P(t.openAccessor,"open"):void 0,this.getHigh=P(t.highAccessor,"high"),this.getLow=P(t.lowAccessor,"low"),this.getClose=i?P(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!i}t.pulse&&(this.timestampBuffer=new p(t.windowSize))}pushDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(t)),void this.yExtent.push(this.getLow(t));this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t))}rebuildYExtent(){this.yExtent.clear();for(const t of this.buffer)this.pushDatumYExtent(t)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const t of this.buffer)this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t)}ingest(t){if(t.bounded&&this._lastBoundedInsertsRef===t.inserts)return!1;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._lastBoundedInsertsRef=t.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),this.getX=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?P(this.config.timeAccessor||this.config.xAccessor,"time"):P(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],i=this.config.xAccessor,o="function"==typeof i?i(e):e[i||"x"],r=o instanceof Date,n="string"==typeof o&&o.length>=10&&!isNaN(new Date(o).getTime())&&isNaN(Number(o));if(this.xIsDate=r||n,n){const t="string"==typeof i?i:void 0;this.getX=t?e=>+new Date(e[t]):t=>+(i(t)instanceof Date?i(t):new Date(i(t)))}}const i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(i)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(i)),this.yExtent.push(this.getLow(i))):(this.yExtent.push(this.getY(i)),this.getY0&&this.yExtent.push(this.getY0(i)))}else for(const i of t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity||1e6;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const t=this.buffer.push(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.xExtent.push(this.getX(i)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(i)),this.yExtent.push(this.getLow(i))):(this.yExtent.push(this.getY(i)),this.getY0&&this.yExtent.push(this.getY0(i))),null!=t&&(this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t))))}return!0}computeScene(t){var e,i,r,n,s,a,c,l,u,h,d,f,g,y;const{config:p,buffer:m}=this;if(!this.needsFullRebuild&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(null!==(e=this.config.scalePadding)&&void 0!==e?e:0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);this.xExtent.dirty&&this.xExtent.recalculate(m,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const v=this.getBufferArray(),b=this.xExtent.extent,A=this.yExtent.extent;let w=p.xExtent?[null!==(i=p.xExtent[0])&&void 0!==i?i:b[0],null!==(r=p.xExtent[1])&&void 0!==r?r:b[1]]:b,S=p.yExtent?[null!==(n=p.yExtent[0])&&void 0!==n?n:A[0],null!==(s=p.yExtent[1])&&void 0!==s?s:A[1]]:A;const _=p.yExtent&&null!=p.yExtent[0]&&null!=p.yExtent[1];if("stackedarea"===p.chartType&&!_&&m.size>0)if(p.normalize)S=[0,1+p.extentPadding];else{const t=`${m.size}:${this._ingestVersion}:${null!==(a=p.baseline)&&void 0!==a?a:"zero"}:${null!==(c=p.stackOrder)&&void 0!==c?c:"key"}`;if(this._stackExtentCache&&this._stackExtentCache.key===t)S=this._stackExtentCache.yDomain;else{const e=this.groupData(v),i=new Map,o=new Set;let r=0;const n=new Map,s=new Map;for(const t of e){const e=new Map;let a=0;for(const i of t.data){const t=this.getX(i),s=this.getY(i);if(!Number.isFinite(t)||!Number.isFinite(s))continue;e.set(t,(e.get(t)||0)+s),o.add(t),a+=s;const c=(n.get(t)||0)+s;n.set(t,c),c>r&&(r=c)}i.set(t.key,e),s.set(t.key,a)}const a=null!==(l=p.stackOrder)&&void 0!==l?l:"key",c=(t,e)=>e>t?-1:t>e?1:0;let g;if("insideOut"===a){const t=[...e].map(t=>t.key).sort((t,e)=>{var i,o;const r=(null!==(i=s.get(e))&&void 0!==i?i:0)-(null!==(o=s.get(t))&&void 0!==o?o:0);return 0!==r?r:c(t,e)}),i=[],o=[];let r=0,n=0;for(const e of t)n>r?(i.push(e),r+=null!==(u=s.get(e))&&void 0!==u?u:0):(o.push(e),n+=null!==(h=s.get(e))&&void 0!==h?h:0);g=[...o.reverse(),...i]}else g="asc"===a?e.map(t=>t.key).sort((t,e)=>{var i,o;const r=(null!==(i=s.get(t))&&void 0!==i?i:0)-(null!==(o=s.get(e))&&void 0!==o?o:0);return 0!==r?r:c(t,e)}):"desc"===a?e.map(t=>t.key).sort((t,e)=>{var i,o;const r=(null!==(i=s.get(e))&&void 0!==i?i:0)-(null!==(o=s.get(t))&&void 0!==o?o:0);return 0!==r?r:c(t,e)}):e.map(t=>t.key).sort(c);if("wiggle"===p.baseline||"silhouette"===p.baseline){const t=Array.from(o).sort((t,e)=>t-e),e=k(t,g,(t,e)=>{var o;return(null===(o=i.get(t))||void 0===o?void 0:o.get(e))||0},p.baseline);let r=1/0,s=-1/0;for(const i of t){const t=null!==(d=e.get(i))&&void 0!==d?d:0,o=null!==(f=n.get(i))&&void 0!==f?f:0;r>t&&(r=t),t+o>s&&(s=t+o)}Number.isFinite(r)&&Number.isFinite(s)||(r=0,s=0);const a=s-r,c=a>0?a*p.extentPadding:1;S=[r-c,s+c]}else S=[0,r+(r>0?r*p.extentPadding:1)];this._stackExtentCache={key:t,yDomain:S}}}else if("bar"===p.chartType&&p.binSize&&!_&&m.size>0){const[,t]=function(t,e,i,o,r){const n=x(t,e,i,o,r);if(0===n.size)return[0,0];let s=0;for(const t of n.values())t.total>s&&(s=t.total);return[0,s]}(m,this.getX,this.getY,p.binSize,this.getCategory);S=[0,t+t*p.extentPadding]}else if("waterfall"===p.chartType&&!_&&m.size>0){const[t,e]=function(t,e){let i=0,o=0,r=0;for(const n of t){const t=e(n);null==t||Number.isNaN(t)||(r+=t,i>r&&(i=r),r>o&&(o=r))}return[i,o]}(m,this.getY),i=e-t,o=i>0?i*p.extentPadding:1;S=[Math.min(0,t-Math.abs(o)),Math.max(0,e+Math.abs(o))]}else if(!_&&S[0]!==1/0){if(this.getBounds)for(const t of v){const e=this.getY(t),i=this.getBounds(t);null!=e&&!Number.isNaN(e)&&i&&(e+i>S[1]&&(S[1]=e+i),S[0]>e-i&&(S[0]=e-i))}const t=S[1]-S[0],e=t>0?t*p.extentPadding:1,i=null===(g=p.yExtent)||void 0===g?void 0:g[0],o=null===(y=p.yExtent)||void 0===y?void 0:y[1];S=[null!=i?S[0]:S[0]-e,null!=o?S[1]:S[1]+e],"log"===p.yScaleType&&0>=S[0]&&A[0]>0&&(S[0]=null!=i?S[0]:A[0]/(1+p.extentPadding))}if(w[0]===1/0||w[1]===-1/0)if("time"===p.xScaleType){const t=Date.now();w=[t-864e5,t]}else w=[0,1];S[0]!==1/0&&S[1]!==-1/0||(S=[0,1]);const P="streaming"===p.runtimeMode,j=Math.max(0,Math.min(p.scalePadding||0,Math.min(t.width,t.height)/2-1));if(P)if("x"==("up"===(M=p.arrowOfTime)||"down"===M?"y":"x")){const e="right"===p.arrowOfTime?[j,t.width-j]:[t.width-j,j];this.scales={x:o.scaleLinear().domain(w).range(e),y:o.scaleLinear().domain(S).range([t.height-j,j])}}else{const e="down"===p.arrowOfTime?[j,t.height-j]:[t.height-j,j];this.scales={x:o.scaleLinear().domain(S).range([j,t.width-j]),y:o.scaleLinear().domain(w).range(e)}}else{const e=(t,e,i)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return o.scaleLog().domain(t).range(i).clamp(!0)}return"time"===t?o.scaleTime().domain([new Date(e[0]),new Date(e[1])]).range(i):o.scaleLinear().domain(e).range(i)};this.scales={x:e(p.xScaleType,w,[j,t.width-j]),y:e(p.yScaleType,S,[t.height-j,j])}}var M;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(t,v),this.config.decay&&this.applyDecay(this.scene,v),this.config.pulse&&this.applyPulse(this.scene,v),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.rebuildQuadtree(),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}rebuildQuadtree(){const t=this.config.chartType;if("scatter"!==t&&"bubble"!==t)return this._quadtree=null,void(this._maxPointRadius=0);let e=0,i=0;for(const t of this.scene)"point"===t.type&&(e++,t.r>i&&(i=t.r));if(this._maxPointRadius=i,at.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const o=Array(e);let n=0;for(const t of this.scene)"point"===t.type&&(o[n++]=t);this._quadtree=r.quadtree().x(t=>t.x).y(t=>t.y).addAll(o)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}remapScene(t){const e=t.width/this.lastLayout.width,i=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const o of t.path)o[0]*=e,o[1]*=i;break;case"area":for(const o of t.topPath)o[0]*=e,o[1]*=i;for(const o of t.bottomPath)o[0]*=e,o[1]*=i;t.clipRect&&(t.clipRect={x:t.clipRect.x*e,y:t.clipRect.y*i,width:t.clipRect.width*e,height:t.clipRect.height*i});break;case"point":t.x*=e,t.y*=i;break;case"rect":case"heatcell":t.x*=e,t.y*=i,t.w*=e,t.h*=i;break;case"candlestick":t.x*=e,t.openY*=i,t.closeY*=i,t.highY*=i,t.lowY*=i}const r=this.scales.x.domain(),n=this.scales.y.domain(),s=this.scales.x.range(),a=this.scales.y.range(),c=(t,e,i)=>{if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return o.scaleLog().domain(t).range(i).clamp(!0)}return"time"===t?o.scaleTime().domain([new Date(e[0]),new Date(e[1])]).range(i):o.scaleLinear().domain(e).range(i)},l=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),u=a[1]>a[0];this.scales={x:c(this.config.xScaleType,r,s[0]>s[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,o,r,n,s,a,c;const{config:l,scales:u}=this;if(!u)return[];if(l.customLayout){const c=null!==(i=l.layoutMargin)&&void 0!==i?i:{top:0,right:0,bottom:0,left:0},h={data:e,scales:u,dimensions:{width:t.width,height:t.height,margin:c,plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:null!==(o=l.themeSemantic)&&void 0!==o?o:{},categorical:null!==(r=l.themeCategorical)&&void 0!==r?r:V},resolveColor:(t,e)=>{var i,o;const r=this.resolveGroupColor(t);if(r)return r;const n=this.resolveLineStyle(t,e);return n.stroke?n.stroke:"string"==typeof n.fill?n.fill:null!==(o=null===(i=l.themeSemantic)||void 0===i?void 0:i.primary)&&void 0!==o?o:"#4e79a7"},config:null!==(n=l.layoutConfig)&&void 0!==n?n:{}};let d;try{d=l.customLayout(h)}catch(t){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",t),this.customLayoutOverlays=null,[]}return this.customLayoutOverlays=null!==(s=d.overlays)&&void 0!==s?s:null,null!==(a=d.nodes)&&void 0!==a?a:[]}if(this.customLayoutOverlays=null,0===e.length)return[];const h={scales:u,config:l,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(l.chartType){case"line":return function(t,e){var i;const o=t.groupData(e),r=[],n=null===(i=t.config.annotations)||void 0===i?void 0:i.filter(t=>"threshold"===t.type&&t.color).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.getBounds)for(const e of o){const i=ot(t,e.data,e.key);i&&r.push(i)}for(const e of o){const i=t.resolveLineStyle(e.key,e.data[0]),o=v(e.data,t.scales,t.getX,t.getY,i,e.key);n&&n.length>0&&(o.colorThresholds=n),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),r.push(o)}return rt(t,o,r),r}(h,e);case"area":return function(t,e){const i=t.groupData(e),o=[],r=t.scales.y.domain()[0],n=t.getY0?e=>{const i=t.getY0(e);return null==i?r:i}:void 0;for(const e of i){const i=t.resolveAreaStyle(e.key,e.data[0]),s=b(e.data,t.scales,t.getX,t.getY,r,i,e.key,n);t.config.gradientFill&&(s.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),o.push(s)}return rt(t,i,o),o}(h,e);case"mixed":return function(t,e){const i=t.groupData(e),o=[],r=t.config.areaGroups||new Set,n=t.scales.y.domain()[0],s=t.getY0?e=>{const i=t.getY0(e);return null==i?n:i}:void 0;for(const e of i)if(r.has(e.key)){const i=t.resolveAreaStyle(e.key,e.data[0]),r=b(e.data,t.scales,t.getX,t.getY,n,i,e.key,s);t.config.gradientFill&&(r.fillGradient=t.config.gradientFill),t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}else{const i=t.resolveLineStyle(e.key,e.data[0]),r=v(e.data,t.scales,t.getX,t.getY,i,e.key);t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}return rt(t,i,o),o}(h,e);case"stackedarea":return function(t,e){var i,o,r,n;const s=t.groupData(e),a=null!==(i=t.config.stackOrder)&&void 0!==i?i:"key",c=()=>s.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);if("key"===a)c();else if("asc"===a||"desc"===a||"insideOut"===a){const e=new Map;for(const i of s){let o=0;for(const e of i.data){const i=t.getX(e),r=t.getY(e);Number.isFinite(i)&&Number.isFinite(r)&&(o+=r)}e.set(i.key,o)}const i=(t,e)=>e>t?-1:t>e?1:0;if("asc"===a)s.sort((t,o)=>{var r,n;const s=(null!==(r=e.get(t.key))&&void 0!==r?r:0)-(null!==(n=e.get(o.key))&&void 0!==n?n:0);return 0!==s?s:i(t.key,o.key)});else if("desc"===a)s.sort((t,o)=>{var r,n;const s=(null!==(r=e.get(o.key))&&void 0!==r?r:0)-(null!==(n=e.get(t.key))&&void 0!==n?n:0);return 0!==s?s:i(t.key,o.key)});else{const t=[...s].sort((t,o)=>{var r,n;const s=(null!==(r=e.get(o.key))&&void 0!==r?r:0)-(null!==(n=e.get(t.key))&&void 0!==n?n:0);return 0!==s?s:i(t.key,o.key)}),n=[],a=[];let c=0,l=0;for(const i of t)l>c?(n.push(i),c+=null!==(o=e.get(i.key))&&void 0!==o?o:0):(a.push(i),l+=null!==(r=e.get(i.key))&&void 0!==r?r:0);s.length=0,s.push(...a.reverse(),...n)}}else c();const l=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,u=t.config.normalize?"zero":null!==(n=t.config.baseline)&&void 0!==n?n:"zero",{nodes:h,stackedTops:d}=function(t,e,i,o,r,n,s,a="zero"){var c,l;const u=new Set;for(const e of t)for(const t of e.data){const e=i(t);Number.isFinite(e)&&u.add(e)}const h=Array.from(u).sort((t,e)=>t-e),d=new Map;for(const e of t){const t=new Map;for(const r of e.data){const e=i(r),n=o(r);Number.isFinite(e)&&Number.isFinite(n)&&t.set(e,(t.get(e)||0)+n)}d.set(e.key,t)}let f;if(n){f=new Map;for(const e of h){let i=0;for(const o of t)i+=(null===(c=d.get(o.key))||void 0===c?void 0:c.get(e))||0;f.set(e,i||1)}}const g=k(h,t.map(t=>t.key),(t,e)=>{var i;return(null===(i=d.get(t))||void 0===i?void 0:i.get(e))||0},a),y=[],p=new Map,m=new Map;for(const t of h)m.set(t,null!==(l=g.get(t))&&void 0!==l?l:0);for(const i of t){const t=d.get(i.key),o=[],a=[],c=new Map;for(const i of h){let r=t.get(i)||0;const s=m.get(i);n&&(r/=f.get(i));const l=s+r,u=e.x(i);a.push([u,e.y(s)]),o.push([u,e.y(l)]),m.set(i,l),c.set(i,l)}p.set(i.key,c);const l={type:"area",topPath:o,bottomPath:a,style:r(i.key,i.data[0]),datum:i.data,group:i.key};s&&(l.curve=s),y.push(l)}return{nodes:y,stackedTops:p}}(s,t.scales,t.getX,t.getY,(e,i)=>t.resolveAreaStyle(e,i),t.config.normalize,l,u),f=h;if(t.config.pointStyle){const e=new WeakMap;for(const i of s){const o=d.get(i.key);if(o)for(const r of i.data){const i=t.getX(r),n=t.getY(r);null==i||Number.isNaN(i)||null==n||Number.isNaN(n)||!o.has(i)||e.set(r,o.get(i))}}const i=i=>{var o;return null!==(o=e.get(i))&&void 0!==o?o:t.getY(i)};rt(t,s,f,i)}return f}(h,e);case"scatter":case"bubble":return function(t,e){var i;const o=[],r="bubble"===t.config.chartType?10:5,n=t.config.sizeRange||[3,15];let s=null;if(t.getSize&&!t.config.pointStyle){const i=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(i.length>0){let t=1/0,e=-1/0;for(const o of i)t>o&&(t=o),o>e&&(e=o);s=i=>t===e?(n[0]+n[1])/2:n[0]+(i-t)/(e-t)*(n[1]-n[0])}}const a=t.getColor?t.resolveColorMap(e):null,c=(null===(i=t.config.themeSemantic)||void 0===i?void 0:i.primary)||"#4e79a7";for(const i of e){let e=t.config.pointStyle?t.config.pointStyle(i):{fill:c,opacity:.8},n=e.r||r;if(s&&t.getSize){const e=t.getSize(i);null==e||Number.isNaN(e)||(n=s(e))}if(a&&t.getColor&&!e.fill){const o=t.getColor(i);o&&a.has(o)&&(e=Object.assign(Object.assign({},e),{fill:a.get(o)}))}const l=t.getPointId?t.getPointId(i)+"":void 0,u=A(i,t.scales,t.getX,t.getY,n,e,l);u&&o.push(u)}return o}(h,e);case"heatmap":return function(t,e,i){if(t.config.heatmapAggregation)return function(t,e,i){var o,r,n;const s=Math.max(1,Math.floor(null!==(o=t.config.heatmapXBins)&&void 0!==o?o:20)),a=Math.max(1,Math.floor(null!==(r=t.config.heatmapYBins)&&void 0!==r?r:20)),c=null!==(n=t.config.heatmapAggregation)&&void 0!==n?n:"count",l=P(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[u,h]=t.scales.x.domain(),[d,f]=t.scales.y.domain(),g=(h-u||1)/s,y=(f-d||1)/a,p=s*a;if(p>1e6)return[];const m=new Int32Array(p),x=new Float64Array(p);for(let i=0;e.length>i;i++){const o=e[i],r=t.getX(o),n=t.getY(o);if(!isFinite(r)||!isFinite(n))continue;const c=Math.min(Math.floor((r-u)/g),s-1),h=Math.min(Math.floor((n-d)/y),a-1);if(0>c||0>h)continue;const f=h*s+c;m[f]++;const p=l(o);x[f]+=isFinite(p)?p:0}let v=1/0,b=-1/0;for(let t=0;p>t;t++){if(0===m[t])continue;let e;switch(c){case"sum":e=x[t];break;case"mean":e=x[t]/m[t];break;default:e=m[t]}v>e&&(v=e),e>b&&(b=e)}if(!isFinite(v))return[];const k=b-v||1,A=i.width/s,w=i.height/a,_=t.config.showValues,j=t.config.heatmapValueFormat,M=[];for(let t=0;a>t;t++){const e=t*s;for(let i=0;s>i;i++){const o=e+i;if(0===m[o])continue;let r;switch(c){case"sum":r=x[o];break;case"mean":r=x[o]/m[o];break;default:r=m[o]}const n=(r-v)/k;M.push(S(i*A,(a-1-t)*w,A,w,`rgb(${220-(180*n+.5)|0},${220-(100*n+.5)|0},${255-(50*n+.5)|0})`,{xi:i,yi:t,value:r,count:m[o],sum:x[o]},_?{value:r,showValues:!0,valueFormat:j}:void 0))}}return M}(t,e,i);if(0===e.length)return[];const o=P(t.config.valueAccessor,"value"),r=j(t.config.xAccessor,"x"),n=j(t.config.yAccessor,"y"),s=new Map,a=new Map,c=Array(e.length),l=Array(e.length);for(let t=0;e.length>t;t++){const i=e[t],o=r(i),u=n(i);c[t]=o,l[t]=u,s.has(o)||s.set(o,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,h=a.size;if(0===u||0===h)return[];const d=Array.from(s.keys()),f=Array.from(a.keys()),g=d.every(t=>"number"==typeof t&&!isNaN(t)),y=f.every(t=>"number"==typeof t&&!isNaN(t));if(g){d.sort((t,e)=>t-e),s.clear();for(let t=0;d.length>t;t++)s.set(d[t],t)}if(y){f.sort((t,e)=>t-e),a.clear();for(let t=0;f.length>t;t++)a.set(f[t],t)}const p=new Float64Array(e.length),m=new Float64Array(e.length),x=Array(e.length),v=new Map;let b=0;for(let t=0;e.length>t;t++){const i=e[t],r=s.get(c[t]),n=a.get(l[t]);if(void 0===r||void 0===n)continue;const h=o(i),d=n*u+r,f=v.get(d);let g;void 0!==f?g=f:(g=b++,v.set(d,g)),p[g]=d,m[g]=h,x[g]=i}let k=1/0,A=-1/0;for(let t=0;b>t;t++){const e=m[t];isFinite(e)&&(k>e&&(k=e),e>A&&(A=e))}if(!isFinite(k)||!isFinite(A))return[];const w=function(t){const e=t in nt?t:"blues";let i=st.get(e);if(i)return i;i=Array(256);const o=nt[e]||D;for(let t=0;256>t;t++)i[t]=o(t/255);return st.set(e,i),i}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),_=255/(A-k||1),M=i.width/u,O=i.height/h,L=t.config.showValues,E=t.config.heatmapValueFormat,T=[];for(let t=0;b>t;t++){const e=m[t];if(!isFinite(e))continue;const i=p[t],o=i%u;T.push(S(o*M,(h-1-(i-o)/u)*O,M,O,w[Math.min((e-k)*_+.5|0,255)],x[t],L?{value:e,showValues:!0,valueFormat:E}:void 0))}return T}(h,e,t);case"bar":{const t=function(t,e){var i,o;if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const r=x(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===r.size)return{nodes:[],binBoundaries:[]};let n=null;if(t.getCategory){const e=new Set;for(const t of r.values())for(const i of t.categories.keys())e.add(i);const i=t.config.barColors?Object.keys(t.config.barColors):[],o=new Set(i),s=Array.from(e).filter(t=>!o.has(t)).sort(),a=i.filter(t=>e.has(t)),c=a.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===c?n=t.barCategoryCache.order:(n=[...a,...s],t.barCategoryCache={key:c,order:n})}const s=[],a=t.scales,[c,l]=a.x.domain(),u=t.config.barStyle,h=null===(i=t.config.themeSemantic)||void 0===i?void 0:i.primary,d=null==u?void 0:u.gap,f="number"!=typeof d||0>d?1:d,g={};(null==u?void 0:u.stroke)&&(g.stroke=u.stroke),"number"==typeof(null==u?void 0:u.strokeWidth)&&(g.strokeWidth=u.strokeWidth),"number"==typeof(null==u?void 0:u.opacity)&&(g.opacity=u.opacity);for(const e of r.values()){const i=Math.max(e.start,c),r=Math.min(e.end,l);if(i>=r)continue;const d=a.x(i),y=a.x(r),p=Math.abs(y-d),m=p>f+1?f:0,x=Math.min(d,y)+m/2,v=Math.max(p-m,1);if(v>0)if(n&&e.categories.size>0){let i=0;for(const r of n){const n=e.categories.get(r)||0;if(0===n)continue;const c=a.y(i),l=a.y(i+n),d=(null===(o=t.config.barColors)||void 0===o?void 0:o[r])||(null==u?void 0:u.fill)||h||"#4e79a7";s.push(w(x,Math.min(c,l),v,Math.abs(c-l),Object.assign({fill:d},g),{binStart:e.start,binEnd:e.end,total:e.total,category:r,categoryValue:n},r)),i+=n}}else{const t=a.y(0),i=a.y(e.total);s.push(w(x,Math.min(t,i),v,Math.abs(t-i),Object.assign({fill:(null==u?void 0:u.fill)||h||"#007bff"},g),{binStart:e.start,binEnd:e.end,total:e.total}))}}const y=new Set;for(const t of r.values())y.add(t.start),y.add(t.end);return{nodes:s,binBoundaries:Array.from(y).sort((t,e)=>t-e)}}(h,e);return this._barCategoryCache=null!==(c=h.barCategoryCache)&&void 0!==c?c:null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){var i,o,r,n,s,a;const c=[],l=t.config.swarmStyle||{},u=null!==(i=l.radius)&&void 0!==i?i:3,h=null!==(n=null!==(o=l.fill)&&void 0!==o?o:null===(r=t.config.themeSemantic)||void 0===r?void 0:r.primary)&&void 0!==n?n:"#007bff",d=null!==(s=l.opacity)&&void 0!==s?s:.7,f=l.stroke,g=l.strokeWidth;for(const i of e){const e=t.getX(i),o=t.getY(i);if(null==o||Number.isNaN(o))continue;const r=t.scales.x(e),n=t.scales.y(o);let s=h;if(t.getCategory){const e=t.getCategory(i);s=(null===(a=t.config.barColors)||void 0===a?void 0:a[e])||s}const l={type:"point",x:r,y:n,r:u,style:{fill:s,opacity:d,stroke:f,strokeWidth:g},datum:i};t.getPointId&&(l.pointId=t.getPointId(i)+""),c.push(l)}return c}(h,e);case"waterfall":return function(t,e,i){var o,r,n,s,a,c,l;const u=[],h=t.scales,d=t.config.waterfallStyle,f=e.filter(e=>{const i=t.getY(e),o=t.getX(e);return null!=i&&!Number.isNaN(i)&&null!=o&&isFinite(o)});if(0===f.length)return u;const g=null!==(n=null!==(o=null==d?void 0:d.positiveColor)&&void 0!==o?o:null===(r=t.config.themeSemantic)||void 0===r?void 0:r.success)&&void 0!==n?n:"#28a745",y=null!==(c=null!==(s=null==d?void 0:d.negativeColor)&&void 0!==s?s:null===(a=t.config.themeSemantic)||void 0===a?void 0:a.danger)&&void 0!==c?c:"#dc3545",p=null!==(l=null==d?void 0:d.gap)&&void 0!==l?l:1,m=null==d?void 0:d.stroke,x=null==d?void 0:d.strokeWidth,v=null==d?void 0:d.opacity;let b=0;for(let e=0;f.length>e;e++){const o=f[e],r=t.getX(o),n=t.getY(o),s=b+n;let a;a=f.length-1>e?t.getX(f[e+1])-r:e>0?r-t.getX(f[e-1]):0;const c=h.x(r),l=0!==a?h.x(r+a):c+i.width/10,k=Math.min(c,l)+p/2,A=Math.max(c,l)-p/2-k;if(0>=A){b=s;continue}const S=h.y(b),_=h.y(s),P=Math.min(S,_),j=Math.abs(S-_),M={fill:0>n?y:g,stroke:m,strokeWidth:x};null!=v&&(M.opacity=v),u.push(w(k,P,A,j,M,Object.assign(Object.assign({},o),{baseline:b,cumEnd:s,delta:n,_connectorStroke:null==d?void 0:d.connectorStroke,_connectorWidth:null==d?void 0:d.connectorWidth}))),b=s}return u}(h,e,t);case"candlestick":return function(t,e){var i,o;if(!t.getHigh||!t.getLow||!t.scales)return[];const r=null!==(i=t.config.candlestickRangeMode)&&void 0!==i&&i;if(!(r||t.getOpen&&t.getClose))return[];const n=[],s=t.config.candlestickStyle||{},a=s.rangeColor||"#6366f1",c=r?a:s.upColor||"#28a745",l=r?a:s.downColor||"#dc3545",u=r?a:s.wickColor||"#333",h=s.wickWidth||(r?2:1),d=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let f=null!==(o=s.bodyWidth)&&void 0!==o?o:0;if(null==s.bodyWidth)if(d.length>1){let e=1/0;for(let i=1;d.length>i;i++){const o=Math.abs(t.scales.x(d[i])-t.scales.x(d[i-1]));o>0&&e>o&&(e=o)}f=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else f=6;for(const i of e){const e=t.getX(i);if(null==e||Number.isNaN(e))continue;const o=t.getHigh(i),s=t.getLow(i);if(null==o||Number.isNaN(o)||null==s||Number.isNaN(s))continue;const a=r?o:t.getOpen(i),d=r?s:t.getClose(i);if(!r&&[a,d].some(t=>null==t||Number.isNaN(t)))continue;const g=d>=a,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(a),closeY:t.scales.y(d),highY:t.scales.y(o),lowY:t.scales.y(s),bodyWidth:f,upColor:c,downColor:l,wickColor:u,wickWidth:h,isUp:g,datum:i};r&&(y.isRange=!0),n.push(y)}return n}(h,e);default:return[]}}resolveBoundsStyle(t,e){var i;const o=this.config.boundsStyle;return"function"==typeof o?o(e||{},t):o&&"object"==typeof o?o:{fill:this.resolveLineStyle(t,e).stroke||(null===(i=this.config.themeSemantic)||void 0===i?void 0:i.primary)||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?U(i,t,e):1}applyDecay(t,e){this.config.decay&&function(t,e,i){var o,r;const n=i.length;if(1>=n)return;const s=new Map;for(let t=0;i.length>t;t++)s.set(i[t],t);for(const i of e){if("line"===i.type){const e=Array.isArray(i.datum)?i.datum:[];if(2>e.length)continue;const o=Array(e.length);let r=!1;for(let i=0;e.length>i;i++){const a=s.get(e[i]);null!=a?(o[i]=U(t,a,n),1>o[i]&&(r=!0)):o[i]=1}r&&(i._decayOpacities=o);continue}if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[],o=i.topPath?i.topPath.length:e.length;if(2>o)continue;if(e.length===o){const r=Array(o);let a=!1;for(let i=0;e.length>i;i++){const o=s.get(e[i]);null!=o?(r[i]=U(t,o,n),1>r[i]&&(a=!0)):r[i]=1}a&&(i._decayOpacities=r)}else{let r=1;for(const i of e){const e=s.get(i);if(null!=e){const i=U(t,e,n);r>i&&(r=i)}}if(1>r){const t=Array(o);t.fill(r),i._decayOpacities=t}}continue}const e=s.get(i.datum);if(null==e)continue;const a=U(t,e,n);if("heatcell"===i.type)i.style={opacity:a};else if("candlestick"===i.type)i._decayOpacity=a;else{const t=null!==(r=null===(o=i.style)||void 0===o?void 0:o.opacity)&&void 0!==r?r:1;i.style=Object.assign(Object.assign({},i.style),{opacity:t*a})}}}(this.config.decay,t,e)}applyPulse(t,e){this.config.pulse&&this.timestampBuffer&&function(t,e,i,o){var r,n;const s="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(r=t.color)&&void 0!==r?r:"rgba(255,255,255,0.6)",c=null!==(n=t.glowRadius)&&void 0!==n?n:4,l=new Map;for(let t=0;i.length>t;t++)l.set(i[t],t);for(const i of e){if("line"===i.type)continue;if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[i.datum];let r=0;for(const i of e){const e=l.get(i);if(null==e)continue;const n=o.get(e);if(null==n)continue;const a=Z(t,n,s);a>r&&(r=a)}r>0&&(i._pulseIntensity=r,i._pulseColor=a);continue}const e=l.get(i.datum);if(null==e)continue;const r=o.get(e);if(null==r)continue;const n=Z(t,r,s);n>0&&(i._pulseIntensity=n,i._pulseColor=a,i._pulseGlowRadius=c)}}(this.config.pulse,t,e,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(t,e){var i;if(!e||0===e.size)return!1;const o="undefined"!=typeof performance?performance.now():Date.now(),r=null!==(i=t.duration)&&void 0!==i?i:500,n=e.peek();return null!=n&&r>o-n}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,i,o){var r,n,s,a;i.clear(),o.clear();for(let c=0;e.length>c;c++){const l=e[c],u=it(t,l,c);u&&("point"===l.type?i.set(u,{x:l.x,y:l.y,r:l.r,opacity:l.style.opacity}):"rect"===l.type?i.set(u,{x:l.x,y:l.y,w:l.w,h:l.h,opacity:l.style.opacity}):"heatcell"===l.type?i.set(u,{x:l.x,y:l.y,w:l.w,h:l.h,opacity:null===(r=l.style)||void 0===r?void 0:r.opacity}):"candlestick"===l.type?i.set(u,{x:l.x,y:l.openY,w:l.bodyWidth,openY:l.openY,closeY:l.closeY,highY:l.highY,lowY:l.lowY,opacity:null===(n=l.style)||void 0===n?void 0:n.opacity}):"line"===l.type?o.set(u,{path:l.path.map(t=>[t[0],t[1]]),opacity:null===(s=l.style)||void 0===s?void 0:s.opacity}):"area"===l.type&&o.set(u,{topPath:l.topPath.map(t=>[t[0],t[1]]),bottomPath:l.bottomPath.map(t=>[t[0],t[1]]),opacity:null===(a=l.style)||void 0===a?void 0:a.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){var t,e,i;this.prevPositionMap.clear(),this.prevPathMap.clear();const o=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.y(0))&&void 0!==e?e:0;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],r=it(this.transitionContext,e,t);r&&("point"===e.type?this.prevPositionMap.set(r,{x:e.x,y:e.y,r:0,opacity:0}):"rect"===e.type?this.prevPositionMap.set(r,{x:e.x,y:o,w:e.w,h:0,opacity:null!==(i=e.style.opacity)&&void 0!==i?i:1}):"heatcell"===e.type?this.prevPositionMap.set(r,{x:e.x,y:e.y,w:e.w,h:e.h,opacity:0}):"line"===e.type?(e._introClipFraction=0,this.prevPathMap.set(r,{path:e.path.map(t=>[t[0],t[1]]),opacity:e.style.opacity})):"area"===e.type&&(e._introClipFraction=0,this.prevPathMap.set(r,{topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),opacity:e.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,i,o,r){var n,s,a,c,l,u,h,d,f,g,y,p,m,x,v,b,k,A,w,S,_,P,j,M,O,L,E,T,D,z,$,R,C,N,F,B,W,Y,I,X,q;if(0===o.size&&0===r.size)return i;const G=null!==(n=e.duration)&&void 0!==n?n:300;if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}let V=!1;const H=new Set,Q=new Set;for(let e=0;i.scene.length>e;e++){const n=i.scene[e],L=it(t,n,e);if(!L)continue;if(n._transitionKey=L,"line"===n.type||"area"===n.type){const t=r.get(L);if(t){if(Q.add(L),"line"===n.type&&t.path&&t.path.length===n.path.length){n._targetPath=n.path.map(t=>[t[0],t[1]]),n._prevPath=t.path;for(let e=0;n.path.length>e;e++)n.path[e]=[t.path[e][0],t.path[e][1]];V=!0}else if("area"===n.type&&t.topPath&&t.bottomPath&&t.topPath.length===n.topPath.length&&t.bottomPath.length===n.bottomPath.length){n._targetTopPath=n.topPath.map(t=>[t[0],t[1]]),n._targetBottomPath=n.bottomPath.map(t=>[t[0],t[1]]),n._prevTopPath=t.topPath,n._prevBottomPath=t.bottomPath;for(let e=0;n.topPath.length>e;e++)n.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;n.bottomPath.length>e;e++)n.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];V=!0}n._targetOpacity=null!==(s=n.style.opacity)&&void 0!==s?s:1,n._startOpacity=null!==(c=null!==(a=t.opacity)&&void 0!==a?a:n.style.opacity)&&void 0!==c?c:1}else n._targetOpacity=null!==(l=n.style.opacity)&&void 0!==l?l:1,n._startOpacity=0,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),V=!0;continue}const E=o.get(L);if("point"===n.type)if(E){H.add(L);const t={x:n.x,y:n.y,r:n.r};n._targetOpacity=null!==(u=n.style.opacity)&&void 0!==u?u:1,E.x===t.x&&E.y===t.y&&E.r===t.r||(n._targetX=t.x,n._targetY=t.y,n._targetR=t.r,n.x=E.x,n.y=E.y,n.r=null!==(h=E.r)&&void 0!==h?h:n.r,V=!0)}else n._targetOpacity=null!==(d=n.style.opacity)&&void 0!==d?d:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),V=!0;else if("rect"===n.type)if(E){H.add(L);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=null!==(f=n.style.opacity)&&void 0!==f?f:1,E.x===t.x&&E.y===t.y&&E.w===t.w&&E.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=E.x,n.y=E.y,n.w=null!==(g=E.w)&&void 0!==g?g:n.w,n.h=null!==(y=E.h)&&void 0!==y?y:n.h,V=!0)}else n._targetOpacity=null!==(p=n.style.opacity)&&void 0!==p?p:1,n.style=Object.assign(Object.assign({},n.style),{opacity:0}),V=!0;else if("heatcell"===n.type)if(E){H.add(L);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,E.x===t.x&&E.y===t.y&&E.w===t.w&&E.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=E.x,n.y=E.y,n.w=null!==(v=E.w)&&void 0!==v?v:n.w,n.h=null!==(b=E.h)&&void 0!==b?b:n.h,V=!0)}else n._targetOpacity=null!==(A=null===(k=n.style)||void 0===k?void 0:k.opacity)&&void 0!==A?A:1,n.style=Object.assign(Object.assign({},n.style||{}),{opacity:0}),V=!0;else if("candlestick"===n.type)if(E&&null!=E.openY){H.add(L);const t={x:n.x,openY:n.openY,closeY:n.closeY,highY:n.highY,lowY:n.lowY};n._targetOpacity=null!==(S=null===(w=n.style)||void 0===w?void 0:w.opacity)&&void 0!==S?S:1,(E.x!==t.x||E.openY!==t.openY||E.closeY!==t.closeY||E.highY!==t.highY||E.lowY!==t.lowY)&&(n._targetX=t.x,n._targetOpenY=t.openY,n._targetCloseY=t.closeY,n._targetHighY=t.highY,n._targetLowY=t.lowY,n.x=E.x,n.openY=E.openY,n.closeY=null!==(_=E.closeY)&&void 0!==_?_:n.closeY,n.highY=null!==(P=E.highY)&&void 0!==P?P:n.highY,n.lowY=null!==(j=E.lowY)&&void 0!==j?j:n.lowY,V=!0)}else n._targetOpacity=null!==(O=null===(M=n.style)||void 0===M?void 0:M.opacity)&&void 0!==O?O:1,n.style=Object.assign(Object.assign({},n.style||{}),{opacity:0}),V=!0}for(const[t,e]of r)if(!Q.has(t))if(t.startsWith("l:")&&e.path){const o={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(L=e.opacity)&&void 0!==L?L:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),V=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const o={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:null!==(E=e.opacity)&&void 0!==E?E:1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),V=!0}for(const[t,e]of o)if(!H.has(t)){if(t.startsWith("p:")){const o={type:"point",x:e.x,y:e.y,r:null!==(T=e.r)&&void 0!==T?T:3,style:{opacity:null!==(D=e.opacity)&&void 0!==D?D:1},datum:null,_targetOpacity:0,_transitionKey:t};i.exitNodes.push(o)}else if(t.startsWith("r:")){const o={type:"rect",x:e.x,y:e.y,w:null!==(z=e.w)&&void 0!==z?z:0,h:null!==($=e.h)&&void 0!==$?$:0,style:{opacity:null!==(R=e.opacity)&&void 0!==R?R:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t};i.exitNodes.push(o)}else if(t.startsWith("h:")){const o={type:"heatcell",x:e.x,y:e.y,w:null!==(C=e.w)&&void 0!==C?C:0,h:null!==(N=e.h)&&void 0!==N?N:0,fill:"#999",datum:null,style:{opacity:null!==(F=e.opacity)&&void 0!==F?F:1},_targetOpacity:0,_transitionKey:t};i.exitNodes.push(o)}else if(t.startsWith("c:")){const o=null!==(B=e.openY)&&void 0!==B?B:e.y,r={type:"candlestick",x:e.x,openY:o,closeY:null!==(W=e.closeY)&&void 0!==W?W:o,highY:null!==(Y=e.highY)&&void 0!==Y?Y:o,lowY:null!==(I=e.lowY)&&void 0!==I?I:o,bodyWidth:null!==(X=e.w)&&void 0!==X?X:6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:null!==(q=e.opacity)&&void 0!==q?q:1},_targetOpacity:0,_transitionKey:t};i.exitNodes.push(r)}V=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),V&&(i.activeTransition={startTime:et(),duration:G}),i}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},i=function(t,e,i,o){var r,n,s,a,c,l;if(!i.activeTransition)return!1;const u=J(t,i.activeTransition),h=K(u,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of i.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,n=i?null!==(r=i.opacity)&&void 0!==r?r:1:0;t.style.opacity=tt(n,t._targetOpacity,h)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=tt(i.x,t._targetX,h),t.y=tt(i.y,t._targetY,h),void 0!==t._targetR&&void 0!==i.r&&(t.r=tt(i.r,t._targetR,h))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,r=i?null!==(n=i.opacity)&&void 0!==n?n:1:0;t.style.opacity=tt(r,t._targetOpacity,h)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=tt(i.x,t._targetX,h),t.y=tt(i.y,t._targetY,h),void 0!==i.w&&(t.w=tt(i.w,t._targetW,h)),void 0!==i.h&&(t.h=tt(i.h,t._targetH,h))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,r=i?null!==(s=i.opacity)&&void 0!==s?s:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:tt(r,t._targetOpacity,h)})}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=tt(i.x,t._targetX,h),t.y=tt(i.y,t._targetY,h),void 0!==i.w&&(t.w=tt(i.w,t._targetW,h)),void 0!==i.h&&(t.h=tt(i.h,t._targetH,h))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0,r=i?null!==(a=i.opacity)&&void 0!==a?a:1:0;t.style=Object.assign(Object.assign({},t.style||{}),{opacity:tt(r,t._targetOpacity,h)})}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=tt(i.x,t._targetX,h),void 0!==i.openY&&(t.openY=tt(i.openY,t._targetOpenY,h)),void 0!==i.closeY&&(t.closeY=tt(i.closeY,t._targetCloseY,h)),void 0!==i.highY&&(t.highY=tt(i.highY,t._targetHighY,h)),void 0!==i.lowY&&(t.lowY=tt(i.lowY,t._targetLowY,h))}else if("line"===t.type){if(void 0!==t._targetOpacity){const e=null!==(c=t._startOpacity)&&void 0!==c?c:0;t.style=Object.assign(Object.assign({},t.style),{opacity:tt(e,t._targetOpacity,h)})}void 0!==t._introClipFraction&&(t._introClipFraction=h);const e=t._prevPath,i=t._targetPath;if(e&&i&&e.length===t.path.length)for(let o=0;t.path.length>o;o++)t.path[o][0]=tt(e[o][0],i[o][0],h),t.path[o][1]=tt(e[o][1],i[o][1],h)}else if("area"===t.type){if(void 0!==t._targetOpacity){const e=null!==(l=t._startOpacity)&&void 0!==l?l:0;t.style=Object.assign(Object.assign({},t.style),{opacity:tt(e,t._targetOpacity,h)})}void 0!==t._introClipFraction&&(t._introClipFraction=h);const e=t._prevTopPath,i=t._prevBottomPath,o=t._targetTopPath,r=t._targetBottomPath;if(e&&o&&e.length===t.topPath.length)for(let i=0;t.topPath.length>i;i++)t.topPath[i][0]=tt(e[i][0],o[i][0],h),t.topPath[i][1]=tt(e[i][1],o[i][1],h);if(i&&r&&i.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=tt(i[e][0],r[e][0],h),t.bottomPath[e][1]=tt(i[e][1],r[e][1],h)}}if(u>=1){for(const t of i.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style=Object.assign(Object.assign({},"line"===t.type||"area"===t.type?t.style:t.style||{}),{opacity:0===e?0:e}),t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("candlestick"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let i=0;t.path.length>i;i++)t.path[i]=e[i];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,i=t._targetBottomPath;if(e)for(let i=0;t.topPath.length>i;i++)t.topPath[i]=e[i];if(i)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=i[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}return i.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,i}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const t of this.scene)"line"!==t.type&&"area"!==t.type||(t._introClipFraction=void 0)}groupData(t){if(!this.getGroup)return[{key:"_default",data:t}];const e=new Map;for(const i of t){const t=this.getGroup(i);e.has(t)||e.set(t,[]),e.get(t).push(i)}return Array.from(e.entries()).map(([t,e])=>({key:t,data:e}))}resolveColorMap(t){if(this._colorMapCache&&this._colorMapCache.version===this._ingestVersion)return this._colorMapCache.map;const e=new Set;for(const i of t){const t=this.getColor(i);t&&e.add(t)}const i=Array.from(e).sort(),o=i.join("\0");if(this._colorMapCache&&this._colorMapCache.key===o)return this._colorMapCache.version=this._ingestVersion,this._colorMapCache.map;const r=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||V,n=new Map;for(let t=0;i.length>t;t++)n.set(i[t],r[t%r.length]);return this._colorMapCache={key:o,map:n,version:this._ingestVersion},n}resolveLineStyle(t,e){var i;const o=this.config.lineStyle;if("function"==typeof o){const i=o(e||{},t);if(i&&!i.stroke&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{stroke:e})}return i}const r=null===(i=this.config.themeSemantic)||void 0===i?void 0:i.primary;return o&&"object"==typeof o?{stroke:o.stroke||r||"#007bff",strokeWidth:o.strokeWidth||2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity}:{stroke:this.resolveGroupColor(t)||r||"#007bff",strokeWidth:2}}resolveAreaStyle(t,e){var i,o;if(this.config.areaStyle){const i=this.config.areaStyle(e||{});if(i&&!i.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{fill:e,stroke:i.stroke||e})}return i}const r=this.config.lineStyle;if("function"==typeof r){const i=r(e||{},t);if(i&&!i.fill&&t){const e=this.resolveGroupColor(t);if(e)return Object.assign(Object.assign({},i),{fill:e,stroke:i.stroke||e})}return i}const n=null===(i=this.config.themeSemantic)||void 0===i?void 0:i.primary;if(r&&"object"==typeof r)return{fill:r.fill||r.stroke||n||"#4e79a7",fillOpacity:null!==(o=r.fillOpacity)&&void 0!==o?o:.7,stroke:r.stroke||n||"#4e79a7",strokeWidth:r.strokeWidth||2};const s=this.resolveGroupColor(t)||n||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}resolveGroupColor(t){if(this._colorMapCache){const e=this._colorMapCache.map.get(t);if(e)return e}const e=this._groupColorMap.get(t);if(e)return e;const i=(Array.isArray(this.config.colorScheme)&&this.config.colorScheme.length>0?this.config.colorScheme:null)||(Array.isArray(this.config.themeCategorical)&&this.config.themeCategorical.length>0?this.config.themeCategorical:null)||V;if(0===i.length)return null;const o=i[this._groupColorCounter%i.length];if(this._groupColorCounter++,this._groupColorMap.set(t,o),this._groupColorMap.size>at.GROUP_COLOR_MAP_CAP){const t=this._groupColorMap.keys().next().value;void 0!==t&&this._groupColorMap.delete(t)}return o}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),i=this.getPointId,o=t=>e.has(i(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,i)=>{o(t)&&e.add(i)}),this.timestampBuffer.clear();for(let i=0;t.length>i;i++)e.has(i)||this.timestampBuffer.push(t[i])}const r=this.buffer.remove(o);if(0===r.length)return r;for(const t of r)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,r}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const i=new Set(Array.isArray(t)?t:[t]),o=this.getPointId,r=new Set;this.buffer.forEach((t,e)=>{i.has(o(t))&&r.add(e)});const n=this.buffer.update(t=>i.has(o(t)),e);if(0===n.length)return n;for(const t of n)this.xExtent.evict(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(t)),this.yExtent.evict(this.getLow(t))):(this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t)));return this.buffer.forEach((t,e)=>{r.has(e)&&(this.xExtent.push(this.getX(t)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(t)),this.yExtent.push(this.getLow(t))):(this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,n}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this._quadtree=null,this._maxPointRadius=0,this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}updateConfig(t){var e,i,o,r;const n=Object.assign({},this.config);("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"boundsAccessor"in t||"y0Accessor"in t||"openAccessor"in t||"highAccessor"in t||"lowAccessor"in t||"closeAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(this._stackExtentCache=null);let s=!1,a=!1;Object.assign(this.config,t);const c="chartType"in t&&t.chartType!==n.chartType||"runtimeMode"in t&&t.runtimeMode!==n.runtimeMode;if(c||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const l=c||!_(null!==(e=t.xAccessor)&&void 0!==e?e:t.timeAccessor,null!==(i=n.xAccessor)&&void 0!==i?i:n.timeAccessor),u=c||!_(null!==(o=t.yAccessor)&&void 0!==o?o:t.valueAccessor,null!==(r=n.yAccessor)&&void 0!==r?r:n.valueAccessor);(l||u)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=P(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=P(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=P(this.config.xAccessor,"x"),this.getY=P(this.config.yAccessor,"y")),s=!0,a=!0)}if("groupAccessor"in t&&!_(t.groupAccessor,n.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?M(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in t&&!_(t.categoryAccessor,n.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?M(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in t&&!_(t.sizeAccessor,n.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?P(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in t&&!_(t.colorAccessor,n.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?M(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in t&&!_(t.y0Accessor,n.y0Accessor)&&(this.getY0=this.config.y0Accessor?P(this.config.y0Accessor,"y0"):void 0,s=!0,a=!0),"boundsAccessor"in t&&!_(t.boundsAccessor,n.boundsAccessor)&&(this.getBounds=this.config.boundsAccessor?P(this.config.boundsAccessor,"bounds"):void 0,s=!0,a=!0),"pointIdAccessor"in t&&!_(t.pointIdAccessor,n.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?M(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&(c||"openAccessor"in t&&!_(t.openAccessor,n.openAccessor)||"closeAccessor"in t&&!_(t.closeAccessor,n.closeAccessor)||"highAccessor"in t&&!_(t.highAccessor,n.highAccessor)||"lowAccessor"in t&&!_(t.lowAccessor,n.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?P(this.config.openAccessor,"open"):void 0,this.getHigh=P(this.config.highAccessor,"high"),this.getLow=P(this.config.lowAccessor,"low"),this.getClose=e?P(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,s=!0,a=!0}if(!s){const e=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const i of e)if(t[i]!==n[i]){s=!0;break}}s&&(a&&this.rebuildExtents(),this.needsFullRebuild=!0)}}function ct(t,e){var i=t.get(e);if(!i)throw Error("missing: "+e);return i}function lt(t,e){var i,o=[],r=[],n=[],s={},a=[];function c(t){n[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],n[e]&&c(e)})}function l(t){var e,o,h=!1;for(r.push(t),n[t]=!0,e=0;a[t].length>e;e++)(o=a[t][e])===i?(u(i,r),h=!0):n[o]||(h=l(o));if(h)c(t);else for(e=0;a[t].length>e;e++){var d=s[o=a[t][e]];d||(s[o]=d={}),d[o]=!0}return r.pop(),h}function u(t,e){var i=[].concat(e).concat(t);o.push(i)}function h(e){!function(e){for(var i=0;t.length>i;i++)i>=e&&t[i]||(t[i]=[]),t[i]=t[i].filter(function(t){return t>=e})}(e);for(var i,o=function(t){for(var e=t.length,i=Array(e),o=Array(e),r=Array(e),n=Array(e),s=Array(e),a=Array(e),c=0;e>c;++c)i[c]=-1,o[c]=0,r[c]=!1,n[c]=0,s[c]=-1,a[c]=[];var l,u=0,h=[],d=[];function f(e){var c=[e],l=[e];for(i[e]=o[e]=u,r[e]=!0,u+=1;l.length>0;){var f=t[e=l[l.length-1]];if(f.length>n[e]){for(var g=n[e];f.length>g;++g){var y=f[g];if(0>i[y]){i[y]=o[y]=u,r[y]=!0,u+=1,c.push(y),l.push(y);break}r[y]&&(o[e]=0|Math.min(o[e],o[y])),0>s[y]||a[e].push(s[y])}n[e]=g}else{if(o[e]===i[e]){var p=[],m=[],x=0;for(g=c.length-1;g>=0;--g){var v=c[g];if(r[v]=!1,p.push(v),m.push(a[v]),x+=a[v].length,s[v]=h.length,v===e){c.length=g;break}}h.push(p);var b=Array(x);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)b[--x]=m[g][k];d.push(b)}l.pop()}}}for(c=0;e>c;++c)0>i[c]&&f(c);for(c=0;d.length>c;c++){var g=d[c];if(0!==g.length){g.sort(function(t,e){return t-e}),l=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&l.push(g[y]);d[c]=l}}return{components:h,adjacencyList:d}}(t),r=o.components.filter(function(t){return t.length>1}),n=1/0,s=0;r.length>s;s++)for(var a=0;r[s].length>a;a++)n>r[s][a]&&(n=r[s][a],i=s);var c=r[i];if(!c)return!1;var l=t.map(function(t,e){return-1===c.indexOf(e)?[]:t.filter(function(t){return-1!==c.indexOf(t)})});return{leastVertex:n,adjList:l}}i=0;for(var d=t.length;d>i;){var f=h(i);if(i=f.leastVertex,a=f.adjList){for(var g=0;a.length>g;g++)for(var y=0;a[g].length>y;y++){var p=a[g][y];n[+p]=!1,s[p]={}}l(i),i+=1}else i=d}return o}function ut(t){return t.y0-t.y1>0?"up":"down"}function ht(t,e){return e(t.source)==e(t.target)}function dt(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 ft(t){return t.target.x0-t.source.x1}function gt(t,e){var i=pt(t),o=ft(e)/Math.tan(i);return"up"==ut(t)?t.y1-o:t.y1+o}function yt(t,e){var i=pt(t),o=ft(e)/Math.tan(i);return"up"==ut(t)?t.y1+o:t.y1-o}function pt(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function mt(t,e){return e(t)}function xt(t){return bt(t.source)}function vt(t){return bt(t.target)}function bt(t){return(t.y0+t.y1)/2}function kt(t){return t.virtual?0:t.value}function At(t,e){var i=0;t.sourceLinks.forEach(function(t){i=t.circular&&!ht(t,e)?i+1:i});var o=0;return t.targetLinks.forEach(function(t){o=t.circular&&!ht(t,e)?o+1:o}),i+o}function wt(t){return t.target.depth}function St(t,e){return t.sourceLinks.length?t.depth:e-1}function _t(t,e){return t.y0-e.y0}function Pt(t,e){return e.y0-t.y0}function jt(t,e){return t.y1-e.y1}function Mt(t,e){return e.y1-t.y1}function Ot(t,e){return Et(t.source,e.source)||t.index-e.index}function Lt(t,e){return Et(t.target,e.target)||t.index-e.index}function Et(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function Tt(t,e){return Dt(t)==Dt(e)?"bottom"==t.circularLinkType?Pt(t,e):_t(t,e):Dt(e)-Dt(t)}function Dt(t){return t.target.column-t.source.column}function zt(t,e){return $t(t)==$t(e)}function $t(t){return t.y0-t.y1>0?"up":"down"}function Rt(t,e,i,o,r){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=n.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}),Ct(s.links.filter(function(t){return"top"==t.circularLinkType}),e,i),Ct(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+o,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,ht(t,e)&&dt(t))t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+r+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-r-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var n=t.source.column,a=t.circularLinkType,l=s.links.filter(function(t){return t.source.column==n&&t.circularLinkType==a});l.sort("bottom"==t.circularLinkType?Pt:_t);var u=0;l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2+r*i+u),u+=e._circularWidth||e.width}),n=t.target.column,(l=s.links.filter(function(t){return t.target.column==n&&t.circularLinkType==a})).sort("bottom"==t.circularLinkType?Mt:jt),u=0,l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2+r*i+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(s.y1,t.source.y1,t.target.y1)+r+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=c-r-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,i=t.y0,o=t.target.x0,r=t.y1,n=(e+o)/2;return"M"+e+","+i+"C"+n+","+i+" "+n+","+r+" "+o+","+r}(t)}),s}function Ct(t,e,i){t.sort(Tt);var o=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,r){var n=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(ht(t,e)&&dt(t))t.circularPathData.verticalBuffer=n+t._circularWidth/2;else{for(var s=0;o.length>s;s++){var a=o[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&Nt(t,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+i;n=c>n?c:n}}t.circularPathData.verticalBuffer=n+t._circularWidth/2}}),t}function Nt(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}function Ft(t){return function(){return t}}function Bt(t){return t.index}function Wt(t){return t.nodes}function Yt(t){return t.links}function It(t,e,i){var o=n.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});o.forEach(function(r,n){var s=r.length;if(e)r.sort(e);else if(n>0){var a=new Map;r.forEach(function(t,e){var i,o,r,n=(o=0,r=0,(i=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=bt(t.source)*e,o+=e}}),i.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=bt(t.target)*e,o+=e}}),o>0?r/o:NaN);a.set(t,{bc:n,idx:e})}),r.sort(function(t,e){var i=a.get(t),o=a.get(e),r=i.bc,n=o.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(r)||isNaN(n)?isNaN(r)?isNaN(n)?i.idx-o.idx:1:-1:r-n})}else r.sort(function(t,e){return t.circularLinkType==e.circularLinkType?At(e,i)-At(t,i):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});r.forEach(function(e,r){e.depth==o.length-1&&1==s||0==e.depth&&1==s?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==At(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,o,r,s){var a=n.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 o=a.length;a.forEach(function(r){var s=r.length,a=r[0].depth;r.forEach(function(r){var c;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&At(r,i)>0){var l=n.mean(r.sourceLinks,vt),u=n.mean(r.targetLinks,xt),h=l&&u?(l+u)/2:l||u;if(h){var d=(h-bt(r))*e*.3;r.y0+=d,r.y1+=d}}else if(0==a&&1==s)r.y0=t.y1/2-(c=r.y1-r.y0)/2,r.y1=t.y1/2+c/2;else if(a==o-1&&1==s)r.y0=t.y1/2-(c=r.y1-r.y0)/2,r.y1=t.y1/2+c/2;else if(1==r.targetLinks.length&&1==r.targetLinks[0].source.sourceLinks.length)c=r.y1-r.y0,r.y0=r.targetLinks[0].source.y0,r.y1=r.y0+c;else{var f=n.mean(r.sourceLinks,vt),g=n.mean(r.targetLinks,xt),y=((f&&g?(f+g)/2:f||g)-bt(r))*e;r.y0+=y,r.y1+=y}})})}function h(){a.forEach(function(i){var n,s,a,c=t.y0,l=i.length;for(i.sort(e||Et),a=0;l>a;++a)(s=c-(n=i[a]).y0)>0&&(n.y0+=s,n.y1+=s),c=n.y1+o;if((s=c-o-t.y1)>0)for(c=n.y0-=s,n.y1-=s,a=l-2;a>=0;--a)(s=(n=i[a]).y1+r-c)>0&&(n.y0-=s,n.y1-=s),c=n.y0})}}function qt(t){t.nodes.forEach(function(t){t.sourceLinks.sort(Lt),t.targetLinks.sort(Ot)}),t.nodes.forEach(function(t){var e=t.y0,i=e,o=t.y1,r=o;t.sourceLinks.forEach(function(t){t.circular?(t.y0=o-t.width/2,o-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=r-t.width/2,r-=t.width):(t.y1=i+t.width/2,i+=t.width)})})}function Gt(){var t=0,e=0,i=1,o=1,r=24,s=8,a=null,c=Bt,l=St,u=void 0,h=32,d=2,f=Wt,g=Yt;function y(){var y={nodes:f.apply(null,arguments),links:g.apply(null,arguments)};return function(f){f.x0=t,f.y0=e,f.x1=i,f.y1=o,f.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var i=function(t,e){var i=new Map;return n.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 o=t.source,r=t.target;"object"!=typeof o&&(o=t.source=ct(i,o)),"object"!=typeof r&&(r=t.target=ct(i,r)),o.sourceLinks.push(t),r.targetLinks.push(t)})}(f,c),function(t,e){var i=0;if(null==e){for(var o=[],r=0;t.links.length>r;r++){var n=t.links[r],s=n.source.index,a=n.target.index;o[s]||(o[s]=[]),o[a]||(o[a]=[]),-1===o[s].indexOf(a)&&o[s].push(a)}var c=lt(o);c.sort(function(t,e){return t.length-e.length});var l={};for(r=0;c.length>r;r++){var u=c[r].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,o=t.source.index;e===o||l[o]&&l[o][e]?(t.circular=!0,t.circularLinkID=i++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=i++)})}(f,u),function(t,e){var i=0,o=0;t.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:o>i?"top":"bottom","top"==r.circularLinkType?i++:o++,t.nodes.forEach(function(t){mt(t,e)!=mt(r.source,e)&&mt(t,e)!=mt(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),ht(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(f,c),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(n.sum(t.sourceLinks,kt),n.sum(t.targetLinks,kt)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(f),function(t,e,i){var o,r,n;if(null!=e){t.nodes.sort(function(t,i){return e(t)<e(i)?-1:1});var s=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==a?s:s+1,a=e(t)==a?a:e(t),t.column=s})}for(o=t.nodes,r=[],n=0;o.length;++n,o=r,r=[])o.forEach(function(t){t.depth=n,t.sourceLinks.forEach(function(t){0>r.indexOf(t.target)&&!t.circular&&r.push(t.target)})});for(o=t.nodes,r=[],n=0;o.length;++n,o=r,r=[])o.forEach(function(t){t.height=n,t.targetLinks.forEach(function(t){0>r.indexOf(t.source)&&!t.circular&&r.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?i(t,n):t.column})}(f,u,l);var g=s;if(null!==a){var y=n.groups(f.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=n.max(y,function(t){return t.length});p>1&&(g=Math.max(1,(o-e)*a/(p-1)))}(function(t,e,i){var o=n.groups(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var r=n.min(o,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/n.sum(e,function(t){return t.value})});t.ky=r,t.links.forEach(function(e){e.width=e.value*t.ky});var s=n.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})})(f,g,r),It(f,u,c),Xt(f,u,c,g,g,h),qt(f),Rt(f,c,d,10,8),It(f,u,c),Xt(f,u,c,g,g,h),qt(f),Rt(f,c,d,10,8),function(t,e){let i=t;i.nodes.forEach(function(t){t.y+(t.y1-t.y0)>i.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-i.y1));var o=i.links.filter(function(i){return mt(i.source,e)==mt(t,e)}),r=o.length;r>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!zt(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var i=gt(e,t);return t.y1-i}if(e.target.column>t.target.column)return gt(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var n=t.y0;o.forEach(function(t){t.y0=n+t.width/2,n+=t.width}),o.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var n=i+1,s=0;r>n;n++)s+=o[n].width;e.y0=t.y1-s-e.width/2}})})}(f,c),function(t,e){let i=t;i.nodes.forEach(function(t){var o=i.links.filter(function(i){return mt(i.target,e)==mt(t,e)}),r=o.length;r>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!zt(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var i=yt(e,t);return t.y0-i}if(e.source.column>t.source.column)return yt(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var n=t.y0;o.forEach(function(t){t.y1=n+t.width/2,n+=t.width}),o.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var n=i+1,s=0;r>n;n++)s+=o[n].width;e.y1=t.y1-s-e.width/2}})})}(f,c),function(t){var e=t.nodes,i=t.links,o=!1,r=!1;if(i.forEach(function(t){"top"==t.circularLinkType?o=!0:"bottom"==t.circularLinkType&&(r=!0)}),0==o||0==r){var s=n.min(e,function(t){return t.y0}),a=n.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})})}}(f),Rt(f,c,d,10,8)}(y),y}return y.update=function(t){return qt(t),Rt(t,c,d,10,8),t},y.nodeWidth=function(t){return arguments.length?(r=+t,y):r},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?(f="function"==typeof t?t:Ft(t),y):f},y.links=function(t){return arguments.length?(g="function"==typeof t?t:Ft(t),y):g},y.nodeId=function(t){return arguments.length?(c="function"==typeof t?t:Ft(t),y):c},y.nodeAlign=function(t){return arguments.length?(l="function"==typeof t?t:Ft(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?(d=+t,y):d},y.extent=function(r){return arguments.length?(t=+r[0][0],e=+r[0][1],i=+r[1][0],o=+r[1][1],y):[[t,e],[i,o]]},y.size=function(r){return arguments.length?(t=e=0,i=+r[0],o=+r[1],y):[i-t,o-e]},y}at.GROUP_COLOR_MAP_CAP=1e3,at.QUADTREE_THRESHOLD=500;const Vt=t=>{let e,i,o,r,n,a,c,l,u;return"down"===t.direction?(e=t.y0-t.sankeyWidth/2,i=t.y1-t.sankeyWidth/2,o=t.y1+t.sankeyWidth/2,r=t.y0+t.sankeyWidth/2,n=t.source.x1,a=t.target.x0,c=s.interpolateNumber(n,a),l=c(.5),u=c(.5),`M${e},${n}C${e},${l} ${i},${u} ${i},${a}L${o},${a}C${o},${u} ${r},${l} ${r},${n}Z`):(e=t.source.x1,i=t.target.x0,c=s.interpolateNumber(e,i),o=c(.5),r=c(.5),n=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},${n}C${o},${n} ${r},${a} ${i},${a}L${i},${l}C${r},${l} ${o},${u} ${e},${u}Z`)};function Ht(t){var e;const i=t.sankeyWidth/2,o=(null!==(e=t._circularWidth)&&void 0!==e?e:t.sankeyWidth)/2,r=t.circularPathData;if(!r)return null;if("down"===t.direction)return null;if(t._circularStub){const e=r.sourceX,o=r.sourceY,n=r.targetX,s=r.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(r.rightFullExtent-e))),c=Math.max(15,Math.min(40,.33*(n-r.leftFullExtent)));return`M${e},${o-i}L${e+a},${o-i}L${e+a},${o+i}L${e},${o+i}ZM${n},${s-i}L${n-c},${s-i}L${n-c},${s+i}L${n},${s+i}Z`}const n=r.sourceX,s=r.sourceY,a=r.targetX,c=r.targetY,l=r.rightFullExtent,u=r.leftFullExtent,h=r.verticalFullExtent,d="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(o,15));return`M${n},${s-d*i}L${l},${s-d*i}L${l+o},${s-d*i+d*f}L${l+o},${h+d*o-d*f}L${l+o-f},${h+d*o}L${u-o+f},${h+d*o}L${u-o},${h+d*o-d*f}L${u-o},${c-d*i+d*f}L${u-o+f},${c-d*i}L${a},${c-d*i}L${a},${c+d*i}L${u+o},${c+d*i}L${u+o},${h-d*o}L${l-o},${h-d*o}L${l-o},${s+d*i}L${n},${s+d*i}Z`}const Qt=new Set,Ut=new WeakMap;function Zt(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let i=Ut.get(t);if(i){const t=i.get(e);if(t)return t}else i=new Map,Ut.set(t,i);const o=new Proxy(t,{get(t,i,o){if("string"==typeof i&&!(i in t)&&t.data&&i in t.data){const t=`${e}:${i}`;Qt.has(t)||(Qt.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${i}" on the wrapper object, but it only exists on ".data". Use d.data.${i} (or d.data?.${i}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,i,o)}});return i.set(e,o),o}const Kt={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(wt))-1:0},justify:St};function Jt(t){return"string"==typeof t?t:t.id}const te={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,o){var r,n,s,a,c,l,u;if(0===t.length)return;const h="vertical"===i.orientation?"down":"right",d=i.nodeAlign||"justify",f=null!==(r=i.nodeWidth)&&void 0!==r?r:15,g=null!==(n=i.nodePaddingRatio)&&void 0!==n?n:.05,y=null!==(s=i.iterations)&&void 0!==s?s:100,p=t.map(t=>Object.assign({},t)),m=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let x;x="down"===h?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const v=Gt().extent(x).links(m).nodes(p).nodeAlign(Kt[d]||St).nodeId(t=>t.id).nodeWidth(f).iterations(y);v.nodePaddingRatio&&v.nodePaddingRatio(g),v();{let t=1/0,e=-1/0,i=1/0,r=-1/0;for(const o of p)t>o.x0&&(t=o.x0),o.x1>e&&(e=o.x1),i>o.y0&&(i=o.y0),o.y1>r&&(r=o.y1);for(const o of m){if(!o.circular||!o.circularPathData)continue;const n=o.circularPathData,s=(null!==(c=null!==(a=o._circularWidth)&&void 0!==a?a:o.width)&&void 0!==c?c:0)/2;t>n.leftFullExtent-s&&(t=n.leftFullExtent-s),n.rightFullExtent+s>e&&(e=n.rightFullExtent+s),i>n.verticalFullExtent-s&&(i=n.verticalFullExtent-s),n.verticalFullExtent+s>r&&(r=n.verticalFullExtent+s)}const n=e-t,s=r-i,u=o[0],h=o[1];if(n>0&&s>0&&(0>t||0>i||e>u||r>h)){const e=Math.min(u/n,h/s),o=-t*e+(u-n*e)/2,r=-i*e+(h-s*e)/2;for(const t of p)t.x0=t.x0*e+o,t.x1=t.x1*e+o,t.y0=t.y0*e+r,t.y1=t.y1*e+r;for(const t of m)if(t.y0=t.y0*e+r,t.y1=t.y1*e+r,t.width=(null!==(l=t.width)&&void 0!==l?l:0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const i=t.circularPathData;i.sourceX=i.sourceX*e+o,i.targetX=i.targetX*e+o,i.sourceY=i.sourceY*e+r,i.targetY=i.targetY*e+r,i.rightFullExtent=i.rightFullExtent*e+o,i.leftFullExtent=i.leftFullExtent*e+o,i.verticalFullExtent=i.verticalFullExtent*e+r,i.rightInnerExtent=i.rightInnerExtent*e+o,i.leftInnerExtent=i.leftInnerExtent*e+o,i.verticalRightInnerExtent=i.verticalRightInnerExtent*e+r,i.verticalLeftInnerExtent=i.verticalLeftInnerExtent*e+r,i.rightSmallArcRadius*=e,i.rightLargeArcRadius*=e,i.leftSmallArcRadius*=e,i.leftLargeArcRadius*=e,i.sourceWidth*=e,i.rightNodeBuffer*=e,i.leftNodeBuffer*=e,i.arcRadius*=e}}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of p){const e=b.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const k=new Map;for(const t of e)k.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of m){const e=Jt(t.source),i=Jt(t.target),o=k.get(t._edgeKey?t._edgeKey:`${e}\0${i}`);if(o){o.y0=t.y0,o.y1=t.y1,o.sankeyWidth=null!==(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 r=b.get(e),n=b.get(i);r&&(o.source=r),n&&(o.target=n)}}},buildScene(t,e,i,o){var r,n,s,a,c,l;const u="vertical"===i.orientation?"down":"right",h=i.nodeStyle,d=i.edgeStyle,f=null!==(r=i.edgeOpacity)&&void 0!==r?r:.5,g=i.edgeColorBy||"source",y=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:T,p=new Map;t.forEach((t,e)=>{p.set(t.id,y[e%y.length])});const m=[],x=[],v=[],b=new Map;for(const e of t){const t=e.x1-e.x0,i=e.y1-e.y0;if(0>=t||0>=i)continue;const o=h?h(Zt(e,"nodeStyle")):{},r={fill:o.fill||p.get(e.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};b.set(e.id,("string"==typeof r.fill?r.fill:null)||p.get(e.id)||"#4d430c"),m.push("down"===u?{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 k=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of k){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let r=(null===(n=i.themeSemantic)||void 0===n?void 0:n.border)||(null===(s=i.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";r="function"==typeof g?g(t)||r:"target"===g?b.get(o.id)||p.get(o.id)||r:b.get(e.id)||p.get(e.id)||r;const u=d?d(Zt(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,i=t.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),n=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),s=u.fill||r;x.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-i}L${e.sourceX+o},${e.sourceY-i}L${e.sourceX+o},${e.sourceY+i}L${e.sourceX},${e.sourceY+i}Z`,style:{fill:s,fillOpacity:null!==(a=u.fillOpacity)&&void 0!==a?a:f,stroke:"none",opacity:u.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+o}}),x.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-i}L${e.targetX-n},${e.targetY-i}L${e.targetX-n},${e.targetY+i}L${e.targetX},${e.targetY+i}Z`,style:{fill:s,fillOpacity:null!==(c=u.fillOpacity)&&void 0!==c?c:f,stroke:"none",opacity:u.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-n,x1:e.targetX}});continue}let h;if(h=t.circular&&t.circularPathData?Ht(t):Vt(t),!h)continue;const y={fill:u.fill||r,fillOpacity:null!==(l=u.fillOpacity)&&void 0!==l?l:f,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};x.push({type:"bezier",pathD:h,bezierCache:t.bezier,style:y,datum:t})}if(!1!==i.showLabels){const e=(A=i.nodeLabel)?"function"==typeof A?A:t=>t[A]||t.id:null;for(const i of t){const t=i.x1-i.x0,r=i.y1-i.y0;if(0>=t||0>=r)continue;const n=e?e(i):i.id;if(!n)continue;let s,a,c;"down"===u?(s=i.y0+(i.y1-i.y0)/2,a=i.x1+14,c="start"):(o[0]/2>i.x0+t/2?(s=i.x0-6,c="end"):(s=i.x1+6,c="start"),a=i.y0+r/2),v.push({x:s,y:a,text:n+"",anchor:"down"===u?"middle":c,baseline:"middle",fontSize:11})}}var A;return{sceneNodes:m,sceneEdges:x,labels:v}}},ee={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,o){var r,n;if(0===t.length)return;const s=null!==(r=i.forceStrength)&&void 0!==r?r:.1,c=o[0]/2,l=o[1]/2,u=i.__previousPositions;let h=0;const d=[];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++):d.push(e)}const f=h>0&&.3>=(t.length>0?d.length/t.length:1);if(f){const i=new Map;for(const e of t)i.set(e.id,e);for(const t of d){const o=ie(t.id,e,i);if(o.length>0){let e=0,i=0;for(const t of o)e+=t.x,i+=t.y;const r=oe(t.id),n=r%360*(Math.PI/180),s=10+r%20;t.x=e/o.length+s*Math.cos(n),t.y=i/o.length+s*Math.sin(n)}else{const e=oe(t.id),i=e%360*(Math.PI/180),o=15+e%30;t.x=c+o*Math.cos(i),t.y=l+o*Math.sin(i)}}}else{const e=2.399963229728653;for(let i=0;t.length>i;i++){const o=t[i];if(null==o.x||null==o.y||0===o.x&&0===o.y){const t=10*Math.sqrt(i+.5),r=i*e;o.x=c+t*Math.cos(r),o.y=l+t*Math.sin(r)}}}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:f?40:g,p=re(i.nodeSize,i.nodeSizeRange,t),m=t=>p(t);if(y>0){const i=a.forceLink().strength(t=>{const e=t.weight;return Math.min(2.5,e?e*s:s)}).id(t=>t.id),o=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(o.nodes(t),e.length>0){const t=e.map(t=>Object.assign(Object.assign({},t),{source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));o.force("link",i),o.force("link").links(t)}f?o.alpha(.3):.1>o.alpha()&&o.alpha(1),o.stop();for(let t=0;y>t;++t)o.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(o[0]-t,e.x)),e.y=Math.max(t,Math.min(o[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const 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 r,n,s,a,c,l,u;const h=i.nodeStyle,d=i.edgeStyle,f=re(i.nodeSize,i.nodeSizeRange,t),g=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:T,y=new Map;t.forEach((t,e)=>{y.set(t.id,g[e%g.length])});const p=[],m=[],x=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=f(Zt(e,"nodeSize")),o=h?h(Zt(e,"nodeStyle")):{},a={fill:o.fill||y.get(e.id)||(null===(r=i.themeSemantic)||void 0===r?void 0:r.primary)||"#007bff",stroke:o.stroke||(null===(n=i.themeSemantic)||void 0===n?void 0:n.surface)||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:2,opacity:o.opacity};p.push({type:"circle",cx:e.x,cy:e.y,r:t,style:a,datum:e,id:e.id,label:e.id})}const v=new Map;for(const e of t)v.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:v.get(t.source),o="object"==typeof t.target?t.target:v.get(t.target);if(!e||!o)continue;if(null==e.x||null==e.y)continue;if(null==o.x||null==o.y)continue;const r=d?d(Zt(t,"edgeStyle")):{},n={stroke:r.stroke||(null===(a=i.themeSemantic)||void 0===a?void 0:a.border)||(null===(c=i.themeSemantic)||void 0===c?void 0:c.secondary)||"#999",strokeWidth:null!==(l=r.strokeWidth)&&void 0!==l?l:1,opacity:null!==(u=r.opacity)&&void 0!==u?u:.6};m.push({type:"line",x1:e.x,y1:e.y,x2:o.x,y2:o.y,style:n,datum:t})}if(!1!==i.showLabels){const e=(b=i.nodeLabel)?"function"==typeof b?b:t=>t[b]||t.id:null;for(const i of t){if(null==i.x||null==i.y)continue;const t=e?e(i):i.id;if(!t)continue;const o=f(Zt(i,"nodeSize"));x.push({x:i.x,y:i.y-o-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var b;return{sceneNodes:p,sceneEdges:m,labels:x}}};function ie(t,e,i){const o=[];for(const r of e){const e="string"==typeof r.source?r.source:r.source.id,n="string"==typeof r.target?r.target:r.target.id;let s=null;if(e===t?s=n:n===t&&(s=e),s){const t=i.get(s);!t||0===t.x&&0===t.y||o.push({x:t.x,y:t.y})}}return o}function oe(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 re(t,e,i){var r,s;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const a=e||[5,20],c=i.map(e=>{var i;return null===(i=e.data)||void 0===i?void 0:i[t]}).filter(t=>null!=t&&"number"==typeof t);if(0===c.length)return()=>a[0];const l=null!==(r=n.min(c))&&void 0!==r?r:0,u=null!==(s=n.max(c))&&void 0!==s?s:1;if(l===u)return()=>(a[0]+a[1])/2;const h=o.scaleLinear().domain([l,u]).range(a).clamp(!0);return e=>{var i;const o=null===(i=e.data)||void 0===i?void 0:i[t];return null==o||"number"!=typeof o?a[0]:h(o)}}const ne=T,se={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,i,o){if(0===t.length)return;const{padAngle:r=.01,groupWidth:n=20,sortGroups:s}=i,a=Math.min(o[0],o[1])/2,u=a-n,h=o[0]/2,d=o[1]/2,f=(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),o=y.get(e);if(void 0===i||void 0===o)continue;const r=f(t);m[i][o]=r}const x=c.chord().padAngle(r);s&&x.sortGroups(s);const v=x(m),b=v.groups,k=l.arc().innerRadius(u).outerRadius(a);for(const e of b){const i=t[e.index],o=k.centroid({innerRadius:u,outerRadius:a,startAngle:e.startAngle,endAngle:e.endAngle});i.x=o[0]+h,i.y=o[1]+d,i.__arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const A=new Map;for(const e of t)A.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,i=A.get("string"==typeof t.source?t.source:t.source.id),o=A.get(e);i&&(t.source=i),o&&(t.target=o)}const w=new Map;for(const t of e)w.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,o=t[e.target.index].id,r=w.get(`${i}\0${o}`)||w.get(`${o}\0${i}`);r&&(r.__chordData=e)}},buildScene(t,e,i,o){var r,n,s,a;const{groupWidth:l=20,edgeOpacity:u=.5}=i,h=Math.min(o[0],o[1])/2,d=h-l,f=o[0]/2,g=o[1]/2,y=i.nodeStyle,p=i.edgeStyle,m=i.edgeColorBy||"source",x=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:ne,v=new Map;t.forEach((t,e)=>{v.set(t.id,x[e%x.length])});const b=c.ribbon().radius(d),k=[],A=[],w=[];for(let e=0;t.length>e;e++){const i=t[e],o=i.__arcData;if(!o)continue;let n;n=y?y(Zt(i,"nodeStyle")).fill||v.get(i.id)||x[e%x.length]:v.get(i.id)||x[e%x.length];const s=y?y(Zt(i,"nodeStyle")):{},a={fill:n,stroke:s.stroke||"black",strokeWidth:null!==(r=s.strokeWidth)&&void 0!==r?r:1,opacity:s.opacity};k.push({type:"arc",cx:f,cy:g,innerR:d,outerR:h,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:a,datum:i,id:i.id,label:i.id})}for(const t of e){const e=t.__chordData;if(!e)continue;const o=b(e);if(!o)continue;const r=ae(o,f,g);let c=(null===(n=i.themeSemantic)||void 0===n?void 0:n.border)||(null===(s=i.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";if(p)c=p(Zt(t,"edgeStyle")).fill||c;else{const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;"target"===m&&i?c=v.get(i.id)||c:e&&(c=v.get(e.id)||c)}const l=p?p(Zt(t,"edgeStyle")):{},h={fill:c,fillOpacity:null!==(a=l.fillOpacity)&&void 0!==a?a:u,stroke:l.stroke||"none",strokeWidth:l.strokeWidth,opacity:l.opacity};A.push({type:"ribbon",pathD:r,style:h,datum:t})}if(!1!==i.showLabels){const e=(S=i.nodeLabel)?"function"==typeof S?S:t=>t[S]||t.id:null,o=h+12;for(const i of t){const t=i.__arcData;if(!t)continue;const r=e?e(i):i.id;if(!r)continue;const n=(t.startAngle+t.endAngle)/2,s=n-Math.PI/2;w.push({x:f+Math.cos(s)*o,y:g+Math.sin(s)*o,text:r+"",anchor:n>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var S;return{sceneNodes:k,sceneEdges:A,labels:w}}};function ae(t,e,i){const o=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return t;const r=[];let n=0;for(;o.length>n;){const t=o[n];if("M"===t||"L"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)r.push(Number(o[n])+e+""),n++,o.length>n&&!isNaN(Number(o[n]))&&(r.push(Number(o[n])+i+""),n++);else if("C"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)for(let t=0;3>t&&o.length>n&&!isNaN(Number(o[n]));t++)r.push(Number(o[n])+e+""),n++,o.length>n&&!isNaN(Number(o[n]))&&(r.push(Number(o[n])+i+""),n++);else if("Q"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)for(let t=0;2>t&&o.length>n&&!isNaN(Number(o[n]));t++)r.push(Number(o[n])+e+""),n++,o.length>n&&!isNaN(Number(o[n]))&&(r.push(Number(o[n])+i+""),n++);else if("A"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&(r.push(Number(o[n])+e+""),n++),o.length>n&&(r.push(Number(o[n])+i+""),n++);else"Z"===t||"z"===t?(r.push(t),n++):(r.push(o[n]),n++)}return r.join(" ")}const ce=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function le(t){const[e,i,o]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*i+.114*o>150?"#222":"#fff"}function ue(t,e,i){const o=e.nodeIDAccessor;return"function"==typeof o?o(t.data)+"":"string"==typeof o&&void 0!==t.data[o]?t.data[o]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+i}function he(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 de(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:ce}function fe(t){var e;return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)?t.themeSemantic.primary:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical[0]:"#4d430c"}function ge(t,e,i,o,r){if("horizontal"===r){const r=(t+i)/2;return`M ${t},${e} C ${r},${e} ${r},${o} ${i},${o}`}if("radial"===r){const r=(t+i)/2;return`M ${t},${e} Q ${r},${e} ${r},${(e+o)/2} T ${i},${o}`}{const r=(e+o)/2;return`M ${t},${e} C ${t},${r} ${i},${r} ${i},${o}`}}const ye={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,i,o){var r;const n=i.__hierarchyRoot;if(!n)return;const s=i.chartType,a=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(i.childrenAccessor),c=i.hierarchySum,l="function"==typeof c?c:"string"==typeof c?t=>Number(t[c])||0:t=>Number(t.value)||0,h=u.hierarchy(n,a);h.sum(l),h.sort((t,e)=>{var i,o;return(null!==(i=e.value)&&void 0!==i?i:0)-(null!==(o=t.value)&&void 0!==o?o:0)});const[d,f]=o;switch(s){case"tree":!function(t,e,i,o){const r=e.treeOrientation||"vertical",n=u.tree();n.size("horizontal"===r?[o,i]:"radial"===r?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),n(t)}(h,i,d,f);break;case"cluster":!function(t,e,i,o){const r=e.treeOrientation||"vertical",n=u.cluster();n.size("horizontal"===r?[o,i]:"radial"===r?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),n(t)}(h,i,d,f);break;case"treemap":!function(t,e,i,o){var r,n;const s=null!==(r=e.padding)&&void 0!==r?r:4,a=null!==(n=e.paddingTop)&&void 0!==n?n:0,c=u.treemap().size([i,o]).tile(u.treemapBinary).padding(s);a>0&&c.paddingTop(a),c(t)}(h,i,d,f);break;case"circlepack":!function(t,e,i,o){var r;const n=null!==(r=e.padding)&&void 0!==r?r:4;u.pack().size([i,o]).padding(n)(t)}(h,i,d,f);break;case"partition":!function(t,e,i,o){var r;u.partition().size([i,o]).padding(null!==(r=e.padding)&&void 0!==r?r:1)(t)}(h,i,d,f)}const g=h.descendants();t.length=0,e.length=0;const y=new Map;for(let e=0;g.length>e;e++){const o=g[e],n={id:ue(o,i,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(r=o.value)&&void 0!==r?r:0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===s||"cluster"===s?pe(n,o,i):"treemap"===s||"partition"===s?me(n,o):"circlepack"===s&&xe(n,o),n.__hierarchyNode=o,t.push(n),y.set(o,n)}if("tree"===s||"cluster"===s)for(const t of g)if(t.parent){const i=y.get(t.parent),o=y.get(t);i&&o&&e.push({source:i,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,i,o){const r=i.nodeStyle||(()=>({})),n=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return function(t,e,i,o,r,n){var s,a,c,l,u,h,d,f;const g=[],y=[],p=[],m=i.treeOrientation||"vertical",x="radial"===m,v=o[0]/2,b=o[1]/2,k="number"==typeof(A=i.nodeSize)?A:5;var A;for(const e of t){let t=e.x,o=e.y;x&&(t+=v,o+=b);const n=r(Zt(e,"nodeStyle"));let c=n.fill||fe(i);if(i.colorByDepth&&void 0!==e.depth){const t=de(i);c=t[e.depth%t.length]}const l={fill:c,stroke:n.stroke||(null===(s=i.themeSemantic)||void 0===s?void 0:s.surface)||"#fff",strokeWidth:null!==(a=n.strokeWidth)&&void 0!==a?a:1,opacity:n.opacity};g.push({type:"circle",cx:t,cy:o,r:k,style:l,datum:e,id:e.id,label:e.id,depth:e.depth})}const w=null!==(c=i.edgeOpacity)&&void 0!==c?c:.5;for(const t of e){const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let r=e.x,s=e.y,a=o.x,c=o.y;x&&(r+=v,s+=b,a+=v,c+=b);const f=ge(r,s,a,c,m),g=n(Zt(t,"edgeStyle")),p={fill:"none",stroke:g.stroke||(null===(l=i.themeSemantic)||void 0===l?void 0:l.border)||(null===(u=i.themeSemantic)||void 0===u?void 0:u.secondary)||"#999",strokeWidth:null!==(h=g.strokeWidth)&&void 0!==h?h:1.5,opacity:null!==(d=g.opacity)&&void 0!==d?d:w};y.push({type:"curved",pathD:f,style:p,datum:t})}if(!1!==i.showLabels){const e=he(i.nodeLabel);for(const i of t){const t=e?e(i):i.id;if(!t)continue;let o,r,n,s=i.x,a=i.y;if(x&&(s+=v,a+=b),x){const t=s-v,e=a-b,i=Math.sqrt(t*t+e*e);i>0?(o=s+t/i*10,r=a+e/i*10,n=0>t?"end":"start"):(o=s,r=a-12,n="middle")}else"horizontal"===m?((null===(f=i.data)||void 0===f?void 0:f.children)&&0!==i.data.children.length?(o=s-k-6,n="end"):(o=s+k+6,n="start"),r=a):(o=s,r=a+k+14,n="middle");p.push({x:o,y:r,text:t+"",anchor:n,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:y,labels:p}}(t,e,i,o,r,n);case"treemap":case"partition":return function(t,e,i,o){var r,n,s,a,c;const l=[],u=[];for(const i of t){const t=i.x1-i.x0,s=i.y1-i.y0;if(0>=t||0>=s)continue;const a=o(Zt(i,"nodeStyle"));let c=a.fill||fe(e);if(e.colorByDepth&&void 0!==i.depth){const t=de(e);c=t[i.depth%t.length]}const u={fill:c,stroke:a.stroke||(null===(r=e.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(n=a.strokeWidth)&&void 0!==n?n:1,opacity:a.opacity};l.push({type:"rect",x:i.x0,y:i.y0,w:t,h:s,style:u,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=he(e.nodeLabel),r=e.labelMode||"leaf",n="partition"===e.chartType;for(const l of t){const t=l.x1-l.x0,h=l.y1-l.y0;if(0>=t||0>=h)continue;const d=!((null===(s=l.data)||void 0===s?void 0:s.children)&&l.data.children.length>0);if(!n){if("leaf"===r&&!d)continue;if("parent"===r&&d)continue}const f=i?i(l):l.id;if(!f)continue;if((d?30:40)>t||(d?16:14)>h)continue;let g=o(Zt(l,"nodeStyle")).fill||fe(e);if(e.colorByDepth&&void 0!==l.depth){const t=de(e);g=t[l.depth%t.length]}const y="string"==typeof g?le(g):null!==(c=null===(a=e.themeSemantic)||void 0===a?void 0:a.text)&&void 0!==c?c:"#000";u.push(d?{x:l.x0+t/2,y:l.y0+h/2,text:f+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,h)/6)),fill:y}:{x:l.x0+4,y:l.y0+12,text:f+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}return{sceneNodes:l,sceneEdges:[],labels:u}}(t,i,0,r);case"circlepack":return function(t,e,i,o){var r,n,s,a,c,l,u,h,d,f;const g=[],y=[];for(const i of t){const t=null!==(r=i.__radius)&&void 0!==r?r:5;if(0>=t)continue;const c=o(Zt(i,"nodeStyle"));let l=c.fill||fe(e);if(e.colorByDepth&&void 0!==i.depth){const t=de(e);l=t[i.depth%t.length]}const u={fill:l,stroke:c.stroke||(null===(n=e.themeSemantic)||void 0===n?void 0:n.surface)||"#fff",strokeWidth:null!==(s=c.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=c.opacity)&&void 0!==a?a:.7};g.push({type:"circle",cx:i.x,cy:i.y,r:t,style:u,datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=he(e.nodeLabel);for(const r of t){const t=null!==(c=r.__radius)&&void 0!==c?c:5,n=i?i(r):r.id;if(!n)continue;if(15>t)continue;const s=!((null===(l=r.data)||void 0===l?void 0:l.children)&&r.data.children.length>0);let a=o(Zt(r,"nodeStyle")).fill||fe(e);if(e.colorByDepth&&void 0!==r.depth){const t=de(e);a=t[r.depth%t.length]}if(s){const i="string"==typeof a?le(a):null!==(h=null===(u=e.themeSemantic)||void 0===u?void 0:u.text)&&void 0!==h?h:"#000";y.push({x:r.x,y:r.y,text:n+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:i})}else y.push({x:r.x,y:r.y-t+14,text:n+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:(null===(d=e.themeSemantic)||void 0===d?void 0:d.text)||"#000",stroke:(null===(f=e.themeSemantic)||void 0===f?void 0:f.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:g,sceneEdges:[],labels:y}}(t,i,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function pe(t,e,i){const o=i.treeOrientation||"vertical";if("radial"===o){const i=e.x,o=e.y;t.x=o*Math.cos(i-Math.PI/2),t.y=o*Math.sin(i-Math.PI/2)}else"horizontal"===o?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function me(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 xe(t,e){var i;const o=null!==(i=e.r)&&void 0!==i?i:0;t.x=e.x,t.y=e.y,t.x0=e.x-o,t.x1=e.x+o,t.y0=e.y-o,t.y1=e.y+o,t.width=2*o,t.height=2*o,t.__radius=o}function ve(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}const be={sankey:te,force:ee,chord:se,tree:ye,cluster:ye,treemap:ye,circlepack:ye,partition:ye,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,i,o){const r=i.__hierarchyRoot;r&&function(t,e,i,o,r){var n,s;const a=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(i.childrenAccessor),c=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>{var i;return(null!==(i=t[e])&&void 0!==i?i:"")+""}}(i.nodeIDAccessor),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,d=null!==(s=i.orbitEccentricity)&&void 0!==s?s:1,f="number"==typeof h?()=>h:h,g="number"==typeof d?()=>d:d,y=ve(i);y.metaMap.clear(),o.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 x=e[0]/2,v=e[1]/2,b=Math.min(e[0],e[1])/2*.85,k=m(c(t));o.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,s,h,d,p){const x=a(e);if(!(null==x?void 0:x.length))return;const v=x.length;let b=0,k=0,A=0;for(;v>k;)k+=u[Math.min(A,u.length-1)],A++,b++;let w=0;for(let v=0;b>v;v++){const k=u[Math.min(v,u.length-1)],A=x.slice(w,w+k);if(!A.length)break;const S=(v+1)/b,_={id:i,depth:d,data:e,parentId:i},P=p?h/f(_)*S:h*S,j=l.pie().value(t=>{var e;return(null===(e=a(t))||void 0===e?void 0:e.length)?4:1}).sort(null),M=j(A),O=g(_);for(let e=0;A.length>e;e++){const a=(M[e].startAngle+M[e].endAngle)/2,l=A[e],u=m(c(l)),h=n+P*Math.sin(a),f=s+P*Math.cos(a)*O;o.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:d,data:l}),y.metaMap.set(u,{ring:P,angle:a,depth:d,parentId:i,eccentricity:O}),r.push({source:i,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:u}}),t(l,u,h,f,P,d+1,!0)}w+=k}}(t,k,x,v,b,1,!1)}(r,o,i,t,e)},buildScene(t,e,i,o){var r,n,s,a,c,l,u;const h=i.nodeStyle,d=i.nodeSize,f="number"==typeof d?()=>d:"function"==typeof d?d:()=>6,g=[],y=[],p=[];if(!1!==i.orbitShowRings){const e=ve(i),o=new Map;for(const e of t)o.set(e.id,e);const r=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=o.get(t.parentId);if(!e)continue;const i=`${t.parentId}:${t.ring}`;r.has(i)||r.set(i,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const n=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:i,ecc:o}]of r)for(let r=0;n>r;r++){const a=r/n*Math.PI*2,c=(r+1)/n*Math.PI*2;y.push({type:"line",x1:t+i*Math.sin(a),y1:e+i*Math.cos(a)*o,x2:t+i*Math.sin(c),y2:e+i*Math.cos(c)*o,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=f(Zt(e,"nodeSize")),o=h?h(Zt(e,"nodeStyle")):{},l={fill:o.fill||(null===(r=i.themeSemantic)||void 0===r?void 0:r.primary)||"#6366f1",stroke:o.stroke||(null===(n=i.themeSemantic)||void 0===n?void 0:n.surface)||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=o.opacity)&&void 0!==a?a:0===(null!==(c=e.depth)&&void 0!==c?c:0)?1:.85};g.push({type:"circle",cx:e.x,cy:e.y,r:t,style:l,datum:e,id:e.id,label:e.id,depth:e.depth})}const m=new Map;for(const e of t)m.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:m.get(t.source),i="object"==typeof t.target?t.target:m.get(t.target);e&&i&&(null!=e.x&&null!=i.x&&y.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(i.showLabels){const e=i.nodeLabel;for(const i of t){const t=f(Zt(i,"nodeSize"));if(4>=t)continue;const o="function"==typeof e?e(i):e&&null!==(u=null===(l=i.data)||void 0===l?void 0:l[e])&&void 0!==u?u:i.id;p.push({x:i.x,y:i.y+t+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:y,labels:p}},tick:(t,e,i,o,r)=>!1!==i.orbitAnimated&&(function(t,e){var i,o;const r=ve(e),n=null!==(i=e.orbitSpeed)&&void 0!==i?i:.25,s=null!==(o=e.orbitRevolution)&&void 0!==o?o:function(t){switch(t){case"decay":return t=>{var e;return Math.pow(.6,null!==(e=t.depth)&&void 0!==e?e:0)};case"alternate":return t=>{var e;const i=null!==(e=t.depth)&&void 0!==e?e:0;return(i%2==0?1:-1)/(i+1)};default:return t=>{var e;return 1/((null!==(e=t.depth)&&void 0!==e?e:0)+1)}}}(e.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-r.startTime)/1e3,c=n*(Math.PI/6),l=new Map;for(const e of t)l.set(e.id,e);for(const e of t){const t=r.metaMap.get(e.id);if(!t||!t.parentId)continue;const i=l.get(t.parentId);if(!i)continue;const o=t.angle+a*c*s({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=i.x+t.ring*Math.sin(o),e.y=i.y+t.ring*Math.cos(o)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,i),!0)}};function ke(t,e){const{columns:i,config:o,resolvePieceStyle:r}=t,n=[],s=Math.min(e.width,e.height)/2-4,a="donut"===o.chartType?o.innerRadius||60:0,c=-Math.PI/2+(o.startAngle||0)*Math.PI/180,l=null!=o.sweepAngle?o.sweepAngle*Math.PI/180:2*Math.PI;for(const t of Object.values(i)){const e=c+t.pctStart*l,i=c+(t.pctStart+t.pct)*l,u=r(t.pieceData[0],t.name);n.push(Object.assign(Object.assign({type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:e,endAngle:i},o.cornerRadius&&{cornerRadius:o.cornerRadius}),{style:u,datum:t.pieceData,category:t.name}))}return n}function Ae(t){var e,i,o;const r=t.length,s=t[0],a=t[r-1];return{n:r,min:s,q1:null!==(e=n.quantile(t,.25))&&void 0!==e?e:s,median:null!==(i=n.quantile(t,.5))&&void 0!==i?i:(s+a)/2,q3:null!==(o=n.quantile(t,.75))&&void 0!==o?o:a,max:a,mean:t.reduce((t,e)=>t+e,0)/r}}function we(t){return 0===t.length?()=>"#4e79a7":e=>{var i;let o=0;for(let t=0;e.length>t;t++)o=31*o+e.charCodeAt(t)|0;return null!==(i=t[Math.abs(o)%t.length])&&void 0!==i?i:"#4e79a7"}}const Se={bar:function(t,e){var i,o,r;const{scales:n,columns:s,config:a,getR:c,getStack:l,resolvePieceStyle:u}=t,{r:h,projection:d}=n,f=[],g="vertical"===d,y="horizontal"===d,p=a.normalize,m=[];if(l){const t=new Set;for(const e of Object.values(s))for(const i of e.pieceData){const e=l(i);t.has(e)||(t.add(e),m.push(e))}}else m.push("_default");for(const t of Object.values(s)){const e=new Map;for(const i of t.pieceData){const t=l?l(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t);o.total+=c(i),o.pieces.push(i)}let i=0;if(p)for(const t of e.values())i+=Math.abs(t.total);let o=0,r=0;for(const n of m){const s=e.get(n);if(!s)continue;let a=s.total;p&&i>0&&(a/=i);const c=u(s.pieces[0],l?n:t.name),d=Object.assign(Object.assign({},s.pieces[0]),{__aggregateValue:s.total,__pieceCount:s.pieces.length,category:t.name});if(g){const e=h(0>a?r:o+a),i=0>a?h(r+a)-h(r):h(o)-h(o+a);f.push(w(t.x,e,t.width,Math.abs(i),c,d,n)),0>a?r+=a:o+=a}else if(y){const e=h(0>a?r+a:o),i=0>a?h(r)-h(r+a):h(o+a)-h(o);f.push(w(e,t.x,Math.abs(i),t.width,c,d,n)),0>a?r+=a:o+=a}}}const x="vertical"===d,v=a.roundedTop&&a.roundedTop>0?Math.max(0,a.roundedTop):0;for(const t of f){if("rect"!==t.type)continue;const e=null!==(o=null===(i=t.datum)||void 0===i?void 0:i.__aggregateValue)&&void 0!==o?o:0;t.roundedEdge=x?0>e?"bottom":"top":0>e?"left":"right",a.gradientFill&&(t.fillGradient=a.gradientFill)}if(v>0){const t=new Map;for(const e of f){if("rect"!==e.type)continue;const i=(null===(r=e.datum)||void 0===r?void 0:r.category)||"";t.has(i)||t.set(i,[]),t.get(i).push(e)}for(const e of t.values()){if(0===e.length)continue;const t=e.filter(t=>{var e,i;return(null!==(i=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==i?i:0)>=0}),i=e.filter(t=>{var e,i;return 0>(null!==(i=null===(e=t.datum)||void 0===e?void 0:e.__aggregateValue)&&void 0!==i?i:0)});t.length>0&&(t.reduce(x?(t,e)=>e.y>t.y?t:e:(t,e)=>t.x+t.w>e.x+e.w?t:e).roundedTop=v),i.length>0&&(i.reduce(x?(t,e)=>t.y+t.h>e.y+e.h?t:e:(t,e)=>e.x>t.x?t:e).roundedTop=v)}}return f},clusterbar:function(t,e){const{scales:i,columns:o,config:r,getR:n,getGroup:s,resolvePieceStyle:a}=t,{r:c,projection:l}=i,u=[],h="vertical"===l,d=[],f=new Set;for(const t of Object.values(o))for(const e of t.pieceData){const t=s?s(e):"_default";f.has(t)||(f.add(t),d.push(t))}const g=d.length||1;for(const t of Object.values(o)){const e=t.width/g,i=.2*e,o=e-i,r=new Map;for(const e of t.pieceData){const t=s?s(e):"_default";r.has(t)||r.set(t,[]),r.get(t).push(e)}for(let s=0;d.length>s;s++){const l=r.get(d[s])||[];for(const r of l){const l=n(r),f=a(r,d[s]);if(h){const n=t.x+s*e+i/2,a=c(0),h=c(l);u.push(w(n,Math.min(a,h),o,Math.abs(a-h),f,r,d[s]))}else{const n=t.x+s*e+i/2,a=c(0),h=c(l);u.push(w(Math.min(a,h),n,Math.abs(h-a),o,f,r,d[s]))}}}}const y=r.roundedTop&&r.roundedTop>0?Math.max(0,r.roundedTop):0;for(const t of u){if("rect"!==t.type)continue;if(null==t.datum)continue;const e=n(t.datum);y>0&&(t.roundedTop=y),t.roundedEdge=h?0>e?"bottom":"top":0>e?"left":"right",r.gradientFill&&(t.fillGradient=r.gradientFill)}return u},point:function(t,e){var i,o;const{scales:r,columns:n,getR:s,multiScales:a,resolvePieceStyle:c}=t,{r:l,projection:u}=r,h=[],d="vertical"===u,f="radial"===u,g=a.length>0,y=2*Math.PI,p=-Math.PI/2;for(const t of Object.values(n))for(const e of t.pieceData){const r=null!==(i=e.__rIndex)&&void 0!==i?i:0,n=null!==(o=e.__rValue)&&void 0!==o?o:s(e),u=g&&a[r]||l,m=c(e,t.name),x=m.r||5;let v,b;if(f){const e=p+(t.pctStart+t.pct/2)*y,i=u(n);v=Math.cos(e)*i,b=Math.sin(e)*i}else d?(v=t.middle,b=u(n)):(v=u(n),b=t.middle);h.push({type:"point",x:v,y:b,r:x,style:m,datum:e})}return h},swarm:function(t,e){const{scales:i,columns:o,getR:r,resolvePieceStyle:n}=t,{r:s,projection:a}=i,c=[],l="vertical"===a;for(const t of Object.values(o)){const e=t.width/2;for(let i=0;t.pieceData.length>i;i++){const o=t.pieceData[i],a=r(o),u=n(o,t.name),h=u.r||4,d=(7919*i%100/100-.5)*e*.8,f=l?t.middle+d:s(a),g=l?s(a):t.middle+d;c.push({type:"point",x:f,y:g,r:h,style:u,datum:o})}}return c},pie:ke,donut:ke,boxplot:function(t,e){var i,o,r,s,a,c;const{scales:l,columns:u,config:h,getR:d,resolveSummaryStyle:f}=t,{r:g,projection:y}=l,p=[],m="vertical"===y,x=!1!==h.showOutliers;for(const e of Object.values(u)){const l=e.pieceData.map(t=>d(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===l.length)continue;const u=l[0],h=l[l.length-1],y=null!==(i=n.quantile(l,.25))&&void 0!==i?i:u,v=null!==(o=n.quantile(l,.5))&&void 0!==o?o:(u+h)/2,b=null!==(r=n.quantile(l,.75))&&void 0!==r?r:h,k=b-y,A=y-1.5*k,w=b+1.5*k,S=null!==(s=l.find(t=>t>=A))&&void 0!==s?s:u,_=null!==(a=[...l].reverse().find(t=>w>=t))&&void 0!==a?a:h,P=f(e.pieceData[0],e.name),j=[];if(x)for(const t of e.pieceData){const i=d(t);if(A>i||i>w){const o=m?e.middle:g(i),r=m?g(i):e.middle;j.push({px:o,py:r,value:i,datum:t})}}if(p.push({type:"boxplot",x:m?e.middle:0,y:m?0:e.middle,projection:m?"vertical":"horizontal",columnWidth:.6*e.width,minPos:g(S),q1Pos:g(y),medianPos:g(v),q3Pos:g(b),maxPos:g(_),stats:{n:l.length,min:S,q1:y,median:v,q3:b,max:_,mean:l.reduce((t,e)=>t+e,0)/l.length},style:P,datum:e.pieceData,category:e.name,outliers:j}),x)for(const e of j)p.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:P.fill||(null===(c=t.config.themeSemantic)||void 0===c?void 0:c.secondary)||"#999",opacity:.6},datum:e.datum})}return p},violin:function(t,e){var i,o,r;const{scales:s,columns:a,config:c,getR:l,resolveSummaryStyle:u}=t,{r:h,projection:d}=s,f=[],g="vertical"===d,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,d=Array(y).fill(0);for(const t of e)d[Math.min(Math.floor((t-s)/c),y-1)]++;const m=Math.max(...d,1),x=t.width/2*.9;let v="";if(g){v=`M ${t.middle} ${h(s)}`;for(let e=0;y>e;e++){const i=h(s+(e+.5)*c);v+=` L ${t.middle+d[e]/m*x} ${i}`}v+=` L ${t.middle} ${h(a)}`;for(let e=y-1;e>=0;e--){const i=h(s+(e+.5)*c);v+=` L ${t.middle-d[e]/m*x} ${i}`}v+=" Z"}else{v=`M ${h(s)} ${t.middle}`;for(let e=0;y>e;e++)v+=` L ${h(s+(e+.5)*c)} ${t.middle-d[e]/m*x}`;v+=` L ${h(a)} ${t.middle}`;for(let e=y-1;e>=0;e--)v+=` L ${h(s+(e+.5)*c)} ${t.middle+d[e]/m*x}`;v+=" Z"}const b=u(t.pieceData[0],t.name);let k;if(p&&e.length>=4){const c=null!==(i=n.quantile(e,.25))&&void 0!==i?i:s,l=null!==(o=n.quantile(e,.5))&&void 0!==o?o:(s+a)/2,u=null!==(r=n.quantile(e,.75))&&void 0!==r?r:a;k={q1Pos:h(c),medianPos:h(l),q3Pos:h(u),centerPos:t.middle,isVertical:g}}const A=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};f.push({type:"violin",pathString:v,translateX:0,translateY:0,bounds:A,iqrLine:k,stats:Ae(e),style:b,datum:t.pieceData,category:t.name})}return f},histogram:function(t,e){var i;const{scales:o,columns:r,config:n,getR:s,resolveSummaryStyle:a}=t,{r:c}=o,l=[],u=n.bins||25,h=n.normalize,d=null===(i=c.domain)||void 0===i?void 0:i.call(c),f=d?+d[0]:void 0,g=d?+d[1]:void 0;for(const t of Object.values(r)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const i=null!=f&&isFinite(f)?f:Math.min(...e),o=null!=g&&isFinite(g)?g:Math.max(...e),r=(o-i)/u||1,n=Array(u).fill(0);for(const t of e)i>t||t>o||n[Math.min(Math.floor((t-i)/r),u-1)]++;const d=e.length,y=Math.max(...n,1),p=a(t.pieceData[0],t.name);for(let e=0;u>e;e++){if(0===n[e])continue;const o=(h?n[e]/d:n[e]/y)*t.width*.9,s=c(i+e*r),a=c(i+(e+1)*r);l.push(w(Math.min(s,a),t.x+t.width-o,Math.abs(a-s),o,p,{bin:e,count:n[e],range:[i+e*r,i+(e+1)*r],category:t.name},t.name))}}return l},ridgeline:function(t,e){var i;const{scales:o,columns:r,config:n,getR:s,resolveSummaryStyle:a}=t,{r:c,projection:l}=o,u=[],h=n.bins||20,d="horizontal"===l,f=n.amplitude||1.5;for(const t of Object.values(r)){const e=t.pieceData.map(t=>s(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const o=e[0],r=e[e.length-1],n=(r-o)/h||1,l=Array(h).fill(0);for(const t of e)o>t||t>r||l[Math.min(Math.floor((t-o)/n),h-1)]++;const g=Math.max(...l,1),y=a(t.pieceData[0],t.name),p=t.width*f;let m="";if(d){const e=t.x+t.width;m=`M ${c(o)} ${e}`;for(let t=0;h>t;t++)m+=` L ${c(o+(t+.5)*n)} ${e-l[t]/g*p}`;m+=` L ${c(r)} ${e} Z`}else{const e=t.x;m=`M ${e} ${c(o)}`;for(let t=0;h>t;t++){const i=c(o+(t+.5)*n);m+=` L ${e+l[t]/g*p} ${i}`}m+=` L ${e} ${c(r)} Z`}const x=d?{x:Math.min(c(o),c(r)),y:t.x,width:Math.abs(c(r)-c(o)),height:t.width}:{x:t.x,y:Math.min(c(r),c(o)),width:t.width,height:Math.abs(c(r)-c(o))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:x,stats:Ae(e),style:Object.assign(Object.assign({},y),{fillOpacity:null!==(i=y.fillOpacity)&&void 0!==i?i:.5}),datum:t.pieceData,category:t.name})}return u},timeline:function(t,e){const{scales:i,columns:o,getRawRange:r,resolvePieceStyle:n}=t,{r:s,projection:a}=i,c=[],l="horizontal"===a;for(const t of Object.values(o))for(const e of t.pieceData){const i=r(e);if(!i)continue;const[o,a]=i,u=n(e,t.name);if(l){const i=s(Math.min(o,a)),r=s(Math.max(o,a));c.push(w(i,t.x,r-i,t.width,u,e,t.name))}else{const i=s(Math.max(o,a)),r=s(Math.min(o,a));c.push(w(t.x,i,t.width,r-i,u,e,t.name))}}return c},funnel:function(t,e){var i,r,n,s,a,c,l,u;const{columns:h,getR:d,getStack:f,resolvePieceStyle:g}=t,y=[],p=e.width/2,m=!1!==t.config.showLabels,x=t.scales.o.domain().map(t=>h[t]).filter(Boolean);if(0===x.length)return y;const v=[],b=new Set;for(const t of x)for(const e of t.pieceData){const t=f?f(e):"_default";b.has(t)||(b.add(t),v.push(t))}const k=v.length>1&&"_default"!==v[0],A=[];let S=0;for(const t of x){const e=new Map;let i=0;for(const o of t.pieceData){const t=f?f(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t),n=d(o);r.total+=n,r.pieces.push(o),i+=n}A.push({col:t,groups:e,stepTotal:i}),k||i>S&&(S=i)}if(k)for(const t of A){let e=0,i=0;for(let o=0;v.length>o;o++){const r=t.groups.get(v[o]);r&&(o%2==0?e+=r.total:i+=r.total)}const o=Math.max(e,i);o>S&&(S=o)}if(0===S)return y;const _=new Map;for(const t of v){const e=A[0].groups.get(t);_.set(t,null!==(i=null==e?void 0:e.total)&&void 0!==i?i:0)}const P=A[0].stepTotal,j=k?.95*p:.9*e.width,M=o.scaleLinear().domain([0,S]).range([0,j]),O=null!==(r=t.config.connectorOpacity)&&void 0!==r?r:.3;let L=new Map;for(let e=0;A.length>e;e++){const i=A[e],o=i.col,r=0===e,h=o.width,d=.55*h,f=o.x+(h-d)/2,x=new Map;if(k){let t=0;for(const e of v){const o=i.groups.get(e);o&&(t+=M(o.total))}let e=p,n=p;for(let s=0;v.length>s;s++){const c=v[s],l=i.groups.get(c);if(!l)continue;const u=M(l.total),h=s%2==0,b=h?e:n-u;h?e+=u:n-=u;const k=g(l.pieces[0],c),A=null!==(a=_.get(c))&&void 0!==a?a:l.total,S=A>0?l.total/A*100:0,P=Object.assign(Object.assign({},l.pieces[0]),{__funnelValue:l.total,__funnelPercent:S,__funnelStep:o.name,__funnelIsFirstStep:r,__aggregateValue:l.total,__pieceCount:l.pieces.length,category:c});m&&(0===s&&(P.__funnelStepLabel=o.name,P.__funnelStepLabelX=p,P.__funnelStepLabelY=f,P.__funnelRowWidth=t),P.__funnelValueLabelX=b+u/2,P.__funnelValueLabelY=f,P.__funnelBarW=u),y.push(w(b,f,u,d,k,P,c)),x.set(c,{x:b,y:f,w:u,h:d})}}else{const t=i.stepTotal,e=M(t),a=p-e/2,c=v[0],l="_default"!==c,u=null!==(s=null===(n=i.groups.get(c))||void 0===n?void 0:n.pieces[0])&&void 0!==s?s:o.pieceData[0],h=l?c:o.name,b=g(u,h),k=P>0?t/P*100:0,A=Object.assign(Object.assign({},u),{__funnelValue:t,__funnelPercent:k,__funnelStep:o.name,__funnelIsFirstStep:r,category:l?c:o.name});m&&(A.__funnelStepLabel=o.name,A.__funnelStepLabelX=p,A.__funnelStepLabelY=f,A.__funnelRowWidth=e,A.__funnelValueLabelX=p,A.__funnelValueLabelY=f,A.__funnelBarW=e),y.push(w(a,f,e,d,b,A,h)),x.set(c,{x:a,y:f,w:e,h:d})}if(e>0&&L.size>0){const e=k?v:[v[0]];for(const r of e){const e=L.get(r),n=x.get(r);if(!e||!n)continue;const s=(()=>{const t=i.groups.get(r);return g(t?t.pieces[0]:o.pieceData[0],"_default"===r?o.name:r)})(),a={type:"trapezoid",points:[[e.x,e.y+e.h],[e.x+e.w,e.y+e.h],[n.x+n.w,n.y],[n.x,n.y]],style:{fill:s.fill||(null===(c=t.config.themeSemantic)||void 0===c?void 0:c.secondary)||"#999",opacity:O},datum:null!==(u=null===(l=i.groups.get(r))||void 0===l?void 0:l.pieces[0])&&void 0!==u?u:o.pieceData[0],category:"_default"===r?o.name:r};y.push(a)}}L=x}return y},"bar-funnel":function(t,e){var i,o,r,n;const{columns:s,getR:a,getStack:c,resolvePieceStyle:l,scales:u}=t,h=[],d=u.o.domain().map(t=>s[t]).filter(Boolean);if(0===d.length)return h;const f=[],g=new Set;for(const t of d)for(const e of t.pieceData){const t=c?c(e):"_default";g.has(t)||(g.add(t),f.push(t))}const y=f.length>1&&"_default"!==f[0],p=[];for(const t of d){const e=new Map;let i=0;for(const o of t.pieceData){const t=c?c(o):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const r=e.get(t),n=a(o);r.total+=n,r.pieces.push(o),i+=n}p.push({col:t,groups:e,stepTotal:i})}const m=new Map;for(const t of f){const e=null===(i=p[0])||void 0===i?void 0:i.groups.get(t);m.set(t,null!==(o=null==e?void 0:e.total)&&void 0!==o?o:0)}const x=u.r,v=y?f.length:1,b=y?.15:0;for(let t=0;p.length>t;t++){const e=p[t],i=e.col,o=0===t,s=t>0?p[t-1]:null,a=i.width/v,c=a*b,u=a-c;for(let t=0;f.length>t;t++){const d=f[t],g=e.groups.get(d);if(!g)continue;const p=g.total,v=null!==(r=m.get(d))&&void 0!==r?r:p,b=v>0?p/v*100:0,k=null==s?void 0:s.groups.get(d),A=null!==(n=null==k?void 0:k.total)&&void 0!==n?n:p,S=o?0:Math.max(0,A-p),_=i.x+t*a+c/2,P=x(p),j=x(0)-P,M=l(g.pieces[0],y?d:i.name),O=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:p,__barFunnelPercent:b,__barFunnelIsFirstStep:o,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:S,__barFunnelCategory:"_default"===d?void 0:d,category:y?d:i.name,__barFunnelLabelX:_+u/2,__barFunnelLabelY:x(p+S)});if(h.push(w(_,P,u,j,M,O,y?d:i.name)),S>0){const t=x(p+S),e=P-t,o=Object.assign({},M),r=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:S,__barFunnelPercent:v>0?S/v*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===d?void 0:d,category:y?d:i.name});h.push(w(_,t,u,e,o,r,y?d:i.name))}}}return h},swimlane:function(t,e){var i;const{scales:o,columns:r,getR:n,getStack:s,resolvePieceStyle:a}=t,{r:c,projection:l}=o,u=[],h="horizontal"===l,d=t.config.gradientFill,f=h?"left":"bottom",g=t.config.trackFill;if(g){const t="string"==typeof g?g:g.color,e="string"==typeof g?1:null!==(i=g.opacity)&&void 0!==i?i:1,[o,n]=c.range(),s=Math.min(o,n),a=Math.abs(n-o);for(const i of Object.values(r)){const o={fill:t,opacity:e},r=h?w(s,i.x,a,i.width,o,null,"__track__"):w(i.x,s,i.width,a,o,null,"__track__");u.push(r)}}for(const t of Object.values(r)){let e=0;for(const i of t.pieceData){const o=Math.abs(n(i));if(0===o)continue;const r=s?s(i):t.name,l=a(i,r);let g;if(h){const n=c(e),s=c(e+o);g=w(n,t.x,s-n,t.width,l,i,r)}else{const n=c(e+o),s=c(e);g=w(t.x,n,t.width,s-n,l,i,r)}d&&(g.fillGradient=d,g.roundedEdge=f),u.push(g),e+=o}}return u}};class _e{constructor(t){this.rExtent=new m,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.customLayoutOverlays=null,this.version=0,this._dataVersion=0,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=t,this.buffer=new p(t.windowSize),this.getO=M(t.categoryAccessor||t.oAccessor,"category");const e=t.valueAccessor||t.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(t=>P(t,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new m)):(this.getR=P(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=M(t.stackBy),this.getGroup=M(t.groupBy),this.getColor=M(t.colorAccessor),this.getConnector=M(t.connectorAccessor),this.getDataId=M(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new p(t.windowSize))}ingest(t){const e="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=e,this._dataVersion++,t.bounded){this.buffer.clear(),this.rExtent.clear();for(const t of this.rExtents)t.clear();t.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=t.totalSize||t.inserts.length;i>this.buffer.capacity&&(this.buffer.resize(i),this.timestampBuffer&&i>this.timestampBuffer.capacity&&this.timestampBuffer.resize(i));for(const i of t.inserts)this.buffer.push(i),this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else{this._hasStreamingData=!0;for(const i of t.inserts){const t=this.buffer.push(i);this.timestampBuffer&&this.timestampBuffer.push(e),this.categories.add(this.getO(i)),this.pushValueExtent(i),null!=t&&this.evictValueExtent(t)}}return!0}pushValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.push(e[0]),this.rExtent.push(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].push(this.rAccessors[e](t));this.rExtent.push(this.getR(t))}else this.rExtent.push(this.getR(t))}evictValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.evict(e[0]),this.rExtent.evict(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].evict(this.rAccessors[e](t));this.rExtent.evict(this.getR(t))}else this.rExtent.evict(this.getR(t))}getRawRange(t){const e=this.config.valueAccessor||this.config.rAccessor;if(!e)return null;const i="function"==typeof e?e(t):t[e];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(t){const{config:e,buffer:i}=this;if(0===i.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(i,this.getR);const r=i.toArray(),n=e.projection||"vertical",s=e.oExtent||this.resolveCategories(r),a=this.computeValueDomain(r,s),c="horizontal"===n,l="radial"===n,u=Math.min(.9,Math.max(0,null!=e.barPadding?e.barPadding/("vertical"===n?t.width:t.height):.1));let h,d;if(l){h=o.scaleBand().domain(s).range([0,1]).padding(0);const i=Math.min(t.width,t.height)/2,r=e.innerRadius||0;d=o.scaleLinear().domain(a).range([r,i])}else c?(h=o.scaleBand().domain(s).range([0,t.height]).padding(u),d=o.scaleLinear().domain(a).range([0,t.width])):(h=o.scaleBand().domain(s).range([0,t.width]).padding(u),d=o.scaleLinear().domain(a).range([t.height,0]));this.scales={o:h,r:d,projection:n},this.multiScales=this.rAccessors.length>1&&e.multiAxis?this.rAccessors.map((r,n)=>{var s;const a=this.rExtents[n];a.dirty&&a.recalculate(i,r);let[l,u]=a.extent;l===1/0&&(l=0,u=1);const h=null!==(s=e.extentPadding)&&void 0!==s?s:.05,d=u-l,f=d>0?d*h:1;return l-=f,u+=f,l>0&&(l=0),c?o.scaleLinear().domain([l,u]).range([0,t.width]):o.scaleLinear().domain([l,u]).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,h,n,t),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(f,t),this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,r),this.config.pulse&&this.applyPulse(this.scene,r),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(t){const e=this.config.valueAccessor||this.config.rAccessor,i=Array.isArray(e)?e[t]:e;return"string"==typeof i?i:"value"+t}resolveCategories(t){const e=this.config.oSort,i="streaming"===this.config.runtimeMode||this._hasStreamingData,o="auto"===e?void 0:e;let r=null;if(i){r=new Set;for(const e of t)r.add(this.getO(e))}const n=r?Array.from(this.categories).filter(t=>r.has(t)):Array.from(this.categories);if(i&&void 0===o){const t=Math.max(50,3*r.size);if(this.categories.size>t){let e=this.categories.size-t;for(const t of this.categories){if(0>=e)break;r.has(t)||(this.categories.delete(t),e--)}}return n}if(!1===o)return n;if("function"==typeof o)return n.sort(o);const s=new Map;for(const e of t){const t=this.getO(e);s.set(t,(s.get(t)||0)+Math.abs(this.getR(e)))}return n.sort("asc"===o?(t,e)=>(s.get(t)||0)-(s.get(e)||0):(t,e)=>(s.get(e)||0)-(s.get(t)||0))}computeValueDomain(t,e){var i,o,r,n,s;const a=this.config.chartType,c=null!==(i=this.config.extentPadding)&&void 0!==i?i:.05;if("radial"===this.config.projection&&("pie"===a||"donut"===a))return[0,1];let l=0,u=0;if("bar"===a&&this.getStack&&this.config.normalize)l=0,u=1;else if("bar"===a&&this.getStack){const e=new Map,i=new Map;for(const o of t){const t=this.getO(o),r=this.getR(o);0>r?i.set(t,(i.get(t)||0)+r):e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>u&&(u=t);for(const t of i.values())l>t&&(l=t)}else if("bar"===a){const e=new Map;for(const i of t){const t=this.getO(i),o=this.getR(i);e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>u&&(u=t),l>t&&(l=t)}else if("swimlane"===a){const e=new Map;for(const i of t){const t=this.getO(i),o=Math.abs(this.getR(i));e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>u&&(u=t)}else if("clusterbar"===a||"bar-funnel"===a)for(const e of t){const t=this.getR(e);t>u&&(u=t),l>t&&(l=t)}else{const t=this.rExtent.extent[0],e=this.rExtent.extent[1];t!==1/0&&(l=t),e!==-1/0&&(u=e)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(l=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(u=this.config.rExtent[1]));const h="bar"===a||"clusterbar"===a||"bar-funnel"===a||"swimlane"===a;if(h&&null==(null===(o=this.config.rExtent)||void 0===o?void 0:o[0])&&null==(null===(r=this.config.rExtent)||void 0===r?void 0:r[1])&&(l>0&&(l=0),0>u&&(u=0)),"bar-funnel"!==a){const t=u-l,e=t>0?t*c:1;null!=(null===(n=this.config.rExtent)||void 0===n?void 0:n[0])||h&&!this.config.baselinePadding&&0===l||(l-=e),null!=(null===(s=this.config.rExtent)||void 0===s?void 0:s[1])||h&&!this.config.baselinePadding&&0===u||"swimlane"===a||(u+=e)}return[l,u]}buildColumns(t,e,i,o,r){var n;const s={},a=new Map;for(const e of t){const t=this.getO(e);a.has(t)||a.set(t,[]),a.get(t).push(e)}let c=0;if("radial"===o)for(const e of t)c+=Math.abs(this.getR(e));const l=this.config.dynamicColumnWidth;let u=null;if(l&&"radial"!==o){u=new Map;let t=0;for(const i of e){const e=a.get(i)||[];let o;o="string"==typeof l?e.reduce((t,e)=>t+(Number(e[l])||0),0):l(e),u.set(i,o),t+=o}const n=("horizontal"===o?r.height:r.width)-i.padding()*i.step()*e.length;if(t>0)for(const[e,i]of u)u.set(e,i/t*n)}let h=0,d=0;for(const t of e){const e=a.get(t)||[],o=e.reduce((t,e)=>t+Math.abs(this.getR(e)),0),r=c>0?o/c:0;let l,f;u?(l=d,f=u.get(t)||i.bandwidth(),d+=f+i.padding()*i.step()):(l=null!==(n=i(t))&&void 0!==n?n:0,f=i.bandwidth()),s[t]={name:t,x:l,y:0,width:f,middle:l+f/2,padding:i.padding()*i.step(),pieceData:e,pct:r,pctStart: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){var i,o;if(!this.scales)return[];if(this.config.customLayout){const r=this.buildLayoutContext(t,e);let n;try{n=this.config.customLayout(r)}catch(t){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",t),this.customLayoutOverlays=null,[]}return this.customLayoutOverlays=null!==(i=n.overlays)&&void 0!==i?i:null,null!==(o=n.nodes)&&void 0!==o?o:[]}this.customLayoutOverlays=null;const r=this.getSceneContext(),n=Se[this.config.chartType];let s=n?n(r,e):[];if(this.getConnector&&this.scales){const t=function(t,e){var i,o;const{scales:r,config:n,getConnector:s,getO:a}=t;if(!s||!r)return[];const c=[],{projection:l}=r,u=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const i=s(e);if(!i)continue;let o,r;"point"===t.type?(o=t.x,r=t.y):(o=t.x+t.w/2,r=t.y+("vertical"===l?0:t.h/2)),u.has(i)||u.set(i,[]),u.get(i).push({x:o,y:r,datum:e,category:a(e)})}const h=r.o.domain(),d=n.connectorStyle;for(const[e,r]of u)if(r.length>=2){r.sort((t,e)=>h.indexOf(t.category)-h.indexOf(e.category));for(let n=0;r.length-1>n;n++){const s=r[n],a=r[n+1],l="function"==typeof d?d(s.datum):d||{stroke:(null===(i=t.config.themeSemantic)||void 0===i?void 0:i.border)||(null===(o=t.config.themeSemantic)||void 0===o?void 0:o.secondary)||"#999",strokeWidth:1,opacity:.5};c.push({type:"connector",x1:s.x,y1:s.y,x2:a.x,y2:a.y,style:l,datum:s.datum,group:e})}}return c}(r,s);s=[...t,...s]}return s}buildLayoutContext(t,e){var i,o,r;const n=this.config,s=null!==(i=n.layoutMargin)&&void 0!==i?i:{top:0,right:0,bottom:0,left:0},a=function(t,e,i){if(Array.isArray(t)&&t.length>0)return t;if("string"==typeof t){const e=q[t];if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:i}(n.colorScheme,n.themeCategorical,V),c=this.scales;return{data:t,scales:{o:c.o,r:c.r,projection:c.projection},dimensions:{width:e.width,height:e.height,margin:s,plot:"radial"===c.projection?{x:-e.width/2,y:-e.height/2,width:e.width,height:e.height}:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:null!==(o=n.themeSemantic)&&void 0!==o?o:{},categorical:[...a]},resolveColor:we(a),config:null!==(r=n.layoutConfig)&&void 0!==r?r:{}}}resolvePieceStyle(t,e){if("function"==typeof this.config.pieceStyle){const i=this.config.pieceStyle(t,e);return i&&!i.fill&&e?Object.assign(Object.assign({},i),{fill:this.getColorFromScheme(e)}):i}return this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&e?{fill:this.config.barColors[e]||"#007bff"}:e?{fill:this.getColorFromScheme(e)}:{fill:"#007bff"}}getColorFromScheme(t){this._colorSchemeMap||(this._colorSchemeMap=new Map);const e=this._colorSchemeMap.get(t);if(e)return e;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||V,o=i[this._colorSchemeIndex%i.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(t,o),o}resolveSummaryStyle(t,e){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(t,e):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?U(i,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const e=new Map;for(let i=0;t.length>i;i++)e.set(t[i],i);return this._datumIndexCache={version:this._dataVersion,map:e},e}getCategoryIndexMap(t){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const e=this.config.categoryAccessor||this.config.oAccessor,i="function"==typeof e,o=i?null:e||"category",r=new Map;for(let n=0;t.length>n;n++){const s=t[n],a=i?e(s):s[o];let c=r.get(a);c||(c=[],r.set(a,c)),c.push(n)}return this._categoryIndexCache={version:this._dataVersion,map:r},r}rebuildPointQuadtree(){let t=0,e=0;for(const i of this.scene)"point"===i.type&&(t++,i.r>e&&(e=i.r));if(this._maxPointRadius=e,_e.QUADTREE_THRESHOLD>=t)return void(this._pointQuadtree=null);const i=Array(t);let o=0;for(const t of this.scene)"point"===t.type&&(i[o++]=t);this._pointQuadtree=r.quadtree().x(t=>t.x).y(t=>t.y).addAll(i)}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(t,e){var i,o;if(!this.config.decay)return;const r=e.length;if(1>=r)return;const n=this.getDatumIndexMap(e);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;const t=n.get(e.datum);if(null==t)continue;const s=this.computeDecayOpacity(t,r),a=null!==(o=null===(i=e.style)||void 0===i?void 0:i.opacity)&&void 0!==o?o:1;e.style=Object.assign(Object.assign({},e.style),{opacity:a*s})}}applyPulse(t,e){var i,o,r;if(!this.config.pulse||!this.timestampBuffer)return;const n="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(i=this.config.pulse.duration)&&void 0!==i?i:500,a=null!==(o=this.config.pulse.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",c=null!==(r=this.config.pulse.glowRadius)&&void 0!==r?r:4,l=this.getDatumIndexMap(e);let u=null;for(const i of t){if("connector"===i.type||"violin"===i.type||"boxplot"===i.type)continue;if("wedge"===i.type){const t=i.category;if(!t)continue;u||(u=this.getCategoryIndexMap(e));const o=u.get(t);if(!o)continue;let r=0;for(let t=0;o.length>t;t++){const e=this.timestampBuffer.get(o[t]);if(null==e)continue;const i=n-e;if(s>i){const t=1-i/s;t>r&&(r=t)}}r>0&&(i._pulseIntensity=r,i._pulseColor=a);continue}const t=l.get(i.datum);if(null==t)continue;const o=this.timestampBuffer.get(t);if(null==o)continue;const r=n-o;s>r&&(i._pulseIntensity=1-r/s,i._pulseColor=a,i._pulseGlowRadius=c)}}get hasActivePulses(){var t;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const e="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(t=this.config.pulse.duration)&&void 0!==t?t:500,o=this.timestampBuffer.peek();return null!=o&&i>e-o}synthesizeIntroPositions(){var t,e,i,o,r;this.prevPositionMap.clear();const n=new Map,s=null!==(e=null===(t=this.scales)||void 0===t?void 0:t.r(0))&&void 0!==e?e:0,a="horizontal"!==(null===(i=this.scales)||void 0===i?void 0:i.projection);let c;for(let t=0;this.scene.length>t;t++){const e=this.scene[t],i=this.getNodeKey(e,n);i&&("rect"===e.type?this.prevPositionMap.set(i,a?{x:e.x,y:s,w:e.w,h:0,opacity:null!==(o=e.style.opacity)&&void 0!==o?o:1}:{x:s,y:e.y,w:0,h:e.h,opacity:null!==(r=e.style.opacity)&&void 0!==r?r:1}):"point"===e.type?this.prevPositionMap.set(i,{x:e.x,y:e.y,r:0,opacity:0}):"wedge"===e.type&&(void 0===c&&(c=e.startAngle),this.prevPositionMap.set(i,{x:e.cx,y:e.cy,startAngle:c,endAngle:c,innerRadius:e.innerRadius,outerRadius:e.outerRadius,opacity:0})))}}getNodeKey(t,e){var i,o,r;if("point"===t.type){const i=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,o=e.get(i)||0;return e.set(i,o+1),`${i}:${o}`}return"rect"===t.type?`r:${t.group||""}:${null!==(o=null===(i=t.datum)||void 0===i?void 0:i.category)&&void 0!==o?o:""}`:"wedge"===t.type?"w:"+(null!==(r=t.category)&&void 0!==r?r:""):null}snapshotPositions(){var t;this.prevPositionMap.clear();const e=new Map;for(let i=0;this.scene.length>i;i++){const o=this.scene[i],r=this.getNodeKey(o,e);r&&("point"===o.type?this.prevPositionMap.set(r,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity}):"rect"===o.type?this.prevPositionMap.set(r,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity}):"wedge"===o.type&&this.prevPositionMap.set(r,{x:o.cx,y:o.cy,startAngle:o.startAngle,endAngle:o.endAngle,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:null!==(t=o.style.opacity)&&void 0!==t?t:1}))}}startTransition(){var t,e,i,o,r,n,s,a,c,l,u,h,d,f,g,y,p,m,x,v,b;if(!this.config.transition||0===this.prevPositionMap.size)return;const k=null!==(t=this.config.transition.duration)&&void 0!==t?t:300;if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}let A=!1;const w=new Set,S=new Map;for(let t=0;this.scene.length>t;t++){const l=this.scene[t],u=this.getNodeKey(l,S);if(!u)continue;l._transitionKey=u;const h=this.prevPositionMap.get(u);if("point"===l.type)h?(w.add(u),l._targetOpacity=null!==(e=l.style.opacity)&&void 0!==e?e:1,(h.x!==l.x||h.y!==l.y||void 0!==h.r&&h.r!==l.r)&&(l._targetX=l.x,l._targetY=l.y,l._targetR=l.r,l.x=h.x,l.y=h.y,void 0!==h.r&&(l.r=h.r),A=!0)):(l._targetOpacity=null!==(i=l.style.opacity)&&void 0!==i?i:1,l._targetR=l.r,l.r=0,l.style=Object.assign(Object.assign({},l.style),{opacity:0}),A=!0);else if("rect"===l.type)h?(w.add(u),l._targetOpacity=null!==(o=l.style.opacity)&&void 0!==o?o:1,h.x===l.x&&h.y===l.y&&h.w===l.w&&h.h===l.h||(l._targetX=l.x,l._targetY=l.y,l._targetW=l.w,l._targetH=l.h,l.x=h.x,l.y=h.y,l.w=null!==(r=h.w)&&void 0!==r?r:l.w,l.h=null!==(n=h.h)&&void 0!==n?n:l.h,A=!0)):(l._targetOpacity=null!==(s=l.style.opacity)&&void 0!==s?s:1,l.style=Object.assign(Object.assign({},l.style),{opacity:0}),A=!0);else if("wedge"===l.type)if(h)w.add(u),l._targetOpacity=null!==(a=l.style.opacity)&&void 0!==a?a:1,h.startAngle===l.startAngle&&h.endAngle===l.endAngle||(l._targetStartAngle=l.startAngle,l._targetEndAngle=l.endAngle,l.startAngle=h.startAngle,l.endAngle=h.endAngle,A=!0);else{l._targetOpacity=null!==(c=l.style.opacity)&&void 0!==c?c:1,l._targetStartAngle=l.startAngle,l._targetEndAngle=l.endAngle;const t=l.startAngle;l.startAngle=t,l.endAngle=t,l.style=Object.assign(Object.assign({},l.style),{opacity:0}),this.prevPositionMap.set(u,{x:l.cx,y:l.cy,startAngle:t,endAngle:t,innerRadius:l.innerRadius,outerRadius:l.outerRadius,opacity:0}),A=!0}}this.exitNodes=[];for(const[t,e]of this.prevPositionMap)if(!w.has(t)){if(t.startsWith("p:"))this.exitNodes.push({type:"point",x:e.x,y:e.y,r:null!==(l=e.r)&&void 0!==l?l:3,style:{opacity:null!==(u=e.opacity)&&void 0!==u?u:1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))this.exitNodes.push({type:"rect",x:e.x,y:e.y,w:null!==(h=e.w)&&void 0!==h?h:0,h:null!==(d=e.h)&&void 0!==d?d:0,style:{opacity:null!==(f=e.opacity)&&void 0!==f?f:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("w:")){const i=((null!==(g=e.startAngle)&&void 0!==g?g:0)+(null!==(y=e.endAngle)&&void 0!==y?y:0))/2,o={type:"wedge",cx:e.x,cy:e.y,innerRadius:null!==(p=e.innerRadius)&&void 0!==p?p:0,outerRadius:null!==(m=e.outerRadius)&&void 0!==m?m:100,startAngle:null!==(x=e.startAngle)&&void 0!==x?x:0,endAngle:null!==(v=e.endAngle)&&void 0!==v?v:0,style:{opacity:null!==(b=e.opacity)&&void 0!==b?b:1},datum:null,category:t.slice(2),_targetStartAngle:i,_targetEndAngle:i,_targetOpacity:0,_transitionKey:t};this.exitNodes.push(o)}A=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),A&&(this.activeTransition={startTime:et(),duration:k})}advanceTransition(t){var e,i,o,r;if(!this.activeTransition)return!1;const n=J(t,this.activeTransition),s=K(n,"linear"===(null===(e=this.config.transition)||void 0===e?void 0:e.easing)?"linear":"ease-out-cubic");for(const t of this.scene){const e=t._transitionKey;if(e)if("point"===t.type){if(void 0!==t._targetOpacity){const o=this.prevPositionMap.get(e),r=o?null!==(i=o.opacity)&&void 0!==i?i:1:0;t.style.opacity=tt(r,t._targetOpacity,s)}const o=this.prevPositionMap.get(e);void 0!==t._targetX&&o&&(t.x=tt(o.x,t._targetX,s),t.y=tt(o.y,t._targetY,s)),void 0!==t._targetR&&void 0!==(null==o?void 0:o.r)&&(t.r=tt(o.r,t._targetR,s))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e),r=i?null!==(o=i.opacity)&&void 0!==o?o:1:0;t.style.opacity=tt(r,t._targetOpacity,s)}if(void 0===t._targetX)continue;const i=this.prevPositionMap.get(e);if(!i)continue;t.x=tt(i.x,t._targetX,s),t.y=tt(i.y,t._targetY,s),void 0!==i.w&&(t.w=tt(i.w,t._targetW,s),t.h=tt(i.h,t._targetH,s))}else if("wedge"===t.type){if(void 0!==t._targetOpacity){const i=this.prevPositionMap.get(e),o=i?null!==(r=i.opacity)&&void 0!==r?r:1:0;t.style=Object.assign(Object.assign({},t.style),{opacity:tt(o,t._targetOpacity,s)})}if(void 0!==t._targetStartAngle&&void 0!==t._targetEndAngle){const i=this.prevPositionMap.get(e);i&&void 0!==i.startAngle&&(t.startAngle=tt(i.startAngle,t._targetStartAngle,s),t.endAngle=tt(i.endAngle,t._targetEndAngle,s))}}}if(n>=1){for(const t of this.scene)if(void 0!==t._targetOpacity&&(t.style=Object.assign(Object.assign({},t.style||{}),{opacity:0===t._targetOpacity?0:t._targetOpacity}),t._targetOpacity=void 0),"point"===t.type){if(void 0===t._targetX&&void 0===t._targetR)continue;void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY),void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=void 0);if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}cancelIntroAnimation(){this.prevPositionMap.clear(),this.activeTransition=null}getData(){return this.buffer.toArray()}remove(t){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=new Set(Array.isArray(t)?t:[t]),i=this.getDataId,o=t=>e.has(i(t));if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),e=new Set;this.buffer.forEach((t,i)=>{o(t)&&e.add(i)}),this.timestampBuffer.clear();for(let i=0;t.length>i;i++)e.has(i)||this.timestampBuffer.push(t[i])}const r=this.buffer.remove(o);if(0===r.length)return r;for(const t of r)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach(t=>this.categories.add(this.getO(t))),this._dataVersion++,this.version++,r}update(t,e){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const i=new Set(Array.isArray(t)?t:[t]),o=this.getDataId,r=new Set;this.buffer.forEach((t,e)=>{i.has(o(t))&&r.add(e)});const n=this.buffer.update(t=>i.has(o(t)),e);if(0===n.length)return n;for(const t of n)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach((t,e)=>{this.categories.add(this.getO(t)),r.has(e)&&this.pushValueExtent(t)}),this._dataVersion++,this.version++,n}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this._pointQuadtree=null,this._maxPointRadius=0,this._dataVersion++,this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}updateConfig(t){const e=Object.assign({},this.config);if(("colorScheme"in t&&t.colorScheme!==e.colorScheme||"themeCategorical"in t&&t.themeCategorical!==e.themeCategorical||"colorAccessor"in t&&!_(t.colorAccessor,e.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in t&&!_(t.categoryAccessor,e.categoryAccessor)||"oAccessor"in t&&!_(t.oAccessor,e.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,t),("categoryAccessor"in t||"oAccessor"in t)&&(_(t.categoryAccessor||t.oAccessor,e.categoryAccessor||e.oAccessor)||(this.getO=M(this.config.categoryAccessor||this.config.oAccessor,"category"),this.categories.clear())),"valueAccessor"in t||"rAccessor"in t){const i=t.valueAccessor||t.rAccessor,o=e.valueAccessor||e.rAccessor,r=Array.isArray(i)?i:[i],n=Array.isArray(o)?o:[o];if(r.length!==n.length||r.some((t,e)=>!_(t,n[e]))){const t=this.config.valueAccessor||this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>P(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new m)):(this.getR=P(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!_(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?M(this.config.stackBy):void 0),"groupBy"in t&&!_(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?M(this.config.groupBy):void 0),"colorAccessor"in t&&!_(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?M(this.config.colorAccessor):void 0),"connectorAccessor"in t&&!_(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?M(this.config.connectorAccessor):void 0)}}_e.QUADTREE_THRESHOLD=500;const Pe={mercator:h.geoMercator,equalEarth:h.geoEqualEarth,albersUsa:h.geoAlbersUsa,orthographic:h.geoOrthographic,naturalEarth:h.geoNaturalEarth1,equirectangular:h.geoEquirectangular};function je(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function Me(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function Oe(t,e,i){return t?Object.assign(Object.assign({},i),"function"==typeof t?t(e):t):Object.assign({},i)}function Le(t,e){if(2>t.length)return[t];const i=.4*e,o=[];let r=[t[0]];for(let e=1;t.length>e;e++){const n=t[e];Math.abs(n[0]-t[e-1][0])>i?(2>r.length||o.push(r),r=[n]):r.push(n)}return 2>r.length||o.push(r),o}function Ee(t,e,i=24){const o=e[0]-t[0],r=e[1]-t[1],n=Math.sqrt(o*o+r*r);if(0===n)return[t,e];const s=-r/n,a=o/n,c=Math.min(.3*n,80),l=(t[0]+e[0])/2+s*c,u=(t[1]+e[1])/2+a*c,h=[];for(let o=0;i>=o;o++){const r=o/i,n=1-r;h.push([n*n*t[0]+2*n*r*l+r*r*e[0],n*n*t[1]+2*n*r*u+r*r*e[1]])}return h}function Te(t,e){if(2>t.length)return t;const i=e/2+1,o=[];for(let e=0;t.length>e;e++){const r=t[e];let n,s;0===e?(n=t[1][0]-r[0],s=t[1][1]-r[1]):e===t.length-1?(n=r[0]-t[e-1][0],s=r[1]-t[e-1][1]):(n=t[e+1][0]-t[e-1][0],s=t[e+1][1]-t[e-1][1]);const a=Math.sqrt(n*n+s*s)||1;o.push([r[0]+s/a*i,r[1]+-n/a*i])}return o}function De(t,e,i,o,r){const n=e[0]-t[0],s=e[1]-t[1],a=Math.sqrt(n*n+s*s);if(0===a)return[t,e];const c=s/a,l=-n/a,u=r/2+1;return[[t[0]+c*u,t[1]+l*u],[e[0]+c*u,e[1]+l*u]]}class ze{constructor(t){this.scene=[],this.scales=null,this.version=0,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this.config=t}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}setAreas(t){this.areas=t}setPoints(t){this.pointData=t,this.streaming=!1}setLines(t){this.lineData=t}initStreaming(t=500){this.pointBuffer=new p(t),this.timestampBuffer=new p(t),this.streaming=!0}pushPoint(t){this.pointBuffer||this.initStreaming(),this.pointBuffer.push(t),this.timestampBuffer.push(performance.now()),this.lastIngestTime=performance.now()}pushMany(t){this.pointBuffer||this.initStreaming();const e=performance.now();for(const i of t)this.pointBuffer.push(i),this.timestampBuffer.push(e);this.lastIngestTime=e}removePoint(t){const{pointIdAccessor:e}=this.config;if(!e)throw Error("removePoint() requires pointIdAccessor to be configured");const i="function"==typeof e?e:t=>t[e],o=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>o.has(i(t)+"");if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),i=new Set;this.pointBuffer.forEach((e,o)=>{t(e)&&i.add(o)}),this.timestampBuffer.clear();for(let t=0;e.length>t;t++)i.has(t)||this.timestampBuffer.push(e[t])}const e=this.pointBuffer.remove(t);return e.length>0&&this.version++,e}{const t=[];return this.pointData=this.pointData.filter(e=>!o.has(i(e)+"")||(t.push(e),!1)),t.length>0&&this.version++,t}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.version++}computeScene(t){const{config:e}=this;this.projection=function(t){if(!t)return h.geoEqualEarth();if("string"==typeof t){const e=Pe[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),h.geoEqualEarth())}if("object"==typeof t&&"type"in t){const e=Pe[t.type],i=e?e():h.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=h.geoPath(this.projection),this.fitProjection(t),this.geoPath=h.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 o=this.scene;if(this.scene=this.buildSceneNodes(t),this.rebuildQuadtree(),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&!this._hasRenderedOnce&&this.scene.length>0&&e.introAnimation){const e=t.width/2,i=t.height/2,o=this.scene.filter(t=>"point"===t.type).map(t=>Object.assign(Object.assign({},t),{x:e,y:i}));o.length>0&&this.startTransition(o)}this._hasRenderedOnce=!0,e.transition&&o.length>0&&this.startTransition(o),this.version++}fitProjection(t){var e,i,o,r,n;const s=this.projection,a=this.config,c=[...this.areas],l=je(a.xAccessor,"lon"),u=je(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 d=Me(a.lineDataAccessor);for(const t of this.lineData){const e=d(t);if(e&&e.length>0){const t=e.map(t=>[l(t),u(t)]);c.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==c.length){if(a.projectionExtent){const[[e,i],[o,r]]=a.projectionExtent;s.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[e,i],[o,i],[o,r],[e,r],[e,i]]]}})}else if(s.clipAngle&&(null!==(e=s.clipAngle())&&void 0!==e?e:0)>0){const e=null!==(i=a.fitPadding)&&void 0!==i?i:0,o=Math.min(t.width,t.height);s.scale(o/2-o*e),s.translate([t.width/2,t.height/2])}else{const e=null!==(o=a.fitPadding)&&void 0!==o?o:0,i=t.width*e,r=t.height*e;s.fitExtent([[i,r],[t.width-i,t.height-r]],{type:"FeatureCollection",features:c})}this.baseScale=s.scale(),this.baseTranslate=s.translate(),this.baseRotation=null!==(n=null===(r=s.rotate)||void 0===r?void 0:r.call(s))&&void 0!==n?n:[0,0,0]}}applyZoomTransform(t,e){const i=this.projection;i&&(i.scale(this.baseScale*t.k),i.translate([this.baseTranslate[0]*t.k+t.x,this.baseTranslate[1]*t.k+t.y]),this.currentZoom=t.k,this.geoPath=h.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.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyZoomScale(t,e){const i=this.projection;i&&(i.scale(this.baseScale*t),i.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=h.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.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyRotation(t,e){const i=this.projection;i&&i.rotate&&(i.rotate(t),this.geoPath=h.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.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}setRotation(t){const e=this.projection;e&&e.rotate&&e.rotate(t)}getRotation(){var t,e,i;return null!==(i=null===(e=null===(t=this.projection)||void 0===t?void 0:t.rotate)||void 0===e?void 0:e.call(t))&&void 0!==i?i:this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let t=0,e=0;for(const i of this.scene)"point"===i.type&&(e++,i.r>t&&(t=i.r));if(this._maxPointRadius=t,ze.QUADTREE_THRESHOLD>=e)return void(this._quadtree=null);const i=Array(e);let o=0;for(const t of this.scene)"point"===t.type&&(i[o++]=t);this._quadtree=r.quadtree().x(t=>t.x).y(t=>t.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(t){var e,i,o;const r=[],{config:n}=this,s=this.projection,a=this.geoPath,c=je(n.xAccessor,"lon"),l=je(n.yAccessor,"lat"),u=function(t){var e,i;return{fill:(null===(e=t.themeSemantic)||void 0===e?void 0:e.surface)||"#e0e0e0",stroke:(null===(i=t.themeSemantic)||void 0===i?void 0:i.border)||"#999",strokeWidth:.5,fillOpacity:1}}(n),d=function(t){var e;return{stroke:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",strokeWidth:1.5,fill:"none"}}(n),f=function(t){var e;return{fill:(null===(e=t.themeSemantic)||void 0===e?void 0:e.primary)||"#4e79a7",r:4,fillOpacity:.8}}(n);if(n.graticule){const e=!0===n.graticule?{}:n.graticule,i=h.geoGraticule();e.step&&i.step(e.step);const o=a(i())||"";o&&r.push({type:"geoarea",pathData:o,centroid:[t.width/2,t.height/2],bounds:[[0,0],[t.width,t.height]],screenArea:0,style:{fill:"none",stroke:e.stroke||"#e0e0e0",strokeWidth:e.strokeWidth||.5,strokeDasharray:e.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const t of this.areas){const e=a(t);if(!e)continue;const i=a.centroid(t),o=a.bounds(t),s=a.area(t),c=Oe(n.areaStyle,t,u);r.push({type:"geoarea",pathData:e,centroid:i,bounds:o,screenArea:s,style:c,datum:t,interactive:!0})}const g=Me(n.lineDataAccessor);for(const e of this.lineData){const i=g(e);if(!i||2>i.length)continue;let o=[];if("geo"===n.lineType){const t=Array(i.length);for(let e=0;i.length>e;e++)t[e]=[c(i[e]),l(i[e])];for(let e=0;t.length-1>e;e++){const i=t[e],r=t[e+1],n=h.geoDistance(i,r)||0,a=Math.max(2,Math.ceil(n/(Math.PI/180))),c=h.geoInterpolate(i,r);for(let t=0;a>=t;t++){if(e>0&&0===t)continue;const i=s(c(t/a));null!=i&&o.push(i)}}}else for(let t=0;i.length>t;t++){const e=i[t],r=s([c(e),l(e)]);null!=r&&o.push(r)}if(2>o.length)continue;const a=Oe(n.lineStyle,e,d),u="number"==typeof a.strokeWidth?a.strokeWidth:1;2!==i.length||2>o.length||"arc"!==n.flowStyle?2!==i.length||2>o.length||"offset"!==n.flowStyle||(o="geo"===n.lineType?Te(o,u):De(o[0],o[o.length-1],0,0,u)):o=Ee(o[0],o[o.length-1]);const f=Le(o,t.width);if(f.length>1)for(const t of f){if(2>t.length)continue;const i={type:"line",path:t,style:Object.assign(Object.assign({},a),{_edgeFade:!0}),datum:e};r.push(i)}else r.push({type:"line",path:2>o.length&&f[0]||o,style:a,datum:e})}const y=this.getPoints(),p=n.pointIdAccessor?"function"==typeof n.pointIdAccessor?n.pointIdAccessor:t=>t[n.pointIdAccessor]:null,m=s.clipAngle&&null!==(e=s.clipAngle())&&void 0!==e?e:0,x=m>0?m*Math.PI/180:null,v=s.rotate?s.rotate():[0,0,0],b="function"==typeof s.center?s.center():[0,0],k=[(null!==(i=b[0])&&void 0!==i?i:0)-v[0],(null!==(o=b[1])&&void 0!==o?o:0)-v[1]];for(let t=0;y.length>t;t++){const e=y[t],i=c(e),o=l(e);if(null!=x&&h.geoDistance([i,o],k)>x)continue;const a=s([i,o]);if(!a)continue;const u=n.pointStyle?n.pointStyle(e):Object.assign({},f),d={type:"point",x:a[0],y:a[1],r:u.r||4,style:u,datum:e,pointId:p?p(e)+"":void 0};r.push(d)}return r}applyCartogramTransform(t,e){var i,r,n;const s=this.scene.filter(t=>"point"===t.type);if(2>s.length)return;const a=null!==(i=t.strength)&&void 0!==i?i:1;if(0===a)return;const c=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:t=>t.id,l="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],u=s.find(e=>e.datum&&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,d=u.y,f=s.map(t=>t.datum?l(t.datum):NaN).filter(t=>isFinite(t)&&t>=0),g=Math.max(...f,1),y=Math.min(e.width,e.height)/2,p=o.scaleLinear().domain([0,g]).range([0,y]);this.cartogramLayout={cx:h,cy:d,maxCost:g,availableRadius:y},this.areas.length>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them."),this.scene=this.scene.filter(t=>"geoarea"!==t.type||!t.interactive);for(const t of s){if(t===u)continue;if(!t.datum)continue;const e=Math.atan2(t.y-d,t.x-h),i=Math.sqrt(Math.pow(t.x-h,2)+Math.pow(t.y-d,2)),o=l(t.datum),r=i+((isFinite(o)?p(o):i)-i)*a;t.x=h+Math.cos(e)*r,t.y=d+Math.sin(e)*r}const m=e.width/2,x=e.height/2,v=m-u.x,b=x-u.y;if(Math.abs(v)>.5||Math.abs(b)>.5)for(const t of s)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 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,o=null===(n=e.datum)||void 0===n?void 0:n.target;if(i&&o){const r=t.get(i+""),n=t.get(o+"");r&&n&&(e.path=[r,n])}}}}applyDecay(){const t=this.config.decay;if(!t||!this.pointBuffer)return;const e=this.pointBuffer.size;if(0===e)return;const i=this.scene.filter(t=>"point"===t.type);for(let o=0;i.length>o;o++){const r=U(t,o,e);i[o]._decayOpacity=r,i[o].style=Object.assign(Object.assign({},i[o].style),{opacity:r})}}applyPulse(){var t,e;const i=this.config.pulse;if(!i||!this.timestampBuffer)return;const o=null!==(t=i.duration)&&void 0!==t?t:500,r=performance.now(),n=this.scene.filter(t=>"point"===t.type),s=this.timestampBuffer.toArray();for(let t=0;n.length>t&&s.length>t;t++){const a=r-s[t];o>a&&(n[t]._pulseIntensity=1-a/o,n[t]._pulseColor=i.color||"rgba(255,255,255,0.6)",n[t]._pulseGlowRadius=null!==(e=i.glowRadius)&&void 0!==e?e:4)}}get hasActivePulses(){var t,e;if(!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const i=null!==(e=null===(t=this.config.pulse)||void 0===t?void 0:t.duration)&&void 0!==e?e:500,o=this.timestampBuffer.toArray()[this.timestampBuffer.size-1];return performance.now()-o<i}startTransition(t){var e,i;const o=null!==(i=null===(e=this.config.transition)||void 0===e?void 0:e.duration)&&void 0!==i?i:300;if(0>=o)return;const r=new Map;for(const e of t)"point"===e.type&&e.pointId&&r.set(e.pointId,[e.x,e.y]);const n=this.scene.filter(t=>"point"===t.type);let s=!1;for(const t of n)if(t.pointId){const e=r.get(t.pointId);e&&(t._targetX=t.x,t._targetY=t.y,t.x=e[0],t.y=e[1],(Math.abs(e[0]-t._targetX)>.5||Math.abs(e[1]-t._targetY)>.5)&&(s=!0))}s&&(this.activeTransition={startTime:performance.now(),duration:o})}cancelIntroAnimation(){this.activeTransition=null}advanceTransition(t){if(!this.activeTransition)return!1;const e=J(t,this.activeTransition),i=K(e),o=this.scene.filter(t=>"point"===t.type);for(const t of o)if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=tt(t.x,t._targetX,i),t.y=tt(e,t._targetY,i)}if(e>=1){for(const t of o)null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0);return this.activeTransition=null,!1}return!0}}ze.QUADTREE_THRESHOLD=500;const $e={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Re(t,e="#4e79a7"){return t&&"string"==typeof t?t:e}function Ce(e,i,o){var r,n,s,a,c;switch(e.type){case"line":{const o=e;if(0===o.path.length)return null;const r="M"+o.path.map(([t,e])=>`${t},${e}`).join("L");return t.jsx("path",{d:r,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||2,strokeDasharray:o.style.strokeDasharray,opacity:o.style.opacity},"line-"+i)}case"area":{const c=e;if(0===c.topPath.length)return null;const l=`M${c.topPath.map(([t,e])=>`${t},${e}`).join("L")}L${[...c.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L")}Z`;if(c.clipRect){const e=`${o?o+"-":""}area-clip-${i}`;return t.jsxs("g",{children:[t.jsx("defs",{children:t.jsx("clipPath",{id:e,children:t.jsx("rect",{x:c.clipRect.x,y:c.clipRect.y,width:c.clipRect.width,height:c.clipRect.height})})}),t.jsx("path",{d:l,fill:Re(c.style.fill),fillOpacity:null!==(n=null!==(r=c.style.fillOpacity)&&void 0!==r?r:c.style.opacity)&&void 0!==n?n:.7,stroke:c.style.stroke,strokeWidth:c.style.strokeWidth,clipPath:`url(#${e})`})]},"area-"+i)}return t.jsx("path",{d:l,fill:Re(c.style.fill),fillOpacity:null!==(a=null!==(s=c.style.fillOpacity)&&void 0!==s?s:c.style.opacity)&&void 0!==a?a:.7,stroke:c.style.stroke,strokeWidth:c.style.strokeWidth},"area-"+i)}case"point":{const o=e;return t.jsx("circle",{cx:o.x,cy:o.y,r:o.r,fill:Re(o.style.fill),opacity:null!==(c=o.style.opacity)&&void 0!==c?c:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},"point-"+i)}case"rect":{const o=e;return t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:Re(o.style.fill),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},"rect-"+i)}case"heatcell":{const o=e;if(o.showValues&&null!=o.value&&o.w>=20&&o.h>=20){const e=o.valueFormat?o.valueFormat(o.value):Number.isInteger(o.value)?o.value+"":100>Math.abs(o.value)?1>Math.abs(o.value)?o.value.toPrecision(3):o.value.toFixed(1):o.value.toFixed(0),[r,n,s]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(o.fill),a=.299*r+.587*n+.114*s>128?"#000":"#fff",c=Math.max(10,Math.min(16,.3*Math.min(o.w,o.h)));return t.jsxs("g",{children:[t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill}),t.jsx("text",{x:o.x+o.w/2,y:o.y+o.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:c+"px",children:e})]},"heatcell-"+i)}return t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill},"heatcell-"+i)}case"candlestick":{const o=e,r=Math.min(o.openY,o.closeY),n=Math.max(Math.abs(o.openY-o.closeY),1),s=o.isUp?o.upColor:o.downColor;return t.jsxs("g",{children:[t.jsx("line",{x1:o.x,y1:o.highY,x2:o.x,y2:o.lowY,stroke:o.wickColor,strokeWidth:o.wickWidth}),t.jsx("rect",{x:o.x-o.bodyWidth/2,y:r,width:o.bodyWidth,height:n,fill:s,stroke:s,strokeWidth:1})]},"candle-"+i)}default:return null}}function Ne(e,i){var o,r,n,s,a;const c=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",u=t=>`ord-${e.type}-${c}-${i}-${t}`,h=`ord-${e.type}-${c}-${i}`;switch(e.type){case"rect":{const i=e,o=function(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}(h)+"-grad",r=function(e,i){const o=e.fillGradient;if(!o)return null;let r=e.x,n=e.y,s=e.x,a=e.y+e.h;"bottom"===e.roundedEdge?(n=e.y+e.h,a=e.y):"right"===e.roundedEdge?(r=e.x+e.w,n=e.y,s=e.x,a=e.y):"left"===e.roundedEdge&&(r=e.x,n=e.y,s=e.x+e.w,a=e.y);const c=[];if("colorStops"in o){const e=o.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>e.length)return null;for(let i=0;e.length>i;i++)c.push(t.jsx("stop",{offset:e[i].offset,stopColor:e[i].color},i))}else{const i=Re(e.style.fill);c.push(t.jsx("stop",{offset:0,stopColor:i,stopOpacity:o.topOpacity},"0")),c.push(t.jsx("stop",{offset:1,stopColor:i,stopOpacity:o.bottomOpacity},"1"))}return t.jsx("linearGradient",{id:i,gradientUnits:"userSpaceOnUse",x1:r,y1:n,x2:s,y2:a,children:c})}(i,o),n=r?`url(#${o})`:Re(i.style.fill);if(i.roundedTop&&i.roundedTop>0){const e=Math.min(i.roundedTop,i.w/2,i.h/2),{x:o,y:s,w:a,h:c}=i;let l;switch(i.roundedEdge){case"right":l=`M${o},${s} L${o+a-e},${s} A${e},${e} 0 0 1 ${o+a},${s+e} L${o+a},${s+c-e} A${e},${e} 0 0 1 ${o+a-e},${s+c} L${o},${s+c} Z`;break;case"left":l=`M${o+a},${s} L${o+e},${s} A${e},${e} 0 0 0 ${o},${s+e} L${o},${s+c-e} A${e},${e} 0 0 0 ${o+e},${s+c} L${o+a},${s+c} Z`;break;case"bottom":l=`M${o},${s} L${o+a},${s} L${o+a},${s+c-e} A${e},${e} 0 0 1 ${o+a-e},${s+c} L${o+e},${s+c} A${e},${e} 0 0 1 ${o},${s+c-e} Z`;break;default:l=`M${o},${s+c} L${o},${s+e} A${e},${e} 0 0 1 ${o+e},${s} L${o+a-e},${s} A${e},${e} 0 0 1 ${o+a},${s+e} L${o+a},${s+c} Z`}return t.jsxs(f.Fragment,{children:[r&&t.jsx("defs",{children:r}),t.jsx("path",{d:l,fill:n,opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},h)}return t.jsxs(f.Fragment,{children:[r&&t.jsx("defs",{children:r}),t.jsx("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:n,opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},h)}case"point":{const i=e;return t.jsx("circle",{cx:i.x,cy:i.y,r:i.r,fill:Re(i.style.fill),opacity:null!==(o=i.style.opacity)&&void 0!==o?o:.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth},h)}case"wedge":{const i=e,o=l.arc().innerRadius(i.innerRadius).outerRadius(i.outerRadius).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2);i.cornerRadius&&o.cornerRadius(i.cornerRadius);const r=o($e)||"";return t.jsx("path",{d:r,transform:`translate(${i.cx},${i.cy})`,fill:Re(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},h)}case"boxplot":{const i=e,o=i.columnWidth/2;return t.jsxs("g","vertical"===i.projection?{children:[t.jsx("line",{x1:i.x,y1:i.minPos,x2:i.x,y2:i.maxPos,stroke:i.style.stroke||"#333",strokeWidth:1}),t.jsx("rect",{x:i.x-o,y:Math.min(i.q1Pos,i.q3Pos),width:i.columnWidth,height:Math.abs(i.q3Pos-i.q1Pos),fill:Re(i.style.fill),fillOpacity:null!==(r=i.style.fillOpacity)&&void 0!==r?r:.6,stroke:i.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:i.x-o,y1:i.medianPos,x2:i.x+o,y2:i.medianPos,stroke:i.style.stroke||"#333",strokeWidth:2}),t.jsx("line",{x1:i.x-.5*o,y1:i.minPos,x2:i.x+.5*o,y2:i.minPos,stroke:i.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:i.x-.5*o,y1:i.maxPos,x2:i.x+.5*o,y2:i.maxPos,stroke:i.style.stroke||"#333",strokeWidth:1})]}:{children:[t.jsx("line",{x1:i.minPos,y1:i.y,x2:i.maxPos,y2:i.y,stroke:i.style.stroke||"#333",strokeWidth:1}),t.jsx("rect",{x:Math.min(i.q1Pos,i.q3Pos),y:i.y-o,width:Math.abs(i.q3Pos-i.q1Pos),height:i.columnWidth,fill:Re(i.style.fill),fillOpacity:null!==(n=i.style.fillOpacity)&&void 0!==n?n:.6,stroke:i.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:i.medianPos,y1:i.y-o,x2:i.medianPos,y2:i.y+o,stroke:i.style.stroke||"#333",strokeWidth:2}),t.jsx("line",{x1:i.minPos,y1:i.y-.5*o,x2:i.minPos,y2:i.y+.5*o,stroke:i.style.stroke||"#333",strokeWidth:1}),t.jsx("line",{x1:i.maxPos,y1:i.y-.5*o,x2:i.maxPos,y2:i.y+.5*o,stroke:i.style.stroke||"#333",strokeWidth:1})]},h)}case"violin":{const i=e,o=[t.jsx("path",{d:i.pathString,transform:i.translateX||i.translateY?`translate(${i.translateX},${i.translateY})`:void 0,fill:Re(i.style.fill),fillOpacity:null!==(s=i.style.fillOpacity)&&void 0!==s?s:.6,stroke:i.style.stroke||"#333",strokeWidth:i.style.strokeWidth||1},u("path"))];if(i.iqrLine&&i.bounds){const e=i.bounds,r=e.x+e.width/2,n=e.y+e.height/2;e.height>e.width?o.push(t.jsx("line",{x1:r,y1:i.iqrLine.q1Pos,x2:r,y2:i.iqrLine.q3Pos,stroke:i.style.stroke||"#333",strokeWidth:2},u("iqr")),t.jsx("circle",{cx:r,cy:i.iqrLine.medianPos,r:3,fill:"white",stroke:i.style.stroke||"#333",strokeWidth:1},u("med"))):o.push(t.jsx("line",{x1:i.iqrLine.q1Pos,y1:n,x2:i.iqrLine.q3Pos,y2:n,stroke:i.style.stroke||"#333",strokeWidth:2},u("iqr")),t.jsx("circle",{cx:i.iqrLine.medianPos,cy:n,r:3,fill:"white",stroke:i.style.stroke||"#333",strokeWidth:1},u("med")))}return t.jsx("g",{children:o},h)}case"connector":return t.jsx("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:null!==(a=e.style.opacity)&&void 0!==a?a:.5},h);case"trapezoid":{const i=e,o=i.points.map(t=>`${t[0]},${t[1]}`).join(" ");return t.jsx("polygon",{points:o,fill:Re(i.style.fill,"#999"),opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth},h)}default:return null}}function Fe(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{categorical:Be})})),t.accessibility.highContrast){const t="dark"===e.mode;e=Object.assign(Object.assign({},e),{colors:Object.assign(Object.assign({},e.colors),{text:t?"#ffffff":"#000000",textSecondary:t?"#cccccc":"#333333",grid:t?"#666666":"#999999",border:t?"#888888":"#000000"})})}return e}const Be=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],We={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},Ye={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},Ie={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:Be,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function Xe(t,e){if("light"===e)return We;if("dark"===e)return Ye;if("high-contrast"===e)return Ie;if("string"==typeof e)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${e}". Keeping current theme.`),t;if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?Ye:We;return Fe(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 Fe(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||{})}))}!function(t,e){const i=new EventTarget;let o=Object.assign(Object.assign({},t(function(t){o=Object.assign(Object.assign({},o),t(o)),i.dispatchEvent(new Event("update"))})),null!=e?e:{})}(t=>({theme:We,setTheme(e){t(t=>({theme:Xe(t.theme,e)}))}}));const qe={light:We,dark:Ye,"high-contrast":Ie,pastels:{mode:"light",colors:{primary:"#c9a0dc",secondary:"#b8a8c8",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",surface:"#fff5ee",text:"#4a3728",textSecondary:"#8b7355",grid:"#e8d5c4",border:"#e8d5c4",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#9ad4a3",danger:"#e8869a",warning:"#f0c888",error:"#c86070",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",secondary:"#a899c0",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",surface:"#251e35",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#88d4ab",danger:"#f0a0c0",warning:"#f0c888",error:"#e87690",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",secondary:"#6b7280",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",surface:"#ffffff",text:"#2c3e50",textSecondary:"#7f8c9b",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb",annotation:"#2563eb",success:"#10b981",danger:"#ef4444",warning:"#f59e0b",error:"#dc2626",info:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",secondary:"#9ca3af",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",surface:"#1f2937",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6",annotation:"#3b82f6",success:"#34d399",danger:"#f87171",warning:"#fbbf24",error:"#ef4444",info:"#60a5fa"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",secondary:"#666666",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",surface:"#ffffff",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000",annotation:"#cc0000",success:"#556b2f",danger:"#cc0000",warning:"#c8a415",error:"#8b0000",info:"#4682b4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",secondary:"#aaaaaa",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",surface:"#1a1a1a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333",annotation:"#ff3333",success:"#7a8b5a",danger:"#ff3333",warning:"#d4a843",error:"#cc0000",info:"#6aa4d4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",secondary:"#555555",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",surface:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000",success:"#556b2f",danger:"#8b0000",warning:"#b88700",error:"#6b0000",info:"#4a5568"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",secondary:"#a09880",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",surface:"#262520",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050",annotation:"#c05050",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",secondary:"#666666",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",surface:"#f8f8f8",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#e45050",success:"#2d7a3d",danger:"#c8303a",warning:"#d4a843",error:"#a02028",info:"#3a86c8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:18,labelSize:12,tickSize:10,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",secondary:"#a0a0a0",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",surface:"#1e1e1e",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b",annotation:"#ff6b6b",success:"#6fba78",danger:"#ff6b6b",warning:"#e0c060",error:"#d04040",info:"#5a9fd8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",secondary:"#7c5a9e",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",surface:"#ffffff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6",annotation:"#8b5cf6",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",secondary:"#b8a0d8",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",surface:"#1f1138",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa",annotation:"#a78bfa",success:"#4ade80",danger:"#fb7185",warning:"#fbbf24",error:"#f43f5e",info:"#22d3ee"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",secondary:"#525252",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe",annotation:"#0f62fe",success:"#24a148",danger:"#da1e28",warning:"#f1c21b",error:"#a2191f",info:"#0043ce"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",secondary:"#a8a8a8",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",surface:"#262626",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff",annotation:"#4589ff",success:"#42be65",danger:"#fa4d56",warning:"#f1c21b",error:"#da1e28",info:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function Ge(t){if(!t)return We;if("string"==typeof t){if("light"===t)return We;if("dark"===t)return Ye;if("high-contrast"===t)return Ie;return qe[t]||We}const e="dark"===t.mode?Ye:We;return Fe(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){var e,i,o,r;return{background:t.colors.background,text:t.colors.text,textSecondary:t.colors.textSecondary,grid:t.colors.grid,border:t.colors.border,primary:t.colors.primary,fontFamily:t.typography.fontFamily,titleSize:t.typography.titleSize,labelSize:t.typography.labelSize,tickSize:t.typography.tickSize,categorical:t.colors.categorical,annotation:null!==(e=t.colors.annotation)&&void 0!==e?e:t.colors.text,legendSize:null!==(i=t.typography.legendSize)&&void 0!==i?i:t.typography.labelSize,titleFontSize:null!==(o=t.typography.titleFontSize)&&void 0!==o?o:t.typography.titleSize,tickFontFamily:null!==(r=t.typography.tickFontFamily)&&void 0!==r?r:t.typography.fontFamily}}function He(e){const{categories:i,colorScheme:r,theme:n,position:s="right",totalWidth:a,totalHeight:c,margin:l,hasTitle:u=!1}=e;if(!i||0===i.length)return null;const h=function(t,e,i){const r=Array.isArray(e)?e:i.colors.categorical.length>0?i.colors.categorical:T;return o.scaleOrdinal().domain(t).range(r)}(i,r,n),d="top"===s||"bottom"===s;let f,g;if("left"===s?(f=4,g=l.top):"top"===s?(f=l.left,g=u?32:8):"bottom"===s?(f=l.left,g=Math.min(c-l.bottom+38,c-16)):(f=a-l.right+10,g=l.top),d){let e=0;const o=i.map((i,o)=>{const r=e;return e+=22+6.5*i.length+8,t.jsxs("g",{transform:`translate(${r},0)`,children:[t.jsx("rect",{width:14,height:14,fill:h(i),rx:2}),t.jsx("text",{x:20,y:7,dominantBaseline:"central",fontSize:n.typography.tickSize,fill:n.colors.text,fontFamily:n.typography.fontFamily,children:i})]},"legend-"+o)});return t.jsx("g",{className:"semiotic-legend",transform:`translate(${f},${g})`,children:o})}const y=i.map((e,i)=>t.jsxs("g",{transform:`translate(0,${20*i})`,children:[t.jsx("rect",{width:14,height:14,fill:h(e),rx:2}),t.jsx("text",{x:20,y:7,dominantBaseline:"central",fontSize:n.typography.tickSize,fill:n.colors.text,fontFamily:n.typography.fontFamily,children:e})]},"legend-"+i));return t.jsx("g",{className:"semiotic-legend",transform:`translate(${f},${g})`,children:y})}function Qe(t,e){if(!e||!t||0===t.length)return[];const i="function"==typeof e?e:t=>t[e],o=new Set;for(const e of t){const t=i(e);null!=t&&o.add(t+"")}return Array.from(o)}function Ue(t,e){return t.color||e.colors.annotation||e.colors.text}function Ze(t,e,i){return null!=t.x&&e.x?e.x(t.x):i&&null!=t[i]&&e.x?e.x(t[i]):"number"==typeof t.x?t.x:null}function Ke(t,e,i){return null!=t.y&&e.y?e.y(t.y):i&&null!=t[i]&&e.y?e.y(t[i]):"number"==typeof t.y?t.y:null}function Je(e){const{annotations:i}=e;if(!i||0===i.length)return null;const o=[];for(let t=0;i.length>t;t++){const r=ti(i[t],t,e);r&&o.push(r)}return o.length>0?t.jsx("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:o}):null}function ti(e,i,o){var r,n,s,a;const{scales:c,layout:l,theme:u,xAccessor:h,yAccessor:d}=o;switch(e.type){case"y-threshold":{const n=e.value;if(null==n)return null;const s=Ue(e,u),a=e.label,h=e.labelPosition||"right",d=e.strokeDasharray||"6,4",f=null!==(r=e.strokeWidth)&&void 0!==r?r:1.5;if("horizontal"===o.projection&&c.r){const e=c.r(n);return null==e?null:t.jsxs("g",{children:[t.jsx("line",{x1:e,y1:0,x2:e,y2:l.height,stroke:s,strokeWidth:f,strokeDasharray:d}),a&&t.jsx("text",{x:e+4,y:12,textAnchor:"start",fontSize:u.typography.tickSize,fill:s,fontFamily:u.typography.fontFamily,children:a})]},"ann-ythresh-"+i)}const g=c.y?c.y(n):c.r?c.r(n):null;return null==g?null:t.jsxs("g",{children:[t.jsx("line",{x1:0,y1:g,x2:l.width,y2:g,stroke:s,strokeWidth:f,strokeDasharray:d}),a&&t.jsx("text",{x:"left"===h?4:"center"===h?l.width/2:l.width-4,y:g-6,textAnchor:"left"===h?"start":"center"===h?"middle":"end",fontSize:u.typography.tickSize,fill:s,fontFamily:u.typography.fontFamily,children:a})]},"ann-ythresh-"+i)}case"x-threshold":{const o=e.value;if(null==o||!c.x)return null;const r=c.x(o);if(null==r)return null;const s=Ue(e,u),a=e.label,h=e.labelPosition||"top",d=null!==(n=e.strokeWidth)&&void 0!==n?n:1.5;return t.jsxs("g",{children:[t.jsx("line",{x1:r,y1:0,x2:r,y2:l.height,stroke:s,strokeWidth:d,strokeDasharray:e.strokeDasharray||"6,4"}),a&&t.jsx("text",{x:r+4,y:"bottom"===h?l.height-4:"center"===h?l.height/2:12,textAnchor:"start",fontSize:u.typography.tickSize,fill:s,fontFamily:u.typography.fontFamily,children:a})]},"ann-xthresh-"+i)}case"band":{const o=null!=e.y0&&c.y?c.y(e.y0):null,r=null!=e.y1&&c.y?c.y(e.y1):null;if(null==o||null==r)return null;const n=Math.min(o,r),a=Math.abs(r-o),h=e.fill||Ue(e,u),d=null!==(s=e.opacity)&&void 0!==s?s:.1;return t.jsxs("g",{children:[t.jsx("rect",{x:0,y:n,width:l.width,height:a,fill:h,opacity:d}),e.label&&t.jsx("text",{x:l.width-4,y:n+12,textAnchor:"end",fontSize:u.typography.tickSize,fill:h,fontFamily:u.typography.fontFamily,children:e.label})]},"ann-band-"+i)}case"category-highlight":{if(!e.category||!c.o)return null;const r=c.o(e.category);if(null==r)return null;const n=c.o.bandwidth?c.o.bandwidth():40,s=Ue(e,u),h=null!==(a=e.opacity)&&void 0!==a?a:.1;return t.jsx("rect","horizontal"===o.projection?{x:0,y:r,width:l.width,height:n,fill:s,opacity:h}:{x:r,y:0,width:n,height:l.height,fill:s,opacity:h},"ann-cathighlight-"+i)}case"label":case"text":{const{x:o,y:r}=function(t,e,i,o){if(Array.isArray(t.coordinates)&&t.coordinates.length>=2&&e.geoProjection){const i=e.geoProjection([t.coordinates[0],t.coordinates[1]]);if(i)return{x:i[0],y:i[1]}}return{x:Ze(t,e,i),y:Ke(t,e,o)}}(e,c,h,d);if(null==o||null==r)return null;const n=e.dx||0,s=e.dy||0,a=e.color||u.colors.text;return t.jsxs("g",{children:["label"===e.type&&t.jsx("line",{x1:o,y1:r,x2:o+n,y2:r+s,stroke:u.colors.textSecondary,strokeWidth:1}),t.jsx("text",{x:o+n,y:r+s,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||u.typography.labelSize,fill:a,fontFamily:u.typography.fontFamily,fontWeight:e.fontWeight,children:e.label||e.title})]},"ann-label-"+i)}default:return null}}function ei(t,e,i){return"function"==typeof t?t(i):i[t||e]}function ii(t){return t instanceof Date?t.getTime():Number(t)}function oi(t,e){return F(1===e?.5:t/(e-1))}const ri={Sparkline:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign(Object.assign({chartType:"line",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.lineBy||e,colorAccessor:e},o),{showAxes:!1,margin:o.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0})},LineChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"line",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.lineBy||e,colorAccessor:e,colorScheme:i,lineStyle:r.lineStyle},o)},AreaChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"area",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",y0Accessor:r.y0Accessor,groupAccessor:r.areaBy||e,colorAccessor:e,colorScheme:i},o)},StackedAreaChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"stackedarea",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.areaBy,colorAccessor:e||r.areaBy,colorScheme:i,normalize:r.normalize},o)},Scatterplot:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"scatter",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,sizeAccessor:r.sizeBy,colorScheme:i},o)},CandlestickChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"candlestick",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.highAccessor||"high",highAccessor:r.highAccessor||"high",lowAccessor:r.lowAccessor||"low",openAccessor:r.openAccessor,closeAccessor:r.closeAccessor,candlestickStyle:r.candlestickStyle},o)},BubbleChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"scatter",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange||[5,40],colorScheme:i},o)},ConnectedScatterplot:{frameType:"xy",buildProps:(t,e,i,o,r)=>{var n,s;const a=function(t,e){if(!Array.isArray(t))return{data:t,orderMap:new WeakMap};const i=e.xAccessor||"x",o=e.yAccessor||"y",r=e.orderAccessor?[...t].sort((t,i)=>null==t||"object"!=typeof t?1:null==i||"object"!=typeof i?-1:ii(ei(e.orderAccessor,"order",t))-ii(ei(e.orderAccessor,"order",i))):t,n=new WeakMap;let s=0;for(const t of r){if(null==t||"object"!=typeof t)continue;const e=ii(ei(i,"x",t)),r=ii(ei(o,"y",t));Number.isFinite(e)&&Number.isFinite(r)&&s++}let a=0;for(const t of r){if(null==t||"object"!=typeof t)continue;const e=ii(ei(i,"x",t)),r=ii(ei(o,"y",t));Number.isFinite(e)&&Number.isFinite(r)&&n.set(t,{idx:a++,total:s})}return{data:r,orderMap:n}}(t,r),c=null!==(n=r.pointRadius)&&void 0!==n?n:4;return Object.assign({chartType:"line",data:a.data,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,colorScheme:i,lineStyle:r.lineStyle||{stroke:r.stroke||"#6366f1",strokeWidth:null!==(s=r.strokeWidth)&&void 0!==s?s:c,opacity:r.opacity},pointStyle:t=>{var e,i;const o=a.orderMap.get(t),r=null!==(e=null==o?void 0:o.idx)&&void 0!==e?e:0,n=null!==(i=null==o?void 0:o.total)&&void 0!==i?i:1;return{fill:n>0?oi(r,n):"#6366f1",stroke:"white",strokeWidth:1,r:c,fillOpacity:1}}},o)}},Heatmap:{frameType:"xy",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"heatmap",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",valueAccessor:r.valueAccessor,colorScheme:i||r.colorScheme||"blues",showValues:r.showValues,cellBorderColor:r.cellBorderColor},o)},BarChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:null!==(n=r.sort)&&void 0!==n&&n,colorAccessor:e,colorScheme:i,barPadding:r.barPadding},null!=r.roundedTop&&{roundedTop:r.roundedTop}),o)}},StackedBarChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"bar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.stackBy,colorAccessor:e||r.stackBy,colorScheme:i,projection:"horizontal"===r.orientation?"horizontal":"vertical",normalize:r.normalize,oSort:null!==(n=r.sort)&&void 0!==n&&n},null!=r.roundedTop&&{roundedTop:r.roundedTop}),o)}},GroupedBarChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"clusterbar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",groupBy:r.groupBy,colorAccessor:e||r.groupBy,colorScheme:i,projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:null!==(n=r.sort)&&void 0!==n&&n,barPadding:r.barPadding},null!=r.roundedTop&&{roundedTop:r.roundedTop}),o)}},PieChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign(Object.assign({chartType:"pie",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",colorAccessor:e||r.categoryAccessor,colorScheme:i},null!=r.cornerRadius&&{cornerRadius:r.cornerRadius}),o)},DonutChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign(Object.assign({chartType:"donut",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",innerRadius:r.innerRadius||60,colorAccessor:e||r.categoryAccessor,colorScheme:i},null!=r.cornerRadius&&{cornerRadius:r.cornerRadius}),o)},Histogram:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"histogram",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"horizontal",bins:r.bins,colorAccessor:e,colorScheme:i},o)},BoxPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"boxplot",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorScheme:i},o)},ViolinPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"violin",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",bins:r.bins,colorScheme:i},o)},SwarmPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"swarm",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:e,colorScheme:i},o)},DotPlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n;return Object.assign(Object.assign({chartType:"point",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:e,colorScheme:i},o),{showGrid:null===(n=o.showGrid)||void 0===n||n})}},SwimlaneChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"swimlane",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.subcategoryAccessor,colorAccessor:e||r.subcategoryAccessor,categoryAccessor:r.categoryAccessor,subcategoryAccessor:r.subcategoryAccessor,colorScheme:i,projection:"horizontal"===r.orientation?"horizontal":"vertical"},o)},RidgelinePlot:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"ridgeline",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",bins:r.bins,amplitude:r.amplitude},o)},LikertChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"bar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.levelAccessor||"level",colorAccessor:e||r.levelAccessor||"level",colorScheme:i,normalize:!0,projection:"vertical"===r.orientation?"vertical":"horizontal"},o)},FunnelChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{const n="vertical"===r.orientation;return Object.assign({chartType:n?"bar-funnel":"funnel",data:t,oAccessor:r.stepAccessor||"step",rAccessor:r.valueAccessor||"value",colorAccessor:e||r.categoryAccessor,categoryAccessor:r.categoryAccessor,projection:n?"vertical":"horizontal",connectorAccessor:r.connectorAccessor,connectorStyle:r.connectorStyle,colorScheme:i},o)}},GaugeChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>{var n,s,a,c;const l=null!==(n=r.min)&&void 0!==n?n:0,u=null!==(s=r.max)&&void 0!==s?s:100,h=null!==(a=r.sweep)&&void 0!==a?a:240,d=null!==(c=r.arcWidth)&&void 0!==c?c:.3,f=180+(360-h)/2,g=r.thresholds||[{value:u,color:"#4e79a7"}],y=g.map((t,e)=>({category:t.label||"zone-"+e,value:t.value-(e>0?g[e-1].value:l)})),p={};g.forEach((t,e)=>{p[t.label||"zone-"+e]=t.color||"#4e79a7"});const m=o.margin||{top:20,right:20,bottom:30,left:40},[x,v]=o.size||[300,300];return Object.assign(Object.assign({chartType:"donut",data:y,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:Math.max(10,Math.min(x-(m.left||0)-(m.right||0),v-(m.top||0)-(m.bottom||0))/2*(1-d)),sweepAngle:h,startAngle:f,oSort:!1,pieceStyle:(t,e)=>({fill:p[e||""]||"#4e79a7"})},o),{showAxes:!1,__gauge:{gMin:l,gMax:u,sweep:h,arcWidth:d,value:r.value,startAngleDeg:f,thresholds:g}})}},ForceDirectedGraph:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"force",nodes:r.nodes,edges:r.edges,nodeIDAccessor:r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,colorBy:e,colorScheme:i,iterations:r.iterations,forceStrength:r.forceStrength,showLabels:r.showLabels,nodeLabel:r.nodeLabel,nodeSize:r.nodeSize,nodeSizeRange:r.nodeSizeRange,nodeStyle:r.nodeStyle,edgeStyle:r.edgeStyle},o)},SankeyDiagram:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"sankey",nodes:r.nodes,edges:r.edges,nodeIDAccessor:r.nodeIdAccessor||r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,valueAccessor:r.valueAccessor,orientation:r.orientation,nodeAlign:r.nodeAlign,nodeWidth:r.nodeWidth,nodePaddingRatio:r.nodePaddingRatio,showLabels:r.showLabels,nodeLabel:r.nodeLabel,colorBy:e,edgeColorBy:r.edgeColorBy,edgeOpacity:r.edgeOpacity,nodeStyle:r.nodeStyle,edgeStyle:r.edgeStyle,colorScheme:i},o)},ChordDiagram:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"chord",nodes:r.nodes,edges:r.edges,valueAccessor:r.valueAccessor,padAngle:r.padAngle,groupWidth:r.groupWidth,showLabels:r.showLabels,colorBy:e,edgeColorBy:r.edgeColorBy,colorScheme:i},o)},TreeDiagram:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"cluster"===r.layout?"cluster":"tree",data:t,childrenAccessor:r.childrenAccessor,colorBy:e,colorByDepth:r.colorByDepth,orientation:r.orientation,showLabels:r.showLabels,colorScheme:i},o)},Treemap:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"treemap",data:t,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:e,colorByDepth:r.colorByDepth,showLabels:r.showLabels,colorScheme:i},o)},CirclePack:{frameType:"network",buildProps:(t,e,i,o,r)=>Object.assign({chartType:"circlepack",data:t,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:e,colorByDepth:r.colorByDepth,colorScheme:i},o)},ChoroplethMap:{frameType:"geo",buildProps:(t,e,i,o,r)=>Object.assign({areas:r.areas,projection:r.projection||"equalEarth",areaStyle:r.areaStyle,valueAccessor:r.valueAccessor,colorScheme:i||"blues",graticule:r.graticule,fitPadding:r.fitPadding},o)},ProportionalSymbolMap:{frameType:"geo",buildProps:(t,e,i,o,r)=>Object.assign({points:t||r.points,xAccessor:r.xAccessor||"lon",yAccessor:r.yAccessor||"lat",areas:r.areas,areaStyle:r.areaStyle,sizeBy:r.sizeBy,colorBy:e,colorScheme:i,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding},o)},FlowMap:{frameType:"geo",buildProps:(t,e,i,o,r)=>{var n,s,a,c,l;const u=(Array.isArray(t)?t:null)||r.flows||[],h=r.nodeIdAccessor||"id",d=r.valueAccessor||"value",f=r.xAccessor||"lon",g=r.yAccessor||"lat",y="function"==typeof f?f:t=>t[f],p="function"==typeof g?g:t=>t[g],m=(r.nodes||[]).map(t=>Object.assign(Object.assign({},t),{x:y(t),y:p(t)})),x=new Map;for(const t of m)x.set(t[h]+"",t);const v=null!==(n=r.edgeColorBy)&&void 0!==n?n:e,b="function"==typeof v,k=u.map(t=>{if(!t||null==t.source||null==t.target)return null;const e=x.get(t.source+""),i=x.get(t.target+"");return e&&i?Object.assign(Object.assign({},t),{coordinates:[{x:e.x,y:e.y},{x:i.x,y:i.y}]}):null}).filter(Boolean),A="__flowMapEdgeColor",w=v?b?Q(k.map(t=>({[A]:v(t)})),A,i||"category10"):Q(k,v,i||"category10"):null,S=t=>v&&w?function(t,e,i){if("function"==typeof e){const o=e(t);return i&&o&&"string"==typeof o&&!function(t){const e=t.toLowerCase();return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")||H.has(e)}(o)?i(o):o}const o=(null==t?void 0:t[e])+"";return i?i(o):G[Math.abs(function(t){let e=0;for(let i=0;t.length>i;i++)e=(e<<5)-e+t.charCodeAt(i),e&=e;return Math.abs(e)}(o))%G.length]}(t,v,w):"#007bff";let _=1/0,P=-1/0;for(const t of k){const e=Number(null!==(s=t[d])&&void 0!==s?s:0);isFinite(e)&&(_>e&&(_=e),e>P&&(P=e))}const j=P>_?P-_:0,[M,O]=null!==(a=r.edgeWidthRange)&&void 0!==a?a:[1,8],L=O-M,E=null!==(c=r.edgeOpacity)&&void 0!==c?c:.6,T=null!==(l=r.edgeLinecap)&&void 0!==l?l:"round";return Object.assign({lines:k,points:m,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:r.lineType||"geo",flowStyle:r.flowStyle||"basic",areas:r.areas,areaStyle:r.areaStyle,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding,colorScheme:i,lineStyle:t=>{const e=Number(null==t?void 0:t[d]),i=M+Math.max(0,Math.min(1,j>0?((Number.isFinite(e)?e:_)-_)/j:0))*L;return{stroke:S(t),strokeWidth:i,strokeLinecap:T,opacity:E,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8})},o)}}},ni=Object.freeze([]);function si(t){if(!t)return ni;let e=!1;for(let i=0;t.length>i;i++){const o=t[i];if(null==o||"object"!=typeof o){e=!0;break}}if(!e)return t;const i=[];for(const e of t)null!=e&&"object"==typeof e&&i.push(e);return i}function ai(t){return Math.round(100*t)/100+""}function ci(e,i){const o=Ve(i.theme),r=i.idPrefix?i.idPrefix+"-":"",n="string"==typeof i.title?i.title:void 0,s=n?r+"semiotic-title":void 0,a=i.description?r+"semiotic-desc":void 0,c=[s,a].filter(Boolean).join(" ")||void 0;return t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:i.className,width:i.width,height:i.height,role:"img","aria-labelledby":c,style:{fontFamily:o.fontFamily},children:[n&&t.jsx("title",{id:s,children:n}),i.description&&t.jsx("desc",{id:a,children:i.description}),i.defs&&t.jsx("defs",{children:i.defs}),i.background&&"transparent"!==i.background&&t.jsx("rect",{x:0,y:0,width:i.width,height:i.height,fill:i.background}),t.jsx("g",{id:r+"data-area",transform:i.innerTransform,children:e}),n&&t.jsx("text",{id:r+"chart-title",x:i.width/2,y:16,textAnchor:"middle",fontSize:o.titleSize,fontWeight:"bold",fill:o.text,fontFamily:o.fontFamily,children:n}),i.legend&&t.jsx("g",{id:r+"legend",children:i.legend}),i.outerElements]})}function li(e){var i,o,r,n;const s=Ge(e.theme),a=e.size||[500,300],c=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),e.margin),l=si(e.data),u=e.legendPosition;e.showLegend&&(u&&"right"!==u?"left"===u?c.left=Math.max(c.left,100):"bottom"===u?c.bottom=Math.max(c.bottom,70):"top"===u&&(c.top=Math.max(c.top,40)):c.right=Math.max(c.right,100));const h=a[0]-c.left-c.right,d=a[1]-c.top-c.bottom,y="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),p={chartType:e.chartType,windowSize:null!==(i=e.windowSize)&&void 0!==i?i:200,windowMode:null!==(o=e.windowMode)&&void 0!==o?o:"sliding",arrowOfTime:y&&null!==(r=e.arrowOfTime)&&void 0!==r?r:"right",extentPadding:null!==(n=e.extentPadding)&&void 0!==n?n:.1,xAccessor:y?void 0:e.xAccessor,yAccessor:y?void 0:e.yAccessor,timeAccessor:y?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,groupAccessor:e.groupAccessor,categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,sizeRange:e.sizeRange,binSize:e.binSize,normalize:e.normalize,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,openAccessor:e.openAccessor,highAccessor:e.highAccessor,lowAccessor:e.lowAccessor,closeAccessor:e.closeAccessor,candlestickStyle:e.candlestickStyle,lineStyle:e.lineStyle,pointStyle:e.pointStyle,areaStyle:e.areaStyle,colorScheme:e.colorScheme||s.colors.categorical,barColors:e.barColors},m=new at(p);if(e.data&&m.ingest({inserts:l,bounded:!0}),m.computeScene({width:h,height:d}),!m.scales||0===m.scene.length)return g.renderToStaticMarkup(ci(null,{width:a[0],height:a[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:s,innerTransform:`translate(${c.left},${c.top})`,idPrefix:e._idPrefix}));const x=e._idPrefix,v=e.showGrid?function(e,i,o,r){const{grid:n}=Ve(o),s=r?r+"-":"",a=e.x.ticks(5),c=e.y.ticks(5);return t.jsxs("g",{id:s+"grid",className:"semiotic-grid",opacity:.8,children:[a.map((o,r)=>{const s=e.x(o);return t.jsx("line",{x1:s,y1:0,x2:s,y2:i.height,stroke:n,strokeWidth:.5},"gx-"+r)}),c.map((o,r)=>{const s=e.y(o);return t.jsx("line",{x1:0,y1:s,x2:i.width,y2:s,stroke:n,strokeWidth:.5},"gy-"+r)})]})}(m.scales,{width:h,height:d},s,x):null,b=m.scene.map((t,e)=>Ce(t,e,x)).filter(Boolean),k=!1!==e.showAxes?function(e,i,o,r,n){var s,a,c,l;const u=Ve(r),h=e.x.ticks(5).map(t=>({pixel:e.x(t),label:(o.xFormat||o.tickFormatTime||ai)(t)})),d=e.y.ticks(5).map(t=>({pixel:e.y(t),label:(o.yFormat||o.tickFormatValue||ai)(t)}));return t.jsxs("g",{id:(n?n+"-":"")+"axes",className:"stream-axes",children:[t.jsx("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:u.border,strokeWidth:1}),h.map((e,o)=>t.jsxs("g",{transform:`translate(${e.pixel},${i.height})`,children:[t.jsx("line",{y2:5,stroke:u.border,strokeWidth:1}),t.jsx("text",{y:18,textAnchor:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label})]},"xtick-"+o)),o.xLabel&&t.jsx("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,children:o.xLabel}),t.jsx("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:u.border,strokeWidth:1}),d.map((e,i)=>t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:u.border,strokeWidth:1}),t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label})]},"ytick-"+i)),o.yLabel&&t.jsx("text",{x:15-(null!==(a=null===(s=o.margin)||void 0===s?void 0:s.left)&&void 0!==a?a:40),y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-(null!==(l=null===(c=o.margin)||void 0===c?void 0:c.left)&&void 0!==l?l:40)}, ${i.height/2})`,children:o.yLabel})]})}(m.scales,{width:h,height:d},e,s,x):null,A=e.annotations?Je({annotations:e.annotations,scales:{x:m.scales.x,y:m.scales.y},layout:{width:h,height:d},theme:s,xAccessor:"string"==typeof e.xAccessor?e.xAccessor:void 0,yAccessor:"string"==typeof e.yAccessor?e.yAccessor:void 0,idPrefix:x}):null,w=e.showLegend?(()=>{const t=Qe(l,e.colorAccessor||e.groupAccessor);return 0===t.length?null:He({categories:t,colorScheme:e.colorScheme,theme:s,position:e.legendPosition||"right",totalWidth:a[0],totalHeight:a[1],margin:c,hasTitle:!!e.title})})():null,S=f.isValidElement(e.legend)?e.legend:w,_=t.jsxs(t.Fragment,{children:[e.backgroundGraphics,v,b,k,A,e.foregroundGraphics]});return g.renderToStaticMarkup(ci(_,{width:a[0],height:a[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:s,innerTransform:`translate(${c.left},${c.top})`,legend:S,idPrefix:e._idPrefix}))}function ui(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}const hi=new Set(["tree","cluster","treemap","circlepack","partition"]);function di(e){const i=Ge(e.theme),o=e.chartType||"force",r=e.size||[500,500],n=Object.assign(Object.assign({},{top:20,right:20,bottom:20,left:20}),e.margin),s=e.legendPosition;e.showLegend&&(s&&"right"!==s?"left"===s?n.left=Math.max(n.left,100):"bottom"===s?n.bottom=Math.max(n.bottom,70):"top"===s&&(n.top=Math.max(n.top,40)):n.right=Math.max(n.right,100));const a=r[0]-n.left-n.right,c=r[1]-n.top-n.bottom,u=function(t){return be[t]}(o);if(!u)throw Error(`No layout plugin found for chart type: "${o}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const h={chartType:o,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,colorBy:e.colorBy,colorScheme:e.colorScheme||i.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange};let d,y;if(hi.has(o)){const t=e.data||e.edges;if(!t||Array.isArray(t))return g.renderToStaticMarkup(ci(null,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,idPrefix:e._idPrefix}));h.__hierarchyRoot=t,d=[],y=[]}else{const t=si(e.nodes||[]),o=Array.isArray(e.edges)?si(e.edges):[];if(0===t.length&&0===o.length)return g.renderToStaticMarkup(ci(null,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,idPrefix:e._idPrefix}));if(y=function(t,e){const i=ui(e.sourceAccessor,"source"),o=ui(e.targetAccessor,"target"),r=ui(e.valueAccessor,"value");return t.map(t=>({source:i(t)+"",target:o(t)+"",value:Number(r(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(o,h),0===t.length&&y.length>0){const t=new Set;for(const e of y){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)}d=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 d=function(t,e){const i=ui(e.nodeIDAccessor,"id");return t.map(t=>{var e,o;return{id:i(t)+"",x:null!==(e=t.x)&&void 0!==e?e:0,y:null!==(o=t.y)&&void 0!==o?o:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}})}(t,h)}u.computeLayout(d,y,h,[a,c]);const{sceneNodes:p,sceneEdges:m,labels:x}=u.buildScene(d,y,h,[a,c]),v=Ve(i);for(const t of x)t.fill||(t.fill=v.text);const b=m.map((e,i)=>function(e,i){switch(e.type){case"line":return t.jsx("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+i);case"bezier":{const o=e;return t.jsx("path",{d:o.pathD,fill:Re(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+i)}case"ribbon":{const o=e;return t.jsx("path",{d:o.pathD,fill:Re(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+i)}case"curved":{const o=e;return t.jsx("path",{d:o.pathD,fill:Re(o.style.fill,"none"),stroke:o.style.stroke||"#999",strokeWidth:o.style.strokeWidth||1,opacity:o.style.opacity},"net-edge-"+i)}default:return null}}(e,i)).filter(Boolean),k=p.map((e,i)=>function(e,i){switch(e.type){case"circle":{const o=e;return t.jsx("circle",{cx:o.cx,cy:o.cy,r:o.r,fill:Re(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-circle-"+i)}case"rect":{const o=e;return t.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:Re(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-rect-"+i)}case"arc":{const o=e,r=l.arc().innerRadius(o.innerR).outerRadius(o.outerR).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2)($e)||"";return t.jsx("path",{d:r,transform:`translate(${o.cx},${o.cy})`,fill:Re(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-arc-"+i)}default:return null}}(e,i)).filter(Boolean),A=x.map((e,i)=>function(e,i){return t.jsx("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"#333",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+i)}(e,i)).filter(Boolean),w=e.annotations?Je({annotations:e.annotations,scales:{},layout:{width:a,height:c},theme:i,idPrefix:e._idPrefix}):null,S=e.showLegend?(()=>{const t=t=>"string"==typeof t||"function"==typeof t,o=t(e.colorBy)?e.colorBy:t(e.nodeIDAccessor)?e.nodeIDAccessor:void 0,s=Qe(d.length>0?d.map(t=>t.data||{id:t.id}):Array.from(new Set(y.flatMap(t=>{var e,i;return["string"==typeof t.source?t.source:null===(e=t.source)||void 0===e?void 0:e.id,"string"==typeof t.target?t.target:null===(i=t.target)||void 0===i?void 0:i.id]}).filter(Boolean))).map(t=>({id:t})),o);return 0===s.length?null:He({categories:s,colorScheme:e.colorScheme,theme:i,position:e.legendPosition||"right",totalWidth:r[0],totalHeight:r[1],margin:n,hasTitle:!!e.title})})():null,_=f.isValidElement(e.legend)?e.legend:S,P=t.jsxs(t.Fragment,{children:[e.backgroundGraphics,b,k,A,w,e.foregroundGraphics]});return g.renderToStaticMarkup(ci(P,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${n.left},${n.top})`,legend:_,idPrefix:e._idPrefix}))}function fi(e){var i,o,r,n,s;const a=Ge(e.theme),c=e.size||[500,400],l=Object.assign(Object.assign({},{top:20,right:20,bottom:30,left:40}),e.margin),u=si(e.data),h=e.legendPosition;e.showLegend&&(h&&"right"!==h?"left"===h?l.left=Math.max(l.left,100):"bottom"===h?l.bottom=Math.max(l.bottom,70):"top"===h&&(l.top=Math.max(l.top,40)):l.right=Math.max(l.right,100));const d=c[0]-l.left-l.right,y=c[1]-l.top-l.bottom,p=e.projection||"vertical",m="radial"===p,x={chartType:e.chartType,windowSize:null!==(i=e.windowSize)&&void 0!==i?i:1e4,windowMode:null!==(o=e.windowMode)&&void 0!==o?o:"sliding",extentPadding:null!==(r=e.extentPadding)&&void 0!==r?r:.05,projection:p,oAccessor:e.oAccessor,rAccessor:e.rAccessor,colorAccessor:e.colorAccessor,stackBy:e.stackBy,groupBy:e.groupBy,categoryAccessor:e.categoryAccessor,valueAccessor:e.valueAccessor,timeAccessor:e.timeAccessor,rExtent:e.rExtent,oExtent:e.oExtent,barPadding:e.barPadding,roundedTop:e.roundedTop,innerRadius:e.innerRadius,cornerRadius:e.cornerRadius,normalize:e.normalize,startAngle:e.startAngle,sweepAngle:e.sweepAngle,bins:e.bins,showOutliers:e.showOutliers,showIQR:e.showIQR,amplitude:e.amplitude,oSort:e.oSort,connectorAccessor:e.connectorAccessor,connectorStyle:e.connectorStyle,dynamicColumnWidth:e.dynamicColumnWidth,pieceStyle:e.pieceStyle,summaryStyle:e.summaryStyle,colorScheme:e.colorScheme||a.colors.categorical,barColors:e.barColors},v=new _e(x);if(e.data&&v.ingest({inserts:u,bounded:!0}),v.computeScene({width:d,height:y}),!v.scales||0===v.scene.length)return g.renderToStaticMarkup(ci(null,{width:c[0],height:c[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:a,innerTransform:`translate(${l.left},${l.top})`,idPrefix:e._idPrefix}));const b=e._idPrefix,k=e.showGrid?function(e,i,o,r){const n=e.scales;if(!n||"radial"===n.projection)return null;const{grid:s}=Ve(o),a=r?r+"-":"",c="vertical"===n.projection,l=n.r.ticks(5);return t.jsx("g",c?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,o)=>{const r=n.r(e);return t.jsx("line",{x1:0,y1:r,x2:i.width,y2:r,stroke:s,strokeWidth:.5},"gr-"+o)})}:{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,o)=>{const r=n.r(e);return t.jsx("line",{x1:r,y1:0,x2:r,y2:i.height,stroke:s,strokeWidth:.5},"gr-"+o)})})}(v,{width:d,height:y},a,b):null,A=v.scene.some(t=>{var e;return"rect"===t.type&&(null===(e=t.datum)||void 0===e?void 0:e.__barFunnelIsDropoff)});let w=null;if(A){const i=function(t){const e=t._idPrefix||t.chartId;if(e){const t=(e+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(t)?t:"c"+t}const i=`${t.chartType||""}:${t.title||""}:${Array.isArray(t.data)?t.data.length:0}`;let o=0;for(let t=0;i.length>t;t++)o=31*o+i.charCodeAt(t)|0;return"c"+(o>>>0).toString(36)}(e),o=new Set;for(const t of v.scene)"rect"===t.type&&(null===(n=t.datum)||void 0===n?void 0:n.__barFunnelIsDropoff)&&o.add("string"==typeof t.style.fill?t.style.fill:"#666");w=Array.from(o).map((e,o)=>function(e){const{id:i,background:o="transparent",stroke:r="#000",lineWidth:n=1.5,spacing:s=6,angle:a=45}=e,c=Math.max(8,Math.ceil(2*s));return t.jsxs("pattern",{id:i,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==a?`rotate(${a})`:void 0,children:[o&&"transparent"!==o&&t.jsx("rect",{width:c,height:c,fill:o}),t.jsx("line",{x1:0,y1:0,x2:0,y2:c,stroke:r,strokeWidth:n}),t.jsx("line",{x1:s,y1:0,x2:s,y2:c,stroke:r,strokeWidth:n})]},i)}({id:`funnel-hatch-${i}-${o}`,background:e,stroke:"transparent"===a.colors.background?"#fff":a.colors.background,lineWidth:1.5,spacing:5,angle:45}));const r=new Map;Array.from(o).forEach((t,e)=>r.set(t,`funnel-hatch-${i}-${e}`));for(const t of v.scene)if("rect"===t.type&&(null===(s=t.datum)||void 0===s?void 0:s.__barFunnelIsDropoff)){const e="string"==typeof t.style.fill?t.style.fill:"#666";t.style=Object.assign(Object.assign({},t.style),{fill:`url(#${r.get(e)})`})}}const S=v.scene.map((t,e)=>Ne(t,e)).filter(Boolean),_=!1!==e.showAxes?function(e,i,o,r,n){var s,a,c,l,u,h,d,f;const g=e.scales;if(!g)return null;if("radial"===g.projection)return null;const y=Ve(r),p="vertical"===g.projection,m=o.categoryFormat||o.oFormat,x=o.valueFormat||o.rFormat,v=o.categoryLabel||o.oLabel,b=o.valueLabel||o.rLabel,k=Object.values(e.columns).map(t=>({pixel:t.middle,label:(m||String)(t.name)})),A=g.r.ticks(5).map(t=>({pixel:g.r(t),label:(x||ai)(t)}));return t.jsxs("g",p?{id:(n?n+"-":"")+"axes",className:"ordinal-axes",children:[t.jsx("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:y.border,strokeWidth:1}),k.map((e,o)=>t.jsxs("g",{transform:`translate(${e.pixel},${i.height})`,children:[t.jsx("line",{y2:5,stroke:y.border,strokeWidth:1}),t.jsx("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:e.label})]},"oxtick-"+o)),v&&t.jsx("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,children:v}),t.jsx("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:y.border,strokeWidth:1}),A.map((e,i)=>t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:y.border,strokeWidth:1}),t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:e.label})]},"oytick-"+i)),b&&t.jsx("text",{x:15-(null!==(a=null===(s=o.margin)||void 0===s?void 0:s.left)&&void 0!==a?a:40),y:i.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(l=null===(c=o.margin)||void 0===c?void 0:c.left)&&void 0!==l?l:40)}, ${i.height/2})`,children:b})]}:{id:(n?n+"-":"")+"axes",className:"ordinal-axes",children:[t.jsx("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:y.border,strokeWidth:1}),A.map((e,o)=>t.jsxs("g",{transform:`translate(${e.pixel},${i.height})`,children:[t.jsx("line",{y2:5,stroke:y.border,strokeWidth:1}),t.jsx("text",{y:18,textAnchor:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:e.label})]},"oxtick-"+o)),b&&t.jsx("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,children:b}),t.jsx("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:y.border,strokeWidth:1}),k.map((e,i)=>t.jsxs("g",{transform:`translate(0,${e.pixel})`,children:[t.jsx("line",{x2:-5,stroke:y.border,strokeWidth:1}),t.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:y.tickSize,fill:y.textSecondary,fontFamily:y.fontFamily,children:e.label})]},"oytick-"+i)),v&&t.jsx("text",{x:15-(null!==(h=null===(u=o.margin)||void 0===u?void 0:u.left)&&void 0!==h?h:40),y:i.height/2,textAnchor:"middle",fontSize:y.labelSize,fill:y.text,fontFamily:y.fontFamily,transform:`rotate(-90, ${15-(null!==(f=null===(d=o.margin)||void 0===d?void 0:d.left)&&void 0!==f?f:40)}, ${i.height/2})`,children:v})]})}(v,{width:d,height:y},e,a,b):null,P=e.annotations?Je({annotations:e.annotations,scales:{r:v.scales.r,y:"vertical"===v.scales.projection?v.scales.r:void 0},layout:{width:d,height:y},theme:a,projection:p,idPrefix:b}):null,j=e.showLegend?(()=>{const t=Qe(u,e.colorAccessor||e.stackBy||e.groupBy);return 0===t.length?null:He({categories:t,colorScheme:e.colorScheme,theme:a,position:e.legendPosition||"right",totalWidth:c[0],totalHeight:c[1],margin:l,hasTitle:!!e.title})})():null,M=f.isValidElement(e.legend)?e.legend:j,O=m?l.left+d/2:l.left,L=m?l.top+y/2:l.top,E=t.jsxs(t.Fragment,{children:[e.backgroundGraphics,k,S,_,P,e.foregroundGraphics]});return g.renderToStaticMarkup(ci(E,{width:c[0],height:c[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:a,innerTransform:`translate(${O},${L})`,legend:M,defs:w,idPrefix:e._idPrefix}))}function gi(e){var i,o,r,n,s,a,c,l,u,h,d,y,p,m;const x=Ge(e.theme),v=e.size||[e.width||600,e.height||400],b=Object.assign(Object.assign({},{top:10,right:10,bottom:10,left:10}),e.margin),k=Array.isArray(e.areas)?si(e.areas):e.areas,A=si(e.points),w=si(e.lines),S=e.legendPosition;e.showLegend&&(S&&"right"!==S?"left"===S?b.left=Math.max(null!==(o=b.left)&&void 0!==o?o:0,100):"bottom"===S?b.bottom=Math.max(null!==(r=b.bottom)&&void 0!==r?r:0,70):"top"===S&&(b.top=Math.max(null!==(n=b.top)&&void 0!==n?n:0,40)):b.right=Math.max(null!==(i=b.right)&&void 0!==i?i:0,100));const _=v[0]-(null!==(s=b.left)&&void 0!==s?s:0)-(null!==(a=b.right)&&void 0!==a?a:0),P=v[1]-(null!==(c=b.top)&&void 0!==c?c:0)-(null!==(l=b.bottom)&&void 0!==l?l:0),j=new ze({projection:e.projection||"equalEarth",xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineType:e.lineType,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform});if(k){if("string"==typeof k)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${k}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${k}')\` before calling renderGeoToStaticSVG.`);j.setAreas(k)}if(e.points&&j.setPoints(A),e.lines&&j.setLines(w),j.computeScene({width:_,height:P}),0===j.scene.length){const i=e.backgroundGraphics||e.foregroundGraphics||e.annotations?t.jsxs(t.Fragment,{children:[e.backgroundGraphics,e.annotations?Je({annotations:e.annotations,scales:{geoProjection:(null===(u=j.scales)||void 0===u?void 0:u.projectedPoint)?([t,e])=>j.scales.projectedPoint(t,e):void 0},layout:{width:_,height:P},theme:x,idPrefix:e._idPrefix}):null,e.foregroundGraphics]}):null;return g.renderToStaticMarkup(ci(i,{width:v[0],height:v[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:x,innerTransform:`translate(${null!==(h=b.left)&&void 0!==h?h:0},${null!==(d=b.top)&&void 0!==d?d:0})`,idPrefix:e._idPrefix}))}const M=j.scene.map((e,i)=>function(e,i){var o,r,n,s,a,c;switch(e.type){case"geoarea":{const n=e;return n.pathData?t.jsx("path",{d:n.pathData,fill:Re(n.style.fill,"#e0e0e0"),fillOpacity:null!==(o=n.style.fillOpacity)&&void 0!==o?o:1,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth||.5,strokeDasharray:n.style.strokeDasharray,opacity:null!==(r=n._decayOpacity)&&void 0!==r?r:1},"geoarea-"+i):null}case"point":{const o=e;return t.jsx("circle",{cx:o.x,cy:o.y,r:o.r,fill:Re(o.style.fill),fillOpacity:null!==(n=o.style.fillOpacity)&&void 0!==n?n:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:null!==(s=o._decayOpacity)&&void 0!==s?s:null!==(a=o.style.opacity)&&void 0!==a?a:1},"point-"+i)}case"line":{const o=e;if(2>o.path.length)return null;const r="M"+o.path.map(t=>`${t[0]},${t[1]}`).join("L");return t.jsx("path",{d:r,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||1.5,strokeDasharray:o.style.strokeDasharray,opacity:null!==(c=o.style.opacity)&&void 0!==c?c:1},"line-"+i)}default:return null}}(e,i)).filter(Boolean),O=e.annotations?Je({annotations:e.annotations,scales:{geoProjection:(null===(y=j.scales)||void 0===y?void 0:y.projectedPoint)?([t,e])=>j.scales.projectedPoint(t,e):void 0},layout:{width:_,height:P},theme:x,idPrefix:e._idPrefix}):null,L=e.showLegend?(()=>{const t="string"==typeof(i=e.colorBy)||"function"==typeof i?e.colorBy:void 0;var i;const o=Qe(A.length>0?A:Array.isArray(k)&&k.length>0?"string"==typeof t?k.map(t=>Object.assign(Object.assign({},t.properties||{}),t)):k:[],t);return 0===o.length?null:He({categories:o,colorScheme:e.colorScheme,theme:x,position:e.legendPosition||"right",totalWidth:v[0],totalHeight:v[1],margin:b,hasTitle:!!e.title})})():null,E=f.isValidElement(e.legend)?e.legend:L,T=t.jsxs(t.Fragment,{children:[e.backgroundGraphics,M,O,e.foregroundGraphics]});return g.renderToStaticMarkup(ci(T,{width:v[0],height:v[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:x,innerTransform:`translate(${null!==(p=b.left)&&void 0!==p?p:0},${null!==(m=b.top)&&void 0!==m?m:0})`,legend:E,idPrefix:e._idPrefix}))}function yi(t,e){switch(t){case"xy":return li(e);case"ordinal":return fi(e);case"network":return di(e);case"geo":return gi(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", or "geo".`)}}function pi(e,i,o){var r;const{data:n,width:s=600,height:a=400,theme:c,title:l,description:u,showLegend:h,showGrid:d,background:f,className:y,annotations:p,margin:m,colorScheme:x,colorBy:v,legendPosition:b}=i,k=function(t,e){var i={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&0>e.indexOf(o)&&(i[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);o.length>r;r++)0>e.indexOf(o[r])&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(i[o[r]]=t[o[r]])}return i}(i,["data","width","height","theme","title","description","showLegend","showGrid","background","className","annotations","margin","colorScheme","colorBy","legendPosition"]),A=[s,a],w=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},k.frameProps||{}),{theme:c,title:l,description:u,showLegend:h,showGrid:d,background:f,className:y,annotations:p,size:A}),void 0!==m&&{margin:m}),void 0!==x&&{colorScheme:x}),void 0!==b&&{legendPosition:b}),{_idPrefix:k._idPrefix}),S=ri[e];if(!S)throw Error(`Unknown chart component: "${e}". See CLAUDE.md for supported chart types.`);const _=S.buildProps(n,v,x,w,k);let P=(0,{xy:li,ordinal:fi,network:di,geo:gi}[S.frameType])(_);if("GaugeChart"===e&&_.__gauge){const e=_.__gauge,i=w.margin||{top:20,right:20,bottom:30,left:40},o=(s||300)-i.left-i.right,n=(a||300)-i.top-i.bottom,l=Math.min(o,n)/2*.85,u=i.left+o/2,h=i.top+n/2,d=Math.max(e.gMin,Math.min(e.gMax,null!==(r=e.value)&&void 0!==r?r:e.gMin)),f=(e.startAngleDeg+(e.gMax===e.gMin?0:(d-e.gMin)/(e.gMax-e.gMin))*e.sweep-90)*Math.PI/180,y=Ge(c).colors.text,p=g.renderToStaticMarkup(t.jsxs(t.Fragment,{children:[t.jsx("line",{x1:u,y1:h,x2:u+l*Math.cos(f),y2:h+l*Math.sin(f),stroke:y,strokeWidth:2.5,strokeLinecap:"round"}),t.jsx("circle",{cx:u,cy:h,r:4,fill:y})]}));P=P.replace("</svg>",p+"</svg>")}return P}function mi(t,e,i,o={}){const{stepSize:r,windowSize:n,frameCount:s,xExtent:a,yExtent:c,transitionFrames:l=4,fps:u=12,easing:h="ease-out",decay:d}=o,f=i.width||600,g=i.height||400,y=Ge(i.theme),p=Object.assign(Object.assign(Object.assign({},i),a&&{xExtent:a}),c&&{yExtent:c});if(!e||0===e.length)return[];const m=r||Math.max(1,Math.ceil(e.length/(s||Math.min(60,Math.max(10,e.length))))),x=[];for(let t=m;e.length>=t;t+=m)x.push(t);x[x.length-1]!==e.length&&x.push(e.length);const v=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(t),b=Object.assign({top:20,right:20,bottom:30,left:40},i.margin),k=f-b.left-b.right,A=g-b.top-b.bottom,w=[];if(v)for(let o=0;x.length>o;o++){const r=x[o],s=e.slice(n?Math.max(0,r-n):0,r),a=Object.assign({chartType:t,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:i.projection||"vertical",oAccessor:i.oAccessor||i.categoryAccessor||"category",rAccessor:i.rAccessor||i.valueAccessor||"value",colorAccessor:i.colorAccessor||i.colorBy,stackBy:i.stackBy,groupBy:i.groupBy,barPadding:i.barPadding,innerRadius:i.innerRadius,normalize:i.normalize,bins:i.bins,colorScheme:i.colorScheme||y.colors.categorical},d&&{decay:d}),c=new _e(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:k,height:A}),c.scene.length>0&&w.push(bi(c.scene,f,g,y,p))}else for(let o=0;x.length>o;o++){const r=x[o],s=e.slice(n?Math.max(0,r-n):0,r),m=Object.assign(Object.assign({chartType:t,windowSize:s.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:i.colorAccessor||i.colorBy,groupAccessor:i.groupAccessor||i.lineBy,lineDataAccessor:i.lineDataAccessor,xExtent:a,yExtent:c,colorScheme:i.colorScheme||y.colors.categorical,lineStyle:i.lineStyle,pointStyle:i.pointStyle,areaStyle:i.areaStyle,sizeAccessor:i.sizeAccessor||i.sizeBy,sizeRange:i.sizeRange},d&&{decay:d}),l>0&&{transition:{duration:l*(1e3/u),easing:h}}),v=new at(m);if(v.ingest({inserts:s,bounded:!0}),v.computeScene({width:k,height:A}),0===v.scene.length)continue;const b=v.scales?{y:v.scales.y}:void 0;if(w.push(vi(v.scene,f,g,y,p,b)),l>0&&o>0&&v.activeTransition){const t=l*(1e3/u);for(let e=1;l>=e;e++)v.advanceTransition(v.activeTransition.startTime+e/l*t),w.push(vi(v.scene,f,g,y,p,b))}}return w}function xi(t,e){const i=t.background||e.colors.background;return i&&"transparent"!==i?i:null}function vi(e,i,o,r,n,s){const a=Ve(r),c=Object.assign({top:20,right:20,bottom:30,left:40},n.margin),l=i-c.left-c.right,u=o-c.top-c.bottom,h=xi(n,r),d=e.map((t,e)=>Ce(t,e)).filter(Boolean),f=function(e,i,o,r,n,s){var a;if(!e||0===e.length)return null;const c=Ve(r),l=[];for(let r=0;e.length>r;r++){const u=e[r];if("y-threshold"===u.type&&null!=u.value){let e=null;if(s)e=s(u.value);else if(n){const[t,i]=n,r=i-t;if(0===r)continue;e=o-(u.value-t)/r*o}if(null==e)continue;const h=u.color||c.primary,d=null!==(a=u.strokeWidth)&&void 0!==a?a:1.5,f=u.labelPosition||"right";l.push(t.jsxs("g",{children:[t.jsx("line",{x1:0,y1:e,x2:i,y2:e,stroke:h,strokeWidth:d,strokeDasharray:u.strokeDasharray||"6,4"}),u.label&&t.jsx("text",{x:"left"===f?4:"center"===f?i/2:i-4,y:e-5,textAnchor:"left"===f?"start":"center"===f?"middle":"end",fontSize:c.tickSize,fill:h,fontFamily:c.fontFamily,children:u.label})]},"ann-"+r))}}return l.length>0?t.jsx(t.Fragment,{children:l}):null}(n.annotations,l,u,r,n.yExtent,null==s?void 0:s.y),y="string"==typeof n.title?n.title:void 0,p="string"==typeof n.description?n.description:void 0,m=y?"semiotic-title":void 0,x=p?"semiotic-desc":void 0,v=[m,x].filter(Boolean).join(" ")||void 0,b=t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:i,height:o,role:"img","aria-labelledby":v,style:{fontFamily:a.fontFamily},children:[y&&t.jsx("title",{id:m,children:y}),p&&t.jsx("desc",{id:x,children:p}),h&&t.jsx("rect",{x:0,y:0,width:i,height:o,fill:h}),t.jsxs("g",{transform:`translate(${c.left},${c.top})`,children:[f,d]}),y&&t.jsx("text",{x:i/2,y:16,textAnchor:"middle",fontSize:a.titleSize,fontWeight:"bold",fill:a.text,fontFamily:a.fontFamily,children:y})]});return g.renderToStaticMarkup(b)}function bi(e,i,o,r,n){const s=Ve(r),a=Object.assign({top:20,right:20,bottom:30,left:40},n.margin),c="radial"===n.projection,l=c?a.left+(i-a.left-a.right)/2:a.left,u=c?a.top+(o-a.top-a.bottom)/2:a.top,h=xi(n,r),d=e.map((t,e)=>Ne(t,e)).filter(Boolean),f="string"==typeof n.title?n.title:void 0,y="string"==typeof n.description?n.description:void 0,p=f?"semiotic-title":void 0,m=y?"semiotic-desc":void 0,x=[p,m].filter(Boolean).join(" ")||void 0,v=t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:i,height:o,role:"img","aria-labelledby":x,style:{fontFamily:s.fontFamily},children:[f&&t.jsx("title",{id:p,children:f}),y&&t.jsx("desc",{id:m,children:y}),h&&t.jsx("rect",{x:0,y:0,width:i,height:o,fill:h}),t.jsx("g",{transform:`translate(${l},${u})`,children:d}),f&&t.jsx("text",{x:i/2,y:16,textAnchor:"middle",fontSize:s.titleSize,fontWeight:"bold",fill:s.text,fontFamily:s.fontFamily,children:f})]});return g.renderToStaticMarkup(v)}exports.generateFrameSVGs=mi,exports.generateFrameSequence=function(t,e,i={}){return e.map(e=>{try{return pi(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=pi,exports.renderDashboard=function(e,i={}){var o;const{title:r,subtitle:n,theme:s,width:a=1200,height:c,layout:l={},background:u}=i,h=Ve(Ge(s)),d=l.columns||2,f=null!==(o=l.gap)&&void 0!==o?o:16;let y=0;r&&(y+=30),n&&(y+=20),y>0&&(y+=10);const p=Math.floor((a-f-f*(d-1))/d),m=[];let x=0,v=y+f,b=0;for(const t of e){const e=Math.min(t.colSpan||1,d),i=t.props.height||300;x+e>d&&(v+=b+f,x=0,b=0),m.push({chart:t,x:f/2+x*(p+f),y:v,w:p*e+f*(e-1),h:i}),b=Math.max(b,i),x+=e}const k=c||v+b+f,A=m.map((e,i)=>{const{chart:o,x:r,y:n,w:a,h:c}=e,l=Object.assign(Object.assign({},o.props),{width:a,height:c,theme:s,_idPrefix:"chart-"+i});let u;return u=o.component?pi(o.component,l):o.frameType?yi(o.frameType,l):`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${c}"></svg>`,t.jsx("g",{transform:`translate(${r},${n})`,children:t.jsx("foreignObject",{width:a,height:c,children:t.jsx("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:u}})})},"dashboard-chart-"+i)}),w=t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:a,height:k,role:"img","aria-label":r||"Dashboard",style:{fontFamily:h.fontFamily},children:[r&&t.jsx("title",{children:r}),u&&t.jsx("rect",{x:0,y:0,width:a,height:k,fill:u}),r&&t.jsx("text",{x:a/2,y:24,textAnchor:"middle",fontSize:h.titleSize+4,fontWeight:"bold",fill:h.text,fontFamily:h.fontFamily,children:r}),n&&t.jsx("text",{x:a/2,y:r?46:20,textAnchor:"middle",fontSize:h.labelSize,fill:h.textSecondary,fontFamily:h.fontFamily,children:n}),A]});return g.renderToStaticMarkup(w)},exports.renderGeoToStaticSVG=function(t){return gi(t)},exports.renderNetworkToStaticSVG=function(t){return di(t)},exports.renderOrdinalToStaticSVG=function(t){return fi(t)},exports.renderToAnimatedGif=function(t,e,i){return y(this,arguments,void 0,function*(t,e,i,o={}){var r,n,s,a,c,l,u,h,d,f,g,y,p,m,x,v;const{fps:b=12,loop:k=!0,scale:A=1,background:w}=o,S=i.height||400,_=Math.round((i.width||600)*A),P=Math.round(S*A),j=mi(t,e,w?Object.assign(Object.assign({},i),{background:w}):i,o);if(0===j.length)throw Error("No frames generated — check that data is not empty");let M,O,L,E;try{const t="sharp",e=yield import(t);M=null!==(r=e.default)&&void 0!==r?r:e}catch(t){throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t="gifenc",e=yield import(t);O=null!==(a=null!==(n=e.GIFEncoder)&&void 0!==n?n:null===(s=e.default)||void 0===s?void 0:s.GIFEncoder)&&void 0!==a?a:null===(l=null===(c=e.default)||void 0===c?void 0:c.default)||void 0===l?void 0:l.GIFEncoder,L=null!==(d=null!==(u=e.quantize)&&void 0!==u?u:null===(h=e.default)||void 0===h?void 0:h.quantize)&&void 0!==d?d:null===(g=null===(f=e.default)||void 0===f?void 0:f.default)||void 0===g?void 0:g.quantize,E=null!==(m=null!==(y=e.applyPalette)&&void 0!==y?y:null===(p=e.default)||void 0===p?void 0:p.applyPalette)&&void 0!==m?m:null===(v=null===(x=e.default)||void 0===x?void 0:x.default)||void 0===v?void 0:v.applyPalette}catch(t){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc')}const T=Math.round(1e3/b),D=O();for(let t=0;j.length>t;t++){const e=j[t],i=yield M(Buffer.from(e),{density:72*A}).resize(_,P).ensureAlpha().raw().toBuffer(),o=new Uint8Array(i),r=L(o,256),n=E(o,r);D.writeFrame(n,_,P,{palette:r,delay:T,repeat:k?0:-1})}return D.finish(),Buffer.from(D.bytes())})},exports.renderToImage=function(t,e){return y(this,arguments,void 0,function*(t,e,i={}){var o,r,n;const{format:s="png",scale:a=1,background:c}=i;let l,u;l=["xy","ordinal","network","geo"].includes(t)?yi(t,e):pi(t,e),c&&(l=l.replace(/<svg /,`<svg style="background:${c}" `));try{const t="sharp",e=yield import(t);u=null!==(o=e.default)&&void 0!==o?o:e}catch(t){throw Error('Image export requires the "sharp" package and a Node.js runtime. Install it:\n npm install sharp\nsharp is listed as an optional dependency of semiotic.')}const h=e.width||(null===(r=e.size)||void 0===r?void 0:r[0])||600,d=e.height||(null===(n=e.size)||void 0===n?void 0:n[1])||400,f=u(void 0!==globalThis.Buffer?globalThis.Buffer.from(l):(new TextEncoder).encode(l),{density:72*a}).resize(Math.round(h*a),Math.round(d*a));return"jpeg"===s?f.jpeg({quality:90}).toBuffer():f.png().toBuffer()})},exports.renderToStaticSVG=yi,exports.renderXYToStaticSVG=function(t){return li(t)},exports.resolveTheme=Ge,exports.themeStyles=Ve;