semiotic 3.4.1 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/CLAUDE.md +114 -9
  2. package/README.md +45 -4
  3. package/ai/behaviorContracts.cjs +311 -0
  4. package/ai/chartSuggestions.cjs +291 -0
  5. package/ai/cli.js +255 -30
  6. package/ai/componentMetadata.cjs +107 -0
  7. package/ai/dist/mcp-server.js +907 -227
  8. package/ai/schema.json +3954 -2537
  9. package/ai/system-prompt.md +23 -4
  10. package/dist/components/LinkedCharts.d.ts +5 -1
  11. package/dist/components/Tooltip/Tooltip.d.ts +1 -1
  12. package/dist/components/charts/custom/NetworkCustomChart.d.ts +64 -0
  13. package/dist/components/charts/custom/OrdinalCustomChart.d.ts +71 -0
  14. package/dist/components/charts/custom/XYCustomChart.d.ts +59 -0
  15. package/dist/components/charts/geo/ChoroplethMap.d.ts +93 -2
  16. package/dist/components/charts/geo/DistanceCartogram.d.ts +51 -4
  17. package/dist/components/charts/geo/FlowMap.d.ts +55 -0
  18. package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +53 -0
  19. package/dist/components/charts/index.d.ts +6 -0
  20. package/dist/components/charts/network/ChordDiagram.d.ts +34 -2
  21. package/dist/components/charts/network/CirclePack.d.ts +36 -1
  22. package/dist/components/charts/network/ForceDirectedGraph.d.ts +130 -2
  23. package/dist/components/charts/network/OrbitDiagram.d.ts +37 -0
  24. package/dist/components/charts/network/SankeyDiagram.d.ts +51 -2
  25. package/dist/components/charts/network/TreeDiagram.d.ts +37 -2
  26. package/dist/components/charts/network/Treemap.d.ts +36 -2
  27. package/dist/components/charts/ordinal/BarChart.d.ts +111 -1
  28. package/dist/components/charts/ordinal/BoxPlot.d.ts +31 -0
  29. package/dist/components/charts/ordinal/DonutChart.d.ts +36 -0
  30. package/dist/components/charts/ordinal/DotPlot.d.ts +31 -0
  31. package/dist/components/charts/ordinal/FunnelChart.d.ts +40 -0
  32. package/dist/components/charts/ordinal/GaugeChart.d.ts +45 -0
  33. package/dist/components/charts/ordinal/GroupedBarChart.d.ts +38 -0
  34. package/dist/components/charts/ordinal/Histogram.d.ts +95 -0
  35. package/dist/components/charts/ordinal/LikertChart.d.ts +42 -0
  36. package/dist/components/charts/ordinal/PieChart.d.ts +90 -1
  37. package/dist/components/charts/ordinal/RidgelinePlot.d.ts +27 -0
  38. package/dist/components/charts/ordinal/StackedBarChart.d.ts +38 -0
  39. package/dist/components/charts/ordinal/SwarmPlot.d.ts +36 -0
  40. package/dist/components/charts/ordinal/SwimlaneChart.d.ts +60 -0
  41. package/dist/components/charts/ordinal/ViolinPlot.d.ts +32 -0
  42. package/dist/components/charts/realtime/RealtimeHeatmap.d.ts +22 -4
  43. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +5 -2
  44. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +24 -3
  45. package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +12 -0
  46. package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +14 -0
  47. package/dist/components/charts/realtime/defaultRealtimeTooltip.d.ts +43 -0
  48. package/dist/components/charts/realtime/resolveWindowSize.d.ts +26 -0
  49. package/dist/components/charts/shared/chartSpecs.d.ts +91 -0
  50. package/dist/components/charts/shared/colorPalettes.d.ts +62 -0
  51. package/dist/components/charts/shared/colorUtils.d.ts +9 -10
  52. package/dist/components/charts/shared/numberFormat.d.ts +58 -0
  53. package/dist/components/charts/shared/sparseArray.d.ts +27 -0
  54. package/dist/components/charts/shared/streamPropsHelpers.d.ts +113 -0
  55. package/dist/components/charts/shared/timeFormat.d.ts +60 -0
  56. package/dist/components/charts/shared/useChartSetup.d.ts +8 -0
  57. package/dist/components/charts/shared/useCustomChartSetup.d.ts +84 -0
  58. package/dist/components/charts/shared/useFrameImperativeHandle.d.ts +28 -0
  59. package/dist/components/charts/shared/useOrdinalStreaming.d.ts +6 -19
  60. package/dist/components/charts/shared/useStreamingLegend.d.ts +27 -11
  61. package/dist/components/charts/shared/validateProps.d.ts +2 -2
  62. package/dist/components/charts/shared/validationMap.d.ts +2 -1
  63. package/dist/components/charts/shared/withChartWrapper.d.ts +13 -4
  64. package/dist/components/charts/xy/AreaChart.d.ts +30 -1
  65. package/dist/components/charts/xy/CandlestickChart.d.ts +33 -6
  66. package/dist/components/charts/xy/ConnectedScatterplot.d.ts +24 -0
  67. package/dist/components/charts/xy/MinimapChart.d.ts +51 -0
  68. package/dist/components/charts/xy/MultiAxisLineChart.d.ts +27 -0
  69. package/dist/components/charts/xy/QuadrantChart.d.ts +21 -0
  70. package/dist/components/charts/xy/Scatterplot.d.ts +34 -2
  71. package/dist/components/charts/xy/ScatterplotMatrix.d.ts +16 -0
  72. package/dist/components/charts/xy/StackedAreaChart.d.ts +49 -1
  73. package/dist/components/export/selectionSerializer.d.ts +1 -1
  74. package/dist/components/realtime/types.d.ts +7 -9
  75. package/dist/components/recipes/bullet.d.ts +86 -0
  76. package/dist/components/recipes/calendar.d.ts +43 -0
  77. package/dist/components/recipes/dagre.d.ts +56 -0
  78. package/dist/components/recipes/flextree.d.ts +55 -0
  79. package/dist/components/recipes/marimekko.d.ts +55 -0
  80. package/dist/components/recipes/parallelCoordinates.d.ts +97 -0
  81. package/dist/components/recipes/recipeUtils.d.ts +27 -0
  82. package/dist/components/recipes/waffle.d.ts +46 -0
  83. package/dist/components/semiotic-ai.d.ts +4 -0
  84. package/dist/components/semiotic-network.d.ts +3 -0
  85. package/dist/components/semiotic-ordinal.d.ts +3 -0
  86. package/dist/components/semiotic-recipes.d.ts +24 -0
  87. package/dist/components/semiotic-xy.d.ts +3 -0
  88. package/dist/components/semiotic.d.ts +2 -2
  89. package/dist/components/server/renderToStaticSVG.d.ts +8 -2
  90. package/dist/components/server/serverChartConfigs.d.ts +47 -1
  91. package/dist/components/server/staticAnnotations.d.ts +6 -0
  92. package/dist/components/store/ObservationStore.d.ts +1 -3
  93. package/dist/components/store/SelectionStore.d.ts +2 -4
  94. package/dist/components/store/ThemeStore.d.ts +4 -4
  95. package/dist/components/store/TooltipStore.d.ts +5 -3
  96. package/dist/components/store/createStore.d.ts +4 -2
  97. package/dist/components/store/useSelection.d.ts +7 -4
  98. package/dist/components/stream/CanvasHitTester.d.ts +10 -8
  99. package/dist/components/stream/DataSourceAdapter.d.ts +9 -0
  100. package/dist/components/stream/GeoPipelineStore.d.ts +9 -0
  101. package/dist/components/stream/GeoTileRenderer.d.ts +14 -0
  102. package/dist/components/stream/NetworkPipelineStore.d.ts +25 -0
  103. package/dist/components/stream/NetworkSVGOverlay.d.ts +18 -12
  104. package/dist/components/stream/OrdinalPipelineStore.d.ts +12 -0
  105. package/dist/components/stream/PipelineStore.d.ts +51 -0
  106. package/dist/components/stream/SVGOverlay.d.ts +12 -0
  107. package/dist/components/stream/SceneGraph.d.ts +15 -1
  108. package/dist/components/stream/SceneToSVG.d.ts +1 -1
  109. package/dist/components/stream/categoryDomain.d.ts +4 -0
  110. package/dist/components/stream/composeOverlays.d.ts +15 -0
  111. package/dist/components/stream/customLayout.d.ts +76 -0
  112. package/dist/components/stream/customLayoutPalette.d.ts +29 -0
  113. package/dist/components/stream/geoTypes.d.ts +33 -8
  114. package/dist/components/stream/hoverUtils.d.ts +4 -10
  115. package/dist/components/stream/keyboardNav.d.ts +18 -6
  116. package/dist/components/stream/networkCustomLayout.d.ts +67 -0
  117. package/dist/components/stream/networkTypes.d.ts +87 -21
  118. package/dist/components/stream/ordinalCustomLayout.d.ts +84 -0
  119. package/dist/components/stream/ordinalTypes.d.ts +47 -13
  120. package/dist/components/stream/renderers/barFunnelCanvasRenderer.d.ts +9 -1
  121. package/dist/components/stream/renderers/canvasRenderHelpers.d.ts +92 -0
  122. package/dist/components/stream/sampleCurvePath.d.ts +9 -0
  123. package/dist/components/stream/types.d.ts +57 -10
  124. package/dist/components/stream/useHydration.d.ts +89 -0
  125. package/dist/components/stream/useStableShallow.d.ts +1 -0
  126. package/dist/components/stream/xySceneBuilders/types.d.ts +4 -0
  127. package/dist/geo.min.js +2 -1
  128. package/dist/geo.module.min.js +2 -1
  129. package/dist/network.min.js +2 -1
  130. package/dist/network.module.min.js +2 -1
  131. package/dist/ordinal.min.js +2 -1
  132. package/dist/ordinal.module.min.js +2 -1
  133. package/dist/realtime.min.js +2 -1
  134. package/dist/realtime.module.min.js +2 -1
  135. package/dist/semiotic-ai.d.ts +69 -65
  136. package/dist/semiotic-ai.min.js +2 -1
  137. package/dist/semiotic-ai.module.min.js +2 -1
  138. package/dist/semiotic-data.d.ts +4 -4
  139. package/dist/semiotic-geo.d.ts +15 -15
  140. package/dist/semiotic-network.d.ts +19 -16
  141. package/dist/semiotic-ordinal.d.ts +31 -28
  142. package/dist/semiotic-realtime.d.ts +17 -17
  143. package/dist/semiotic-recipes.d.ts +24 -0
  144. package/dist/semiotic-recipes.min.js +1 -0
  145. package/dist/semiotic-recipes.module.min.js +1 -0
  146. package/dist/semiotic-server.d.ts +6 -6
  147. package/dist/semiotic-statisticalOverlays-C3DsOgr_.js +1 -0
  148. package/dist/semiotic-themes.d.ts +3 -3
  149. package/dist/semiotic-themes.min.js +2 -1
  150. package/dist/semiotic-themes.module.min.js +2 -1
  151. package/dist/semiotic-utils.d.ts +23 -23
  152. package/dist/semiotic-utils.min.js +2 -1
  153. package/dist/semiotic-utils.module.min.js +2 -1
  154. package/dist/semiotic-xy.d.ts +27 -24
  155. package/dist/semiotic.d.ts +63 -63
  156. package/dist/semiotic.min.js +2 -1
  157. package/dist/semiotic.module.min.js +2 -1
  158. package/dist/server.min.js +1 -1
  159. package/dist/server.module.min.js +1 -1
  160. package/dist/test-utils/canvasMock.d.ts +34 -5
  161. package/dist/xy.min.js +2 -1
  162. package/dist/xy.module.min.js +2 -1
  163. package/package.json +40 -20
  164. package/dist/semiotic-statisticalOverlays-Ckd_jM8z.js +0 -1
package/dist/geo.min.js CHANGED
@@ -1 +1,2 @@
1
- "use strict";const e=require("react/jsx-runtime"),t=require("react"),n=require("d3-geo"),o=require("d3-scale"),r=require("d3-quadtree"),i=require("d3-array"),s=require("d3-hierarchy"),a=require("d3-shape"),l=require("regression"),c=require("d3-zoom"),u=require("d3-selection"),d=require("d3-scale-chromatic");function h(e){return e&&e.__esModule?e:{default:e}}function p(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const f=p(t),g=h(l);class y{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;return{next:()=>this._size>e?{done:!1,value:this.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}update(e,t){const n=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++){const i=(o+r)%this._capacity,s=this.buffer[i];if(e(s)){let e;e="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:Object.assign({},s),n.push(e),this.buffer[i]=t(s)}}return n}remove(e){const t=[],n=[];if(this.forEach(o=>{e(o)?n.push(o):t.push(o)}),0===n.length)return n;this.buffer=Array(this._capacity),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 m(e,t,n){return e+(t-e)*n}function b(e,t,n){var o,r,i;if(1>=n)return 1;const s=null!==(o=e.minOpacity)&&void 0!==o?o:.1,a=n-1-t;switch(e.type){case"linear":return s+(1-a/(n-1))*(1-s);case"exponential":{const t=null!==(r=e.halfLife)&&void 0!==r?r:n/2;return s+Math.pow(.5,a/t)*(1-s)}case"step":return(null!==(i=e.stepThreshold)&&void 0!==i?i:.5*n)>a?1:s;default:return 1}}const v={mercator:n.geoMercator,equalEarth:n.geoEqualEarth,albersUsa:n.geoAlbersUsa,orthographic:n.geoOrthographic,naturalEarth:n.geoNaturalEarth1,equirectangular:n.geoEquirectangular};function x(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function j(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function k(e,t,n){return e?Object.assign(Object.assign({},n),"function"==typeof e?e(t):e):Object.assign({},n)}function w(e,t){if(2>e.length)return[e];const n=.4*t,o=[];let r=[e[0]];for(let t=1;e.length>t;t++){const i=e[t];Math.abs(i[0]-e[t-1][0])>n?(2>r.length||o.push(r),r=[i]):r.push(i)}return 2>r.length||o.push(r),o}function A(e,t,n=24){const o=t[0]-e[0],r=t[1]-e[1],i=Math.sqrt(o*o+r*r);if(0===i)return[e,t];const s=-r/i,a=o/i,l=Math.min(.3*i,80),c=(e[0]+t[0])/2+s*l,u=(e[1]+t[1])/2+a*l,d=[];for(let o=0;n>=o;o++){const r=o/n,i=1-r;d.push([i*i*e[0]+2*i*r*c+r*r*t[0],i*i*e[1]+2*i*r*u+r*r*t[1]])}return d}function O(e,t){if(2>e.length)return e;const n=t/2+1,o=[];for(let t=0;e.length>t;t++){const r=e[t];let i,s;0===t?(i=e[1][0]-r[0],s=e[1][1]-r[1]):t===e.length-1?(i=r[0]-e[t-1][0],s=r[1]-e[t-1][1]):(i=e[t+1][0]-e[t-1][0],s=e[t+1][1]-e[t-1][1]);const a=Math.sqrt(i*i+s*s)||1;o.push([r[0]+s/a*n,r[1]+-i/a*n])}return o}function S(e,t,n,o,r){const i=t[0]-e[0],s=t[1]-e[1],a=Math.sqrt(i*i+s*s);if(0===a)return[e,t];const l=s/a,c=-i/a,u=r/2+1;return[[e[0]+l*u,e[1]+c*u],[t[0]+l*u,t[1]+c*u]]}class M{constructor(e){this.scene=[],this.scales=null,this.version=0,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this.config=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 y(e),this.timestampBuffer=new y(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}removePoint(e){const{pointIdAccessor:t}=this.config;if(!t)throw Error("removePoint() requires pointIdAccessor to be configured");const n="function"==typeof t?t:e=>e[t],o=new Set(Array.isArray(e)?e:[e]);if(this.streaming&&this.pointBuffer){const e=e=>o.has(n(e)+"");if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),n=new Set;this.pointBuffer.forEach((t,o)=>{e(t)&&n.add(o)}),this.timestampBuffer.clear();for(let e=0;t.length>e;e++)n.has(e)||this.timestampBuffer.push(t[e])}const t=this.pointBuffer.remove(e);return t.length>0&&this.version++,t}{const e=[];return this.pointData=this.pointData.filter(t=>!o.has(n(t)+"")||(e.push(t),!1)),e.length>0&&this.version++,e}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.version++}computeScene(e){const{config:t}=this;this.projection=function(e){if(!e)return n.geoEqualEarth();if("string"==typeof e){const t=v[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),n.geoEqualEarth())}if("object"==typeof e&&"type"in e){const t=v[e.type],o=t?t():n.geoEqualEarth();return e.rotate&&"rotate"in o&&o.rotate(e.rotate),e.center&&"center"in o&&o.center(e.center),o}return e}(t.projection),this.geoPath=n.geoPath(this.projection),this.fitProjection(e),this.geoPath=n.geoPath(this.projection);const o=this.projection;this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(e,t)=>o([e,t]),invertedPoint:(e,t)=>o.invert?o.invert([e,t]):null};const r=this.scene;if(this.scene=this.buildSceneNodes(e),this.rebuildQuadtree(),t.projectionTransform&&this.applyCartogramTransform(t.projectionTransform,e),t.decay&&this.streaming&&this.applyDecay(),t.pulse&&this.streaming&&this.applyPulse(),t.transition&&!this._hasRenderedOnce&&this.scene.length>0&&t.introAnimation){const t=e.width/2,n=e.height/2,o=this.scene.filter(e=>"point"===e.type).map(e=>Object.assign(Object.assign({},e),{x:t,y:n}));o.length>0&&this.startTransition(o)}this._hasRenderedOnce=!0,t.transition&&r.length>0&&this.startTransition(r),this.version++}fitProjection(e){var t,n,o,r,i;const s=this.projection,a=this.config,l=[...this.areas],c=x(a.xAccessor,"lon"),u=x(a.yAccessor,"lat"),d=this.getPoints();if(d.length>0){const e=d.map(e=>[c(e),u(e)]);l.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}const h=j(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)]);l.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==l.length){if(a.projectionExtent){const[[t,n],[o,r]]=a.projectionExtent;s.fitExtent([[0,0],[e.width,e.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[t,n],[o,n],[o,r],[t,r],[t,n]]]}})}else if(s.clipAngle&&(null!==(t=s.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);s.scale(o/2-o*t),s.translate([e.width/2,e.height/2])}else{const t=null!==(o=a.fitPadding)&&void 0!==o?o:0,n=e.width*t,r=e.height*t;s.fitExtent([[n,r],[e.width-n,e.height-r]],{type:"FeatureCollection",features:l})}this.baseScale=s.scale(),this.baseTranslate=s.translate(),this.baseRotation=null!==(i=null===(r=s.rotate)||void 0===r?void 0:r.call(s))&&void 0!==i?i:[0,0,0]}}applyZoomTransform(e,t){const o=this.projection;o&&(o.scale(this.baseScale*e.k),o.translate([this.baseTranslate[0]*e.k+e.x,this.baseTranslate[1]*e.k+e.y]),this.currentZoom=e.k,this.geoPath=n.geoPath(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(e,t)=>o([e,t]),invertedPoint:(e,t)=>o.invert?o.invert([e,t]):null},this.scene=this.buildSceneNodes(t),this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyZoomScale(e,t){const o=this.projection;o&&(o.scale(this.baseScale*e),o.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=n.geoPath(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(e,t)=>o([e,t]),invertedPoint:(e,t)=>o.invert?o.invert([e,t]):null},this.scene=this.buildSceneNodes(t),this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyRotation(e,t){const o=this.projection;o&&o.rotate&&(o.rotate(e),this.geoPath=n.geoPath(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(e,t)=>o([e,t]),invertedPoint:(e,t)=>o.invert?o.invert([e,t]):null},this.scene=this.buildSceneNodes(t),this.rebuildQuadtree(),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}rebuildQuadtree(){let e=0,t=0;for(const n of this.scene)"point"===n.type&&(t++,n.r>e&&(e=n.r));if(this._maxPointRadius=e,M.QUADTREE_THRESHOLD>=t)return void(this._quadtree=null);const n=Array(t);let o=0;for(const e of this.scene)"point"===e.type&&(n[o++]=e);this._quadtree=r.quadtree().x(e=>e.x).y(e=>e.y).addAll(n)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(e){var t,o,r;const i=[],{config:s}=this,a=this.projection,l=this.geoPath,c=x(s.xAccessor,"lon"),u=x(s.yAccessor,"lat"),d=function(e){var t,n;return{fill:(null===(t=e.themeSemantic)||void 0===t?void 0:t.surface)||"#e0e0e0",stroke:(null===(n=e.themeSemantic)||void 0===n?void 0:n.border)||"#999",strokeWidth:.5,fillOpacity:1}}(s),h=function(e){var t;return{stroke:(null===(t=e.themeSemantic)||void 0===t?void 0:t.primary)||"#4e79a7",strokeWidth:1.5,fill:"none"}}(s),p=function(e){var t;return{fill:(null===(t=e.themeSemantic)||void 0===t?void 0:t.primary)||"#4e79a7",r:4,fillOpacity:.8}}(s);if(s.graticule){const t=!0===s.graticule?{}:s.graticule,o=n.geoGraticule();t.step&&o.step(t.step);const r=l(o())||"";r&&i.push({type:"geoarea",pathData:r,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=l(e);if(!t)continue;const n=l.centroid(e),o=l.bounds(e),r=l.area(e),a=k(s.areaStyle,e,d);i.push({type:"geoarea",pathData:t,centroid:n,bounds:o,screenArea:r,style:a,datum:e,interactive:!0})}const f=j(s.lineDataAccessor);for(const t of this.lineData){const o=f(t);if(!o||2>o.length)continue;let r=[];if("geo"===s.lineType){const e=Array(o.length);for(let t=0;o.length>t;t++)e[t]=[c(o[t]),u(o[t])];for(let t=0;e.length-1>t;t++){const o=e[t],i=e[t+1],s=n.geoDistance(o,i)||0,l=Math.max(2,Math.ceil(s/(Math.PI/180))),c=n.geoInterpolate(o,i);for(let e=0;l>=e;e++){if(t>0&&0===e)continue;const n=a(c(e/l));null!=n&&r.push(n)}}}else for(let e=0;o.length>e;e++){const t=o[e],n=a([c(t),u(t)]);null!=n&&r.push(n)}if(2>r.length)continue;const l=k(s.lineStyle,t,h),d="number"==typeof l.strokeWidth?l.strokeWidth:1;2!==o.length||2>r.length||"arc"!==s.flowStyle?2!==o.length||2>r.length||"offset"!==s.flowStyle||(r="geo"===s.lineType?O(r,d):S(r[0],r[r.length-1],0,0,d)):r=A(r[0],r[r.length-1]);const p=w(r,e.width);if(p.length>1)for(const e of p){if(2>e.length)continue;const n={type:"line",path:e,style:Object.assign(Object.assign({},l),{_edgeFade:!0}),datum:t};i.push(n)}else i.push({type:"line",path:2>r.length&&p[0]||r,style:l,datum:t})}const g=this.getPoints(),y=s.pointIdAccessor?"function"==typeof s.pointIdAccessor?s.pointIdAccessor:e=>e[s.pointIdAccessor]:null,m=a.clipAngle&&null!==(t=a.clipAngle())&&void 0!==t?t:0,b=m>0?m*Math.PI/180:null,v=a.rotate?a.rotate():[0,0,0],M="function"==typeof a.center?a.center():[0,0],C=[(null!==(o=M[0])&&void 0!==o?o:0)-v[0],(null!==(r=M[1])&&void 0!==r?r:0)-v[1]];for(let e=0;g.length>e;e++){const t=g[e],o=c(t),r=u(t);if(null!=b&&n.geoDistance([o,r],C)>b)continue;const l=a([o,r]);if(!l)continue;const d=s.pointStyle?s.pointStyle(t):Object.assign({},p),h={type:"point",x:l[0],y:l[1],r:d.r||4,style:d,datum:t,pointId:y?y(t)+"":void 0};i.push(h)}return i}applyCartogramTransform(e,t){var n,r,i;const s=this.scene.filter(e=>"point"===e.type);if(2>s.length)return;const a=null!==(n=e.strength)&&void 0!==n?n:1;if(0===a)return;const l=e.centerAccessor?"function"==typeof e.centerAccessor?e.centerAccessor:t=>t[e.centerAccessor]:e=>e.id,c="function"==typeof e.costAccessor?e.costAccessor:t=>t[e.costAccessor],u=s.find(t=>l(t.datum)+""==e.center+"");if(!u)return void("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${e.center}" not found in point data`));const d=u.x,h=u.y,p=s.map(e=>c(e.datum)).filter(e=>isFinite(e)&&e>=0),f=Math.max(...p,1),g=Math.min(t.width,t.height)/2,y=o.scaleLinear().domain([0,f]).range([0,g]);this.cartogramLayout={cx:d,cy:h,maxCost:f,availableRadius:g},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 s){if(e===u)continue;const t=Math.atan2(e.y-h,e.x-d),n=Math.sqrt(Math.pow(e.x-d,2)+Math.pow(e.y-h,2)),o=c(e.datum),r=n+((isFinite(o)?y(o):n)-n)*a;e.x=d+Math.cos(t)*r,e.y=h+Math.sin(t)*r}const m=t.width/2,b=t.height/2,v=m-u.x,x=b-u.y;if(Math.abs(v)>.5||Math.abs(x)>.5)for(const e of s)e.x+=v,e.y+=x;this.cartogramLayout={cx:m,cy:b,maxCost:f,availableRadius:g};const j=this.scene.filter(e=>"line"===e.type);if(j.length>0&&"fractional"!==e.lineMode){const e=new Map;for(const t of s)t.pointId&&e.set(t.pointId,[t.x,t.y]);for(const t of j){const n=null===(r=t.datum)||void 0===r?void 0:r.source,o=null===(i=t.datum)||void 0===i?void 0:i.target;if(n&&o){const r=e.get(n+""),i=e.get(o+"");r&&i&&(t.path=[r,i])}}}}applyDecay(){const e=this.config.decay;if(!e||!this.pointBuffer)return;const t=this.pointBuffer.size;if(0===t)return;const n=this.scene.filter(e=>"point"===e.type);for(let o=0;n.length>o;o++){const r=b(e,o,t);n[o]._decayOpacity=r,n[o].style=Object.assign(Object.assign({},n[o].style),{opacity:r})}}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,r=performance.now(),i=this.scene.filter(e=>"point"===e.type),s=this.timestampBuffer.toArray();for(let e=0;i.length>e&&s.length>e;e++){const a=r-s[e];o>a&&(i[e]._pulseIntensity=1-a/o,i[e]._pulseColor=n.color||"rgba(255,255,255,0.6)",i[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 r=new Map;for(const t of e)"point"===t.type&&t.pointId&&r.set(t.pointId,[t.x,t.y]);const i=this.scene.filter(e=>"point"===e.type);let s=!1;for(const e of i)if(e.pointId){const t=r.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)&&(s=!0))}s&&(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=m(e.x,e._targetX,n),e.y=m(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 C(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}function R(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function P(e,t){const n=R(e);if(!n)return!1;const o=R(t);return!o||n.getFullYear()!==o.getFullYear()||n.getMonth()!==o.getMonth()}function z(e,t,n,o,r,i,s=0){if(i){const e=function(e,t,n,o,r){const i=Math.max(o,r+5,12),s=t-i,a=t+i,l=n-i,c=n+i;let u=null,d=1/0;return e.visit((e,r,i,h,p)=>{if(r>a||s>h||i>c||l>p)return!0;if(!e.length){let r=e;do{const e=r.data,i=e.x-t,s=e.y-n,a=Math.sqrt(i*i+s*s);C(e.r,o)>=a&&d>a&&(u=e,d=a),r=r.next}while(r)}return!1}),u?{node:u,distance:d}:null}(i,t,n,o,s);if(e)return e}else{let r=null,i=o;for(const s of e){if("point"!==s.type)continue;const e=s.x-t,a=s.y-n,l=Math.sqrt(e*e+a*a);C(s.r,o)>=l&&i>l&&(r=s,i=l)}if(r)return{node:r,distance:i}}for(let o=e.length-1;o>=0;o--){const i=e[o];if("geoarea"!==i.type)continue;const s=i;if(!1===s.interactive)continue;const[[a,l],[c,u]]=s.bounds;if(!(a>t||t>c||l>n||n>u)&&(s._cachedPath2D||(s._cachedPath2D=new Path2D(s.pathData)),r.isPointInPath(s._cachedPath2D,t,n)))return{node:s,distance:0}}let a=null,l=o;for(const o of e){if("line"!==o.type)continue;const e=o,{path:r}=e,i=Math.max((e.style.strokeWidth||2)+4,5);for(let o=0;r.length-1>o;o++){const[s,c]=r[o],[u,d]=r[o+1],h=$(t,n,s,c,u,d);i>=h&&l>h&&(a=e,l=h)}}return a?{node:a,distance:l}:null}function $(e,t,n,o,r,i){const s=r-n,a=i-o,l=s*s+a*a;if(0===l)return Math.sqrt(Math.pow(e-n,2)+Math.pow(t-o,2));let c=((e-n)*s+(t-o)*a)/l;c=Math.max(0,Math.min(1,c));const u=o+c*a;return Math.sqrt(Math.pow(e-(n+c*s),2)+Math.pow(t-u,2))}function L(n){const o=t.createContext(null),r=E(n);return[function({children:r}){const i=t.useMemo(()=>E(n),[]);return e.jsx(o.Provider,{value:i,children:r})},e=>{var n;const i=null!==(n=t.useContext(o))&&void 0!==n?n:r,s=t.useRef(e);s.current=e;const a=t.useCallback(()=>s.current(i.getState()),[i]),l=t.useCallback(()=>s.current(i.getState()),[i]);return t.useSyncExternalStore(i.subscribe,a,l)}]}function E(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)}}}function B(e){if(!(null==e?void 0:e.colors))return;const t=e.colors;return{primary:t.primary,secondary:t.secondary||t.primary,surface:t.surface||t.background,success:t.success,danger:t.danger,warning:t.warning,error:t.error,info:t.info,text:t.text,textSecondary:t.textSecondary,border:t.border,grid:t.grid}}function I(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t=Object.assign(Object.assign({},t),{colors:Object.assign(Object.assign({},t.colors),{categorical:D})})),e.accessibility.highContrast){const e="dark"===t.mode;t=Object.assign(Object.assign({},t),{colors:Object.assign(Object.assign({},t.colors),{text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"})})}return t}M.QUADTREE_THRESHOLD=500;const D=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],N={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},T={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},W={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:D,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"},[_,F]=L(e=>({theme:N,setTheme(t){e(e=>{if("light"===t)return{theme:N};if("dark"===t)return{theme:T};if("high-contrast"===t)return{theme:W};if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?T:N;return{theme:I(Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{})}))}}return{theme:I(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||{})}))}})}}));const q=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,H=new WeakMap;let G=0,V=!1,U=null,Z=null,Y=null;function X(e,t){var n,o;if(!t)return t;const r=q.exec(t);if(!r)return t;const i=e.canvas;if(!i)return(null===(n=r[2])||void 0===n?void 0:n.trim())||t;!function(){if(V)return;if("undefined"==typeof window||"undefined"==typeof document)return;V=!0;const e=()=>{G++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(U=new MutationObserver(e),U.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{Z=window.matchMedia("(prefers-color-scheme: dark)"),Y=e,"function"==typeof Z.addEventListener?Z.addEventListener("change",Y):"function"==typeof Z.addListener&&Z.addListener(Y)}catch(e){}}();let s=H.get(i);s&&s.version===G||(s={version:G,map:new Map},H.set(i,s));const a=s.map.get(t);if(void 0!==a)return a;const l=getComputedStyle(i).getPropertyValue(r[1]).trim()||(null===(o=r[2])||void 0===o?void 0:o.trim())||t;return s.map.set(t,l),l}function Q(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function K(e){const n=function(){const[e,n]=t.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return t.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return n(e.matches),function(e,t){return"function"==typeof e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))}(e,e=>n(e.matches))},[]),e}(),o=t.useRef(n);o.current=n;const[r,i]=function(e,n,o){const r=t.useRef(null),[i,s]=t.useState(null);return t.useEffect(()=>{if(!n&&!o)return;const e=r.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()},[n,o]),[r,[n&&i?i.w:e[0],o&&i?i.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),s=t.useMemo(()=>Object.assign(Object.assign({},e.marginDefault),e.userMargin),[e.marginDefault,e.userMargin]),a=i[0]-s.left-s.right,l=i[1]-s.top-s.bottom,c=Q(e.foregroundGraphics,i,s),u=Q(e.backgroundGraphics,i,s),d=F(e=>e.theme),{transition:h,introEnabled:p}=function(e,t){var n,o;if(!1===e)return{transition:void 0,introEnabled:!1};const r="undefined"!=typeof window&&(null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:e?!0===e?{duration:300}:{duration:null!==(o=e.duration)&&void 0!==o?o:300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(r||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),g="semiotic-table-"+f.useId(),y=t.useRef(0),m=t.useRef(()=>{}),b=t.useCallback(()=>{y.current||(y.current=requestAnimationFrame(()=>m.current()))},[]);t.useEffect(()=>()=>{y.current&&(cancelAnimationFrame(y.current),y.current=0)},[]);const v=t.useRef(()=>{}),x=t.useRef(()=>{}),j=t.useRef(null),k=t.useRef(0),w=t.useCallback(()=>{k.current=0;const e=j.current;j.current=null,e&&v.current(e)},[]),A=t.useCallback(e=>{j.current={clientX:e.clientX,clientY:e.clientY},0===k.current&&(k.current=requestAnimationFrame(w))},[w]),O=t.useCallback(()=>{j.current=null,0!==k.current&&(cancelAnimationFrame(k.current),k.current=0),x.current()},[]);t.useEffect(()=>()=>{j.current=null,0!==k.current&&(cancelAnimationFrame(k.current),k.current=0)},[]);const S=e.themeDirtyRef;return t.useEffect(()=>{S&&(G++,S.current=!0,b())},[d,b,S]),{reducedMotion:n,reducedMotionRef:o,responsiveRef:r,size:i,margin:s,adjustedWidth:a,adjustedHeight:l,resolvedForeground:c,resolvedBackground:u,currentTheme:d,transition:h,introEnabled:p,tableId:g,rafRef:y,renderFnRef:m,scheduleRender:b,hoverHandlerRef:v,hoverLeaveRef:x,onPointerMove:A,onPointerLeave:O}}const J={fill:t=>e.jsx("rect",{style:t,width:16,height:16}),line:t=>e.jsx("line",{style:t,x1:0,y1:0,x2:16,y2:16})};function ee(e,t,n,o){let r;return r="function"==typeof n?n(e):(0,J[n])(o(e,t)),r}function te(){return e.jsx("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function ne(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}const oe=(t,n,o,r,i,s,a,l,c,u)=>{const{type:d="fill",styleFn:h,items:p}=t,f=[];let g=0;const y=!(!n&&!o),m="isolate"===u||void 0===u&&null!=i;return p.forEach((t,u)=>{const b=ee(t,u,d,h),v=ne(t,r,i),x=i&&i.size>0&&i.has(t.label);f.push(e.jsxs("g",{transform:`translate(0,${g})`,onClick:n?()=>n(t):void 0,onMouseEnter:o?()=>o(t):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:y?l===s&&u===a?0:-1:void 0,role:y?"option":void 0,"aria-selected":y&&m?x||!1:void 0,"aria-current":y&&!m&&null!=r&&t.label===r||void 0,"aria-label":t.label,onKeyDown:y?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)+p.length)%p.length;c(l,t);const n=null===(o=e.currentTarget.parentElement)||void 0===o?void 0:o.children[t];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:y?e=>{c(l,u),o&&o(t);const n=e.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:y?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:y?"pointer":"default",opacity:v,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[y&&e.jsx("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"}),b,x&&e.jsx(te,{}),e.jsx("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+u)),g+=22}),f};function re({config:t,orientation:n="vertical",width:o=100}){const{colorFn:r,domain:i,label:s,format:a}=t,l=a||(e=>Math.round(100*e)/100+""),c="grad-legend-"+f.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.jsx("stop",{offset:100*n+"%",stopColor:r(i[0]+n*(i[1]-i[0]))},t))}return e.jsxs("g",{"aria-label":s||"Gradient legend",children:[e.jsx("defs",{children:e.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:u})}),s&&e.jsx("text",{x:a+n/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),e.jsx("rect",{x:a,y:0,width:n,height:t,fill:`url(#${c})`,rx:2}),e.jsx("text",{x:a,y:t+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(i[0])}),e.jsx("text",{x:a+n,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(i[1])})]})}const u=[];for(let t=0;64>=t;t++){const n=t/64;u.push(e.jsx("stop",{offset:100*n+"%",stopColor:r(i[1]-n*(i[1]-i[0]))},t))}return e.jsxs("g",{"aria-label":s||"Gradient legend",children:[s&&e.jsx("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),e.jsx("defs",{children:e.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:u})}),e.jsx("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),e.jsx("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(i[1])}),e.jsx("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(i[0])})]})}function ie(t){const{legendGroups:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:s,legendInteraction:a,title:l="Legend",width:c=100,height:u=20,orientation:d="vertical"}=t,[h,p]=f.useState(0),[g,y]=f.useState(0),m=f.useCallback((e,t)=>{p(e),y(t)},[]),b="vertical"===d?(({legendGroups:t,width:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u})=>{let d=24;const h=[];return t.forEach((t,p)=>{d+=5,h.push(e.jsx("line",{stroke:"gray",x1:0,y1:d,x2:n,y2:d},"legend-top-line legend-symbol-"+p)),d+=8,t.label&&(d+=16,h.push(e.jsx("text",{y:d,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label},"legend-text-"+p)),d+=8),h.push(e.jsx("g",{className:"legend-item",transform:`translate(0,${d})`,children:oe(t,o,r,i,s,a,l,p,c,u)},"legend-group-"+p)),d+=22*t.items.length+8}),h})({legendGroups:n||[],width:c,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:m,legendInteraction:a}):(({legendGroups:t,height:n,width:o,customClickBehavior:r,customHoverBehavior:i,highlightedCategory:s,isolatedCategories:a,focusedGroupIndex:l,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:d})=>{let h=0;const p=[];t.forEach((t,n)=>{let f=0;t.label&&(f+=16);const g=((t,n,o,r,i,s,a,l,c,u,d)=>{const{type:h="fill",styleFn:p,items:f}=t,g=[];let y=0,m=0;const b=!(!n&&!o),v="isolate"===u||void 0===u&&null!=i;f.forEach((t,u)=>{const x=ee(t,u,h,p),j=ne(t,r,i),k=i&&i.size>0&&i.has(t.label),w=26+7*t.label.length;d&&d>0&&y>0&&y+w>d&&(m++,y=0),g.push(e.jsxs("g",{transform:`translate(${y},${22*m})`,onClick:n?()=>n(t):void 0,onMouseEnter:o?()=>o(t):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:b?l===s&&u===a?0:-1:void 0,role:b?"option":void 0,"aria-selected":b&&v?k||!1:void 0,"aria-current":b&&!v&&null!=r&&t.label===r||void 0,"aria-label":t.label,onKeyDown:b?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(l,t);const n=null===(o=e.currentTarget.parentElement)||void 0===o?void 0:o.children[t];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:b?e=>{c(l,u),o&&o(t);const n=e.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:b?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:b?"pointer":"default",opacity:j,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[b&&e.jsx("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"}),x,k&&e.jsx(te,{}),e.jsx("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+u)),y+=w});let x=0,j=0;for(const e of f){const t=26+7*e.label.length;d&&d>0&&j>0&&j+t>d?(x=Math.max(x,j),j=t):j+=t}x=Math.max(x,j);const k=m+1;return{items:g,offset:x,totalRows:k,totalHeight:22*k}})(t,r,i,s,a,l,c,n,u,d,o);f+=g.offset+5,p.push(Object.assign(Object.assign({label:t.label},g),{offset:f,totalRows:g.totalRows,totalHeight:g.totalHeight})),h+=f+12});let f=h>o?0:Math.max(0,(o-h)/2);const g=[];return p.forEach((o,r)=>{const i=t[r];i.label&&(g.push(e.jsx("text",{transform:`translate(${f},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:i.label},"legend-text-"+r)),f+=16),g.push(e.jsx("g",{className:"legend-item",transform:`translate(${f},0)`,children:o.items},"legend-group-"+r)),f+=o.offset+5,t[r+1]&&g.push(e.jsx("line",{stroke:"gray",x1:f,y1:-8,x2:f,y2:(o.totalHeight||n)+0+8},"legend-top-line legend-symbol-"+r)),f+=12}),e.jsx("g",{children:g})})({legendGroups:n||[],title:l,height:u,width:c,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:m,legendInteraction:a}),v=!(!o&&!r);return e.jsxs("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==a&&(void 0!==a||null==s))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==l&&""!==l&&"vertical"===d&&e.jsx("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:l}),b]})}function se(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}function ae(t){const{legend:n,totalWidth:o,totalHeight:r,margin:i,legendPosition:s="right",title:a,legendHoverBehavior:l,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=t;if(!n)return null;const p="top"===s||"bottom"===s;let f,g;return"left"===s?(f=4,g=i.top):"top"===s?(f=0,g=a?32:8):"bottom"===s?(f=0,g=r-i.bottom+50):(f=o-i.right+10,g=i.top),e.jsx("g",{transform:`translate(${f}, ${g})`,children:(y=n,"object"==typeof y&&null!==y&&"gradient"in y?e.jsx(re,{config:n.gradient,orientation:p?"horizontal":"vertical",width:p?o:100}):se(n)?e.jsx(ie,{legendGroups:n.legendGroups,title:"",width:p?o:100,orientation:p?"horizontal":"vertical",customHoverBehavior:l,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):n)});var y}function le(e){return"string"==typeof e?{type:e}:e}function ce({orient:n,config:o,values:r,scale:s,size:a,length:l}){const c=function(e){var t,n,o,r,i;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!==(r=e.stroke)&&void 0!==r?r:"none",strokeWidth:null!==(i=e.strokeWidth)&&void 0!==i?i:1}}(o),u="top"===n||"bottom"===n,d=t.useMemo(()=>{if(0===r.length)return null;const t=s.domain(),o=a-8;if("boxplot"===c.type){const t=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)],r=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],s=i-o;return{q1:o,median:r,q3:i,whiskerLow:Math.max(t[0],o-1.5*s),whiskerHigh:Math.min(t[n-1],i+1.5*s)}}(r);if(!t)return null;const{q1:i,median:a,q3:l,whiskerLow:d,whiskerHigh:h}=t,p=Math.min(.5*o,20),f=(o-p)/2+4;if(u){const t=s(i),o=s(l),r=s(a),u=s(d),g=s(h),y="top"===n?-1:1,m=0;return e.jsxs("g",{"data-testid":"marginal-boxplot-"+n,children:[e.jsx("line",{x1:u,y1:m+y*(f+p/2),x2:g,y2:m+y*(f+p/2),stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:u,y1:m+y*f,x2:u,y2:m+y*(f+p),stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:g,y1:m+y*f,x2:g,y2:m+y*(f+p),stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("rect",{x:Math.min(t,o),y:"top"===n?m-f-p:m+f,width:Math.abs(o-t),height:p,fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:r,y1:"top"===n?m-f-p:m+f,x2:r,y2:"top"===n?m-f:m+f+p,stroke:c.fill,strokeWidth:2})]})}{const t=s(i),o=s(l),r=s(a),u=s(d),g=s(h),y="left"===n?-1:1,m=0;return e.jsxs("g",{"data-testid":"marginal-boxplot-"+n,children:[e.jsx("line",{x1:m+y*(f+p/2),y1:u,x2:m+y*(f+p/2),y2:g,stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:m+y*f,y1:u,x2:m+y*(f+p),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:m+y*f,y1:g,x2:m+y*(f+p),y2:g,stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("rect",{x:"left"===n?m-f-p:m+f,y:Math.min(t,o),width:p,height:Math.abs(o-t),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:"left"===n?m-f-p:m+f,y1:r,x2:"left"===n?m-f:m+f+p,y2:r,stroke:c.fill,strokeWidth:2})]})}}const d=i.bin().domain(t).thresholds(c.bins)(r);if(0===d.length)return null;const h=Math.max(...d.map(e=>e.length));if(0===h)return null;if("histogram"===c.type)return e.jsx("g",{"data-testid":"marginal-histogram-"+n,children:d.map((t,r)=>{if(null==t.x0||null==t.x1)return null;const i=t.length/h*o;if(u){const o=s(t.x0),a=s(t.x1)-s(t.x0);return e.jsx("rect",{x:o,y:"top"===n?-4-i:4,width:Math.max(a,.5),height:i,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},r)}{const o=s(t.x0),a=s(t.x1)-s(t.x0);return e.jsx("rect",{x:"left"===n?-4-i:4,y:Math.min(o,o+a),width:i,height:Math.abs(a),fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},r)}})});if("violin"===c.type){const t=o/2+4,r=[];for(const e of d){if(null==e.x0||null==e.x1)continue;const i=e.length/h*(o/2),a=s((e.x0+e.x1)/2);r.push(u?`${a},${"top"===n?-(t-i):t-i}`:`${"left"===n?-(t-i):t-i},${a}`)}for(let e=d.length-1;e>=0;e--){const i=d[e];if(null==i.x0||null==i.x1)continue;const a=i.length/h*(o/2),l=s((i.x0+i.x1)/2);r.push(u?`${l},${"top"===n?-(t+a):t+a}`:`${"left"===n?-(t+a):t+a},${l}`)}return e.jsx("g",{"data-testid":"marginal-violin-"+n,children:e.jsx("polygon",{points:r.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}if("ridgeline"===c.type){const t=[];if(u){const e=0,r=null!=d[0].x0?s(d[0].x0):0;t.push(`M${r},${e}`);for(const e of d){if(null==e.x0||null==e.x1)continue;const r=e.length/h*o,i=s((e.x0+e.x1)/2);t.push(`L${i},${"top"===n?-r-4:r+4}`)}const i=null!=d[d.length-1].x1?s(d[d.length-1].x1):l;t.push(`L${i},${e}`),t.push("Z")}else{const e=0,r=null!=d[0].x0?s(d[0].x0):0;t.push(`M${e},${r}`);for(const e of d){if(null==e.x0||null==e.x1)continue;const r=e.length/h*o,i=s((e.x0+e.x1)/2);t.push(`L${"left"===n?-r-4:r+4},${i}`)}const i=null!=d[d.length-1].x1?s(d[d.length-1].x1):l;t.push(`L${e},${i}`),t.push("Z")}return e.jsx("g",{"data-testid":"marginal-ridgeline-"+n,children:e.jsx("path",{d:t.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}return null},[r,s,c,a,l,n,u,4]);return d?e.jsx("g",{className:"marginal-"+n,"data-testid":"marginal-"+n,children:d}):null}function ue(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=e.split(/\s+/),i=[];let s="";for(const e of r)s&&s.length+1+e.length>o?(i.push(s),s=e):s=s?`${s} ${e}`:e;return s&&i.push(s),i}function de(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 he(t,n,o,r){if(!t)return e.jsx("g",{className:"annotation-note"});const{label:i,title:s,orientation:a,align:l,wrap:c=120,noWrap:u}=t;if(!i&&!s)return e.jsx("g",{className:"annotation-note"});let d=a;d||(d=Math.abs(n)>Math.abs(o)?"leftRight":"topBottom");let h=l;h&&"dynamic"!==h||(h="topBottom"===d?0>n?"right":"left":0>o?"bottom":"top");let p="start";"topBottom"===d?"right"===h?p="end":"middle"===h&&(p="middle"):p=0>n?"end":"start";const f=16,g=s?u?[s]:ue(s,c):[],y=i?u?[i]:ue(i,c):[],m="leftRight"===d?"end"===p?-4:4:0;let b=0;const v=[],x=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";g.length>0&&(v.push(e.jsx("text",{className:"annotation-note-title",fill:x,textAnchor:p,fontWeight:"bold",children:g.map((t,n)=>e.jsx("tspan",{x:m,dy:0===n?0:f,children:t},n))},"annotation-note-title")),b=g.length*f),y.length>0&&v.push(e.jsx("text",{className:"annotation-note-label",fill:x,textAnchor:p,y:b,children:y.map((t,n)=>e.jsx("tspan",{x:m,dy:0===n?0:f,children:t},n))},"annotation-note-label"));let j=null;if((s||i)&&(0!==n||0!==o))if("topBottom"===d){const t=Math.min(c,120);let n=0,o=t;"end"===p?(n=-t,o=0):"middle"===p&&(n=-t/2,o=t/2),j=e.jsx("line",{className:"note-line",x1:n,x2:o,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const t=(g.length+y.length)*f+(y.length>0?f:0);let n=0,o=t;"bottom"===h?(n=-t,o=0):"middle"===h&&(n=-t/2,o=t/2),j=e.jsx("line",{className:"note-line",x1:0,x2:0,y1:n,y2:o,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const k=Math.max(0,g.length+y.length-1)*f;let w=0;return"topBottom"===d?w=0>o?-(k+2):18:"leftRight"===d&&(w="middle"===h?-(k+f+(y.length>0&&g.length>0?2:0))/2+8:"bottom"===h||0>o?-(k+2):18),e.jsxs("g",{className:"annotation-note",transform:`translate(${n},${o})`,children:[e.jsx("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0,children:v}),j]})}function pe(t,n,o,r,i){var s;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.jsx("circle",{r:t,fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const t=(null==n?void 0:n.width)||0,r=(null==n?void 0:n.height)||0;(t>0||r>0)&&a.push(e.jsx("rect",{width:t,height:r,fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));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=r||0,s=i||0;if(void 0!==(null==n?void 0:n.x)){const r=(n.x||0)-t;a.push(e.jsx("line",{x1:r,y1:(n.y1||0)-s,x2:r,y2:(n.y2||0)-s,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==(null==n?void 0:n.y)){const r=(n.y||0)-s;a.push(e.jsx("line",{x1:(n.x1||0)-t,y1:r,x2:(n.x2||0)-t,y2:r,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?a.push(e.jsx("line",{x1:(n.x1||0)-t,y1:0,x2:(n.x2||0)-t,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||a.push(e.jsx("line",{x1:0,y1:(n.y1||0)-s,x2:0,y2:(n.y2||0)-s,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const t=null!==(s=null==n?void 0:n.width)&&void 0!==s?s:null==n?void 0:n.height;void 0!==t&&a.push(e.jsx("path",{d:de((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||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return e.jsx("g",{className:"annotation-subject",children:a})}function fe(t,n,o,r,i,s){const a=[];let l=0,c=0;if("callout-circle"!==i&&"label"!==i||!(null==s?void 0:s.radius)){if("callout-rect"===i&&s){const e=s.width||0,o=s.height||0;if(e>0||o>0){const r=e/2,i=o/2,s=t-r,a=n-i;if(0!==s||0!==a){const t=Math.abs(s),n=Math.abs(a),u=e/2,d=o/2,h=t*d>n*u?u/t:d/n;l=r+s*h,c=i+a*h}}}else if("bracket"===i&&s){const e=s.width,t=s.height,n=s.depth||30;void 0!==e?(l=e/2,c=n):void 0!==t&&(l=n,c=t/2)}}else{const e=(s.radius||0)+(s.radiusPadding||0);if(e>0&&(0!==t||0!==n)){const o=Math.atan2(n,t);l=Math.cos(o)*e,c=Math.sin(o)*e}}if(Math.sqrt(Math.pow(t-l,2)+Math.pow(n-c,2))>.5&&(a.push(e.jsx("line",{x1:l,y1:c,x2:t,y2:n,stroke:r||"var(--semiotic-text-secondary, currentColor)"},"connector-line")),"arrow"===(null==o?void 0:o.end))){const o=10,i=16/180*Math.PI,s=Math.atan2(n-c,t-l);a.push(e.jsx("path",{d:`M${l},${c}L${l+o*Math.cos(s+i)},${c+o*Math.sin(s+i)}L${l+o*Math.cos(s-i)},${c+o*Math.sin(s-i)}Z`,fill:r||"var(--semiotic-text-secondary, currentColor)",stroke:"none"},"connector-arrow"))}return e.jsx("g",{className:"annotation-connector",children:a})}function ge(t){const{x:n=0,y:o=0,dx:r,dy:i,nx:s,ny:a,note:l,connector:c,subject:u,type:d,color:h,className:p,disable:f,events:g={},"data-testid":y}=t,m=new Set(Array.isArray(f)?f:[]);let b=r||0,v=i||0;null!=s&&(b=s-n),null!=a&&(v=a-o);const x="string"==typeof d?d:"label";if("bracket"===x&&u&&0===b&&0===v)if(void 0!==u.width){b=u.width/2;const e=u.depth||30;v=e+(0>e?-5:5)}else if(void 0!==u.height){const e=u.depth||30;b=e+(0>e?-5:5),v=u.height/2}return e.jsxs("g",Object.assign({className:("annotation "+(p||"")).trim(),transform:`translate(${n},${o})`,"data-testid":y},g,{children:[!m.has("connector")&&fe(b,v,c,h,x,u),!m.has("subject")&&pe(x,u,h,n,o),!m.has("note")&&he(l,b,v,h)]}))}function ye(t){var n,o;const{noteData:r}=t,{screenCoordinates:i}=r,s="string"==typeof r.type?r.type:"label",a=r.eventListeners||r.events||{};if(r.coordinates&&i){const t=r.nx||i[0][0]+(null!==(n=r.dx)&&void 0!==n?n:0),a=r.ny||i[0][1]+(null!==(o=r.dy)&&void 0!==o?o:0),l=i.map((n,o)=>{const i=Object.assign({},r,{note:0===o?r.note:{label:""},x:n[0],y:n[1],nx:t,ny:a});return e.jsx(ge,Object.assign({"data-testid":"semiotic-annotation"},i,{type:s}),"multi-annotation-"+o)});return e.jsx("g",{children:l})}const l=r.note||{title:"none",label:r.label},c=`${l.label}-${l.title}-${r.i}`;return e.jsx(ge,Object.assign({"data-testid":"semiotic-annotation",events:a},r,{type:s}),c)}function me(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function be(e,t){var n,o,r;const i=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(r=t.scales)||void 0===r?void 0:r.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function ve(e,t,n){var o,r,i,s;const a=e.anchor||"fixed";if("latest"===a){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const i=n.pointNodes[r];if(i.pointId===e.pointId){const e={x:i.x,y:i.y};return null===(o=n.stickyPositionCache)||void 0===o||o.set(t,e),e}}const i=function(e){var t,n,o,r,i,s;const a=e.data;if(!a||0===a.length)return null;const l=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!==(i=null===(r=e.scales)||void 0===r?void 0:r.y)&&void 0!==i?i:null===(s=e.scales)||void 0===s?void 0:s.value;if(!c||!u)return null;const d=l[e.xAccessor||"x"],h=l[e.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return i&&(null===(r=n.stickyPositionCache)||void 0===r||r.set(t,i)),i}let l=null,c=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(l=t.x,c=t.y)}if(null!=l&&null!=c||(l=me(e,n),c=be(e,n)),null!=l&&null!=c)return null===(i=n.stickyPositionCache)||void 0===i||i.set(t,{x:l,y:c}),{x:l,y:c};if("sticky"===a){const e=null===(s=n.stickyPositionCache)||void 0===s?void 0:s.get(t);if(e)return e}return null}function xe(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}const je={linear:a.curveLinear,monotoneX:a.curveMonotoneX,monotoneY:a.curveMonotoneY,step:a.curveStep,stepAfter:a.curveStepAfter,stepBefore:a.curveStepBefore,basis:a.curveBasis,cardinal:a.curveCardinal,catmullRom:a.curveCatmullRom};let ke={positions:new Map};const we=new Set;function Ae(){for(const e of we)e()}function Oe(e,t){const n=ke.positions.get(e);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==t)return;const o=new Map(ke.positions);o.delete(e),ke={positions:o},Ae()}function Se(e,t){const n=ke.positions.get(e);if(!(null==n?void 0:n.locked))return;if(t&&n.sourceId!==t)return;const o=new Map(ke.positions);o.delete(e),ke={positions:o},Ae()}function Me(){return ke}function Ce(e){return we.add(e),()=>we.delete(e)}const Re={positions:new Map};function Pe(){return()=>{}}function ze(){return Re}function $e(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Le(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,r="left"===e?-1:1,i=Math.ceil(t/8);let s="M0,"+o;for(let e=0;i>e;e++){const n=8*(e+1);s+=`L${Math.min(8*e+4,t)},${o+4*r}`,s+=`L${Math.min(n,t)},${o}`}return s}{const o="bottom"===e?0:t,r="bottom"===e?1:-1,i=Math.ceil(n/8);let s=`M${o},0`;for(let e=0;i>e;e++){const t=8*(e+1);s+=`L${o+4*r},${Math.min(8*e+4,n)}`,s+=`L${o},${Math.min(t,n)}`}return s}}function Ee(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function Be(e,t){if(2>=e.length)return e;const n=[e[0]];for(let o=1;e.length-1>o;o++)t>Math.abs(e[o].pixel-n[n.length-1].pixel)||n.push(e[o]);const o=e[e.length-1];return t>Math.abs(o.pixel-n[n.length-1].pixel)?n[n.length-1]=o:n.push(o),n}function Ie(n){var o,r;const{width:i,height:l,totalWidth:c,totalHeight:u,margin:d,scales:h,showAxes:p,axes:f,xLabel:y,yLabel:m,yLabelRight:b,xFormat:v,yFormat:x,showGrid:j,title:k,legend:w,legendHoverBehavior:A,legendClickBehavior:O,legendHighlightedCategory:S,legendIsolatedCategories:M,legendPosition:C="right",foregroundGraphics:R,marginalGraphics:z,xValues:$,yValues:L,annotations:E,svgAnnotationRules:B,xAccessor:I,yAccessor:D,annotationData:N,pointNodes:T,curve:W,underlayRendered:_,linkedCrosshairName:F,linkedCrosshairSourceId:q,children:H}=n,G=t.useMemo(()=>{var e;if(!p||!h)return[];const t=null==f?void 0:f.find(e=>"bottom"===e.orient),n=(null==t?void 0:t.tickFormat)||v||Ee,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,r=h.x.ticks(Math.min(o,Math.max(2,Math.floor(i/70)))),s=r.map(e=>e.valueOf()),a=r.map((e,t)=>({value:e,pixel:h.x(e),label:n(e,t,s)})),l=a.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),c=(null==t?void 0:t.autoRotate)?Math.max(20,Math.min(l+8,55)):Math.max(55,l+8);let u=Be(a,c);if(u.length>1&&(u=u.filter((e,t)=>0===t||e.label+""!=u[t-1].label+"")),(null==t?void 0:t.includeMax)&&u.length>0){const e=h.x.domain()[1],t=h.x(e),o=u[u.length-1].pixel;if(Math.abs(t-o)>1){const r=n(e,u.length,s);c>t-o&&u.length>1&&(u=u.slice(0,-1)),u.push({value:e,pixel:t,label:r})}}return u},[p,h,f,v,i]),V=t.useMemo(()=>{var e;if(!p||!h)return[];const t=null==f?void 0:f.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||x||Ee,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;let r=Be(h.y.ticks(Math.min(o,Math.max(2,Math.floor(l/30)))).map(e=>({value:e,pixel:h.y(e),label:n(e)})),22);if(r.length>1&&(r=r.filter((e,t)=>0===t||e.label+""!=r[t-1].label+"")),(null==t?void 0:t.includeMax)&&r.length>0){const e=h.y.domain()[1],t=h.y(e),o=r[r.length-1].pixel;if(Math.abs(t-o)>1){const i=n(e);22>Math.abs(t-o)&&r.length>1&&(r=r.slice(0,-1)),r.push({value:e,pixel:t,label:i})}}return r},[p,h,f,x,l]),U=t.useMemo(()=>{var e;if(!p||!h)return[];const t=null==f?void 0:f.find(e=>"right"===e.orient);if(!t)return[];const n=t.tickFormat||x||Ee,o=null!==(e=t.ticks)&&void 0!==e?e:5;return Be(h.y.ticks(Math.min(o,Math.max(2,Math.floor(l/30)))).map(e=>({value:e,pixel:h.y(e),label:n(e)})),22)},[p,h,f,x,l]),Z=t.useRef(new Map),Y=t.useRef(null!==(o=null==E?void 0:E.length)&&void 0!==o?o:0),X=null!==(r=null==E?void 0:E.length)&&void 0!==r?r:0;Y.current!==X&&(Y.current=X,Z.current=new Map);const Q=t.useMemo(()=>{if(!E||0===E.length)return null;const t=function(t,n,o){var r,i,l,c,u,d,h,p,f,y,m,b,v,x,j,k,w,A,O,S,M,C,R,P,z,$,L,E,B,I,D,N,T,W,_,F,q,H,G,V,U,Z,Y,X,Q,K,J,ee;switch(t.type){case"label":{const r=ve(t,n,o);if(!r)return null;const{x:i,y:s}=r;return xe(i,s,o)?e.jsx(ye,{noteData:{x:i,y:s,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}},"ann-"+n):null}case"callout":{const r=ve(t,n,o);if(!r)return null;const{x:i,y:s}=r;return xe(i,s,o)?e.jsx(ye,{noteData:{x:i,y:s,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}},"ann-"+n):null}case"x-threshold":{const r=me(t,o);if(null==r)return null;const i=t.color||"#f97316",s=t.labelPosition||"top";let a;return a="bottom"===s?(o.height||0)-4:"center"===s?(o.height||0)/2:12,e.jsxs("g",{children:[e.jsx("line",{x1:r,y1:0,x2:r,y2:o.height||0,stroke:i,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.jsx("text",{x:r+4,y:a,fill:i,fontSize:12,fontWeight:"bold",children:t.label})]},"ann-"+n)}case"y-threshold":{const r=be(t,o);if(null==r)return null;const i=t.color||"#f97316",s=t.labelPosition||"right";let a,l;return"left"===s?(a=4,l="start"):"center"===s?(a=(o.width||0)/2,l="middle"):(a=(o.width||0)-4,l="end"),e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:r,x2:o.width||0,y2:r,stroke:i,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.jsx("text",{x:a,y:r-4,textAnchor:l,fill:i,fontSize:12,fontWeight:"bold",children:t.label})]},"ann-"+n)}case"enclose":{const r=(t.coordinates||[]).map(e=>({x:me(Object.assign(Object.assign({},e),{type:"point"}),o),y:be(Object.assign(Object.assign({},e),{type:"point"}),o),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;const i=s.packEnclose(r),a=t.padding||10;return e.jsxs("g",{children:[e.jsx("circle",{cx:i.x,cy:i.y,r:i.r+a,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.jsx("text",{x:i.x,y:i.y-i.r-a-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:t.label})]},"ann-"+n)}case"rect-enclose":{const r=(t.coordinates||[]).map(e=>({x:me(Object.assign(Object.assign({},e),{type:"point"}),o),y:be(Object.assign(Object.assign({},e),{type:"point"}),o)})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;const i=t.padding||10,s=r.map(e=>e.x),a=r.map(e=>e.y),l=Math.min(...s)-i,c=Math.max(...s)+i,u=Math.min(...a)-i,d=Math.max(...a)+i;return e.jsxs("g",{children:[e.jsx("rect",{x:l,y:u,width:c-l,height:d-u,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.jsx("text",{x:(l+c)/2,y:u-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:t.label})]},"ann-"+n)}case"highlight":{const r=o.data||[],i="function"==typeof t.filter?r.filter(t.filter):t.field&&null!=t.value?r.filter(e=>e[t.field]===t.value):[],s={stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return e.jsx("g",{children:i.map((n,r)=>{const i=me(n,o),a=be(n,o);if(null==i||null==a)return null;const l="function"==typeof t.r?t.r(n):t.r||6,c="function"==typeof t.style?t.style(n):t.style||s;return e.jsx("circle",Object.assign({cx:i,cy:a,r:l},c),"hl-"+r)})},"ann-"+n)}case"bracket":{const r=me(t,o),i=be(t,o);return e.jsx(ye,{noteData:{x:null!=r?r:0,y:null!=i?i: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}},"ann-"+n)}case"trend":{const s=o.data||[];if(2>s.length)return null;const a=o.xAccessor||"x",p=o.yAccessor||"y",f=s.map(e=>[e[a],e[p]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>f.length)return null;const y=null!==(i=null===(r=o.scales)||void 0===r?void 0:r.x)&&void 0!==i?i:null===(l=o.scales)||void 0===l?void 0:l.time,m=null!==(u=null===(c=o.scales)||void 0===c?void 0:c.y)&&void 0!==u?u:null===(d=o.scales)||void 0===d?void 0:d.value;if(!y||!m)return null;const b=t.method||"linear";let v;v="loess"===b?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]),r=o.map(e=>e[0]),i=o.map(e=>e[1]),s=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=r[e],o=r.map(e=>Math.abs(e-t)),l=o.slice().sort((e,t)=>e-t)[Math.min(s-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:o[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,p=0,f=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*r[e],h+=t*i[e],p+=t*r[e]*r[e],f+=t*r[e]*i[e])}if(0===u){a.push([t,i[e]]);continue}const g=u*p-d*d;if(1e-12>Math.abs(g))a.push([t,h/u]);else{const e=(u*f-d*h)/g;a.push([t,(h-e*d)/u+e*t])}}return a}(f,null!==(h=t.bandwidth)&&void 0!==h?h:.3):("polynomial"===b?g.default.polynomial(f,{order:t.order||2}):g.default.linear(f)).points;const x=v.map(([e,t])=>`${y(e)},${m(t)}`).join(" "),j=t.color||"#6366f1";return e.jsxs("g",{children:[e.jsx("polyline",{points:x,fill:"none",stroke:j,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.jsx("text",{x:y(v[v.length-1][0])+4,y:m(v[v.length-1][1])-4,fill:j,fontSize:11,children:t.label})]},"ann-"+n)}case"band":{const r=null!==(f=null===(p=o.scales)||void 0===p?void 0:p.y)&&void 0!==f?f:null===(y=o.scales)||void 0===y?void 0:y.value,i=null!==(m=null==r?void 0:r(t.y0))&&void 0!==m?m:0,s=null!==(b=null==r?void 0:r(t.y1))&&void 0!==b?b:o.height||0;return e.jsxs("g",{children:[e.jsx("rect",{x:0,y:Math.min(i,s),width:o.width||0,height:Math.abs(s-i),fill:t.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:t.fillOpacity||.1}),t.label&&e.jsx("text",{x:(o.width||0)-4,y:Math.min(i,s)-4,textAnchor:"end",fill:t.color||"var(--semiotic-primary, #6366f1)",fontSize:11,children:t.label})]},"ann-"+n)}case"envelope":{const r=o.data||[];if(2>r.length)return null;const i=o.xAccessor||"x",s=null!==(x=null===(v=o.scales)||void 0===v?void 0:v.x)&&void 0!==x?x:null===(j=o.scales)||void 0===j?void 0:j.time,l=null!==(w=null===(k=o.scales)||void 0===k?void 0:k.y)&&void 0!==w?w:null===(A=o.scales)||void 0===A?void 0:A.value;if(!s||!l)return null;const c=t.upperAccessor||"upperBounds",u=t.lowerAccessor||"lowerBounds",d=t.filter,h=r.filter(e=>null!=e[c]&&null!=e[u]&&!(d&&!d(e))).sort((e,t)=>e[i]-t[i]);if(2>h.length)return null;const p=je[o.curve||"linear"]||a.curveLinear,f=a.area().x(e=>s(e[i])).y0(e=>l(e[u])).y1(e=>l(e[c])).curve(p)(h);if(!f)return null;const g=t.fill||"#6366f1";return e.jsxs("g",{children:[e.jsx("path",{d:f,fill:g,fillOpacity:null!==(O=t.fillOpacity)&&void 0!==O?O:.15,stroke:"none"}),t.label&&h.length>0&&e.jsx("text",{x:s(h[h.length-1][i])+4,y:l(h[h.length-1][c])-4,fill:g,fontSize:11,children:t.label})]},"ann-"+n)}case"anomaly-band":{const r=o.data||[];if(2>r.length)return null;const i=o.yAccessor||"y",s=null!==(M=null===(S=o.scales)||void 0===S?void 0:S.x)&&void 0!==M?M:null===(C=o.scales)||void 0===C?void 0:C.time,a=null!==(P=null===(R=o.scales)||void 0===R?void 0:R.y)&&void 0!==P?P:null===(z=o.scales)||void 0===z?void 0:z.value;if(!s||!a)return null;const l=r.map(e=>e[i]).filter(e=>null!=e&&isFinite(e));if(2>l.length)return null;const c=l.reduce((e,t)=>e+t,0)/l.length,u=l.reduce((e,t)=>e+Math.pow(t-c,2),0)/l.length,d=Math.sqrt(u),h=null!==($=t.threshold)&&void 0!==$?$:2,p=c-h*d,f=!1!==t.showBand,g=t.fill||"#6366f1",y=null!==(L=t.fillOpacity)&&void 0!==L?L:.1,m=t.anomalyColor||"#ef4444",b=null!==(E=t.anomalyRadius)&&void 0!==E?E:6,v=a(c+h*d),x=a(p),j=r.filter(e=>{const t=e[i];return null!=t&&Math.abs(t-c)>h*d});return e.jsxs("g",{children:[f&&e.jsx("rect",{x:0,y:Math.min(v,x),width:o.width||0,height:Math.abs(x-v),fill:g,fillOpacity:y}),j.map((t,n)=>{const r=me(t,o),i=be(t,o);return null==r||null==i?null:e.jsx("circle",{cx:r,cy:i,r:b,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5},"anomaly-"+n)}),t.label&&e.jsx("text",{x:(o.width||0)-4,y:Math.min(v,x)-4,textAnchor:"end",fill:g,fontSize:11,children:t.label})]},"ann-"+n)}case"forecast":{const r=o.data||[];if(3>r.length)return null;const i=o.xAccessor||"x",s=o.yAccessor||"y",a=null!==(I=null===(B=o.scales)||void 0===B?void 0:B.x)&&void 0!==I?I:null===(D=o.scales)||void 0===D?void 0:D.time,l=null!==(T=null===(N=o.scales)||void 0===N?void 0:N.y)&&void 0!==T?T:null===(W=o.scales)||void 0===W?void 0:W.value;if(!a||!l)return null;const c=r.map(e=>[e[i],e[s]]).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=g.default.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,r=0;for(const[e,i]of c)t+=e,n+=i,o+=e*e,r+=e*i;const i=e*o-t*t;if(1e-12>Math.abs(i))return null;const s=(e*r-t*n)/i,a=(n-s*t)/e;u=e=>a+s*e}const d=c.length,h=c.map(([e,t])=>t-u(e)).reduce((e,t)=>e+t*t,0),p=Math.sqrt(h/Math.max(d-2,1)),f=c.reduce((e,t)=>e+t[0],0)/d,y=c.reduce((e,t)=>e+Math.pow(t[0]-f,2),0),m=null!==(_=t.confidence)&&void 0!==_?_:.95,b=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,v=null!==(F=t.steps)&&void 0!==F?F:5,x=c[d-1][0],j=(x-c[0][0])/Math.max(d-1,1),k=[];for(let e=1;v>=e;e++)k.push(x+e*j);const w=[];for(const e of k){const t=u(e),n=p*Math.sqrt(1+1/d+(y>0?Math.pow(e-f,2)/y:0))*b;w.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const A=`M${w.map(e=>`${a(e.x)},${l(e.yUpper)}`).join(" L")} L${w.slice().reverse().map(e=>`${a(e.x)},${l(e.yLower)}`).join(" L")} Z`,O=w.map(e=>`${a(e.x)},${l(e.yCenter)}`).join(" "),S=`${a(x)},${l(u(x))}`,M=t.strokeColor||"#6366f1";return e.jsxs("g",{children:[e.jsx("path",{d:A,fill:t.fill||"#6366f1",fillOpacity:null!==(q=t.fillOpacity)&&void 0!==q?q:.15,stroke:"none"}),e.jsx("polyline",{points:`${S} ${O}`,fill:"none",stroke:M,strokeWidth:null!==(H=t.strokeWidth)&&void 0!==H?H:2,strokeDasharray:null!==(G=t.strokeDasharray)&&void 0!==G?G:"6,3"}),t.label&&w.length>0&&e.jsx("text",{x:a(w[w.length-1].x)+4,y:l(w[w.length-1].yCenter)-4,fill:M,fontSize:11,children:t.label})]},"ann-"+n)}case"widget":{let r=null,i=null;if(null!=t.px&&null!=t.py)r=t.px,i=t.py;else{const e=ve(t,n,o);if(!e)return null;r=e.x,i=e.y}if(null==r||null==i)return null;if(!xe(r,i,o))return null;const s=null!==(V=t.dx)&&void 0!==V?V:0,a=null!==(U=t.dy)&&void 0!==U?U:0,l=null!==(Z=t.width)&&void 0!==Z?Z:32,c=null!==(Y=t.height)&&void 0!==Y?Y:32,u=null!==(X=t.content)&&void 0!==X?X:e.jsx("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info",children:"ℹ️"});return e.jsx("foreignObject",{x:r+s-l/2,y:i+a-c/2,width:l,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:e.jsx("div",{style:{width:l,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const r=ve(t,n,o);if(!r)return null;const{x:i,y:s}=r;return e.jsx("text",{x:i+(t.dx||0),y:s+(t.dy||0),fill:t.color||"var(--semiotic-text, #333)",fontSize:t.fontSize||11,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:t.label},"ann-text-"+n)}case"category-highlight":{const r=t.category;if(null==r)return null;const i=null===(Q=o.scales)||void 0===Q?void 0:Q.o,s=null===(K=o.scales)||void 0===K?void 0:K.x,a=null===(J=o.scales)||void 0===J?void 0:J.y,l=(null==i?void 0:i.bandwidth)?i:(null==s?void 0:s.bandwidth)?s:(null==a?void 0:a.bandwidth)?a:null;if(!l)return null;const c=l(r);if(null==c)return null;const u=l.bandwidth(),d=t.color||"var(--semiotic-primary, #4589ff)",h=null!==(ee=t.opacity)&&void 0!==ee?ee:.15,p=t.label;return e.jsxs("g",(o.projection?"vertical"===o.projection:l===s)?{children:[e.jsx("rect",{x:c,y:0,width:u,height:o.height||0,fill:d,fillOpacity:h}),p&&e.jsx("text",{x:c+u/2,y:12,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold",children:p})]}:{children:[e.jsx("rect",{x:0,y:c,width:o.width||0,height:u,fill:d,fillOpacity:h}),p&&e.jsx("text",{x:12,y:c+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold",children:p})]},"ann-"+n)}default:return null}},n={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:I,yAccessor:D,width:i,height:l,data:N,frameType:"xy",pointNodes:T,curve:W,stickyPositionCache:Z.current};return E.map((e,o)=>{if(B){const r=B(e,o,n);return null!=r?r:t(e,o,n)}return t(e,o,n)}).filter(Boolean)},[E,B,i,l,I,D,N,h,T,W]),K=function(e){var n;const o=t.useSyncExternalStore(e?Ce:Pe,e?Me:ze,e?Me:ze);return e&&null!==(n=o.positions.get(e))&&void 0!==n?n:null}(F);return t.useEffect(()=>{if(!(null==K?void 0:K.locked)||!F)return;const e=e=>{"Escape"===e.key&&Se(F)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[null==K?void 0:K.locked,F]),p||k||w||R||z||Q&&Q.length>0||j||H||K?e.jsxs("svg",{role:"img",width:c,height:u,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[e.jsx("title",{children:"string"==typeof k?k:"XY Chart"}),e.jsx("desc",{children:"string"==typeof k?k+" — XY data visualization":"XY data visualization"}),e.jsxs("g",{transform:`translate(${d.left},${d.top})`,children:[j&&h&&!_&&(()=>{var t,n;const o=$e(null===(t=null==f?void 0:f.find(e=>"bottom"===e.orient))||void 0===t?void 0:t.gridStyle),r=$e(null===(n=null==f?void 0:f.find(e=>"left"===e.orient))||void 0===n?void 0:n.gridStyle);return e.jsxs("g",{className:"stream-grid",children:[G.map((t,n)=>e.jsx("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:l,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"xgrid-"+n)),V.map((t,n)=>e.jsx("line",{x1:0,y1:t.pixel,x2:i,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),p&&h&&(()=>{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,r=!n||!1!==n.baseline,s=(null==t?void 0:t.jaggedBase)||!1,a=(null==n?void 0:n.jaggedBase)||!1,c=null==n?void 0:n.landmarkTicks,u=null==t?void 0:t.landmarkTicks,h="var(--semiotic-border, #ccc)",p="var(--semiotic-text-secondary, var(--semiotic-text, #666))",g="var(--semiotic-text, #333)",v=!!(null==n?void 0:n.autoRotate)&&G.length>1&&(()=>{const e=i/Math.max(G.length-1,1);return G.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})();return e.jsxs("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[!_&&r&&!a&&e.jsx("line",{x1:0,y1:l,x2:i,y2:l,stroke:h,strokeWidth:1}),!_&&a&&e.jsx("path",{d:Le("bottom",i,l),fill:"none",stroke:h,strokeWidth:1}),G.map((t,n)=>{const o=!!c&&("function"==typeof c?c(t.value,n):P(t.value,n>0?G[n-1].value:void 0));return e.jsxs("g",{transform:`translate(${t.pixel},${l})`,children:[e.jsx("line",{y2:5,stroke:h,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{y:v?10:18,textAnchor:v?"end":"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:p,style:{userSelect:"none"},transform:v?"rotate(-45)":void 0,children:t.label}):e.jsx("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"},children:t.label})})]},"xtick-"+n)}),y&&e.jsx("text",{x:i/2,y:l+40,textAnchor:"middle",fontSize:12,fill:g,style:{userSelect:"none"},children:y}),!_&&o&&!s&&e.jsx("line",{x1:0,y1:0,x2:0,y2:l,stroke:h,strokeWidth:1}),!_&&s&&e.jsx("path",{d:Le("left",i,l),fill:"none",stroke:h,strokeWidth:1}),V.map((t,n)=>{const o=!!u&&("function"==typeof u?u(t.value,n):P(t.value,n>0?V[n-1].value:void 0));return e.jsxs("g",{transform:`translate(0,${t.pixel})`,children:[e.jsx("line",{x2:-5,stroke:h,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:p,style:{userSelect:"none"},children:t.label}):e.jsx("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"},children:t.label})})]},"ytick-"+n)}),(()=>{const n=(null==t?void 0:t.label)||m;return n?e.jsx("text",{x:15-d.left,y:l/2,textAnchor:"middle",fontSize:12,fill:g,transform:`rotate(-90, ${15-d.left}, ${l/2})`,style:{userSelect:"none"},children:n}):null})(),(()=>{const t=null==f?void 0:f.find(e=>"right"===e.orient);if(!t||0===U.length)return null;const n=t.landmarkTicks,o=t.label||b;return e.jsxs(e.Fragment,{children:[!1!==t.baseline&&e.jsx("line",{x1:i,y1:0,x2:i,y2:l,stroke:h,strokeWidth:1}),U.map((t,o)=>{const r=!!n&&("function"==typeof n?n(t.value,o):P(t.value,o>0?U[o-1].value:void 0));return e.jsxs("g",{transform:`translate(${i},${t.pixel})`,children:[e.jsx("line",{x2:5,stroke:h,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:r?11:10,fontWeight:r?600:400,fill:p,style:{userSelect:"none"},children:t.label}):e.jsx("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:{textAlign:"left",fontSize:10,userSelect:"none"},children:t.label})})]},"ytick-r-"+o)}),o&&e.jsx("text",{x:i+d.right-15,y:l/2,textAnchor:"middle",fontSize:12,fill:g,transform:`rotate(90, ${i+d.right-15}, ${l/2})`,style:{userSelect:"none"},children:o})]})})()]})})(),Q,z&&h&&$&&L&&e.jsxs(e.Fragment,{children:[z.top&&e.jsx("g",{transform:"translate(0, 0)",children:e.jsx(ce,{orient:"top",config:le(z.top),values:$,scale:h.x,size:d.top,length:i})}),z.bottom&&e.jsx("g",{transform:`translate(0, ${l})`,children:e.jsx(ce,{orient:"bottom",config:le(z.bottom),values:$,scale:h.x,size:d.bottom,length:i})}),z.left&&e.jsx("g",{transform:"translate(0, 0)",children:e.jsx(ce,{orient:"left",config:le(z.left),values:L,scale:h.y,size:d.left,length:l})}),z.right&&e.jsx("g",{transform:`translate(${i}, 0)`,children:e.jsx(ce,{orient:"right",config:le(z.right),values:L,scale:h.y,size:d.right,length:l})})]}),R,K&&K.sourceId!==q&&(null==h?void 0:h.x)&&(()=>{const t=h.x(K.xValue);if(null==t||0>t||t>i)return null;const n=K.locked;return e.jsx("line",{x1:t,y1:0,x2:t,y2:l,stroke:n?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:n?1.5:1,strokeDasharray:n?"6,3":"4,4",pointerEvents:"none"})})(),H]}),k&&e.jsx("text",{x:c/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"},children:"string"==typeof k?k:null}),ae({legend:w,totalWidth:c,totalHeight:u,margin:d,legendPosition:C,title:k,legendHoverBehavior:A,legendClickBehavior:O,legendHighlightedCategory:S,legendIsolatedCategories:M})]}):null}function De(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}const Ne="undefined"==typeof window||"undefined"==typeof document,Te=f.createContext(null),We={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function _e(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=[],r={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},i=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],s=Object.keys(n).sort((e,t)=>{const n=i.indexOf(e),o=i.indexOf(t);return(-1===n?999:n)-(-1===o?999:o)});for(const e of s)o.push(`${n[e]} ${r[e]||e}`);return`${t}, ${o.join(", ")}`}const Fe=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},qe={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},He={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},Ge={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},Ve={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Ue={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},Ze={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},Ye={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function Xe({scene:t,chartType:n,tableId:o,chartTitle:r}){var i;const[s,a]=f.useState(!1),l=f.useContext(Te),c=null!==(i=null==l?void 0:l.visible)&&void 0!==i&&i,u=s||c,d=f.useRef(null),h=r?"Data summary for "+r:o?`Data summary for ${n} ${o}`:"Data summary for "+n,p=f.useCallback(()=>{s||c||a(!0)},[s,c]),g=f.useCallback(e=>{var t;c||(null===(t=d.current)||void 0===t?void 0:t.contains(e.relatedTarget))||a(!1)},[c]);if(!t||0===t.length)return o?e.jsx("span",{id:o,tabIndex:-1,style:We}):null;if(!u)return e.jsx("div",{id:o,tabIndex:-1,onFocus:p,style:We,role:"region","aria-label":h,children:e.jsxs("button",{type:"button",onClick:()=>a(!0),children:["View data summary (",t.length," elements)"]})});const y=function(e){var t,n,o,r,i,s,a,l,c,u,d,h,p,f,g,y,m,b,v,x,j,k,w,A,O;const S=[];if(!Array.isArray(e))return S;for(const M of e)if(M&&"object"==typeof M)try{switch(M.type){case"point":S.push({label:"Point",values:{x:M.x,y:M.y}});break;case"line":{const e=M.path,t=Array.isArray(M.datum)?M.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&S.push({label:"Line point",values:{x:t[0],y:t[1]}})}break}case"area":{const e=M.topPath,t=Array.isArray(M.datum)?M.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&S.push({label:"Area point",values:{x:t[0],y:t[1]}})}break}case"rect":{const e=null!=M.datum&&"object"==typeof M.datum?M.datum:{},i=null!==(n=null!==(t=e.category)&&void 0!==t?t:M.group)&&void 0!==n?n:"",s=null!==(r=null!==(o=e.value)&&void 0!==o?o:e.__aggregateValue)&&void 0!==r?r:e.total;S.push({label:"Bar",values:{category:i,value:null!=s?s:""}});break}case"heatcell":S.push({label:"Cell",values:{x:M.x,y:M.y,value:M.value}});break;case"wedge":S.push({label:"Wedge",values:{category:null!==(l=null!==(s=null===(i=M.datum)||void 0===i?void 0:i.category)&&void 0!==s?s:null===(a=M.datum)||void 0===a?void 0:a.label)&&void 0!==l?l:"",value:null!==(u=null===(c=M.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":S.push({label:"Node",values:{id:null!==(h=null===(d=M.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",x:null!==(p=M.cx)&&void 0!==p?p:M.x,y:null!==(f=M.cy)&&void 0!==f?f:M.y}});break;case"arc":S.push({label:"Arc",values:{id:null!==(y=null===(g=M.datum)||void 0===g?void 0:g.id)&&void 0!==y?y:"",x:null!==(m=M.cx)&&void 0!==m?m:M.x,y:null!==(b=M.cy)&&void 0!==b?b:M.y}});break;case"candlestick":S.push({label:"Candlestick",values:{x:M.x,open:M.open,high:M.high,low:M.low,close:M.close}});break;case"geoarea":S.push({label:"Region",values:{name:null!==(w=null!==(j=null===(x=null===(v=M.datum)||void 0===v?void 0:v.properties)||void 0===x?void 0:x.name)&&void 0!==j?j:null===(k=M.datum)||void 0===k?void 0:k.name)&&void 0!==w?w:"",value:null!==(O=null===(A=M.datum)||void 0===A?void 0:A.value)&&void 0!==O?O:""}})}}catch(e){}return S}(t),m=function(e){if(!e||0===e.length)return[];const t=new Set;for(const n of e)if(n&&n.values)for(const e of Object.keys(n.values))t.add(e);const n=[];for(const o of t){const t=[],r=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[o];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&r.add(e+""))}if(t.length>0){let e=t[0],r=t[0],i=0;for(const n of t)e>n&&(e=n),n>r&&(r=n),i+=n;n.push({name:o,count:t.length,numeric:!0,min:e,max:r,mean:i/t.length})}else if(r.size>0){const e=Array.from(r);n.push({name:o,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(y),b=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${Fe(e.min)} to ${Fe(e.max)}, mean ${Fe(e.mean)}.`);else{const t=e.uniqueValues,o=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${o}.`)}return n.join(" ")}(y.length,m),v=y.slice(0,5),x=new Set;for(const e of v)for(const t of Object.keys(e.values))x.add(t);const j=Array.from(x);return e.jsxs("div",{ref:d,id:o,tabIndex:-1,onBlur:g,style:qe,role:"region","aria-label":h,children:[e.jsx("button",{type:"button",onClick:()=>{c&&l&&l.setVisible(!1),a(!1)},"aria-label":"Close data summary",style:Ge,children:"×"}),e.jsx("div",{role:"note",style:He,children:b}),e.jsxs("table",{role:"table","aria-label":"Sample data for "+n,style:Ve,children:[e.jsxs("caption",{style:Ye,children:["First ",v.length," of ",y.length," data points"]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:Ue,children:"type"}),j.map(t=>e.jsx("th",{style:Ue,children:t},t))]})}),e.jsx("tbody",{children:v.map((t,n)=>e.jsxs("tr",{children:[e.jsx("td",{style:Ze,children:t.label}),j.map(n=>{return e.jsx("td",{style:Ze,children:(o=t.values[n],null==o||""===o?"—":"number"==typeof o?Number.isNaN(o)?"—":Fe(o):"boolean"==typeof o?o?"true":"false":"object"==typeof o?"—":o+"")},n);var o})]},n))})]})]})}function Qe({summary:t}){return t?e.jsx("div",{role:"note",style:We,children:t}):null}function Ke({tableId:t}){return e.jsx("a",{href:"#"+t,style:We,onClick:e=>{e.preventDefault();const n=document.getElementById(t);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,We)},children:"Skip to data table"})}function Je({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.jsx("div",{"aria-live":"polite","aria-atomic":"true",style:We,children:n})}const et="var(--semiotic-focus, #005fcc)";function tt({active:t,hoverPoint:n,margin:o,size:r,shape:i="circle",width:s,height:a}){if(!t||!n)return null;const l=n.x+o.left,c=n.y+o.top;let u;if("rect"===i&&null!=s&&null!=a){const t=Math.max(s,4),n=Math.max(a,4);u=e.jsx("rect",{x:l-t/2-3,y:c-n/2-3,width:t+6,height:n+6,rx:3,fill:"none",stroke:et,strokeWidth:2,strokeDasharray:"4,2"})}else u=e.jsx("circle","wedge"===i?{cx:l,cy:c,r:12,fill:"none",stroke:et,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:et,strokeWidth:2,strokeDasharray:"4,2"});return e.jsx("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}function nt({x:t,y:n,containerWidth:o,containerHeight:r,margin:i,children:s,className:a="stream-frame-tooltip",zIndex:l=1}){const c=f.useRef(null),[u,d]=f.useState(null);f.useLayoutEffect(()=>{const e=c.current;if(!e)return;const t=e.getBoundingClientRect();d(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[s,a,o,r]);let h;return h=u?`translate(${u.width+12>o-t?"calc(-100% - 12px)":"12px"}, ${u.height+12>r-n?"calc(-100% - 4px)":"4px"})`:`translate(${t>.7*o?"calc(-100% - 12px)":"12px"}, ${.3*r>n?"4px":"calc(-100% - 4px)"})`,e.jsx("div",{ref:c,className:a,style:{position:"absolute",left:i.left+t,top:i.top+n,transform:h,pointerEvents:"none",zIndex:l,width:"max-content"},children:s})}function ot(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function rt(e,t,n=.6){var o,r,i,s,a;if(!ot(t))return;const l=null!==(o=t._pulseGlowRadius)&&void 0!==o?o:4,c=t.r+l*t._pulseIntensity,u=null!==(i=null!==(r=t.cx)&&void 0!==r?r:t.x)&&void 0!==i?i:0,d=null!==(a=null!==(s=t.cy)&&void 0!==s?s: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 it(e,t,n,o=.35){ot(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}function st(e){switch(e){case"monotoneX":return a.curveMonotoneX;case"monotoneY":return a.curveMonotoneY;case"cardinal":return a.curveCardinal;case"catmullRom":return a.curveCatmullRom;case"step":return a.curveStep;case"stepBefore":return a.curveStepBefore;case"stepAfter":return a.curveStepAfter;case"basis":return a.curveBasis;case"natural":return a.curveNatural;default:return null}}function at(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 lt(e,t,n,o,r,i){if(2>t.length)return;const s=[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];s.push(s[e-1]+Math.sqrt(n*n+o*o))}const a=s[s.length-1];if(0===a)return;const l=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=o,e.lineCap=i;for(let n=0;t.length-1>n;n++){const o=(s[n]+s[n+1])/2;let i=r;l>o&&(i*=o/l),l>a-o&&(i*=(a-o)/l),e.globalAlpha=Math.max(0,i),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}function ct(e){return e.k}function ut(e){return[e.x,e.y]}function dt(e){return function(){return e}}function ht([e,t,n]){const o=1<<n;return[e-Math.floor(e/o)*o,t-Math.floor(t/o)*o,n]}function pt(e,t,n,o){const r=e.getContext("2d");if(!r)return null;const i=t[0]*o,s=t[1]*o,a=t[0]+"px",l=t[1]+"px";return e.style.width!==a&&(e.style.width=a),e.style.height!==l&&(e.style.height=l),e.width===i&&e.height===s||(e.width=i,e.height=s),r.setTransform(o,0,0,o,0,0),r.translate(n.left,n.top),r}function ft(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function gt(e,t,n,o,r){return"function"==typeof e?e(t,n,o,r):e.replace("{z}",t+"").replace("{x}",n+"").replace("{y}",o+"").replace("{r}",r>1?"@2x":"")}class yt{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 mt{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 r=0;this.capacity>r;r++){const i=this.particles[r];if(!i.active)continue;const s=n[i.lineIndex];if(!s||2>s.length){i.active=!1;continue}if(i.t+=e*t,i.t>=1){i.active=!1;continue}const a=bt(s),l=vt(s,i.t*a),c=(o[i.lineIndex]||2)/2;i.x=l.x+l.nx*i.offset*c*2,i.y=l.y+l.ny*i.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 bt(e){let t=0;for(let n=1;e.length>n;n++){const o=e[n][0]-e[n-1][0],r=e[n][1]-e[n-1][1];t+=Math.sqrt(o*o+r*r)}return t}function vt(e,t){let n=0;for(let o=1;e.length>o;o++){const r=e[o][0]-e[o-1][0],i=e[o][1]-e[o-1][1],s=Math.sqrt(r*r+i*i);if(n+s>=t||o===e.length-1){const a=s>0?(t-n)/s:0,l=s>.001?s:1;return{x:e[o-1][0]+r*a,y:e[o-1][1]+i*a,nx:-i/l,ny:r/l}}n+=s}const o=e[e.length-1];return{x:o[0],y:o[1],nx:0,ny:0}}const xt={top:10,right:10,bottom:10,left:10},jt={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"},kt={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 wt({data:t}){if(!t)return null;if(t.properties)return e.jsx("div",{className:"semiotic-tooltip",style:jt,children:e.jsx("div",{style:{fontWeight:600},children:t.properties.name||t.properties.NAME||t.properties.id||"Feature"})});const n=Object.entries(t).slice(0,3);return e.jsx("div",{className:"semiotic-tooltip",style:jt,children:n.map(([t,n])=>e.jsxs("div",{children:[e.jsxs("span",{style:{opacity:.7},children:[t,": "]}),e.jsx("span",{style:{fontWeight:600},children:n+""})]},t))})}const At=t.forwardRef(function(n,o){var r,i,s,l,d,h,p,f,g,y;const{projection:m,projectionExtent:b,fitPadding:v,projectionTransform:x,areas:j,points:k,lines:w,xAccessor:A,yAccessor:O,lineDataAccessor:S,pointIdAccessor:C,lineType:R="geo",flowStyle:P="basic",graticule:$,zoomable:L,zoomExtent:E,onZoom:I,dragRotate:D,showParticles:N,particleStyle:T,tileURL:W,tileAttribution:_,tileCacheSize:F,size:q,width:H,height:G,responsiveWidth:V,responsiveHeight:U,margin:Z,className:Y,background:Q,areaStyle:J,pointStyle:ee,lineStyle:te,colorScheme:ne,enableHover:oe=!0,hoverAnnotation:re,tooltipContent:ie,customClickBehavior:se,customHoverBehavior:ae,annotations:le,decay:ce,pulse:ue,transition:de,animate:he,staleness:pe,backgroundGraphics:fe,foregroundGraphics:ge,title:ye,legend:me,legendPosition:be,legendHoverBehavior:ve,legendClickBehavior:xe,legendHighlightedCategory:je,legendIsolatedCategories:ke,showAxes:we,accessibleTable:Ae=!0,description:Oe,summary:Se}=n,Me=q||[H||600,G||400],Ce=t.useRef(!0),Re=K({sizeProp:Me,responsiveWidth:V,responsiveHeight:U,userMargin:Z,marginDefault:xt,foregroundGraphics:ge,backgroundGraphics:fe,animate:he,transitionProp:de,themeDirtyRef:Ce}),{reducedMotionRef:Pe,responsiveRef:ze,size:$e,margin:Le,adjustedWidth:Ee,adjustedHeight:Be,resolvedForeground:Te,resolvedBackground:We,transition:Fe,introEnabled:qe,tableId:He,rafRef:Ge,renderFnRef:Ve,scheduleRender:Ue,currentTheme:Ze}=Re,Ye=t.useMemo(()=>null!=D?D:"orthographic"===("string"==typeof m?m:"object"==typeof m&&"type"in m?m.type:null),[D,m]),et=t.useMemo(()=>{var e,t;return{projection:m,projectionExtent:b,fitPadding:v,xAccessor:A,yAccessor:O,lineDataAccessor:S,lineType:R,flowStyle:P,areaStyle:J,pointStyle:ee,lineStyle:te,colorScheme:ne,themeSemantic:B(Ze),themeSequential:null===(e=null==Ze?void 0:Ze.colors)||void 0===e?void 0:e.sequential,themeDiverging:null===(t=null==Ze?void 0:Ze.colors)||void 0===t?void 0:t.diverging,graticule:$,projectionTransform:x,decay:ce,pulse:ue,transition:Fe,introAnimation:qe,annotations:le,pointIdAccessor:C}},[m,b,v,A,O,S,R,P,J,ee,te,ne,$,x,ce,ue,null==Fe?void 0:Fe.duration,null==Fe?void 0:Fe.easing,qe,le,C,Ze]),ot=t.useRef(null);ot.current||(ot.current=new M(et));const bt=t.useRef(null),vt=t.useRef(null),jt=t.useRef(null),At=t.useRef(null),Ot=t.useRef(null);W&&!Ot.current&&(Ot.current=new yt(F||256));const St=t.useRef(le),Mt=t.useRef(null),Ct=t.useRef(c.zoomIdentity),Rt=t.useRef(!1),Pt=t.useRef(null),zt=t.useRef(null),$t=t.useRef(null),Lt=t.useRef(null),Et=t.useRef(0);if(N&&!Lt.current){const e=null!==(r=null==T?void 0:T.maxPerLine)&&void 0!==r?r:30;Lt.current=new mt(50*e)}const Bt=t.useRef(null),It=t.useRef(null),[Dt,Nt]=t.useState(null),[Tt,Wt]=t.useState(0),[_t,Ft]=t.useState(!1);t.useEffect(()=>{var e;null===(e=ot.current)||void 0===e||e.updateConfig(et),Ce.current=!0,Ue()},[et,Ue]),t.useEffect(()=>{const e=ot.current;e&&(j&&e.setAreas(j),k&&e.setPoints(k),w&&e.setLines(w),Ce.current=!0,Ue())},[j,k,w,Ue]);const qt=t.useCallback(e=>{var t;null===(t=ot.current)||void 0===t||t.pushPoint(e),Ce.current=!0,Ue()},[Ue]),Ht=t.useCallback(e=>{var t;null===(t=ot.current)||void 0===t||t.pushMany(e),Ce.current=!0,Ue()},[Ue]),Gt=t.useCallback(()=>{var e;null===(e=ot.current)||void 0===e||e.clear(),Ce.current=!0,Ue()},[Ue]);t.useImperativeHandle(o,()=>({push:qt,pushMany:Ht,removePoint:e=>{var t,n;const o=null!==(n=null===(t=ot.current)||void 0===t?void 0:t.removePoint(e))&&void 0!==n?n:[];return o.length>0&&(Ce.current=!0,Ue()),o},clear:Gt,getProjection:()=>{var e,t,n;return null!==(n=null===(t=null===(e=ot.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=ot.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=ot.current)||void 0===e?void 0:e.cartogramLayout)&&void 0!==t?t:null},getZoom:()=>Ct.current.k,resetZoom:()=>{const e=Pt.current;e&&Mt.current&&u.select(e).call(Mt.current.transform,c.zoomIdentity)},getData:()=>{var e,t;return null!==(t=null===(e=ot.current)||void 0===e?void 0:e.getPoints())&&void 0!==t?t:[]}}),[qt,Ht,Gt,Ue]);const{hoverHandlerRef:Vt,onPointerMove:Ut,onPointerLeave:Zt}=Re;t.useEffect(()=>{Vt.current=e=>{if(!oe)return;const t=ot.current;if(!t||!t.scene.length)return;const n=vt.current;if(!n)return;const o=n.getBoundingClientRect(),r=e.clientX-o.left-Le.left,i=e.clientY-o.top-Le.top;if(0>r||r>Ee||0>i||i>Be)return Bt.current=null,It.current=null,Nt(null),null==ae||ae(null),void Ue();At.current||(At.current="undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"));const s=At.current.getContext("2d");if(!s)return;const a=z(t.scene,r,i,30,s,t.quadtree,t.maxPointRadius);if(a){const e=a.node,t=e.datum,n=(null==t?void 0:t.properties)?t:(null==t?void 0:t.data)||t;let o,s;"point"===e.type?(o=e.x,s=e.y):"geoarea"===e.type?(o=e.centroid[0],s=e.centroid[1]):(o=r,s=i);const l=Object.assign(Object.assign(Object.assign({},n),(null==n?void 0:n.properties)||{}),{data:n,properties:null==n?void 0:n.properties,x:o,y:s,time:o,value:s});Bt.current=l,It.current=e,Nt(l),null==ae||ae(l),Ue()}else Bt.current&&(Bt.current=null,It.current=null,Nt(null),null==ae||ae(null),Ue())}},[oe,Ee,Be,Le,ae,Ue]),Re.hoverLeaveRef.current=()=>{Bt.current=null,It.current=null,Nt(null),null==ae||ae(null),Ue()};const Yt=t.useCallback(e=>{if(!se)return;const t=ot.current;if(!t||!t.scene.length)return;const n=e.currentTarget.getBoundingClientRect(),o=e.clientX-n.left-Le.left,r=e.clientY-n.top-Le.top;At.current||(At.current="undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"));const i=At.current.getContext("2d");if(!i)return;const s=z(t.scene,o,r,30,i,t.quadtree,t.maxPointRadius);if(s){const e=s.node.datum,t=(null==e?void 0:e.properties)?e:(null==e?void 0:e.data)||e,n=(null==t?void 0:t.properties)?Object.assign(Object.assign({},t),t.properties):t;se(Object.assign(Object.assign({},n),{data:t,properties:null==t?void 0:t.properties,x:o,y:r,time:o,value:r}))}},[se,Le]),Xt=t.useRef(-1),Qt=t.useRef(null),Kt=t.useCallback(e=>{const t=ot.current;if(!t||0===t.scene.length)return;const n=function(e){const t=[];for(const n of e)"point"===n.type&&null!=n.x?t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle"}):"geoarea"===n.type&&n.centroid&&t.push({x:n.centroid[0],y:n.centroid[1],datum:n.datum,shape:"circle"});return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.scene);if(0===n.length)return;const o=Xt.current,r=function(e,t,n){switch(e){case"ArrowRight":case"ArrowDown":return n-1>t?t+1:t;case"ArrowLeft":case"ArrowUp":return t>0?t-1:t;case"PageDown":return Math.min(t+Math.max(1,Math.floor(.1*n)),n-1);case"PageUp":return Math.max(t-Math.max(1,Math.floor(.1*n)),0);case"Home":return 0;case"End":return n-1;case"Escape":return-1;default:return null}}(e.key,0>o?-1:o,n.length);if(null===r)return;if(e.preventDefault(),0>r)return Xt.current=-1,Qt.current=null,Bt.current=null,It.current=null,Nt(null),null==ae||ae(null),void Ue();const i=0>o?0:r;Xt.current=i;const s=n[i];Qt.current={shape:s.shape,w:s.w,h:s.h};const a=s.datum;let l=a;a&&"object"==typeof a&&"geometry"in a&&a.properties&&"object"==typeof a.properties&&(l=Object.assign(Object.assign({},a),a.properties));const c=Object.assign(Object.assign({},l),{data:a,properties:null==a?void 0:a.properties,x:s.x,y:s.y,time:s.x,value:s.y});Bt.current=c,Nt(c),null==ae||ae(c),Ue()},[ae,Ue]),Jt=t.useCallback(e=>{Xt.current=-1,Qt.current=null,Ut(e)},[Ut]);Ve.current=()=>{var e,t,n,o,r,i,s;Ge.current=0;const l=vt.current,c=ot.current;if(!l||!c)return;const u=performance.now();let d=!1;const h=$t.current;h&&($t.current=null,c.applyRotation(h,{width:Ee,height:Be}));const p=c.advanceTransition(Pe.current?u+1e6:u),f=!Pe.current&&p;if(Ce.current&&!p){const e={width:Ee,height:Be},t=Ye?c.getRotation():null;c.computeScene(e);const n=Ct.current,o=1!==n.k||0!==n.x||0!==n.y;Ye&&t?o?(c.setRotation(t),c.applyZoomScale(n.k,e)):c.applyRotation(t,e):o&&c.applyZoomTransform(n,e),Ce.current=!1,l.setAttribute("aria-label",_e(c.scene,"Geographic chart"))}const g=ft();if(W&&Ot.current){const t=bt.current;if(t&&(null===(e=c.scales)||void 0===e?void 0:e.projection)){const e=pt(t,$e,Le,g);if(e){e.clearRect(-Le.left,-Le.top,$e[0],$e[1]),e.save(),e.beginPath(),e.rect(0,0,Ee,Be),e.clip();const t=function(e,t){const{tileURL:n,projection:o,width:r,height:i,tileCache:s,onTileLoad:a}=t,l=o.scale(),c=o.translate(),u=2*l*Math.PI,d=function(){let e=0,t=0,n=960,o=500,r=!0,i=!0,s=256,a=ct,l=ut,c=0;function u(){const u=+a.apply(this,arguments),d=l.apply(this,arguments),h=Math.log2(u/s),p=Math.round(Math.max(h+c,0)),f=Math.pow(2,h-p)*s,g=+d[0]-u/2,y=+d[1]-u/2,m=Math.max(r?0:-1/0,Math.floor((e-g)/f)),b=Math.min(r?1<<p:1/0,Math.ceil((n-g)/f)),v=Math.max(i?0:-1/0,Math.floor((t-y)/f)),x=Math.min(i?1<<p:1/0,Math.ceil((o-y)/f)),j=[];for(let e=v;x>e;++e)for(let t=m;b>t;++t)j.push([t,e,p]);return j.translate=[g/f,y/f],j.scale=f,j}return u.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],u):[n-e,o-t]},u.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],u):[[e,t],[n,o]]},u.scale=function(e){return arguments.length?(a="function"==typeof e?e:dt(+e),u):a},u.translate=function(e){return arguments.length?(l="function"==typeof e?e:dt([+e[0],+e[1]]),u):l},u.zoomDelta=function(e){return arguments.length?(c=+e,u):c},u.tileSize=function(e){return arguments.length?(s=+e,u):s},u.clamp=function(e){return arguments.length?(r=i=!!e,u):r&&i},u.clampX=function(e){return arguments.length?(r=!!e,u):r},u.clampY=function(e){return arguments.length?(i=!!e,u):i},u}().size([r,i]).scale(u).translate(c).clamp(!0)(),h=ft();let p=!0;for(const t of d){const[o,r,i]=ht(t),l=`${i}/${o}/${r}`;let c=s.get(l);if(!c){const e=new Image;e.crossOrigin="anonymous";const t={img:e,loaded:!1,key:l,lastUsed:performance.now()};s.set(l,t),e.onload=()=>{t.loaded=!0,null==a||a()},e.onerror=()=>{t.loaded=!0},e.src=gt(n,i,o,r,h),c=t}if(!c.loaded){p=!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 p}(e,{tileURL:W,projection:c.scales.projection,width:Ee,height:Be,tileCache:Ot.current,onTileLoad:()=>Ue()});e.restore(),t||(d=!0)}}}const y=pt(l,$e,Le,g);if(!y)return;y.clearRect(-Le.left,-Le.top,$e[0],$e[1]),Q&&!W&&(y.fillStyle=Q,y.fillRect(0,0,Ee,Be)),y.save(),y.beginPath(),y.rect(0,0,Ee,Be),y.clip();const m=c.scene,b={width:Ee,height:Be};if(function(e,t){var n,o,r;const i=t.filter(e=>"geoarea"===e.type);for(const t of i){if(!t.pathData)continue;const i=new Path2D(t.pathData),s=t.style.fill||"#e0e0e0";if("none"!==s&&(e.fillStyle=s,e.globalAlpha=(null!==(n=t._decayOpacity)&&void 0!==n?n:1)*(null!==(o=t.style.fillOpacity)&&void 0!==o?o:1),e.fill(i)),t.style.stroke&&"none"!==t.style.stroke){if(e.strokeStyle=X(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||.5,e.globalAlpha=null!==(r=t._decayOpacity)&&void 0!==r?r:1,t.style.strokeDasharray){const n=t.style.strokeDasharray.split(",").map(Number);e.setLineDash(n)}else e.setLineDash([]);e.stroke(i)}it(e,t,i),e.globalAlpha=1,e.setLineDash([])}}(y,m),((e,t,n,o)=>{var r,i;const s=t.filter(e=>"line"===e.type);for(const l of s){if(2>l.path.length)continue;const c=l._introClipFraction;void 0!==c&&1>c&&(e.save(),e.beginPath(),e.rect(0,0,o.width*c,o.height),e.clip());const u=l.style.stroke||"#007bff",d=X(e,u)||u,h=l.style.strokeWidth||2,p=l.colorThresholds,f=l.rawValues;if(e.setLineDash(l.style.strokeDasharray?l.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=l.style.opacity&&(e.globalAlpha=l.style.opacity),e.lineWidth=h,e.lineCap=l.style.strokeLinecap||"butt",l.style._edgeFade){const b=null!==(r=l.style.opacity)&&void 0!==r?r:1;lt(e,l.path,d,h,b,l.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const g=st(l.curve),y=p&&p.length>0&&f&&f.length===l.path.length,m=l._decayOpacities;if(m&&m.length===l.path.length&&!y){e.strokeStyle=d;const v=null!==(i=l.style.opacity)&&void 0!==i?i:1;for(let x=0;l.path.length-1>x;x++)e.globalAlpha=.5*(m[x]+m[x+1])*v,e.beginPath(),e.moveTo(l.path[x][0],l.path[x][1]),e.lineTo(l.path[x+1][0],l.path[x+1][1]),e.stroke()}else if(y){let j=null,k=null,w=null,A=null,O=!1;function S(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),O=!0}function M(){O&&(e.stroke(),O=!1)}for(let C=0;l.path.length>C;C++){const[R,P]=l.path[C],z=f[C],$=at(z,p,d);if(null!==j&&null!==A&&null!==w){if($===A)e.lineTo(R,P);else{const L=[];for(const E of p){const B=E.value;(w>B||B>z)&&(B>w||z>B)||w===B||z===B||L.push({t:(B-w)/(z-w)})}L.sort((e,t)=>e.t-t.t);for(const I of L){const D=j+(R-j)*I.t,N=k+(P-k)*I.t,T=at(w+(z-w)*Math.min(I.t+1e-4,1),p,d);e.lineTo(D,N),M(),S(T,D,N)}e.lineTo(R,P)}j=R,k=P,w=z,A=$}else S($,R,P),j=R,k=P,w=z,A=$}M()}else{if(e.beginPath(),!l.strokeGradient||2>l.strokeGradient.colorStops.length||2>l.path.length)e.strokeStyle=d;else{const W=e.createLinearGradient(l.path[0][0],0,l.path[l.path.length-1][0],0);for(const _ of l.strokeGradient.colorStops)W.addColorStop(Math.max(0,Math.min(1,_.offset)),_.color);e.strokeStyle=W}if(g)a.line().x(e=>e[0]).y(e=>e[1]).curve(g).context(e)(l.path);else{const[F,q]=l.path[0];e.moveTo(F,q);for(let H=1;l.path.length>H;H++)e.lineTo(l.path[H][0],l.path[H][1])}e.stroke()}if(l.style.fill&&l.style.fillOpacity&&l.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=l.style.fillOpacity,e.fillStyle=("string"==typeof l.style.fill?X(e,l.style.fill):l.style.fill)||l.style.fill,g&&!y)a.line().x(e=>e[0]).y(e=>e[1]).curve(g).context(e)(l.path);else{const[V,U]=l.path[0];e.moveTo(V,U);for(let Z=1;l.path.length>Z;Z++)e.lineTo(l.path[Z][0],l.path[Z][1])}const G=l.path[0][0];e.lineTo(l.path[l.path.length-1][0],o.height),e.lineTo(G,o.height),e.closePath(),e.fill()}void 0!==c&&1>c&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}})(y,m,0,b),((e,t)=>{var n;const o=t.filter(e=>"point"===e.type);if(0!==o.length){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=("string"==typeof t.style.fill?X(e,t.style.fill):t.style.fill)||"#4e79a7",e.fill(),t.style.stroke&&(e.strokeStyle=("string"==typeof t.style.stroke?X(e,t.style.stroke):t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),rt(e,t),e.globalAlpha=1}}finally{e.restore()}}})(y,m),N&&Lt.current){const e=Lt.current,s=m.filter(e=>"line"===e.type);if(s.length>0){const a=T||{},l=.3*(null!==(t=a.speedMultiplier)&&void 0!==t?t:1),c=null!==(n=a.maxPerLine)&&void 0!==n?n:30,h=null!==(o=a.spawnRate)&&void 0!==o?o:.15,p=null!==(r=a.radius)&&void 0!==r?r:2,f=null!==(i=a.opacity)&&void 0!==i?i:.7,g=u/1e3,m=Et.current>0?Math.min(g-Et.current,.1):.016;Et.current=g;const b=s.map(e=>e.path),v=s.map(e=>e.style.strokeWidth||2);for(let t=0;s.length>t;t++)Math.random()<h&&e.countForLine(t)<c&&e.spawn(t);e.step(m,l,b,v),y.globalAlpha=f;for(let t=0;e.particles.length>t;t++){const n=e.particles[t];if(!n.active)continue;const o=s[n.lineIndex],r="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";y.beginPath(),y.arc(n.x,n.y,p,0,2*Math.PI),y.fillStyle=r,y.fill()}y.globalAlpha=1,d=!0}}y.restore();const v=jt.current;if(v){const e=pt(v,$e,Le,g);if(e){e.clearRect(-Le.left,-Le.top,$e[0],$e[1]);const t=It.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,o="object"==typeof re?re:void 0,r=(null==o?void 0:o.pointColor)||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const n="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||n||null:n||t.stroke||null}(t);e.beginPath(),e.arc(n.x,n.y,n.r+3,0,2*Math.PI),r?(e.save(),e.globalAlpha=.4,e.fillStyle=r,e.fill(),e.restore()):(e.fillStyle="rgba(255, 255, 255, 0.4)",e.fill()),e.strokeStyle=r||"rgba(0, 0, 0, 0.5)",e.lineWidth=2,e.stroke()}}}if(pe){const e=performance.now()-c.lastIngestTime>(null!==(s=pe.threshold)&&void 0!==s?s:5e3);e!==_t&&Ft(e)}const x=le!==St.current;x&&(St.current=le),(Ce.current||x)&&Wt(e=>e+1),(f||null!=c.activeTransition||c.hasActivePulses||d)&&(Ge.current=requestAnimationFrame(()=>Ve.current()))},t.useEffect(()=>(Ue(),()=>{var e;null===(e=Ot.current)||void 0===e||e.clear()}),[Ue]),t.useEffect(()=>{Ce.current=!0,Ue()},[Ee,Be,Q,Ue]),function(e,n,o,r,i,s){t.useEffect(()=>{if(!e)return;const t=setInterval(()=>{var t;const a=n.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(t=e.threshold)&&void 0!==t?t:5e3,u=l-a.lastIngestTime>c;u!==i&&(s(u),o.current=!0,r())},1e3);return()=>clearInterval(t)},[e,i,r])}(pe,ot,Ce,Ue,_t,Ft),t.useEffect(()=>{if("production"!==process.env.NODE_ENV&&W){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.`)}},[W,m]),t.useEffect(()=>{const e=Pt.current;if(!L||!e)return Mt.current&&e&&(u.select(e).on(".zoom",null),Mt.current=null),void(e&&u.select(e).on("mousedown.rotate",null).on("touchstart.rotate",null));const[t,n]=E||[1,8],o={width:Ee,height:Be};if(Ye){let r=Ct.current.k;const i=e=>{var i;r=Math.max(t,Math.min(n,e)),Ct.current=c.zoomIdentity.scale(r);const s=ot.current;s&&(s.applyZoomScale(r,o),Ce.current=!1,Ue(),(null===(i=s.scales)||void 0===i?void 0:i.projection)&&(null==I||I({projection:s.scales.projection,zoom:s.currentZoom})))};Mt.current={scaleBy:(e,t)=>i(r*t),transform:(e,t)=>{var n;return i(null!==(n=null==t?void 0:t.k)&&void 0!==n?n:1)}};const s=e=>{e.preventDefault(),i(r*(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(),i(1.5*r))};e.addEventListener("wheel",s,{passive:!1}),e.addEventListener("dblclick",a);const l=.4,u=t=>{if(0!==t.button)return;const n=t.target;if(n.closest("button")||n.closest(".stream-geo-zoom-controls"))return;const o=ot.current;if(!o)return;const r=o.getRotation();zt.current={x:t.clientX,y:t.clientY,rotation:[...r]},e.setPointerCapture(t.pointerId),t.preventDefault()},d=e=>{const t=zt.current;t&&($t.current=[t.rotation[0]+(e.clientX-t.x)*l,Math.max(-90,Math.min(90,t.rotation[1]-(e.clientY-t.y)*l)),t.rotation[2]],Ue())},h=t=>{var n;if(!zt.current)return;zt.current=null,e.releasePointerCapture(t.pointerId);const r=$t.current;if(r){$t.current=null;const e=ot.current;e&&(e.applyRotation(r,o),Ue())}const i=ot.current;(null===(n=null==i?void 0:i.scales)||void 0===n?void 0:n.projection)&&(null==I||I({projection:i.scales.projection,zoom:i.currentZoom}))};return e.addEventListener("pointerdown",u),e.addEventListener("pointermove",d),e.addEventListener("pointerup",h),e.addEventListener("pointercancel",h),()=>{e.removeEventListener("wheel",s),e.removeEventListener("dblclick",a),e.removeEventListener("pointerdown",u),e.removeEventListener("pointermove",d),e.removeEventListener("pointerup",h),e.removeEventListener("pointercancel",h),Mt.current=null}}const r=c.zoom().scaleExtent([t,n]).extent([[0,0],[$e[0],$e[1]]]).translateExtent([[-1/0,-1/0],[1/0,1/0]]).on("zoom",e=>{const t=e.transform;Ct.current=t,Rt.current=!0;const n=ot.current;n&&(n.applyZoomTransform(t,o),Ce.current=!1,Ue())}).on("end",e=>{var t;Ct.current=e.transform,Rt.current=!1;const n=ot.current;(null===(t=null==n?void 0:n.scales)||void 0===t?void 0:t.projection)&&(null==I||I({projection:n.scales.projection,zoom:n.currentZoom}))});return Mt.current=r,u.select(e).call(r),()=>{u.select(e).on(".zoom",null)}},[L,E,Ye,$e,Ee,Be,Le,I,Ue]);const en=oe&&!1!==re,tn=en&&Dt?ie?ie(Dt):e.jsx(wt,{data:Dt}):null,nn=tn?e.jsx(nt,{x:Dt.x,y:Dt.y,containerWidth:Ee,containerHeight:Be,margin:Le,className:"stream-frame-tooltip",zIndex:10,children:tn}):null;if(Ne){const t=ot.current;t&&(j||k||w)&&(j&&t.setAreas(j),k&&t.setPoints(k),w&&t.setLines(w),t.computeScene({width:Ee,height:Be}));const n=null!==(i=null==t?void 0:t.scene)&&void 0!==i?i:[];return e.jsxs("div",{className:"stream-geo-frame"+(Y?" "+Y:""),role:"img","aria-label":Oe||("string"==typeof ye?ye:"Geographic chart"),style:{position:"relative",width:$e[0],height:$e[1]},children:[e.jsx(Qe,{summary:Se}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:$e[0],height:$e[1],style:{position:"absolute",left:0,top:0},children:[e.jsx("g",{transform:`translate(${Le.left},${Le.top})`,children:We}),e.jsxs("g",{transform:`translate(${Le.left},${Le.top})`,children:[Q&&e.jsx("rect",{x:0,y:0,width:Ee,height:Be,fill:Q}),n.map((t,n)=>function(t,n){var o,r,i,s,a,l;switch(t.type){case"geoarea":{const i=t;return i.pathData?e.jsx("path",{d:i.pathData,fill:De(i.style.fill,"#e0e0e0"),fillOpacity:null!==(o=i.style.fillOpacity)&&void 0!==o?o:1,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth||.5,strokeDasharray:i.style.strokeDasharray,opacity:null!==(r=i._decayOpacity)&&void 0!==r?r:1},"geoarea-"+n):null}case"point":{const o=t;return e.jsx("circle",{cx:o.x,cy:o.y,r:o.r,fill:De(o.style.fill),fillOpacity:null!==(i=o.style.fillOpacity)&&void 0!==i?i:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:null!==(s=o._decayOpacity)&&void 0!==s?s:null!==(a=o.style.opacity)&&void 0!==a?a:1},"point-"+n)}case"line":{const o=t;if(2>o.path.length)return null;const r="M"+o.path.map(e=>`${e[0]},${e[1]}`).join("L");return e.jsx("path",{d:r,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||1.5,strokeDasharray:o.style.strokeDasharray,opacity:null!==(l=o.style.opacity)&&void 0!==l?l:1},"line-"+n)}default:return null}}(t,n))]})]}),e.jsx(Ie,{width:Ee,height:Be,totalWidth:$e[0],totalHeight:$e[1],margin:Le,scales:null,showAxes:!1,title:ye,legend:me,legendPosition:be,legendHoverBehavior:ve,legendClickBehavior:xe,legendHighlightedCategory:je,legendIsolatedCategories:ke,foregroundGraphics:Te,annotations:le,annotationFrame:0,xValues:[],yValues:[],pointNodes:n.filter(e=>"point"===e.type)})]})}const on=t.useCallback(e=>{Pt.current=e,ze&&"object"==typeof ze&&(ze.current=e)},[ze]);return e.jsxs("div",{ref:on,className:"stream-geo-frame"+(Y?" "+Y:""),role:"group","aria-label":Oe||("string"==typeof ye?ye:"Geographic chart"),tabIndex:0,style:Object.assign({position:"relative",width:V?"100%":$e[0],height:U?"100%":$e[1],overflow:"hidden"},L?{touchAction:"none"}:{}),onKeyDown:Kt,children:[Ae&&e.jsx(Ke,{tableId:He}),Ae&&e.jsx(Xe,{scene:null!==(l=null===(s=ot.current)||void 0===s?void 0:s.scene)&&void 0!==l?l:[],chartType:"Geographic chart",tableId:He,chartTitle:"string"==typeof ye?ye:void 0}),e.jsx(Qe,{summary:Se}),e.jsxs("div",{role:"img","aria-label":Oe||("string"==typeof ye?ye:"Geographic chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:en?Jt:void 0,onMouseLeave:en?Zt:void 0,onClick:se?Yt:void 0,children:[We&&e.jsx("svg",{style:{position:"absolute",left:0,top:0,width:$e[0],height:$e[1],pointerEvents:"none"},children:e.jsx("g",{transform:`translate(${Le.left},${Le.top})`,children:We})}),W&&e.jsx("canvas",{ref:bt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),e.jsx("canvas",{ref:vt,"aria-label":_e(null!==(h=null===(d=ot.current)||void 0===d?void 0:d.scene)&&void 0!==h?h:[],"Geographic chart"),style:{position:"absolute",left:0,top:0}}),e.jsx("canvas",{ref:jt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),e.jsx(Je,{hoverPoint:Dt}),e.jsx(Ie,{width:Ee,height:Be,totalWidth:$e[0],totalHeight:$e[1],margin:Le,scales:null,showAxes:null!=we&&we,title:ye,legend:me,legendPosition:be,legendHoverBehavior:ve,legendClickBehavior:xe,legendHighlightedCategory:je,legendIsolatedCategories:ke,foregroundGraphics:Te,annotations:le,annotationFrame:Tt,xValues:[],yValues:[],pointNodes:null===(p=ot.current)||void 0===p?void 0:p.scene.filter(e=>"point"===e.type)}),(null==pe?void 0:pe.showBadge)&&e.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===pe.badgePosition?{top:4,left:4}:"bottom-left"===pe.badgePosition?{bottom:4,left:4}:"bottom-right"===pe.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:_t?"#dc3545":"#28a745",color:"white"}),children:_t?"STALE":"LIVE"}),L&&e.jsxs("div",{className:"stream-geo-zoom-controls",style:{position:"absolute",bottom:Le.bottom+8,left:Le.left+8,display:"flex",flexDirection:"column",gap:2,zIndex:2},children:[e.jsx("button",{type:"button","aria-label":"Zoom in",onClick:e=>{e.stopPropagation();const t=Pt.current,n=Mt.current;t&&(null==n?void 0:n.scaleBy)&&n.scaleBy(u.select(t),1.5)},style:kt,children:"+"}),e.jsx("button",{type:"button","aria-label":"Zoom out",onClick:e=>{e.stopPropagation();const t=Pt.current,n=Mt.current;t&&(null==n?void 0:n.scaleBy)&&n.scaleBy(u.select(t),1/1.5)},style:kt,children:"−"})]}),_&&e.jsx("div",{className:"stream-geo-tile-attribution",style:{position:"absolute",bottom:Le.bottom+2,right:Le.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},children:_}),e.jsx(tt,{active:Xt.current>=0,hoverPoint:Dt,margin:Le,size:$e,shape:null===(f=Qt.current)||void 0===f?void 0:f.shape,width:null===(g=Qt.current)||void 0===g?void 0:g.w,height:null===(y=Qt.current)||void 0===y?void 0:y.h}),nn]})]})});At.displayName="StreamGeoFrame";const Ot={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function St(e,t){return"function"==typeof t?t(e):e[t]}function Mt(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return 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 Ct(t={}){const{fields:n,title:o,format:r,style:i={},className:s=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let a;const l=[];if(o){const e=St(t,o);a=Mt(e,r)}if(n&&n.length>0)n.forEach(e=>{let n,o,i;"string"==typeof e?(n=e,o=e,i=r):(n=e.label,o=e.accessor||e.key||"",i=e.format||r);const s=St(t,o);l.push({label:n,value:Mt(s,i)})});else if(!o){const e=["value","y","name","id","label"];for(const n of e)if(void 0!==t[n]){a=Mt(t[n],r);break}if(!a){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(a=Mt(t[e[0]],r))}}const c=Object.assign(Object.assign({},Ot),i);return e.jsxs("div",{className:("semiotic-tooltip "+s).trim(),style:c,children:[a&&e.jsx("div",{style:{fontWeight:l.length>0?"bold":"normal"},children:a}),l.map((t,n)=>e.jsxs("div",{style:{marginTop:0===n&&a?"4px":0},children:[t.label&&e.jsxs("span",{children:[t.label,": "]}),t.value]},n))]})}}function Rt(t){if(!0===t)return Ct();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.jsx("div",{className:"semiotic-tooltip",style:Ot,children:o})}}return!1!==t&&void 0!==t&&("object"==typeof t&&null!==t&&("fields"in t||"title"in t)?Ct(t):Ct())}const Pt={category10:d.schemeCategory10,tableau10:d.schemeTableau10,set3:d.schemeSet3,blues:d.interpolateBlues,reds:d.interpolateReds,greens:d.interpolateGreens,oranges:d.interpolateOranges,purples:d.interpolatePurples,viridis:d.interpolateViridis,plasma:d.interpolatePlasma},zt=d.schemeCategory10,$t=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],Lt=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 Et(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")||Lt.has(t)}(o)?n(o):o}const o=null==e?void 0:e[t];return n?n(o):zt[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+""))%zt.length]}function Bt(e,t,n="category10"){const r=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e))),i=r.every(e=>"number"==typeof e||!isNaN(Number(e)));if(Array.isArray(n))return o.scaleOrdinal().domain(r).range(n).unknown("#999");const s=Pt[n]||Pt.category10;if(i&&"function"==typeof s){let e=-1/0;for(const t of r){const n=Number(t);n>e&&(e=n)}return t=>s(Number(t)/e)}{const e=Array.isArray(s)?s:zt;return o.scaleOrdinal().domain(r).range(e).unknown("#999")}}function It(e,t,n=[3,20],o){let r;if(r="function"==typeof t?t(e):null==e?void 0:e[t],!o)return r;const[i,s]=o,[a,l]=n;return s===i?(a+l)/2:a+(r-i)/(s-i)*(l-a)}const Dt=t.createContext(null);function Nt(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,r]=o.range;t.push(t=>{const o=t[n];return o>=e&&r>=o})}return e=>t.every(t=>t(e))}function Tt(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[Wt,_t]=L(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),r=Tt(o,t),i=new Map(r.clauses);return i.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},r),{clauses:i})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const r=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),r.set(t,Object.assign(Object.assign({},o),{clauses:i})),{selections:r}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),r=Tt(o,t);return o.set(t,Object.assign(Object.assign({},r),{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}})}})),[Ft,qt]=L(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 Ht(e){const n=t.useId(),o=e.clientId||n,{name:r}=e,i=_t(e=>e.selections.get(r)),s=_t(e=>e.setClause),a=_t(e=>e.clearClause),l=t.useMemo(()=>!!i&&i.clauses.size>0,[i]);return{predicate:t.useMemo(()=>i&&0!==i.clauses.size?function(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(Nt(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(i,o):()=>!0,[i,o]),isActive:l,selectPoints:t.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};s(r,{clientId:o,type:"point",fields:t})},[o,r,s]),selectInterval:t.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};s(r,{clientId:o,type:"interval",fields:t})},[o,r,s]),clear:t.useCallback(()=>{a(r,o)},[a,r,o]),clientId:o}}function Gt(e){const n=e.name||"hover",{fields:o}=e,{predicate:r,isActive:i,selectPoints:s,clear:a}=Ht({name:n});return{onHover:t.useCallback(e=>{if(!e)return void a();const t={};for(const n of o){const o=e[n];void 0!==o&&(t[n]=[o])}Object.keys(t).length>0&&s(t)},[o,s,a,n]),predicate:r,isActive:i}}const Vt=t.createContext(!1);function Ut(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField}:null}function Zt(e,t,n){return t?o=>{var r;const i=Object.assign({},e(o));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(i,n.selectedStyle);else{const e=null!==(r=null==n?void 0:n.unselectedOpacity)&&void 0!==r?r:.5;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(i,n.unselectedStyle)}return i}:e}function Yt(){return F(e=>e.theme)}f.createContext(void 0);const Xt="#007bff";function Qt(e,n,o){const r=t.useContext(Dt),i=function(){var e;const t=Yt(),n=null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.categorical;return n&&n.length>0?n:void 0}();return t.useMemo(()=>{var t;if(!n)return;const s=null!==(t=null!=o?o:i&&i.length>0?i:void 0)&&void 0!==t?t:"category10";if(0!==e.length){if("function"==typeof n){const t=Array.from(new Set(e.map(e=>n(e)+"")));if(r&&Object.keys(r).length>0){const e=Bt(t.map(e=>({_cat:e})),"_cat",s);return t=>r[t]||e(t)}return Bt(t.map(e=>({_cat:e})),"_cat",s)}if(r&&Object.keys(r).length>0){const t=Bt(e,n,s);return e=>r[e]||t(e)}return Bt(e,n,s)}if(r&&Object.keys(r).length>0){const e=Bt([{_:"a"}],"_",s);return t=>r[t]||e(t)}},[e,n,o,r,i])}function Kt({selection:e,linkedHover:n,fallbackFields:o=[],unwrapData:r=!1,onObservation:i,chartType:s,chartId:a,onClick:l,hoverHighlight:c,colorByField:u}){const d=t.useId(),h=Ut(n,o),p=Ht({name:(null==e?void 0:e.name)||"__unused__"}),f=Gt({name:(null==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||o||[]}),g=qt(e=>e.pushObservation),y=e?{isActive:p.isActive,predicate:p.predicate}:null,[m,b]=t.useState(null),v=u||o[0],x=t.useMemo(()=>{if(!c||null==m||!v)return null;const e=m,t=v;return{isActive:!0,predicate:n=>{var o;return("string"==typeof n[t]?n[t]:(null!==(o=n[t])&&void 0!==o?o:"")+"")===e}}},[c,m,v]),j=t.useCallback(e=>{var t,o;if(n)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const e=null==t?void 0:t[h.xField];null!=e&&Number.isFinite(Number(e))&&function(e,t,n){const o=ke.positions.get(e);(null==o?void 0:o.locked)||o&&o.xValue===t&&o.sourceId===n||(ke={positions:new Map(ke.positions).set(e,{xValue:t,sourceId:n})},Ae())}(h.name||"hover",Number(e),d)}"x-position"!==(null==h?void 0:h.mode)&&f.onHover(t)}else"x-position"===(null==h?void 0:h.mode)&&Oe(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&f.onHover(null);if(c&&v)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[v];b(null!=n?n+"":null)}else b(null);if(i||g){const n={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const s=Object.assign(Object.assign({},n),{type:"hover",datum:r||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0});i&&i(s),g&&g(s)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});i&&i(e),g&&g(e)}}},[n,f,h,d,i,s,a,g,c,v]),k=t.useCallback(e=>{var t,n,o,r;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[h.xField];null!=n&&Number.isFinite(Number(n))&&function(e,t,n){const o=ke.positions.get(e);if(null==o?void 0:o.locked){const t=new Map(ke.positions);return t.delete(e),ke={positions:t},Ae(),!1}ke={positions:new Map(ke.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Ae()}(h.name||"hover",Number(n),d)}if(e&&l){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]),l(o,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0})}if(i||g){const t={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){let n=e.data||e.datum||e;Array.isArray(n)&&(n=n[0]);const s=Object.assign(Object.assign({},t),{type:"click",datum:n||{},x:null!==(o=e.x)&&void 0!==o?o:0,y:null!==(r=e.y)&&void 0!==r?r:0});i&&i(s),g&&g(s)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});i&&i(e),g&&g(e)}}},[l,i,g,s,a,h,d]);return t.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const e=h.name||"hover";return()=>{Se(e,d),Oe(e,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:y,hoverSelectionHook:x,customHoverBehavior:j,customClickBehavior:k,crosshairSourceId:d}}function Jt({data:e,colorBy:n,colorScale:o,showLegend:r,legendPosition:i="right",userMargin:s,defaults:a={top:50,bottom:60,left:70,right:40},categories:l}){const c=t.useContext(Vt),u=void 0!==r?r:!c&&!!n,d=t.useMemo(()=>{if(!u||!n)return;const t=function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:r,strokeWidth:i,categories:s}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==r&&(n.stroke=r),void 0!==i&&(n.strokeWidth=i),n},type:"fill",items:(s&&s.length>0?s:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((r,i)=>{const s=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),a=s?o(s,t,n):n?n(r):$t[i%$t.length];return{label:r+"",color:a}}),label:""}]}}({data:e,colorBy:n,colorScale:o,getColor:Et,categories:l});return 0!==t.legendGroups.reduce((e,t)=>e+t.items.length,0)?t:void 0},[u,n,e,o,l]),h=t.useMemo(()=>{const e="number"==typeof s?{top:s,bottom:s,left:s,right:s}:null!=s?s:{},t=Object.assign(Object.assign({},a),e);return d&&("right"===i&&110>t.right?t.right=110:"left"===i&&110>t.left?t.left=110:"top"===i&&50>t.top?t.top=50:"bottom"===i&&80>t.bottom&&(t.bottom=80)),t},[a,s,d,i]);return{legend:d,margin:h,legendPosition:i}}const en={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 tn(e,t,n){var o,r,i,s,a,l,c;const u=en[e||"primary"],d="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:u.width,height:null!==(r=t.height)&&void 0!==r?r:u.height,showAxes:null!==(i=t.showAxes)&&void 0!==i?i:u.showAxes,showGrid:null!==(s=t.showGrid)&&void 0!==s?s:u.showGrid,enableHover:null!==(a=t.enableHover)&&void 0!==a?a:!!t.linkedHover||u.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:u.showLegend,showLabels:null!==(c=t.showLabels)&&void 0!==c?c:u.showLabels,title:d?void 0:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:d?void 0:t.xLabel,yLabel:d?void 0:t.yLabel,categoryLabel:d?void 0:t.categoryLabel,valueLabel:d?void 0:t.valueLabel,marginDefaults:nn(u.marginDefaults,t.showCategoryTicks,t.orientation),compactMode:d}}function nn(e,t,n){if(!1!==t)return e;const o=Object.assign({},e);return"horizontal"===n?o.left=Math.min(o.left,15):o.bottom=Math.min(o.bottom,15),o}function on(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return null!=e?e:()=>({});const n={};return void 0!==t.stroke&&(n.stroke=t.stroke),void 0!==t.strokeWidth&&(n.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(n.opacity=t.opacity),e?(...t)=>{const o=e(...t)||{};return Object.assign(Object.assign({},o),n)}:(...e)=>Object.assign({},n)}function rn({componentName:t,message:n,diagnosticHint:o,width:r,height:i}){return e.jsx("div",{role:"alert",style:{width:r,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"},children:e.jsxs("div",{style:{textAlign:"center",maxWidth:400},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:t}),e.jsx("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:n}),o&&e.jsx("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6},children:o})]})})}class sn extends f.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.jsx(rn,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}function an(e,t){const n=e.length,o=t.length,r=Array(o+1);for(let e=0;o>=e;e++)r[e]=e;for(let i=1;n>=i;i++){let n=r[0];r[0]=i;for(let s=1;o>=s;s++){const o=r[s];r[s]=e[i-1]===t[s-1]?n:1+Math.min(n,r[s],r[s-1]),n=o}}return r[o]}function ln(e,t,n=3){let o,r=n+1;for(const n of t){const t=an(e.toLowerCase(),n.toLowerCase());r>t&&(r=t,o=n)}return r>n?void 0:o}function cn(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function un(e,t){var n;if(0===t.length)return null;const o=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(o)||o.includes(e.toLowerCase()))||(null!==(n=ln(e,t,3))&&void 0!==n?n:null)}const dn={width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},title:{type:"string"},enableHover:{type:"boolean"},showLegend:{type:"boolean"},showGrid:{type:"boolean"},colorBy:{type:["string","function"]},colorScheme:{type:["string","array"]},tooltip:{type:["boolean","function","object"]},annotations:{type:"array"},frameProps:{type:"object"},onClick:{type:"function"}},hn={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},pn={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"}},fn=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],gn=["vertical","horizontal"],yn={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},dn),hn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:fn},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},fillArea:{type:"boolean"},areaOpacity:{type:"number"}})},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},dn),hn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:fn},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"}})},StackedAreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},dn),hn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:fn},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},normalize:{type:"boolean"}})},Scatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},dn),hn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},dn),hn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},bubbleOpacity:{type:"number"},bubbleStrokeWidth:{type:"number"},bubbleStrokeColor:{type:"string"}})},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},dn),hn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},colorScheme:{type:"string",enum:["blues","reds","greens","viridis","custom"]},customColorScale:{type:["object","function"]},showValues:{type:"boolean"},valueFormat:{type:"function"},cellBorderColor:{type:"string"},cellBorderWidth:{type:"number"},showLegend:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},QuadrantChart:{required:["quadrants"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},dn),hn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},quadrants:{type:"object"},xCenter:{type:"number"},yCenter:{type:"number"},centerlineStyle:{type:"object"},showQuadrantLabels:{type:"boolean"},quadrantLabelSize:{type:"number"},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"}})},MultiAxisLineChart:{required:["series"],dataShape:"array",dataAccessors:["xAccessor"],props:Object.assign(Object.assign(Object.assign({},dn),hn),{data:{type:"array"},xAccessor:{type:["string","function"]},series:{type:"array"},colorScheme:{type:["string","array"]},curve:{type:"string"},lineWidth:{type:"number"},annotations:{type:"array"}})},CandlestickChart:{required:["highAccessor","lowAccessor"],dataShape:"array",dataAccessors:["xAccessor","highAccessor","lowAccessor"],props:Object.assign(Object.assign(Object.assign({},dn),hn),{data:{type:"array"},xAccessor:{type:["string","function"]},highAccessor:{type:["string","function"]},lowAccessor:{type:["string","function"]},openAccessor:{type:["string","function"]},closeAccessor:{type:["string","function"]},candlestickStyle:{type:"object"},mode:{type:"string",enum:["primary","context","sparkline"]},annotations:{type:"array"}})},ConnectedScatterplot:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},dn),hn),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},orderAccessor:{type:["string","function"]},orderLabel:{type:"string"},pointRadius:{type:"number"},pointIdAccessor:{type:["string","function"]},annotations:{type:"array"}})},BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},dn),pn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:gn},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},dn),pn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:gn},normalize:{type:"boolean"},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},LikertChart:{required:["levels"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor","levelAccessor","countAccessor"],props:Object.assign(Object.assign(Object.assign({},dn),pn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},levelAccessor:{type:["string","function"]},countAccessor:{type:["string","function"]},levels:{type:"array"},orientation:{type:"string",enum:gn},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},dn),pn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:gn},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},SwarmPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},dn),pn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:gn},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},BoxPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},dn),pn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:gn},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},dn),pn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},relative:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},ViolinPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},dn),pn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:gn},bins:{type:"number"},curve:{type:"string"},showIQR:{type:"boolean"},categoryPadding:{type:"number"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]}})},RidgelinePlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},dn),pn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},bins:{type:"number"},amplitude:{type:"number"},categoryPadding:{type:"number"}})},DotPlot:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},dn),pn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:gn},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},dn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},startAngle:{type:"number"},cornerRadius:{type:"number"}})},DonutChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},dn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},innerRadius:{type:"number"},centerContent:{type:["object","string","number"]},startAngle:{type:"number"},cornerRadius:{type:"number"}})},GaugeChart:{required:["value"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},dn),{value:{type:"number"},min:{type:"number"},max:{type:"number"},thresholds:{type:"array"},arcWidth:{type:"number"},sweep:{type:"number"},showNeedle:{type:"boolean"},needleColor:{type:"string"},centerContent:{type:["object","string","number","function"]},valueFormat:{type:"function"},showScaleLabels:{type:"boolean"},backgroundColor:{type:"string"}})},FunnelChart:{required:["data"],dataShape:"array",dataAccessors:["stepAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},dn),pn),{data:{type:"array"},stepAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},connectorOpacity:{type:"number"},showCategoryTicks:{type:"boolean"},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},SwimlaneChart:{required:["subcategoryAccessor"],dataShape:"array",dataAccessors:["categoryAccessor","subcategoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},dn),pn),{data:{type:"array"},categoryAccessor:{type:["string","function"]},subcategoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},barPadding:{type:"number"},showCategoryTicks:{type:"boolean"},brush:{type:"boolean"},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},responsiveWidth:{type:"boolean"},legendPosition:{type:"string",enum:["right","left","top","bottom"]}})},ForceDirectedGraph:{required:["nodes","edges"],dataShape:"network",dataAccessors:["nodeIDAccessor","sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},dn),{nodes:{type:"array"},edges:{type:"array"},nodeIDAccessor:{type:["string","function"]},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},nodeLabel:{type:["string","function"]},nodeSize:{type:["number","string","function"]},nodeSizeRange:{type:"array"},edgeWidth:{type:["number","string","function"]},edgeColor:{type:"string"},edgeOpacity:{type:"number"},iterations:{type:"number"},forceStrength:{type:"number"},showLabels:{type:"boolean"}})},SankeyDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},dn),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target","gradient"]},orientation:{type:"string",enum:gn},nodeAlign:{type:"string",enum:["justify","left","right","center"]},nodePaddingRatio:{type:"number"},nodeWidth:{type:"number"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"},edgeSort:{type:"function"}})},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},dn),{nodes:{type:"array"},edges:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},edgeColorBy:{type:["string","function"],enum:["source","target"]},padAngle:{type:"number"},groupWidth:{type:"number"},sortGroups:{type:"function"},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},edgeOpacity:{type:"number"}})},TreeDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},dn),{data:{type:"object"},layout:{type:"string",enum:["tree","cluster","partition","treemap","circlepack"]},orientation:{type:"string",enum:["vertical","horizontal","radial"]},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},edgeStyle:{type:"string",enum:["line","curve"]},nodeLabel:{type:["string","function"]},showLabels:{type:"boolean"},nodeSize:{type:"number"}})},Treemap:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},dn),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]}})},CirclePack:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},dn),{data:{type:"object"},childrenAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},colorByDepth:{type:"boolean"},showLabels:{type:"boolean"},nodeLabel:{type:["string","function"]},circleOpacity:{type:"number"}})},OrbitDiagram:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},dn),{data:{type:"object"},childrenAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},orbitMode:{type:["string","array"]},speed:{type:"number"},revolution:{type:"function"},eccentricity:{type:["number","function"]},orbitSize:{type:["number","function"]},nodeRadius:{type:["number","function"]},showRings:{type:"boolean"},showLabels:{type:"boolean"},animated:{type:"boolean"},colorByDepth:{type:"boolean"},annotations:{type:"array"},foregroundGraphics:{type:"object"}})},RealtimeLineChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},stroke:{type:"string"},strokeWidth:{type:"number"},strokeDasharray:{type:"string"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHistogram:{required:["binSize"],dataShape:"realtime",dataAccessors:[],props:{binSize:{type:"number"},size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},brush:{type:["boolean","string","object"]},onBrush:{type:"function"},linkedBrush:{type:["string","object"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeSwarmChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"object"},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},radius:{type:"number"},fill:{type:"string"},opacity:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeWaterfallChart:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},positiveColor:{type:"string"},negativeColor:{type:"string"},connectorStroke:{type:"string"},connectorWidth:{type:"number"},gap:{type:"number"},stroke:{type:"string"},strokeWidth:{type:"number"},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"},transition:{type:"object"}}},RealtimeHeatmap:{required:[],dataShape:"realtime",dataAccessors:[],props:{size:{type:"array"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},heatmapXBins:{type:"number"},heatmapYBins:{type:"number"},aggregation:{type:"string",enum:["count","sum","mean"]},windowSize:{type:"number"},windowMode:{type:"string",enum:["sliding","stepping"]},arrowOfTime:{type:"string",enum:["left","right"]},timeExtent:{type:"array"},valueExtent:{type:"array"},extentPadding:{type:"number"},showAxes:{type:"boolean"},background:{type:"string"},enableHover:{type:["boolean","object"]},tooltipContent:{type:"function"},tooltip:{type:["function","object"]},onHover:{type:"function"},annotations:{type:"array"},svgAnnotationRules:{type:"function"},tickFormatTime:{type:"function"},tickFormatValue:{type:"function"},width:{type:"number"},height:{type:"number"},decay:{type:"object"},pulse:{type:"object"},staleness:{type:"object"}}},ScatterplotMatrix:{required:["data","fields"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},dn),{data:{type:"array"},fields:{type:"array"}})},MinimapChart:{required:["data"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},dn),{data:{type:"array"}})},ChoroplethMap:{required:["areas"],dataShape:"array",dataAccessors:["valueAccessor"],props:Object.assign(Object.assign({},dn),{areas:{type:["array","string"]},valueAccessor:{type:["string","function"]},colorScheme:{type:["string","array"]},projection:{type:"string"}})},ProportionalSymbolMap:{required:["points"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign({},dn),{points:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},areas:{type:["array","string"]}})},FlowMap:{required:["flows"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},dn),{flows:{type:"array"},nodes:{type:"array"},valueAccessor:{type:["string","function"]}})},DistanceCartogram:{required:["points"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},dn),{points:{type:"array"},center:{type:"array"},costAccessor:{type:["string","function"]}})}};function mn(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}const bn=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),vn=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),xn=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),jn=new Set(["LineChart","AreaChart","StackedAreaChart"]),kn=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]);function wn(e){const t=e.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(!t)return null;const[n,o,r]=[parseInt(t[1],16)/255,parseInt(t[2],16)/255,parseInt(t[3],16)/255],i=e=>e>.03928?Math.pow((e+.055)/1.055,2.4):e/12.92;return.2126*i(n)+.7152*i(o)+.0722*i(r)}function An(e,t){const n=wn(e),o=wn(t);return null===n||null===o?null:(Math.max(n,o)+.05)/(Math.min(n,o)+.05)}const On=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];function Sn(e,t){const n=[],o=function(e,t){const n=[],o=yn[e];if(!o)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(yn).join(", ")}`]};for(const r of o.required)null==t[r]&&n.push(`"${r}" is required for ${e}.`);for(const[e,r]of Object.entries(t)){if(null==r)continue;const t=o.props[e];if(t){if(!mn(r,t.type)){const o=Array.isArray(t.type)?t.type.join(" | "):t.type;n.push(`"${e}" should be ${o}, got ${Array.isArray(r)?"array":typeof r}.`);continue}t.enum&&"string"==typeof r&&!t.enum.includes(r)&&n.push(`"${e}" value "${r}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const r=Object.keys(o.props),i=new Set(r);for(const o of Object.keys(t))if(void 0!==t[o]&&!i.has(o)){const t=ln(o,r),i=t?`Unknown prop "${o}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${o}" for ${e}. Valid props: ${r.join(", ")}.`;n.push(i)}if("array"===o.dataShape){const r=t.data,i={};for(const e of o.dataAccessors){const n=t[e];"string"==typeof n&&(i[e]=n)}const s=function({componentName:e,data:t,accessors:n,requiredProps:o}){if(o)for(const[t,n]of Object.entries(o))if(null==n)return`${e}: ${t} is required. Provide a field name or function.`;if(null==t)return null;if(!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(n){const o=cn(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[r,i]of Object.entries(n))if(i&&"string"==typeof i&&!(i in o)){const n=un(i,t),o=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${i}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}({componentName:e,data:r,accessors:Object.keys(i).length>0?i:void 0});s&&n.push(s)}else if("object"===o.dataShape){const o=function({componentName:e,data:t,dataLabel:n="data"}){return null==t?`${e}: No ${n} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${n} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}({componentName:e,data:t.data});o&&n.push(o)}else if("network"===o.dataShape){const r=function({componentName:e,nodes:t,edges:n,nodesRequired:o=!1,edgesRequired:r=!0,accessors:i}){if(null==t&&null==n)return null;if(r&&(!n||!Array.isArray(n)||0===n.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(o&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const n=cn(t).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[o,r]of Object.entries(i))if(r&&"string"==typeof r&&!(r in n)){const n=un(r,t),i=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${r}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}return null}({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:o.required.includes("nodes"),edgesRequired:o.required.includes("edges")});r&&n.push(r)}return{valid:0===n.length,errors:n}}(e,t);for(const e of o.errors)n.push({severity:"error",code:"VALIDATION",message:e,fix:""});return yn[e]?(function(e,t,n){const o=yn[e];if(o){if("array"===o.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&n.push({severity:"error",code:"EMPTY_DATA",message:"data is an empty array — chart will render blank.",fix:"Provide at least one data point: data={[{ x: 1, y: 2 }]}."})}"network"===o.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&n.push({severity:"error",code:"EMPTY_EDGES",message:"edges is an empty array — network chart will render blank.",fix:'Provide at least one edge: edges={[{ source: "A", target: "B" }]}.'})}}(e,t,n),function(e,t,n){const o=t.width,r=t.height;if(void 0===o||"number"==typeof o&&o>0||n.push({severity:"error",code:"BAD_WIDTH",message:`width=${JSON.stringify(o)} — chart needs a positive number.`,fix:"Set width={600} or use responsiveWidth={true}."}),void 0===r||"number"==typeof r&&r>0||n.push({severity:"error",code:"BAD_HEIGHT",message:`height=${JSON.stringify(r)} — chart needs a positive number.`,fix:"Set height={400} or use responsiveHeight={true}."}),t.size&&Array.isArray(t.size)){const[e,o]=t.size;(null!=e&&0>=e||null!=o&&0>=o)&&n.push({severity:"error",code:"BAD_SIZE",message:`size=[${e}, ${o}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}(0,t,n),function(e,t,n){const o=yn[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const i=r[0];if(!i||"object"!=typeof i)return;const s=Object.keys(i);for(const e of o.dataAccessors){const o=t[e];"string"==typeof o&&(o in i||n.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${o}" not found in data. Available fields: ${s.join(", ")}.`,fix:`Change ${e} to one of: ${s.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,n),function(e,t,n){bn.has(e)&&Array.isArray(t.data)&&n.push({severity:"error",code:"HIERARCHY_FLAT_ARRAY",message:e+" expects hierarchical data but received a flat array.",fix:'Pass a root object: data={{ name: "root", children: [...] }}. For flat data, use BarChart or LineChart.'})}(e,t,n),function(e,t,n){vn.has(e)&&(t.edges||t.data||n.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}(e,t,n),function(e,t,n){const o=yn[e];if(!o||"array"!==o.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const i=r[0];if(!i||"object"!=typeof i)return;const s=t.xAccessor;"string"==typeof s&&i[s]instanceof Date&&!t.xFormat&&n.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${s}" contains Date objects but no xFormat is provided. Axis ticks may display "[object Object]".`,fix:"Add xFormat={d => d.toLocaleDateString()} or use timestamps (d.getTime()) instead of Date objects."})}(e,t,n),function(e,t,n){t.linkedHover&&!t.selection&&n.push({severity:"warning",code:"LINKED_HOVER_NO_SELECTION",message:"linkedHover is set but selection is not — this chart emits hover events but won't highlight from others.",fix:`Add selection={{ name: "${"object"==typeof t.linkedHover&&t.linkedHover.name||"hl"}" }} to receive cross-highlights.`})}(0,t,n),function(e,t,n){var o;if(!xn.has(e))return;const r=t.rExtent||t.yExtent;r&&Array.isArray(r)&&r.length>=1&&null!=r[0]&&0!==r[0]&&n.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${r[0]}). Bar and area charts should start at zero to avoid exaggerating differences.`,fix:`Remove the custom extent minimum or set it to 0: rExtent={[0, ${null!==(o=r[1])&&void 0!==o?o:"auto"}]}. For trend-focused charts, use LineChart instead.`})}(e,t,n),function(e,t,n){if(!jn.has(e))return;if(t.gapStrategy)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const r=t.yAccessor||"y";"string"==typeof r&&o.some(e=>{const t=e[r];return null==t||Number.isNaN(t)})&&n.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${r}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}(e,t,n),function(e,t,n){var o,r;const i=null!==(o=t.width)&&void 0!==o?o:600,s=null!==(r=t.height)&&void 0!==r?r:400,a=t.margin;if(!a||"object"!=typeof a)return;const l=(a.left||0)+(a.right||0),c=(a.top||0)+(a.bottom||0);i>l||n.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${l}px) >= width (${i}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),s>c||n.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${c}px) >= height (${s}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}(0,t,n),function(e,t,n){var o;const r=yn[e];if(!r||"array"!==r.dataShape)return;const i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;const s=[];t.xAccessor&&"string"==typeof t.xAccessor&&s.push({prop:"xAccessor",name:t.xAccessor}),t.yAccessor&&"string"==typeof t.yAccessor&&s.push({prop:"yAccessor",name:t.yAccessor}),t.valueAccessor&&"string"==typeof t.valueAccessor&&s.push({prop:"valueAccessor",name:t.valueAccessor});const a=Math.min(i.length,5);for(const e of s){let t=!0;for(let n=0;a>n;n++){const r=null===(o=i[n])||void 0===o?void 0:o[e.name];if("number"==typeof r&&Number.isFinite(r)){t=!1;break}}t&&n.push({severity:"error",code:"DEGENERATE_EXTENT",message:`${e.prop}="${e.name}" produces NaN or non-finite values for all sampled data points — chart extents will be invalid.`,fix:`Ensure data[].${e.name} contains finite numbers, or use a function accessor to transform values.`})}}(e,t,n),function(e,t,n){if(!kn.has(e))return;const o=t.barPadding;"number"==typeof o&&10>o&&n.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${o} is very small — bars may appear to have no spacing between them.`,fix:"Increase barPadding to at least 10 for visible gaps, e.g. barPadding={12}."})}(e,t,n),function(e,t,n){if("bottom"!==t.legendPosition)return;const o=t.margin;if(!o||"object"!=typeof o)return;const r=o.bottom;"number"==typeof r&&70>r&&n.push({severity:"warning",code:"BOTTOM_MARGIN_WITH_LEGEND",message:`legendPosition="bottom" with margin.bottom=${r}px — legend may overlap axis labels.`,fix:"Increase margin.bottom to at least 70, e.g. margin={{ ...margin, bottom: 80 }}."})}(0,t,n),function(e,t,n){var o;if(!t.showLegend)return;if("right"!==(null!==(o=t.legendPosition)&&void 0!==o?o:"right"))return;const r=t.margin;if(!r||"object"!=typeof r)return;const i=r.right;"number"==typeof i&&100>i&&n.push({severity:"warning",code:"LEGEND_MARGIN_TIGHT",message:`showLegend is true with legendPosition="right" but margin.right=${i}px — legend may be clipped or overlap the chart.`,fix:"Increase margin.right to at least 100, e.g. margin={{ ...margin, right: 120 }}."})}(0,t,n),function(e,t,n){if("Heatmap"!==e)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const r=o[0];if(r&&"object"==typeof r)for(const e of["xAccessor","yAccessor"]){const o=t[e];if("string"!=typeof o)continue;const i=r[o];"string"==typeof i&&n.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${o}" resolves to string values (e.g. "${i}"). Heatmap will use categorical axis handling which may produce unexpected cell layout.`,fix:"If you intend categorical axes this is fine. Otherwise, convert values to numbers before passing data."})}}(e,t,n),function(e,t,n){const o=t.colorScheme;if(!o||!Array.isArray(o))return;const r="string"==typeof t.background?t.background:"#ffffff";if(!r.startsWith("#"))return;const i=[];for(const e of o){if("string"!=typeof e||!e.startsWith("#"))continue;const t=An(e,r);null!==t&&3>t&&i.push(`${e} (${t.toFixed(1)}:1)`)}i.length>0&&n.push({severity:"warning",code:"LOW_COLOR_CONTRAST",message:`${i.length} color(s) in colorScheme have < 3:1 contrast against background "${r}": ${i.join(", ")}. Data marks may be hard to see.`,fix:'Use darker colors on light backgrounds or lighter colors on dark backgrounds. Import COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for an accessible preset.'})}(0,t,n),function(e,t,n){const o=t.colorScheme;if(!o||!Array.isArray(o)||2>o.length)return;const r=o.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>r.length)return;const i=[];for(let e=0;r.length-1>e;e++){const t=An(r[e],r[e+1]);null!==t&&1.5>t&&i.push(`${r[e]} / ${r[e+1]} (${t.toFixed(1)}:1)`)}i.length>0&&n.push({severity:"warning",code:"LOW_ADJACENT_CONTRAST",message:`${i.length} adjacent color pair(s) in colorScheme have very similar luminance: ${i.join("; ")}. Categories may be hard to distinguish.`,fix:'Alternate light and dark colors in the scheme, or use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for a pre-tested palette.'})}(0,t,n),function(e,t,n){const o="string"==typeof t.title&&t.title.trim().length>0,r="string"==typeof t.description&&t.description.trim().length>0,i="string"==typeof t.summary&&t.summary.trim().length>0;o||r||i||n.push({severity:"warning",code:"MISSING_DESCRIPTION",message:'No title, description, or summary provided. Screen readers will use a generic label like "XY chart".',fix:'Add a title="..." prop for a brief label, or description="..." for a detailed aria-label, or summary="..." for a screen-reader-only note describing the chart\'s purpose.'})}(0,t,n),function(e,t,n){const o=[];for(const e of On)"function"==typeof t[e]&&o.push(e);o.length>0&&n.push({severity:"warning",code:"FUNCTION_ACCESSOR",message:`Function accessor${o.length>1?"s":""} detected: ${o.join(", ")}. If defined inline (e.g. \`xAccessor={d => d.value}\`), every parent re-render creates a new reference which may trigger unnecessary scene rebuilds.`,fix:'Use string accessors when possible (e.g. xAccessor="value"), or memoize with useCallback / define outside the component.'})}(0,t,n),{ok:n.every(e=>"warning"===e.severity),diagnoses:n}):{ok:0===n.length,diagnoses:n}}var Mn;const Cn="undefined"!=typeof process&&"production"!==(null===(Mn=process.env)||void 0===Mn?void 0:Mn.NODE_ENV);function Rn({componentName:t,width:n,height:o,chartProps:r,children:i}){return e.jsx(sn,{fallback:i=>{let s="";if(Cn&&r)try{const e=Sn(t,r);e.ok||(s=e.diagnoses.map(e=>`${"error"===e.severity?"✗":"⚠"} ${e.message}${e.fix?" — Fix: "+e.fix:""}`).join("\n"))}catch(e){}return e.jsx(rn,{componentName:t,message:i.message,diagnosticHint:s,width:n,height:o})},children:i})}const Pn={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"},zn={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function $n(t,n,o,r){return!1===r||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?e.jsx("div",{style:Object.assign(Object.assign({},Pn),{width:n,height:o}),children:r||"No data available"}):null}function Ln(t,n,o){if(!t)return null;const r=Math.min(5,Math.floor(o/40)),i=Math.max(8,Math.floor(o/(3*r))),s=Math.max(6,Math.floor(o/(2.5*r))),a=Math.floor((o-(r*(i+s)-s))/2);return e.jsx("div",{style:{width:n,height:o,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:r},(t,o)=>e.jsx("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},zn),{position:"absolute",top:a+o*(i+s),left:Math.floor(.1*n),width:30+(37*o+13)%50+"%",height:i,opacity:.5+o%2*.2})},o))})}function En(e,t,n,o){if(!Cn)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const r=t[0];if(!r||"object"!=typeof r)return;if(o in r)return;const i=Object.keys(r).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${i}`)}function Bn(e){const n=F(e=>e.theme.colors.selectionOpacity);return t.useMemo(()=>{var t,o;if(void 0!==e||void 0!==n)return Object.assign(Object.assign({name:null!==(t=null==e?void 0:e.name)&&void 0!==t?t:""},e),{unselectedOpacity:null!==(o=null==e?void 0:e.unselectedOpacity)&&void 0!==o?o:n})},[e,n])}function In(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{l(o.next(e))}catch(e){i(e)}}function a(e){try{l(o.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((o=o.apply(e,t||[])).next())})}function Dn(e){return e}function Nn(e,t){var n=t.id,o=t.bbox,r=null==t.properties?{}:t.properties,i=function(e,t){var n=function(e){if(null==e)return Dn;var t,n,o=e.scale[0],r=e.scale[1],i=e.translate[0],s=e.translate[1];return function(e,a){a||(t=n=0);var l=2,c=e.length,u=Array(c);for(u[0]=(t+=e[0])*o+i,u[1]=(n+=e[1])*r+s;c>l;)u[l]=e[l],++l;return u}}(e.transform),o=e.arcs;function r(e,t){t.length&&t.pop();for(var r=o[0>e?~e:e],i=0,s=r.length;s>i;++i)t.push(n(r[i],i));0>e&&function(e,t){for(var n,o=e.length,r=o-t;r<--o;)n=e[r],e[r++]=e[o],e[o]=n}(t,s)}function i(e){return n(e)}function s(e){for(var t=[],n=0,o=e.length;o>n;++n)r(e[n],t);return 2>t.length&&t.push(t[0]),t}function a(e){for(var t=s(e);4>t.length;)t.push(t[0]);return t}function l(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=i(t.coordinates);break;case"MultiPoint":n=t.coordinates.map(i);break;case"LineString":n=s(t.arcs);break;case"MultiLineString":n=t.arcs.map(s);break;case"Polygon":n=l(t.arcs);break;case"MultiPolygon":n=t.arcs.map(l);break;default:return null}return{type:o,coordinates:n}}(t)}(e,t);return null==n&&null==o?{type:"Feature",properties:r,geometry:i}:null==o?{type:"Feature",id:n,properties:r,geometry:i}:{type:"Feature",id:n,bbox:o,properties:r,geometry:i}}"function"==typeof SuppressedError&&SuppressedError;const Tn=new Map;function Wn(e){var t;return null!==(t=e.default)&&void 0!==t?t:e}function _n(e){return In(this,void 0,void 0,function*(){const t=Tn.get(e);if(t)return t;const{topology:n,objectName:o}=yield function(e){return In(this,void 0,void 0,function*(){switch(e){case"world-110m":return{topology:Wn(yield import("world-atlas/countries-110m.json")),objectName:"countries"};case"world-50m":return{topology:Wn(yield import("world-atlas/countries-50m.json")),objectName:"countries"};case"land-110m":return{topology:Wn(yield import("world-atlas/land-110m.json")),objectName:"land"};case"land-50m":return{topology:Wn(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 r=function(e,t){return"string"==typeof t&&(t=e.objects[t]),"GeometryCollection"===t.type?{type:"FeatureCollection",features:t.geometries.map(function(t){return Nn(e,t)})}:Nn(e,t)}(n,n.objects[o]),i="features"in r?r.features:[r];return Tn.set(e,i),i})}function Fn(e){const n=t.useMemo(()=>Array.isArray(e)?e:void 0,[e]),[o,r]=t.useState(null);return t.useEffect(()=>{if(e&&!Array.isArray(e)){if("string"==typeof(t=e)&&["world-110m","world-50m","land-110m","land-50m"].includes(t)){let t=!1;return r(null),_n(e).then(e=>{t||r(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".`),r(null)}else r(null)},[e]),void 0!==n?n:o}const qn={blues:d.interpolateBlues,reds:d.interpolateReds,greens:d.interpolateGreens,viridis:d.interpolateViridis,oranges:d.interpolateOranges,purples:d.interpolatePurples,greys:d.interpolateGreys,plasma:d.interpolatePlasma,inferno:d.interpolateInferno,magma:d.interpolateMagma,cividis:d.interpolateCividis,turbo:d.interpolateTurbo};function Hn(n){var r;const s=tn(n.mode,{width:n.width,height:n.height,showLegend:n.showLegend,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary}),a=function(){var e;const t=Yt();return(null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.sequential)||void 0}(),{areas:l,valueAccessor:c,colorScheme:u,projection:h="equalEarth",graticule:p,fitPadding:f,zoomable:g,zoomExtent:y,onZoom:m,dragRotate:b,tileURL:v,tileAttribution:x,tileCacheSize:j,tooltip:k,areaOpacity:w=1,annotations:A,margin:O,className:S,selection:M,linkedHover:C,onObservation:R,onClick:P,chartId:z,loading:$,emptyContent:L,frameProps:E={},stroke:B,strokeWidth:I,opacity:D}=n,N=null!=g?g:!!v,T=Fn(l),W=t.useMemo(()=>"function"==typeof c?c:e=>{var t,n;return null!==(n=null===(t=null==e?void 0:e.properties)||void 0===t?void 0:t[c])&&void 0!==n?n:null==e?void 0:e[c]},[c]),_=null!==(r=null!=u?u:a)&&void 0!==r?r:"blues",F=t.useMemo(()=>{if(!T)return o.scaleSequential(d.interpolateBlues).domain([0,1]);const e=T.map(e=>W(e)).filter(e=>null!=e&&isFinite(e)),[t,n]=i.extent(e);return o.scaleSequential(qn[_]||d.interpolateBlues).domain([null!=t?t:0,null!=n?n:1])},[T,W,_]),{activeSelectionHook:q,customHoverBehavior:H,customClickBehavior:G}=Kt({selection:M,linkedHover:C,onObservation:R,onClick:P,chartType:"ChoroplethMap",chartId:z}),V=Bn(M),U=t.useMemo(()=>{const e=on(e=>{const t=W(e);return{fill:null!=t&&isFinite(t)?F(t):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:w}},{stroke:B,strokeWidth:I,opacity:D});return q?Zt(e,q,V):e},[W,F,q,V,w,B,I,D]),Z=t.useMemo(()=>t=>{var n,o;const r=(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",i=W(t);return e.jsxs("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:[e.jsx("div",{style:{fontWeight:600},children:r}),null!=i&&e.jsx("div",{style:{opacity:.7},children:(s=i,"number"==typeof s&&isFinite(s)?Number.isInteger(s)?s.toLocaleString():s.toLocaleString(void 0,{maximumFractionDigits:2}):(null!=s?s:"")+"")})]});var s},[W]),Y=t.useMemo(()=>Object.assign({top:10,right:10,bottom:10,left:10},"number"==typeof O?{top:O,bottom:O,left:O,right:O}:O),[O]),X=Ln($,s.width,s.height)||(T?null:Ln(!0,s.width,s.height)),Q=X?null:$n(T,s.width,s.height,L);if(Array.isArray(T)&&T.length>0){const t=T[0];if(!t||"object"!=typeof t||!t.geometry)return e.jsx(rn,{componentName:"ChoroplethMap",message:"ChoroplethMap: areas must be an array of GeoJSON Features with a geometry property.",width:s.width,height:s.height})}const K=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:h,areas:T,areaStyle:U,size:[s.width,s.height],margin:Y,enableHover:!0,tooltipContent:!1===k?()=>null:!0===k?Z:Rt(k)||Z},null!=p&&{graticule:p}),null!=f&&{fitPadding:f}),N&&{zoomable:!0}),y&&{zoomExtent:y}),m&&{onZoom:m}),null!=b&&{dragRotate:b}),v&&{tileURL:v}),x&&{tileAttribution:x}),j&&{tileCacheSize:j}),(C||R||P)&&{customHoverBehavior:H}),(R||P)&&{customClickBehavior:G}),A&&A.length>0&&{annotations:A}),s.title&&{title:s.title}),s.description&&{description:s.description}),s.summary&&{summary:s.summary}),void 0!==s.accessibleTable&&{accessibleTable:s.accessibleTable}),S&&{className:S}),null!=n.animate&&{animate:n.animate}),E);return X||Q||e.jsx(Rn,{componentName:"ChoroplethMap",width:s.width,height:s.height,children:e.jsx(At,Object.assign({},K))})}Hn.displayName="ChoroplethMap";const Gn=t.forwardRef(function(n,o){const r=t.useRef(null);t.useImperativeHandle(o,()=>({push:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=r.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.removePoint(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o,i;const s=null!==(o=null===(n=r.current)||void 0===n?void 0:n.removePoint(e))&&void 0!==o?o:[];for(const e of s)null===(i=r.current)||void 0===i||i.push(t(e));return s},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const i=tn(n.mode,{width:n.width,height:n.height,showLegend:n.showLegend,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary}),{points:s,xAccessor:a="lon",yAccessor:l="lat",sizeBy:c,sizeRange:u=[3,30],colorBy:d,colorScheme:h,projection:p="equalEarth",graticule:f,fitPadding:g,zoomable:y,zoomExtent:m,onZoom:b,dragRotate:v,tileURL:x,tileAttribution:j,tileCacheSize:k,areas:w,areaStyle:A={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5},tooltip:O,annotations:S,margin:M,className:C,selection:R,linkedHover:P,onObservation:z,onClick:$,chartId:L,loading:E,emptyContent:B,legendInteraction:I,legendPosition:D,frameProps:N={},stroke:T,strokeWidth:W,opacity:_}=n,F=null!=y?y:!!x,q=Fn(w),H=s||[],{activeSelectionHook:G,customHoverBehavior:V,customClickBehavior:U}=Kt({selection:R,linkedHover:P,fallbackFields:d?["string"==typeof d?d:""]:[],onObservation:z,onClick:$,chartType:"ProportionalSymbolMap",chartId:L}),Z=Bn(R),Y=Qt(H,d,h),X=t.useMemo(()=>{if(!c)return;const e="function"==typeof c?c:e=>null==e?void 0:e[c],t=H.filter(Boolean).map(t=>e(t)).filter(e=>null!=e&&isFinite(e));return 0!==t.length?[Math.min(...t),Math.max(...t)]:void 0},[H,c]),Q=t.useMemo(()=>{const e=on(e=>({fill:d?Et(e,d,Y):Xt,fillOpacity:.7,stroke:"#fff",strokeWidth:.5,r:c?It(e,c,u,X):6}),{stroke:T,strokeWidth:W,opacity:_});return G?Zt(e,G,Z):e},[d,Y,c,u,X,G,Z,T,W,_]),K=t.useMemo(()=>{if(!d)return[];const e="function"==typeof d?d:e=>null==e?void 0:e[d],t=new Set;for(const n of H){if(!n)continue;const o=e(n);null!=o&&t.add(o+"")}return Array.from(t)},[H,d]),J=function(e,n,o){const[r,i]=t.useState(null),[s,a]=t.useState(new Set),l=t.useCallback(t=>{"highlight"===e&&i(t?t.label:null)},[e]),c=t.useCallback(t=>{"isolate"===e&&a(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]),u=t.useMemo(()=>{if(!e||"none"===e||!n)return null;const t="string"==typeof n?n:null;return"highlight"===e&&null!=r?{isActive:!0,predicate:e=>(t?e[t]:"function"==typeof n?n(e):null)===r}:"isolate"===e&&s.size>0?{isActive:!0,predicate:e=>{const o=t?e[t]:"function"==typeof n?n(e):null;return s.has(o)}}:null},[e,n,r,s]);return{highlightedCategory:"highlight"===e?r:null,isolatedCategories:"isolate"===e?s:new Set,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}(I,d,K),{legend:ee,margin:te,legendPosition:ne}=Jt({data:H,colorBy:d,colorScale:Y,showLegend:i.showLegend,legendPosition:D,userMargin:M,defaults:{top:10,bottom:10,left:10,right:10}}),oe=t.useMemo(()=>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 c?c:null,r=("function"==typeof c?c:e=>e[c])(t),i=e=>"number"==typeof e&&isFinite(e)?Number.isInteger(e)?e.toLocaleString():e.toLocaleString(void 0,{maximumFractionDigits:2}):(null!=e?e:"")+"",s="string"==typeof d?d:null,a=s?null==t?void 0:t[s]:null;return e.jsxs("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:[n&&e.jsx("div",{style:{fontWeight:600,marginBottom:2},children:n}),o&&null!=r&&e.jsxs("div",{children:[e.jsxs("span",{style:{opacity:.7},children:[o,": "]}),i(r)]}),s&&null!=a&&e.jsxs("div",{children:[e.jsxs("span",{style:{opacity:.7},children:[s,": "]}),a+""]}),!n&&!o&&Object.entries(t).filter(([e])=>"data"!==e&&"x"!==e&&"y"!==e&&"time"!==e).slice(0,4).map(([t,n])=>e.jsxs("div",{children:[e.jsxs("span",{style:{opacity:.7},children:[t,": "]}),i(n)]},t))]})},[c,d]),re=Ln(E,i.width,i.height),ie=re?null:$n(s,i.width,i.height,B);En("ProportionalSymbolMap",H,"xAccessor",a),En("ProportionalSymbolMap",H,"yAccessor",l);const se=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(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({projection:p},null!=s&&{points:H}),{xAccessor:a,yAccessor:l,pointStyle:Q}),n.pointIdAccessor&&{pointIdAccessor:n.pointIdAccessor}),q&&{areas:q,areaStyle:A}),null!=f&&{graticule:f}),null!=g&&{fitPadding:g}),F&&{zoomable:!0}),m&&{zoomExtent:m}),b&&{onZoom:b}),null!=v&&{dragRotate:v}),x&&{tileURL:x}),j&&{tileAttribution:j}),k&&{tileCacheSize:k}),{size:[i.width,i.height],margin:te,enableHover:!0,tooltipContent:!1===O?()=>null:Rt(O)||oe}),ee&&{legend:ee,legendPosition:ne}),I&&"none"!==I&&{legendHoverBehavior:J.onLegendHover,legendClickBehavior:J.onLegendClick,legendHighlightedCategory:J.highlightedCategory,legendIsolatedCategories:J.isolatedCategories}),(P||z||$)&&{customHoverBehavior:V}),(z||$)&&{customClickBehavior:U}),S&&S.length>0&&{annotations:S}),i.title&&{title:i.title}),i.description&&{description:i.description}),i.summary&&{summary:i.summary}),void 0!==i.accessibleTable&&{accessibleTable:i.accessibleTable}),C&&{className:C}),null!=n.animate&&{animate:n.animate}),N);return re||ie||e.jsx(Rn,{componentName:"ProportionalSymbolMap",width:i.width,height:i.height,children:e.jsx(At,Object.assign({ref:r},se))})});function Vn(n){const r=tn(n.mode,{width:n.width,height:n.height,showLegend:n.showLegend,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary}),{flows:i,nodes:s,nodeIdAccessor:a="id",xAccessor:l="lon",yAccessor:c="lat",valueAccessor:u="value",projection:d="equalEarth",graticule:h,fitPadding:p,zoomable:f,zoomExtent:g,onZoom:y,dragRotate:m,tileURL:b,tileAttribution:v,tileCacheSize:x,lineType:j="geo",flowStyle:k="basic",areas:w,areaStyle:A={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5},edgeColorBy:O,edgeOpacity:S=.6,edgeWidthRange:M=[1,8],edgeLinecap:C="round",colorScheme:R,showParticles:P,particleStyle:z,tooltip:$,annotations:L,margin:E,className:B,selection:I,linkedHover:D,onObservation:N,onClick:T,chartId:W,loading:_,emptyContent:F,frameProps:q={},stroke:H,strokeWidth:G,opacity:V}=n,U=null!=f?f:!!b,Z=Fn(w),Y=Ut(D),X=Ht({name:(null==I?void 0:I.name)||"__unused__"}),Q=Gt({name:(null==Y?void 0:Y.name)||"hover",fields:(null==Y?void 0:Y.fields)||[]}),K=qt(e=>e.pushObservation),J=I?{isActive:X.isActive,predicate:X.predicate}:null,ee=i||[],te=s||[],ne=Qt(ee,O,R),oe=t.useMemo(()=>{const e=new Map;for(const t of te)e.set(t[a]+"",t);return e},[te,a]),re=t.useMemo(()=>{const e=new Map;for(const t of ee)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},[ee]),ie=t.useCallback(e=>{var t,n;if(D)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"point"===e.type){const e=re.get(t[a]+"");e&&Q.onHover(e)}else Q.onHover(t)}else Q.onHover(null);if(N||K){const o={timestamp:Date.now(),chartType:"FlowMap",chartId:W};if(e){let r=e.data||e.datum||e;Array.isArray(r)&&(r=r[0]);const i=Object.assign(Object.assign({},o),{type:"hover",datum:r||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});N&&N(i),K&&K(i)}else{const e=Object.assign(Object.assign({},o),{type:"hover-end"});N&&N(e),K&&K(e)}}},[D,Q,a,re,N,W,K]),se=t.useCallback(e=>{var t,n,o,r;if(e&&T){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]),T(o,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0})}if(e&&(N||K)){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n={timestamp:Date.now(),chartType:"FlowMap",chartId:W,type:"click",datum:t||{},x:null!==(o=e.x)&&void 0!==o?o:0,y:null!==(r=e.y)&&void 0!==r?r:0};N&&N(n),K&&K(n)}},[T,N,K,W]),ae=t.useMemo(()=>{const e="function"==typeof l?l:e=>e[l],t="function"==typeof c?c:e=>e[c];return ee.map(n=>{if(!n||"object"!=typeof n||null==n.source||null==n.target)return null;const o=oe.get(n.source+""),r=oe.get(n.target+"");return o&&r?Object.assign(Object.assign({},n),{coordinates:[{[l]:e(o),[c]:t(o)},{[l]:e(r),[c]:t(r)}]}):null}).filter(Boolean)},[ee,oe,l,c]),le=t.useMemo(()=>{const e=ee.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?()=>M[0]:o.scaleLinear().domain([Math.min(...e),Math.max(...e)]).range(M)},[ee,u,M]),ce=t.useMemo(()=>e=>{var t;return{stroke:O?Et(e,O,ne):Xt,strokeWidth:le(null!==(t=e[u])&&void 0!==t?t:0),strokeLinecap:C,opacity:S}},[O,ne,le,u,S,C]),ue=Bn(I),de=t.useMemo(()=>{const e=on(ce,{stroke:H,strokeWidth:G,opacity:V});if(!J)return e;const t=Object.assign(Object.assign({},(null==ue?void 0:ue.unselectedStyle)||{}),{fillOpacity:0});return Zt(e,J,Object.assign(Object.assign({},ue||{}),{unselectedStyle:t}))},[ce,J,ue,H,G,V]),he=t.useMemo(()=>on(()=>({fill:"#333",r:5,fillOpacity:.8}),{stroke:H,strokeWidth:G,opacity:V}),[H,G,V]),pe=t.useMemo(()=>t=>{var n,o,r,i,s,l,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===(r=null==t?void 0:t.properties)||void 0===r?void 0:r.NAME)||(null==t?void 0:t.name)||(null==t?void 0:t.NAME)||(null===(s=null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.properties)||void 0===s?void 0:s.name)||(null===(c=null===(l=null==t?void 0:t.data)||void 0===l?void 0:l.properties)||void 0===c?void 0:c.NAME);if(n)return e.jsx("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:e.jsx("div",{style:{fontWeight:600},children:n})})}if(null!=(null==t?void 0:t.source)&&null!=(null==t?void 0:t.target)){const n=t[u];return e.jsxs("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:[e.jsxs("div",{style:{fontWeight:600},children:[t.source," → ",t.target]}),null!=n&&e.jsx("div",{style:{opacity:.7},children:"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[a]);return null!=d?e.jsx("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:e.jsx("div",{style:{fontWeight:600},children:d})}):null},[u,a]),fe=t.useMemo(()=>Object.assign({top:10,right:10,bottom:10,left:10},"number"==typeof E?{top:E,bottom:E,left:E,right:E}:E),[E]),ge=Ln(_,r.width,r.height),ye=ge?null:$n(i,r.width,r.height,F),me=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(Object.assign(Object.assign({projection:d,lines:ae,points:te,xAccessor:l,yAccessor:c,lineDataAccessor:"coordinates",lineType:j,flowStyle:k,lineStyle:de,pointStyle:he},Z&&{areas:Z,areaStyle:A}),null!=h&&{graticule:h}),null!=p&&{fitPadding:p}),U&&{zoomable:!0}),g&&{zoomExtent:g}),y&&{onZoom:y}),null!=m&&{dragRotate:m}),P&&{showParticles:P}),z&&{particleStyle:z}),b&&{tileURL:b}),v&&{tileAttribution:v}),x&&{tileCacheSize:x}),{size:[r.width,r.height],margin:fe,enableHover:!0,tooltipContent:!1===$?()=>null:Rt($)||pe}),(D||N||T)&&{customHoverBehavior:ie}),(N||T)&&{customClickBehavior:se}),L&&L.length>0&&{annotations:L}),r.title&&{title:r.title}),r.description&&{description:r.description}),r.summary&&{summary:r.summary}),void 0!==r.accessibleTable&&{accessibleTable:r.accessibleTable}),B&&{className:B}),null!=n.animate&&{animate:n.animate}),q);return ge||ye||e.jsx(Rn,{componentName:"FlowMap",width:r.width,height:r.height,children:e.jsx(At,Object.assign({},me))})}Gn.displayName="ProportionalSymbolMap",Vn.displayName="FlowMap";const Un=t.forwardRef(function(n,o){const r=tn(n.mode,{width:n.width,height:n.height,showLegend:n.showLegend,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary}),{points:i,lines:s,xAccessor:a="lon",yAccessor:l="lat",nodeIdAccessor:c="id",center:u,costAccessor:d,strength:h=1,lineMode:p="straight",projection:f="mercator",graticule:g,fitPadding:y,zoomable:m,zoomExtent:b,onZoom:v,dragRotate:x,tileURL:j,tileAttribution:k,tileCacheSize:w,transition:A,colorBy:O,colorScheme:S,pointRadius:M=5,tooltip:C,showRings:R=!0,ringStyle:P,showNorth:z=!0,costLabel:$,annotations:L,margin:E,className:B,selection:I,linkedHover:D,onObservation:N,onClick:T,chartId:W,loading:_,emptyContent:F,legendPosition:q,frameProps:H={},stroke:G,strokeWidth:V,opacity:U}=n,Z=null!=m?m:!!j,Y=i||[],{activeSelectionHook:X,customHoverBehavior:Q,customClickBehavior:K}=Kt({selection:I,linkedHover:D,fallbackFields:O?["string"==typeof O?O:""]:[],onObservation:N,onClick:T,chartType:"DistanceCartogram",chartId:W}),J=Bn(I),ee=Qt(Y,O,S),te=t.useMemo(()=>{const e=on(e=>({fill:O?Et(e,O,ee):Xt,fillOpacity:.8,stroke:"#fff",strokeWidth:1,r:M}),{stroke:G,strokeWidth:V,opacity:U});return X?Zt(e,X,J):e},[O,ee,M,X,J,G,V,U]),{legend:ne,margin:oe,legendPosition:re}=Jt({data:Y,colorBy:O,colorScale:ee,showLegend:r.showLegend,legendPosition:q,userMargin:E,defaults:{top:10,bottom:10,left:10,right:10}}),ie=t.useMemo(()=>({center:u,centerAccessor:c,costAccessor:d,strength:h,lineMode:p}),[u,c,d,h,p]),se=t.useMemo(()=>{if(!s)return;const e="function"==typeof a?a:e=>e[a],t="function"==typeof l?l:e=>e[l],n=new Map;for(const e of Y)n.set(e[c]+"",e);return s.map(o=>{if(o.coordinates)return o;const r=n.get(o.source+""),i=n.get(o.target+"");return r&&i?Object.assign(Object.assign({},o),{coordinates:[{[a]:e(r),[l]:t(r)},{[a]:e(i),[l]:t(i)}]}):null}).filter(Boolean)},[s,Y,a,l,c]),ae=t.useMemo(()=>t=>{const n=("function"==typeof d?d:e=>e[d])(t);return e.jsxs("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:[e.jsx("div",{style:{fontWeight:600},children:t[c]||t.name||t.id||"Point"}),null!=n&&e.jsxs("div",{style:{opacity:.7},children:["Cost: ","number"==typeof n?n.toFixed(1):n]})]})},[d,c]),le=t.useRef(null);t.useImperativeHandle(o,()=>({push:e=>{var t;return null===(t=le.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=le.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=le.current)||void 0===t?void 0:t.removePoint(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o,r;const i=null!==(o=null===(n=le.current)||void 0===n?void 0:n.removePoint(e))&&void 0!==o?o:[];for(const e of i)null===(r=le.current)||void 0===r||r.push(t(e));return i},clear:()=>{var e;return null===(e=le.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=le.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}));const[ce,ue]=t.useState(null),de=t.useCallback(()=>{var e,t;const n=null===(t=null===(e=le.current)||void 0===e?void 0:e.getCartogramLayout)||void 0===t?void 0:t.call(e);n&&ue(e=>e&&e.cx===n.cx&&e.cy===n.cy&&e.maxCost===n.maxCost&&e.availableRadius===n.availableRadius?e:n)},[]);t.useEffect(()=>{const e=requestAnimationFrame(de);return()=>cancelAnimationFrame(e)},[de,h,u,r.width,r.height,Y]);const he=t.useMemo(()=>{if(!R||!ce)return[];const{maxCost:e}=ce;if(0>=e)return[];if(Array.isArray(R))return R.filter(t=>t>0&&e>=t);const t="number"==typeof R?R: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},[R,ce]),pe=t.useMemo(()=>{var t,n;if(!ce)return H.foregroundGraphics||null;const{cx:o,cy:r,maxCost:i,availableRadius:s}=ce,a=Object.assign({stroke:"#999",strokeWidth:.8,strokeDasharray:"4,3",labelColor:"#777",labelSize:10},P),l=null!==(t=oe.left)&&void 0!==t?t:10,c=null!==(n=oe.top)&&void 0!==n?n:10;return e.jsxs("g",{children:[he.map(t=>{const n=t/i*s;return e.jsxs("g",{children:[e.jsx("circle",{cx:o+l,cy:r+c,r:n,fill:"none",stroke:a.stroke,strokeWidth:a.strokeWidth,strokeDasharray:a.strokeDasharray,opacity:.5}),e.jsxs("text",{x:o+l+n+3,y:r+c-2,fontSize:a.labelSize,fill:a.labelColor,fontFamily:"system-ui, sans-serif",children:[t,$?" "+$:""]})]},t)}),z&&e.jsxs("g",{transform:`translate(${l+24}, ${c+24})`,children:[e.jsx("circle",{r:16,fill:"white",fillOpacity:.85,stroke:"#bbb",strokeWidth:.8}),e.jsx("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.jsx("text",{y:-12,textAnchor:"middle",fontSize:7,fontWeight:700,fill:"#555",fontFamily:"system-ui, sans-serif",children:"N"}),e.jsx("line",{x1:11,y1:0,x2:13,y2:0,stroke:"#bbb",strokeWidth:.8}),e.jsx("line",{x1:-11,y1:0,x2:-13,y2:0,stroke:"#bbb",strokeWidth:.8}),e.jsx("line",{x1:0,y1:11,x2:0,y2:13,stroke:"#bbb",strokeWidth:.8})]}),H.foregroundGraphics]})},[ce,he,z,$,P,oe,H.foregroundGraphics]),fe=Ln(_,r.width,r.height),ge=fe?null:$n(i,r.width,r.height,F);En("DistanceCartogram",Y,"xAccessor",a),En("DistanceCartogram",Y,"yAccessor",l);const ye=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(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({projection:f},null!=i&&{points:Y}),se&&{lines:se,lineDataAccessor:"coordinates"}),{xAccessor:a,yAccessor:l,pointIdAccessor:c,pointStyle:te,projectionTransform:ie}),A&&{transition:{duration:A}}),null!=g&&{graticule:g}),null!=y&&{fitPadding:y}),Z&&{zoomable:!0}),b&&{zoomExtent:b}),v&&{onZoom:v}),null!=x&&{dragRotate:x}),j&&{tileURL:j}),k&&{tileAttribution:k}),w&&{tileCacheSize:w}),{size:[r.width,r.height],margin:oe,enableHover:!0,tooltipContent:!1===C?()=>null:Rt(C)||ae}),ne&&{legend:ne,legendPosition:re}),(D||N||T)&&{customHoverBehavior:Q}),(N||T)&&{customClickBehavior:K}),L&&L.length>0&&{annotations:L}),r.title&&{title:r.title}),r.description&&{description:r.description}),r.summary&&{summary:r.summary}),void 0!==r.accessibleTable&&{accessibleTable:r.accessibleTable}),B&&{className:B}),null!=n.animate&&{animate:n.animate}),H),pe&&{foregroundGraphics:pe});return fe||ge||e.jsx(Rn,{componentName:"DistanceCartogram",width:r.width,height:r.height,children:e.jsx(At,Object.assign({ref:le},ye))})});Un.displayName="DistanceCartogram",exports.ChoroplethMap=Hn,exports.DistanceCartogram=Un,exports.FlowMap=Vn,exports.ProportionalSymbolMap=Gn,exports.StreamGeoFrame=At,exports.mergeData=function(e,t,n){const{featureKey:o,dataKey:r}=n,i=new Map;for(const e of t)i.set(e[r]+"",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=i.get(t);return n?Object.assign(Object.assign({},e),{properties:Object.assign(Object.assign({},e.properties),n)}):e})},exports.resolveReferenceGeography=_n;
1
+ "use client";
2
+ "use strict";const e=require("react/jsx-runtime"),t=require("react"),n=require("d3-geo"),o=require("d3-scale"),i=require("d3-quadtree"),r=require("d3-array"),l=require("d3-hierarchy"),s=require("d3-shape"),a=require("regression"),c=require("d3-zoom"),u=require("d3-selection");function d(e){return e&&e.__esModule?e:{default:e}}function h(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const f=h(t),p=d(a);class g{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;return{next:()=>this._size>e?{done:!1,value:this.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}update(e,t){const n=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++){const r=(o+i)%this._capacity,l=this.buffer[r];if(e(l)){let e;e="object"!=typeof l||null===l?l:Array.isArray(l)?[...l]:Object.assign({},l),n.push(e),this.buffer[r]=t(l)}}return n}remove(e){const t=[],n=[];if(this.forEach(o=>{e(o)?n.push(o):t.push(o)}),0===n.length)return n;this.buffer=Array(this._capacity),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 y(e,t,n){return e+(t-e)*n}function m(e,t,n){var o,i,r;if(1>=n)return 1;const l=null!==(o=e.minOpacity)&&void 0!==o?o:.1,s=n-1-t;switch(e.type){case"linear":return l+(1-s/(n-1))*(1-l);case"exponential":{const t=null!==(i=e.halfLife)&&void 0!==i?i:n/2;return l+Math.pow(.5,s/t)*(1-l)}case"step":return(null!==(r=e.stepThreshold)&&void 0!==r?r:.5*n)>s?1:l;default:return 1}}const v={mercator:n.geoMercator,equalEarth:n.geoEqualEarth,albersUsa:n.geoAlbersUsa,orthographic:n.geoOrthographic,naturalEarth:n.geoNaturalEarth1,equirectangular:n.geoEquirectangular};function b(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function x(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function j(e,t,n){return e?Object.assign(Object.assign({},n),"function"==typeof e?e(t):e):Object.assign({},n)}function k(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 w(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,s=o/r,a=Math.min(.3*r,80),c=(e[0]+t[0])/2+l*a,u=(e[1]+t[1])/2+s*a,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 O(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 s=Math.sqrt(r*r+l*l)||1;o.push([i[0]+l/s*n,i[1]+-r/s*n])}return o}function M(e,t,n,o,i){const r=t[0]-e[0],l=t[1]-e[1],s=Math.sqrt(r*r+l*l);if(0===s)return[e,t];const a=l/s,c=-r/s,u=i/2+1;return[[e[0]+a*u,e[1]+c*u],[t[0]+a*u,t[1]+c*u]]}class S{constructor(e){this.scene=[],this.scales=null,this.version=0,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this.config=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 g(e),this.timestampBuffer=new g(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}removePoint(e){const{pointIdAccessor:t}=this.config;if(!t)throw Error("removePoint() requires pointIdAccessor to be configured");const n="function"==typeof t?t:e=>e[t],o=new Set(Array.isArray(e)?e:[e]);if(this.streaming&&this.pointBuffer){const e=e=>o.has(n(e)+"");if(this.timestampBuffer&&this.timestampBuffer.size>0){const t=this.timestampBuffer.toArray(),n=new Set;this.pointBuffer.forEach((t,o)=>{e(t)&&n.add(o)}),this.timestampBuffer.clear();for(let e=0;t.length>e;e++)n.has(e)||this.timestampBuffer.push(t[e])}const t=this.pointBuffer.remove(e);return t.length>0&&this.version++,t}{const e=[];return this.pointData=this.pointData.filter(t=>!o.has(n(t)+"")||(e.push(t),!1)),e.length>0&&this.version++,e}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.version++}computeScene(e){const{config:t}=this;this.projection=function(e){if(!e)return n.geoEqualEarth();if("string"==typeof e){const t=v[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),n.geoEqualEarth())}if("object"==typeof e&&"type"in e){const t=v[e.type],o=t?t():n.geoEqualEarth();return e.rotate&&"rotate"in o&&o.rotate(e.rotate),e.center&&"center"in o&&o.center(e.center),o}return e}(t.projection),this.geoPath=n.geoPath(this.projection),this.fitProjection(e),this.geoPath=n.geoPath(this.projection);const o=this.projection;this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(e,t)=>o([e,t]),invertedPoint:(e,t)=>o.invert?o.invert([e,t]):null};const i=this.scene;if(this.scene=this.buildSceneNodes(e),this.rebuildQuadtree(),t.projectionTransform&&this.applyCartogramTransform(t.projectionTransform,e),t.decay&&this.streaming&&this.applyDecay(),t.pulse&&this.streaming&&this.applyPulse(),t.transition&&!this._hasRenderedOnce&&this.scene.length>0&&t.introAnimation){const t=e.width/2,n=e.height/2,o=this.scene.filter(e=>"point"===e.type).map(e=>Object.assign(Object.assign({},e),{x:t,y:n}));o.length>0&&this.startTransition(o)}this._hasRenderedOnce=!0,t.transition&&i.length>0&&this.startTransition(i),this.version++}fitProjection(e){var t,n,o,i,r;const l=this.projection,s=this.config,a=[...this.areas],c=b(s.xAccessor,"lon"),u=b(s.yAccessor,"lat"),d=this.getPoints();if(d.length>0){const e=d.map(e=>[c(e),u(e)]);a.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}const h=x(s.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)]);a.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==a.length){if(s.projectionExtent){const[[t,n],[o,i]]=s.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=s.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=s.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:a})}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 o=this.projection;o&&(o.scale(this.baseScale*e.k),o.translate([this.baseTranslate[0]*e.k+e.x,this.baseTranslate[1]*e.k+e.y]),this.currentZoom=e.k,this.geoPath=n.geoPath(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(e,t)=>o([e,t]),invertedPoint:(e,t)=>o.invert?o.invert([e,t]):null},this.scene=this.buildSceneNodes(t),this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyZoomScale(e,t){const o=this.projection;o&&(o.scale(this.baseScale*e),o.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=n.geoPath(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(e,t)=>o([e,t]),invertedPoint:(e,t)=>o.invert?o.invert([e,t]):null},this.scene=this.buildSceneNodes(t),this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyRotation(e,t){const o=this.projection;o&&o.rotate&&(o.rotate(e),this.geoPath=n.geoPath(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(e,t)=>o([e,t]),invertedPoint:(e,t)=>o.invert?o.invert([e,t]):null},this.scene=this.buildSceneNodes(t),this.rebuildQuadtree(),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}rebuildQuadtree(){let e=0,t=0;for(const n of this.scene)"point"===n.type&&(t++,n.r>e&&(e=n.r));if(this._maxPointRadius=e,S.QUADTREE_THRESHOLD>=t)return void(this._quadtree=null);const n=Array(t);let o=0;for(const e of this.scene)"point"===e.type&&(n[o++]=e);this._quadtree=i.quadtree().x(e=>e.x).y(e=>e.y).addAll(n)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(e){var t,o,i;const r=[],{config:l}=this,s=this.projection,a=this.geoPath,c=b(l.xAccessor,"lon"),u=b(l.yAccessor,"lat"),d=function(e){var t,n;return{fill:(null===(t=e.themeSemantic)||void 0===t?void 0:t.surface)||"#e0e0e0",stroke:(null===(n=e.themeSemantic)||void 0===n?void 0:n.border)||"#999",strokeWidth:.5,fillOpacity:1}}(l),h=function(e){var t;return{stroke:(null===(t=e.themeSemantic)||void 0===t?void 0:t.primary)||"#4e79a7",strokeWidth:1.5,fill:"none"}}(l),f=function(e){var t;return{fill:(null===(t=e.themeSemantic)||void 0===t?void 0:t.primary)||"#4e79a7",r:4,fillOpacity:.8}}(l);if(l.graticule){const t=!0===l.graticule?{}:l.graticule,o=n.geoGraticule();t.step&&o.step(t.step);const i=a(o())||"";i&&r.push({type:"geoarea",pathData:i,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),i=a.area(e),s=j(l.areaStyle,e,d);r.push({type:"geoarea",pathData:t,centroid:n,bounds:o,screenArea:i,style:s,datum:e,interactive:!0})}const p=x(l.lineDataAccessor);for(const t of this.lineData){const o=p(t);if(!o||2>o.length)continue;let i=[];if("geo"===l.lineType){const e=Array(o.length);for(let t=0;o.length>t;t++)e[t]=[c(o[t]),u(o[t])];for(let t=0;e.length-1>t;t++){const o=e[t],r=e[t+1],l=n.geoDistance(o,r)||0,a=Math.max(2,Math.ceil(l/(Math.PI/180))),c=n.geoInterpolate(o,r);for(let e=0;a>=e;e++){if(t>0&&0===e)continue;const n=s(c(e/a));null!=n&&i.push(n)}}}else for(let e=0;o.length>e;e++){const t=o[e],n=s([c(t),u(t)]);null!=n&&i.push(n)}if(2>i.length)continue;const a=j(l.lineStyle,t,h),d="number"==typeof a.strokeWidth?a.strokeWidth:1;2!==o.length||2>i.length||"arc"!==l.flowStyle?2!==o.length||2>i.length||"offset"!==l.flowStyle||(i="geo"===l.lineType?O(i,d):M(i[0],i[i.length-1],0,0,d)):i=w(i[0],i[i.length-1]);const f=k(i,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({},a),{_edgeFade:!0}),datum:t};r.push(n)}else r.push({type:"line",path:2>i.length&&f[0]||i,style:a,datum:t})}const g=this.getPoints(),y=l.pointIdAccessor?"function"==typeof l.pointIdAccessor?l.pointIdAccessor:e=>e[l.pointIdAccessor]:null,m=s.clipAngle&&null!==(t=s.clipAngle())&&void 0!==t?t:0,v=m>0?m*Math.PI/180:null,S=s.rotate?s.rotate():[0,0,0],A="function"==typeof s.center?s.center():[0,0],C=[(null!==(o=A[0])&&void 0!==o?o:0)-S[0],(null!==(i=A[1])&&void 0!==i?i:0)-S[1]];for(let e=0;g.length>e;e++){const t=g[e],o=c(t),i=u(t);if(null!=v&&n.geoDistance([o,i],C)>v)continue;const a=s([o,i]);if(!a)continue;const d=l.pointStyle?l.pointStyle(t):Object.assign({},f),h={type:"point",x:a[0],y:a[1],r:d.r||4,style:d,datum:t,pointId:y?y(t)+"":void 0};r.push(h)}return r}applyCartogramTransform(e,t){var n,i,r;const l=this.scene.filter(e=>"point"===e.type);if(2>l.length)return;const s=null!==(n=e.strength)&&void 0!==n?n:1;if(0===s)return;const a=e.centerAccessor?"function"==typeof e.centerAccessor?e.centerAccessor:t=>t[e.centerAccessor]:e=>e.id,c="function"==typeof e.costAccessor?e.costAccessor:t=>t[e.costAccessor],u=l.find(t=>t.datum&&a(t.datum)+""==e.center+"");if(!u)return void("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${e.center}" not found in point data`));const d=u.x,h=u.y,f=l.map(e=>e.datum?c(e.datum):NaN).filter(e=>isFinite(e)&&e>=0),p=Math.max(...f,1),g=Math.min(t.width,t.height)/2,y=o.scaleLinear().domain([0,p]).range([0,g]);this.cartogramLayout={cx:d,cy:h,maxCost:p,availableRadius:g},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 l){if(e===u)continue;if(!e.datum)continue;const t=Math.atan2(e.y-h,e.x-d),n=Math.sqrt(Math.pow(e.x-d,2)+Math.pow(e.y-h,2)),o=c(e.datum),i=n+((isFinite(o)?y(o):n)-n)*s;e.x=d+Math.cos(t)*i,e.y=h+Math.sin(t)*i}const m=t.width/2,v=t.height/2,b=m-u.x,x=v-u.y;if(Math.abs(b)>.5||Math.abs(x)>.5)for(const e of l)e.x+=b,e.y+=x;this.cartogramLayout={cx:m,cy:v,maxCost:p,availableRadius:g};const j=this.scene.filter(e=>"line"===e.type);if(j.length>0&&"fractional"!==e.lineMode){const e=new Map;for(const t of l)t.pointId&&e.set(t.pointId,[t.x,t.y]);for(const t of j){const n=null===(i=t.datum)||void 0===i?void 0:i.source,o=null===(r=t.datum)||void 0===r?void 0:r.target;if(n&&o){const i=e.get(n+""),r=e.get(o+"");i&&r&&(t.path=[i,r])}}}}applyDecay(){const e=this.config.decay;if(!e||!this.pointBuffer)return;const t=this.pointBuffer.size;if(0===t)return;const n=this.scene.filter(e=>"point"===e.type);for(let o=0;n.length>o;o++){const i=m(e,o,t);n[o]._decayOpacity=i,n[o].style=Object.assign(Object.assign({},n[o].style),{opacity:i})}}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 s=i-l[e];o>s&&(r[e]._pulseIntensity=1-s/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})}cancelIntroAnimation(){this.activeTransition=null}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=y(e.x,e._targetX,n),e.y=y(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 A(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}function C(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function R(e,t){const n=C(e);if(!n)return!1;const o=C(t);return!o||n.getFullYear()!==o.getFullYear()||n.getMonth()!==o.getMonth()}function z(e,t,n,o,i,r,l=0){if(r){const e=function(e,t,n,o,i){const r=Math.max(o,i+5,12),l=t-r,s=t+r,a=n-r,c=n+r;let u=null,d=1/0;return e.visit((e,i,r,h,f)=>{if(i>s||l>h||r>c||a>f)return!0;if(!e.length){let i=e;do{const e=i.data,r=e.x-t,l=e.y-n,s=Math.sqrt(r*r+l*l);A(e.r,o)>=s&&d>s&&(u=e,d=s),i=i.next}while(i)}return!1}),u?{node:u,distance:d}:null}(r,t,n,o,l);if(e)return e}else{let i=null,r=o;for(const l of e){if("point"!==l.type)continue;const e=l.x-t,s=l.y-n,a=Math.sqrt(e*e+s*s);A(l.r,o)>=a&&r>a&&(i=l,r=a)}if(i)return{node:i,distance:r}}for(let o=e.length-1;o>=0;o--){const r=e[o];if("geoarea"!==r.type)continue;const l=r;if(!1===l.interactive)continue;const[[s,a],[c,u]]=l.bounds;if(!(s>t||t>c||a>n||n>u)&&(l._cachedPath2D||(l._cachedPath2D=new Path2D(l.pathData)),i.isPointInPath(l._cachedPath2D,t,n)))return{node:l,distance:0}}let s=null,a=o;for(const o of e){if("line"!==o.type)continue;const e=o,{path:i}=e,r=Math.max((e.style.strokeWidth||2)+4,5);for(let o=0;i.length-1>o;o++){const[l,c]=i[o],[u,d]=i[o+1],h=P(t,n,l,c,u,d);r>=h&&a>h&&(s=e,a=h)}}return s?{node:s,distance:a}:null}function P(e,t,n,o,i,r){const l=i-n,s=r-o,a=l*l+s*s;if(0===a)return Math.sqrt(Math.pow(e-n,2)+Math.pow(t-o,2));let c=((e-n)*l+(t-o)*s)/a;c=Math.max(0,Math.min(1,c));const u=o+c*s;return Math.sqrt(Math.pow(e-(n+c*l),2)+Math.pow(t-u,2))}function L(n){let o=null;const i=()=>(o||(o=t.createContext(null)),o),r=I(n);return[function({children:o,initialState:r}){const l=t.useRef(r),s=t.useMemo(()=>I(n,l.current),[]),a=i();return e.jsx(a.Provider,{value:s,children:o})},e=>{var n;const o=i(),l=null!==(n=t.useContext(o))&&void 0!==n?n:r,s=t.useRef(e);s.current=e;const a=t.useCallback(()=>s.current(l.getState()),[l]),c=t.useCallback(()=>s.current(l.getState()),[l]);return t.useSyncExternalStore(l.subscribe,a,c)}]}function I(e,t){const n=new EventTarget;let o=Object.assign(Object.assign({},e(function(e){o=Object.assign(Object.assign({},o),e(o)),n.dispatchEvent(new Event("update"))})),null!=t?t:{});return{getState:()=>o,subscribe:function(e){return n.addEventListener("update",e),()=>n.removeEventListener("update",e)}}}function E(e){if(!(null==e?void 0:e.colors))return;const t=e.colors;return{primary:t.primary,secondary:t.secondary||t.primary,surface:t.surface||t.background,success:t.success,danger:t.danger,warning:t.warning,error:t.error,info:t.info,text:t.text,textSecondary:t.textSecondary,border:t.border,grid:t.grid}}function D(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t=Object.assign(Object.assign({},t),{colors:Object.assign(Object.assign({},t.colors),{categorical:$})})),e.accessibility.highContrast){const e="dark"===t.mode;t=Object.assign(Object.assign({},t),{colors:Object.assign(Object.assign({},t.colors),{text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"})})}return t}S.QUADTREE_THRESHOLD=500;const $=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],B={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},W={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:10}},T={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:$,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function N(e,t){if("light"===t)return B;if("dark"===t)return W;if("high-contrast"===t)return T;if("string"==typeof t)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${t}". Keeping current theme.`),e;if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?W:B;return D(Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{})}))}return D(Object.assign(Object.assign(Object.assign({},e),t),{colors:Object.assign(Object.assign({},e.colors),t.colors||{}),typography:Object.assign(Object.assign({},e.typography),t.typography||{})}))}const[_,H]=L(e=>({theme:B,setTheme(t){e(e=>({theme:N(e.theme,t)}))}}));const F=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,q=new WeakMap;let G=0,U=!1,V=null,Z=null,Y=null;function X(e,t){var n,o;if(!t)return t;const i=F.exec(t);if(!i)return t;const r=e.canvas;if(!r)return(null===(n=i[2])||void 0===n?void 0:n.trim())||t;!function(){if(U)return;if("undefined"==typeof window||"undefined"==typeof document)return;U=!0;const e=()=>{G++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(V=new MutationObserver(e),V.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{Z=window.matchMedia("(prefers-color-scheme: dark)"),Y=e,"function"==typeof Z.addEventListener?Z.addEventListener("change",Y):"function"==typeof Z.addListener&&Z.addListener(Y)}catch(e){}}();let l=q.get(r);l&&l.version===G||(l={version:G,map:new Map},q.set(r,l));const s=l.map.get(t);if(void 0!==s)return s;const a=getComputedStyle(r).getPropertyValue(i[1]).trim()||(null===(o=i[2])||void 0===o?void 0:o.trim())||t;return l.map.set(t,a),a}const Q="undefined"==typeof window?t.useEffect:t.useLayoutEffect;function K(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function J(e){const n=function(){const[e,n]=t.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return t.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return n(e.matches),function(e,t){return"function"==typeof e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))}(e,e=>n(e.matches))},[]),e}(),o=t.useRef(n);o.current=n;const[i,r]=function(e,n,o){const i=t.useRef(null),[r,l]=t.useState(null);return t.useEffect(()=>{if(!n&&!o)return;const e=i.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;l(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[n,o]),[i,[n&&r?r.w:e[0],o&&r?r.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),l=t.useMemo(()=>Object.assign(Object.assign({},e.marginDefault),e.userMargin),[e.marginDefault,e.userMargin]),s=r[0]-l.left-l.right,a=r[1]-l.top-l.bottom,c=K(e.foregroundGraphics,r,l),u=K(e.backgroundGraphics,r,l),d=H(e=>e.theme),{transition:h,introEnabled:p}=function(e,t){var n,o;if(!1===e)return{transition:void 0,introEnabled:!1};const i="undefined"!=typeof window&&(null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:e?!0===e?{duration:300}:{duration:null!==(o=e.duration)&&void 0!==o?o:300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(i||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),g="semiotic-table-"+f.useId(),y=t.useRef(0),m=t.useRef(()=>{}),v=t.useCallback(()=>{y.current||(y.current=requestAnimationFrame(()=>m.current()))},[]);t.useEffect(()=>()=>{y.current&&(cancelAnimationFrame(y.current),y.current=0)},[]);const b=t.useRef(()=>{}),x=t.useRef(()=>{}),j=t.useRef(null),k=t.useRef(0),w=t.useCallback(()=>{k.current=0;const e=j.current;j.current=null,e&&b.current(e)},[]),O=t.useCallback(e=>{j.current={clientX:e.clientX,clientY:e.clientY},0===k.current&&(k.current=requestAnimationFrame(w))},[w]),M=t.useCallback(()=>{j.current=null,0!==k.current&&(cancelAnimationFrame(k.current),k.current=0),x.current()},[]);t.useEffect(()=>()=>{j.current=null,0!==k.current&&(cancelAnimationFrame(k.current),k.current=0)},[]);const S=e.themeDirtyRef;return Q(()=>{S&&(G++,S.current=!0,v())},[d,v,S]),{reducedMotion:n,reducedMotionRef:o,responsiveRef:i,size:r,margin:l,adjustedWidth:s,adjustedHeight:a,resolvedForeground:c,resolvedBackground:u,currentTheme:d,transition:h,introEnabled:p,tableId:g,rafRef:y,renderFnRef:m,scheduleRender:v,hoverHandlerRef:b,hoverLeaveRef:x,onPointerMove:O,onPointerLeave:M}}const ee={fill:t=>e.jsx("rect",{style:t,width:16,height:16}),line:t=>e.jsx("line",{style:t,x1:0,y1:0,x2:16,y2:16})};function te(e,t,n,o){let i;return i="function"==typeof n?n(e):(0,ee[n])(o(e,t)),i}function ne(){return e.jsx("path",{d:"M4,8.8 L7.2,12 L12.8,4.8",fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function oe(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}const ie=(t,n,o,i,r,l,s,a,c,u)=>{const{type:d="fill",styleFn:h,items:f}=t,p=[];let g=0;const y=!(!n&&!o),m="isolate"===u||void 0===u&&null!=r;return f.forEach((t,u)=>{const v=te(t,u,d,h),b=oe(t,i,r),x=r&&r.size>0&&r.has(t.label);p.push(e.jsxs("g",{transform:`translate(0,${g})`,onClick:n?()=>n(t):void 0,onMouseEnter:o?()=>o(t):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:y?a===l&&u===s?0:-1:void 0,role:y?"option":void 0,"aria-selected":y&&m?x||!1:void 0,"aria-current":y&&!m&&null!=i&&t.label===i||void 0,"aria-label":t.label,onKeyDown:y?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(a,t);const n=null===(o=e.currentTarget.parentElement)||void 0===o?void 0:o.children[t];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:y?e=>{c(a,u),o&&o(t);const n=e.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:y?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:y?"pointer":"default",opacity:b,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[y&&e.jsx("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.jsx(ne,{}),e.jsx("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+u)),g+=22}),p};function re({config:t,orientation:n="vertical",width:o=100}){const{colorFn:i,domain:r,label:l,format:s}=t,a=s||(e=>Math.round(100*e)/100+""),c="grad-legend-"+f.useId();if("horizontal"===n){const t=12,n=Math.min(o,200),s=Math.max(0,(o-n)/2),u=[];for(let t=0;64>=t;t++){const n=t/64;u.push(e.jsx("stop",{offset:100*n+"%",stopColor:i(r[0]+n*(r[1]-r[0]))},t))}return e.jsxs("g",{"aria-label":l||"Gradient legend",children:[e.jsx("defs",{children:e.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:u})}),l&&e.jsx("text",{x:s+n/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:l}),e.jsx("rect",{x:s,y:0,width:n,height:t,fill:`url(#${c})`,rx:2}),e.jsx("text",{x:s,y:t+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[0])}),e.jsx("text",{x:s+n,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[1])})]})}const u=[];for(let t=0;64>=t;t++){const n=t/64;u.push(e.jsx("stop",{offset:100*n+"%",stopColor:i(r[1]-n*(r[1]-r[0]))},t))}return e.jsxs("g",{"aria-label":l||"Gradient legend",children:[l&&e.jsx("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:l}),e.jsx("defs",{children:e.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:u})}),e.jsx("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),e.jsx("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[1])}),e.jsx("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[0])})]})}function le(t){const{legendGroups:n,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:l,legendInteraction:s,title:a="Legend",width:c=100,height:u=20,orientation:d="vertical"}=t,[h,p]=f.useState(0),[g,y]=f.useState(0),m=f.useCallback((e,t)=>{p(e),y(t)},[]),v="vertical"===d?(({legendGroups:t,width:n,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:l,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:c,legendInteraction:u})=>{let d=24;const h=[];return t.forEach((t,f)=>{d+=5,h.push(e.jsx("line",{stroke:"gray",x1:0,y1:d,x2:n,y2:d},"legend-top-line legend-symbol-"+f)),d+=8,t.label&&(d+=16,h.push(e.jsx("text",{y:d,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label},"legend-text-"+f)),d+=8),h.push(e.jsx("g",{className:"legend-item",transform:`translate(0,${d})`,children:ie(t,o,i,r,l,s,a,f,c,u)},"legend-group-"+f)),d+=22*t.items.length+8}),h})({legendGroups:n||[],width:c,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:l,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:m,legendInteraction:s}):(({legendGroups:t,height:n,width:o,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:l,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:d})=>{let h=0;const f=[];t.forEach((t,n)=>{let p=0;t.label&&(p+=16);const g=((t,n,o,i,r,l,s,a,c,u,d)=>{const{type:h="fill",styleFn:f,items:p}=t,g=[];let y=0,m=0;const v=!(!n&&!o),b="isolate"===u||void 0===u&&null!=r;p.forEach((t,u)=>{const x=te(t,u,h,f),j=oe(t,i,r),k=r&&r.size>0&&r.has(t.label),w=26+7*t.label.length;d&&d>0&&y>0&&y+w>d&&(m++,y=0),g.push(e.jsxs("g",{transform:`translate(${y},${22*m})`,onClick:n?()=>n(t):void 0,onMouseEnter:o?()=>o(t):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:v?a===l&&u===s?0:-1:void 0,role:v?"option":void 0,"aria-selected":v&&b?k||!1:void 0,"aria-current":v&&!b&&null!=i&&t.label===i||void 0,"aria-label":t.label,onKeyDown:v?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)+p.length)%p.length;c(a,t);const n=null===(o=e.currentTarget.parentElement)||void 0===o?void 0:o.children[t];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:v?e=>{c(a,u),o&&o(t);const n=e.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:v?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:v?"pointer":"default",opacity:j,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[v&&e.jsx("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"}),x,k&&e.jsx(ne,{}),e.jsx("text",{y:8,x:22,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+u)),y+=w});let x=0,j=0;for(const e of p){const t=26+7*e.label.length;d&&d>0&&j>0&&j+t>d?(x=Math.max(x,j),j=t):j+=t}x=Math.max(x,j);const k=m+1;return{items:g,offset:x,totalRows:k,totalHeight:22*k}})(t,i,r,l,s,a,c,n,u,d,o);p+=g.offset+5,f.push(Object.assign(Object.assign({label:t.label},g),{offset:p,totalRows:g.totalRows,totalHeight:g.totalHeight})),h+=p+12});let p=h>o?0:Math.max(0,(o-h)/2);const g=[];return f.forEach((o,i)=>{const r=t[i];r.label&&(g.push(e.jsx("text",{transform:`translate(${p},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:r.label},"legend-text-"+i)),p+=16),g.push(e.jsx("g",{className:"legend-item",transform:`translate(${p},0)`,children:o.items},"legend-group-"+i)),p+=o.offset+5,t[i+1]&&g.push(e.jsx("line",{stroke:"gray",x1:p,y1:-8,x2:p,y2:(o.totalHeight||n)+0+8},"legend-top-line legend-symbol-"+i)),p+=12}),e.jsx("g",{children:g})})({legendGroups:n||[],title:a,height:u,width:c,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:l,focusedGroupIndex:h,focusedItemIndex:g,onFocusedIndexChange:m,legendInteraction:s}),b=!(!o&&!i);return e.jsxs("g",{role:b?"listbox":void 0,"aria-multiselectable":!(!b||"isolate"!==s&&(void 0!==s||null==l))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==a&&""!==a&&"vertical"===d&&e.jsx("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:a}),v]})}function se(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}function ae(t){const{legend:n,totalWidth:o,totalHeight:i,margin:r,legendPosition:l="right",title:s,legendHoverBehavior:a,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=s?32:8):"bottom"===l?(p=0,g=i-r.bottom+50):(p=o-r.right+10,g=r.top),e.jsx("g",{transform:`translate(${p}, ${g})`,children:(y=n,"object"==typeof y&&null!==y&&"gradient"in y?e.jsx(re,{config:n.gradient,orientation:f?"horizontal":"vertical",width:f?o:100}):se(n)?e.jsx(le,{legendGroups:n.legendGroups,title:"",width:f?o:100,orientation:f?"horizontal":"vertical",customHoverBehavior:a,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):n)});var y}function ce(e){return"string"==typeof e?{type:e}:e}function ue({orient:n,config:o,values:i,scale:l,size:s,length:a}){const c=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}}(o),u="top"===n||"bottom"===n,d=t.useMemo(()=>{if(0===i.length)return null;const t=l.domain(),o=s-8;if("boxplot"===c.type){const t=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)}}(i);if(!t)return null;const{q1:r,median:s,q3:a,whiskerLow:d,whiskerHigh:h}=t,f=Math.min(.5*o,20),p=(o-f)/2+4;if(u){const t=l(r),o=l(a),i=l(s),u=l(d),g=l(h),y="top"===n?-1:1,m=0;return e.jsxs("g",{"data-testid":"marginal-boxplot-"+n,children:[e.jsx("line",{x1:u,y1:m+y*(p+f/2),x2:g,y2:m+y*(p+f/2),stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:u,y1:m+y*p,x2:u,y2:m+y*(p+f),stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:g,y1:m+y*p,x2:g,y2:m+y*(p+f),stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("rect",{x:Math.min(t,o),y:"top"===n?m-p-f:m+p,width:Math.abs(o-t),height:f,fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:i,y1:"top"===n?m-p-f:m+p,x2:i,y2:"top"===n?m-p:m+p+f,stroke:c.fill,strokeWidth:2})]})}{const t=l(r),o=l(a),i=l(s),u=l(d),g=l(h),y="left"===n?-1:1,m=0;return e.jsxs("g",{"data-testid":"marginal-boxplot-"+n,children:[e.jsx("line",{x1:m+y*(p+f/2),y1:u,x2:m+y*(p+f/2),y2:g,stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:m+y*p,y1:u,x2:m+y*(p+f),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:m+y*p,y1:g,x2:m+y*(p+f),y2:g,stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("rect",{x:"left"===n?m-p-f:m+p,y:Math.min(t,o),width:f,height:Math.abs(o-t),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:"left"===n?m-p-f:m+p,y1:i,x2:"left"===n?m-p:m+p+f,y2:i,stroke:c.fill,strokeWidth:2})]})}}const d=r.bin().domain(t).thresholds(c.bins)(i);if(0===d.length)return null;const h=Math.max(...d.map(e=>e.length));if(0===h)return null;if("histogram"===c.type)return e.jsx("g",{"data-testid":"marginal-histogram-"+n,children:d.map((t,i)=>{if(null==t.x0||null==t.x1)return null;const r=t.length/h*o;if(u){const o=l(t.x0),s=l(t.x1)-l(t.x0);return e.jsx("rect",{x:o,y:"top"===n?-4-r:4,width:Math.max(s,.5),height:r,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}{const o=l(t.x0),s=l(t.x1)-l(t.x0);return e.jsx("rect",{x:"left"===n?-4-r:4,y:Math.min(o,o+s),width:r,height:Math.abs(s),fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}})});if("violin"===c.type){const t=o/2+4,i=[];for(const e of d){if(null==e.x0||null==e.x1)continue;const r=e.length/h*(o/2),s=l((e.x0+e.x1)/2);i.push(u?`${s},${"top"===n?-(t-r):t-r}`:`${"left"===n?-(t-r):t-r},${s}`)}for(let e=d.length-1;e>=0;e--){const r=d[e];if(null==r.x0||null==r.x1)continue;const s=r.length/h*(o/2),a=l((r.x0+r.x1)/2);i.push(u?`${a},${"top"===n?-(t+s):t+s}`:`${"left"===n?-(t+s):t+s},${a}`)}return e.jsx("g",{"data-testid":"marginal-violin-"+n,children:e.jsx("polygon",{points:i.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}if("ridgeline"===c.type){const t=[];if(u){const e=0,i=null!=d[0].x0?l(d[0].x0):0;t.push(`M${i},${e}`);for(const e of d){if(null==e.x0||null==e.x1)continue;const i=e.length/h*o,r=l((e.x0+e.x1)/2);t.push(`L${r},${"top"===n?-i-4:i+4}`)}const r=null!=d[d.length-1].x1?l(d[d.length-1].x1):a;t.push(`L${r},${e}`),t.push("Z")}else{const e=0,i=null!=d[0].x0?l(d[0].x0):0;t.push(`M${e},${i}`);for(const e of d){if(null==e.x0||null==e.x1)continue;const i=e.length/h*o,r=l((e.x0+e.x1)/2);t.push(`L${"left"===n?-i-4:i+4},${r}`)}const r=null!=d[d.length-1].x1?l(d[d.length-1].x1):a;t.push(`L${e},${r}`),t.push("Z")}return e.jsx("g",{"data-testid":"marginal-ridgeline-"+n,children:e.jsx("path",{d:t.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}return null},[i,l,c,s,a,n,u,4]);return d?e.jsx("g",{className:"marginal-"+n,"data-testid":"marginal-"+n,children:d}):null}function de(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 he(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 fe(t,n,o,i){if(!t)return e.jsx("g",{className:"annotation-note"});const{label:r,title:l,orientation:s,align:a,wrap:c=120,noWrap:u}=t;if(!r&&!l)return e.jsx("g",{className:"annotation-note"});let d=s;d||(d=Math.abs(n)>Math.abs(o)?"leftRight":"topBottom");let h=a;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]:de(l,c):[],y=r?u?[r]:de(r,c):[],m="leftRight"===d?"end"===f?-4:4:0;let v=0;const b=[],x=i||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";g.length>0&&(b.push(e.jsx("text",{className:"annotation-note-title",fill:x,textAnchor:f,fontWeight:"bold",children:g.map((t,n)=>e.jsx("tspan",{x:m,dy:0===n?0:p,children:t},n))},"annotation-note-title")),v=g.length*p),y.length>0&&b.push(e.jsx("text",{className:"annotation-note-label",fill:x,textAnchor:f,y:v,children:y.map((t,n)=>e.jsx("tspan",{x:m,dy:0===n?0:p,children:t},n))},"annotation-note-label"));let j=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),j=e.jsx("line",{className:"note-line",x1:n,x2:o,y1:0,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}else{const t=(g.length+y.length)*p+(y.length>0?p:0);let n=0,o=t;"bottom"===h?(n=-t,o=0):"middle"===h&&(n=-t/2,o=t/2),j=e.jsx("line",{className:"note-line",x1:0,x2:0,y1:n,y2:o,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}const k=Math.max(0,g.length+y.length-1)*p;let w=0;return"topBottom"===d?w=0>o?-(k+2):18:"leftRight"===d&&(w="middle"===h?-(k+p+(y.length>0&&g.length>0?2:0))/2+8:"bottom"===h||0>o?-(k+2):18),e.jsxs("g",{className:"annotation-note",transform:`translate(${n},${o})`,children:[e.jsx("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0,children:b}),j]})}function pe(t,n,o,i,r){var l;const s=[];switch(t){case"callout-circle":{const t=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);t>0&&s.push(e.jsx("circle",{r:t,fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));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)&&s.push(e.jsx("rect",{width:t,height:i,fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":(null==n?void 0:n.custom)&&s.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;s.push(e.jsx("line",{x1:i,y1:(n.y1||0)-l,x2:i,y2:(n.y2||0)-l,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==(null==n?void 0:n.y)){const i=(n.y||0)-l;s.push(e.jsx("line",{x1:(n.x1||0)-t,y1:i,x2:(n.x2||0)-t,y2:i,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?s.push(e.jsx("line",{x1:(n.x1||0)-t,y1:0,x2:(n.x2||0)-t,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||s.push(e.jsx("line",{x1:0,y1:(n.y1||0)-l,x2:0,y2:(n.y2||0)-l,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));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&&s.push(e.jsx("path",{d:he((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||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return e.jsx("g",{className:"annotation-subject",children:s})}function ge(t,n,o,i,r,l){const s=[];let a=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,s=n-r;if(0!==l||0!==s){const t=Math.abs(l),n=Math.abs(s),u=e/2,d=o/2,h=t*d>n*u?u/t:d/n;a=i+l*h,c=r+s*h}}}else if("bracket"===r&&l){const e=l.width,t=l.height,n=l.depth||30;void 0!==e?(a=e/2,c=n):void 0!==t&&(a=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);a=Math.cos(o)*e,c=Math.sin(o)*e}}if(Math.sqrt(Math.pow(t-a,2)+Math.pow(n-c,2))>.5&&(s.push(e.jsx("line",{x1:a,y1:c,x2:t,y2:n,stroke:i||"var(--semiotic-text-secondary, currentColor)"},"connector-line")),"arrow"===(null==o?void 0:o.end))){const o=10,r=16/180*Math.PI,l=Math.atan2(n-c,t-a);s.push(e.jsx("path",{d:`M${a},${c}L${a+o*Math.cos(l+r)},${c+o*Math.sin(l+r)}L${a+o*Math.cos(l-r)},${c+o*Math.sin(l-r)}Z`,fill:i||"var(--semiotic-text-secondary, currentColor)",stroke:"none"},"connector-arrow"))}return e.jsx("g",{className:"annotation-connector",children:s})}function ye(t){const{x:n=0,y:o=0,dx:i,dy:r,nx:l,ny:s,note:a,connector:c,subject:u,type:d,color:h,className:f,disable:p,events:g={},"data-testid":y}=t,m=new Set(Array.isArray(p)?p:[]);let v=i||0,b=r||0;null!=l&&(v=l-n),null!=s&&(b=s-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.jsxs("g",Object.assign({className:("annotation "+(f||"")).trim(),transform:`translate(${n},${o})`,"data-testid":y},g,{children:[!m.has("connector")&&ge(v,b,c,h,x,u),!m.has("subject")&&pe(x,u,h,n,o),!m.has("note")&&fe(a,v,b,h)]}))}function me(t){var n,o;const{noteData:i}=t,{screenCoordinates:r}=i,l="string"==typeof i.type?i.type:"label",s=i.eventListeners||i.events||{};if(i.coordinates&&r){const t=i.nx||r[0][0]+(null!==(n=i.dx)&&void 0!==n?n:0),s=i.ny||r[0][1]+(null!==(o=i.dy)&&void 0!==o?o:0),a=r.map((n,o)=>{const r=Object.assign({},i,{note:0===o?i.note:{label:""},x:n[0],y:n[1],nx:t,ny:s});return e.jsx(ye,Object.assign({"data-testid":"semiotic-annotation"},r,{type:l}),"multi-annotation-"+o)});return e.jsx("g",{children:a})}const a=i.note||{title:"none",label:i.label},c=`${a.label}-${a.title}-${i.i}`;return e.jsx(ye,Object.assign({"data-testid":"semiotic-annotation",events:s},i,{type:l}),c)}function ve(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 be(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 xe(e,t,n){var o,i,r,l;const s=e.anchor||"fixed";if("latest"===s){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 s=e.data;if(!s||0===s.length)return null;const a=s[s.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=a[e.xAccessor||"x"],h=a[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 a=null,c=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(a=t.x,c=t.y)}if(null!=a&&null!=c||(a=ve(e,n),c=be(e,n)),null!=a&&null!=c)return null===(r=n.stickyPositionCache)||void 0===r||r.set(t,{x:a,y:c}),{x:a,y:c};if("sticky"===s){const e=null===(l=n.stickyPositionCache)||void 0===l?void 0:l.get(t);if(e)return e}return null}function je(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}const ke={linear:s.curveLinear,monotoneX:s.curveMonotoneX,monotoneY:s.curveMonotoneY,step:s.curveStep,stepAfter:s.curveStepAfter,stepBefore:s.curveStepBefore,basis:s.curveBasis,cardinal:s.curveCardinal,catmullRom:s.curveCatmullRom};let we={positions:new Map};const Oe=new Set;function Me(){for(const e of Oe)e()}function Se(e,t){const n=we.positions.get(e);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==t)return;const o=new Map(we.positions);o.delete(e),we={positions:o},Me()}function Ae(e,t){const n=we.positions.get(e);if(!(null==n?void 0:n.locked))return;if(t&&n.sourceId!==t)return;const o=new Map(we.positions);o.delete(e),we={positions:o},Me()}function Ce(){return we}function Re(e){return Oe.add(e),()=>Oe.delete(e)}const ze={positions:new Map};function Pe(){return()=>{}}function Le(){return ze}function Ie(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Ee(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 De(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function $e(e,t){if(2>=e.length)return e;const n=[e[0]];for(let o=1;e.length-1>o;o++)t>Math.abs(e[o].pixel-n[n.length-1].pixel)||n.push(e[o]);const o=e[e.length-1];return t>Math.abs(o.pixel-n[n.length-1].pixel)?n[n.length-1]=o:n.push(o),n}function Be(n){var o,i;const{width:r,height:a,totalWidth:c,totalHeight:u,margin:d,scales:h,showAxes:f,axes:g,xLabel:y,yLabel:m,yLabelRight:v,xFormat:b,yFormat:x,showGrid:j,title:k,legend:w,legendHoverBehavior:O,legendClickBehavior:M,legendHighlightedCategory:S,legendIsolatedCategories:A,legendPosition:C="right",foregroundGraphics:z,marginalGraphics:P,xValues:L,yValues:I,annotations:E,svgAnnotationRules:D,xAccessor:$,yAccessor:B,annotationData:W,pointNodes:T,curve:N,underlayRendered:_,canvasObscuresUnderlay:H=!0,linkedCrosshairName:F,linkedCrosshairSourceId:q,children:G}=n,U=t.useMemo(()=>{var e;if(!f||!h)return[];const t=null==g?void 0:g.find(e=>"bottom"===e.orient),n=(null==t?void 0:t.tickFormat)||b||De,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5,i=h.x.ticks(Math.min(o,Math.max(2,Math.floor(r/70)))),l=i.map(e=>e.valueOf()),s=i.map((e,t)=>({value:e,pixel:h.x(e),label:n(e,t,l)})),a=s.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),c=(null==t?void 0:t.autoRotate)?Math.max(20,Math.min(a+8,55)):Math.max(55,a+8);let u=$e(s,c);if(u.length>1&&(u=u.filter((e,t)=>0===t||e.label+""!=u[t-1].label+"")),(null==t?void 0:t.includeMax)&&u.length>0){const e=h.x.domain()[1],t=h.x(e),o=u[u.length-1].pixel;if(Math.abs(t-o)>1){const i=n(e,u.length,l);c>t-o&&u.length>1&&(u=u.slice(0,-1)),u.push({value:e,pixel:t,label:i})}}return u},[f,h,g,b,r]),V=t.useMemo(()=>{var e;if(!f||!h)return[];const t=null==g?void 0:g.find(e=>"left"===e.orient),n=(null==t?void 0:t.tickFormat)||x||De,o=null!==(e=null==t?void 0:t.ticks)&&void 0!==e?e:5;let i=$e(h.y.ticks(Math.min(o,Math.max(2,Math.floor(a/30)))).map(e=>({value:e,pixel:h.y(e),label:n(e)})),22);if(i.length>1&&(i=i.filter((e,t)=>0===t||e.label+""!=i[t-1].label+"")),(null==t?void 0:t.includeMax)&&i.length>0){const e=h.y.domain()[1],t=h.y(e),o=i[i.length-1].pixel;if(Math.abs(t-o)>1){const r=n(e);22>Math.abs(t-o)&&i.length>1&&(i=i.slice(0,-1)),i.push({value:e,pixel:t,label:r})}}return i},[f,h,g,x,a]),Z=t.useMemo(()=>{var e;if(!f||!h)return[];const t=null==g?void 0:g.find(e=>"right"===e.orient);if(!t)return[];const n=t.tickFormat||x||De,o=null!==(e=t.ticks)&&void 0!==e?e:5;return $e(h.y.ticks(Math.min(o,Math.max(2,Math.floor(a/30)))).map(e=>({value:e,pixel:h.y(e),label:n(e)})),22)},[f,h,g,x,a]),Y=t.useRef(new Map),X=t.useRef(null!==(o=null==E?void 0:E.length)&&void 0!==o?o:0),Q=null!==(i=null==E?void 0:E.length)&&void 0!==i?i:0;X.current!==Q&&(X.current=Q,Y.current=new Map);const K=t.useMemo(()=>{if(!E||0===E.length)return null;const t=function(t,n,o){var i,r,a,c,u,d,h,f,g,y,m,v,b,x,j,k,w,O,M,S,A,C,R,z,P,L,I,E,D,$,B,W,T,N,_,H,F,q,G,U,V,Z,Y,X,Q,K,J,ee;switch(t.type){case"label":{const i=xe(t,n,o);if(!i)return null;const{x:r,y:l}=i;return je(r,l,o)?e.jsx(me,{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}},"ann-"+n):null}case"callout":{const i=xe(t,n,o);if(!i)return null;const{x:r,y:l}=i;return je(r,l,o)?e.jsx(me,{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}},"ann-"+n):null}case"x-threshold":{const i=ve(null!=t.value?Object.assign(Object.assign({},t),{x:t.value}):t,o);if(null==i)return null;const r=t.color||"#f97316",l=t.labelPosition||"top";let s;return s="bottom"===l?(o.height||0)-4:"center"===l?(o.height||0)/2:12,e.jsxs("g",{children:[e.jsx("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.jsx("text",{x:i+4,y:s,fill:r,fontSize:12,fontWeight:"bold",children:t.label})]},"ann-"+n)}case"y-threshold":{const i=be(null!=t.value?Object.assign(Object.assign({},t),{y:t.value}):t,o);if(null==i)return null;const r=t.color||"#f97316",l=t.labelPosition||"right";let s,a;return"left"===l?(s=4,a="start"):"center"===l?(s=(o.width||0)/2,a="middle"):(s=(o.width||0)-4,a="end"),e.jsxs("g",{children:[e.jsx("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.jsx("text",{x:s,y:i-4,textAnchor:a,fill:r,fontSize:12,fontWeight:"bold",children:t.label})]},"ann-"+n)}case"enclose":{const i=(t.coordinates||[]).map(e=>({x:ve(Object.assign(Object.assign({},e),{type:"point"}),o),y:be(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=l.packEnclose(i),s=t.padding||10;return e.jsxs("g",{children:[e.jsx("circle",{cx:r.x,cy:r.y,r:r.r+s,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.jsx("text",{x:r.x,y:r.y-r.r-s-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:t.label})]},"ann-"+n)}case"rect-enclose":{const i=(t.coordinates||[]).map(e=>({x:ve(Object.assign(Object.assign({},e),{type:"point"}),o),y:be(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),s=i.map(e=>e.y),a=Math.min(...l)-r,c=Math.max(...l)+r,u=Math.min(...s)-r,d=Math.max(...s)+r;return e.jsxs("g",{children:[e.jsx("rect",{x:a,y:u,width:c-a,height:d-u,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.jsx("text",{x:(a+c)/2,y:u-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:t.label})]},"ann-"+n)}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={stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return e.jsx("g",{children:r.map((n,i)=>{const r=ve(n,o),s=be(n,o);if(null==r||null==s)return null;const a="function"==typeof t.r?t.r(n):t.r||6,c="function"==typeof t.style?t.style(n):t.style||l;return e.jsx("circle",Object.assign({cx:r,cy:s,r:a},c),"hl-"+i)})},"ann-"+n)}case"bracket":{const i=ve(t,o),r=be(t,o);return e.jsx(me,{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}},"ann-"+n)}case"trend":{const l=o.data||[];if(2>l.length)return null;const s=o.xAccessor||"x",f=o.yAccessor||"y",g=l.map(e=>[e[s],e[f]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>g.length)return null;const y=null!==(r=null===(i=o.scales)||void 0===i?void 0:i.x)&&void 0!==r?r:null===(a=o.scales)||void 0===a?void 0:a.time,m=null!==(u=null===(c=o.scales)||void 0===c?void 0:c.y)&&void 0!==u?u:null===(d=o.scales)||void 0===d?void 0:d.value;if(!y||!m)return null;const v=t.method||"linear";let b;b="loess"===v?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)),s=[];for(let e=0;n>e;e++){const t=i[e],o=i.map(e=>Math.abs(e-t)),a=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===a?0:o[e]/a;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){s.push([t,r[e]]);continue}const g=u*f-d*d;if(1e-12>Math.abs(g))s.push([t,h/u]);else{const e=(u*p-d*h)/g;s.push([t,(h-e*d)/u+e*t])}}return s}(g,null!==(h=t.bandwidth)&&void 0!==h?h:.3):("polynomial"===v?p.default.polynomial(g,{order:t.order||2}):p.default.linear(g)).points;const x=b.map(([e,t])=>`${y(e)},${m(t)}`).join(" "),j=t.color||"#6366f1";return e.jsxs("g",{children:[e.jsx("polyline",{points:x,fill:"none",stroke:j,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.jsx("text",{x:y(b[b.length-1][0])+4,y:m(b[b.length-1][1])-4,fill:j,fontSize:11,children:t.label})]},"ann-"+n)}case"band":{const i=null!==(g=null===(f=o.scales)||void 0===f?void 0:f.y)&&void 0!==g?g:null===(y=o.scales)||void 0===y?void 0:y.value,r=null!==(m=null==i?void 0:i(t.y0))&&void 0!==m?m:0,l=null!==(v=null==i?void 0:i(t.y1))&&void 0!==v?v:o.height||0;return e.jsxs("g",{children:[e.jsx("rect",{x:0,y:Math.min(r,l),width:o.width||0,height:Math.abs(l-r),fill:t.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:t.fillOpacity||.1}),t.label&&e.jsx("text",{x:(o.width||0)-4,y:Math.min(r,l)-4,textAnchor:"end",fill:t.color||"var(--semiotic-primary, #6366f1)",fontSize:11,children:t.label})]},"ann-"+n)}case"envelope":{const i=o.data||[];if(2>i.length)return null;const r=o.xAccessor||"x",l=null!==(x=null===(b=o.scales)||void 0===b?void 0:b.x)&&void 0!==x?x:null===(j=o.scales)||void 0===j?void 0:j.time,a=null!==(w=null===(k=o.scales)||void 0===k?void 0:k.y)&&void 0!==w?w:null===(O=o.scales)||void 0===O?void 0:O.value;if(!l||!a)return null;const c=t.upperAccessor||"upperBounds",u=t.lowerAccessor||"lowerBounds",d=t.filter,h=i.filter(e=>null!=e[c]&&null!=e[u]&&!(d&&!d(e))).sort((e,t)=>e[r]-t[r]);if(2>h.length)return null;const f=ke[o.curve||"linear"]||s.curveLinear,p=s.area().x(e=>l(e[r])).y0(e=>a(e[u])).y1(e=>a(e[c])).curve(f)(h);if(!p)return null;const g=t.fill||"#6366f1";return e.jsxs("g",{children:[e.jsx("path",{d:p,fill:g,fillOpacity:null!==(M=t.fillOpacity)&&void 0!==M?M:.15,stroke:"none"}),t.label&&h.length>0&&e.jsx("text",{x:l(h[h.length-1][r])+4,y:a(h[h.length-1][c])-4,fill:g,fontSize:11,children:t.label})]},"ann-"+n)}case"anomaly-band":{const i=o.data||[];if(2>i.length)return null;const r=o.yAccessor||"y",l=null!==(A=null===(S=o.scales)||void 0===S?void 0:S.x)&&void 0!==A?A:null===(C=o.scales)||void 0===C?void 0:C.time,s=null!==(z=null===(R=o.scales)||void 0===R?void 0:R.y)&&void 0!==z?z:null===(P=o.scales)||void 0===P?void 0:P.value;if(!l||!s)return null;const a=i.map(e=>e[r]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const c=a.reduce((e,t)=>e+t,0)/a.length,u=a.reduce((e,t)=>e+Math.pow(t-c,2),0)/a.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",y=null!==(I=t.fillOpacity)&&void 0!==I?I:.1,m=t.anomalyColor||"#ef4444",v=null!==(E=t.anomalyRadius)&&void 0!==E?E:6,b=s(c+h*d),x=s(f),j=i.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-c)>h*d});return e.jsxs("g",{children:[p&&e.jsx("rect",{x:0,y:Math.min(b,x),width:o.width||0,height:Math.abs(x-b),fill:g,fillOpacity:y}),j.map((t,n)=>{const i=ve(t,o),r=be(t,o);return null==i||null==r?null:e.jsx("circle",{cx:i,cy:r,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5},"anomaly-"+n)}),t.label&&e.jsx("text",{x:(o.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:g,fontSize:11,children:t.label})]},"ann-"+n)}case"forecast":{const i=o.data||[];if(3>i.length)return null;const r=o.xAccessor||"x",l=o.yAccessor||"y",s=null!==($=null===(D=o.scales)||void 0===D?void 0:D.x)&&void 0!==$?$:null===(B=o.scales)||void 0===B?void 0:B.time,a=null!==(T=null===(W=o.scales)||void 0===W?void 0:W.y)&&void 0!==T?T:null===(N=o.scales)||void 0===N?void 0:N.value;if(!s||!a)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=p.default.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,s=(n-l*t)/e;u=e=>s+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)),g=c.reduce((e,t)=>e+t[0],0)/d,y=c.reduce((e,t)=>e+Math.pow(t[0]-g,2),0),m=null!==(_=t.confidence)&&void 0!==_?_:.95,v=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,b=null!==(H=t.steps)&&void 0!==H?H:5,x=c[d-1][0],j=(x-c[0][0])/Math.max(d-1,1),k=[];for(let e=1;b>=e;e++)k.push(x+e*j);const w=[];for(const e of k){const t=u(e),n=f*Math.sqrt(1+1/d+(y>0?Math.pow(e-g,2)/y:0))*v;w.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const O=`M${w.map(e=>`${s(e.x)},${a(e.yUpper)}`).join(" L")} L${w.slice().reverse().map(e=>`${s(e.x)},${a(e.yLower)}`).join(" L")} Z`,M=w.map(e=>`${s(e.x)},${a(e.yCenter)}`).join(" "),S=`${s(x)},${a(u(x))}`,A=t.strokeColor||"#6366f1";return e.jsxs("g",{children:[e.jsx("path",{d:O,fill:t.fill||"#6366f1",fillOpacity:null!==(F=t.fillOpacity)&&void 0!==F?F:.15,stroke:"none"}),e.jsx("polyline",{points:`${S} ${M}`,fill:"none",stroke:A,strokeWidth:null!==(q=t.strokeWidth)&&void 0!==q?q:2,strokeDasharray:null!==(G=t.strokeDasharray)&&void 0!==G?G:"6,3"}),t.label&&w.length>0&&e.jsx("text",{x:s(w[w.length-1].x)+4,y:a(w[w.length-1].yCenter)-4,fill:A,fontSize:11,children:t.label})]},"ann-"+n)}case"widget":{let i=null,r=null;if(null!=t.px&&null!=t.py)i=t.px,r=t.py;else{const e=xe(t,n,o);if(!e)return null;i=e.x,r=e.y}if(null==i||null==r)return null;if(!je(i,r,o))return null;const l=null!==(U=t.dx)&&void 0!==U?U:0,s=null!==(V=t.dy)&&void 0!==V?V:0,a=null!==(Z=t.width)&&void 0!==Z?Z:32,c=null!==(Y=t.height)&&void 0!==Y?Y:32,u=null!==(X=t.content)&&void 0!==X?X:e.jsx("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info",children:"ℹ️"});return e.jsx("foreignObject",{x:i+l-a/2,y:r+s-c/2,width:a,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:e.jsx("div",{style:{width:a,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const i=xe(t,n,o);if(!i)return null;const{x:r,y:l}=i;return e.jsx("text",{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"},children:t.label},"ann-text-"+n)}case"category-highlight":{const i=t.category;if(null==i)return null;const r=null===(Q=o.scales)||void 0===Q?void 0:Q.o,l=null===(K=o.scales)||void 0===K?void 0:K.x,s=null===(J=o.scales)||void 0===J?void 0:J.y,a=(null==r?void 0:r.bandwidth)?r:(null==l?void 0:l.bandwidth)?l:(null==s?void 0:s.bandwidth)?s:null;if(!a)return null;const c=a(i);if(null==c)return null;const u=a.bandwidth(),d=t.color||"var(--semiotic-primary, #4589ff)",h=null!==(ee=t.opacity)&&void 0!==ee?ee:.15,f=t.label;return e.jsxs("g",(o.projection?"vertical"===o.projection:a===l)?{children:[e.jsx("rect",{x:c,y:0,width:u,height:o.height||0,fill:d,fillOpacity:h}),f&&e.jsx("text",{x:c+u/2,y:12,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold",children:f})]}:{children:[e.jsx("rect",{x:0,y:c,width:o.width||0,height:u,fill:d,fillOpacity:h}),f&&e.jsx("text",{x:12,y:c+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold",children:f})]},"ann-"+n)}default:return null}},n={scales:h?{x:h.x,y:h.y,time:h.x,value:h.y}:null,timeAxis:"x",xAccessor:$,yAccessor:B,width:r,height:a,data:W,frameType:"xy",pointNodes:T,curve:N,stickyPositionCache:Y.current};return E.map((e,o)=>{if(D){const i=D(e,o,n);return null!=i?i:t(e,o,n)}return t(e,o,n)}).filter(Boolean)},[E,D,r,a,$,B,W,h,T,N]),J=function(e){var n;const o=t.useSyncExternalStore(e?Re:Pe,e?Ce:Le,e?Ce:Le);return e&&null!==(n=o.positions.get(e))&&void 0!==n?n:null}(F);return t.useEffect(()=>{if(!(null==J?void 0:J.locked)||!F)return;const e=e=>{"Escape"===e.key&&Ae(F)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[null==J?void 0:J.locked,F]),f||k||w||z||P||K&&K.length>0||j||G||J?e.jsxs("svg",{role:"img",width:c,height:u,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[e.jsx("title",{children:"string"==typeof k?k:"XY Chart"}),e.jsx("desc",{children:"string"==typeof k?k+" — XY data visualization":"XY data visualization"}),e.jsxs("g",{transform:`translate(${d.left},${d.top})`,children:[j&&h&&(!_||H)&&(()=>{var t,n;const o=Ie(null===(t=null==g?void 0:g.find(e=>"bottom"===e.orient))||void 0===t?void 0:t.gridStyle),i=Ie(null===(n=null==g?void 0:g.find(e=>"left"===e.orient))||void 0===n?void 0:n.gridStyle);return e.jsxs("g",{className:"stream-grid",children:[U.map((t,n)=>e.jsx("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:a,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"xgrid-"+n)),V.map((t,n)=>e.jsx("line",{x1:0,y1:t.pixel,x2:r,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i},"ygrid-"+n))]})})(),f&&h&&(()=>{const t=null==g?void 0:g.find(e=>"left"===e.orient),n=null==g?void 0:g.find(e=>"bottom"===e.orient),o=!t||!1!==t.baseline,i=!n||!1!==n.baseline,l=(null==t?void 0:t.jaggedBase)||!1,s=(null==n?void 0:n.jaggedBase)||!1,c=null==n?void 0:n.landmarkTicks,u=null==t?void 0:t.landmarkTicks,h="var(--semiotic-border, #ccc)",f="var(--semiotic-text-secondary, var(--semiotic-text, #666))",p="var(--semiotic-text, #333)",b=!!(null==n?void 0:n.autoRotate)&&U.length>1&&(()=>{const e=r/Math.max(U.length-1,1);return U.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})();return e.jsxs("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[(!_||H)&&i&&!s&&e.jsx("line",{x1:0,y1:a,x2:r,y2:a,stroke:h,strokeWidth:1}),(!_||H)&&s&&e.jsx("path",{d:Ee("bottom",r,a),fill:"none",stroke:h,strokeWidth:1}),U.map((t,n)=>{const o=!!c&&("function"==typeof c?c(t.value,n):R(t.value,n>0?U[n-1].value:void 0));return e.jsxs("g",{transform:`translate(${t.pixel},${a})`,children:[e.jsx("line",{y2:5,stroke:h,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{y:b?10:18,textAnchor:b?"end":"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:f,style:{userSelect:"none"},transform:b?"rotate(-45)":void 0,children:t.label}):e.jsx("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:{textAlign:"center",fontSize:10,userSelect:"none"},children:t.label})})]},"xtick-"+n)}),y&&e.jsx("text",{x:r/2,y:a+40,textAnchor:"middle",fontSize:12,fill:p,style:{userSelect:"none"},children:y}),(!_||H)&&o&&!l&&e.jsx("line",{x1:0,y1:0,x2:0,y2:a,stroke:h,strokeWidth:1}),(!_||H)&&l&&e.jsx("path",{d:Ee("left",r,a),fill:"none",stroke:h,strokeWidth:1}),V.map((t,n)=>{const o=!!u&&("function"==typeof u?u(t.value,n):R(t.value,n>0?V[n-1].value:void 0));return e.jsxs("g",{transform:`translate(0,${t.pixel})`,children:[e.jsx("line",{x2:-5,stroke:h,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:o?11:10,fontWeight:o?600:400,fill:f,style:{userSelect:"none"},children:t.label}):e.jsx("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:{textAlign:"right",fontSize:10,userSelect:"none"},children:t.label})})]},"ytick-"+n)}),(()=>{const n=(null==t?void 0:t.label)||m;return n?e.jsx("text",{x:15-d.left,y:a/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(-90, ${15-d.left}, ${a/2})`,style:{userSelect:"none"},children:n}):null})(),(()=>{const t=null==g?void 0:g.find(e=>"right"===e.orient);if(!t||0===Z.length)return null;const n=t.landmarkTicks,o=t.label||v;return e.jsxs(e.Fragment,{children:[!1!==t.baseline&&e.jsx("line",{x1:r,y1:0,x2:r,y2:a,stroke:h,strokeWidth:1}),Z.map((t,o)=>{const i=!!n&&("function"==typeof n?n(t.value,o):R(t.value,o>0?Z[o-1].value:void 0));return e.jsxs("g",{transform:`translate(${r},${t.pixel})`,children:[e.jsx("line",{x2:5,stroke:h,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{x:8,textAnchor:"start",dominantBaseline:"middle",fontSize:i?11:10,fontWeight:i?600:400,fill:f,style:{userSelect:"none"},children:t.label}):e.jsx("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:{textAlign:"left",fontSize:10,userSelect:"none"},children:t.label})})]},"ytick-r-"+o)}),o&&e.jsx("text",{x:r+d.right-15,y:a/2,textAnchor:"middle",fontSize:12,fill:p,transform:`rotate(90, ${r+d.right-15}, ${a/2})`,style:{userSelect:"none"},children:o})]})})()]})})(),K,P&&h&&L&&I&&e.jsxs(e.Fragment,{children:[P.top&&e.jsx("g",{transform:"translate(0, 0)",children:e.jsx(ue,{orient:"top",config:ce(P.top),values:L,scale:h.x,size:d.top,length:r})}),P.bottom&&e.jsx("g",{transform:`translate(0, ${a})`,children:e.jsx(ue,{orient:"bottom",config:ce(P.bottom),values:L,scale:h.x,size:d.bottom,length:r})}),P.left&&e.jsx("g",{transform:"translate(0, 0)",children:e.jsx(ue,{orient:"left",config:ce(P.left),values:I,scale:h.y,size:d.left,length:a})}),P.right&&e.jsx("g",{transform:`translate(${r}, 0)`,children:e.jsx(ue,{orient:"right",config:ce(P.right),values:I,scale:h.y,size:d.right,length:a})})]}),z,J&&J.sourceId!==q&&(null==h?void 0:h.x)&&(()=>{const t=h.x(J.xValue);if(null==t||0>t||t>r)return null;const n=J.locked;return e.jsx("line",{x1:t,y1:0,x2:t,y2:a,stroke:n?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:n?1.5:1,strokeDasharray:n?"6,3":"4,4",pointerEvents:"none"})})(),G]}),k&&e.jsx("text",{x:c/2,y:20,textAnchor:"middle",fontSize:14,fontWeight:"bold",fill:"var(--semiotic-text, #333)",style:{userSelect:"none"},children:"string"==typeof k?k:null}),ae({legend:w,totalWidth:c,totalHeight:u,margin:d,legendPosition:C,title:k,legendHoverBehavior:O,legendClickBehavior:M,legendHighlightedCategory:S,legendIsolatedCategories:A})]}):null}function We(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}const Te="undefined"==typeof window||"undefined"==typeof document,Ne="undefined"!=typeof window?t.useLayoutEffect:t.useEffect,_e=()=>()=>{},He=()=>!1,Fe=()=>!0;function qe(e,t){const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;if(!Object.is(e[o],t[o]))return!1}return!0}function Ge(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function Ue(e){if(null===e||"object"!=typeof e)return!1;if(Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}const Ve=f.createContext(null),Ze={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Ye(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",wedge:"wedges",arc:"arcs",geoarea:"regions"},r=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],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(", ")}`}const Xe=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},Qe={position:"absolute",top:0,left:0,right:0,zIndex:5,padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-text, #333)",background:"var(--semiotic-bg, #fff)",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},Ke={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},Je={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-border, #e0e0e0)",background:"var(--semiotic-bg, #fff)",cursor:"pointer",color:"var(--semiotic-text-secondary, #666)",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},et={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},tt={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-border, #e0e0e0)",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-text-secondary, #666)"},nt={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},ot={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function it({scene:t,chartType:n,tableId:o,chartTitle:i}){var r;const[l,s]=f.useState(!1),a=f.useContext(Ve),c=null!==(r=null==a?void 0:a.visible)&&void 0!==r&&r,u=l||c,d=f.useRef(null),h=i?"Data summary for "+i:o?`Data summary for ${n} ${o}`:"Data summary for "+n,p=f.useCallback(()=>{l||c||s(!0)},[l,c]),g=f.useCallback(e=>{var t;c||(null===(t=d.current)||void 0===t?void 0:t.contains(e.relatedTarget))||s(!1)},[c]);if(!t||0===t.length)return o?e.jsx("span",{id:o,tabIndex:-1,style:Ze}):null;if(!u)return e.jsx("div",{id:o,tabIndex:-1,onFocus:p,style:Ze,role:"region","aria-label":h,children:e.jsxs("button",{type:"button",onClick:()=>s(!0),children:["View data summary (",t.length," elements)"]})});const y=function(e){var t,n,o,i,r,l,s,a,c,u,d,h,f,p,g,y,m,v,b,x,j,k,w,O,M;const S=[];if(!Array.isArray(e))return S;for(const A of e)if(A&&"object"==typeof A)try{switch(A.type){case"point":S.push({label:"Point",values:{x:A.x,y:A.y}});break;case"line":{const e=A.path,t=Array.isArray(A.datum)?A.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&S.push({label:"Line point",values:{x:t[0],y:t[1]}})}break}case"area":{const e=A.topPath,t=Array.isArray(A.datum)?A.datum:[];if(!Array.isArray(e))break;for(let n=0;e.length>n&&t.length>n;n++){const t=e[n];Array.isArray(t)&&S.push({label:"Area point",values:{x:t[0],y:t[1]}})}break}case"rect":{const e=null!=A.datum&&"object"==typeof A.datum?A.datum:{},r=null!==(n=null!==(t=e.category)&&void 0!==t?t:A.group)&&void 0!==n?n:"",l=null!==(i=null!==(o=e.value)&&void 0!==o?o:e.__aggregateValue)&&void 0!==i?i:e.total;S.push({label:"Bar",values:{category:r,value:null!=l?l:""}});break}case"heatcell":S.push({label:"Cell",values:{x:A.x,y:A.y,value:A.value}});break;case"wedge":S.push({label:"Wedge",values:{category:null!==(a=null!==(l=null===(r=A.datum)||void 0===r?void 0:r.category)&&void 0!==l?l:null===(s=A.datum)||void 0===s?void 0:s.label)&&void 0!==a?a:"",value:null!==(u=null===(c=A.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":S.push({label:"Node",values:{id:null!==(h=null===(d=A.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",x:null!==(f=A.cx)&&void 0!==f?f:A.x,y:null!==(p=A.cy)&&void 0!==p?p:A.y}});break;case"arc":S.push({label:"Arc",values:{id:null!==(y=null===(g=A.datum)||void 0===g?void 0:g.id)&&void 0!==y?y:"",x:null!==(m=A.cx)&&void 0!==m?m:A.x,y:null!==(v=A.cy)&&void 0!==v?v:A.y}});break;case"candlestick":S.push({label:"Candlestick",values:{x:A.x,open:A.open,high:A.high,low:A.low,close:A.close}});break;case"geoarea":S.push({label:"Region",values:{name:null!==(w=null!==(j=null===(x=null===(b=A.datum)||void 0===b?void 0:b.properties)||void 0===x?void 0:x.name)&&void 0!==j?j:null===(k=A.datum)||void 0===k?void 0:k.name)&&void 0!==w?w:"",value:null!==(M=null===(O=A.datum)||void 0===O?void 0:O.value)&&void 0!==M?M:""}})}}catch(e){}return S}(t),m=function(e){if(!e||0===e.length)return[];const t=new Set;for(const n of e)if(n&&n.values)for(const e of Object.keys(n.values))t.add(e);const n=[];for(const o of t){const t=[],i=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[o];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&i.add(e+""))}if(t.length>0){let e=t[0],i=t[0],r=0;for(const n of t)e>n&&(e=n),n>i&&(i=n),r+=n;n.push({name:o,count:t.length,numeric:!0,min:e,max:i,mean:r/t.length})}else if(i.size>0){const e=Array.from(i);n.push({name:o,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(y),v=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${Xe(e.min)} to ${Xe(e.max)}, mean ${Xe(e.mean)}.`);else{const t=e.uniqueValues,o=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${o}.`)}return n.join(" ")}(y.length,m),b=y.slice(0,5),x=new Set;for(const e of b)for(const t of Object.keys(e.values))x.add(t);const j=Array.from(x);return e.jsxs("div",{ref:d,id:o,tabIndex:-1,onBlur:g,style:Qe,role:"region","aria-label":h,children:[e.jsx("button",{type:"button",onClick:()=>{c&&a&&a.setVisible(!1),s(!1)},"aria-label":"Close data summary",style:Je,children:"×"}),e.jsx("div",{role:"note",style:Ke,children:v}),e.jsxs("table",{role:"table","aria-label":"Sample data for "+n,style:et,children:[e.jsxs("caption",{style:ot,children:["First ",b.length," of ",y.length," data points"]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:tt,children:"type"}),j.map(t=>e.jsx("th",{style:tt,children:t},t))]})}),e.jsx("tbody",{children:b.map((t,n)=>e.jsxs("tr",{children:[e.jsx("td",{style:nt,children:t.label}),j.map(n=>{return e.jsx("td",{style:nt,children:(o=t.values[n],null==o||""===o?"—":"number"==typeof o?Number.isNaN(o)?"—":Xe(o):"boolean"==typeof o?o?"true":"false":"object"==typeof o?"—":o+"")},n);var o})]},n))})]})]})}function rt({summary:t}){return t?e.jsx("div",{role:"note",style:Ze,children:t}):null}function lt({tableId:t}){return e.jsx("a",{href:"#"+t,style:Ze,onClick:e=>{e.preventDefault();const n=document.getElementById(t);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,Ze)},children:"Skip to data table"})}function st({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.jsx("div",{"aria-live":"polite","aria-atomic":"true",style:Ze,children:n})}const at=Object.freeze([]);function ct(e){if(!e)return at;let t=!1;for(let n=0;e.length>n;n++){const o=e[n];if(null==o||"object"!=typeof o){t=!0;break}}if(!t)return e;const n=[];for(const t of e)null!=t&&"object"==typeof t&&n.push(t);return n}const ut="var(--semiotic-focus, #005fcc)";function dt({active:t,hoverPoint:n,margin:o,size:i,shape:r="circle",width:l,height:s}){if(!t||!n)return null;const a=n.x+o.left,c=n.y+o.top;let u;if("rect"===r&&null!=l&&null!=s){const t=Math.max(l,4),n=Math.max(s,4);u=e.jsx("rect",{x:a-t/2-3,y:c-n/2-3,width:t+6,height:n+6,rx:3,fill:"none",stroke:ut,strokeWidth:2,strokeDasharray:"4,2"})}else u=e.jsx("circle","wedge"===r?{cx:a,cy:c,r:12,fill:"none",stroke:ut,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:a,cy:c,r:8,fill:"none",stroke:ut,strokeWidth:2,strokeDasharray:"4,2"});return e.jsx("svg",{style:{position:"absolute",left:0,top:0,width:i[0],height:i[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}function ht({x:t,y:n,containerWidth:o,containerHeight:i,margin:r,children:l,className:s="stream-frame-tooltip",zIndex:a=1}){const c=f.useRef(null),[u,d]=f.useState(null);f.useLayoutEffect(()=>{const e=c.current;if(!e)return;const t=e.getBoundingClientRect();d(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[l,s,o,i]);let h;return h=u?`translate(${u.width+12>o-t?"calc(-100% - 12px)":"12px"}, ${u.height+12>i-n?"calc(-100% - 4px)":"4px"})`:`translate(${t>.7*o?"calc(-100% - 12px)":"12px"}, ${.3*i>n?"4px":"calc(-100% - 4px)"})`,e.jsx("div",{ref:c,className:s,style:{position:"absolute",left:r.left+t,top:r.top+n,transform:h,pointerEvents:"none",zIndex:a,width:"max-content"},children:l})}function ft(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function pt(e,t,n=.6){var o,i,r,l,s;if(!ft(t))return;const a=null!==(o=t._pulseGlowRadius)&&void 0!==o?o:4,c=t.r+a*t._pulseIntensity,u=null!==(r=null!==(i=t.cx)&&void 0!==i?i:t.x)&&void 0!==r?r:0,d=null!==(s=null!==(l=t.cy)&&void 0!==l?l:t.y)&&void 0!==s?s: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 gt(e,t,n,o=.35){ft(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}function yt(e){switch(e){case"monotoneX":return s.curveMonotoneX;case"monotoneY":return s.curveMonotoneY;case"cardinal":return s.curveCardinal;case"catmullRom":return s.curveCatmullRom;case"step":return s.curveStep;case"stepBefore":return s.curveStepBefore;case"stepAfter":return s.curveStepAfter;case"basis":return s.curveBasis;case"natural":return s.curveNatural;default:return null}}function mt(e,t,n){return null==t?n:"string"!=typeof t?t:X(e,t)||n}function vt(e,t,n,o,i,r){const l=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>l.length)return null;const s=e.createLinearGradient(n,o,i,r);for(const e of l)s.addColorStop(e.offset,e.color);return s}function bt(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 xt(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 s=l[l.length-1];if(0===s)return;const a=Math.min(.2*s,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;a>o&&(r*=o/a),a>s-o&&(r*=(s-o)/a),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 jt(e,t,n,o){const i=e.getContext("2d");if(!i)return null;const r=t[0]*o,l=t[1]*o,s=t[0]+"px",a=t[1]+"px";return e.style.width!==s&&(e.style.width=s),e.style.height!==a&&(e.style.height=a),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 kt(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function wt([e,t,n]){const o=1<<n;return[e-Math.floor(e/o)*o,t,n]}function Ot(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 Mt{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 St{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 s=At(l),a=Ct(l,r.t*s),c=(o[r.lineIndex]||2)/2;r.x=a.x+a.nx*r.offset*c*2,r.y=a.y+a.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 At(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 Ct(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 s=l>0?(t-n)/l:0,a=l>.001?l:1;return{x:e[o-1][0]+i*s,y:e[o-1][1]+r*s,nx:-r/a,ny:i/a}}n+=l}const o=e[e.length-1];return{x:o[0],y:o[1],nx:0,ny:0}}const Rt={top:10,right:10,bottom:10,left:10},zt={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"},Pt={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 Lt(e){return"string"==typeof e?e:"object"==typeof e&&e&&"type"in e?e.type:null}function It(e){return e?e.getContext("2d"):null}function Et({data:t}){var n;if(!t)return null;if(t.properties)return e.jsx("div",{className:"semiotic-tooltip",style:zt,children:e.jsx("div",{style:{fontWeight:600},children:t.properties.name||t.properties.NAME||t.properties.id||"Feature"})});const o=null!==(n=t.data)&&void 0!==n?n:t,i=Object.entries(o).filter(([e])=>"data"!==e&&!e.startsWith("__")).slice(0,3);return e.jsx("div",{className:"semiotic-tooltip",style:zt,children:i.map(([t,n])=>e.jsxs("div",{children:[e.jsxs("span",{style:{opacity:.7},children:[t,": "]}),e.jsx("span",{style:{fontWeight:600},children:n+""})]},t))})}const Dt=t.forwardRef(function(n,o){var i,r,l,a,d,h,f,p,g,y;const{projection:m,projectionExtent:v,fitPadding:b,projectionTransform:x,areas:j,points:k,lines:w,xAccessor:O,yAccessor:M,lineDataAccessor:A,pointIdAccessor:C,lineType:R="geo",flowStyle:P="basic",graticule:L,zoomable:I,zoomExtent:D,onZoom:$,dragRotate:B,showParticles:W,particleStyle:T,tileURL:N,tileAttribution:_,tileCacheSize:H,size:F,width:q,height:G,responsiveWidth:U,responsiveHeight:V,margin:Z,className:Y,background:Q,areaStyle:K,pointStyle:ee,lineStyle:te,colorScheme:ne,enableHover:oe=!0,hoverAnnotation:ie,tooltipContent:re,customClickBehavior:le,customHoverBehavior:se,annotations:ae,decay:ce,pulse:ue,transition:de,animate:he,staleness:fe,backgroundGraphics:pe,foregroundGraphics:ge,title:ye,legend:me,legendPosition:ve,legendHoverBehavior:be,legendClickBehavior:xe,legendHighlightedCategory:je,legendIsolatedCategories:ke,legendCategoryAccessor:we,onCategoriesChange:Oe,showAxes:Me,accessibleTable:Se=!0,description:Ae,summary:Ce}=n,Re=F||[q||600,G||400],ze=t.useRef(!0),Pe=J({sizeProp:Re,responsiveWidth:U,responsiveHeight:V,userMargin:Z,marginDefault:Rt,foregroundGraphics:ge,backgroundGraphics:pe,animate:he,transitionProp:de,themeDirtyRef:ze}),{reducedMotionRef:Le,responsiveRef:Ie,size:Ee,margin:De,adjustedWidth:$e,adjustedHeight:Ve,resolvedForeground:Ze,resolvedBackground:Xe,transition:Qe,introEnabled:Ke,tableId:Je,rafRef:et,renderFnRef:tt,scheduleRender:nt,currentTheme:ot}=Pe,at=function(){const[e,n]=t.useState(!1);return Ne(()=>{n(!0)},[]),e}(),ut=function(){const e=t.useSyncExternalStore(_e,He,Fe);return t.useRef(e).current}(),ft=t.useMemo(()=>Array.isArray(j)?ct(j):j,[j]),At=t.useMemo(()=>ct(k),[k]),Ct=t.useMemo(()=>ct(w),[w]),zt=t.useMemo(()=>null!=B?B:"orthographic"===Lt(m),[B,m]),Dt=t.useMemo(()=>{var e,t;return{projection:m,projectionExtent:v,fitPadding:b,xAccessor:O,yAccessor:M,lineDataAccessor:A,lineType:R,flowStyle:P,areaStyle:K,pointStyle:ee,lineStyle:te,colorScheme:ne,themeSemantic:E(ot),themeSequential:null===(e=null==ot?void 0:ot.colors)||void 0===e?void 0:e.sequential,themeDiverging:null===(t=null==ot?void 0:ot.colors)||void 0===t?void 0:t.diverging,graticule:L,projectionTransform:x,decay:ce,pulse:ue,transition:Qe,introAnimation:Ke,annotations:ae,pointIdAccessor:C}},[m,v,b,O,M,A,R,P,K,ee,te,ne,L,x,ce,ue,null==Qe?void 0:Qe.duration,null==Qe?void 0:Qe.easing,Ke,ae,C,ot]),$t=function(e){const n=t.useRef(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return Ge(e,t);if(!Ue(e)||!Ue(t))return!1;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;const n=e[o],i=t[o];if(!Object.is(n,i))if(Array.isArray(n)&&Array.isArray(i)){if(!Ge(n,i))return!1}else{if(!Ue(n)||!Ue(i))return!1;if(!qe(n,i))return!1}}return!0}(n.current,e)||(n.current=e),n.current}(Dt),Bt=t.useRef(null);Bt.current||(Bt.current=new S($t));const Wt=t.useRef(null),Tt=t.useRef(null),Nt=t.useRef(null),_t=t.useRef(null),Ht=t.useRef(null);N&&!Ht.current&&(Ht.current=new Mt(H||256));const Ft=t.useRef(ae),qt=t.useRef(null),Gt=t.useRef(c.zoomIdentity),Ut=t.useRef(!1),Vt=t.useRef(null),Zt=t.useCallback(e=>{Vt.current=e,Ie&&"object"==typeof Ie&&(Ie.current=e)},[Ie]),Yt=t.useRef(null),Xt=t.useRef(null),Qt=t.useRef(null),Kt=t.useRef(0);if(W&&!Qt.current){const e=null!==(i=null==T?void 0:T.maxPerLine)&&void 0!==i?i:30;Qt.current=new St(50*e)}const Jt=t.useRef(null),en=t.useRef(null),[tn,nn]=t.useState(null),[on,rn]=t.useState(0),[ln,sn]=t.useState(!1),an=t.useRef([]),cn=t.useRef(we),un=t.useRef(Oe);cn.current=we,un.current=Oe;const dn=t.useCallback(()=>{var e,t;const n=cn.current,o=un.current;if(!o||!n)return;const i=function(e,t){if(!t)return[];const n=new Set,o=[];for(const i of e){if(!i||"object"!=typeof i)continue;const e="function"==typeof t?t(i):i[t];if(null==e)continue;const r=e+"";n.has(r)||(n.add(r),o.push(r))}return o}(null!==(t=null===(e=Bt.current)||void 0===e?void 0:e.getPoints())&&void 0!==t?t:[],n);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(i,an.current)||(an.current=i,o(i))},[]);t.useEffect(()=>{var e;null===(e=Bt.current)||void 0===e||e.updateConfig($t),ze.current=!0,nt()},[$t,nt]),t.useEffect(()=>{const e=Bt.current;e&&(ft&&e.setAreas(ft),k&&e.setPoints(At),w&&e.setLines(Ct),ze.current=!0,nt())},[ft,k,At,w,Ct,nt]);const hn=t.useCallback(e=>{var t;null!=e&&"object"==typeof e&&(null===(t=Bt.current)||void 0===t||t.pushPoint(e),ze.current=!0,nt())},[nt]),fn=t.useCallback(e=>{var t;const n=ct(e);0!==n.length&&(null===(t=Bt.current)||void 0===t||t.pushMany(n),ze.current=!0,nt())},[nt]),pn=t.useCallback(()=>{var e;null===(e=Bt.current)||void 0===e||e.clear(),ze.current=!0,nt()},[nt]);t.useImperativeHandle(o,()=>({push:hn,pushMany:fn,removePoint:e=>{var t,n;const o=null!==(n=null===(t=Bt.current)||void 0===t?void 0:t.removePoint(e))&&void 0!==n?n:[];return o.length>0&&(ze.current=!0,nt()),o},clear:pn,getProjection:()=>{var e,t,n;return null!==(n=null===(t=null===(e=Bt.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=Bt.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=Bt.current)||void 0===e?void 0:e.cartogramLayout)&&void 0!==t?t:null},getZoom:()=>Gt.current.k,resetZoom:()=>{const e=Vt.current;e&&qt.current&&u.select(e).call(qt.current.transform,c.zoomIdentity)},getData:()=>{var e,t;return null!==(t=null===(e=Bt.current)||void 0===e?void 0:e.getPoints())&&void 0!==t?t:[]}}),[hn,fn,pn,nt]);const{hoverHandlerRef:gn,onPointerMove:yn,onPointerLeave:mn}=Pe;t.useEffect(()=>{gn.current=e=>{if(!oe)return;const t=Bt.current;if(!t||!t.scene.length)return;const n=Tt.current;if(!n)return;const o=n.getBoundingClientRect(),i=e.clientX-o.left-De.left,r=e.clientY-o.top-De.top;if(0>i||i>$e||0>r||r>Ve)return Jt.current=null,en.current=null,nn(null),null==se||se(null),void nt();_t.current||(_t.current="undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"));const l=It(_t.current);if(!l)return;const s=z(t.scene,i,r,30,l,t.quadtree,t.maxPointRadius);if(s){const e=s.node,t=e.datum,n=Array.isArray(t)?null:(null==t?void 0:t.properties)?t:(null==t?void 0:t.data)||t;let o,l;"point"===e.type?(o=e.x,l=e.y):"geoarea"===e.type?(o=e.centroid[0],l=e.centroid[1]):(o=i,l=r);const a=Object.assign(Object.assign(Object.assign({},n),(null==n?void 0:n.properties)||{}),{data:n,properties:null==n?void 0:n.properties,__semioticHoverData:!0,x:o,y:l});Jt.current=a,en.current=e,nn(a),null==se||se(a),nt()}else Jt.current&&(Jt.current=null,en.current=null,nn(null),null==se||se(null),nt())}},[oe,$e,Ve,De,se,nt]),Pe.hoverLeaveRef.current=()=>{Jt.current=null,en.current=null,nn(null),null==se||se(null),nt()};const vn=t.useCallback(e=>{if(!le)return;const t=Bt.current;if(!t||!t.scene.length)return;const n=e.currentTarget.getBoundingClientRect(),o=e.clientX-n.left-De.left,i=e.clientY-n.top-De.top;_t.current||(_t.current="undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"));const r=It(_t.current);if(!r)return;const l=z(t.scene,o,i,30,r,t.quadtree,t.maxPointRadius);if(l){const e=l.node.datum,t=Array.isArray(e)?null:(null==e?void 0:e.properties)?e:(null==e?void 0:e.data)||e,n=(null==t?void 0:t.properties)?Object.assign(Object.assign({},t),t.properties):t;le(Object.assign(Object.assign({},n),{data:t,properties:null==t?void 0:t.properties,__semioticHoverData:!0,x:o,y:i,time:o,value:i}))}},[le,De]),bn=t.useRef(-1),xn=t.useRef(null),jn=t.useCallback(e=>{const t=Bt.current;if(!t||0===t.scene.length)return;const n=function(e){const t=[];for(const n of e)"point"===n.type&&null!=n.x?t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle"}):"geoarea"===n.type&&n.centroid&&t.push({x:n.centroid[0],y:n.centroid[1],datum:n.datum,shape:"circle"});return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.scene);if(0===n.length)return;const o=bn.current,i=function(e,t,n){switch(e){case"ArrowRight":case"ArrowDown":return n-1>t?t+1:t;case"ArrowLeft":case"ArrowUp":return t>0?t-1:t;case"PageDown":return Math.min(t+Math.max(1,Math.floor(.1*n)),n-1);case"PageUp":return Math.max(t-Math.max(1,Math.floor(.1*n)),0);case"Home":return 0;case"End":return n-1;case"Escape":return-1;default:return null}}(e.key,0>o?-1:o,n.length);if(null===i)return;if(e.preventDefault(),0>i)return bn.current=-1,xn.current=null,Jt.current=null,en.current=null,nn(null),null==se||se(null),void nt();const r=0>o?0:i;bn.current=r;const l=n[r];xn.current={shape:l.shape,w:l.w,h:l.h};const s=l.datum,a=Object.assign(Object.assign(Object.assign({},s||{}),(null==s?void 0:s.properties)||{}),{data:s,properties:null==s?void 0:s.properties,x:l.x,y:l.y,__semioticHoverData:!0});Jt.current=a,nn(a),null==se||se(a),nt()},[se,nt]),kn=t.useCallback(e=>{bn.current=-1,xn.current=null,yn(e)},[yn]);tt.current=()=>{var e,t,n,o,i,r,l,a;et.current=0;const c=Tt.current,u=Bt.current;if(!c||!u)return;const d=performance.now();let h=!1;const f=Xt.current;f&&(Xt.current=null,u.applyRotation(f,{width:$e,height:Ve}));const p=u.advanceTransition(Le.current?d+1e6:d),g=!Le.current&&p;if(ze.current&&!p){const e={width:$e,height:Ve},t=zt?u.getRotation():null;u.computeScene(e);const n=Gt.current,o=1!==n.k||0!==n.x||0!==n.y;zt&&t?o?(u.setRotation(t),u.applyZoomScale(n.k,e)):u.applyRotation(t,e):o&&u.applyZoomTransform(n,e),ze.current=!1,c.setAttribute("aria-label",Ye(u.scene,"Geographic chart")),dn()}const y=kt();if(N&&Ht.current){const t=Wt.current;if(t&&(null===(e=u.scales)||void 0===e?void 0:e.projection)){const e=jt(t,Ee,De,y);if(e){e.clearRect(-De.left,-De.top,Ee[0],Ee[1]),e.save(),e.beginPath(),e.rect(0,0,$e,Ve),e.clip();const t=function(e,t){const{tileURL:n,projection:o,width:i,height:r,tileCache:l,onTileLoad:s}=t,a=o.scale(),c=o.translate(),u=function(e){const{size:t,scale:n,translate:o,clampX:i=!0,clampY:r=!0}=e,l=Math.max(Math.log(n)/Math.LN2-8,0),s=Math.round(l),a=1<<s,c=Math.pow(2,l-s+8),u=o[0]-n/2,d=o[1]-n/2,h=Math.max(i?0:-1/0,Math.floor((0-u)/c)),f=Math.min(i?a:1/0,Math.ceil((t[0]-u)/c)),p=Math.max(r?0:-1/0,Math.floor((0-d)/c)),g=Math.min(r?a:1/0,Math.ceil((t[1]-d)/c)),y=[];for(let e=p;g>e;++e)for(let t=h;f>t;++t)y.push([t,e,s]);return{tiles:y,translate:[u/c,d/c],scale:c}}({size:[i,r],scale:2*a*Math.PI,translate:c}),d=kt();let h=!0;for(const t of u.tiles){const[o,i,r]=wt(t),a=`${r}/${o}/${i}`;let c=l.get(a);if(!c){const e=new Image;e.crossOrigin="anonymous";const t={img:e,loaded:!1,key:a,lastUsed:performance.now()};l.set(a,t),e.onload=()=>{t.loaded=!0,null==s||s()},e.onerror=()=>{t.loaded=!0},e.src=Ot(n,r,o,i,d),c=t}if(!c.loaded){h=!1;continue}const f=u.scale;e.drawImage(c.img,(t[0]+u.translate[0])*f-.5,(t[1]+u.translate[1])*f-.5,f+1,f+1)}return h}(e,{tileURL:N,projection:u.scales.projection,width:$e,height:Ve,tileCache:Ht.current,onTileLoad:()=>nt()});e.restore(),t||(h=!0)}}}const m=jt(c,Ee,De,y);if(!m)return;if(m.clearRect(-De.left,-De.top,Ee[0],Ee[1]),Q&&!N){const e=X(m,Q);e&&(m.fillStyle=e,m.fillRect(0,0,$e,Ve))}m.save(),m.beginPath(),m.rect(0,0,$e,Ve),m.clip();const v=u.scene,b={width:$e,height:Ve};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=X(e,t.style.stroke)||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)}gt(e,t,r),e.globalAlpha=1,e.setLineDash([])}}(m,v),((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 c=a._introClipFraction;void 0!==c&&1>c&&(e.save(),e.beginPath(),e.rect(0,0,o.width*c,o.height),e.clip());const u=a.style.stroke||"#007bff",d=X(e,u)||u,h=a.style.strokeWidth||2,f=a.colorThresholds,p=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=h,e.lineCap=a.style.strokeLinecap||"butt",a.style._edgeFade){const v=null!==(i=a.style.opacity)&&void 0!==i?i:1;xt(e,a.path,d,h,v,a.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const g=yt(a.curve),y=f&&f.length>0&&p&&p.length===a.path.length,m=a._decayOpacities;if(m&&m.length===a.path.length&&!y){e.strokeStyle=d;const b=null!==(r=a.style.opacity)&&void 0!==r?r:1;for(let x=0;a.path.length-1>x;x++)e.globalAlpha=.5*(m[x]+m[x+1])*b,e.beginPath(),e.moveTo(a.path[x][0],a.path[x][1]),e.lineTo(a.path[x+1][0],a.path[x+1][1]),e.stroke()}else if(y){let j=null,k=null,w=null,O=null,M=!1;function S(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),M=!0}function A(){M&&(e.stroke(),M=!1)}for(let C=0;a.path.length>C;C++){const[R,z]=a.path[C],P=p[C],L=bt(P,f,d);if(null!==j&&null!==O&&null!==w){if(L===O)e.lineTo(R,z);else{const I=[];for(const E of f){const D=E.value;(w>D||D>P)&&(D>w||P>D)||w===D||P===D||I.push({t:(D-w)/(P-w)})}I.sort((e,t)=>e.t-t.t);for(const $ of I){const B=j+(R-j)*$.t,W=k+(z-k)*$.t,T=bt(w+(P-w)*Math.min($.t+1e-4,1),f,d);e.lineTo(B,W),A(),S(T,B,W)}e.lineTo(R,z)}j=R,k=z,w=P,O=L}else S(L,R,z),j=R,k=z,w=P,O=L}A()}else{e.beginPath();const N=a.strokeGradient&&a.path.length>=2?vt(e,a.strokeGradient,a.path[0][0],0,a.path[a.path.length-1][0],0):null;if(e.strokeStyle=N||d,g)s.line().x(e=>e[0]).y(e=>e[1]).curve(g).context(e)(a.path);else{const[_,H]=a.path[0];e.moveTo(_,H);for(let F=1;a.path.length>F;F++)e.lineTo(a.path[F][0],a.path[F][1])}e.stroke()}if(a.style.fill&&a.style.fillOpacity&&a.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=a.style.fillOpacity,e.fillStyle=mt(e,a.style.fill,a.style.fill),g&&!y)s.line().x(e=>e[0]).y(e=>e[1]).curve(g).context(e)(a.path);else{const[G,U]=a.path[0];e.moveTo(G,U);for(let V=1;a.path.length>V;V++)e.lineTo(a.path[V][0],a.path[V][1])}const q=a.path[0][0];e.lineTo(a.path[a.path.length-1][0],o.height),e.lineTo(q,o.height),e.closePath(),e.fill()}void 0!==c&&1>c&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}})(m,v,0,b),((e,t)=>{var n;const o=t.filter(e=>"point"===e.type);if(0!==o.length){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=mt(e,t.style.fill,"#4e79a7"),e.fill(),t.style.stroke&&(e.strokeStyle=mt(e,t.style.stroke,t.style.stroke),e.lineWidth=t.style.strokeWidth||1,e.stroke()),pt(e,t),e.globalAlpha=1}}finally{e.restore()}}})(m,v),W&&Qt.current){const e=Qt.current,s=v.filter(e=>"line"===e.type);if(s.length>0){const a=T||{},c=.3*(null!==(t=a.speedMultiplier)&&void 0!==t?t:1),u=null!==(n=a.maxPerLine)&&void 0!==n?n:30,f=null!==(o=a.spawnRate)&&void 0!==o?o:.15,p=null!==(i=a.radius)&&void 0!==i?i:2,g=null!==(r=a.opacity)&&void 0!==r?r:.7,y=d/1e3,v=Kt.current>0?Math.min(y-Kt.current,.1):.016;Kt.current=y;const b=s.map(e=>e.path),x=s.map(e=>e.style.strokeWidth||2);for(let t=0;s.length>t;t++)Math.random()<f&&e.countForLine(t)<u&&e.spawn(t);e.step(v,c,b,x),m.globalAlpha=g;for(let t=0;e.particles.length>t;t++){const n=e.particles[t];if(!n.active)continue;const o=s[n.lineIndex],i="function"==typeof a.color?a.color(null!==(l=null==o?void 0:o.datum)&&void 0!==l?l:{}):"source"!==a.color&&a.color?a.color:(null==o?void 0:o.style.stroke)||"#fff";m.beginPath(),m.arc(n.x,n.y,p,0,2*Math.PI),m.fillStyle=i,m.fill()}m.globalAlpha=1,h=!0}}m.restore();const x=Nt.current;if(x){const e=jt(x,Ee,De,y);if(e){e.clearRect(-De.left,-De.top,Ee[0],Ee[1]);const t=en.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,o="object"==typeof ie?ie:void 0,i=(null==o?void 0:o.pointColor)||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const n="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||n||null:n||t.stroke||null}(t);e.beginPath(),e.arc(n.x,n.y,n.r+3,0,2*Math.PI),i?(e.save(),e.globalAlpha=.4,e.fillStyle=i,e.fill(),e.restore()):(e.fillStyle="rgba(255, 255, 255, 0.4)",e.fill()),e.strokeStyle=i||"rgba(0, 0, 0, 0.5)",e.lineWidth=2,e.stroke()}}}if(fe){const e=performance.now()-u.lastIngestTime>(null!==(a=fe.threshold)&&void 0!==a?a:5e3);e!==ln&&sn(e)}const j=ae!==Ft.current;j&&(Ft.current=ae),(ze.current||j)&&rn(e=>e+1),(g||null!=u.activeTransition||u.hasActivePulses||h)&&(et.current=requestAnimationFrame(()=>tt.current()))},function(e){const{hydrated:n,wasHydratingFromSSR:o,storeRef:i,dirtyRef:r,renderFnRef:l,cleanup:s}=e;Ne(()=>{var e,t;n&&o&&(null===(t=null===(e=i.current)||void 0===e?void 0:e.cancelIntroAnimation)||void 0===t||t.call(e)),r.current=!0,l.current()},[n,o]);const a=t.useRef(s);a.current=s,t.useEffect(()=>()=>{var e;return null===(e=a.current)||void 0===e?void 0:e.call(a)},[])}({hydrated:at,wasHydratingFromSSR:ut,storeRef:Bt,dirtyRef:ze,renderFnRef:tt,cleanup:()=>{var e;return null===(e=Ht.current)||void 0===e?void 0:e.clear()}}),t.useEffect(()=>{ze.current=!0,nt()},[$e,Ve,Q,nt]),function(e,n,o,i,r,l){t.useEffect(()=>{if(!e)return;const t=setInterval(()=>{var t;const s=n.current;if(!s||0===s.lastIngestTime)return;const a="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(t=e.threshold)&&void 0!==t?t:5e3,u=a-s.lastIngestTime>c;u!==r&&(l(u),o.current=!0,i())},1e3);return()=>clearInterval(t)},[e,r,i])}(fe,Bt,ze,nt,ln,sn),t.useEffect(()=>{if("production"!==process.env.NODE_ENV&&N){const e=Lt(m);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.`)}},[N,m]),t.useEffect(()=>{const e=Vt.current;if(!I||!e)return qt.current&&e&&(u.select(e).on(".zoom",null),qt.current=null),void(e&&u.select(e).on("mousedown.rotate",null).on("touchstart.rotate",null));const[t,n]=D||[1,8],o={width:$e,height:Ve};if(zt){let i=Gt.current.k;const r=e=>{var r;i=Math.max(t,Math.min(n,e)),Gt.current=c.zoomIdentity.scale(i);const l=Bt.current;l&&(l.applyZoomScale(i,o),ze.current=!1,nt(),(null===(r=l.scales)||void 0===r?void 0:r.projection)&&(null==$||$({projection:l.scales.projection,zoom:l.currentZoom})))};qt.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))},s=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",s);const a=.4,u=t=>{if(0!==t.button)return;const n=t.target;if(n.closest("button")||n.closest(".stream-geo-zoom-controls"))return;const o=Bt.current;if(!o)return;const i=o.getRotation();Yt.current={x:t.clientX,y:t.clientY,rotation:[...i]},e.setPointerCapture(t.pointerId),t.preventDefault()},d=e=>{const t=Yt.current;t&&(Xt.current=[t.rotation[0]+(e.clientX-t.x)*a,Math.max(-90,Math.min(90,t.rotation[1]-(e.clientY-t.y)*a)),t.rotation[2]],nt())},h=t=>{var n;if(!Yt.current)return;Yt.current=null,e.releasePointerCapture(t.pointerId);const i=Xt.current;if(i){Xt.current=null;const e=Bt.current;e&&(e.applyRotation(i,o),nt())}const r=Bt.current;(null===(n=null==r?void 0:r.scales)||void 0===n?void 0:n.projection)&&(null==$||$({projection:r.scales.projection,zoom:r.currentZoom}))};return e.addEventListener("pointerdown",u),e.addEventListener("pointermove",d),e.addEventListener("pointerup",h),e.addEventListener("pointercancel",h),()=>{e.removeEventListener("wheel",l),e.removeEventListener("dblclick",s),e.removeEventListener("pointerdown",u),e.removeEventListener("pointermove",d),e.removeEventListener("pointerup",h),e.removeEventListener("pointercancel",h),qt.current=null}}const i=c.zoom().scaleExtent([t,n]).extent([[0,0],[Ee[0],Ee[1]]]).translateExtent([[-1/0,-1/0],[1/0,1/0]]).on("zoom",e=>{const t=e.transform;Gt.current=t,Ut.current=!0;const n=Bt.current;n&&(n.applyZoomTransform(t,o),ze.current=!1,nt())}).on("end",e=>{var t;Gt.current=e.transform,Ut.current=!1;const n=Bt.current;(null===(t=null==n?void 0:n.scales)||void 0===t?void 0:t.projection)&&(null==$||$({projection:n.scales.projection,zoom:n.currentZoom}))});return qt.current=i,u.select(e).call(i),()=>{u.select(e).on(".zoom",null)}},[I,D,zt,Ee,$e,Ve,De,$,nt]);const wn=oe&&!1!==ie,On=wn&&tn?re?re(tn):e.jsx(Et,{data:tn}):null,Mn=On?e.jsx(ht,{x:tn.x,y:tn.y,containerWidth:$e,containerHeight:Ve,margin:De,className:"stream-frame-tooltip",zIndex:10,children:On}):null;if(Te||!at&&ut){const t=Bt.current;t&&(ft||k||w)&&(ft&&t.setAreas(ft),k&&t.setPoints(At),w&&t.setLines(Ct),t.computeScene({width:$e,height:Ve}));const n=null!==(r=null==t?void 0:t.scene)&&void 0!==r?r:[];return e.jsxs("div",{ref:Zt,className:"stream-geo-frame"+(Y?" "+Y:""),role:"img","aria-label":Ae||("string"==typeof ye?ye:"Geographic chart"),style:{position:"relative",width:U?"100%":Ee[0],height:V?"100%":Ee[1]},children:[e.jsx(rt,{summary:Ce}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ee[0],height:Ee[1],style:{position:"absolute",left:0,top:0},children:[e.jsx("g",{transform:`translate(${De.left},${De.top})`,children:Xe}),e.jsxs("g",{transform:`translate(${De.left},${De.top})`,children:[Q&&e.jsx("rect",{x:0,y:0,width:$e,height:Ve,fill:Q}),n.map((t,n)=>function(t,n){var o,i,r,l,s,a;switch(t.type){case"geoarea":{const r=t;return r.pathData?e.jsx("path",{d:r.pathData,fill:We(r.style.fill,"#e0e0e0"),fillOpacity:null!==(o=r.style.fillOpacity)&&void 0!==o?o:1,stroke:r.style.stroke||"none",strokeWidth:r.style.strokeWidth||.5,strokeDasharray:r.style.strokeDasharray,opacity:null!==(i=r._decayOpacity)&&void 0!==i?i:1},"geoarea-"+n):null}case"point":{const o=t;return e.jsx("circle",{cx:o.x,cy:o.y,r:o.r,fill:We(o.style.fill),fillOpacity:null!==(r=o.style.fillOpacity)&&void 0!==r?r:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:null!==(l=o._decayOpacity)&&void 0!==l?l:null!==(s=o.style.opacity)&&void 0!==s?s:1},"point-"+n)}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.jsx("path",{d:i,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||1.5,strokeDasharray:o.style.strokeDasharray,opacity:null!==(a=o.style.opacity)&&void 0!==a?a:1},"line-"+n)}default:return null}}(t,n))]})]}),e.jsx(Be,{width:$e,height:Ve,totalWidth:Ee[0],totalHeight:Ee[1],margin:De,scales:null,showAxes:!1,title:ye,legend:me,legendPosition:ve,legendHoverBehavior:be,legendClickBehavior:xe,legendHighlightedCategory:je,legendIsolatedCategories:ke,foregroundGraphics:Ze,annotations:ae,annotationFrame:0,xValues:[],yValues:[],pointNodes:n.filter(e=>"point"===e.type)})]})}return e.jsxs("div",{ref:Zt,className:"stream-geo-frame"+(Y?" "+Y:""),role:"group","aria-label":Ae||("string"==typeof ye?ye:"Geographic chart"),tabIndex:0,style:Object.assign({position:"relative",width:U?"100%":Ee[0],height:V?"100%":Ee[1],overflow:"hidden"},I?{touchAction:"none"}:{}),onKeyDown:jn,children:[Se&&e.jsx(lt,{tableId:Je}),Se&&e.jsx(it,{scene:null!==(a=null===(l=Bt.current)||void 0===l?void 0:l.scene)&&void 0!==a?a:[],chartType:"Geographic chart",tableId:Je,chartTitle:"string"==typeof ye?ye:void 0}),e.jsx(rt,{summary:Ce}),e.jsxs("div",{role:"img","aria-label":Ae||("string"==typeof ye?ye:"Geographic chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:wn?kn:void 0,onMouseLeave:wn?mn:void 0,onClick:le?vn:void 0,children:[Xe&&e.jsx("svg",{style:{position:"absolute",left:0,top:0,width:Ee[0],height:Ee[1],pointerEvents:"none"},children:e.jsx("g",{transform:`translate(${De.left},${De.top})`,children:Xe})}),N&&e.jsx("canvas",{ref:Wt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),e.jsx("canvas",{ref:Tt,"aria-label":Ye(null!==(h=null===(d=Bt.current)||void 0===d?void 0:d.scene)&&void 0!==h?h:[],"Geographic chart"),style:{position:"absolute",left:0,top:0}}),e.jsx("canvas",{ref:Nt,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),e.jsx(st,{hoverPoint:tn}),e.jsx(Be,{width:$e,height:Ve,totalWidth:Ee[0],totalHeight:Ee[1],margin:De,scales:null,showAxes:null!=Me&&Me,title:ye,legend:me,legendPosition:ve,legendHoverBehavior:be,legendClickBehavior:xe,legendHighlightedCategory:je,legendIsolatedCategories:ke,foregroundGraphics:Ze,annotations:ae,annotationFrame:on,xValues:[],yValues:[],pointNodes:null===(f=Bt.current)||void 0===f?void 0:f.scene.filter(e=>"point"===e.type)}),(null==fe?void 0:fe.showBadge)&&e.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===fe.badgePosition?{top:4,left:4}:"bottom-left"===fe.badgePosition?{bottom:4,left:4}:"bottom-right"===fe.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:ln?"#dc3545":"#28a745",color:"white"}),children:ln?"STALE":"LIVE"}),I&&e.jsxs("div",{className:"stream-geo-zoom-controls",style:{position:"absolute",bottom:De.bottom+8,left:De.left+8,display:"flex",flexDirection:"column",gap:2,zIndex:2},children:[e.jsx("button",{type:"button","aria-label":"Zoom in",onClick:e=>{e.stopPropagation();const t=Vt.current,n=qt.current;t&&(null==n?void 0:n.scaleBy)&&n.scaleBy(u.select(t),1.5)},style:Pt,children:"+"}),e.jsx("button",{type:"button","aria-label":"Zoom out",onClick:e=>{e.stopPropagation();const t=Vt.current,n=qt.current;t&&(null==n?void 0:n.scaleBy)&&n.scaleBy(u.select(t),1/1.5)},style:Pt,children:"−"})]}),_&&e.jsx("div",{className:"stream-geo-tile-attribution",style:{position:"absolute",bottom:De.bottom+2,right:De.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},children:_}),e.jsx(dt,{active:bn.current>=0,hoverPoint:tn,margin:De,size:Ee,shape:null===(p=xn.current)||void 0===p?void 0:p.shape,width:null===(g=xn.current)||void 0===g?void 0:g.w,height:null===(y=xn.current)||void 0===y?void 0:y.h}),Mn]})]})});Dt.displayName="StreamGeoFrame";const $t={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function Bt(e,t){return"function"==typeof t?t(e):e[t]}function Wt(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return 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 Tt(t={}){const{fields:n,title:o,format:i,style:r={},className:l=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let s;const a=[];if(o){const e=Bt(t,o);s=Wt(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=Bt(t,o);a.push({label:n,value:Wt(l,r)})});else if(!o){const e=["value","y","name","id","label"];for(const n of e)if(void 0!==t[n]){s=Wt(t[n],i);break}if(!s){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(s=Wt(t[e[0]],i))}}const c=Object.assign(Object.assign({},$t),r);return e.jsxs("div",{className:("semiotic-tooltip "+l).trim(),style:c,children:[s&&e.jsx("div",{style:{fontWeight:a.length>0?"bold":"normal"},children:s}),a.map((t,n)=>e.jsxs("div",{style:{marginTop:0===n&&s?"4px":0},children:[t.label&&e.jsxs("span",{children:[t.label,": "]}),t.value]},n))]})}}function Nt(t){if(!0!==t){if("function"==typeof t){const n=t;return t=>{var o;const i=!0===(null==t?void 0:t.__semioticHoverData)||t&&void 0!==t.data&&"number"==typeof t.x&&"number"==typeof t.y&&t&&("node"===t.type||"edge"===t.type||void 0!==t.nodeOrEdge||void 0!==t.allSeries||void 0!==t.stats||void 0!==t.__chartType)?null!==(o=t.data)&&void 0!==o?o:{}:t,r=n(i);return null==r?null:e.jsx("div",{className:"semiotic-tooltip",style:$t,children:r})}}return!1!==t&&void 0!==t&&("object"==typeof t&&null!==t&&("fields"in t||"title"in t)?Tt(t):Tt())}}function _t(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function Ht(e,t,n){const o=e=>e.toString(16).padStart(2,"0");return`#${o(e)}${o(t)}${o(n)}`}function Ft(e){const t=e.map(_t),n=t.length-1;return e=>{if(0>=e){const[e,n,o]=t[0];return Ht(e,n,o)}if(e>=1){const[e,o,i]=t[n];return Ht(e,o,i)}const o=e*n,i=Math.floor(o),r=o-i,[l,s,a]=t[i],[c,u,d]=t[i+1];return Ht(Math.round(l+(c-l)*r),Math.round(s+(u-s)*r),Math.round(a+(d-a)*r))}}const qt=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Gt=Ft(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),Ut=Ft(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),Vt=Ft(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),Zt=Ft(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),Yt=Ft(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),Xt=Ft(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),Qt=Ft(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),Kt=Ft(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),Jt=Ft(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),en=Ft(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),tn=Ft(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),nn=Ft(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]);Ft(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),Ft(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),Ft(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),Ft(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),Ft(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),Ft(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),Ft(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);const on={category10:qt,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],blues:Gt,reds:Ut,greens:Vt,oranges:Zt,purples:Yt,viridis:Qt,plasma:Kt},rn=qt,ln=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],sn=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 an(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")||sn.has(t)}(o)?n(o):o}const o=(null==e?void 0:e[t])+"";return n?n(o):rn[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))%rn.length]}function cn(e,t,n="category10"){const i=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e).map(e=>e+""))),r=i.every(e=>!isNaN(Number(e)));if(Array.isArray(n))return o.scaleOrdinal().domain(i).range(n).unknown("#999");const l=on[n]||on.category10;if(r&&"function"==typeof l){let e=-1/0;for(const t of i){const n=Number(t);n>e&&(e=n)}return t=>l(Number(t)/e)}{const e=Array.isArray(l)?l:rn;return o.scaleOrdinal().domain(i).range(e).unknown("#999")}}function un(e,t,n=[3,20],o){let i;if(i="function"==typeof t?t(e):null==e?void 0:e[t],!o)return i;const[r,l]=o,[s,a]=n;return l===r?(s+a)/2:s+(i-r)/(l-r)*(a-s)}const dn=t.createContext(null);function hn(){return t.useContext(dn)}function fn(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 pn(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}const[gn,yn]=L(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),i=pn(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=pn(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}})}})),[mn,vn]=L(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 bn(e){const n=t.useId(),o=e.clientId||n,{name:i}=e,r=yn(e=>e.selections.get(i)),l=yn(e=>e.setClause),s=yn(e=>e.clearClause),a=t.useMemo(()=>!!r&&r.clauses.size>0,[r]);return{predicate:t.useMemo(()=>r&&0!==r.clauses.size?function(e,t){const n=[];for(const[o,i]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(fn(i));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(r,o):()=>!0,[r,o]),isActive:a,selectPoints:t.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};l(i,{clientId:o,type:"point",fields:t})},[o,i,l]),selectInterval:t.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};l(i,{clientId:o,type:"interval",fields:t})},[o,i,l]),clear:t.useCallback(()=>{s(i,o)},[s,i,o]),clientId:o}}function xn(e){const n=e.name||"hover",{fields:o}=e,{predicate:i,isActive:r,selectPoints:l,clear:s}=bn({name:n});return{onHover:t.useCallback(e=>{if(!e)return void s();const t={};for(const n of o){const o=e[n];void 0!==o&&(t[n]=[o])}Object.keys(t).length>0&&l(t)},[o,l,s,n]),predicate:i,isActive:r}}const jn=t.createContext(!1),kn=t.createContext(null),wn="undefined"==typeof window?t.useEffect:t.useLayoutEffect;function On(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField}:null}function Mn(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:.5;r.opacity=e,r.fillOpacity=e,r.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(r,n.unselectedStyle)}return r}:e}function Sn(){return H(e=>e.theme)}f.createContext(void 0);const An="#007bff";function Cn(e,t,n){var o;const i=null!==(o=e.xValue)&&void 0!==o?o:null==t?void 0:t[n];if(null==i)return null;const r=Number(i);return Number.isFinite(r)?r:null}function Rn(e){let t=e.data||e.datum||e;return Array.isArray(t)&&(t=t[0]),null!=e.xValue&&t&&"object"==typeof t&&!Array.isArray(t)&&null==t.xValue?Object.assign(Object.assign({},t),{xValue:e.xValue}):t||{}}function zn(){var e;const t=Sn(),n=null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.categorical;return n&&n.length>0?n:void 0}function Pn({selection:e,linkedHover:n,fallbackFields:o=[],unwrapData:i=!1,onObservation:r,chartType:l,chartId:s,onClick:a,hoverHighlight:c,colorByField:u}){const d=t.useId(),h=On(n,o),f=bn({name:(null==e?void 0:e.name)||"__unused__"}),p=xn({name:(null==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||o||[]}),g=vn(e=>e.pushObservation),y=e?{isActive:f.isActive,predicate:f.predicate}:null,[m,v]=t.useState(null),b=u||o[0],x=t.useMemo(()=>{if(!c||null==m||!b)return null;const e=m,t=b;return{isActive:!0,predicate:n=>{var o;return("string"==typeof n[t]?n[t]:(null!==(o=n[t])&&void 0!==o?o:"")+"")===e}}},[c,m,b]),j=t.useCallback(e=>{var t,o;if(n)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const n=Cn(e,t,h.xField);null!=n&&function(e,t,n){const o=we.positions.get(e);(null==o?void 0:o.locked)||o&&o.xValue===t&&o.sourceId===n||(we={positions:new Map(we.positions).set(e,{xValue:t,sourceId:n})},Me())}(h.name||"hover",n,d)}"x-position"!==(null==h?void 0:h.mode)&&p.onHover(t)}else"x-position"===(null==h?void 0:h.mode)&&Se(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&p.onHover(null);if(c&&b)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[b];v(null!=n?n+"":null)}else v(null);if(r||g){const n={timestamp:Date.now(),chartType:l||"unknown",chartId:s};if(e){const i=Rn(e),l=Object.assign(Object.assign({},n),{type:"hover",datum:i||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0});r&&r(l),g&&g(l)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});r&&r(e),g&&g(e)}}},[n,p,h,d,r,l,s,g,c,b]),k=t.useCallback(e=>{var t,n,o,i;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=Cn(e,t,h.xField);null!=n&&function(e,t,n){const o=we.positions.get(e);if(null==o?void 0:o.locked){const t=new Map(we.positions);return t.delete(e),we={positions:t},Me(),!1}we={positions:new Map(we.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Me()}(h.name||"hover",n,d)}if(e&&a){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]),a(o,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0})}if(r||g){const t={timestamp:Date.now(),chartType:l||"unknown",chartId:s};if(e){const n=Rn(e),l=Object.assign(Object.assign({},t),{type:"click",datum:n||{},x:null!==(o=e.x)&&void 0!==o?o:0,y:null!==(i=e.y)&&void 0!==i?i:0});r&&r(l),g&&g(l)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});r&&r(e),g&&g(e)}}},[a,r,g,l,s,h,d]);return t.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const e=h.name||"hover";return()=>{Ae(e,d),Se(e,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:y,hoverSelectionHook:x,customHoverBehavior:j,customClickBehavior:k,crosshairSourceId:d}}function Ln({data:e,colorBy:n,colorScale:o,showLegend:i,legendPosition:r="right",userMargin:l,defaults:s={top:50,bottom:60,left:70,right:40},categories:a}){const c=t.useContext(jn),u=null!==t.useContext(kn),d=void 0!==i?i:!c&&!!n,h=!!n&&(d||u),f=t.useMemo(()=>{if(!h)return[];if(void 0!==a)return a;const t=new Set;for(const o of e){const e="function"==typeof n?n(o):o[n];null!=e&&t.add(e+"")}return Array.from(t)},[a,n,e,h]);!function(e){const n=t.useContext(kn),o=t.useId(),i=function(e){const t=new Set,n=[];for(const o of e)t.has(o)||(t.add(o),n.push(o));return n}(e),r=t.useRef([]);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(r.current,i)||(r.current=i);const l=r.current;wn(()=>{if(n)return()=>n.unregisterCategories(o)},[n,o]),wn(()=>{n&&n.registerCategories(o,l)},[n,o,l])}(u&&n?f:[]);const p=t.useMemo(()=>{if(!d||!n)return;const t=function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:i,strokeWidth:r,categories:l}){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:(l&&l.length>0?l:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((i,r)=>{const l=e.find("function"==typeof t?e=>t(e)===i:e=>e[t]===i),s=l?o(l,t,n):n?n(i):ln[r%ln.length];return{label:i+"",color:s}}),label:""}]}}({data:e,colorBy:n,colorScale:o,getColor:an,categories:f});return 0!==t.legendGroups.reduce((e,t)=>e+t.items.length,0)?t:void 0},[d,n,e,o,f]),g=t.useMemo(()=>{const e="number"==typeof l?{top:l,bottom:l,left:l,right:l}:null!=l?l:{},t=Object.assign(Object.assign({},s),e);return p&&("right"===r&&110>t.right?t.right=110:"left"===r&&110>t.left?t.left=110:"top"===r&&50>t.top?t.top=50:"bottom"===r&&80>t.bottom&&(t.bottom=80)),t},[s,l,p,r]);return{legend:p,margin:g,legendPosition:r}}const In={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 En(e,t,n){var o,i,r,l,s,a,c;const u=In[e||"primary"],d="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:u.width,height:null!==(i=t.height)&&void 0!==i?i:u.height,showAxes:null!==(r=t.showAxes)&&void 0!==r?r:u.showAxes,showGrid:null!==(l=t.showGrid)&&void 0!==l?l:u.showGrid,enableHover:null!==(s=t.enableHover)&&void 0!==s?s:!!t.linkedHover||u.enableHover,showLegend:null!==(a=t.showLegend)&&void 0!==a?a:u.showLegend,showLabels:null!==(c=t.showLabels)&&void 0!==c?c:u.showLabels,title:d?void 0:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:d?void 0:t.xLabel,yLabel:d?void 0:t.yLabel,categoryLabel:d?void 0:t.categoryLabel,valueLabel:d?void 0:t.valueLabel,marginDefaults:Dn(u.marginDefaults,t.showCategoryTicks,t.orientation),compactMode:d}}function Dn(e,t,n){if(!1!==t)return e;const o=Object.assign({},e);return"horizontal"===n?o.left=Math.min(o.left,15):o.bottom=Math.min(o.bottom,15),o}function $n(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return null!=e?e:()=>({});const n={};return void 0!==t.stroke&&(n.stroke=t.stroke),void 0!==t.strokeWidth&&(n.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(n.opacity=t.opacity),e?(...t)=>{const o=e(...t)||{};return Object.assign(Object.assign({},o),n)}:(...e)=>Object.assign({},n)}function Bn({componentName:t,message:n,diagnosticHint:o,width:i,height:r}){return e.jsx("div",{role:"alert",style:{width:i,height:Math.max(r,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"},children:e.jsxs("div",{style:{textAlign:"center",maxWidth:400},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:t}),e.jsx("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:n}),o&&e.jsx("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6},children:o})]})})}class Wn extends f.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.jsx(Bn,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}var Tn;const Nn="undefined"!=typeof process&&"production"!==(null===(Tn=process.env)||void 0===Tn?void 0:Tn.NODE_ENV);function _n({componentName:t,width:n,height:o,children:i}){return e.jsx(Wn,{fallback:i=>e.jsx(Bn,{componentName:t,message:i.message,width:n,height:o}),children:i})}const Hn={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"},Fn={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function qn(t,n,o,i){return!1===i||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?e.jsx("div",{style:Object.assign(Object.assign({},Hn),{width:n,height:o}),children:i||"No data available"}):null}function Gn(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))),s=Math.floor((o-(i*(r+l)-l))/2);return e.jsx("div",{style:{width:n,height:o,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:i},(t,o)=>e.jsx("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Fn),{position:"absolute",top:s+o*(r+l),left:Math.floor(.1*n),width:30+(37*o+13)%50+"%",height:r,opacity:.5+o%2*.2})},o))})}function Un(e,t,n,o){if(!Nn)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 Vn(e){const n=H(e=>e.theme.colors.selectionOpacity);return t.useMemo(()=>{var t,o;if(void 0!==e||void 0!==n)return Object.assign(Object.assign({name:null!==(t=null==e?void 0:e.name)&&void 0!==t?t:""},e),{unselectedOpacity:null!==(o=null==e?void 0:e.unselectedOpacity)&&void 0!==o?o:n})},[e,n])}function Zn(e,t,n,o){return new(n||(n=Promise))(function(i,r){function l(e){try{a(o.next(e))}catch(e){r(e)}}function s(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(l,s)}a((o=o.apply(e,t||[])).next())})}function Yn(e){return e}function Xn(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 Yn;var t,n,o=e.scale[0],i=e.scale[1],r=e.translate[0],l=e.translate[1];return function(e,s){s||(t=n=0);var a=2,c=e.length,u=Array(c);for(u[0]=(t+=e[0])*o+r,u[1]=(n+=e[1])*i+l;c>a;)u[a]=e[a],++a;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 s(e){for(var t=l(e);4>t.length;)t.push(t[0]);return t}function a(e){return e.map(s)}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=a(t.arcs);break;case"MultiPolygon":n=t.arcs.map(a);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 Qn=new Map;function Kn(e){var t;return null!==(t=e.default)&&void 0!==t?t:e}function Jn(e){return Zn(this,void 0,void 0,function*(){const t=Qn.get(e);if(t)return t;const{topology:n,objectName:o}=yield function(e){return Zn(this,void 0,void 0,function*(){switch(e){case"world-110m":return{topology:Kn(yield import("world-atlas/countries-110m.json")),objectName:"countries"};case"world-50m":return{topology:Kn(yield import("world-atlas/countries-50m.json")),objectName:"countries"};case"land-110m":return{topology:Kn(yield import("world-atlas/land-110m.json")),objectName:"land"};case"land-50m":return{topology:Kn(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 Xn(e,t)})}:Xn(e,t)}(n,n.objects[o]),r="features"in i?i.features:[i];return Qn.set(e,r),r})}function eo(e){const n=t.useMemo(()=>Array.isArray(e)?e:void 0,[e]),[o,i]=t.useState(null);return t.useEffect(()=>{if(e&&!Array.isArray(e)){if("string"==typeof(t=e)&&["world-110m","world-50m","land-110m","land-50m"].includes(t)){let t=!1;return i(null),Jn(e).then(e=>{t||i(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".`),i(null)}else i(null)},[e]),void 0!==n?n:o}const to={blues:Gt,reds:Ut,greens:Vt,viridis:Qt,oranges:Zt,purples:Yt,greys:Xt,plasma:Kt,inferno:Jt,magma:en,cividis:tn,turbo:nn};function no(n){var i;const l=En(n.mode,{width:n.width,height:n.height,showLegend:n.showLegend,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary}),s=function(){var e;const t=Sn();return(null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.sequential)||void 0}(),{areas:a,valueAccessor:c,colorScheme:u,projection:d="equalEarth",graticule:h,fitPadding:f,zoomable:p,zoomExtent:g,onZoom:y,dragRotate:m,tileURL:v,tileAttribution:b,tileCacheSize:x,tooltip:j,areaOpacity:k=1,annotations:w,margin:O,className:M,selection:S,linkedHover:A,onObservation:C,onClick:R,chartId:z,loading:P,emptyContent:L,frameProps:I={},stroke:E,strokeWidth:D,opacity:$}=n,B=null!=p?p:!!v,W=eo(a),T=t.useMemo(()=>W?ct(W):W,[W]),N=t.useMemo(()=>"function"==typeof c?c:e=>{var t,n;return null!==(n=null===(t=null==e?void 0:e.properties)||void 0===t?void 0:t[c])&&void 0!==n?n:null==e?void 0:e[c]},[c]),_=null!==(i=null!=u?u:s)&&void 0!==i?i:"blues",H=t.useMemo(()=>{if(!T)return o.scaleSequential(Gt).domain([0,1]);const e=T.map(e=>N(e)).filter(e=>null!=e&&isFinite(e)),[t,n]=r.extent(e);return o.scaleSequential(to[_]||Gt).domain([null!=t?t:0,null!=n?n:1])},[T,N,_]),{activeSelectionHook:F,customHoverBehavior:q,customClickBehavior:G}=Pn({selection:S,linkedHover:A,onObservation:C,onClick:R,chartType:"ChoroplethMap",chartId:z}),U=Vn(S),V=t.useMemo(()=>{const e=$n(e=>{const t=N(e);return{fill:null!=t&&isFinite(t)?H(t):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:k}},{stroke:E,strokeWidth:D,opacity:$});return F?Mn(e,F,U):e},[N,H,F,U,k,E,D,$]),Z=t.useMemo(()=>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=N(t);return e.jsxs("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:[e.jsx("div",{style:{fontWeight:600},children:i}),null!=r&&e.jsx("div",{style:{opacity:.7},children:(l=r,"number"==typeof l&&isFinite(l)?Number.isInteger(l)?l.toLocaleString():l.toLocaleString(void 0,{maximumFractionDigits:2}):(null!=l?l:"")+"")})]});var l},[N]),Y=t.useMemo(()=>Object.assign({top:10,right:10,bottom:10,left:10},"number"==typeof O?{top:O,bottom:O,left:O,right:O}:O),[O]),X=Gn(P,l.width,l.height)||(T?null:Gn(!0,l.width,l.height)),Q=X?null:qn(T,l.width,l.height,L);if(Array.isArray(T)&&T.length>0){const t=T[0];if(!t||"object"!=typeof t||!t.geometry)return e.jsx(Bn,{componentName:"ChoroplethMap",message:"ChoroplethMap: areas must be an array of GeoJSON Features with a geometry property.",width:l.width,height:l.height})}const K=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:d,areas:T,areaStyle:V,size:[l.width,l.height],margin:Y,enableHover:!0,tooltipContent:!1===j?()=>null:!0===j?Z:Nt(j)||Z},null!=h&&{graticule:h}),null!=f&&{fitPadding:f}),B&&{zoomable:!0}),g&&{zoomExtent:g}),y&&{onZoom:y}),null!=m&&{dragRotate:m}),v&&{tileURL:v}),b&&{tileAttribution:b}),x&&{tileCacheSize:x}),(A||C||R)&&{customHoverBehavior:q}),(C||R)&&{customClickBehavior:G}),w&&w.length>0&&{annotations:w}),l.title&&{title:l.title}),l.description&&{description:l.description}),l.summary&&{summary:l.summary}),void 0!==l.accessibleTable&&{accessibleTable:l.accessibleTable}),M&&{className:M}),null!=n.animate&&{animate:n.animate}),I);return X||Q||e.jsx(_n,{componentName:"ChoroplethMap",width:l.width,height:l.height,children:e.jsx(Dt,Object.assign({},K))})}function oo(e){const{data:n,rawData:o,colorBy:i,colorScheme:r,legendInteraction:l,legendPosition:s,selection:a,linkedHover:c,fallbackFields:u,unwrapData:d=!1,onObservation:h,chartType:f,chartId:p,showLegend:g,userMargin:y,marginDefaults:m,onClick:v,hoverHighlight:b,loading:x,emptyContent:j,width:k,height:w}=e,O=void 0===o,M=t.useMemo(()=>ct(n),[n]),[S,A]=t.useState([]),C=t.useCallback(e=>{A(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[]),R="string"==typeof e.colorBy?e.colorBy:void 0,{activeSelectionHook:z,hoverSelectionHook:P,customHoverBehavior:L,customClickBehavior:I,crosshairSourceId:E}=Pn({selection:a,linkedHover:c,fallbackFields:u,unwrapData:d,onObservation:h,chartType:f,chartId:p,onClick:v,hoverHighlight:b,colorByField:R}),D=function(e,t){const n="object"==typeof e&&null!==e?e:void 0;if("x-position"===(null==n?void 0:n.mode))return{linkedCrosshairName:n.name||"hover",linkedCrosshairSourceId:t}}(c,E),$=function(e,n,o){const i=hn(),r=zn();return t.useMemo(()=>{var t;if(!n)return;const l=null!==(t=null!=o?o:r&&r.length>0?r:void 0)&&void 0!==t?t:"category10";if(0!==e.length){if("function"==typeof n){const t=Array.from(new Set(e.map(e=>n(e)+"")));if(i&&Object.keys(i).length>0){const e=cn(t.map(e=>({_cat:e})),"_cat",l);return t=>i[t]||e(t)}return cn(t.map(e=>({_cat:e})),"_cat",l)}if(i&&Object.keys(i).length>0){const t=cn(e,n,l);return e=>i[e]||t(e)}return cn(e,n,l)}if(i&&Object.keys(i).length>0){const e=cn([{_:"a"}],"_",l);return t=>i[t]||e(t)}},[e,n,o,i,r])}(M,i,r),B=t.useMemo(()=>{if(!i)return[];const e=new Set;for(const t of M){const n="function"==typeof i?i(t):t[i];null!=n&&e.add(n+"")}return Array.from(e)},[M,i]),W=t.useMemo(()=>O&&S.length>0?S:B,[O,S,B]),T=function(e,n,o){const[i,r]=t.useState(null),[l,s]=t.useState(new Set),a=t.useCallback(t=>{"highlight"===e&&r(t?t.label:null)},[e]),c=t.useCallback(t=>{"isolate"===e&&s(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]),u=t.useMemo(()=>{if(!e||"none"===e||!n)return null;const t="string"==typeof n?n:null;return"highlight"===e&&null!=i?{isActive:!0,predicate:e=>(t?e[t]:"function"==typeof n?n(e):null)===i}:"isolate"===e&&l.size>0?{isActive:!0,predicate:e=>{const o=t?e[t]:"function"==typeof n?n(e):null;return l.has(o)}}:null},[e,n,i,l]);return{highlightedCategory:"highlight"===e?i:null,isolatedCategories:"isolate"===e?l:new Set,onLegendHover:a,onLegendClick:c,legendSelectionHook:u}}(l,i,W),N=t.useMemo(()=>P||(T.legendSelectionHook?T.legendSelectionHook:z),[P,T.legendSelectionHook,z]),_=Vn(a),H=zn(),F=hn(),q=t.useMemo(()=>{if($)return $;if(!i||0===W.length)return;const e=Array.isArray(r)&&r.length>0||"string"==typeof r&&r.length>0?r:H&&H.length>0?H:ln,t="__streamCat",n=cn(W.map(e=>({[t]:e})),t,e);return e=>(null==F?void 0:F[e])||n(e)||"#999"},[$,i,W,r,H,F]),{legend:G,margin:U,legendPosition:V}=Ln({data:M,colorBy:i,colorScale:q,showLegend:g,legendPosition:s,userMargin:y,defaults:m,categories:W}),Z=t.useMemo(()=>{const e={};return G&&(e.legend=G,e.legendPosition=V),l&&"none"!==l&&(e.legendHoverBehavior=T.onLegendHover,e.legendClickBehavior=T.onLegendClick,e.legendHighlightedCategory=T.highlightedCategory,e.legendIsolatedCategories=T.isolatedCategories),O&&i&&(e.legendCategoryAccessor=i,e.onCategoriesChange=C),e},[G,V,l,T.onLegendHover,T.onLegendClick,T.highlightedCategory,T.isolatedCategories,O,i,C]),Y=Array.isArray(o)?ct(o):o,X=Gn(x,k,w),Q=X?null:qn(Y,k,w,j);return{data:M,colorScale:$,allCategories:W,legendState:T,effectiveSelectionHook:N,activeSelectionHook:z,customHoverBehavior:L,customClickBehavior:I,legend:G,margin:U,legendPosition:V,earlyReturn:X||Q||null,legendBehaviorProps:Z,crosshairProps:D,resolvedSelection:_}}function io(e,n){const{variant:o,frameRef:i,overrides:r,deps:l}=n;t.useImperativeHandle(e,()=>{const e=function(e,t){if("xy"===e){const e=t;return{push:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.push(t)},pushMany:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.pushMany(t)},remove:t=>{var n,o;return null!==(o=null===(n=e.current)||void 0===n?void 0:n.remove(t))&&void 0!==o?o:[]},update:(t,n)=>{var o,i;return null!==(i=null===(o=e.current)||void 0===o?void 0:o.update(t,n))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,n;return null!==(n=null===(t=e.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var t,n;return null!==(n=null===(t=e.current)||void 0===t?void 0:t.getScales())&&void 0!==n?n:null}}}if("network"===e){const e=t;return{push:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.push(t)},pushMany:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.pushMany(t)},remove:t=>{var n,o,i,r,l;const s=Array.isArray(t)?t:[t],a=null!==(i=null===(o=null===(n=e.current)||void 0===n?void 0:n.getTopology())||void 0===o?void 0:o.nodes)&&void 0!==i?i:[],c=[];for(const t of s){const n=a.find(e=>e.id===t);n&&c.push(Object.assign(Object.assign({},null!==(r=n.data)&&void 0!==r?r:{}),{id:t})),null===(l=e.current)||void 0===l||l.removeNode(t)}return c},update:(t,n)=>(Array.isArray(t)?t:[t]).flatMap(t=>{var o;const i=null===(o=e.current)||void 0===o?void 0:o.updateNode(t,n);return i?[Object.assign(Object.assign({},i),{id:t})]:[]}),clear:()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,n,o,i;return null!==(i=null===(o=null===(n=null===(t=e.current)||void 0===t?void 0:t.getTopology())||void 0===n?void 0:n.nodes)||void 0===o?void 0:o.map(e=>e.data))&&void 0!==i?i:[]}}}const n=t;return{push:e=>{var t;return null===(t=n.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=n.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=n.current)||void 0===t?void 0:t.removePoint(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,i,r;const l=null!==(i=null===(o=n.current)||void 0===o?void 0:o.removePoint(e))&&void 0!==i?i:[];for(const e of l)null===(r=n.current)||void 0===r||r.push(t(e));return l},clear:()=>{var e;return null===(e=n.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=n.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]}}}(o,i);return Object.assign(Object.assign({},e),r)},null!=l?l:[])}no.displayName="ChoroplethMap";const ro=t.forwardRef(function(n,o){const i=t.useRef(null);io(o,{variant:"geo-points",frameRef:i});const r=En(n.mode,{width:n.width,height:n.height,showLegend:n.showLegend,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary}),{points:l,xAccessor:s="lon",yAccessor:a="lat",sizeBy:c,sizeRange:u=[3,30],colorBy:d,colorScheme:h,projection:f="equalEarth",graticule:p,fitPadding:g,zoomable:y,zoomExtent:m,onZoom:v,dragRotate:b,tileURL:x,tileAttribution:j,tileCacheSize:k,areas:w,areaStyle:O={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5},tooltip:M,annotations:S,margin:A,className:C,selection:R,linkedHover:z,onObservation:P,onClick:L,chartId:I,loading:E,emptyContent:D,legendInteraction:$,legendPosition:B,frameProps:W={},stroke:T,strokeWidth:N,opacity:_}=n,H=null!=y?y:!!x,F=eo(w),q=oo({data:null!=l?l:at,rawData:l,colorBy:d,colorScheme:h,legendInteraction:$,legendPosition:B,selection:R,linkedHover:z,fallbackFields:d?["string"==typeof d?d:""]:[],unwrapData:!1,onObservation:P,onClick:L,chartType:"ProportionalSymbolMap",chartId:I,showLegend:r.showLegend,userMargin:A,marginDefaults:{top:10,bottom:10,left:10,right:10},loading:E,emptyContent:D,width:r.width,height:r.height}),G=q.data,U=t.useMemo(()=>{if(!c)return;const e="function"==typeof c?c:e=>null==e?void 0:e[c],t=G.filter(Boolean).map(t=>e(t)).filter(e=>null!=e&&isFinite(e));return 0!==t.length?[Math.min(...t),Math.max(...t)]:void 0},[G,c]),V=t.useMemo(()=>{const e=$n(e=>({fill:d?an(e,d,q.colorScale):An,fillOpacity:.7,stroke:"#fff",strokeWidth:.5,r:c?un(e,c,u,U):6}),{stroke:T,strokeWidth:N,opacity:_});return q.effectiveSelectionHook?Mn(e,q.effectiveSelectionHook,q.resolvedSelection):e},[d,q.colorScale,q.effectiveSelectionHook,q.resolvedSelection,c,u,U,T,N,_]),Z=t.useMemo(()=>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 c?c:null,i=("function"==typeof c?c:e=>e[c])(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 d?d:null,s=l?null==t?void 0:t[l]:null;return e.jsxs("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:[n&&e.jsx("div",{style:{fontWeight:600,marginBottom:2},children:n}),o&&null!=i&&e.jsxs("div",{children:[e.jsxs("span",{style:{opacity:.7},children:[o,": "]}),r(i)]}),l&&null!=s&&e.jsxs("div",{children:[e.jsxs("span",{style:{opacity:.7},children:[l,": "]}),s+""]}),!n&&!o&&Object.entries(t).filter(([e])=>"data"!==e&&"x"!==e&&"y"!==e&&"time"!==e).slice(0,4).map(([t,n])=>e.jsxs("div",{children:[e.jsxs("span",{style:{opacity:.7},children:[t,": "]}),r(n)]},t))]})},[c,d]);Un("ProportionalSymbolMap",G,"xAccessor",s),Un("ProportionalSymbolMap",G,"yAccessor",a);const Y=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(Object.assign(Object.assign(Object.assign(Object.assign({projection:f},null!=l&&{points:G}),{xAccessor:s,yAccessor:a,pointStyle:V}),n.pointIdAccessor&&{pointIdAccessor:n.pointIdAccessor}),F&&{areas:F,areaStyle:O}),null!=p&&{graticule:p}),null!=g&&{fitPadding:g}),H&&{zoomable:!0}),m&&{zoomExtent:m}),v&&{onZoom:v}),null!=b&&{dragRotate:b}),x&&{tileURL:x}),j&&{tileAttribution:j}),k&&{tileCacheSize:k}),{size:[r.width,r.height],margin:q.margin,enableHover:!0,tooltipContent:!1===M?()=>null:Nt(M)||Z}),q.legendBehaviorProps),(z||P||L)&&{customHoverBehavior:q.customHoverBehavior}),(P||L)&&{customClickBehavior:q.customClickBehavior}),S&&S.length>0&&{annotations:S}),r.title&&{title:r.title}),r.description&&{description:r.description}),r.summary&&{summary:r.summary}),void 0!==r.accessibleTable&&{accessibleTable:r.accessibleTable}),C&&{className:C}),null!=n.animate&&{animate:n.animate}),W);return q.earlyReturn?q.earlyReturn:e.jsx(_n,{componentName:"ProportionalSymbolMap",width:r.width,height:r.height,children:e.jsx(Dt,Object.assign({ref:i},Y))})});function lo(n){const i=En(n.mode,{width:n.width,height:n.height,showLegend:n.showLegend,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary}),{flows:r,nodes:l,nodeIdAccessor:s="id",xAccessor:a="lon",yAccessor:c="lat",valueAccessor:u="value",projection:d="equalEarth",graticule:h,fitPadding:f,zoomable:p,zoomExtent:g,onZoom:y,dragRotate:m,tileURL:v,tileAttribution:b,tileCacheSize:x,lineType:j="geo",flowStyle:k="basic",areas:w,areaStyle:O={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5},edgeColorBy:M,edgeOpacity:S=.6,edgeWidthRange:A=[1,8],edgeLinecap:C="round",colorScheme:R,showParticles:z,particleStyle:P,tooltip:L,annotations:I,margin:E,className:D,selection:$,linkedHover:B,onObservation:W,onClick:T,chartId:N,loading:_,emptyContent:H,frameProps:F={},legendInteraction:q,legendPosition:G,stroke:U,strokeWidth:V,opacity:Z}=n,Y=null!=p?p:!!v,X=eo(w),Q=t.useMemo(()=>ct(l),[l]),K=oo({data:null!=r?r:at,rawData:r,colorBy:M,colorScheme:R,legendInteraction:q,legendPosition:G,selection:$,linkedHover:B,fallbackFields:M?["string"==typeof M?M:""]:[],unwrapData:!1,onObservation:W,onClick:T,chartType:"FlowMap",chartId:N,showLegend:i.showLegend,userMargin:E,marginDefaults:{top:10,bottom:10,left:10,right:10},loading:_,emptyContent:H,width:i.width,height:i.height}),J=K.data,ee=On(B),te=xn({name:(null==ee?void 0:ee.name)||"hover",fields:(null==ee?void 0:ee.fields)||[]}),ne=vn(e=>e.pushObservation),oe=t.useMemo(()=>{const e=new Map;for(const t of Q)e.set(t[s]+"",t);return e},[Q,s]),ie=t.useMemo(()=>{const e=new Map;for(const t of J)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},[J]),re=t.useCallback(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=ie.get(t[s]+"");e&&te.onHover(e)}else te.onHover(t)}else te.onHover(null);if(W||ne){const o={timestamp:Date.now(),chartType:"FlowMap",chartId:N};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});W&&W(r),ne&&ne(r)}else{const e=Object.assign(Object.assign({},o),{type:"hover-end"});W&&W(e),ne&&ne(e)}}},[B,te,s,ie,W,N,ne]),le=K.customClickBehavior,se=t.useMemo(()=>{const e="function"==typeof a?a:e=>e[a],t="function"==typeof c?c:e=>e[c];return J.map(n=>{if(!n||"object"!=typeof n||null==n.source||null==n.target)return null;const o=oe.get(n.source+""),i=oe.get(n.target+"");return o&&i?Object.assign(Object.assign({},n),{coordinates:[{[a]:e(o),[c]:t(o)},{[a]:e(i),[c]:t(i)}]}):null}).filter(Boolean)},[J,oe,a,c]),ae=t.useMemo(()=>{const e=J.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?()=>A[0]:o.scaleLinear().domain([Math.min(...e),Math.max(...e)]).range(A)},[J,u,A]),ce=t.useMemo(()=>e=>{var t;return{stroke:M?an(e,M,K.colorScale):An,strokeWidth:ae(null!==(t=e[u])&&void 0!==t?t:0),strokeLinecap:C,opacity:S}},[M,K.colorScale,ae,u,S,C]),ue=t.useMemo(()=>{var e;const t=$n(ce,{stroke:U,strokeWidth:V,opacity:Z});if(!K.effectiveSelectionHook)return t;const n=Object.assign(Object.assign({},(null===(e=K.resolvedSelection)||void 0===e?void 0:e.unselectedStyle)||{}),{fillOpacity:0});return Mn(t,K.effectiveSelectionHook,Object.assign(Object.assign({},K.resolvedSelection||{}),{unselectedStyle:n}))},[ce,K.effectiveSelectionHook,K.resolvedSelection,U,V,Z]),de=t.useMemo(()=>$n(()=>({fill:"#333",r:5,fillOpacity:.8}),{stroke:U,strokeWidth:V,opacity:Z}),[U,V,Z]),he=t.useMemo(()=>t=>{var n,o,i,r,l,a,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===(l=null===(r=null==t?void 0:t.data)||void 0===r?void 0:r.properties)||void 0===l?void 0:l.name)||(null===(c=null===(a=null==t?void 0:t.data)||void 0===a?void 0:a.properties)||void 0===c?void 0:c.NAME);if(n)return e.jsx("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:e.jsx("div",{style:{fontWeight:600},children:n})})}if(null!=(null==t?void 0:t.source)&&null!=(null==t?void 0:t.target)){const n=t[u];return e.jsxs("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:[e.jsxs("div",{style:{fontWeight:600},children:[t.source," → ",t.target]}),null!=n&&e.jsx("div",{style:{opacity:.7},children:"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[s]);return null!=d?e.jsx("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:e.jsx("div",{style:{fontWeight:600},children:d})}):null},[u,s]),fe=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(Object.assign(Object.assign(Object.assign({projection:d,lines:se,points:Q,xAccessor:a,yAccessor:c,lineDataAccessor:"coordinates",lineType:j,flowStyle:k,lineStyle:ue,pointStyle:de},X&&{areas:X,areaStyle:O}),null!=h&&{graticule:h}),null!=f&&{fitPadding:f}),Y&&{zoomable:!0}),g&&{zoomExtent:g}),y&&{onZoom:y}),null!=m&&{dragRotate:m}),z&&{showParticles:z}),P&&{particleStyle:P}),v&&{tileURL:v}),b&&{tileAttribution:b}),x&&{tileCacheSize:x}),{size:[i.width,i.height],margin:K.margin,enableHover:!0,tooltipContent:!1===L?()=>null:Nt(L)||he}),K.legendBehaviorProps),(B||W||T)&&{customHoverBehavior:re}),(W||T)&&{customClickBehavior:le}),I&&I.length>0&&{annotations:I}),i.title&&{title:i.title}),i.description&&{description:i.description}),i.summary&&{summary:i.summary}),void 0!==i.accessibleTable&&{accessibleTable:i.accessibleTable}),D&&{className:D}),null!=n.animate&&{animate:n.animate}),F);return K.earlyReturn?K.earlyReturn:e.jsx(_n,{componentName:"FlowMap",width:i.width,height:i.height,children:e.jsx(Dt,Object.assign({},fe))})}ro.displayName="ProportionalSymbolMap",lo.displayName="FlowMap";const so=t.forwardRef(function(n,o){const i=En(n.mode,{width:n.width,height:n.height,showLegend:n.showLegend,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary}),{points:r,lines:l,xAccessor:s="lon",yAccessor:a="lat",nodeIdAccessor:c="id",center:u,costAccessor:d,strength:h=1,lineMode:f="straight",projection:p="mercator",graticule:g,fitPadding:y,zoomable:m,zoomExtent:v,onZoom:b,dragRotate:x,tileURL:j,tileAttribution:k,tileCacheSize:w,transition:O,colorBy:M,colorScheme:S,pointRadius:A=5,tooltip:C,showRings:R=!0,ringStyle:z,showNorth:P=!0,costLabel:L,annotations:I,margin:E,className:D,selection:$,linkedHover:B,onObservation:W,onClick:T,chartId:N,loading:_,emptyContent:H,legendPosition:F,frameProps:q={},stroke:G,strokeWidth:U,opacity:V}=n,Z=null!=m?m:!!j,Y=t.useMemo(()=>ct(r),[r]),X=oo({data:Y,rawData:r,colorBy:M,colorScheme:S,legendInteraction:void 0,legendPosition:F,selection:$,linkedHover:B,fallbackFields:M?["string"==typeof M?M:""]:[],unwrapData:!1,onObservation:W,onClick:T,chartType:"DistanceCartogram",chartId:N,showLegend:i.showLegend,userMargin:E,marginDefaults:{top:10,bottom:10,left:10,right:10},loading:_,emptyContent:H,width:i.width,height:i.height}),Q=t.useMemo(()=>{const e=$n(e=>({fill:M?an(e,M,X.colorScale):An,fillOpacity:.8,stroke:"#fff",strokeWidth:1,r:A}),{stroke:G,strokeWidth:U,opacity:V});return X.effectiveSelectionHook?Mn(e,X.effectiveSelectionHook,X.resolvedSelection):e},[M,X.colorScale,X.effectiveSelectionHook,X.resolvedSelection,A,G,U,V]),K=t.useMemo(()=>({center:u,centerAccessor:c,costAccessor:d,strength:h,lineMode:f}),[u,c,d,h,f]),J=t.useMemo(()=>{if(!l)return;const e="function"==typeof s?s:e=>e[s],t="function"==typeof a?a:e=>e[a],n=new Map;for(const e of Y)n.set(e[c]+"",e);return l.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:[{[s]:e(i),[a]:t(i)},{[s]:e(r),[a]:t(r)}]}):null}).filter(Boolean)},[l,Y,s,a,c]),ee=t.useMemo(()=>t=>{const n=("function"==typeof d?d:e=>e[d])(t);return e.jsxs("div",{style:{background:"rgba(0,0,0,0.85)",color:"white",padding:"6px 10px",borderRadius:4,fontSize:12},children:[e.jsx("div",{style:{fontWeight:600},children:t[c]||t.name||t.id||"Point"}),null!=n&&e.jsxs("div",{style:{opacity:.7},children:["Cost: ","number"==typeof n?n.toFixed(1):n]})]})},[d,c]),te=t.useRef(null);io(o,{variant:"geo-points",frameRef:te});const[ne,oe]=t.useState(null),ie=t.useCallback(()=>{var e,t;const n=null===(t=null===(e=te.current)||void 0===e?void 0:e.getCartogramLayout)||void 0===t?void 0:t.call(e);n&&oe(e=>e&&e.cx===n.cx&&e.cy===n.cy&&e.maxCost===n.maxCost&&e.availableRadius===n.availableRadius?e:n)},[]);t.useEffect(()=>{const e=requestAnimationFrame(ie);return()=>cancelAnimationFrame(e)},[ie,h,u,i.width,i.height,Y]);const re=t.useMemo(()=>{if(!R||!ne)return[];const{maxCost:e}=ne;if(0>=e)return[];if(Array.isArray(R))return R.filter(t=>t>0&&e>=t);const t="number"==typeof R?R: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},[R,ne]),le=t.useMemo(()=>{var t,n;if(!ne)return q.foregroundGraphics||null;const{cx:o,cy:i,maxCost:r,availableRadius:l}=ne,s=Object.assign({stroke:"#999",strokeWidth:.8,strokeDasharray:"4,3",labelColor:"#777",labelSize:10},z),a=null!==(t=X.margin.left)&&void 0!==t?t:10,c=null!==(n=X.margin.top)&&void 0!==n?n:10;return e.jsxs("g",{children:[re.map(t=>{const n=t/r*l;return e.jsxs("g",{children:[e.jsx("circle",{cx:o+a,cy:i+c,r:n,fill:"none",stroke:s.stroke,strokeWidth:s.strokeWidth,strokeDasharray:s.strokeDasharray,opacity:.5}),e.jsxs("text",{x:o+a+n+3,y:i+c-2,fontSize:s.labelSize,fill:s.labelColor,fontFamily:"system-ui, sans-serif",children:[t,L?" "+L:""]})]},t)}),P&&e.jsxs("g",{transform:`translate(${a+24}, ${c+24})`,children:[e.jsx("circle",{r:16,fill:"white",fillOpacity:.85,stroke:"#bbb",strokeWidth:.8}),e.jsx("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.jsx("text",{y:-12,textAnchor:"middle",fontSize:7,fontWeight:700,fill:"#555",fontFamily:"system-ui, sans-serif",children:"N"}),e.jsx("line",{x1:11,y1:0,x2:13,y2:0,stroke:"#bbb",strokeWidth:.8}),e.jsx("line",{x1:-11,y1:0,x2:-13,y2:0,stroke:"#bbb",strokeWidth:.8}),e.jsx("line",{x1:0,y1:11,x2:0,y2:13,stroke:"#bbb",strokeWidth:.8})]}),q.foregroundGraphics]})},[ne,re,P,L,z,X.margin,q.foregroundGraphics]);Un("DistanceCartogram",Y,"xAccessor",s),Un("DistanceCartogram",Y,"yAccessor",a);const se=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(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({projection:p},null!=r&&{points:Y}),J&&{lines:J,lineDataAccessor:"coordinates"}),{xAccessor:s,yAccessor:a,pointIdAccessor:c,pointStyle:Q,projectionTransform:K}),O&&{transition:{duration:O}}),null!=g&&{graticule:g}),null!=y&&{fitPadding:y}),Z&&{zoomable:!0}),v&&{zoomExtent:v}),b&&{onZoom:b}),null!=x&&{dragRotate:x}),j&&{tileURL:j}),k&&{tileAttribution:k}),w&&{tileCacheSize:w}),{size:[i.width,i.height],margin:X.margin,enableHover:!0,tooltipContent:!1===C?()=>null:Nt(C)||ee}),X.legendBehaviorProps),(B||W||T)&&{customHoverBehavior:X.customHoverBehavior}),(W||T)&&{customClickBehavior:X.customClickBehavior}),I&&I.length>0&&{annotations:I}),i.title&&{title:i.title}),i.description&&{description:i.description}),i.summary&&{summary:i.summary}),void 0!==i.accessibleTable&&{accessibleTable:i.accessibleTable}),D&&{className:D}),null!=n.animate&&{animate:n.animate}),q),le&&{foregroundGraphics:le});return X.earlyReturn?X.earlyReturn:e.jsx(_n,{componentName:"DistanceCartogram",width:i.width,height:i.height,children:e.jsx(Dt,Object.assign({ref:te},se))})});so.displayName="DistanceCartogram",exports.ChoroplethMap=no,exports.DistanceCartogram=so,exports.FlowMap=lo,exports.ProportionalSymbolMap=ro,exports.StreamGeoFrame=Dt,exports.mergeData=function(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})},exports.resolveReferenceGeography=Jn;