semiotic 3.0.0 → 3.1.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 (219) hide show
  1. package/CLAUDE.md +242 -29
  2. package/README.md +101 -66
  3. package/ai/cli.js +34 -21
  4. package/ai/dist/componentRegistry.js +2 -0
  5. package/ai/dist/mcp-server.js +54 -0
  6. package/ai/examples.md +433 -18
  7. package/ai/schema.json +134 -1
  8. package/ai/system-prompt.md +51 -10
  9. package/dist/{ChartGrid.d.ts → components/ChartGrid.d.ts} +9 -7
  10. package/dist/components/Legend.d.ts +9 -0
  11. package/dist/{LinkedCharts.d.ts → components/LinkedCharts.d.ts} +34 -1
  12. package/dist/{Tooltip → components/Tooltip}/Tooltip.d.ts +9 -2
  13. package/dist/components/charts/geo/ChoroplethMap.d.ts +53 -0
  14. package/dist/components/charts/geo/DistanceCartogram.d.ts +90 -0
  15. package/dist/components/charts/geo/FlowMap.d.ts +83 -0
  16. package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +67 -0
  17. package/dist/components/charts/geo/index.d.ts +8 -0
  18. package/dist/{charts → components/charts}/index.d.ts +4 -0
  19. package/dist/{charts → components/charts}/network/ChordDiagram.d.ts +8 -5
  20. package/dist/{charts → components/charts}/network/CirclePack.d.ts +4 -2
  21. package/dist/{charts → components/charts}/network/ForceDirectedGraph.d.ts +10 -6
  22. package/dist/components/charts/network/OrbitDiagram.d.ts +79 -0
  23. package/dist/{charts → components/charts}/network/SankeyDiagram.d.ts +8 -5
  24. package/dist/{charts → components/charts}/network/TreeDiagram.d.ts +4 -2
  25. package/dist/{charts → components/charts}/network/Treemap.d.ts +4 -2
  26. package/dist/{charts → components/charts}/ordinal/BarChart.d.ts +9 -5
  27. package/dist/{charts → components/charts}/ordinal/BoxPlot.d.ts +9 -5
  28. package/dist/{charts → components/charts}/ordinal/DonutChart.d.ts +9 -5
  29. package/dist/{charts → components/charts}/ordinal/DotPlot.d.ts +9 -5
  30. package/dist/{charts → components/charts}/ordinal/GroupedBarChart.d.ts +9 -5
  31. package/dist/{charts → components/charts}/ordinal/Histogram.d.ts +8 -5
  32. package/dist/{charts → components/charts}/ordinal/PieChart.d.ts +9 -5
  33. package/dist/{charts → components/charts}/ordinal/RidgelinePlot.d.ts +2 -0
  34. package/dist/{charts → components/charts}/ordinal/StackedBarChart.d.ts +9 -5
  35. package/dist/{charts → components/charts}/ordinal/SwarmPlot.d.ts +9 -5
  36. package/dist/{charts → components/charts}/ordinal/ViolinPlot.d.ts +8 -5
  37. package/dist/{charts → components/charts}/realtime/RealtimeHeatmap.d.ts +24 -6
  38. package/dist/{charts → components/charts}/realtime/RealtimeHistogram.d.ts +28 -7
  39. package/dist/{charts → components/charts}/realtime/RealtimeLineChart.d.ts +23 -5
  40. package/dist/{charts → components/charts}/realtime/RealtimeSwarmChart.d.ts +24 -6
  41. package/dist/{charts → components/charts}/realtime/RealtimeWaterfallChart.d.ts +23 -5
  42. package/dist/{charts → components/charts}/shared/colorUtils.d.ts +5 -0
  43. package/dist/components/charts/shared/diagnoseConfig.d.ts +23 -0
  44. package/dist/{charts → components/charts}/shared/hooks.d.ts +36 -2
  45. package/dist/{charts → components/charts}/shared/legendUtils.d.ts +2 -3
  46. package/dist/{charts → components/charts}/shared/statisticalOverlays.d.ts +1 -2
  47. package/dist/components/charts/shared/statisticalOverlaysLazy.d.ts +10 -0
  48. package/dist/components/charts/shared/stringDistance.d.ts +11 -0
  49. package/dist/{charts → components/charts}/shared/tooltipUtils.d.ts +2 -2
  50. package/dist/{charts → components/charts}/shared/types.d.ts +16 -4
  51. package/dist/components/charts/shared/useChartSetup.d.ts +112 -0
  52. package/dist/components/charts/shared/useStreamingLegend.d.ts +65 -0
  53. package/dist/{charts → components/charts}/shared/withChartWrapper.d.ts +10 -0
  54. package/dist/{charts → components/charts}/xy/AreaChart.d.ts +18 -5
  55. package/dist/{charts → components/charts}/xy/BubbleChart.d.ts +18 -5
  56. package/dist/{charts → components/charts}/xy/ConnectedScatterplot.d.ts +10 -6
  57. package/dist/{charts → components/charts}/xy/Heatmap.d.ts +24 -5
  58. package/dist/{charts → components/charts}/xy/LineChart.d.ts +47 -5
  59. package/dist/{charts → components/charts}/xy/MinimapChart.d.ts +3 -0
  60. package/dist/components/charts/xy/QuadrantChart.d.ts +120 -0
  61. package/dist/{charts → components/charts}/xy/Scatterplot.d.ts +11 -5
  62. package/dist/{charts → components/charts}/xy/StackedAreaChart.d.ts +18 -5
  63. package/dist/{export → components/export}/exportChart.d.ts +6 -1
  64. package/dist/components/geo/mergeData.d.ts +18 -0
  65. package/dist/components/geo/referenceGeography.d.ts +10 -0
  66. package/dist/components/geo/useReferenceAreas.d.ts +13 -0
  67. package/dist/{realtime → components/realtime}/RingBuffer.d.ts +1 -0
  68. package/dist/{realtime → components/realtime}/types.d.ts +17 -0
  69. package/dist/components/semiotic-ai.d.ts +61 -0
  70. package/dist/components/semiotic-data.d.ts +8 -0
  71. package/dist/components/semiotic-geo.d.ts +16 -0
  72. package/dist/components/semiotic-network.d.ts +14 -0
  73. package/dist/components/semiotic-ordinal.d.ts +18 -0
  74. package/dist/components/semiotic-realtime.d.ts +22 -0
  75. package/dist/components/semiotic-server.d.ts +1 -0
  76. package/dist/components/semiotic-xy.d.ts +17 -0
  77. package/dist/components/semiotic.d.ts +57 -0
  78. package/dist/{server → components/server}/renderToStaticSVG.d.ts +11 -2
  79. package/dist/components/stream/AccessibleDataTable.d.ts +50 -0
  80. package/dist/{stream → components/stream}/CanvasHitTester.d.ts +8 -2
  81. package/dist/components/stream/DataSourceAdapter.d.ts +64 -0
  82. package/dist/components/stream/GeoCanvasHitTester.d.ts +19 -0
  83. package/dist/components/stream/GeoParticlePool.d.ts +46 -0
  84. package/dist/components/stream/GeoPipelineStore.d.ts +81 -0
  85. package/dist/components/stream/GeoTileRenderer.d.ts +31 -0
  86. package/dist/{stream → components/stream}/NetworkPipelineStore.d.ts +16 -4
  87. package/dist/{stream → components/stream}/NetworkSVGOverlay.d.ts +24 -1
  88. package/dist/{stream → components/stream}/OrdinalPipelineStore.d.ts +8 -4
  89. package/dist/{stream → components/stream}/OrdinalSVGOverlay.d.ts +31 -1
  90. package/dist/{stream → components/stream}/PipelineStore.d.ts +64 -5
  91. package/dist/components/stream/SVGOverlay.d.ts +98 -0
  92. package/dist/{stream → components/stream}/SceneGraph.d.ts +7 -3
  93. package/dist/components/stream/SceneToSVG.d.ts +22 -0
  94. package/dist/components/stream/StreamGeoFrame.d.ts +4 -0
  95. package/dist/{stream → components/stream}/accessorUtils.d.ts +1 -0
  96. package/dist/components/stream/canvasSetup.d.ts +26 -0
  97. package/dist/components/stream/geoTypes.d.ts +186 -0
  98. package/dist/components/stream/hitTestUtils.d.ts +23 -0
  99. package/dist/components/stream/layouts/forceLayoutPlugin.d.ts +2 -0
  100. package/dist/{stream → components/stream}/layouts/index.d.ts +2 -1
  101. package/dist/components/stream/layouts/orbitLayoutPlugin.d.ts +2 -0
  102. package/dist/components/stream/legendRenderer.d.ts +33 -0
  103. package/dist/{stream → components/stream}/networkTypes.d.ts +59 -3
  104. package/dist/{stream → components/stream}/ordinalTypes.d.ts +26 -10
  105. package/dist/components/stream/pipelineTransitionUtils.d.ts +42 -0
  106. package/dist/components/stream/renderers/areaCanvasRenderer.d.ts +2 -0
  107. package/dist/components/stream/renderers/geoCanvasRenderer.d.ts +9 -0
  108. package/dist/{stream → components/stream}/renderers/heatmapCanvasRenderer.d.ts +2 -1
  109. package/dist/{stream → components/stream}/renderers/lineCanvasRenderer.d.ts +1 -0
  110. package/dist/components/stream/renderers/renderPulse.d.ts +50 -0
  111. package/dist/{stream → components/stream}/types.d.ts +89 -3
  112. package/dist/components/stream/useStalenessCheck.d.ts +16 -0
  113. package/dist/components/types/legendTypes.d.ts +49 -0
  114. package/dist/geo.min.js +1 -0
  115. package/dist/geo.module.min.js +1 -0
  116. package/dist/network.min.js +1 -1
  117. package/dist/network.module.min.js +1 -1
  118. package/dist/ordinal.min.js +1 -1
  119. package/dist/ordinal.module.min.js +1 -1
  120. package/dist/realtime.min.js +1 -1
  121. package/dist/realtime.module.min.js +1 -1
  122. package/dist/semiotic-ai.d.ts +3 -0
  123. package/dist/semiotic-ai.min.js +1 -1
  124. package/dist/semiotic-ai.module.min.js +1 -1
  125. package/dist/semiotic-data.d.ts +1 -0
  126. package/dist/semiotic-data.min.js +1 -1
  127. package/dist/semiotic-data.module.min.js +1 -1
  128. package/dist/semiotic-geo.d.ts +16 -0
  129. package/dist/semiotic-network.d.ts +1 -0
  130. package/dist/semiotic-ordinal.d.ts +1 -0
  131. package/dist/semiotic-server.d.ts +1 -1
  132. package/dist/semiotic-xy.d.ts +1 -0
  133. package/dist/semiotic.d.ts +4 -4
  134. package/dist/semiotic.min.js +1 -1
  135. package/dist/semiotic.module.min.js +1 -1
  136. package/dist/server.min.js +1 -1
  137. package/dist/server.module.min.js +1 -1
  138. package/dist/test-utils/canvasMock.d.ts +23 -0
  139. package/dist/test-utils/frameMock.d.ts +78 -0
  140. package/dist/xy.min.js +1 -1
  141. package/dist/xy.module.min.js +1 -1
  142. package/package.json +34 -20
  143. package/dist/Legend.d.ts +0 -3
  144. package/dist/stream/DataSourceAdapter.d.ts +0 -35
  145. package/dist/stream/SVGOverlay.d.ts +0 -56
  146. package/dist/stream/layouts/forceLayoutPlugin.d.ts +0 -9
  147. package/dist/stream/renderers/areaCanvasRenderer.d.ts +0 -7
  148. package/dist/types/legendTypes.d.ts +0 -20
  149. /package/dist/{Annotation.d.ts → components/Annotation.d.ts} +0 -0
  150. /package/dist/{CategoryColors.d.ts → components/CategoryColors.d.ts} +0 -0
  151. /package/dist/{ChartContainer.d.ts → components/ChartContainer.d.ts} +0 -0
  152. /package/dist/{ChartErrorBoundary.d.ts → components/ChartErrorBoundary.d.ts} +0 -0
  153. /package/dist/{ContextLayout.d.ts → components/ContextLayout.d.ts} +0 -0
  154. /package/dist/{DetailsPanel.d.ts → components/DetailsPanel.d.ts} +0 -0
  155. /package/dist/{ThemeProvider.d.ts → components/ThemeProvider.d.ts} +0 -0
  156. /package/dist/{charts → components/charts}/shared/ChartError.d.ts +0 -0
  157. /package/dist/{charts → components/charts}/shared/annotationRules.d.ts +0 -0
  158. /package/dist/{charts → components/charts}/shared/formatUtils.d.ts +0 -0
  159. /package/dist/{charts → components/charts}/shared/loess.d.ts +0 -0
  160. /package/dist/{charts → components/charts}/shared/networkUtils.d.ts +0 -0
  161. /package/dist/{charts → components/charts}/shared/selectionUtils.d.ts +0 -0
  162. /package/dist/{charts → components/charts}/shared/validateChartData.d.ts +0 -0
  163. /package/dist/{charts → components/charts}/shared/validateProps.d.ts +0 -0
  164. /package/dist/{charts → components/charts}/xy/ScatterplotMatrix.d.ts +0 -0
  165. /package/dist/{data → components/data}/fromVegaLite.d.ts +0 -0
  166. /package/dist/{data → components/data}/transforms.d.ts +0 -0
  167. /package/dist/{export → components/export}/chartConfig.d.ts +0 -0
  168. /package/dist/{export → components/export}/selectionSerializer.d.ts +0 -0
  169. /package/dist/{geometry → components/geometry}/sankeyLinks.d.ts +0 -0
  170. /package/dist/{realtime → components/realtime}/BinAccumulator.d.ts +0 -0
  171. /package/dist/{realtime → components/realtime}/IncrementalExtent.d.ts +0 -0
  172. /package/dist/{realtime → components/realtime}/renderers/types.d.ts +0 -0
  173. /package/dist/{realtime → components/realtime}/renderers/waterfallRenderer.d.ts +0 -0
  174. /package/dist/{store → components/store}/ObservationStore.d.ts +0 -0
  175. /package/dist/{store → components/store}/SelectionStore.d.ts +0 -0
  176. /package/dist/{store → components/store}/ThemeStore.d.ts +0 -0
  177. /package/dist/{store → components/store}/TooltipStore.d.ts +0 -0
  178. /package/dist/{store → components/store}/createStore.d.ts +0 -0
  179. /package/dist/{store → components/store}/useObservation.d.ts +0 -0
  180. /package/dist/{store → components/store}/useSelection.d.ts +0 -0
  181. /package/dist/{stream → components/stream}/MarginalGraphics.d.ts +0 -0
  182. /package/dist/{stream → components/stream}/NetworkCanvasHitTester.d.ts +0 -0
  183. /package/dist/{stream → components/stream}/OrdinalCanvasHitTester.d.ts +0 -0
  184. /package/dist/{stream → components/stream}/ParticlePool.d.ts +0 -0
  185. /package/dist/{stream → components/stream}/StreamNetworkFrame.d.ts +0 -0
  186. /package/dist/{stream → components/stream}/StreamOrdinalFrame.d.ts +0 -0
  187. /package/dist/{stream → components/stream}/StreamXYFrame.d.ts +0 -0
  188. /package/dist/{stream → components/stream}/keyboardNav.d.ts +0 -0
  189. /package/dist/{stream → components/stream}/layouts/chordLayoutPlugin.d.ts +0 -0
  190. /package/dist/{stream → components/stream}/layouts/hierarchyLayoutPlugin.d.ts +0 -0
  191. /package/dist/{stream → components/stream}/layouts/sankeyLayoutPlugin.d.ts +0 -0
  192. /package/dist/{stream → components/stream}/ordinalSceneBuilders/barScene.d.ts +0 -0
  193. /package/dist/{stream → components/stream}/ordinalSceneBuilders/connectorScene.d.ts +0 -0
  194. /package/dist/{stream → components/stream}/ordinalSceneBuilders/pieScene.d.ts +0 -0
  195. /package/dist/{stream → components/stream}/ordinalSceneBuilders/pointScene.d.ts +0 -0
  196. /package/dist/{stream → components/stream}/ordinalSceneBuilders/statisticalScene.d.ts +0 -0
  197. /package/dist/{stream → components/stream}/ordinalSceneBuilders/timelineScene.d.ts +0 -0
  198. /package/dist/{stream → components/stream}/ordinalSceneBuilders/types.d.ts +0 -0
  199. /package/dist/{stream → components/stream}/renderers/barCanvasRenderer.d.ts +0 -0
  200. /package/dist/{stream → components/stream}/renderers/boxplotCanvasRenderer.d.ts +0 -0
  201. /package/dist/{stream → components/stream}/renderers/candlestickCanvasRenderer.d.ts +0 -0
  202. /package/dist/{stream → components/stream}/renderers/connectorCanvasRenderer.d.ts +0 -0
  203. /package/dist/{stream → components/stream}/renderers/networkArcRenderer.d.ts +0 -0
  204. /package/dist/{stream → components/stream}/renderers/networkCircleRenderer.d.ts +0 -0
  205. /package/dist/{stream → components/stream}/renderers/networkEdgeRenderer.d.ts +0 -0
  206. /package/dist/{stream → components/stream}/renderers/networkParticleRenderer.d.ts +0 -0
  207. /package/dist/{stream → components/stream}/renderers/networkRectRenderer.d.ts +0 -0
  208. /package/dist/{stream → components/stream}/renderers/pointCanvasRenderer.d.ts +0 -0
  209. /package/dist/{stream → components/stream}/renderers/swarmCanvasRenderer.d.ts +0 -0
  210. /package/dist/{stream → components/stream}/renderers/types.d.ts +0 -0
  211. /package/dist/{stream → components/stream}/renderers/violinCanvasRenderer.d.ts +0 -0
  212. /package/dist/{stream → components/stream}/renderers/waterfallCanvasRenderer.d.ts +0 -0
  213. /package/dist/{stream → components/stream}/renderers/wedgeCanvasRenderer.d.ts +0 -0
  214. /package/dist/{stream → components/stream}/useResponsiveSize.d.ts +0 -0
  215. /package/dist/{types → components/types}/annotationTypes.d.ts +0 -0
  216. /package/dist/{types → components/types}/generalTypes.d.ts +0 -0
  217. /package/dist/{types → components/types}/interactionTypes.d.ts +0 -0
  218. /package/dist/{types → components/types}/networkTypes.d.ts +0 -0
  219. /package/dist/{types → components/types}/ordinalTypes.d.ts +0 -0
@@ -0,0 +1 @@
1
+ import*as e from"react";import{useRef as t,useState as n,useEffect as o,useMemo as i,createContext as r,useContext as l,useCallback as a,useSyncExternalStore as s,forwardRef as c,useImperativeHandle as u,useId as d}from"react";import{geoPath as h,geoGraticule as f,geoDistance as p,geoInterpolate as g,geoEqualEarth as m,geoEquirectangular as y,geoNaturalEarth1 as v,geoOrthographic as b,geoAlbersUsa as x,geoMercator as k}from"d3-geo";import{scaleLinear as w,scaleOrdinal as E,scaleSequential as j}from"d3-scale";import{bin as O,extent as M}from"d3-array";import{packEnclose as A}from"d3-hierarchy";import{area as S,curveCatmullRom as C,curveCardinal as z,curveBasis as L,curveStepBefore as P,curveStepAfter as $,curveStep as W,curveMonotoneY as D,curveMonotoneX as I,curveLinear as N,line as B,curveNatural as T}from"d3-shape";import _ from"regression";import{zoomIdentity as R,zoom as F}from"d3-zoom";import{select as H}from"d3-selection";import{schemeCategory10 as G,interpolatePlasma as q,interpolateViridis as Z,interpolatePurples as U,interpolateOranges as Y,interpolateGreens as X,interpolateReds as V,interpolateBlues as K,schemeSet3 as J,schemeTableau10 as Q}from"d3-scale-chromatic";class ee{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+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 e=0;const t=this;return{next:()=>t._size>e?{done:!1,value:t.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}function te(e,t,n){return e+(t-e)*n}const ne={mercator:k,equalEarth:m,albersUsa:x,orthographic:b,naturalEarth:v,equirectangular:y};function oe(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function ie(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function re(e,t,n){return e?Object.assign(Object.assign({},n),"function"==typeof e?e(t):e):n}const le={fill:"#e0e0e0",stroke:"#999",strokeWidth:.5,fillOpacity:1},ae={fill:"#4e79a7",r:4,fillOpacity:.8},se={stroke:"#4e79a7",strokeWidth:1.5,fill:"none"};function ce(e,t){if(2>e.length)return[e];const n=.4*t,o=[];let i=[e[0]];for(let t=1;e.length>t;t++){const r=e[t];Math.abs(r[0]-e[t-1][0])>n?(2>i.length||o.push(i),i=[r]):i.push(r)}return 2>i.length||o.push(i),o}function ue(e,t,n=24){const o=t[0]-e[0],i=t[1]-e[1],r=Math.sqrt(o*o+i*i);if(0===r)return[e,t];const l=-i/r,a=o/r,s=Math.min(.3*r,80),c=(e[0]+t[0])/2+l*s,u=(e[1]+t[1])/2+a*s,d=[];for(let o=0;n>=o;o++){const i=o/n,r=1-i;d.push([r*r*e[0]+2*r*i*c+i*i*t[0],r*r*e[1]+2*r*i*u+i*i*t[1]])}return d}function de(e,t){if(2>e.length)return e;const n=t/2+1,o=[];for(let t=0;e.length>t;t++){const i=e[t];let r,l;0===t?(r=e[1][0]-i[0],l=e[1][1]-i[1]):t===e.length-1?(r=i[0]-e[t-1][0],l=i[1]-e[t-1][1]):(r=e[t+1][0]-e[t-1][0],l=e[t+1][1]-e[t-1][1]);const a=Math.sqrt(r*r+l*l)||1;o.push([i[0]+l/a*n,i[1]+-r/a*n])}return o}function he(e,t,n,o,i){const r=t[0]-e[0],l=t[1]-e[1],a=Math.sqrt(r*r+l*l);if(0===a)return[e,t];const s=l/a,c=-r/a,u=i/2+1;return[[e[0]+s*u,e[1]+c*u],[t[0]+s*u,t[1]+c*u]]}class fe{constructor(e){this.scene=[],this.scales=null,this.version=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this.config=e}updateConfig(e){this.config=Object.assign(Object.assign({},this.config),e)}setAreas(e){this.areas=e}setPoints(e){this.pointData=e,this.streaming=!1}setLines(e){this.lineData=e}initStreaming(e=500){this.pointBuffer=new ee(e),this.timestampBuffer=new ee(e),this.streaming=!0}pushPoint(e){this.pointBuffer||this.initStreaming(),this.pointBuffer.push(e),this.timestampBuffer.push(performance.now()),this.lastIngestTime=performance.now()}pushMany(e){this.pointBuffer||this.initStreaming();const t=performance.now();for(const n of e)this.pointBuffer.push(n),this.timestampBuffer.push(t);this.lastIngestTime=t}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.scene=[],this.scales=null,this.version++}computeScene(e){const{config:t}=this;this.projection=function(e){if(!e)return m();if("string"==typeof e){const t=ne[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),m())}if("object"==typeof e&&"type"in e){const t=ne[e.type],n=t?t():m();return e.rotate&&"rotate"in n&&n.rotate(e.rotate),e.center&&"center"in n&&n.center(e.center),n}return e}(t.projection),this.geoPath=h(this.projection),this.fitProjection(e),this.geoPath=h(this.projection);const n=this.projection;this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null};const o=this.scene;this.scene=this.buildSceneNodes(e),t.projectionTransform&&this.applyCartogramTransform(t.projectionTransform,e),t.decay&&this.streaming&&this.applyDecay(),t.pulse&&this.streaming&&this.applyPulse(),t.transition&&o.length>0&&this.startTransition(o),this.version++}fitProjection(e){var t,n,o,i,r;const l=this.projection,a=this.config,s=[...this.areas],c=oe(a.xAccessor,"lon"),u=oe(a.yAccessor,"lat"),d=this.getPoints();if(d.length>0){const e=d.map(e=>[c(e),u(e)]);s.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}const h=ie(a.lineDataAccessor);for(const e of this.lineData){const t=h(e);if(t&&t.length>0){const e=t.map(e=>[c(e),u(e)]);s.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==s.length){if(a.projectionExtent){const[[t,n],[o,i]]=a.projectionExtent;l.fitExtent([[0,0],[e.width,e.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[t,n],[o,n],[o,i],[t,i],[t,n]]]}})}else if(l.clipAngle&&(null!==(t=l.clipAngle())&&void 0!==t?t:0)>0){const t=null!==(n=a.fitPadding)&&void 0!==n?n:0,o=Math.min(e.width,e.height);l.scale(o/2-o*t),l.translate([e.width/2,e.height/2])}else{const t=null!==(o=a.fitPadding)&&void 0!==o?o:0,n=e.width*t,i=e.height*t;l.fitExtent([[n,i],[e.width-n,e.height-i]],{type:"FeatureCollection",features:s})}this.baseScale=l.scale(),this.baseTranslate=l.translate(),this.baseRotation=null!==(r=null===(i=l.rotate)||void 0===i?void 0:i.call(l))&&void 0!==r?r:[0,0,0]}}applyZoomTransform(e,t){const n=this.projection;n&&(n.scale(this.baseScale*e.k),n.translate([this.baseTranslate[0]*e.k+e.x,this.baseTranslate[1]*e.k+e.y]),this.currentZoom=e.k,this.geoPath=h(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this.scene=this.buildSceneNodes(t),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyZoomScale(e,t){const n=this.projection;n&&(n.scale(this.baseScale*e),n.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=h(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this.scene=this.buildSceneNodes(t),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyRotation(e,t){const n=this.projection;n&&n.rotate&&(n.rotate(e),this.geoPath=h(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this.scene=this.buildSceneNodes(t),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}setRotation(e){const t=this.projection;t&&t.rotate&&t.rotate(e)}getRotation(){var e,t,n;return null!==(n=null===(t=null===(e=this.projection)||void 0===e?void 0:e.rotate)||void 0===t?void 0:t.call(e))&&void 0!==n?n:this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}buildSceneNodes(e){var t,n,o;const i=[],{config:r}=this,l=this.projection,a=this.geoPath,s=oe(r.xAccessor,"lon"),c=oe(r.yAccessor,"lat");if(r.graticule){const t=!0===r.graticule?{}:r.graticule,n=f();t.step&&n.step(t.step);const o=a(n())||"";o&&i.push({type:"geoarea",pathData:o,centroid:[e.width/2,e.height/2],bounds:[[0,0],[e.width,e.height]],screenArea:0,style:{fill:"none",stroke:t.stroke||"#e0e0e0",strokeWidth:t.strokeWidth||.5,strokeDasharray:t.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const e of this.areas){const t=a(e);if(!t)continue;const n=a.centroid(e),o=a.bounds(e),l=a.area(e),s=re(r.areaStyle,e,le);i.push({type:"geoarea",pathData:t,centroid:n,bounds:o,screenArea:l,style:s,datum:e,interactive:!0})}const u=ie(r.lineDataAccessor);for(const t of this.lineData){const n=u(t);if(!n||2>n.length)continue;const o=n.map(e=>[s(e),c(e)]);let a;if("geo"===r.lineType){const e=[];for(let t=0;o.length-1>t;t++){const n=o[t],i=o[t+1],r=p(n,i)||0,l=Math.max(2,Math.ceil(r/(Math.PI/180))),a=g(n,i);for(let n=0;l>=n;n++)t>0&&0===n||e.push(a(n/l))}a=e.map(([e,t])=>l([e,t])).filter(e=>null!=e)}else a=o.map(([e,t])=>l([e,t])).filter(e=>null!=e);if(2>a.length)continue;const d=re(r.lineStyle,t,se),h="number"==typeof d.strokeWidth?d.strokeWidth:1;2!==o.length||2>a.length||"arc"!==r.flowStyle?2!==o.length||2>a.length||"offset"!==r.flowStyle||(a="geo"===r.lineType?de(a,h):he(a[0],a[a.length-1],0,0,h)):a=ue(a[0],a[a.length-1]);const f=ce(a,e.width);if(f.length>1)for(const e of f){if(2>e.length)continue;const n={type:"line",path:e,style:Object.assign(Object.assign({},d),{_edgeFade:!0}),datum:t};i.push(n)}else i.push({type:"line",path:2>a.length&&f[0]||a,style:d,datum:t})}const d=this.getPoints(),h=r.pointIdAccessor?"function"==typeof r.pointIdAccessor?r.pointIdAccessor:e=>e[r.pointIdAccessor]:null,m=l.clipAngle&&null!==(t=l.clipAngle())&&void 0!==t?t:0,y=m>0?m*Math.PI/180:null,v=l.rotate?l.rotate():[0,0,0],b="function"==typeof l.center?l.center():[0,0],x=[(null!==(n=b[0])&&void 0!==n?n:0)-v[0],(null!==(o=b[1])&&void 0!==o?o:0)-v[1]];for(let e=0;d.length>e;e++){const t=d[e],n=s(t),o=c(t);if(null!=y&&p([n,o],x)>y)continue;const a=l([n,o]);if(!a)continue;const u=r.pointStyle?r.pointStyle(t):Object.assign({},ae),f={type:"point",x:a[0],y:a[1],r:u.r||4,style:u,datum:t,pointId:h?h(t)+"":void 0};i.push(f)}return i}applyCartogramTransform(e,t){var n,o,i;const r=this.scene.filter(e=>"point"===e.type);if(2>r.length)return;const l=null!==(n=e.strength)&&void 0!==n?n:1;if(0===l)return;const a=e.centerAccessor?"function"==typeof e.centerAccessor?e.centerAccessor:t=>t[e.centerAccessor]:e=>e.id,s="function"==typeof e.costAccessor?e.costAccessor:t=>t[e.costAccessor],c=r.find(t=>a(t.datum)+""==e.center+"");if(!c)return void("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${e.center}" not found in point data`));const u=c.x,d=c.y,h=r.map(e=>s(e.datum)).filter(e=>isFinite(e)&&e>=0),f=Math.max(...h,1),p=Math.min(t.width,t.height)/2,g=w().domain([0,f]).range([0,p]);this.cartogramLayout={cx:u,cy:d,maxCost:f,availableRadius:p},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(e=>"geoarea"!==e.type||!e.interactive);for(const e of r){if(e===c)continue;const t=Math.atan2(e.y-d,e.x-u),n=Math.sqrt(Math.pow(e.x-u,2)+Math.pow(e.y-d,2)),o=s(e.datum),i=n+((isFinite(o)?g(o):n)-n)*l;e.x=u+Math.cos(t)*i,e.y=d+Math.sin(t)*i}const m=t.width/2,y=t.height/2,v=m-c.x,b=y-c.y;if(Math.abs(v)>.5||Math.abs(b)>.5)for(const e of r)e.x+=v,e.y+=b;this.cartogramLayout={cx:m,cy:y,maxCost:f,availableRadius:p};const x=this.scene.filter(e=>"line"===e.type);if(x.length>0&&"fractional"!==e.lineMode){const e=new Map;for(const t of r)t.pointId&&e.set(t.pointId,[t.x,t.y]);for(const t of x){const n=null===(o=t.datum)||void 0===o?void 0:o.source,r=null===(i=t.datum)||void 0===i?void 0:i.target;if(n&&r){const o=e.get(n+""),i=e.get(r+"");o&&i&&(t.path=[o,i])}}}}applyDecay(){var e,t,n;const o=this.config.decay;if(!o||!this.pointBuffer)return;const i=this.pointBuffer.size;if(0===i)return;const r=null!==(e=o.minOpacity)&&void 0!==e?e:.1,l=null!==(t=o.halfLife)&&void 0!==t?t:i/2,a=null!==(n=o.stepThreshold)&&void 0!==n?n:.5*i,s=this.scene.filter(e=>"point"===e.type);for(let e=0;s.length>e;e++){const t=i-1-e;let n;switch(o.type){case"exponential":n=r+Math.pow(.5,t/l)*(1-r);break;case"step":n=a>t?1:r;break;default:n=r+(i>1?1-t/(i-1):1)*(1-r)}s[e]._decayOpacity=n,s[e].style=Object.assign(Object.assign({},s[e].style),{opacity:n})}}applyPulse(){var e,t;const n=this.config.pulse;if(!n||!this.timestampBuffer)return;const o=null!==(e=n.duration)&&void 0!==e?e:500,i=performance.now(),r=this.scene.filter(e=>"point"===e.type),l=this.timestampBuffer.toArray();for(let e=0;r.length>e&&l.length>e;e++){const a=i-l[e];o>a&&(r[e]._pulseIntensity=1-a/o,r[e]._pulseColor=n.color||"rgba(255,255,255,0.6)",r[e]._pulseGlowRadius=null!==(t=n.glowRadius)&&void 0!==t?t:4)}}get hasActivePulses(){var e,t;if(!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const n=null!==(t=null===(e=this.config.pulse)||void 0===e?void 0:e.duration)&&void 0!==t?t:500,o=this.timestampBuffer.toArray()[this.timestampBuffer.size-1];return performance.now()-o<n}startTransition(e){var t,n;const o=null!==(n=null===(t=this.config.transition)||void 0===t?void 0:t.duration)&&void 0!==n?n:300;if(0>=o)return;const i=new Map;for(const t of e)"point"===t.type&&t.pointId&&i.set(t.pointId,[t.x,t.y]);const r=this.scene.filter(e=>"point"===e.type);let l=!1;for(const e of r)if(e.pointId){const t=i.get(e.pointId);t&&(e._targetX=e.x,e._targetY=e.y,e.x=t[0],e.y=t[1],(Math.abs(t[0]-e._targetX)>.5||Math.abs(t[1]-e._targetY)>.5)&&(l=!0))}l&&(this.activeTransition={startTime:performance.now(),duration:o})}advanceTransition(e){if(!this.activeTransition)return!1;const t=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,this.activeTransition),n=function(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}(t),o=this.scene.filter(e=>"point"===e.type);for(const e of o)if(null!=e._targetX&&null!=e._targetY){const t=e.y;e.x=te(e.x,e._targetX,n),e.y=te(t,e._targetY,n)}if(t>=1){for(const e of o)null!=e._targetX&&(e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0);return this.activeTransition=null,!1}return!0}}function pe(e,t,n,o,i,r){const l=e.filter(e=>"point"===e.type);let a=null,s=o;for(const e of l){const o=e.x-t,i=e.y-n,r=Math.sqrt(o*o+i*i);(e.r||4)+4>=r&&s>r&&(a=e,s=r)}if(a)return{node:a,distance:s};const c=e.filter(e=>"geoarea"===e.type&&!1!==e.interactive);for(let e=c.length-1;e>=0;e--){const o=c[e],[[r,l],[a,s]]=o.bounds;if(!(r>t||t>a||l>n||n>s)&&(o._cachedPath2D||(o._cachedPath2D=new Path2D(o.pathData)),i.isPointInPath(o._cachedPath2D,t,n)))return{node:o,distance:0}}const u=e.filter(e=>"line"===e.type);let d=null,h=o;for(const e of u){const{path:o}=e;for(let i=0;o.length-1>i;i++){const[r,l]=o[i],[a,s]=o[i+1],c=ge(t,n,r,l,a,s);Math.max((e.style.strokeWidth||2)+4,5)>=c&&h>c&&(d=e,h=c)}}return d?{node:d,distance:h}:null}function ge(e,t,n,o,i,r){const l=i-n,a=r-o,s=l*l+a*a;if(0===s)return Math.sqrt(Math.pow(e-n,2)+Math.pow(t-o,2));let c=((e-n)*l+(t-o)*a)/s;c=Math.max(0,Math.min(1,c));const u=o+c*a;return Math.sqrt(Math.pow(e-(n+c*l),2)+Math.pow(t-u,2))}const me={fill:t=>e.createElement("rect",{style:t,width:16,height:16}),line:t=>e.createElement("line",{style:t,x1:0,y1:0,x2:16,y2:16})};function ye(e,t,n,o){let i;return i="function"==typeof n?n(e):(0,me[n])(o(e,t)),i}function ve(){return e.createElement("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function be(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}function xe({config:t,orientation:n="vertical",width:o=100}){const{colorFn:i,domain:r,label:l,format:a}=t,s=a||(e=>Math.round(100*e)/100+""),c="grad-legend-"+e.useId();if("horizontal"===n){const t=12,n=Math.min(o,200),a=Math.max(0,(o-n)/2),u=[];for(let t=0;64>=t;t++){const n=t/64;u.push(e.createElement("stop",{key:t,offset:100*n+"%",stopColor:i(r[0]+n*(r[1]-r[0]))}))}return e.createElement("g",{"aria-label":l||"Gradient legend"},e.createElement("defs",null,e.createElement("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%"},u)),l&&e.createElement("text",{x:a+n/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},l),e.createElement("rect",{x:a,y:0,width:n,height:t,fill:`url(#${c})`,rx:2}),e.createElement("text",{x:a,y:t+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(r[0])),e.createElement("text",{x:a+n,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(r[1])))}const u=[];for(let t=0;64>=t;t++){const n=t/64;u.push(e.createElement("stop",{key:t,offset:100*n+"%",stopColor:i(r[1]-n*(r[1]-r[0]))}))}return e.createElement("g",{"aria-label":l||"Gradient legend"},l&&e.createElement("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)"},l),e.createElement("defs",null,e.createElement("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%"},u)),e.createElement("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),e.createElement("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(r[1])),e.createElement("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)"},s(r[0])))}function ke(t){const{legendGroups:n,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:l,legendInteraction:a,title:s="Legend",width:c=100,height:u=20,orientation:d="vertical"}=t,[h,f]=e.useState(0),[p,g]=e.useState(0),m=e.useCallback((e,t)=>{f(e),g(t)},[]),y="vertical"===d?(({legendGroups:t,width:n,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:l,focusedGroupIndex:a,focusedItemIndex:s,onFocusedIndexChange:c,legendInteraction:u})=>{let d=24;const h=[];return t.forEach((t,f)=>{d+=5,h.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+f,stroke:"gray",x1:0,y1:d,x2:n,y2:d})),d+=8,t.label&&(d+=16,h.push(e.createElement("text",{key:"legend-text-"+f,y:d,className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label)),d+=8),h.push(e.createElement("g",{key:"legend-group-"+f,className:"legend-item",transform:`translate(0,${d})`},((t,n,o,i,r,l,a,s,c,u)=>{const{type:d="fill",styleFn:h,items:f}=t,p=[];let g=0;const m=!(!n&&!o),y="isolate"===u||void 0===u&&null!=r;return f.forEach((t,u)=>{const v=ye(t,u,d,h),b=be(t,i,r),x=r&&r.size>0&&r.has(t.label);p.push(e.createElement("g",{key:"legend-item-"+u,transform:`translate(0,${g})`,onClick:n?()=>n(t):void 0,onMouseEnter:o?()=>o(t):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:m?s===l&&u===a?0:-1:void 0,role:m?"option":void 0,"aria-selected":m&&y?x||!1:void 0,"aria-current":m&&!y&&null!=i&&t.label===i||void 0,"aria-label":t.label,onKeyDown:m?e=>{var o;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),n&&n(t)),"ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault();const t=(u+("ArrowDown"===e.key?1:-1)+f.length)%f.length;c(s,t);const n=null===(o=e.currentTarget.parentElement)||void 0===o?void 0:o.children[t];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:m?e=>{c(s,u),o&&o(t);const n=e.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:m?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:m?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},m&&e.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,x&&e.createElement(ve,null),e.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label))),g+=22}),p})(t,o,i,r,l,a,s,f,c,u))),d+=22*t.items.length+8}),h})({legendGroups:n||[],width:c,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:l,focusedGroupIndex:h,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:a}):(({legendGroups:t,height:n,width:o,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:l,isolatedCategories:a,focusedGroupIndex:s,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:d})=>{let h=0;const f=[];t.forEach((t,n)=>{let o=0;t.label&&(o+=16);const p=((t,n,o,i,r,l,a,s,c,u)=>{const{type:d="fill",styleFn:h,items:f}=t,p=[];let g=0;const m=!(!n&&!o),y="isolate"===u||void 0===u&&null!=r;return f.forEach((t,u)=>{const v=ye(t,u,d,h),b=be(t,i,r),x=r&&r.size>0&&r.has(t.label);p.push(e.createElement("g",{key:"legend-item-"+u,transform:`translate(${g},0)`,onClick:n?()=>n(t):void 0,onMouseEnter:o?()=>o(t):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:m?s===l&&u===a?0:-1:void 0,role:m?"option":void 0,"aria-selected":m&&y?x||!1:void 0,"aria-current":m&&!y&&null!=i&&t.label===i||void 0,"aria-label":t.label,onKeyDown:m?e=>{var o;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),n&&n(t)),"ArrowRight"===e.key||"ArrowLeft"===e.key){e.preventDefault();const t=(u+("ArrowRight"===e.key?1:-1)+f.length)%f.length;c(s,t);const n=null===(o=e.currentTarget.parentElement)||void 0===o?void 0:o.children[t];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:m?e=>{c(s,u),o&&o(t);const n=e.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:m?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:m?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"}},m&&e.createElement("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:24+7*t.label.length,height:20,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,x&&e.createElement(ve,null),e.createElement("text",{y:8,x:22,dominantBaseline:"central",fontSize:12,fill:"var(--semiotic-text, #333)"},t.label))),g+=26+7*t.label.length}),{items:p,offset:g}})(t,i,r,l,a,s,c,n,u,d);o+=p.offset+5,f.push(Object.assign(Object.assign({label:t.label},p),{offset:o})),h+=o+12});let p=Math.max(0,(o-h)/2);const g=[];return f.forEach((o,i)=>{const r=t[i];r.label&&(g.push(e.createElement("text",{key:"legend-text-"+i,transform:`translate(${p},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",fontSize:12,fill:"var(--semiotic-text, #333)"},r.label)),p+=16),g.push(e.createElement("g",{key:"legend-group-"+i,className:"legend-item",transform:`translate(${p},0)`},o.items)),p+=o.offset+5,t[i+1]&&g.push(e.createElement("line",{key:"legend-top-line legend-symbol-"+i,stroke:"gray",x1:p,y1:-8,x2:p,y2:n+0+8})),p+=12}),e.createElement("g",null,g)})({legendGroups:n||[],title:s,height:u,width:c,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:l,focusedGroupIndex:h,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:a}),v=!(!o&&!i);return e.createElement("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==a&&(void 0!==a||null==l))||void 0,"aria-label":"Chart legend"},void 0!==s&&""!==s&&"vertical"===d&&e.createElement("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",fontSize:12,fill:"var(--semiotic-text, #333)"},s),y)}function we(e){return"string"==typeof e?{type:e}:e}function Ee({orient:t,config:n,values:o,scale:r,size:l,length:a}){const s=function(e){var t,n,o,i,r;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(n=e.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(o=e.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(i=e.stroke)&&void 0!==i?i:"none",strokeWidth:null!==(r=e.strokeWidth)&&void 0!==r?r:1}}(n),c="top"===t||"bottom"===t,u=i(()=>{if(0===o.length)return null;const n=r.domain(),i=l-8;if("boxplot"===s.type){const n=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],i=t[Math.floor(.5*n)],r=t[Math.floor(.75*n)],l=r-o;return{q1:o,median:i,q3:r,whiskerLow:Math.max(t[0],o-1.5*l),whiskerHigh:Math.min(t[n-1],r+1.5*l)}}(o);if(!n)return null;const{q1:l,median:a,q3:u,whiskerLow:d,whiskerHigh:h}=n,f=Math.min(.5*i,20),p=(i-f)/2+4;if(c){const n=r(l),o=r(u),i=r(a),c=r(d),g=r(h),m="top"===t?-1:1,y=0;return e.createElement("g",{"data-testid":"marginal-boxplot-"+t},e.createElement("line",{x1:c,y1:y+m*(p+f/2),x2:g,y2:y+m*(p+f/2),stroke:s.fill,strokeWidth:s.strokeWidth}),e.createElement("line",{x1:c,y1:y+m*p,x2:c,y2:y+m*(p+f),stroke:s.fill,strokeWidth:s.strokeWidth}),e.createElement("line",{x1:g,y1:y+m*p,x2:g,y2:y+m*(p+f),stroke:s.fill,strokeWidth:s.strokeWidth}),e.createElement("rect",{x:Math.min(n,o),y:"top"===t?y-p-f:y+p,width:Math.abs(o-n),height:f,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),e.createElement("line",{x1:i,y1:"top"===t?y-p-f:y+p,x2:i,y2:"top"===t?y-p:y+p+f,stroke:s.fill,strokeWidth:2}))}{const n=r(l),o=r(u),i=r(a),c=r(d),g=r(h),m="left"===t?-1:1,y=0;return e.createElement("g",{"data-testid":"marginal-boxplot-"+t},e.createElement("line",{x1:y+m*(p+f/2),y1:c,x2:y+m*(p+f/2),y2:g,stroke:s.fill,strokeWidth:s.strokeWidth}),e.createElement("line",{x1:y+m*p,y1:c,x2:y+m*(p+f),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),e.createElement("line",{x1:y+m*p,y1:g,x2:y+m*(p+f),y2:g,stroke:s.fill,strokeWidth:s.strokeWidth}),e.createElement("rect",{x:"left"===t?y-p-f:y+p,y:Math.min(n,o),width:f,height:Math.abs(o-n),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),e.createElement("line",{x1:"left"===t?y-p-f:y+p,y1:i,x2:"left"===t?y-p:y+p+f,y2:i,stroke:s.fill,strokeWidth:2}))}}const u=O().domain(n).thresholds(s.bins)(o);if(0===u.length)return null;const d=Math.max(...u.map(e=>e.length));if(0===d)return null;if("histogram"===s.type)return e.createElement("g",{"data-testid":"marginal-histogram-"+t},u.map((n,o)=>{if(null==n.x0||null==n.x1)return null;const l=n.length/d*i;if(c){const i=r(n.x0),a=r(n.x1)-r(n.x0);return e.createElement("rect",{key:o,x:i,y:"top"===t?-4-l:4,width:Math.max(a,.5),height:l,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}{const i=r(n.x0),a=r(n.x1)-r(n.x0);return e.createElement("rect",{key:o,x:"left"===t?-4-l:4,y:Math.min(i,i+a),width:l,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth})}}));if("violin"===s.type){const n=i/2+4,o=[];for(const e of u){if(null==e.x0||null==e.x1)continue;const l=e.length/d*(i/2),a=r((e.x0+e.x1)/2);o.push(c?`${a},${"top"===t?-(n-l):n-l}`:`${"left"===t?-(n-l):n-l},${a}`)}for(let e=u.length-1;e>=0;e--){const l=u[e];if(null==l.x0||null==l.x1)continue;const a=l.length/d*(i/2),s=r((l.x0+l.x1)/2);o.push(c?`${s},${"top"===t?-(n+a):n+a}`:`${"left"===t?-(n+a):n+a},${s}`)}return e.createElement("g",{"data-testid":"marginal-violin-"+t},e.createElement("polygon",{points:o.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}if("ridgeline"===s.type){const n=[];if(c){const e=0,o=null!=u[0].x0?r(u[0].x0):0;n.push(`M${o},${e}`);for(const e of u){if(null==e.x0||null==e.x1)continue;const o=e.length/d*i,l=r((e.x0+e.x1)/2);n.push(`L${l},${"top"===t?-o-4:o+4}`)}const l=null!=u[u.length-1].x1?r(u[u.length-1].x1):a;n.push(`L${l},${e}`),n.push("Z")}else{const e=0,o=null!=u[0].x0?r(u[0].x0):0;n.push(`M${e},${o}`);for(const e of u){if(null==e.x0||null==e.x1)continue;const o=e.length/d*i,l=r((e.x0+e.x1)/2);n.push(`L${"left"===t?-o-4:o+4},${l}`)}const l=null!=u[u.length-1].x1?r(u[u.length-1].x1):a;n.push(`L${e},${l}`),n.push("Z")}return e.createElement("g",{"data-testid":"marginal-ridgeline-"+t},e.createElement("path",{d:n.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}))}return null},[o,r,s,l,a,t,c,4]);return u?e.createElement("g",{className:"marginal-"+t,"data-testid":"marginal-"+t},u):null}function je(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),i=e.split(/\s+/),r=[];let l="";for(const e of i)l&&l.length+1+e.length>o?(r.push(l),l=e):l=l?`${l} ${e}`:e;return l&&r.push(l),r}function Oe(e,t,n,o){return"curly"===e?o?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:o?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function Me(t){const{x:n=0,y:o=0,dx:i,dy:r,nx:l,ny:a,note:s,connector:c,subject:u,type:d,color:h,className:f,disable:p,events:g={},"data-testid":m}=t,y=new Set(Array.isArray(p)?p:[]);let v=i||0,b=r||0;null!=l&&(v=l-n),null!=a&&(b=a-o);const x="string"==typeof d?d:"label";if("bracket"===x&&u&&0===v&&0===b)if(void 0!==u.width){v=u.width/2;const e=u.depth||30;b=e+(0>e?-5:5)}else if(void 0!==u.height){const e=u.depth||30;v=e+(0>e?-5:5),b=u.height/2}return e.createElement("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${n},${o})`,"data-testid":m},g),!y.has("connector")&&function(t,n,o,i,r,l){const a=[];let s=0,c=0;if("callout-circle"!==r&&"label"!==r||!(null==l?void 0:l.radius)){if("callout-rect"===r&&l){const e=l.width||0,o=l.height||0;if(e>0||o>0){const i=e/2,r=o/2,l=t-i,a=n-r;if(0!==l||0!==a){const t=Math.abs(l),n=Math.abs(a),u=e/2,d=o/2,h=t*d>n*u?u/t:d/n;s=i+l*h,c=r+a*h}}}else if("bracket"===r&&l){const e=l.width,t=l.height,n=l.depth||30;void 0!==e?(s=e/2,c=n):void 0!==t&&(s=n,c=t/2)}}else{const e=(l.radius||0)+(l.radiusPadding||0);if(e>0&&(0!==t||0!==n)){const o=Math.atan2(n,t);s=Math.cos(o)*e,c=Math.sin(o)*e}}if(Math.sqrt(Math.pow(t-s,2)+Math.pow(n-c,2))>.5&&(a.push(e.createElement("line",{key:"connector-line",x1:s,y1:c,x2:t,y2:n,stroke:i||"currentColor"})),"arrow"===(null==o?void 0:o.end))){const o=10,r=16/180*Math.PI,l=Math.atan2(n-c,t-s);a.push(e.createElement("path",{key:"connector-arrow",d:`M${s},${c}L${s+o*Math.cos(l+r)},${c+o*Math.sin(l+r)}L${s+o*Math.cos(l-r)},${c+o*Math.sin(l-r)}Z`,fill:i||"currentColor",stroke:"none"}))}return e.createElement("g",{className:"annotation-connector"},a)}(v,b,c,h,x,u),!y.has("subject")&&function(t,n,o,i,r){var l;const a=[];switch(t){case"callout-circle":{const t=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);t>0&&a.push(e.createElement("circle",{key:"subject-circle",r:t,fill:"none",stroke:o||"currentColor"}));break}case"callout-rect":{const t=(null==n?void 0:n.width)||0,i=(null==n?void 0:n.height)||0;(t>0||i>0)&&a.push(e.createElement("rect",{key:"subject-rect",width:t,height:i,fill:"none",stroke:o||"currentColor"}));break}case"callout-custom":(null==n?void 0:n.custom)&&a.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const t=i||0,l=r||0;if(void 0!==(null==n?void 0:n.x)){const i=(n.x||0)-t;a.push(e.createElement("line",{key:"threshold-line",x1:i,y1:(n.y1||0)-l,x2:i,y2:(n.y2||0)-l,stroke:o||"currentColor",strokeDasharray:"5,5"}))}else if(void 0!==(null==n?void 0:n.y)){const i=(n.y||0)-l;a.push(e.createElement("line",{key:"threshold-line",x1:(n.x1||0)-t,y1:i,x2:(n.x2||0)-t,y2:i,stroke:o||"currentColor",strokeDasharray:"5,5"}))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?a.push(e.createElement("line",{key:"threshold-line",x1:(n.x1||0)-t,y1:0,x2:(n.x2||0)-t,y2:0,stroke:o||"currentColor",strokeDasharray:"5,5"})):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||a.push(e.createElement("line",{key:"threshold-line",x1:0,y1:(n.y1||0)-l,x2:0,y2:(n.y2||0)-l,stroke:o||"currentColor",strokeDasharray:"5,5"}));break}case"bracket":{const t=null!==(l=null==n?void 0:n.width)&&void 0!==l?l:null==n?void 0:n.height;void 0!==t&&a.push(e.createElement("path",{key:"bracket-path",d:Oe((null==n?void 0:n.type)||"curly",t,(null==n?void 0:n.depth)||30,void 0===(null==n?void 0:n.width)),fill:"none",stroke:o||"currentColor"}));break}}return e.createElement("g",{className:"annotation-subject"},a)}(x,u,h,n,o),!y.has("note")&&function(t,n,o,i){if(!t)return e.createElement("g",{className:"annotation-note"});const{label:r,title:l,orientation:a,align:s,wrap:c=120,noWrap:u}=t;if(!r&&!l)return e.createElement("g",{className:"annotation-note"});let d=a;d||(d=Math.abs(n)>Math.abs(o)?"leftRight":"topBottom");let h=s;h&&"dynamic"!==h||(h="topBottom"===d?0>n?"right":"left":0>o?"bottom":"top");let f="start";"topBottom"===d?"right"===h?f="end":"middle"===h&&(f="middle"):f=0>n?"end":"start";const p=16,g=l?u?[l]:je(l,c):[],m=r?u?[r]:je(r,c):[],y="leftRight"===d?"end"===f?-4:4:0;let v=0;const b=[];g.length>0&&(b.push(e.createElement("text",{key:"annotation-note-title",className:"annotation-note-title",fill:i||void 0,textAnchor:f,fontWeight:"bold"},g.map((t,n)=>e.createElement("tspan",{key:n,x:y,dy:0===n?0:p},t)))),v=g.length*p),m.length>0&&b.push(e.createElement("text",{key:"annotation-note-label",className:"annotation-note-label",fill:i||void 0,textAnchor:f,y:v},m.map((t,n)=>e.createElement("tspan",{key:n,x:y,dy:0===n?0:p},t))));let x=null;if((l||r)&&(0!==n||0!==o))if("topBottom"===d){const t=Math.min(c,120);let n=0,o=t;"end"===f?(n=-t,o=0):"middle"===f&&(n=-t/2,o=t/2),x=e.createElement("line",{className:"note-line",x1:n,x2:o,y1:0,y2:0,stroke:i||"currentColor"})}else{const t=(g.length+m.length)*p+(m.length>0?p:0);let n=0,o=t;"bottom"===h?(n=-t,o=0):"middle"===h&&(n=-t/2,o=t/2),x=e.createElement("line",{className:"note-line",x1:0,x2:0,y1:n,y2:o,stroke:i||"currentColor"})}const k=Math.max(0,g.length+m.length-1)*p;let w=0;return"topBottom"===d?w=0>o?-(k+2):18:"leftRight"===d&&(w="middle"===h?-(k+p+(m.length>0&&g.length>0?2:0))/2+8:"bottom"===h||0>o?-(k+2):18),e.createElement("g",{className:"annotation-note",transform:`translate(${n},${o})`},e.createElement("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0},b),x)}(s,v,b,h))}function Ae(t){var n,o;const{noteData:i}=t,{screenCoordinates:r}=i,l="string"==typeof i.type?i.type:"label",a=i.eventListeners||i.events||{};if(i.coordinates&&r){const t=i.nx||r[0][0]+(null!==(n=i.dx)&&void 0!==n?n:0),a=i.ny||r[0][1]+(null!==(o=i.dy)&&void 0!==o?o:0),s=r.map((n,o)=>{const r=Object.assign({},i,{note:0===o?i.note:{label:""},x:n[0],y:n[1],nx:t,ny:a});return e.createElement(Me,Object.assign({"data-testid":"semiotic-annotation",key:"multi-annotation-"+o},r,{type:l}))});return e.createElement("g",null,s)}const s=i.note||{title:"none",label:i.label};return e.createElement(Me,Object.assign({"data-testid":"semiotic-annotation",key:`${s.label}-${s.title}-${i.i}`,events:a},i,{type:l}))}const Se={linear:N,monotoneX:I,monotoneY:D,step:W,stepAfter:$,stepBefore:P,basis:L,cardinal:z,catmullRom:C};function Ce(e,t){var n,o,i;const r=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(i=t.scales)||void 0===i?void 0:i.time;return r?null!=e.x?r(e.x):t.xAccessor&&null!=e[t.xAccessor]?r(e[t.xAccessor]):null:null}function ze(e,t){var n,o,i;const r=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(i=t.scales)||void 0===i?void 0:i.value;return r?null!=e.y?r(e.y):t.yAccessor&&null!=e[t.yAccessor]?r(e[t.yAccessor]):null:null}function Le(e,t,n){var o,i,r,l;const a=e.anchor||"fixed";if("latest"===a){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let i=n.pointNodes.length-1;i>=0;i--){const r=n.pointNodes[i];if(r.pointId===e.pointId){const e={x:r.x,y:r.y};return null===(o=n.stickyPositionCache)||void 0===o||o.set(t,e),e}}const r=function(e){var t,n,o,i,r,l;const a=e.data;if(!a||0===a.length)return null;const s=a[a.length-1],c=null!==(n=null===(t=e.scales)||void 0===t?void 0:t.x)&&void 0!==n?n:null===(o=e.scales)||void 0===o?void 0:o.time,u=null!==(r=null===(i=e.scales)||void 0===i?void 0:i.y)&&void 0!==r?r:null===(l=e.scales)||void 0===l?void 0:l.value;if(!c||!u)return null;const d=s[e.xAccessor||"x"],h=s[e.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return r&&(null===(i=n.stickyPositionCache)||void 0===i||i.set(t,r)),r}let s=null,c=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(s=t.x,c=t.y)}if(null!=s&&null!=c||(s=Ce(e,n),c=ze(e,n)),null!=s&&null!=c)return null===(r=n.stickyPositionCache)||void 0===r||r.set(t,{x:s,y:c}),{x:s,y:c};if("sticky"===a){const e=null===(l=n.stickyPositionCache)||void 0===l?void 0:l.get(t);if(e)return e}return null}function Pe(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}function $e(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,i="left"===e?-1:1,r=Math.ceil(t/8);let l="M0,"+o;for(let e=0;r>e;e++){const n=8*(e+1);l+=`L${Math.min(8*e+4,t)},${o+4*i}`,l+=`L${Math.min(n,t)},${o}`}return l}{const o="bottom"===e?0:t,i="bottom"===e?1:-1,r=Math.ceil(n/8);let l=`M${o},0`;for(let e=0;r>e;e++){const t=8*(e+1);l+=`L${o+4*i},${Math.min(8*e+4,n)}`,l+=`L${o},${Math.min(t,n)}`}return l}}function We(e){return Math.round(100*e)/100+""}function De(e,t){return e instanceof Date&&(!(t&&t instanceof Date)||e.getFullYear()!==t.getFullYear()||e.getMonth()!==t.getMonth()||e.getDate()!==t.getDate())}function Ie(n){var o,r;const{width:l,height:a,totalWidth:s,totalHeight:c,margin:u,scales:d,showAxes:h,axes:f,xLabel:p,yLabel:g,xFormat:m,yFormat:y,showGrid:v,title:b,legend:x,legendHoverBehavior:k,legendClickBehavior:w,legendHighlightedCategory:E,legendIsolatedCategories:j,legendPosition:O="right",foregroundGraphics:M,marginalGraphics:C,xValues:z,yValues:L,annotations:P,svgAnnotationRules:$,xAccessor:W,yAccessor:D,annotationData:I,pointNodes:B,curve:T,underlayRendered:R,children:F}=n,H=i(()=>{var e;if(!h||!d)return[];const t=null==f?void 0:f.find(e=>"bottom"===e.orient),n=(null==t?void 0:t.tickFormat)||m||We,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return d.x.ticks(Math.min(o,Math.max(2,Math.floor(l/70)))).map(e=>({value:e,pixel:d.x(e),label:n(e)}))},[h,d,f,m,l]),G=i(()=>{var e;if(!h||!d)return[];const t=null==f?void 0:f.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||y||We,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;return d.y.ticks(Math.min(o,Math.max(2,Math.floor(a/30)))).map(e=>({value:e,pixel:d.y(e),label:n(e)}))},[h,d,f,y,a]),q=t(new Map),Z=t(null!==(o=null==P?void 0:P.length)&&void 0!==o?o:0),U=null!==(r=null==P?void 0:P.length)&&void 0!==r?r:0;Z.current!==U&&(Z.current=U,q.current=new Map);const Y=i(()=>{if(!P||0===P.length)return null;const t=function(t,n,o){var i,r,l,a,s,c,u,d,h,f,p,g,m,y,v,b,x,k,w,E,j,O,M,C,z,L,P,$,W,D,I,B,T,R,F,H,G,q,Z,U,Y,X,V,K;switch(t.type){case"label":{const i=Le(t,n,o);if(!i)return null;const{x:r,y:l}=i;return Pe(r,l,o)?e.createElement(Ae,{key:"ann-"+n,noteData:{x:r,y:l,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"label",connector:t.connector||{end:"arrow"},color:t.color}}):null}case"callout":{const i=Le(t,n,o);if(!i)return null;const{x:r,y:l}=i;return Pe(r,l,o)?e.createElement(Ae,{key:"ann-"+n,noteData:{x:r,y:l,dx:t.dx||30,dy:t.dy||-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"callout-circle",subject:{radius:t.radius||12},connector:t.connector||{end:"arrow"},color:t.color}}):null}case"x-threshold":{const i=Ce(t,o);if(null==i)return null;const r=t.color||"#f97316";return e.createElement("g",{key:"ann-"+n},e.createElement("line",{x1:i,y1:0,x2:i,y2:o.height||0,stroke:r,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:i+4,y:12,fill:r,fontSize:12,fontWeight:"bold"},t.label))}case"y-threshold":{const i=ze(t,o);if(null==i)return null;const r=t.color||"#f97316";return e.createElement("g",{key:"ann-"+n},e.createElement("line",{x1:0,y1:i,x2:o.width||0,y2:i,stroke:r,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:i-4,textAnchor:"end",fill:r,fontSize:12,fontWeight:"bold"},t.label))}case"enclose":{const i=(t.coordinates||[]).map(e=>({x:Ce(Object.assign(Object.assign({},e),{type:"point"}),o),y:ze(Object.assign(Object.assign({},e),{type:"point"}),o),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const r=A(i),l=t.padding||10;return e.createElement("g",{key:"ann-"+n},e.createElement("circle",{cx:r.x,cy:r.y,r:r.r+l,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.createElement("text",{x:r.x,y:r.y-r.r-l-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"rect-enclose":{const i=(t.coordinates||[]).map(e=>({x:Ce(Object.assign(Object.assign({},e),{type:"point"}),o),y:ze(Object.assign(Object.assign({},e),{type:"point"}),o)})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const r=t.padding||10,l=i.map(e=>e.x),a=i.map(e=>e.y),s=Math.min(...l)-r,c=Math.max(...l)+r,u=Math.min(...a)-r,d=Math.max(...a)+r;return e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:s,y:u,width:c-s,height:d-u,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"#666",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.createElement("text",{x:(s+c)/2,y:u-4,textAnchor:"middle",fill:t.color||"#666",fontSize:12},t.label))}case"highlight":{const i=o.data||[],r="function"==typeof t.filter?i.filter(t.filter):t.field&&null!=t.value?i.filter(e=>e[t.field]===t.value):[],l=t.style||{stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return e.createElement("g",{key:"ann-"+n},r.map((n,i)=>{const r=Ce(n,o),a=ze(n,o);return null==r||null==a?null:e.createElement("circle",Object.assign({key:"hl-"+i,cx:r,cy:a,r:t.r||6},l))}))}case"bracket":{const i=Ce(t,o),r=ze(t,o);return e.createElement(Ae,{key:"ann-"+n,noteData:{x:null!=i?i:0,y:null!=r?r:0,dx:t.dx||0,dy:t.dy||0,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"bracket",subject:{type:t.bracketType||"curly",width:t.width,height:t.height,depth:t.depth||30},color:t.color}})}case"trend":{const d=o.data||[];if(2>d.length)return null;const h=o.xAccessor||"x",f=o.yAccessor||"y",p=d.map(e=>[e[h],e[f]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>p.length)return null;const g=null!==(r=null===(i=o.scales)||void 0===i?void 0:i.x)&&void 0!==r?r:null===(l=o.scales)||void 0===l?void 0:l.time,m=null!==(s=null===(a=o.scales)||void 0===a?void 0:a.y)&&void 0!==s?s:null===(c=o.scales)||void 0===c?void 0:c.value;if(!g||!m)return null;const y=t.method||"linear";let v;v="loess"===y?function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),i=o.map(e=>e[0]),r=o.map(e=>e[1]),l=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=i[e],o=i.map(e=>Math.abs(e-t)),s=o.slice().sort((e,t)=>e-t)[Math.min(l-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===s?0:o[e]/s;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,f=0,p=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*i[e],h+=t*r[e],f+=t*i[e]*i[e],p+=t*i[e]*r[e])}if(0===u){a.push([t,r[e]]);continue}const g=u*f-d*d;if(1e-12>Math.abs(g))a.push([t,h/u]);else{const e=(u*p-d*h)/g;a.push([t,(h-e*d)/u+e*t])}}return a}(p,null!==(u=t.bandwidth)&&void 0!==u?u:.3):("polynomial"===y?_.polynomial(p,{order:t.order||2}):_.linear(p)).points;const b=v.map(([e,t])=>`${g(e)},${m(t)}`).join(" "),x=t.color||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("polyline",{points:b,fill:"none",stroke:x,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.createElement("text",{x:g(v[v.length-1][0])+4,y:m(v[v.length-1][1])-4,fill:x,fontSize:11},t.label))}case"band":{const i=null!==(h=null===(d=o.scales)||void 0===d?void 0:d.y)&&void 0!==h?h:null===(f=o.scales)||void 0===f?void 0:f.value,r=null!==(p=null==i?void 0:i(t.y0))&&void 0!==p?p:0,l=null!==(g=null==i?void 0:i(t.y1))&&void 0!==g?g:o.height||0;return e.createElement("g",{key:"ann-"+n},e.createElement("rect",{x:0,y:Math.min(r,l),width:o.width||0,height:Math.abs(l-r),fill:t.fill||"#6366f1",fillOpacity:t.fillOpacity||.1}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:Math.min(r,l)-4,textAnchor:"end",fill:t.color||"#6366f1",fontSize:11},t.label))}case"envelope":{const i=o.data||[];if(2>i.length)return null;const r=o.xAccessor||"x",l=null!==(y=null===(m=o.scales)||void 0===m?void 0:m.x)&&void 0!==y?y:null===(v=o.scales)||void 0===v?void 0:v.time,a=null!==(x=null===(b=o.scales)||void 0===b?void 0:b.y)&&void 0!==x?x:null===(k=o.scales)||void 0===k?void 0:k.value;if(!l||!a)return null;const s=t.upperAccessor||"upperBounds",c=t.lowerAccessor||"lowerBounds",u=t.filter,d=i.filter(e=>null!=e[s]&&null!=e[c]&&!(u&&!u(e))).sort((e,t)=>e[r]-t[r]);if(2>d.length)return null;const h=Se[o.curve||"linear"]||N,f=S().x(e=>l(e[r])).y0(e=>a(e[c])).y1(e=>a(e[s])).curve(h)(d);if(!f)return null;const p=t.fill||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("path",{d:f,fill:p,fillOpacity:null!==(w=t.fillOpacity)&&void 0!==w?w:.15,stroke:"none"}),t.label&&d.length>0&&e.createElement("text",{x:l(d[d.length-1][r])+4,y:a(d[d.length-1][s])-4,fill:p,fontSize:11},t.label))}case"anomaly-band":{const i=o.data||[];if(2>i.length)return null;const r=o.yAccessor||"y",l=null!==(j=null===(E=o.scales)||void 0===E?void 0:E.x)&&void 0!==j?j:null===(O=o.scales)||void 0===O?void 0:O.time,a=null!==(C=null===(M=o.scales)||void 0===M?void 0:M.y)&&void 0!==C?C:null===(z=o.scales)||void 0===z?void 0:z.value;if(!l||!a)return null;const s=i.map(e=>e[r]).filter(e=>null!=e&&isFinite(e));if(2>s.length)return null;const c=s.reduce((e,t)=>e+t,0)/s.length,u=s.reduce((e,t)=>e+Math.pow(t-c,2),0)/s.length,d=Math.sqrt(u),h=null!==(L=t.threshold)&&void 0!==L?L:2,f=c-h*d,p=!1!==t.showBand,g=t.fill||"#6366f1",m=null!==(P=t.fillOpacity)&&void 0!==P?P:.1,y=t.anomalyColor||"#ef4444",v=null!==($=t.anomalyRadius)&&void 0!==$?$:6,b=a(c+h*d),x=a(f),k=i.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-c)>h*d});return e.createElement("g",{key:"ann-"+n},p&&e.createElement("rect",{x:0,y:Math.min(b,x),width:o.width||0,height:Math.abs(x-b),fill:g,fillOpacity:m}),k.map((t,n)=>{const i=Ce(t,o),r=ze(t,o);return null==i||null==r?null:e.createElement("circle",{key:"anomaly-"+n,cx:i,cy:r,r:v,fill:y,fillOpacity:.7,stroke:y,strokeWidth:1.5})}),t.label&&e.createElement("text",{x:(o.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:g,fontSize:11},t.label))}case"forecast":{const i=o.data||[];if(3>i.length)return null;const r=o.xAccessor||"x",l=o.yAccessor||"y",a=null!==(D=null===(W=o.scales)||void 0===W?void 0:W.x)&&void 0!==D?D:null===(I=o.scales)||void 0===I?void 0:I.time,s=null!==(T=null===(B=o.scales)||void 0===B?void 0:B.y)&&void 0!==T?T:null===(R=o.scales)||void 0===R?void 0:R.value;if(!a||!s)return null;const c=i.map(e=>[e[r],e[l]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let u;if("polynomial"===(t.method||"linear")){const e=_.polynomial(c,{order:t.order||2}).equation;u=t=>e.reduce((e,n,o)=>e+n*Math.pow(t,o),0)}else{const e=c.length;let t=0,n=0,o=0,i=0;for(const[e,r]of c)t+=e,n+=r,o+=e*e,i+=e*r;const r=e*o-t*t;if(1e-12>Math.abs(r))return null;const l=(e*i-t*n)/r,a=(n-l*t)/e;u=e=>a+l*e}const d=c.length,h=c.map(([e,t])=>t-u(e)).reduce((e,t)=>e+t*t,0),f=Math.sqrt(h/Math.max(d-2,1)),p=c.reduce((e,t)=>e+t[0],0)/d,g=c.reduce((e,t)=>e+Math.pow(t[0]-p,2),0),m=null!==(F=t.confidence)&&void 0!==F?F:.95,y=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,v=null!==(H=t.steps)&&void 0!==H?H:5,b=c[d-1][0],x=(b-c[0][0])/Math.max(d-1,1),k=[];for(let e=1;v>=e;e++)k.push(b+e*x);const w=[];for(const e of k){const t=u(e),n=f*Math.sqrt(1+1/d+(g>0?Math.pow(e-p,2)/g:0))*y;w.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const E=`M${w.map(e=>`${a(e.x)},${s(e.yUpper)}`).join(" L")} L${w.slice().reverse().map(e=>`${a(e.x)},${s(e.yLower)}`).join(" L")} Z`,j=w.map(e=>`${a(e.x)},${s(e.yCenter)}`).join(" "),O=`${a(b)},${s(u(b))}`,M=t.strokeColor||"#6366f1";return e.createElement("g",{key:"ann-"+n},e.createElement("path",{d:E,fill:t.fill||"#6366f1",fillOpacity:null!==(G=t.fillOpacity)&&void 0!==G?G:.15,stroke:"none"}),e.createElement("polyline",{points:`${O} ${j}`,fill:"none",stroke:M,strokeWidth:null!==(q=t.strokeWidth)&&void 0!==q?q:2,strokeDasharray:null!==(Z=t.strokeDasharray)&&void 0!==Z?Z:"6,3"}),t.label&&w.length>0&&e.createElement("text",{x:a(w[w.length-1].x)+4,y:s(w[w.length-1].yCenter)-4,fill:M,fontSize:11},t.label))}case"widget":{let i=null,r=null;if(null!=t.px&&null!=t.py)i=t.px,r=t.py;else{const e=Le(t,n,o);if(!e)return null;i=e.x,r=e.y}if(null==i||null==r)return null;if(!Pe(i,r,o))return null;const l=null!==(U=t.dx)&&void 0!==U?U:0,a=null!==(Y=t.dy)&&void 0!==Y?Y:0,s=null!==(X=t.width)&&void 0!==X?X:32,c=null!==(V=t.height)&&void 0!==V?V:32,u=null!==(K=t.content)&&void 0!==K?K:e.createElement("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info"},"ℹ️");return e.createElement("foreignObject",{key:"ann-"+n,x:i+l-s/2,y:r+a-c/2,width:s,height:c,style:{overflow:"visible",pointerEvents:"auto"}},e.createElement("div",{style:{width:s,height:c,display:"flex",alignItems:"center",justifyContent:"center"}},u))}case"text":{const i=Le(t,n,o);if(!i)return null;const{x:r,y:l}=i;return e.createElement("text",{key:"ann-text-"+n,x:r+(t.dx||0),y:l+(t.dy||0),fill:t.color||"var(--semiotic-text, #333)",fontSize:t.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"}},t.label)}default:return null}},n={scales:d?{x:d.x,y:d.y,time:d.x,value:d.y}:null,timeAxis:"x",xAccessor:W,yAccessor:D,width:l,height:a,data:I,frameType:"xy",pointNodes:B,curve:T,stickyPositionCache:q.current};return P.map((e,o)=>{if($){const i=$(e,o,n);return null!=i?i:t(e,o,n)}return t(e,o,n)}).filter(Boolean)},[P,$,l,a,W,D,I,d,B,T]);return h||b||x||M||C||Y&&Y.length>0||v||F?e.createElement("svg",{role:"img",width:s,height:c,style:{position:"absolute",top:0,left:0,pointerEvents:"none"}},e.createElement("title",null,"string"==typeof b?b:"XY Chart"),e.createElement("desc",null,"string"==typeof b?b+" — XY data visualization":"XY data visualization"),e.createElement("g",{transform:`translate(${u.left},${u.top})`},v&&d&&!R&&e.createElement("g",{className:"stream-grid"},H.map((t,n)=>e.createElement("line",{key:"xgrid-"+n,x1:t.pixel,y1:0,x2:t.pixel,y2:a,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1})),G.map((t,n)=>e.createElement("line",{key:"ygrid-"+n,x1:0,y1:t.pixel,x2:l,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1}))),h&&d&&(()=>{const t=null==f?void 0:f.find(e=>"left"===e.orient),n=null==f?void 0:f.find(e=>"bottom"===e.orient),o=!t||!1!==t.baseline,i=(null==t?void 0:t.jaggedBase)||!1,r=(null==n?void 0:n.jaggedBase)||!1,s=null==n?void 0:n.landmarkTicks,c=null==t?void 0:t.landmarkTicks,d="var(--semiotic-border, #ccc)",h="var(--semiotic-text-secondary, #666)",m="var(--semiotic-text, #333)";return e.createElement("g",{className:"stream-axes"},!R&&(!n||!1!==n.baseline)&&!r&&e.createElement("line",{x1:0,y1:a,x2:l,y2:a,stroke:d,strokeWidth:1}),!R&&r&&e.createElement("path",{d:$e("bottom",l,a),fill:"none",stroke:d,strokeWidth:1}),H.map((t,n)=>{const o=!!s&&("function"==typeof s?s(t.value,n):De(t.value,n>0?H[n-1].value:void 0));return e.createElement("g",{key:"xtick-"+n,transform:`translate(${t.pixel},${a})`},e.createElement("line",{y2:5,stroke:d,strokeWidth:1}),e.createElement("text",{y:18,textAnchor:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:h,style:{userSelect:"none"}},t.label))}),p&&e.createElement("text",{x:l/2,y:a+40,textAnchor:"middle",fontSize:12,fill:m,style:{userSelect:"none"}},p),!R&&o&&!i&&e.createElement("line",{x1:0,y1:0,x2:0,y2:a,stroke:d,strokeWidth:1}),!R&&i&&e.createElement("path",{d:$e("left",l,a),fill:"none",stroke:d,strokeWidth:1}),G.map((t,n)=>{const o=!!c&&("function"==typeof c?c(t.value,n):De(t.value,n>0?G[n-1].value:void 0));return e.createElement("g",{key:"ytick-"+n,transform:`translate(0,${t.pixel})`},e.createElement("line",{x2:-5,stroke:d,strokeWidth:1}),e.createElement("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:h,style:{userSelect:"none"}},t.label))}),g&&e.createElement("text",{x:15-u.left,y:a/2,textAnchor:"middle",fontSize:12,fill:m,transform:`rotate(-90, ${15-u.left}, ${a/2})`,style:{userSelect:"none"}},g))})(),Y,C&&d&&z&&L&&e.createElement(e.Fragment,null,C.top&&e.createElement("g",{transform:"translate(0, 0)"},e.createElement(Ee,{orient:"top",config:we(C.top),values:z,scale:d.x,size:u.top,length:l})),C.bottom&&e.createElement("g",{transform:`translate(0, ${a})`},e.createElement(Ee,{orient:"bottom",config:we(C.bottom),values:z,scale:d.x,size:u.bottom,length:l})),C.left&&e.createElement("g",{transform:"translate(0, 0)"},e.createElement(Ee,{orient:"left",config:we(C.left),values:L,scale:d.y,size:u.left,length:a})),C.right&&e.createElement("g",{transform:`translate(${l}, 0)`},e.createElement(Ee,{orient:"right",config:we(C.right),values:L,scale:d.y,size:u.right,length:a}))),M,F),b&&e.createElement("text",{x:s/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"}},"string"==typeof b?b:null),function(t){const{legend:n,totalWidth:o,totalHeight:i,margin:r,legendPosition:l="right",title:a,legendHoverBehavior:s,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=t;if(!n)return null;const f="top"===l||"bottom"===l;let p,g;return"left"===l?(p=4,g=r.top):"top"===l?(p=0,g=a?32:8):"bottom"===l?(p=0,g=i-r.bottom+50):(p=o-r.right+10,g=r.top),e.createElement("g",{transform:`translate(${p}, ${g})`},"object"==typeof(m=n)&&null!==m&&"gradient"in m?e.createElement(xe,{config:n.gradient,orientation:f?"horizontal":"vertical",width:f?o:100}):function(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}(n)?e.createElement(ke,{legendGroups:n.legendGroups,title:"",width:f?o:100,orientation:f?"horizontal":"vertical",customHoverBehavior:s,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):n);var m}({legend:x,totalWidth:s,totalHeight:c,margin:u,legendPosition:O,title:b,legendHoverBehavior:k,legendClickBehavior:w,legendHighlightedCategory:E,legendIsolatedCategories:j})):null}const Ne="undefined"==typeof window||"undefined"==typeof document,Be={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Te(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e)n[t.type]=(n[t.type]||0)+1;const o=[],i={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks"},r=["point","line","area","rect","heatcell","circle","candlestick"],l=Object.keys(n).sort((e,t)=>{const n=r.indexOf(e),o=r.indexOf(t);return(-1===n?999:n)-(-1===o?999:o)});for(const e of l)o.push(`${n[e]} ${i[e]||e}`);return`${t}, ${o.join(", ")}`}function _e({scene:t,chartType:n}){var o,i,r,l;const a=[];for(const e of t){if(a.length>=50)break;"point"===e.type?a.push({label:"Point",values:{x:Math.round(100*e.x)/100+"",y:Math.round(100*e.y)/100+""}}):"rect"===e.type?a.push({label:"Bar",values:{category:(null===(o=e.datum)||void 0===o?void 0:o.category)||"",value:Math.round(100*(null!==(r=null===(i=e.datum)||void 0===i?void 0:i.value)&&void 0!==r?r:0))/100+""}}):"heatcell"===e.type&&a.push({label:"Cell",values:{x:Math.round(100*e.x)/100+"",y:Math.round(100*e.y)/100+"",value:Math.round(100*(null!==(l=e.value)&&void 0!==l?l:0))/100+""}})}if(0===a.length)return null;const s=new Set;for(const e of a)for(const t of Object.keys(e.values))s.add(t);const c=Array.from(s);return e.createElement("table",{style:Be,role:"table","aria-label":"Data table for "+n},e.createElement("thead",null,e.createElement("tr",null,c.map(t=>e.createElement("th",{key:t},t)))),e.createElement("tbody",null,a.map((t,n)=>e.createElement("tr",{key:n},c.map(n=>{var o;return e.createElement("td",{key:n},null!==(o=t.values[n])&&void 0!==o?o:"")}))),t.length>50&&e.createElement("tr",null,e.createElement("td",{colSpan:c.length},"...and ",t.length-50," more items"))))}function Re({hoverPoint:t}){let n="";if(t){const e=t.data||t;n="object"==typeof e?"Focused on data point: "+Object.entries(e).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Focused on data point: "+e}return e.createElement("div",{"aria-live":"polite","aria-atomic":"true",style:Be},n)}function Fe(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function He(e,t,n=.6){var o,i,r,l,a;if(!Fe(t))return;const s=null!==(o=t._pulseGlowRadius)&&void 0!==o?o:4,c=t.r+s*t._pulseIntensity,u=null!==(r=null!==(i=t.cx)&&void 0!==i?i:t.x)&&void 0!==r?r:0,d=null!==(a=null!==(l=t.cy)&&void 0!==l?l:t.y)&&void 0!==a?a:0;e.beginPath(),e.arc(u,d,c,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function Ge(e,t,n,o=.35){Fe(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}function qe(e){switch(e){case"monotoneX":return I;case"monotoneY":return D;case"cardinal":return z;case"catmullRom":return C;case"step":return W;case"stepBefore":return P;case"stepAfter":return $;case"basis":return L;case"natural":return T;default:return null}}function Ze(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}function Ue(e,t,n,o,i,r){if(2>t.length)return;const l=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],o=t[e][1]-t[e-1][1];l.push(l[e-1]+Math.sqrt(n*n+o*o))}const a=l[l.length-1];if(0===a)return;const s=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=o,e.lineCap=r;for(let n=0;t.length-1>n;n++){const o=(l[n]+l[n+1])/2;let r=i;s>o&&(r*=o/s),s>a-o&&(r*=(a-o)/s),e.globalAlpha=Math.max(0,r),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}function Ye(e){return e.k}function Xe(e){return[e.x,e.y]}function Ve(e){return function(){return e}}function Ke([e,t,n]){const o=1<<n;return[e-Math.floor(e/o)*o,t-Math.floor(t/o)*o,n]}function Je(e,t,n,o){const i=e.getContext("2d");if(!i)return null;const r=t[0]*o,l=t[1]*o,a=t[0]+"px",s=t[1]+"px";return e.style.width!==a&&(e.style.width=a),e.style.height!==s&&(e.style.height=s),e.width===r&&e.height===l||(e.width=r,e.height=l),i.setTransform(o,0,0,o,0,0),i.translate(n.left,n.top),i}function Qe(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function et(e,t,n,o,i){return"function"==typeof e?e(t,n,o,i):e.replace("{z}",t+"").replace("{x}",n+"").replace("{y}",o+"").replace("{r}",i>1?"@2x":"")}class tt{constructor(e=256){this.cache=new Map,this.limit=e}get(e){const t=this.cache.get(e);return t&&(t.lastUsed=performance.now()),t}set(e,t){this.cache.set(e,t),this.cache.size>this.limit&&this.evict()}evict(){for(;this.cache.size>this.limit;){let e,t=1/0;for(const[n,o]of this.cache)t>o.lastUsed&&(t=o.lastUsed,e=n);if(!e)break;{const t=this.cache.get(e);t&&(t.img.onload=null,t.img.onerror=null,t.img.src=""),this.cache.delete(e)}}}clear(){for(const e of this.cache.values())e.img.onload=null,e.img.onerror=null,e.img.src="";this.cache.clear()}}class nt{constructor(e){this.capacity=e,this.particles=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,lineIndex:0,active:!1,x:0,y:0}}spawn(e){for(let t=0;this.capacity>t;t++){const n=this.particles[t];if(!n.active)return n.active=!0,n.t=0,n.offset=.6*(Math.random()-.5),n.lineIndex=e,n.x=0,n.y=0,n}return null}step(e,t,n,o){for(let i=0;this.capacity>i;i++){const r=this.particles[i];if(!r.active)continue;const l=n[r.lineIndex];if(!l||2>l.length){r.active=!1;continue}if(r.t+=e*t,r.t>=1){r.active=!1;continue}const a=ot(l),s=it(l,r.t*a),c=(o[r.lineIndex]||2)/2;r.x=s.x+s.nx*r.offset*c*2,r.y=s.y+s.ny*r.offset*c*2}}countForLine(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].lineIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1}}function ot(e){let t=0;for(let n=1;e.length>n;n++){const o=e[n][0]-e[n-1][0],i=e[n][1]-e[n-1][1];t+=Math.sqrt(o*o+i*i)}return t}function it(e,t){let n=0;for(let o=1;e.length>o;o++){const i=e[o][0]-e[o-1][0],r=e[o][1]-e[o-1][1],l=Math.sqrt(i*i+r*r);if(n+l>=t||o===e.length-1){const a=l>0?(t-n)/l:0,s=l>.001?l:1;return{x:e[o-1][0]+i*a,y:e[o-1][1]+r*a,nx:-r/s,ny:i/s}}n+=l}const o=e[e.length-1];return{x:o[0],y:o[1],nx:0,ny:0}}function rt(n){const o=r(null),c=lt(n);return[function({children:t}){const r=i(()=>lt(n),[]);return e.createElement(o.Provider,{value:r,children:t})},e=>{var n;const i=null!==(n=l(o))&&void 0!==n?n:c,r=t(e);r.current=e;const u=a(()=>r.current(i.getState()),[i]),d=a(()=>r.current(i.getState()),[i]);return s(i.subscribe,u,d)}]}function lt(e){const t=new EventTarget;let n=e(function(e){n=Object.assign(Object.assign({},n),e(n)),t.dispatchEvent(new CustomEvent("update"))});return{getState:()=>n,subscribe:function(e){return t.addEventListener("update",e),()=>t.removeEventListener("update",e)}}}const at={mode:"light",colors:{primary:"#00a2ce",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",background:"transparent",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},st={mode:"dark",colors:{primary:"#4fc3f7",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",background:"#1a1a2e",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},[ct,ut]=rt(e=>({theme:at,setTheme(t){e(e=>"light"===t?{theme:at}:"dark"===t?{theme:st}:{theme:Object.assign(Object.assign(Object.assign({},e.theme),t),{colors:Object.assign(Object.assign({},e.theme.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.theme.typography),t.typography||{})})})}})),dt={top:10,right:10,bottom:10,left:10},ht={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12,lineHeight:1.5,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"},ft={width:28,height:28,border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,background:"rgba(255,255,255,0.9)",color:"#333",fontSize:16,fontWeight:600,lineHeight:1,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",padding:0,boxShadow:"0 1px 3px rgba(0,0,0,0.1)"};function pt({data:t}){if(!t)return null;if(t.properties)return e.createElement("div",{className:"semiotic-tooltip",style:ht},e.createElement("div",{style:{fontWeight:600}},t.properties.name||t.properties.NAME||t.properties.id||"Feature"));const n=Object.entries(t).slice(0,3);return e.createElement("div",{className:"semiotic-tooltip",style:ht},n.map(([t,n])=>e.createElement("div",{key:t},e.createElement("span",{style:{opacity:.7}},t,": "),e.createElement("span",{style:{fontWeight:600}},n+""))))}const gt=c(function(r,l){var s,c,d,h,f,p,g;const{projection:m,projectionExtent:y,fitPadding:v,projectionTransform:b,areas:x,points:k,lines:w,xAccessor:E,yAccessor:j,lineDataAccessor:O,pointIdAccessor:M,lineType:A="geo",flowStyle:S="basic",graticule:C,zoomable:z,zoomExtent:L,onZoom:P,dragRotate:$,showParticles:W,particleStyle:D,tileURL:I,tileAttribution:N,tileCacheSize:T,size:_,width:G,height:q,responsiveWidth:Z,responsiveHeight:U,margin:Y,className:X,background:V,areaStyle:K,pointStyle:J,lineStyle:Q,colorScheme:ee,enableHover:te=!0,hoverAnnotation:ne,tooltipContent:oe,customClickBehavior:ie,customHoverBehavior:re,annotations:le,decay:ae,pulse:se,transition:ce,staleness:ue,backgroundGraphics:de,foregroundGraphics:he,title:ge,legend:me,legendPosition:ye,legendHoverBehavior:ve,legendClickBehavior:be,legendHighlightedCategory:xe,legendIsolatedCategories:ke,showAxes:we,accessibleTable:Ee}=r,je=_||[G||600,q||400],[Oe,Me]=function(e,i,r){const l=t(null),[a,s]=n(null);return o(()=>{if(!i&&!r)return;const e=l.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;s(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[i,r]),[l,[i&&a?a.w:e[0],r&&a?a.h:e[1]]]}(je,Z,U),Ae=i(()=>Object.assign(Object.assign({},dt),Y),[Y]),Se=Me[0]-Ae.left-Ae.right,Ce=Me[1]-Ae.top-Ae.bottom,ze="function"==typeof he?he({size:Me,margin:Ae}):he,Le="function"==typeof de?de({size:Me,margin:Ae}):de,Pe=i(()=>null!=$?$:"orthographic"===("string"==typeof m?m:"object"==typeof m&&"type"in m?m.type:null),[$,m]),$e=i(()=>({projection:m,projectionExtent:y,fitPadding:v,xAccessor:E,yAccessor:j,lineDataAccessor:O,lineType:A,flowStyle:S,areaStyle:K,pointStyle:J,lineStyle:Q,colorScheme:ee,graticule:C,projectionTransform:b,decay:ae,pulse:se,transition:ce,annotations:le,pointIdAccessor:M}),[m,y,v,E,j,O,A,S,K,J,Q,ee,C,b,ae,se,ce,le,M]),We=t(null);We.current||(We.current=new fe($e));const De=t(null),Be=t(null),Fe=t(null),ot=t(null),it=t(null);I&&!it.current&&(it.current=new tt(T||256));const rt=t(0),lt=t(!0),at=ut(e=>e.theme),st=t(le),ct=t(()=>{}),ht=t(null),gt=t(R),mt=t(!1),yt=t(null),vt=t(null),bt=t(null),xt=t(null),kt=t(0);if(W&&!xt.current){const e=null!==(s=null==D?void 0:D.maxPerLine)&&void 0!==s?s:30;xt.current=new nt(50*e)}const wt=t(null),Et=t(null),[jt,Ot]=n(null),[Mt,At]=n(0),[St,Ct]=n(!1),zt=a(()=>{rt.current||(rt.current=requestAnimationFrame(()=>ct.current()))},[]);o(()=>{lt.current=!0,zt()},[at,zt]),o(()=>{var e;null===(e=We.current)||void 0===e||e.updateConfig($e),lt.current=!0,zt()},[$e,zt]),o(()=>{const e=We.current;e&&(x&&e.setAreas(x),k&&e.setPoints(k),w&&e.setLines(w),lt.current=!0,zt())},[x,k,w,zt]);const Lt=a(e=>{var t;null===(t=We.current)||void 0===t||t.pushPoint(e),lt.current=!0,zt()},[zt]),Pt=a(e=>{var t;null===(t=We.current)||void 0===t||t.pushMany(e),lt.current=!0,zt()},[zt]),$t=a(()=>{var e;null===(e=We.current)||void 0===e||e.clear(),lt.current=!0,zt()},[zt]);u(l,()=>({push:Lt,pushMany:Pt,clear:$t,getProjection:()=>{var e,t,n;return null!==(n=null===(t=null===(e=We.current)||void 0===e?void 0:e.scales)||void 0===t?void 0:t.projection)&&void 0!==n?n:null},getGeoPath:()=>{var e,t,n;return null!==(n=null===(t=null===(e=We.current)||void 0===e?void 0:e.scales)||void 0===t?void 0:t.geoPath)&&void 0!==n?n:null},getCartogramLayout:()=>{var e,t;return null!==(t=null===(e=We.current)||void 0===e?void 0:e.cartogramLayout)&&void 0!==t?t:null},getZoom:()=>gt.current.k,resetZoom:()=>{const e=yt.current;e&&ht.current&&H(e).call(ht.current.transform,R)},getData:()=>{const e=We.current;return e?e.scene.filter(e=>"point"===e.type).map(e=>e.datum).filter(Boolean):[]}}),[Lt,Pt,$t]);const Wt=t(()=>{});o(()=>{Wt.current=e=>{if(!te)return;const t=We.current;if(!t||!t.scene.length)return;const n=e.currentTarget.getBoundingClientRect(),o=e.clientX-n.left-Ae.left,i=e.clientY-n.top-Ae.top;if(0>o||o>Se||0>i||i>Ce)return wt.current=null,Et.current=null,Ot(null),null==re||re(null),void zt();ot.current||(ot.current="undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"));const r=ot.current.getContext("2d");if(!r)return;const l=pe(t.scene,o,i,30,r);if(l){const e=l.node,t=e.datum,n=(null==t?void 0:t.properties)?t:(null==t?void 0:t.data)||t;let r,a;"point"===e.type?(r=e.x,a=e.y):"geoarea"===e.type?(r=e.centroid[0],a=e.centroid[1]):(r=o,a=i);const s=Object.assign(Object.assign(Object.assign({},n),(null==n?void 0:n.properties)||{}),{data:n,x:r,y:a,time:0});wt.current=s,Et.current=e,Ot(s),null==re||re({type:e.type,data:n,x:r,y:a}),zt()}else wt.current&&(wt.current=null,Et.current=null,Ot(null),null==re||re(null),zt())}},[te,Se,Ce,Ae,re,zt]);const Dt=a(e=>Wt.current(e),[]),It=a(()=>{wt.current=null,Et.current=null,Ot(null),null==re||re(null),zt()},[re,zt]),Nt=a(e=>{if(!ie)return;const t=We.current;if(!t||!t.scene.length)return;const n=e.currentTarget.getBoundingClientRect(),o=e.clientX-n.left-Ae.left,i=e.clientY-n.top-Ae.top;ot.current||(ot.current="undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"));const r=ot.current.getContext("2d");if(!r)return;const l=pe(t.scene,o,i,30,r);if(l){const e=l.node.datum;ie({type:l.node.type,data:(null==e?void 0:e.properties)?e:(null==e?void 0:e.data)||e,x:o,y:i})}},[ie,Ae]);ct.current=()=>{var e,t,n,o,i,r,l;rt.current=0;const a=Be.current,s=We.current;if(!a||!s)return;const c=performance.now();let u=!1;const d=bt.current;d&&(bt.current=null,s.applyRotation(d,{width:Se,height:Ce}));const h=s.advanceTransition(c);if(lt.current&&!h){const e={width:Se,height:Ce},t=Pe?s.getRotation():null;s.computeScene(e);const n=gt.current,o=1!==n.k||0!==n.x||0!==n.y;Pe&&t?o?(s.setRotation(t),s.applyZoomScale(n.k,e)):s.applyRotation(t,e):o&&s.applyZoomTransform(n,e),lt.current=!1,a.setAttribute("aria-label",Te(s.scene,"Geographic chart"))}const f=Qe();if(I&&it.current){const t=De.current;if(t&&(null===(e=s.scales)||void 0===e?void 0:e.projection)){const e=Je(t,Me,Ae,f);if(e){e.clearRect(-Ae.left,-Ae.top,Me[0],Me[1]),e.save(),e.beginPath(),e.rect(0,0,Se,Ce),e.clip();const t=function(e,t){const{tileURL:n,projection:o,width:i,height:r,tileCache:l,onTileLoad:a}=t,s=o.scale(),c=o.translate(),u=2*s*Math.PI,d=function(){let e=0,t=0,n=960,o=500,i=!0,r=!0,l=256,a=Ye,s=Xe,c=0;function u(){const u=+a.apply(this,arguments),d=s.apply(this,arguments),h=Math.log2(u/l),f=Math.round(Math.max(h+c,0)),p=Math.pow(2,h-f)*l,g=+d[0]-u/2,m=+d[1]-u/2,y=Math.max(i?0:-1/0,Math.floor((e-g)/p)),v=Math.min(i?1<<f:1/0,Math.ceil((n-g)/p)),b=Math.max(r?0:-1/0,Math.floor((t-m)/p)),x=Math.min(r?1<<f:1/0,Math.ceil((o-m)/p)),k=[];for(let e=b;x>e;++e)for(let t=y;v>t;++t)k.push([t,e,f]);return k.translate=[g/p,m/p],k.scale=p,k}return u.size=function(i){return arguments.length?(e=t=0,n=+i[0],o=+i[1],u):[n-e,o-t]},u.extent=function(i){return arguments.length?(e=+i[0][0],t=+i[0][1],n=+i[1][0],o=+i[1][1],u):[[e,t],[n,o]]},u.scale=function(e){return arguments.length?(a="function"==typeof e?e:Ve(+e),u):a},u.translate=function(e){return arguments.length?(s="function"==typeof e?e:Ve([+e[0],+e[1]]),u):s},u.zoomDelta=function(e){return arguments.length?(c=+e,u):c},u.tileSize=function(e){return arguments.length?(l=+e,u):l},u.clamp=function(e){return arguments.length?(i=r=!!e,u):i&&r},u.clampX=function(e){return arguments.length?(i=!!e,u):i},u.clampY=function(e){return arguments.length?(r=!!e,u):r},u}().size([i,r]).scale(u).translate(c).clamp(!0)(),h=Qe();let f=!0;for(const t of d){const[o,i,r]=Ke(t),s=`${r}/${o}/${i}`;let c=l.get(s);if(!c){const e=new Image;e.crossOrigin="anonymous";const t={img:e,loaded:!1,key:s,lastUsed:performance.now()};l.set(s,t),e.onload=()=>{t.loaded=!0,null==a||a()},e.onerror=()=>{t.loaded=!0},e.src=et(n,r,o,i,h),c=t}if(!c.loaded){f=!1;continue}const u=d.scale;e.drawImage(c.img,(t[0]+d.translate[0])*u-.5,(t[1]+d.translate[1])*u-.5,u+1,u+1)}return f}(e,{tileURL:I,projection:s.scales.projection,width:Se,height:Ce,tileCache:it.current,onTileLoad:()=>zt()});e.restore(),t||(u=!0)}}}const p=Je(a,Me,Ae,f);if(!p)return;p.clearRect(-Ae.left,-Ae.top,Me[0],Me[1]),V&&!I&&(p.fillStyle=V,p.fillRect(0,0,Se,Ce)),p.save(),p.beginPath(),p.rect(0,0,Se,Ce),p.clip();const g=s.scene,m={height:Ce};if(function(e,t){var n,o,i;const r=t.filter(e=>"geoarea"===e.type);for(const t of r){if(!t.pathData)continue;const r=new Path2D(t.pathData),l=t.style.fill||"#e0e0e0";if("none"!==l&&(e.fillStyle=l,e.globalAlpha=(null!==(n=t._decayOpacity)&&void 0!==n?n:1)*(null!==(o=t.style.fillOpacity)&&void 0!==o?o:1),e.fill(r)),t.style.stroke&&"none"!==t.style.stroke){if(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||.5,e.globalAlpha=null!==(i=t._decayOpacity)&&void 0!==i?i:1,t.style.strokeDasharray){const n=t.style.strokeDasharray.split(",").map(Number);e.setLineDash(n)}else e.setLineDash([]);e.stroke(r)}Ge(e,t,r),e.globalAlpha=1,e.setLineDash([])}}(p,g),((e,t,n,o)=>{var i,r;const l=t.filter(e=>"line"===e.type);for(const a of l){if(2>a.path.length)continue;const s=a.style.stroke||"#007bff",c=a.style.strokeWidth||2,u=a.colorThresholds,d=a.rawValues;if(e.setLineDash(a.style.strokeDasharray?a.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=a.style.opacity&&(e.globalAlpha=a.style.opacity),e.lineWidth=c,e.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const g=null!==(i=a.style.opacity)&&void 0!==i?i:1;Ue(e,a.path,s,c,g,a.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const h=qe(a.curve),f=u&&u.length>0&&d&&d.length===a.path.length,p=a._decayOpacities;if(p&&p.length===a.path.length&&!f){e.strokeStyle=s;const m=null!==(r=a.style.opacity)&&void 0!==r?r:1;for(let y=0;a.path.length-1>y;y++)e.globalAlpha=.5*(p[y]+p[y+1])*m,e.beginPath(),e.moveTo(a.path[y][0],a.path[y][1]),e.lineTo(a.path[y+1][0],a.path[y+1][1]),e.stroke()}else if(f){let v=null,b=null,x=null,k=null,w=!1;function E(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),w=!0}function j(){w&&(e.stroke(),w=!1)}for(let O=0;a.path.length>O;O++){const[M,A]=a.path[O],S=d[O],C=Ze(S,u,s);if(null!==v&&null!==k&&null!==x){if(C===k)e.lineTo(M,A);else{const z=[];for(const L of u){const P=L.value;(x>P||P>S)&&(P>x||S>P)||x===P||S===P||z.push({t:(P-x)/(S-x)})}z.sort((e,t)=>e.t-t.t);for(const $ of z){const W=v+(M-v)*$.t,D=b+(A-b)*$.t,I=Ze(x+(S-x)*Math.min($.t+1e-4,1),u,s);e.lineTo(W,D),j(),E(I,W,D)}e.lineTo(M,A)}v=M,b=A,x=S,k=C}else E(C,M,A),v=M,b=A,x=S,k=C}j()}else{if(e.beginPath(),e.strokeStyle=s,h)B().x(e=>e[0]).y(e=>e[1]).curve(h).context(e)(a.path);else{const[N,T]=a.path[0];e.moveTo(N,T);for(let _=1;a.path.length>_;_++)e.lineTo(a.path[_][0],a.path[_][1])}e.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=a.style.fillOpacity,e.fillStyle=a.style.fill,h&&!f)B().x(e=>e[0]).y(e=>e[1]).curve(h).context(e)(a.path);else{const[F,H]=a.path[0];e.moveTo(F,H);for(let G=1;a.path.length>G;G++)e.lineTo(a.path[G][0],a.path[G][1])}const R=a.path[0][0];e.lineTo(a.path[a.path.length-1][0],o.height),e.lineTo(R,o.height),e.closePath(),e.fill()}e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}})(p,g,0,m),((e,t)=>{var n;const o=t.filter(e=>"point"===e.type);e.save();try{for(const t of o){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const o=null!==(n=t.style.opacity)&&void 0!==n?n:t.style.fillOpacity;null!=o&&(e.globalAlpha=o),e.fillStyle=t.style.fill||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),He(e,t),e.globalAlpha=1}}finally{e.restore()}})(p,g),W&&xt.current){const e=xt.current,l=g.filter(e=>"line"===e.type);if(l.length>0){const a=D||{},s=.3*(null!==(t=a.speedMultiplier)&&void 0!==t?t:1),d=null!==(n=a.maxPerLine)&&void 0!==n?n:30,h=null!==(o=a.spawnRate)&&void 0!==o?o:.15,f=null!==(i=a.radius)&&void 0!==i?i:2,g=null!==(r=a.opacity)&&void 0!==r?r:.7,m=c/1e3,y=kt.current>0?Math.min(m-kt.current,.1):.016;kt.current=m;const v=l.map(e=>e.path),b=l.map(e=>e.style.strokeWidth||2);for(let t=0;l.length>t;t++)Math.random()<h&&e.countForLine(t)<d&&e.spawn(t);e.step(y,s,v,b),p.globalAlpha=g;for(let t=0;e.particles.length>t;t++){const n=e.particles[t];if(!n.active)continue;const o=l[n.lineIndex],i="function"==typeof a.color?a.color(null==o?void 0:o.datum):"source"!==a.color&&a.color?a.color:(null==o?void 0:o.style.stroke)||"#fff";p.beginPath(),p.arc(n.x,n.y,f,0,2*Math.PI),p.fillStyle=i,p.fill()}p.globalAlpha=1,u=!0}}p.restore();const y=Fe.current;if(y){const e=Je(y,Me,Ae,f);if(e){e.clearRect(-Ae.left,-Ae.top,Me[0],Me[1]);const t=Et.current;if(t&&"geoarea"===t.type){const n=new Path2D(t.pathData);e.fillStyle="rgba(255, 255, 255, 0.3)",e.fill(n),e.strokeStyle="rgba(0, 0, 0, 0.5)",e.lineWidth=2,e.stroke(n)}if(t&&"point"===t.type){const n=t;e.beginPath(),e.arc(n.x,n.y,n.r+3,0,2*Math.PI),e.fillStyle="rgba(255, 255, 255, 0.4)",e.fill(),e.strokeStyle="rgba(0, 0, 0, 0.5)",e.lineWidth=2,e.stroke()}}}if(ue){const e=performance.now()-s.lastIngestTime>(null!==(l=ue.threshold)&&void 0!==l?l:5e3);e!==St&&Ct(e)}const v=le!==st.current;v&&(st.current=le),(lt.current||v)&&At(e=>e+1),(h||s.hasActivePulses||u)&&(rt.current=requestAnimationFrame(()=>ct.current()))},o(()=>(zt(),()=>{var e;rt.current&&(cancelAnimationFrame(rt.current),rt.current=0),null===(e=it.current)||void 0===e||e.clear()}),[zt]),o(()=>{lt.current=!0,zt()},[Se,Ce,V,zt]),function(e,t,n,i,r,l){o(()=>{if(!e)return;const o=setInterval(()=>{var o;const a=t.current;if(!a||0===a.lastIngestTime)return;const s="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(o=e.threshold)&&void 0!==o?o:5e3,u=s-a.lastIngestTime>c;u!==r&&(l(u),n.current=!0,i())},1e3);return()=>clearInterval(o)},[e,r,i])}(ue,We,lt,zt,St,Ct),o(()=>{if("production"!==process.env.NODE_ENV&&I){const e="string"==typeof m?m:"object"==typeof m&&"type"in m?m.type:null;e&&"mercator"!==e&&console.warn(`[StreamGeoFrame] tileURL is set but projection is "${e}". Raster tiles use Web Mercator and will not align with other projections.`)}},[I,m]),o(()=>{const e=yt.current;if(!z||!e)return ht.current&&e&&(H(e).on(".zoom",null),ht.current=null),void(e&&H(e).on("mousedown.rotate",null).on("touchstart.rotate",null));const[t,n]=L||[1,8],o={width:Se,height:Ce};if(Pe){let i=gt.current.k;const r=e=>{var r;i=Math.max(t,Math.min(n,e)),gt.current=R.scale(i);const l=We.current;l&&(l.applyZoomScale(i,o),lt.current=!1,zt(),null==P||P({projection:null===(r=l.scales)||void 0===r?void 0:r.projection,zoom:l.currentZoom}))};ht.current={scaleBy:(e,t)=>r(i*t),transform:(e,t)=>{var n;return r(null!==(n=null==t?void 0:t.k)&&void 0!==n?n:1)}};const l=e=>{e.preventDefault(),r(i*(0>e.deltaY?1.1:1/1.1))},a=e=>{const t=e.target;t&&(t.closest("button")||t.closest(".stream-geo-zoom-controls"))||(e.preventDefault(),r(1.5*i))};e.addEventListener("wheel",l,{passive:!1}),e.addEventListener("dblclick",a);const s=.4,c=t=>{if(0!==t.button)return;const n=t.target;if(n.closest("button")||n.closest(".stream-geo-zoom-controls"))return;const o=We.current;if(!o)return;const i=o.getRotation();vt.current={x:t.clientX,y:t.clientY,rotation:[...i]},e.setPointerCapture(t.pointerId),t.preventDefault()},u=e=>{const t=vt.current;t&&(bt.current=[t.rotation[0]+(e.clientX-t.x)*s,Math.max(-90,Math.min(90,t.rotation[1]-(e.clientY-t.y)*s)),t.rotation[2]],zt())},d=t=>{var n;if(!vt.current)return;vt.current=null,e.releasePointerCapture(t.pointerId);const i=bt.current;if(i){bt.current=null;const e=We.current;e&&(e.applyRotation(i,o),zt())}const r=We.current;r&&(null==P||P({projection:null===(n=r.scales)||void 0===n?void 0:n.projection,zoom:r.currentZoom}))};return e.addEventListener("pointerdown",c),e.addEventListener("pointermove",u),e.addEventListener("pointerup",d),e.addEventListener("pointercancel",d),()=>{e.removeEventListener("wheel",l),e.removeEventListener("dblclick",a),e.removeEventListener("pointerdown",c),e.removeEventListener("pointermove",u),e.removeEventListener("pointerup",d),e.removeEventListener("pointercancel",d),ht.current=null}}const i=F().scaleExtent([t,n]).extent([[0,0],[Me[0],Me[1]]]).translateExtent([[-1/0,-1/0],[1/0,1/0]]).on("zoom",e=>{const t=e.transform;gt.current=t,mt.current=!0;const n=We.current;n&&(n.applyZoomTransform(t,o),lt.current=!1,zt())}).on("end",e=>{var t;gt.current=e.transform,mt.current=!1;const n=We.current;n&&(null==P||P({projection:null===(t=n.scales)||void 0===t?void 0:t.projection,zoom:n.currentZoom}))});return ht.current=i,H(e).call(i),()=>{H(e).on(".zoom",null)}},[z,L,Pe,Me,Se,Ce,Ae,P,zt]);const Bt=te&&!1!==ne,Tt=Bt&&jt?oe?oe(jt):e.createElement(pt,{data:jt}):null,_t=Tt?e.createElement("div",{className:"stream-frame-tooltip",style:{position:"absolute",left:Ae.left+jt.x,top:Ae.top+jt.y,transform:`translate(${jt.x>.7*Se?"calc(-100% - 12px)":"12px"}, ${.3*Ce>jt.y?"4px":"calc(-100% - 4px)"})`,pointerEvents:"none",zIndex:10,width:"max-content"}},Tt):null;if(Ne){const t=We.current;t&&(x||k||w)&&(x&&t.setAreas(x),k&&t.setPoints(k),w&&t.setLines(w),t.computeScene({width:Se,height:Ce}));const n=null!==(c=null==t?void 0:t.scene)&&void 0!==c?c:[];return e.createElement("div",{className:"stream-geo-frame"+(X?" "+X:""),role:"img","aria-label":"string"==typeof ge?ge:"Geographic chart",style:{position:"relative",width:Me[0],height:Me[1]}},e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:Me[0],height:Me[1],style:{position:"absolute",left:0,top:0}},Le,e.createElement("g",{transform:`translate(${Ae.left},${Ae.top})`},V&&e.createElement("rect",{x:0,y:0,width:Se,height:Ce,fill:V}),n.map((t,n)=>function(t,n){var o,i,r,l,a,s;switch(t.type){case"geoarea":return t.pathData?e.createElement("path",{key:"geoarea-"+n,d:t.pathData,fill:t.style.fill||"#e0e0e0",fillOpacity:null!==(o=t.style.fillOpacity)&&void 0!==o?o:1,stroke:t.style.stroke||"none",strokeWidth:t.style.strokeWidth||.5,strokeDasharray:t.style.strokeDasharray,opacity:null!==(i=t._decayOpacity)&&void 0!==i?i:1}):null;case"point":return e.createElement("circle",{key:"point-"+n,cx:t.x,cy:t.y,r:t.r,fill:t.style.fill||"#4e79a7",fillOpacity:null!==(r=t.style.fillOpacity)&&void 0!==r?r:.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth,opacity:null!==(l=t._decayOpacity)&&void 0!==l?l:null!==(a=t.style.opacity)&&void 0!==a?a:1});case"line":{const o=t;if(2>o.path.length)return null;const i="M"+o.path.map(e=>`${e[0]},${e[1]}`).join("L");return e.createElement("path",{key:"line-"+n,d:i,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||1.5,strokeDasharray:o.style.strokeDasharray,opacity:null!==(s=o.style.opacity)&&void 0!==s?s:1})}default:return null}}(t,n)))),e.createElement(Ie,{width:Se,height:Ce,totalWidth:Me[0],totalHeight:Me[1],margin:Ae,scales:null,showAxes:!1,title:ge,legend:me,legendPosition:ye,legendHoverBehavior:ve,legendClickBehavior:be,legendHighlightedCategory:xe,legendIsolatedCategories:ke,foregroundGraphics:ze,annotations:le,annotationFrame:0,xValues:[],yValues:[],pointNodes:n.filter(e=>"point"===e.type)}))}const Rt=a(e=>{yt.current=e,Oe&&"object"==typeof Oe&&(Oe.current=e)},[Oe]);return e.createElement("div",{ref:Rt,className:"stream-geo-frame"+(X?" "+X:""),role:"img","aria-label":"string"==typeof ge?ge:"Geographic chart",tabIndex:0,style:Object.assign({position:"relative",width:Z?"100%":Me[0],height:U?"100%":Me[1],overflow:"hidden"},z?{touchAction:"none"}:{}),onMouseMove:Bt?Dt:void 0,onMouseLeave:Bt?It:void 0,onClick:ie?Nt:void 0},Le&&e.createElement("svg",{style:{position:"absolute",left:0,top:0,width:Me[0],height:Me[1],pointerEvents:"none"}},Le),I&&e.createElement("canvas",{ref:De,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),e.createElement("canvas",{ref:Be,"aria-label":Te(null!==(h=null===(d=We.current)||void 0===d?void 0:d.scene)&&void 0!==h?h:[],"Geographic chart"),style:{position:"absolute",left:0,top:0}}),e.createElement("canvas",{ref:Fe,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),e.createElement(Re,{hoverPoint:jt}),Ee&&e.createElement(_e,{scene:null!==(p=null===(f=We.current)||void 0===f?void 0:f.scene)&&void 0!==p?p:[],chartType:"Geographic chart"}),e.createElement(Ie,{width:Se,height:Ce,totalWidth:Me[0],totalHeight:Me[1],margin:Ae,scales:null,showAxes:null!=we&&we,title:ge,legend:me,legendPosition:ye,legendHoverBehavior:ve,legendClickBehavior:be,legendHighlightedCategory:xe,legendIsolatedCategories:ke,foregroundGraphics:ze,annotations:le,annotationFrame:Mt,xValues:[],yValues:[],pointNodes:null===(g=We.current)||void 0===g?void 0:g.scene.filter(e=>"point"===e.type)}),(null==ue?void 0:ue.showBadge)&&e.createElement("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===ue.badgePosition?{top:4,left:4}:"bottom-left"===ue.badgePosition?{bottom:4,left:4}:"bottom-right"===ue.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:St?"#dc3545":"#28a745",color:"white"})},St?"STALE":"LIVE"),z&&e.createElement("div",{className:"stream-geo-zoom-controls",style:{position:"absolute",bottom:Ae.bottom+8,left:Ae.left+8,display:"flex",flexDirection:"column",gap:2,zIndex:2}},e.createElement("button",{type:"button","aria-label":"Zoom in",onClick:e=>{e.stopPropagation();const t=yt.current,n=ht.current;t&&(null==n?void 0:n.scaleBy)&&n.scaleBy(H(t),1.5)},style:ft},"+"),e.createElement("button",{type:"button","aria-label":"Zoom out",onClick:e=>{e.stopPropagation();const t=yt.current,n=ht.current;t&&(null==n?void 0:n.scaleBy)&&n.scaleBy(H(t),1/1.5)},style:ft},"−")),N&&e.createElement("div",{className:"stream-geo-tile-attribution",style:{position:"absolute",bottom:Ae.bottom+2,right:Ae.right+4,fontSize:10,color:"rgba(0,0,0,0.6)",background:"rgba(255,255,255,0.7)",padding:"1px 4px",borderRadius:2,pointerEvents:"none",zIndex:2}},N),_t)});gt.displayName="StreamGeoFrame";const mt={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"8px 12px",borderRadius:"4px",fontSize:"14px",lineHeight:"1.5",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function yt(e,t){return"function"==typeof t?t(e):e[t]}function vt(e,t){return t?t(e):null==e?"":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function bt(t={}){const{fields:n,title:o,format:i,style:r={},className:l=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let a;const s=[];if(o){const e=yt(t,o);a=vt(e,i)}if(n&&n.length>0)n.forEach(e=>{let n,o,r;"string"==typeof e?(n=e,o=e,r=i):(n=e.label,o=e.accessor||e.key||"",r=e.format||i);const l=yt(t,o);s.push({label:n,value:vt(l,r)})});else if(!o){const e=["value","y","name","id","label"];for(const n of e)if(void 0!==t[n]){a=vt(t[n],i);break}if(!a){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(a=vt(t[e[0]],i))}}const c=Object.assign(Object.assign({},mt),r);return e.createElement("div",{className:("semiotic-tooltip "+l).trim(),style:c},a&&e.createElement("div",{style:{fontWeight:s.length>0?"bold":"normal"}},a),s.map((t,n)=>e.createElement("div",{key:n,style:{marginTop:0===n&&a?"4px":0}},t.label&&e.createElement("span",null,t.label,": "),t.value)))}}function xt(t){if(!0===t)return bt();if("function"==typeof t){const n=t;return t=>{const o=n(!t||"object"!=typeof t.data||null===t.data||"node"!==t.type&&"edge"!==t.type?t:t.data);return null==o?null:e.createElement("div",{className:"semiotic-tooltip",style:mt},o)}}return!1!==t&&void 0!==t&&("object"==typeof t&&null!==t&&("fields"in t||"title"in t)?bt(t):bt())}const kt={category10:G,tableau10:Q,set3:J,blues:K,reds:V,greens:X,oranges:Y,purples:U,viridis:Z,plasma:q},wt=G,Et=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 jt(e,t,n){if("function"==typeof t){const o=t(e);return n&&o&&"string"==typeof o&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||Et.has(t)}(o)?n(o):o}const o=e[t];return n?n(o):wt[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(o+""))%wt.length]}function Ot(e,t,n="category10"){const o=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e))),i=o.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return E().domain(o).range(n).unknown("#999");const r=kt[n]||kt.category10;if(i&&"function"==typeof r){let e=-1/0;for(const t of o){const n=Number(t);n>e&&(e=n)}return t=>r(Number(t)/e)}{const e=Array.isArray(r)?r:wt;return E().domain(o).range(e).unknown("#999")}}function Mt(e,t,n=[3,20],o){let i;if(i="function"==typeof t?t(e):e[t],!o)return i;const[r,l]=o,[a,s]=n;return l===r?(a+s)/2:a+(i-r)/(l-r)*(s-a)}const At=r(null);function St(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,i]=o.range;t.push(t=>{const o=t[n];return o>=e&&i>=o})}return e=>t.every(t=>t(e))}function Ct(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[zt,Lt]=rt(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),i=Ct(o,t),r=new Map(i.clauses);return r.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},i),{clauses:r})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const i=new Map(e.selections),r=new Map(o.clauses);return r.delete(n),i.set(t,Object.assign(Object.assign({},o),{clauses:r})),{selections:i}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),i=Ct(o,t);return o.set(t,Object.assign(Object.assign({},i),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}})),[Pt,$t]=rt(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function Wt(e){const t=d(),n=e.clientId||t,{name:o}=e,r=Lt(e=>e.selections.get(o)),l=Lt(e=>e.setClause),s=Lt(e=>e.clearClause),c=i(()=>!!r&&r.clauses.size>0,[r]);return{predicate:i(()=>r&&0!==r.clauses.size?function(e,t){const n=[];for(const[o,i]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(St(i));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(r,n):()=>!0,[r,n]),isActive:c,selectPoints:a(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};l(o,{clientId:n,type:"point",fields:t})},[n,o,l]),selectInterval:a(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};l(o,{clientId:n,type:"interval",fields:t})},[n,o,l]),clear:a(()=>{s(o,n)},[s,o,n]),clientId:n}}function Dt(e){const t=e.name||"hover",{fields:n}=e,{predicate:o,isActive:i,selectPoints:r,clear:l}=Wt({name:t});return{onHover:a(e=>{if(!e)return void l();const t={};for(const o of n){const n=e[o];void 0!==n&&(t[o]=[n])}Object.keys(t).length>0&&r(t)},[n,r,l,t]),predicate:o,isActive:i}}const It=r(!1);function Nt(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields}:null}function Bt(e,t,n){return t?o=>{var i;const r=Object.assign({},e(o));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(r,n.selectedStyle);else{const e=null!==(i=null==n?void 0:n.unselectedOpacity)&&void 0!==i?i:.2;r.opacity=e,r.fillOpacity=e,r.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(r,n.unselectedStyle)}return r}:e}const Tt="#007bff";function _t(e,t,n="category10"){const o=l(At);return i(()=>{if(t){if(0===e.length)return o&&Object.keys(o).length>0?e=>o[e]||"#999":void 0;if("function"==typeof t){const i=Array.from(new Set(e.map(e=>t(e)+"")));return o&&Object.keys(o).length>0?e=>o[e]||"#999":Ot(i.map(e=>({_cat:e})),"_cat",n)}if(o&&Object.keys(o).length>0){const i=Ot(e,t,n);return e=>o[e]||i(e)}return Ot(e,t,n)}},[e,t,n,o])}function Rt({selection:e,linkedHover:t,fallbackFields:n=[],unwrapData:o=!1,onObservation:i,chartType:r,chartId:l}){const s=Nt(t,n),c=Wt({name:(null==e?void 0:e.name)||"__unused__"}),u=Dt({name:(null==s?void 0:s.name)||"hover",fields:(null==s?void 0:s.fields)||n||[]}),d=$t(e=>e.pushObservation),h=e?{isActive:c.isActive,predicate:c.predicate}:null,f=a(e=>{var n,o;if(t)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]),u.onHover(t)}else u.onHover(null);if(i||d){const t={timestamp:Date.now(),chartType:r||"unknown",chartId:l};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const l=Object.assign(Object.assign({},t),{type:"hover",datum:r||{},x:null!==(n=e.x)&&void 0!==n?n:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(l),d&&d(l)}else{const e=Object.assign(Object.assign({},t),{type:"hover-end"});i&&i(e),d&&d(e)}}},[t,u,i,r,l,d]),p=a(e=>{var t,n;if(i||d){const o={timestamp:Date.now(),chartType:r||"unknown",chartId:l};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const l=Object.assign(Object.assign({},o),{type:"click",datum:r||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});i&&i(l),d&&d(l)}else{const e=Object.assign(Object.assign({},o),{type:"click-end"});i&&i(e),d&&d(e)}}},[i,d,r,l]);return{activeSelectionHook:h,customHoverBehavior:f,customClickBehavior:p}}function Ft({data:e,colorBy:t,colorScale:n,showLegend:o,legendPosition:r="right",userMargin:a,defaults:s={top:50,bottom:60,left:70,right:40}}){const c=l(It),u=void 0!==o?o:!c&&!!t,d=i(()=>{if(u&&t)return function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:i,strokeWidth:r}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==i&&(n.stroke=i),void 0!==r&&(n.strokeWidth=r),n},type:"fill",items:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t]))).map(i=>{const r=e.find("function"==typeof t?e=>t(e)===i:e=>e[t]===i),l=r?o(r,t,n):n?n(i):"#000000";return{label:i+"",color:l}}),label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:jt})},[u,t,e,n]),h=i(()=>{const e=Object.assign(Object.assign({},s),a);return d&&("right"===r&&110>e.right?e.right=110:"left"===r&&110>e.left?e.left=110:"top"===r&&50>e.top?e.top=50:"bottom"===r&&80>e.bottom&&(e.bottom=80)),e},[s,a,d,r]);return{legend:d,margin:h,legendPosition:r}}const Ht={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}}};function Gt(e,t,n){var o,i,r,l,a,s;const c=Ht[e||"primary"],u="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:c.width,height:null!==(i=t.height)&&void 0!==i?i:c.height,showAxes:c.showAxes,showGrid:null!==(r=t.showGrid)&&void 0!==r?r:c.showGrid,enableHover:null!==(l=t.enableHover)&&void 0!==l?l:!!t.linkedHover||c.enableHover,showLegend:null!==(a=t.showLegend)&&void 0!==a?a:c.showLegend,showLabels:null!==(s=t.showLabels)&&void 0!==s?s:c.showLabels,title:u?void 0:t.title,xLabel:u?void 0:t.xLabel,yLabel:u?void 0:t.yLabel,categoryLabel:u?void 0:t.categoryLabel,valueLabel:u?void 0:t.valueLabel,marginDefaults:c.marginDefaults}}function qt({componentName:t,message:n,width:o,height:i}){return e.createElement("div",{role:"alert",style:{width:o,height:Math.max(i,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"}},e.createElement("div",{style:{textAlign:"center",maxWidth:400}},e.createElement("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"}},t),e.createElement("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5}},n)))}class Zt extends e.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,e,t)}render(){if(this.state.error){const{fallback:t}=this.props,n=this.state.error;return"function"==typeof t?t(n):void 0!==t?t:e.createElement(qt,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}var Ut;const Yt="undefined"!=typeof process&&"production"!==(null===(Ut=process.env)||void 0===Ut?void 0:Ut.NODE_ENV);function Xt({componentName:t,width:n,height:o,children:i}){return e.createElement(Zt,{fallback:i=>e.createElement(qt,{componentName:t,message:i.message,width:n,height:o})},i)}const Vt={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #999)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Kt={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Jt(t,n,o,i){return!1===i||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?e.createElement("div",{style:Object.assign(Object.assign({},Vt),{width:n,height:o})},i||"No data available"):null}function Qt(t,n,o){if(!t)return null;const i=Math.min(5,Math.floor(o/40)),r=Math.max(8,Math.floor(o/(3*i))),l=Math.max(6,Math.floor(o/(2.5*i))),a=Math.floor((o-(i*(r+l)-l))/2);return e.createElement("div",{style:{width:n,height:o,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"}},Array.from({length:i},(t,o)=>e.createElement("div",{key:o,className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Kt),{position:"absolute",top:a+o*(r+l),left:Math.floor(.1*n),width:30+(37*o+13)%50+"%",height:r,opacity:.5+o%2*.2})})))}function en(e,t,n,o){if(!Yt)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const i=t[0];if(!i||"object"!=typeof i)return;if(o in i)return;const r=Object.keys(i).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${r}`)}function tn(e,t,n,o){return new(n||(n=Promise))(function(i,r){function l(e){try{s(o.next(e))}catch(e){r(e)}}function a(e){try{s(o.throw(e))}catch(e){r(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(l,a)}s((o=o.apply(e,t||[])).next())})}function nn(e){return e}function on(e,t){var n=t.id,o=t.bbox,i=null==t.properties?{}:t.properties,r=function(e,t){var n=function(e){if(null==e)return nn;var t,n,o=e.scale[0],i=e.scale[1],r=e.translate[0],l=e.translate[1];return function(e,a){a||(t=n=0);var s=2,c=e.length,u=Array(c);for(u[0]=(t+=e[0])*o+r,u[1]=(n+=e[1])*i+l;c>s;)u[s]=e[s],++s;return u}}(e.transform),o=e.arcs;function i(e,t){t.length&&t.pop();for(var i=o[0>e?~e:e],r=0,l=i.length;l>r;++r)t.push(n(i[r],r));0>e&&function(e,t){for(var n,o=e.length,i=o-t;i<--o;)n=e[i],e[i++]=e[o],e[o]=n}(t,l)}function r(e){return n(e)}function l(e){for(var t=[],n=0,o=e.length;o>n;++n)i(e[n],t);return 2>t.length&&t.push(t[0]),t}function a(e){for(var t=l(e);4>t.length;)t.push(t[0]);return t}function s(e){return e.map(a)}return function e(t){var n,o=t.type;switch(o){case"GeometryCollection":return{type:o,geometries:t.geometries.map(e)};case"Point":n=r(t.coordinates);break;case"MultiPoint":n=t.coordinates.map(r);break;case"LineString":n=l(t.arcs);break;case"MultiLineString":n=t.arcs.map(l);break;case"Polygon":n=s(t.arcs);break;case"MultiPolygon":n=t.arcs.map(s);break;default:return null}return{type:o,coordinates:n}}(t)}(e,t);return null==n&&null==o?{type:"Feature",properties:i,geometry:r}:null==o?{type:"Feature",id:n,properties:i,geometry:r}:{type:"Feature",id:n,bbox:o,properties:i,geometry:r}}"function"==typeof SuppressedError&&SuppressedError;const rn=new Map;function ln(e){var t;return null!==(t=e.default)&&void 0!==t?t:e}function an(e){return tn(this,void 0,void 0,function*(){const t=rn.get(e);if(t)return t;const{topology:n,objectName:o}=yield function(e){return tn(this,void 0,void 0,function*(){switch(e){case"world-110m":return{topology:ln(yield import("world-atlas/countries-110m.json")),objectName:"countries"};case"world-50m":return{topology:ln(yield import("world-atlas/countries-50m.json")),objectName:"countries"};case"land-110m":return{topology:ln(yield import("world-atlas/land-110m.json")),objectName:"land"};case"land-50m":return{topology:ln(yield import("world-atlas/land-50m.json")),objectName:"land"};default:throw Error(`Unknown reference geography: "${e}". Supported: "world-110m", "world-50m", "land-110m", "land-50m".`)}})}(e);if(!n||!n.objects)throw Error(`resolveReferenceGeography("${e}"): Failed to load topology. Got ${typeof n} with keys: ${n?Object.keys(n).join(", "):"none"}`);const i=function(e,t){return"string"==typeof t&&(t=e.objects[t]),"GeometryCollection"===t.type?{type:"FeatureCollection",features:t.geometries.map(function(t){return on(e,t)})}:on(e,t)}(n,n.objects[o]),r="features"in i?i.features:[i];return rn.set(e,r),r})}function sn(e){const t=i(()=>Array.isArray(e)?e:void 0,[e]),[r,l]=n(null);return o(()=>{if(e&&!Array.isArray(e)){if("string"==typeof(t=e)&&["world-110m","world-50m","land-110m","land-50m"].includes(t)){let t=!1;return l(null),an(e).then(e=>{t||l(e)}),()=>{t=!0}}var t;"production"!==process.env.NODE_ENV&&console.warn(`[semiotic] Unknown areas reference: "${e}". Supported: "world-110m", "world-50m", "land-110m", "land-50m".`),l(null)}else l(null)},[e]),void 0!==t?t:r}const cn={blues:K,reds:V,greens:X,viridis:Z};function un(t){const n=Gt(t.mode,{width:t.width,height:t.height,showLegend:t.showLegend,title:t.title}),{areas:o,valueAccessor:r,colorScheme:l="blues",projection:a="equalEarth",graticule:s,fitPadding:c,zoomable:u,zoomExtent:d,onZoom:h,dragRotate:f,tileURL:p,tileAttribution:g,tileCacheSize:m,tooltip:y,areaOpacity:v=1,annotations:b,margin:x,className:k,selection:w,linkedHover:E,onObservation:O,chartId:A,loading:S,emptyContent:C,frameProps:z={}}=t,L=null!=u?u:!!p,P=sn(o),$=i(()=>"function"==typeof r?r:e=>{var t,n;return null!==(n=null===(t=null==e?void 0:e.properties)||void 0===t?void 0:t[r])&&void 0!==n?n:null==e?void 0:e[r]},[r]),W=i(()=>{if(!P)return j(K).domain([0,1]);const e=P.map(e=>$(e)).filter(e=>null!=e&&isFinite(e)),[t,n]=M(e);return j(cn[l]||K).domain([null!=t?t:0,null!=n?n:1])},[P,$,l]),{activeSelectionHook:D,customHoverBehavior:I}=Rt({selection:w,linkedHover:E,onObservation:O,chartType:"ChoroplethMap",chartId:A}),N=i(()=>{const e=e=>{const t=$(e);return{fill:null!=t&&isFinite(t)?W(t):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:v}};return D?Bt(e,D,w):e},[$,W,D,w,v]),B=i(()=>t=>{var n,o;const i=(null===(n=null==t?void 0:t.properties)||void 0===n?void 0:n.name)||(null===(o=null==t?void 0:t.properties)||void 0===o?void 0:o.NAME)||(null==t?void 0:t.name)||(null==t?void 0:t.NAME)||"Feature",r=$(t);return e.createElement("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12}},e.createElement("div",{style:{fontWeight:600}},i),null!=r&&e.createElement("div",{style:{opacity:.7}},"number"==typeof(l=r)&&isFinite(l)?Number.isInteger(l)?l.toLocaleString():l.toLocaleString(void 0,{maximumFractionDigits:2}):(null!=l?l:"")+""));var l},[$]),T=i(()=>Object.assign({top:10,right:10,bottom:10,left:10},x),[x]),_=Qt(S,n.width,n.height);if(_)return _;if(!P)return Qt(!0,n.width,n.height)||null;const R=Jt(P,n.width,n.height,C);if(R)return R;if(Array.isArray(P)&&P.length>0){const t=P[0];if(!t||"object"!=typeof t||!t.geometry)return e.createElement(qt,{componentName:"ChoroplethMap",message:"ChoroplethMap: areas must be an array of GeoJSON Features with a geometry property.",width:n.width,height:n.height})}const F=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({projection:a,areas:P,areaStyle:N,size:[n.width,n.height],margin:T,enableHover:!0,tooltipContent:!1===y?()=>null:!0===y?B:xt(y)||B},null!=s&&{graticule:s}),null!=c&&{fitPadding:c}),L&&{zoomable:!0}),d&&{zoomExtent:d}),h&&{onZoom:h}),null!=f&&{dragRotate:f}),p&&{tileURL:p}),g&&{tileAttribution:g}),m&&{tileCacheSize:m}),(E||O)&&{customHoverBehavior:I}),b&&b.length>0&&{annotations:b}),n.title&&{title:n.title}),k&&{className:k}),z);return e.createElement(Xt,{componentName:"ChoroplethMap",width:n.width,height:n.height},e.createElement(gt,Object.assign({},F)))}un.displayName="ChoroplethMap";const dn=c(function(o,r){const l=t(null);u(r,()=>({push:e=>{var t;return null===(t=l.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=l.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=l.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=l.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const s=Gt(o.mode,{width:o.width,height:o.height,showLegend:o.showLegend,title:o.title}),{points:c,xAccessor:d="lon",yAccessor:h="lat",sizeBy:f,sizeRange:p=[3,30],colorBy:g,colorScheme:m="category10",projection:y="equalEarth",graticule:v,fitPadding:b,zoomable:x,zoomExtent:k,onZoom:w,dragRotate:E,tileURL:j,tileAttribution:O,tileCacheSize:M,areas:A,areaStyle:S={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5},tooltip:C,annotations:z,margin:L,className:P,selection:$,linkedHover:W,onObservation:D,chartId:I,loading:N,emptyContent:B,legendInteraction:T,legendPosition:_,frameProps:R={}}=o,F=null!=x?x:!!j,H=sn(A),G=c||[],{activeSelectionHook:q,customHoverBehavior:Z}=Rt({selection:$,linkedHover:W,fallbackFields:g?["string"==typeof g?g:""]:[],onObservation:D,chartType:"ProportionalSymbolMap",chartId:I}),U=_t(G,g,m),Y=i(()=>{if(!f)return;const e="function"==typeof f?f:e=>e[f],t=G.map(t=>e(t)).filter(e=>null!=e&&isFinite(e));return 0!==t.length?[Math.min(...t),Math.max(...t)]:void 0},[G,f]),X=i(()=>{const e=e=>({fill:g?jt(e,g,U):Tt,fillOpacity:.7,stroke:"#fff",strokeWidth:.5,r:f?Mt(e,f,p,Y):6});return q?Bt(e,q,$):e},[g,U,f,p,Y,q,$]),V=i(()=>{if(!g)return[];const e="function"==typeof g?g:e=>e[g],t=new Set;for(const n of G){const o=e(n);null!=o&&t.add(o+"")}return Array.from(t)},[G,g]),K=function(e,t,o){const[r,l]=n(null),[s,c]=n(new Set),u=a(t=>{"highlight"===e&&l(t?t.label:null)},[e]),d=a(t=>{"isolate"===e&&c(e=>{const n=new Set(e);return n.has(t.label)?n.delete(t.label):n.add(t.label),n.size===o.length?new Set:n})},[e,o.length]),h=i(()=>{if(!e||"none"===e||!t)return null;const n="string"==typeof t?t:null;return"highlight"===e&&null!=r?{isActive:!0,predicate:e=>(n?e[n]:"function"==typeof t?t(e):null)===r}:"isolate"===e&&s.size>0?{isActive:!0,predicate:e=>{const o=n?e[n]:"function"==typeof t?t(e):null;return s.has(o)}}:null},[e,t,r,s]);return{highlightedCategory:"highlight"===e?r:null,isolatedCategories:"isolate"===e?s:new Set,onLegendHover:u,onLegendClick:d,legendSelectionHook:h}}(T,g,V),{legend:J,margin:Q,legendPosition:ee}=Ft({data:G,colorBy:g,colorScale:U,showLegend:s.showLegend,legendPosition:_,userMargin:L,defaults:{top:10,bottom:10,left:10,right:10}}),te=i(()=>t=>{const n=(null==t?void 0:t.name)||(null==t?void 0:t.label)||(null==t?void 0:t.NAME)||(null==t?void 0:t.id),o="string"==typeof f?f:null,i=("function"==typeof f?f:e=>e[f])(t),r=e=>"number"==typeof e&&isFinite(e)?Number.isInteger(e)?e.toLocaleString():e.toLocaleString(void 0,{maximumFractionDigits:2}):(null!=e?e:"")+"",l="string"==typeof g?g:null,a=l?null==t?void 0:t[l]:null;return e.createElement("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12}},n&&e.createElement("div",{style:{fontWeight:600,marginBottom:2}},n),o&&null!=i&&e.createElement("div",null,e.createElement("span",{style:{opacity:.7}},o,": "),r(i)),l&&null!=a&&e.createElement("div",null,e.createElement("span",{style:{opacity:.7}},l,": "),a+""),!n&&!o&&Object.entries(t).filter(([e])=>"data"!==e&&"x"!==e&&"y"!==e&&"time"!==e).slice(0,4).map(([t,n])=>e.createElement("div",{key:t},e.createElement("span",{style:{opacity:.7}},t,": "),r(n))))},[f,g]),ne=Qt(N,s.width,s.height);if(ne)return ne;const oe=Jt(c,s.width,s.height,B);if(oe)return oe;en("ProportionalSymbolMap",G,"xAccessor",d),en("ProportionalSymbolMap",G,"yAccessor",h);const ie=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({projection:y},null!=c&&{points:G}),{xAccessor:d,yAccessor:h,pointStyle:X}),H&&{areas:H,areaStyle:S}),null!=v&&{graticule:v}),null!=b&&{fitPadding:b}),F&&{zoomable:!0}),k&&{zoomExtent:k}),w&&{onZoom:w}),null!=E&&{dragRotate:E}),j&&{tileURL:j}),O&&{tileAttribution:O}),M&&{tileCacheSize:M}),{size:[s.width,s.height],margin:Q,enableHover:!0,tooltipContent:!1===C?()=>null:xt(C)||te}),J&&{legend:J,legendPosition:ee}),T&&"none"!==T&&{legendHoverBehavior:K.onLegendHover,legendClickBehavior:K.onLegendClick,legendHighlightedCategory:K.highlightedCategory,legendIsolatedCategories:K.isolatedCategories}),(W||D)&&{customHoverBehavior:Z}),z&&z.length>0&&{annotations:z}),s.title&&{title:s.title}),P&&{className:P}),R);return e.createElement(Xt,{componentName:"ProportionalSymbolMap",width:s.width,height:s.height},e.createElement(gt,Object.assign({ref:l},ie)))});function hn(t){const n=Gt(t.mode,{width:t.width,height:t.height,showLegend:t.showLegend,title:t.title}),{flows:o,nodes:r,nodeIdAccessor:l="id",xAccessor:s="lon",yAccessor:c="lat",valueAccessor:u="value",projection:d="equalEarth",graticule:h,fitPadding:f,zoomable:p,zoomExtent:g,onZoom:m,dragRotate:y,tileURL:v,tileAttribution:b,tileCacheSize:x,lineType:k="geo",flowStyle:E="basic",areas:j,areaStyle:O={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5},edgeColorBy:M,edgeOpacity:A=.6,edgeWidthRange:S=[1,8],edgeLinecap:C="round",colorScheme:z="category10",showParticles:L,particleStyle:P,tooltip:$,annotations:W,margin:D,className:I,selection:N,linkedHover:B,onObservation:T,chartId:_,loading:R,emptyContent:F,frameProps:H={}}=t,G=null!=p?p:!!v,q=sn(j),Z=Nt(B),U=Wt({name:(null==N?void 0:N.name)||"__unused__"}),Y=Dt({name:(null==Z?void 0:Z.name)||"hover",fields:(null==Z?void 0:Z.fields)||[]}),X=$t(e=>e.pushObservation),V=N?{isActive:U.isActive,predicate:U.predicate}:null,K=o||[],J=r||[],Q=_t(K,M,z),ee=i(()=>{const e=new Map;for(const t of J)e.set(t[l]+"",t);return e},[J,l]),te=i(()=>{const e=new Map;for(const t of K)t&&"object"==typeof t&&(null==t.source||e.has(t.source)||e.set(t.source,t),null==t.target||e.has(t.target)||e.set(t.target,t));return e},[K]),ne=a(e=>{var t,n;if(B)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"point"===e.type){const e=te.get(t[l]+"");e&&Y.onHover(e)}else Y.onHover(t)}else Y.onHover(null);if(T||X){const o={timestamp:Date.now(),chartType:"FlowMap",chartId:_};if(e){let i=e.data||e.datum||e;Array.isArray(i)&&(i=i[0]);const r=Object.assign(Object.assign({},o),{type:"hover",datum:i||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});T&&T(r),X&&X(r)}else{const e=Object.assign(Object.assign({},o),{type:"hover-end"});T&&T(e),X&&X(e)}}},[B,Y,l,te,T,_,X]),oe=i(()=>{const e="function"==typeof s?s:e=>e[s],t="function"==typeof c?c:e=>e[c];return K.map(n=>{if(!n||"object"!=typeof n||null==n.source||null==n.target)return null;const o=ee.get(n.source+""),i=ee.get(n.target+"");return o&&i?Object.assign(Object.assign({},n),{coordinates:[{[s]:e(o),[c]:t(o)},{[s]:e(i),[c]:t(i)}]}):null}).filter(Boolean)},[K,ee,s,c]),ie=i(()=>{const e=K.filter(e=>e&&"object"==typeof e).map(e=>{var t;return null!==(t=e[u])&&void 0!==t?t:0}).filter(e=>isFinite(e));return 0===e.length?()=>S[0]:w().domain([Math.min(...e),Math.max(...e)]).range(S)},[K,u,S]),re=i(()=>e=>{var t;return{stroke:M?jt(e,M,Q):Tt,strokeWidth:ie(null!==(t=e[u])&&void 0!==t?t:0),strokeLinecap:C,opacity:A}},[M,Q,ie,u,A,C]),le=i(()=>V?Bt(re,V,Object.assign(Object.assign({},N||{}),{unselectedStyle:{opacity:.15,strokeOpacity:.15,fillOpacity:0}})):re,[re,V,N]),ae=i(()=>()=>({fill:"#333",r:5,fillOpacity:.8}),[]),se=i(()=>t=>{var n,o,i,r,a,s,c;if((null==t?void 0:t.geometry)||(null==t?void 0:t.properties)||(null===(n=null==t?void 0:t.data)||void 0===n?void 0:n.geometry)){const n=(null===(o=null==t?void 0:t.properties)||void 0===o?void 0:o.name)||(null===(i=null==t?void 0:t.properties)||void 0===i?void 0:i.NAME)||(null==t?void 0:t.name)||(null==t?void 0:t.NAME)||(null===(a=null===(r=null==t?void 0:t.data)||void 0===r?void 0:r.properties)||void 0===a?void 0:a.name)||(null===(c=null===(s=null==t?void 0:t.data)||void 0===s?void 0:s.properties)||void 0===c?void 0:c.NAME);if(n)return e.createElement("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12}},e.createElement("div",{style:{fontWeight:600}},n))}if(null!=(null==t?void 0:t.source)&&null!=(null==t?void 0:t.target)){const n=t[u];return e.createElement("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12}},e.createElement("div",{style:{fontWeight:600}},t.source," → ",t.target),null!=n&&e.createElement("div",{style:{opacity:.7}},"number"==typeof n?n.toLocaleString():n))}const d=(null==t?void 0:t.name)||(null==t?void 0:t.label)||(null==t?void 0:t[l]);return null!=d?e.createElement("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12}},e.createElement("div",{style:{fontWeight:600}},d)):null},[u,l]),ce=i(()=>Object.assign({top:10,right:10,bottom:10,left:10},D),[D]),ue=Qt(R,n.width,n.height);if(ue)return ue;const de=Jt(o,n.width,n.height,F);if(de)return de;const he=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({projection:d,lines:oe,points:J,xAccessor:s,yAccessor:c,lineDataAccessor:"coordinates",lineType:k,flowStyle:E,lineStyle:le,pointStyle:ae},q&&{areas:q,areaStyle:O}),null!=h&&{graticule:h}),null!=f&&{fitPadding:f}),G&&{zoomable:!0}),g&&{zoomExtent:g}),m&&{onZoom:m}),null!=y&&{dragRotate:y}),L&&{showParticles:L}),P&&{particleStyle:P}),v&&{tileURL:v}),b&&{tileAttribution:b}),x&&{tileCacheSize:x}),{size:[n.width,n.height],margin:ce,enableHover:!0,tooltipContent:!1===$?()=>null:xt($)||se}),(B||T)&&{customHoverBehavior:ne}),W&&W.length>0&&{annotations:W}),n.title&&{title:n.title}),I&&{className:I}),H);return e.createElement(Xt,{componentName:"FlowMap",width:n.width,height:n.height},e.createElement(gt,Object.assign({},he)))}dn.displayName="ProportionalSymbolMap",hn.displayName="FlowMap";const fn=c(function(r,l){const s=Gt(r.mode,{width:r.width,height:r.height,showLegend:r.showLegend,title:r.title}),{points:c,lines:d,xAccessor:h="lon",yAccessor:f="lat",nodeIdAccessor:p="id",center:g,costAccessor:m,strength:y=1,lineMode:v="straight",projection:b="mercator",graticule:x,fitPadding:k,zoomable:w,zoomExtent:E,onZoom:j,dragRotate:O,tileURL:M,tileAttribution:A,tileCacheSize:S,transition:C,colorBy:z,colorScheme:L="category10",pointRadius:P=5,tooltip:$,showRings:W=!0,ringStyle:D,showNorth:I=!0,costLabel:N,annotations:B,margin:T,className:_,selection:R,linkedHover:F,onObservation:H,chartId:G,loading:q,emptyContent:Z,legendPosition:U,frameProps:Y={}}=r,X=null!=w?w:!!M,V=c||[],{activeSelectionHook:K,customHoverBehavior:J}=Rt({selection:R,linkedHover:F,fallbackFields:z?["string"==typeof z?z:""]:[],onObservation:H,chartType:"DistanceCartogram",chartId:G}),Q=_t(V,z,L),ee=i(()=>{const e=e=>({fill:z?jt(e,z,Q):Tt,fillOpacity:.8,stroke:"#fff",strokeWidth:1,r:P});return K?Bt(e,K,R):e},[z,Q,P,K,R]),{legend:te,margin:ne,legendPosition:oe}=Ft({data:V,colorBy:z,colorScale:Q,showLegend:s.showLegend,legendPosition:U,userMargin:T,defaults:{top:10,bottom:10,left:10,right:10}}),ie=i(()=>({center:g,centerAccessor:p,costAccessor:m,strength:y,lineMode:v}),[g,p,m,y,v]),re=i(()=>{if(!d)return;const e="function"==typeof h?h:e=>e[h],t="function"==typeof f?f:e=>e[f],n=new Map;for(const e of V)n.set(e[p]+"",e);return d.map(o=>{if(o.coordinates)return o;const i=n.get(o.source+""),r=n.get(o.target+"");return i&&r?Object.assign(Object.assign({},o),{coordinates:[{[h]:e(i),[f]:t(i)},{[h]:e(r),[f]:t(r)}]}):null}).filter(Boolean)},[d,V,h,f,p]),le=i(()=>t=>{const n=("function"==typeof m?m:e=>e[m])(t);return e.createElement("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12}},e.createElement("div",{style:{fontWeight:600}},t[p]||t.name||t.id||"Point"),null!=n&&e.createElement("div",{style:{opacity:.7}},"Cost: ","number"==typeof n?n.toFixed(1):n))},[m,p]),ae=t(null);u(l,()=>({push:e=>{var t;return null===(t=ae.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=ae.current)||void 0===t?void 0:t.pushMany(e)},clear:()=>{var e;return null===(e=ae.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=ae.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const[se,ce]=n(null),ue=a(()=>{var e,t;const n=null===(t=null===(e=ae.current)||void 0===e?void 0:e.getCartogramLayout)||void 0===t?void 0:t.call(e);n&&ce(e=>e&&e.cx===n.cx&&e.cy===n.cy&&e.maxCost===n.maxCost&&e.availableRadius===n.availableRadius?e:n)},[]);o(()=>{const e=requestAnimationFrame(ue);return()=>cancelAnimationFrame(e)},[ue,y,g,s.width,s.height,V]);const de=i(()=>{if(!W||!se)return[];const{maxCost:e}=se;if(0>=e)return[];if(Array.isArray(W))return W.filter(t=>t>0&&e>=t);const t="number"==typeof W?W:Math.min(5,Math.max(2,Math.ceil(e/5))),n=e/t,o=[];for(let e=1;t>=e;e++)o.push(Math.round(n*e*10)/10);return o},[W,se]),he=i(()=>{var t,n;if(!se)return Y.foregroundGraphics||null;const{cx:o,cy:i,maxCost:r,availableRadius:l}=se,a=Object.assign({stroke:"#999",strokeWidth:.8,strokeDasharray:"4,3",labelColor:"#777",labelSize:10},D),s=null!==(t=ne.left)&&void 0!==t?t:10,c=null!==(n=ne.top)&&void 0!==n?n:10;return e.createElement("g",null,de.map(t=>{const n=t/r*l;return e.createElement("g",{key:t},e.createElement("circle",{cx:o+s,cy:i+c,r:n,fill:"none",stroke:a.stroke,strokeWidth:a.strokeWidth,strokeDasharray:a.strokeDasharray,opacity:.5}),e.createElement("text",{x:o+s+n+3,y:i+c-2,fontSize:a.labelSize,fill:a.labelColor,fontFamily:"system-ui, sans-serif"},t,N?" "+N:""))}),I&&e.createElement("g",{transform:`translate(${s+24}, ${c+24})`},e.createElement("circle",{r:16,fill:"white",fillOpacity:.85,stroke:"#bbb",strokeWidth:.8}),e.createElement("path",{d:"M0,-11 L3,-3 L1,-4 L1,7 L-1,7 L-1,-4 L-3,-3 Z",fill:"#555",stroke:"none"}),e.createElement("text",{y:-12,textAnchor:"middle",fontSize:7,fontWeight:700,fill:"#555",fontFamily:"system-ui, sans-serif"},"N"),e.createElement("line",{x1:11,y1:0,x2:13,y2:0,stroke:"#bbb",strokeWidth:.8}),e.createElement("line",{x1:-11,y1:0,x2:-13,y2:0,stroke:"#bbb",strokeWidth:.8}),e.createElement("line",{x1:0,y1:11,x2:0,y2:13,stroke:"#bbb",strokeWidth:.8})),Y.foregroundGraphics)},[se,de,I,N,D,ne,Y.foregroundGraphics]),fe=Qt(q,s.width,s.height);if(fe)return fe;const pe=Jt(c,s.width,s.height,Z);if(pe)return pe;en("DistanceCartogram",V,"xAccessor",h),en("DistanceCartogram",V,"yAccessor",f);const ge=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({projection:b},null!=c&&{points:V}),re&&{lines:re,lineDataAccessor:"coordinates"}),{xAccessor:h,yAccessor:f,pointIdAccessor:p,pointStyle:ee,projectionTransform:ie}),C&&{transition:{duration:C}}),null!=x&&{graticule:x}),null!=k&&{fitPadding:k}),X&&{zoomable:!0}),E&&{zoomExtent:E}),j&&{onZoom:j}),null!=O&&{dragRotate:O}),M&&{tileURL:M}),A&&{tileAttribution:A}),S&&{tileCacheSize:S}),{size:[s.width,s.height],margin:ne,enableHover:!0,tooltipContent:!1===$?()=>null:xt($)||le}),te&&{legend:te,legendPosition:oe}),(F||H)&&{customHoverBehavior:J}),B&&B.length>0&&{annotations:B}),s.title&&{title:s.title}),_&&{className:_}),Y),he&&{foregroundGraphics:he});return e.createElement(Xt,{componentName:"DistanceCartogram",width:s.width,height:s.height},e.createElement(gt,Object.assign({ref:ae},ge)))});function pn(e,t,n){const{featureKey:o,dataKey:i}=n,r=new Map;for(const e of t)r.set(e[i]+"",e);return e.map(e=>{const t=(e=>{const t=o.split(".");let n=e;for(const e of t)n=null==n?void 0:n[e];return(null!=n?n:"")+""})(e),n=r.get(t);return n?Object.assign(Object.assign({},e),{properties:Object.assign(Object.assign({},e.properties),n)}):e})}fn.displayName="DistanceCartogram";export{un as ChoroplethMap,fn as DistanceCartogram,hn as FlowMap,dn as ProportionalSymbolMap,gt as StreamGeoFrame,pn as mergeData,an as resolveReferenceGeography};