semiotic 3.0.1 → 3.1.0

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