semiotic 3.8.5 → 3.8.6

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 (176) hide show
  1. package/CLAUDE.md +5 -4
  2. package/README.md +42 -42
  3. package/ai/behaviorContracts.cjs +2 -2
  4. package/ai/componentMetadata.cjs +1 -1
  5. package/ai/dist/mcp-server.js +2 -0
  6. package/ai/examples.md +44 -2
  7. package/ai/schema.json +385 -14
  8. package/ai/surface-manifest.json +6 -4
  9. package/ai/system-prompt.md +1 -1
  10. package/dist/{chunk-chartContainerDataAudit-74TLKIP6.module.min.js → chunk-chartContainerDataAudit-FEOD5GTQ.module.min.js} +1 -1
  11. package/dist/chunk-chunk-2CHN2TA3.module.min.js +1 -0
  12. package/dist/chunk-chunk-2JGJ5GUG.module.min.js +1 -0
  13. package/dist/chunk-chunk-3NGIKFD6.module.min.js +1 -0
  14. package/dist/chunk-chunk-3SHB24AG.module.min.js +1 -0
  15. package/dist/chunk-chunk-4MMOOYTX.module.min.js +2 -0
  16. package/dist/{chunk-chunk-KT2VAZMZ.module.min.js → chunk-chunk-75OTQSXS.module.min.js} +1 -1
  17. package/dist/chunk-chunk-A5GRQUOF.module.min.js +1 -0
  18. package/dist/chunk-chunk-AAF5LZAU.module.min.js +2 -0
  19. package/dist/{chunk-chunk-4AANPFOX.module.min.js → chunk-chunk-ARZGA4LJ.module.min.js} +1 -1
  20. package/dist/chunk-chunk-CAFLML4L.module.min.js +2 -0
  21. package/dist/chunk-chunk-FHBN7OEB.module.min.js +2 -0
  22. package/dist/{chunk-chunk-TMWIZL3K.module.min.js → chunk-chunk-GFTVACTO.module.min.js} +1 -1
  23. package/dist/chunk-chunk-IP2UE74X.module.min.js +1 -0
  24. package/dist/chunk-chunk-ITDWLZXV.module.min.js +2 -0
  25. package/dist/chunk-chunk-LPSPATPC.module.min.js +1 -0
  26. package/dist/chunk-chunk-OM6NWS4H.module.min.js +2 -0
  27. package/dist/chunk-chunk-PX5YQGDP.module.min.js +2 -0
  28. package/dist/chunk-chunk-Q2BS46W2.module.min.js +2 -0
  29. package/dist/{chunk-chunk-LJLS6DY7.module.min.js → chunk-chunk-RA7JCG7D.module.min.js} +1 -1
  30. package/dist/chunk-chunk-RNUHEXZA.module.min.js +2 -0
  31. package/dist/chunk-chunk-ROZWKEUG.module.min.js +1 -0
  32. package/dist/chunk-chunk-SMVD3EQJ.module.min.js +2 -0
  33. package/dist/chunk-chunk-T2FKJD4O.module.min.js +2 -0
  34. package/dist/{chunk-chunk-K3DMEW22.module.min.js → chunk-chunk-UDREYOLV.module.min.js} +1 -1
  35. package/dist/chunk-chunk-VOWE3SAP.module.min.js +2 -0
  36. package/dist/chunk-chunk-VQPNBUSW.module.min.js +2 -0
  37. package/dist/{chunk-chunk-N5DDKCCF.module.min.js → chunk-chunk-WAWCIHFJ.module.min.js} +1 -1
  38. package/dist/{chunk-chunk-XXWSHGPL.module.min.js → chunk-chunk-WYARAXHR.module.min.js} +1 -1
  39. package/dist/{chunk-chunk-I36PJ4OC.module.min.js → chunk-chunk-XP3OHHFX.module.min.js} +1 -1
  40. package/dist/chunk-chunk-XV3KGYTR.module.min.js +2 -0
  41. package/dist/chunk-chunk-YC2IVEPX.module.min.js +1 -0
  42. package/dist/components/ai/chartCapabilities.d.ts +2 -1
  43. package/dist/components/charts/custom/XYCustomChart.d.ts +3 -0
  44. package/dist/components/charts/geo/DistanceCartogram.d.ts +1 -1
  45. package/dist/components/charts/index.d.ts +3 -0
  46. package/dist/components/charts/ordinal/BarChart.d.ts +7 -14
  47. package/dist/components/charts/ordinal/GaugeChart.d.ts +3 -0
  48. package/dist/components/charts/ordinal/GroupedBarChart.d.ts +3 -0
  49. package/dist/components/charts/ordinal/StackedBarChart.d.ts +3 -0
  50. package/dist/components/charts/ordinal/SwimlaneChart.d.ts +4 -14
  51. package/dist/components/charts/shared/chartSpecCore.d.ts +2 -4
  52. package/dist/components/charts/shared/gaugeGradient.d.ts +4 -8
  53. package/dist/components/charts/shared/gradient.d.ts +35 -0
  54. package/dist/components/charts/shared/hatchFill.d.ts +3 -10
  55. package/dist/components/charts/shared/hooks.d.ts +2 -50
  56. package/dist/components/charts/shared/knownChartComponents.d.ts +1 -1
  57. package/dist/components/charts/shared/streamPropsHelpers.d.ts +1 -2
  58. package/dist/components/charts/shared/useChartLegend.d.ts +58 -0
  59. package/dist/components/charts/shared/useChartSetup.d.ts +5 -0
  60. package/dist/components/charts/shared/useCustomChartSetup.d.ts +6 -1
  61. package/dist/components/charts/shared/useNetworkChartSetup.d.ts +1 -0
  62. package/dist/components/charts/shared/useStreamingLegend.d.ts +1 -1
  63. package/dist/components/charts/xy/AreaChart.d.ts +25 -42
  64. package/dist/components/charts/xy/BumpChart.capability.d.ts +11 -0
  65. package/dist/components/charts/xy/BumpChart.d.ts +161 -0
  66. package/dist/components/charts/xy/DifferenceChart.d.ts +3 -10
  67. package/dist/components/charts/xy/Heatmap.d.ts +3 -0
  68. package/dist/components/charts/xy/LineChart.d.ts +6 -8
  69. package/dist/components/geometry/bumpRibbonGeometry.d.ts +36 -0
  70. package/dist/components/legendLayout.d.ts +19 -1
  71. package/dist/components/semiotic-ai.d.ts +2 -1
  72. package/dist/components/semiotic-geo.d.ts +1 -0
  73. package/dist/components/semiotic-network.d.ts +1 -0
  74. package/dist/components/semiotic-ordinal.d.ts +2 -0
  75. package/dist/components/semiotic-physics.d.ts +1 -0
  76. package/dist/components/semiotic-realtime-core.d.ts +1 -0
  77. package/dist/components/semiotic-server-edge.d.ts +1 -1
  78. package/dist/components/semiotic-server.d.ts +1 -1
  79. package/dist/components/semiotic-xy.d.ts +4 -0
  80. package/dist/components/semiotic.d.ts +4 -4
  81. package/dist/components/server/serverChartConfigs.d.ts +1 -0
  82. package/dist/components/server/serverChartConfigsXY.d.ts +1 -0
  83. package/dist/components/server/staticLegend.d.ts +4 -2
  84. package/dist/components/server/staticSVGChrome.d.ts +4 -4
  85. package/dist/components/stream/GeoSVGOverlay.d.ts +4 -10
  86. package/dist/components/stream/NetworkSVGOverlay.d.ts +2 -6
  87. package/dist/components/stream/OrdinalSVGOverlay.d.ts +2 -6
  88. package/dist/components/stream/SVGOverlay.d.ts +2 -6
  89. package/dist/components/stream/StalenessBadge.d.ts +2 -6
  90. package/dist/components/stream/geoTypes.d.ts +3 -6
  91. package/dist/components/stream/legendRenderer.d.ts +2 -6
  92. package/dist/components/stream/ordinalTypes.d.ts +7 -31
  93. package/dist/components/stream/physics/PhysicsKernel.d.ts +1 -0
  94. package/dist/components/stream/physics/PhysicsSVGOverlay.d.ts +2 -6
  95. package/dist/components/stream/physics/StreamPhysicsTypes.d.ts +2 -6
  96. package/dist/components/stream/pipelineConfig.d.ts +7 -15
  97. package/dist/components/stream/renderers/canvasRenderHelpers.d.ts +9 -69
  98. package/dist/components/stream/renderers/cornerRadii.d.ts +2 -9
  99. package/dist/components/stream/renderers/thresholdLineSegments.d.ts +12 -0
  100. package/dist/components/stream/sceneToSVGShared.d.ts +3 -5
  101. package/dist/components/stream/types.d.ts +32 -56
  102. package/dist/components/stream/xySceneBuilders/areaGradient.d.ts +4 -20
  103. package/dist/components/stream/xySceneBuilders/types.d.ts +6 -6
  104. package/dist/components/types/legendTypes.d.ts +15 -6
  105. package/dist/geo.min.js +1 -1
  106. package/dist/geo.module.min.js +1 -1
  107. package/dist/network.min.js +1 -1
  108. package/dist/network.module.min.js +1 -1
  109. package/dist/ordinal.min.js +1 -1
  110. package/dist/ordinal.module.min.js +1 -1
  111. package/dist/physics.min.js +1 -1
  112. package/dist/physics.module.min.js +1 -1
  113. package/dist/physicsWorker.js +1 -1
  114. package/dist/realtime.min.js +1 -1
  115. package/dist/realtime.module.min.js +1 -1
  116. package/dist/semiotic-ai-core.min.js +1 -1
  117. package/dist/semiotic-ai-core.module.min.js +1 -1
  118. package/dist/semiotic-ai.d.ts +2 -1
  119. package/dist/semiotic-ai.min.js +1 -1
  120. package/dist/semiotic-ai.module.min.js +1 -1
  121. package/dist/semiotic-experimental.min.js +1 -1
  122. package/dist/semiotic-experimental.module.min.js +1 -1
  123. package/dist/semiotic-geo.d.ts +1 -0
  124. package/dist/semiotic-network.d.ts +1 -0
  125. package/dist/semiotic-ordinal.d.ts +2 -0
  126. package/dist/semiotic-physics.d.ts +1 -0
  127. package/dist/semiotic-realtime-core.d.ts +1 -0
  128. package/dist/semiotic-realtime-core.min.js +1 -1
  129. package/dist/semiotic-realtime-core.module.min.js +1 -1
  130. package/dist/semiotic-recipes-core.module.min.js +1 -1
  131. package/dist/semiotic-recipes.module.min.js +1 -1
  132. package/dist/semiotic-server-edge.d.ts +1 -1
  133. package/dist/semiotic-server-edge.min.js +1 -1
  134. package/dist/semiotic-server-edge.module.min.js +1 -1
  135. package/dist/semiotic-server-node.min.js +1 -1
  136. package/dist/semiotic-server-node.module.min.js +1 -1
  137. package/dist/semiotic-server.d.ts +1 -1
  138. package/dist/semiotic-utils-core.min.js +1 -1
  139. package/dist/semiotic-utils-core.module.min.js +1 -1
  140. package/dist/semiotic-utils.min.js +1 -1
  141. package/dist/semiotic-utils.module.min.js +1 -1
  142. package/dist/semiotic-xy.d.ts +4 -0
  143. package/dist/semiotic.d.ts +4 -4
  144. package/dist/semiotic.min.js +1 -1
  145. package/dist/semiotic.module.min.js +1 -1
  146. package/dist/server.min.js +1 -1
  147. package/dist/server.module.min.js +1 -1
  148. package/dist/xy.min.js +1 -1
  149. package/dist/xy.module.min.js +1 -1
  150. package/package.json +1 -1
  151. package/dist/chunk-chunk-5I3UZV4Q.module.min.js +0 -2
  152. package/dist/chunk-chunk-74CCPVXB.module.min.js +0 -1
  153. package/dist/chunk-chunk-ANYDWOZF.module.min.js +0 -1
  154. package/dist/chunk-chunk-AVBI6GDT.module.min.js +0 -1
  155. package/dist/chunk-chunk-BANTPINB.module.min.js +0 -2
  156. package/dist/chunk-chunk-C57LR3YG.module.min.js +0 -1
  157. package/dist/chunk-chunk-CKMD5NV3.module.min.js +0 -2
  158. package/dist/chunk-chunk-CWQ5YIHX.module.min.js +0 -2
  159. package/dist/chunk-chunk-E6TXX6MI.module.min.js +0 -1
  160. package/dist/chunk-chunk-L6EA5V3G.module.min.js +0 -2
  161. package/dist/chunk-chunk-LJPCLYSC.module.min.js +0 -2
  162. package/dist/chunk-chunk-LRIFN2HK.module.min.js +0 -1
  163. package/dist/chunk-chunk-NEVE562N.module.min.js +0 -1
  164. package/dist/chunk-chunk-NLO44TOS.module.min.js +0 -2
  165. package/dist/chunk-chunk-PZJ2SBLL.module.min.js +0 -2
  166. package/dist/chunk-chunk-QUJ6TTLY.module.min.js +0 -1
  167. package/dist/chunk-chunk-RBIDBUT4.module.min.js +0 -2
  168. package/dist/chunk-chunk-RFLAG356.module.min.js +0 -1
  169. package/dist/chunk-chunk-RPU4IZAV.module.min.js +0 -2
  170. package/dist/chunk-chunk-SKMBCFIL.module.min.js +0 -2
  171. package/dist/chunk-chunk-TAE7W424.module.min.js +0 -2
  172. package/dist/chunk-chunk-TUBMTZMU.module.min.js +0 -2
  173. package/dist/chunk-chunk-UFFEXJQY.module.min.js +0 -1
  174. package/dist/chunk-chunk-XSCHTS4D.module.min.js +0 -2
  175. package/dist/chunk-statisticalOverlays-QGDLRUHX.module.min.js +0 -1
  176. package/dist/chunk-statisticalOverlays-T77OKLDY.module.min.js +0 -1
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{useChartSetup as t,useCustomChartScaffold as e}from"./chunk-chunk-VQPNBUSW.module.min.js";import{lineCanvasRenderer as n,resolveNodeColor as i}from"./chunk-chunk-SMVD3EQJ.module.min.js";import{RingBuffer as o,compactTimestampBufferForRemoval as r,computePulseIntensity as s,hasActivePulses as a,pointCanvasRenderer as c,pushWithTimestamp as l,refreshIdlePulse as u,setPulseState as h,useGeoKeyboardNavigation as d,useLegendCategoryEmission as p,useSemanticFrameInteractions as f}from"./chunk-chunk-OM6NWS4H.module.min.js";import{needsDataCanvasPaint as m,needsInteractionCanvasPaint as g,paintCanvasBackground as y}from"./chunk-chunk-GFTVACTO.module.min.js";import{StalenessBadge as v,attachUpdateResultStore as b,buildBaseMetadataProps as w,buildCustomBehaviorProps as P,composeOverlays as x,computeDecayOpacity as R,createCustomLayoutFailureDiagnostic as A,filterAnnotationsByStatus as S,findHitPointInQuadtree as L,formatVal as k,getHitRadius as C,glyphCanvasRenderer as D,paintSceneWithBackend as j,renderPathPulse as M,renderSceneWithBackend as T,useConfigSync as B,useLayoutSelectionSync as _,useStableShallow as I,useStalenessCheck as E,warnCustomLayoutDiagnostics as N}from"./chunk-chunk-WYARAXHR.module.min.js";import{wrapWithCustomLayoutSelection as O}from"./chunk-chunk-5UKL5W76.module.min.js";import{buildResolveColor as W,resolveCustomLayoutPalette as F}from"./chunk-chunk-RA7JCG7D.module.min.js";import{AccessibleDataTable as H,AriaLiveTooltip as z,CanvasFrameBackground as G,FlippingTooltip as q,FocusRing as Z,STREAMING_PALETTE as X,SceneRevisionDiagnosticsObserver as Y,ScreenReaderSummary as U,SkipToTableLink as Q,TITLE_BASELINE as V,UpdateResultTracker as $,annotationLayout as J,coerceCanvasFill as K,computeCanvasAriaLabel as tt,computeEasing as et,computeRawProgress as nt,createDefaultAnnotationRules as it,defaultTooltipStyle as ot,filterSparseArray as rt,geoSceneNodeToSVG as st,getDevicePixelRatio as at,getPointerHitRadius as ct,isAnnotationActivationTarget as lt,isServerEnvironment as ut,lerp as ht,normalizeTooltip as dt,now as pt,observationInputType as ft,prepareCanvas as mt,renderAnnotationPass as gt,renderLegendFromConfig as yt,resolveCSSColor as vt,smartTooltipEntries as bt,useAnnotationActivationOptions as wt,useFrame as Pt,useFrameCanvasHost as xt,useSceneRevisionDiagnostics as Rt}from"./chunk-chunk-PX5YQGDP.module.min.js";import{getMax as At}from"./chunk-chunk-JJ2OOIET.module.min.js";import{resolveThemeSemanticColors as St}from"./chunk-chunk-WCX6U47H.module.min.js";import{glyphHitGeometry as Lt}from"./chunk-chunk-KTWEBFMX.module.min.js";import{SafeRender as kt,useHydration as Ct,useWasHydratingFromSSR as Dt}from"./chunk-chunk-ACLDBMRH.module.min.js";import{useRef as jt,useState as Mt,useEffect as Tt,useMemo as Bt,useCallback as _t,useImperativeHandle as It,forwardRef as Et,memo as Nt}from"react";import{geoPath as Ot}from"d3-geo";import{quadtree as Wt}from"d3-quadtree";import{geoMercator as Ft,geoEqualEarth as Ht,geoAlbersUsa as zt,geoOrthographic as Gt,geoNaturalEarth1 as qt,geoEquirectangular as Zt}from"d3-geo";var Xt={mercator:Ft,equalEarth:Ht,albersUsa:zt,orthographic:Gt,naturalEarth:qt,equirectangular:Zt};function Yt(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function Ut(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function Qt(t,e,n){return t?"function"==typeof t?{...n,...t(e)}:{...n,...t}:{...n}}function Vt(t,e){if(2>t.length)return[t];const n=.4*e,i=[];let o=[t[0]];for(let e=1;t.length>e;e++){const r=t[e];Math.abs(r[0]-t[e-1][0])>n?(2>o.length||i.push(o),o=[r]):o.push(r)}return 2>o.length||i.push(o),i}function $t(t,e,n=24){const i=e[0]-t[0],o=e[1]-t[1],r=Math.sqrt(i*i+o*o);if(0===r)return[t,e];const s=-o/r,a=i/r,c=Math.min(.3*r,80),l=(t[0]+e[0])/2+s*c,u=(t[1]+e[1])/2+a*c,h=[];for(let i=0;n>=i;i++){const o=i/n,r=1-o;h.push([r*r*t[0]+2*r*o*l+o*o*e[0],r*r*t[1]+2*r*o*u+o*o*e[1]])}return h}function Jt(t,e){if(2>t.length)return t;const n=e/2+1,i=[];for(let e=0;t.length>e;e++){const o=t[e];let r,s;0===e?(r=t[1][0]-o[0],s=t[1][1]-o[1]):e===t.length-1?(r=o[0]-t[e-1][0],s=o[1]-t[e-1][1]):(r=t[e+1][0]-t[e-1][0],s=t[e+1][1]-t[e-1][1]);const a=Math.sqrt(r*r+s*s)||1;i.push([o[0]+s/a*n,o[1]+-r/a*n])}return i}function Kt(t,e,n,i,o){const r=e[0]-t[0],s=e[1]-t[1],a=Math.sqrt(r*r+s*s);if(0===a)return[t,e];const c=s/a,l=-r/a,u=o/2+1;return[[t[0]+c*u,t[1]+l*u],[e[0]+c*u,e[1]+l*u]]}import{scaleLinear as te}from"d3-scale";var ee=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ne=["scene-style","data-paint","accessibility","evidence"],ie=(t,e)=>({retainedData:t,invalidations:e}),oe=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],re=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],se=["scene-geometry","data-paint","accessibility","evidence"],ae=["scene-style","data-paint","accessibility","evidence"],ce=["overlay","accessibility","evidence"],le=[],ue={xAccessor:ie("rebuild",oe),yAccessor:ie("rebuild",oe),lineDataAccessor:ie("rebuild",oe),pointIdAccessor:ie("rebuild",se),lineIdAccessor:ie("rebuild",se),windowSize:ie("rebuild",oe),projection:ie("preserve",re),projectionExtent:ie("preserve",re),fitPadding:ie("preserve",re),lineType:ie("preserve",re),flowStyle:ie("preserve",re),graticule:ie("preserve",re),projectionTransform:ie("preserve",re),customLayout:ie("preserve",re),layoutConfig:ie("preserve",re),layoutMargin:ie("preserve",re),areaStyle:ie("preserve",ae),pointStyle:ie("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:ie("preserve",ae),colorScheme:ie("preserve",ae),themeCategorical:ie("preserve",ae),themeDiverging:ie("preserve",ae),themeSemantic:ie("preserve",ae),themeSequential:ie("preserve",ae),decay:ie("preserve",ae),pulse:ie("preserve",ae),layoutSelection:ie("preserve",ae),annotations:ie("preserve",ce),autoPlaceAnnotations:ie("preserve",ce),clock:ie("preserve",le),transition:ie("preserve",le),introAnimation:ie("preserve",le),onLayoutError:ie("preserve",le)},he=ie("preserve",re),de=class{constructor(){this.tracker=new $}get last(){return this.tracker.last}subscribe(t){return this.tracker.subscribe(t)}recordData(t,e){return this.tracker.record({kind:t,...void 0===e?{}:{count:e}},ee)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},ne):this.recordNoop("restyle")}recordConfig(t,e={}){const n=function(t){let e="preserve";const n=new Set;for(const i of t){const t=ue[i]??he;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)n.add(e)}return{retainedData:e,invalidations:n}}(t),i=new Set(n.invalidations);return e.retainedDataChanged&&i.add("data"),this.tracker.record({kind:"config",keys:t},i)}};import{geoDistance as pe,geoGraticule as fe,geoInterpolate as me}from"d3-geo";function ge(t){if(null==t)return 0;if("number"==typeof t&&Number.isFinite(t)&&t>=0&&.5>t)return t;throw new RangeError(`[semiotic] fitPadding must be a finite fraction in [0, 0.5); received ${t+""}.`)}var ye=class t{constructor(t){this.updateResults=new de,this.scene=[],this.scales=null,this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this.config=function(t){return{...t,fitPadding:ge(t.fitPadding)}}(t)}currentTime(){return this.config.clock?.()??pt()}getConfiguredWindowSize(){const t=this.config.windowSize??500;if(!Number.isInteger(t)||1>t)throw Error("GeoPipelineStore windowSize must be a positive integer");return t}retainNewestLines(t=this.getConfiguredWindowSize()){this.lineData.length>t&&(this.lineData=this.lineData.slice(-t))}resizeStreamingWindow(t){if(this.pointBuffer){const e=this.pointBuffer.toArray(),n=this.timestampBuffer?.toArray()??[],i=e.slice(-t),r=n.slice(-i.length),s=this.currentTime();this.pointBuffer=new o(t),this.timestampBuffer=new o(t),i.forEach((t,e)=>{this.pointBuffer.push(t),this.timestampBuffer.push(r[e]??s)})}this.retainNewestLines(t)}updateConfig(t){const e=function(t){return"fitPadding"in t?{...t,fitPadding:ge(t.fitPadding)}:t}(t),n=this.config,i=this.getConfiguredWindowSize(),o=Object.keys(e).filter(t=>e[t]!==n[t]);this.config={...this.config,...e};const r=this.getConfiguredWindowSize(),s=this.streaming&&r!==i;s&&(this.resizeStreamingWindow(r),this.version++),"customLayout"in e&&!e.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(o,{retainedDataChanged:s})}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}setAreas(t){this.areas=t,this.updateResults.recordData("replace",t.length)}setAreasWithResult(t){return this.setAreas(t),this.updateResults.last}setPoints(t){this.pointData=t.slice(),this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.updateResults.recordData("replace",t.length)}setPointsWithResult(t){return this.setPoints(t),this.updateResults.last}setLines(t){this.lineData=t.slice(),this.streaming&&this.retainNewestLines(),this.updateResults.recordData("replace",t.length)}setLinesWithResult(t){return this.setLines(t),this.updateResults.last}initStreaming(t){void 0!==t&&t!==this.config.windowSize&&(this.config={...this.config,windowSize:t});const e=this.getConfiguredWindowSize(),n=this.pointBuffer?this.pointBuffer.toArray():this.pointData,i=this.timestampBuffer?.toArray()??[],r=n.slice(-e),s=i.slice(-r.length),a=this.currentTime();this.pointBuffer=new o(e),this.timestampBuffer=new o(e),r.forEach((t,e)=>{this.pointBuffer.push(t),this.timestampBuffer.push(s[e]??a)}),this.pointData=[],this.retainNewestLines(e),this.streaming=!0}pushPoint(t){this.pointBuffer||this.initStreaming();const e=this.currentTime();l(this.pointBuffer,t,this.timestampBuffer,e),this.lastIngestTime=e,this.updateResults.recordData("ingest",1)}pushPointWithResult(t){return this.pushPoint(t),this.updateResults.last}pushMany(t){this.pointBuffer||this.initStreaming();const e=this.currentTime();for(const n of t)l(this.pointBuffer,n,this.timestampBuffer,e);this.lastIngestTime=e,this.updateResults.recordData("ingest",t.length)}pushManyWithResult(t){return this.pushMany(t),this.updateResults.last}pushLine(t){null!=t&&"object"==typeof t?(this.streaming||this.initStreaming(),this.lineData.push(t),this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",1)):this.updateResults.recordNoop("ingest")}pushManyLines(t){if(!Array.isArray(t)||0===t.length)return void this.updateResults.recordNoop("ingest");const e=t.filter(t=>null!=t&&"object"==typeof t);if(0!==e.length){this.streaming||this.initStreaming();for(const t of e)this.lineData.push(t);this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",e.length)}else this.updateResults.recordNoop("ingest")}removeLine(t){const{lineIdAccessor:e}=this.config;if(!e)throw Error("removeLine() requires lineIdAccessor to be configured");const n="function"==typeof e?e:t=>t[e],i=new Set(Array.isArray(t)?t:[t]),o=[];return this.lineData=this.lineData.filter(t=>!i.has(n(t)+"")||(o.push(t),!1)),o.length>0?(this.version++,this.updateResults.recordData("remove",o.length)):this.updateResults.recordNoop("remove"),o}getLines(){return this.lineData.slice()}removePoint(t){const{pointIdAccessor:e}=this.config;if(!e)throw Error("removePoint() requires pointIdAccessor to be configured");const n="function"==typeof e?e:t=>t[e],i=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>i.has(n(t)+"");r(this.pointBuffer,this.timestampBuffer,t);const e=this.pointBuffer.remove(t);return e.length>0?(this.version++,this.updateResults.recordData("remove",e.length)):this.updateResults.recordNoop("remove"),e}{const t=[];return this.pointData=this.pointData.filter(e=>!i.has(n(e)+"")||(t.push(e),!1)),t.length>0?(this.version++,this.updateResults.recordData("remove",t.length)):this.updateResults.recordNoop("remove"),t}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this.version++,this.updateResults.recordData("clear")}restyleScene(t){const e=this._customRestyle;if(e){for(const n of this.scene){const i=this._baseStyles.get(n)??n.style,o=e(n,t);n.style=o?{...i,...o}:i}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(t){const{config:e}=this,n=this.projection,i=this.geoPath,o=this.scales,r=this.baseScale,s=[...this.baseTranslate],a=[...this.baseRotation],c=this.scene;this.projection=function(t){if(!t)return Ht();if("string"==typeof t){const e=Xt[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),Ht())}if("object"==typeof t&&"type"in t){const e=Xt[t.type],n=e?e():Ht();return t.rotate&&"rotate"in n&&n.rotate(t.rotate),t.center&&"center"in n&&n.center(t.center),n}return t}(e.projection),this.geoPath=Ot(this.projection),this.fitProjection(t),this.geoPath=Ot(this.projection);const l=this.projection;this.scales={projection:l,geoPath:this.geoPath,projectedPoint:(t,e)=>l([t,e]),invertedPoint:(t,e)=>l.invert?l.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const u=this.buildSceneNodes(t);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=n,this.geoPath=i,this.scales=o,this.baseScale=r,this.baseTranslate=s,this.baseRotation=a):(this.scene=[],this.rebuildQuadtree());else{if(this.scene=u,this.rebuildQuadtree(),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&!this._hasRenderedOnce&&this.scene.length>0&&e.introAnimation){const e=t.width/2,n=t.height/2,i=this.scene.filter(t=>"point"===t.type).map(t=>({...t,x:e,y:n}));i.length>0&&this.startTransition(i)}this._hasRenderedOnce=!0,e.transition&&c.length>0&&this.startTransition(c),this.version++}}fitProjection(t){const e=this.projection,n=this.config,i=[...this.areas],o=Yt(n.xAccessor,"lon"),r=Yt(n.yAccessor,"lat"),s=this.getPoints();if(s.length>0){const t=s.map(t=>[o(t),r(t)]);i.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const a=Ut(n.lineDataAccessor);for(const t of this.lineData){const e=a(t);if(e&&e.length>0){const t=e.map(t=>[o(t),r(t)]);i.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==i.length){if(n.projectionExtent){const[[i,o],[r,s]]=n.projectionExtent;e.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[i,o],[i,s],[r,s],[r,o],[i,o]]]}})}else if(e.clipAngle&&(e.clipAngle()??0)>0){const i=n.fitPadding??0,o=Math.min(t.width,t.height);e.scale(o/2-o*i),e.translate([t.width/2,t.height/2])}else{const o=n.fitPadding??0,r=t.width*o,s=t.height*o;e.fitExtent([[r,s],[t.width-r,t.height-s]],{type:"FeatureCollection",features:i})}this.baseScale=e.scale(),this.baseTranslate=e.translate(),this.baseRotation=e.rotate?.()??[0,0,0]}}applyZoomTransform(t,e){const n=this.projection;if(!n)return;const i=this.geoPath,o=this.scales,r=n.scale(),s=[...n.translate()],a=this.currentZoom;n.scale(this.baseScale*t.k),n.translate([this.baseTranslate[0]*t.k+t.x,this.baseTranslate[1]*t.k+t.y]),this.currentZoom=t.k,this.geoPath=Ot(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.scale(r),n.translate(s),this.currentZoom=a,this.geoPath=i,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyZoomScale(t,e){const n=this.projection;if(!n)return;const i=this.geoPath,o=this.scales,r=n.scale(),s=[...n.translate()],a=this.currentZoom;n.scale(this.baseScale*t),n.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=Ot(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.scale(r),n.translate(s),this.currentZoom=a,this.geoPath=i,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}applyRotation(t,e){const n=this.projection;if(!n||!n.rotate)return;const i=this.geoPath,o=this.scales,r=[...n.rotate()];n.rotate(t),this.geoPath=Ot(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(t,e)=>n([t,e]),invertedPoint:(t,e)=>n.invert?n.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const s=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.rotate(r),this.geoPath=i,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=s,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}setRotation(t){const e=this.projection;e&&e.rotate&&e.rotate(t)}hasProjection(){return null!=this.projection}getRotation(){return this.projection?.rotate?.()??this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let e=0,n=0;for(const t of this.scene)"point"===t.type&&(n++,t.r>e&&(e=t.r));if(this._maxPointRadius=e,t.QUADTREE_THRESHOLD>=n)return void(this._quadtree=null);const i=Array(n);let o=0;for(const t of this.scene)"point"===t.type&&(i[o++]=t);this._quadtree=Wt().x(t=>t.x).y(t=>t.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(t){this._customLayoutFailedThisBuild=!1;const{config:e}=this,n=this.projection,i=this.geoPath;if(e.customLayout&&this.scales){const n=e.layoutMargin??{top:0,right:0,bottom:0,left:0},i=F(e.colorScheme,e.themeCategorical,X),o={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:t.width,height:t.height,margin:n,plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:e.themeSemantic??{},categorical:[...i]},resolveColor:W(i,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};let r;try{r=e.customLayout(o)}catch(t){const n=null!==this.lastCustomLayoutResult,i=A("geo",t,n,this.version);this.lastCustomLayoutFailure=i,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] geo customLayout threw:",t);try{e.onLayoutError?.(i)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return n?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}const s=r.nodes??[];if(this.customLayoutOverlays=r.overlays??null,this.lastCustomLayoutResult=r,this.lastCustomLayoutFailure=null,this._customRestyle=r.restyle,this.hasCustomRestyle=!!r.restyle,this._baseStyles=new WeakMap,this.hasCustomRestyle){for(const t of s)this._baseStyles.set(t,t.style);this.restyleScene(e.layoutSelection??null)}return N({label:"geo customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}return this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,function({config:t,projection:e,path:n,areas:i,points:o,lines:r,layout:s}){const a=Yt(t.xAccessor,"lon"),c=Yt(t.yAccessor,"lat"),l=[],u=function(t){return{fill:t.themeSemantic?.surface||"#e0e0e0",stroke:t.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}(t),h=function(t){return{stroke:t.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}(t),d=function(t){return{fill:t.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(t);if(t.graticule){const e=!0===t.graticule?{}:t.graticule,i=fe();e.step&&i.step(e.step);const o=n(i())||"";o&&l.push({type:"geoarea",pathData:o,centroid:[s.width/2,s.height/2],bounds:[[0,0],[s.width,s.height]],screenArea:0,style:{fill:"none",stroke:e.stroke||"#e0e0e0",strokeWidth:e.strokeWidth||.5,strokeDasharray:e.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const e of i){const i=n(e);if(!i)continue;const o=n.centroid(e),r=n.bounds(e),s=n.area(e);l.push({type:"geoarea",pathData:i,centroid:o,bounds:r,screenArea:s,style:Qt(t.areaStyle,e,u),datum:e,interactive:!0})}const p=Ut(t.lineDataAccessor);for(const n of r){const i=p(n);if(!i||2>i.length)continue;let o=[];if("geo"===t.lineType){const t=Array(i.length);for(let e=0;i.length>e;e++)t[e]=[a(i[e]),c(i[e])];for(let n=0;t.length-1>n;n++){const i=t[n],r=t[n+1],s=pe(i,r)||0,a=Math.max(2,Math.ceil(s/(Math.PI/180))),c=me(i,r);for(let t=0;a>=t;t++){if(n>0&&0===t)continue;const i=e(c(t/a));null!=i&&o.push(i)}}}else for(let t=0;i.length>t;t++){const n=i[t],r=e([a(n),c(n)]);null!=r&&o.push(r)}if(2>o.length)continue;const r=Qt(t.lineStyle,n,h),u="number"==typeof r.strokeWidth?r.strokeWidth:1;2!==i.length||2>o.length||"arc"!==t.flowStyle?2!==i.length||2>o.length||"offset"!==t.flowStyle||(o="geo"===t.lineType?Jt(o,u):Kt(o[0],o[o.length-1],0,0,u)):o=$t(o[0],o[o.length-1]);const d=Vt(o,s.width);if(d.length>1)for(const t of d)2>t.length||l.push({type:"line",path:t,style:{...r,_edgeFade:!0},datum:n});else l.push({type:"line",path:2>o.length&&d[0]||o,style:r,datum:n})}const f=t.pointIdAccessor?"function"==typeof t.pointIdAccessor?t.pointIdAccessor:e=>e[t.pointIdAccessor]:null,m=e.clipAngle?e.clipAngle()??0:0,g=m>0?m*Math.PI/180:null,y=e.rotate?e.rotate():[0,0,0],v="function"==typeof e.center?e.center():[0,0],b=[(v[0]??0)-y[0],(v[1]??0)-y[1]];for(const n of o){const i=a(n),o=c(n);if(null!=g&&pe([i,o],b)>g)continue;const r=e([i,o]);if(!r)continue;const s=t.pointStyle?t.pointStyle(n):{...d},u={type:"point",x:r[0],y:r[1],r:s.r||4,style:s,datum:n,pointId:f?f(n)+"":void 0};l.push(u)}return l}({config:e,projection:n,path:i,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:t})}applyCartogramTransform(t,e){const n=function(t,e,n,i){const o=t.filter(t=>"point"===t.type);if(2>o.length)return null;const r=e.strength??1,s=Number.isFinite(r)?Math.max(0,Math.min(1,r)):1,a="strip"===e.layout?"strip":"radial";if("radial"===a&&0===s)return null;const c=e.centerAccessor?"function"==typeof e.centerAccessor?e.centerAccessor:t=>t[e.centerAccessor]:t=>t.id,l="function"==typeof e.costAccessor?e.costAccessor:t=>t[e.costAccessor],u=o.find(t=>t.datum&&c(t.datum)+""==e.center+"");if(!u)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${e.center}" not found in point data`),null;const h=o.map(t=>t.datum?Number(l(t.datum)):NaN).filter(t=>isFinite(t)&&t>=0),d=At(h,1);i>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.");for(let e=t.length-1;e>=0;e--){const n=t[e];"geoarea"===n.type&&n.interactive&&t.splice(e,1)}const p="strip"===a?function(t,e,n,i,o){const r=Math.max(3,Math.min(8,.35*o.height)),s=Math.max(1,o.width-2*r),a=o.height/2,c=te().domain([0,i]).range([0,s]);e.x=r,e.y=a;const l=[];for(const o of t){if(o===e)continue;if(!o.datum){o.x=r,o.y=a;continue}const t=Number(n(o.datum)),s=r+(isFinite(t)&&t>=0&&i>0?c(t):0);o.x=s,o.y=a,l.push({node:o,x:s})}l.sort((t,e)=>t.x-e.x);const u=Math.max(0,Math.min(o.height/2-1,6));let h=0;for(;l.length>h;){let t=h+1;for(;l.length>t&&3>Math.abs(l[t].x-l[h].x);)t++;const e=t-h;if(e>1&&u>0)for(let t=0;e>t;t++)l[h+t].node.y=a+(t-(e-1)/2)*Math.min(2.5,2*u/Math.max(1,e-1));h=t}return{cx:r,cy:a,maxCost:i,availableRadius:s,layout:"strip"}}(o,u,l,d,n):function(t,e,n,i,o,r){const s=e.x,a=e.y,c=r.width/2,l=r.height/2,u=Math.min(r.width,r.height)/2,h=te().domain([0,i]).range([0,u]);for(const r of t){if(r===e)continue;if(!r.datum)continue;const t=r.x,u=r.y,d=Math.atan2(u-a,t-s),p=Math.hypot(t-s,u-a),f=Number(n(r.datum)),m=isFinite(f)&&f>=0?i>0?h(f):0:p,g=c+Math.cos(d)*m,y=l+Math.sin(d)*m;r.x=t+(g-t)*o,r.y=u+(y-u)*o}return e.x=s+(c-s)*o,e.y=a+(l-a)*o,{cx:e.x,cy:e.y,maxCost:i,availableRadius:u,layout:"radial"}}(o,u,l,d,s,n),f=t.filter(t=>"line"===t.type);if(f.length>0){const t=new Map;for(const e of o)null!=e.pointId&&t.set(e.pointId+"",[e.x,e.y]);for(const n of f){const i=n.datum?.source,o=n.datum?.target;if(null!=i&&null!=o){const r=t.get(i+""),s=t.get(o+"");if(r&&s)if("fractional"===e.lineMode&&n.path.length>2){const t=n.path[0],e=n.path[n.path.length-1],i=[r[0]-t[0],r[1]-t[1]],o=[s[0]-e[0],s[1]-e[1]],a=[0];for(let t=1;n.path.length>t;t++)a.push(a[t-1]+Math.hypot(n.path[t][0]-n.path[t-1][0],n.path[t][1]-n.path[t-1][1]));const c=a[a.length-1];n.path=n.path.map((t,e)=>{const r=c>0?a[e]/c:e/(n.path.length-1);return[t[0]+i[0]*(1-r)+o[0]*r,t[1]+i[1]*(1-r)+o[1]*r]})}else n.path=[r,s]}}}return p}(this.scene,t,e,this.areas.length);n&&(this.cartogramLayout=n)}applyDecay(){const t=this.config.decay;if(!t||!this.pointBuffer)return;const e=this.pointBuffer.size;if(0===e)return;const n=this.scene.filter(t=>"point"===t.type);for(let i=0;n.length>i;i++){const o=R(t,i,e);n[i]._decayOpacity=o,n[i].style={...n[i].style,opacity:o}}}applyPulse(t=this.currentTime()){const e=this.config.pulse;if(!e||!this.timestampBuffer)return!1;const n=this.scene.filter(t=>"point"===t.type),i=this.timestampBuffer.toArray(),o=e.color||"rgba(255,255,255,0.6)",r=e.glowRadius??4;let a=!1;for(let c=0;n.length>c&&i.length>c;c++){const l=s(e,i[c],t);a=h(n[c],l,o,r)||a}return a}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(t)}hasActivePulsesAt(t){return!!this.config.pulse&&a(this.config.pulse,this.timestampBuffer,t)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}startTransition(t){const e=this.config.transition?.duration??300;if(0>=e)return;const n=new Map;for(const e of t)"point"===e.type&&e.pointId&&n.set(e.pointId,[e.x,e.y]);const i=this.scene.filter(t=>"point"===t.type);let o=!1;for(const t of i)if(t.pointId){const e=n.get(t.pointId);e&&(t._targetX=t.x,t._targetY=t.y,t.x=e[0],t.y=e[1],(Math.abs(e[0]-t._targetX)>.5||Math.abs(e[1]-t._targetY)>.5)&&(o=!0))}for(const t of i)t.pointId&&!n.has(t.pointId)&&(t._targetOpacity=t.style?.opacity??1,t.style={...t.style,opacity:0},o=!0);o&&(this.activeTransition={startTime:this.currentTime(),duration:e})}cancelIntroAnimation(){this.activeTransition=null}advanceTransition(t){if(!this.activeTransition)return!1;const e=nt(t,this.activeTransition),n=et(e),i=this.scene.filter(t=>"point"===t.type);for(const t of i){if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=ht(t.x,t._targetX,n),t.y=ht(e,t._targetY,n)}null!=t._targetOpacity&&(t.style={...t.style,opacity:t._targetOpacity*n})}if(e>=1){for(const t of i)null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0),null!=t._targetOpacity&&(t.style={...t.style,opacity:t._targetOpacity},t._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}};ye.QUADTREE_THRESHOLD=500;var ve=ye;function be(t,e,n,i,o,r,s=0,a=i){if(r){const t=L(r,e,n,i,s);if(t)return t}else{let o=null,r=i;for(const s of t){if("point"!==s.type)continue;const t=s.x-e,a=s.y-n,c=Math.sqrt(t*t+a*a);C(s.r,i)>=c&&r>c&&(o=s,r=c)}if(o)return{node:o,distance:r}}let c=null,l=i;for(const o of t){if("glyph"!==o.type)continue;if(null==o.datum)continue;const t=Lt(o.glyph,o.size),r=o.x+t.centerDx-e,s=o.y+t.centerDy-n,a=Math.sqrt(r*r+s*s);C(t.radius,i)>=a&&l>a&&(c=o,l=a)}if(c)return{node:c,distance:l};for(let i=t.length-1;i>=0;i--){const r=t[i];if("geoarea"!==r.type)continue;const s=r;if(!1===s.interactive)continue;const[[a,c],[l,u]]=s.bounds;if(!(a>e||e>l||c>n||n>u)&&(s._cachedPath2D||(s._cachedPath2D=new Path2D(s.pathData)),o.isPointInPath(s._cachedPath2D,e,n)))return{node:s,distance:0}}let u=null,h=a;for(const i of t){if("line"!==i.type)continue;const t=i,{path:o}=t,r=Math.max((t.style.strokeWidth||2)+4,5,a);for(let i=0;o.length-1>i;i++){const[s,a]=o[i],[c,l]=o[i+1],d=we(e,n,s,a,c,l);r>=d&&h>d&&(u=t,h=d)}}return u?{node:u,distance:h}:null}function we(t,e,n,i,o,r){const s=o-n,a=r-i,c=s*s+a*a;if(0===c)return Math.sqrt((t-n)**2+(e-i)**2);let l=((t-n)*s+(e-i)*a)/c;return l=Math.max(0,Math.min(1,l)),Math.sqrt((t-(n+l*s))**2+(e-(i+l*a))**2)}b(ve);import{useMemo as Pe,useRef as xe}from"react";import{jsx as Re,jsxs as Ae}from"react/jsx-runtime";function Se(t){const{width:e,height:n,totalWidth:i,totalHeight:o,margin:r,showAxes:s,title:a,legend:c,legendHoverBehavior:l,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d,legendPosition:p,legendLayout:f,foregroundGraphics:m,annotations:g,onAnnotationActivate:y,onObservation:v,chartId:b,chartType:w,autoPlaceAnnotations:P,svgAnnotationRules:x,pointNodes:R,geoProjection:A}=t,L=wt({onAnnotationActivate:y,onObservation:v,chartId:b,chartType:w}),k=xe([g?.length??0,new Map]),C=g?.length??0;k.current[0]!==C&&(k.current=[C,new Map]);const D=Pe(()=>{if(!g||0===g.length)return null;const t=S(g),i=A?t.map(t=>{if(!Array.isArray(t.coordinates)||2>t.coordinates.length)return t;const e=A(Number(t.coordinates[0]),Number(t.coordinates[1]));return e?{...t,x:e[0],y:e[1]}:t}):t,o={scales:{x:t=>Number(t),y:t=>Number(t)},timeAxis:"x",width:e,height:n,frameType:"xy",pointNodes:R,stickyPositionCache:k.current[1]},r=P?J({annotations:i,context:o,..."object"==typeof P?P:{}}):i;return gt(r,it("xy",L),x,o)},[g,P,x,e,n,R,L,A]);return s||a||c||m||D&&D.length>0?Ae("svg",{role:"img",width:i,height:o,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[Re("title",{children:"string"==typeof a?a:"XY Chart"}),Re("desc",{children:"string"==typeof a?a+" (XY data visualization)":"XY data visualization"}),Ae("g",{transform:"translate("+r.left+","+r.top+")",children:[D,m]}),a&&"string"==typeof a?Re("text",{x:i/2,y:V,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:a}):a?Re("foreignObject",{x:0,y:0,width:i,height:r.top,children:a}):null,yt({legend:c,totalWidth:i,totalHeight:o,margin:r,legendPosition:p,title:a,legendLayout:f,legendHoverBehavior:l,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d})]}):null}import{zoom as Le,zoomIdentity as ke}from"d3-zoom";import{select as Ce}from"d3-selection";function De([t,e,n]){const i=1<<n;return[t-Math.floor(t/i)*i,e,n]}function je(t,e,n,i,o){return"function"==typeof t?t(e,n,i,o):t.replace("{z}",e+"").replace("{x}",n+"").replace("{y}",i+"").replace("{r}",o>1?"@2x":"")}var Me=class{constructor(t=256){this.cache=new Map,this.limit=t}get(t){const e=this.cache.get(t);return e&&(e.lastUsed=performance.now()),e}set(t,e){this.cache.set(t,e),this.cache.size>this.limit&&this.evict()}evict(){for(;this.cache.size>this.limit;){let t,e=1/0;for(const[n,i]of this.cache)e>i.lastUsed&&(e=i.lastUsed,t=n);if(!t)break;{const e=this.cache.get(t);e&&(e.img.onload=null,e.img.onerror=null,e.img.src=""),this.cache.delete(t)}}}clear(){for(const t of this.cache.values())t.img.onload=null,t.img.onerror=null,t.img.src="";this.cache.clear()}};var Te=class{constructor(t){this.capacity=t,this.particles=Array(t);for(let e=0;t>e;e++)this.particles[e]={t:0,offset:0,lineIndex:0,active:!1,x:0,y:0}}spawn(t,e=Math.random){for(let n=0;this.capacity>n;n++){const i=this.particles[n];if(!i.active)return i.active=!0,i.t=0,i.offset=.6*(e()-.5),i.lineIndex=t,i.x=0,i.y=0,i}return null}step(t,e,n,i){for(let o=0;this.capacity>o;o++){const r=this.particles[o];if(!r.active)continue;const s=n[r.lineIndex];if(!s||2>s.length){r.active=!1;continue}if(r.t+=t*e,r.t>=1){r.active=!1;continue}const a=Be(s),c=_e(s,r.t*a),l=(i[r.lineIndex]||2)/2;r.x=c.x+c.nx*r.offset*l*2,r.y=c.y+c.ny*r.offset*l*2}}countForLine(t){let e=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].lineIndex===t&&e++;return e}clear(){for(let t=0;this.capacity>t;t++)this.particles[t].active=!1}};function Be(t){let e=0;for(let n=1;t.length>n;n++){const i=t[n][0]-t[n-1][0],o=t[n][1]-t[n-1][1];e+=Math.sqrt(i*i+o*o)}return e}function _e(t,e){let n=0;for(let i=1;t.length>i;i++){const o=t[i][0]-t[i-1][0],r=t[i][1]-t[i-1][1],s=Math.sqrt(o*o+r*r);if(n+s>=e||i===t.length-1){const a=s>0?(e-n)/s:0,c=s>.001?s:1;return{x:t[i-1][0]+o*a,y:t[i-1][1]+r*a,nx:-r/c,ny:o/c}}n+=s}const i=t[t.length-1];return{x:i[0],y:i[1],nx:0,ny:0}}function Ie(t){if(!t)return;const e=[];for(const n of t)if("point"===n.type)e.push(n);else if("glyph"===n.type){const t=n,i=Lt(t.glyph,t.size);e.push({pointId:t.pointId,x:t.x+i.centerDx,y:t.y+i.centerDy,r:i.radius})}return e}import{jsx as Ee,jsxs as Ne}from"react/jsx-runtime";function Oe({data:t}){if(!t)return null;if(t.properties)return Ee("div",{className:"semiotic-tooltip",style:ot,children:Ee("div",{style:{fontWeight:600},children:t.properties.name||t.properties.NAME||t.properties.id||"Feature"})});const e=null!=t.data?t.data:t;if(!e||"object"!=typeof e)return null;const n=bt(e),i=null!=n.title?n.title+"":null;return null==i&&0===n.entries.length?null:Ne("div",{className:"semiotic-tooltip",style:ot,children:[null!=i&&Ee("div",{style:{fontWeight:600,marginBottom:n.entries.length?2:0},children:i}),n.entries.map(t=>Ne("div",{children:[Ne("span",{style:{opacity:.7},children:[t.key,": "]}),Ee("span",{style:{fontWeight:600},children:k(t.value)})]},t.key))]})}Oe.ownsChrome=!0;var We={top:10,right:10,bottom:10,left:10},Fe=null;function He(){if(null!==Fe)return Fe;if("undefined"==typeof window)return!1;const t="function"==typeof window.matchMedia&&window.matchMedia("(pointer: coarse)").matches,e="undefined"!=typeof navigator&&"number"==typeof navigator.hardwareConcurrency&&4>=navigator.hardwareConcurrency,n="undefined"!=typeof navigator&&"number"==typeof navigator.deviceMemory&&4>=navigator.deviceMemory;return Fe=t||e||n}function ze(){return He()?12:30}var Ge={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 qe(t){return"string"==typeof t?t:"object"==typeof t&&t&&"type"in t?t.type:null}function Ze(t){return t?t.getContext("2d"):null}import{jsx as Xe,jsxs as Ye}from"react/jsx-runtime";var Ue=Nt(Et(function(t,e){const{projection:o,projectionExtent:r,fitPadding:s,projectionTransform:a,areas:l,points:h,lines:b,customLayout:w,layoutConfig:P,layoutSelection:R,onLayoutError:A,xAccessor:S,yAccessor:L,lineDataAccessor:k,pointIdAccessor:C,lineIdAccessor:N,lineType:W="geo",flowStyle:F="basic",graticule:X,zoomable:V,zoomExtent:$,onZoom:J,dragRotate:et,showParticles:nt,particleStyle:it,tileURL:ot,tileAttribution:ht,tileCacheSize:dt,size:pt,width:gt,height:yt,responsiveWidth:bt,responsiveHeight:wt,margin:At,className:Lt,background:kt,windowSize:Et=500,renderMode:Nt,areaStyle:Ot,pointStyle:Wt,lineStyle:Ft,colorScheme:Ht,enableHover:zt=!0,hoverAnnotation:Gt,tooltipContent:qt,allowTooltipOverflow:Zt=!1,customClickBehavior:Xt,customHoverBehavior:Yt,onObservation:Ut,annotationObservationCallback:Qt,chartId:Vt,annotations:$t,onAnnotationActivate:Jt,autoPlaceAnnotations:Kt,svgAnnotationRules:te,decay:ee,pulse:ne,transition:ie,animate:oe,staleness:re,frameScheduler:se,clock:ae,random:ce,seed:le,paused:ue=!1,suspendWhenHidden:he=!0,backgroundGraphics:de,foregroundGraphics:pe,title:fe,legend:me,legendPosition:ge,legendLayout:ye,legendHoverBehavior:we,legendClickBehavior:Pe,legendHighlightedCategory:xe,legendIsolatedCategories:Re,legendCategoryAccessor:Ae,onCategoriesChange:Be,showAxes:_e,accessibleTable:Ee=!0,description:Ne,summary:Fe}=t,{customHoverBehavior:Ue,customClickBehavior:Qe,hasClickBehavior:Ve}=f({customHoverBehavior:Yt,customClickBehavior:Xt,onObservation:Ut,chartId:Vt,chartType:"StreamGeoFrame"}),$e=pt||[gt||600,yt||400],Je=jt(!0),Ke=Pt({sizeProp:$e,responsiveWidth:bt,responsiveHeight:wt,userMargin:At,marginDefault:We,title:fe,legend:me,legendPosition:ge,foregroundGraphics:pe,backgroundGraphics:de,animate:oe,transitionProp:ie,frameScheduler:se,clock:ae,random:ce,seed:le,paused:ue,suspendWhenHidden:he,themeDirtyRef:Je}),{reducedMotionRef:tn,responsiveRef:en,size:nn,margin:on,adjustedWidth:rn,adjustedHeight:sn,resolvedForeground:an,resolvedBackground:cn,transition:ln,introEnabled:un,tableId:hn,frameRuntime:dn,rafRef:pn,renderFnRef:fn,scheduleRender:mn,currentTheme:gn}=Ke,yn=Ct(),vn=Dt(),bn=Bt(()=>Array.isArray(l)?rt(l):l,[l]),wn=Bt(()=>rt(h),[h]),Pn=Bt(()=>rt(b),[b]),xn=Bt(()=>null!=et?et:"orthographic"===qe(o),[et,o]),Rn=Bt(()=>({projection:o,projectionExtent:r,fitPadding:s,xAccessor:S,yAccessor:L,lineDataAccessor:k,lineType:W,flowStyle:F,areaStyle:Ot,pointStyle:Wt,lineStyle:Ft,colorScheme:Ht,themeSemantic:St(gn),themeSequential:gn?.colors?.sequential,themeDiverging:gn?.colors?.diverging,themeCategorical:gn?.colors?.categorical,graticule:X,projectionTransform:a,windowSize:Et,clock:dn.now,decay:ee,pulse:ne,transition:ln,introAnimation:un,annotations:$t,pointIdAccessor:C,lineIdAccessor:N,customLayout:w,layoutConfig:P,onLayoutError:A,layoutMargin:on}),[o,r,s,S,L,k,W,F,Ot,Wt,Ft,Ht,gn,X,a,Et,dn.now,ee,ne,ln,un,$t,C,N,w,P,A,on]),An=I(Rn),Sn=jt(null);Sn.current||(Sn.current=new ve(An));const Ln=jt(null),kn=jt(null),Cn=jt(null);ot&&!Cn.current&&(Cn.current=new Me(dt||256));const Dn=jt($t),jn=jt(null),Mn=jt(ke),Tn=jt(!1),Bn=jt(null),_n=_t(t=>{Bn.current=t,en&&"object"==typeof en&&(en.current=t)},[en]),In=jt(null),En=jt(null),Nn=jt(null),On=jt(0);if(nt&&!Nn.current){const t=it?.maxPerLine??ze();Nn.current=new Te(50*t)}const Wn=jt(null),Fn=jt(null),Hn=jt(!1),zn=jt(!1),Gn=Rt("StreamGeoFrame"),qn=jt(void 0),[Zn,Xn]=Mt(null),[,Yn]=Mt(0),Un=jt(0),[Qn,Vn]=Mt(!1),$n=p(Sn,Ae,Be,t=>t.getPoints());B(Sn,An,Je,mn),_(Sn,R,Je,mn),Tt(()=>{const t=Sn.current;t&&(bn&&t.setAreas(bn),h&&t.setPoints(wn),b&&t.setLines(Pn),Je.current=!0,mn())},[bn,h,wn,b,Pn,mn]);const Jn=_t(t=>{null!=t&&"object"==typeof t&&(Sn.current?.pushPoint(t),Je.current=!0,mn())},[mn]),Kn=_t(t=>{const e=rt(t);0!==e.length&&(Sn.current?.pushMany(e),Je.current=!0,mn())},[mn]),ti=_t(t=>{null!=t&&"object"==typeof t&&(Sn.current?.pushLine(t),Je.current=!0,mn())},[mn]),ei=_t(t=>{const e=rt(t);0!==e.length&&(Sn.current?.pushManyLines(e),Je.current=!0,mn())},[mn]),ni=_t(()=>{Sn.current?.clear(),Je.current=!0,mn()},[mn]);It(e,()=>({push:Jn,pushMany:Kn,removePoint:t=>{const e=Sn.current?.removePoint(t)??[];return e.length>0&&(Je.current=!0,mn()),e},pushLine:ti,pushManyLines:ei,removeLine:t=>{const e=Sn.current?.removeLine(t)??[];return e.length>0&&(Je.current=!0,mn()),e},getLines:()=>Sn.current?.getLines()??[],clear:ni,getProjection:()=>Sn.current?.scales?.projection??null,getGeoPath:()=>Sn.current?.scales?.geoPath??null,getCartogramLayout:()=>Sn.current?.cartogramLayout??null,getCustomLayout:()=>Sn.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Sn.current?.lastCustomLayoutFailure??null,getZoom:()=>Mn.current.k,resetZoom:()=>{const t=Bn.current;t&&jn.current&&Ce(t).call(jn.current.transform,ke)},getData:()=>Sn.current?.getPoints()??[]}),[Jn,Kn,ti,ei,ni,mn]);const{hoverHandlerRef:ii,onPointerMove:oi,onPointerLeave:ri}=Ke,{canvasRef:si,interactionCanvasRef:ai}=xt(Ke,{hydrated:yn,wasHydratingFromSSR:vn,storeRef:Sn,dirtyRef:Je,cleanup:()=>Cn.current?.clear(),canvasPaintDependencies:[rn,sn,kt,de,Nt,mn]});Tt(()=>{ii.current=t=>{if(!zt)return;const e=Sn.current;if(!e||!e.scene.length)return;const n=si.current;if(!n)return;const i=n.getBoundingClientRect(),o=t.clientX-i.left-on.left,r=t.clientY-i.top-on.top;if(0>o||o>rn||0>r||r>sn)return Wn.current=null,Fn.current=null,Xn(null),Ue?.(null),void mn();kn.current||(kn.current="undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"));const s=Ze(kn.current);if(!s)return;const a=ct(30,t.pointerType),c=ct(6,t.pointerType),l=be(e.scene,o,r,a,s,e.quadtree,e.maxPointRadius,c);if(l){const t=l.node,e=t.datum,n=Array.isArray(e)?null:e?.properties?e:e?.data||e;let i,s;"point"===t.type?(i=t.x,s=t.y):"geoarea"===t.type?(i=t.centroid[0],s=t.centroid[1]):(i=o,s=r);const a={...n,...n?.properties||{},data:n,properties:n?.properties,__semioticHoverData:!0,x:i,y:s};Wn.current=a,Fn.current=t,Xn(a),Ue?.(a),mn()}else Wn.current&&(Wn.current=null,Fn.current=null,Xn(null),Ue?.(null),mn())}},[zt,rn,sn,on,Ue,mn,ii,si]),Ke.hoverLeaveRef.current=()=>{Wn.current=null,Fn.current=null,Xn(null),Ue?.(null),mn()};const ci=_t(t=>{if(lt(t.target))return;if(!Qe)return;const e=Sn.current;if(!e||!e.scene.length)return void Qe(null);const n=t.currentTarget.getBoundingClientRect(),i=t.clientX-n.left-on.left,o=t.clientY-n.top-on.top;if(0>i||i>rn||0>o||o>sn)return void Qe(null);kn.current||(kn.current="undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas"));const r=Ze(kn.current);if(!r)return void Qe(null);const s=ct(30,qn.current),a=ct(6,qn.current),c=be(e.scene,i,o,s,r,e.quadtree,e.maxPointRadius,a);if(c){const t=c.node.datum,e=Array.isArray(t)?null:t?.properties?t:t?.data||t,n=e?.properties?{...e,...e.properties}:e;return void Qe({...n,data:e,properties:e?.properties,__semioticHoverData:!0,x:i,y:o,time:i,value:o},{type:"activate",inputType:ft(qn.current)})}Qe(null)},[sn,rn,Qe,on]),{kbFocusIndexRef:li,focusedNavPointRef:ui,onKeyDown:hi}=d({storeRef:Sn,hoverRef:Wn,hoveredNodeRef:Fn,setHoverPoint:Xn,customHoverBehavior:Ue,customClickBehavior:Qe,scheduleRender:mn}),di=_t(t=>{qn.current=t.pointerType,li.current=-1,ui.current=null,oi(t)},[ui,li,oi]),pi=_t(t=>{qn.current=t.pointerType},[]);fn.current=()=>{if(pn.current=null,!dn.isActive)return;const t=si.current,e=Sn.current;if(!t||!e)return;const o=dn.now();let r=!1;const s=En.current;let a=!1;s&&(En.current=null,e.applyRotation(s,{width:rn,height:sn}),a=!0);const l=e.advanceTransition(tn.current?o+1e6:o),h=!tn.current&&l,d=Gn.current.beforeCompute(e.getLastUpdateResult(),h);let p=!1;if(Je.current&&!l){const n={width:rn,height:sn},i=e.hasProjection(),o=xn&&i?e.getRotation():null;e.computeScene(n);const r=Mn.current,s=1!==r.k||0!==r.x||0!==r.y;xn&&o?s?(e.setRotation(o),e.applyZoomScale(r.k,n)):e.applyRotation(o,n):s&&e.applyZoomTransform(r,n),Je.current=!1,p=!0,t.setAttribute("aria-label",tt(e.scene,"Geographic chart")),$n()}Gn.current.afterCompute(d,p,!1);const f=at(),v=nt&&!tn.current&&!!Nn.current,b=e.consumeStylePaintPending(),w=u(e,o,p,zn),P=m({dirtyOrRebuilt:p,transitioning:h,continuous:v,liveEncoding:w.changed,forced:a||b});if(ot&&Cn.current){const t=Ln.current;if(t&&e.scales?.projection){const n=mt(t,nn,on,f);if(n){n.clearRect(-on.left,-on.top,nn[0],nn[1]),n.save(),n.beginPath(),n.rect(0,0,rn,sn),n.clip();const t=function(t,e){const{tileURL:n,projection:i,width:o,height:r,tileCache:s,onTileLoad:a}=e,c=i.scale(),l=i.translate(),u=function(t){const{size:e,scale:n,translate:i,clampX:o=!0,clampY:r=!0}=t,s=Math.max(Math.log(n)/Math.LN2-8,0),a=Math.round(s),c=1<<a,l=Math.pow(2,s-a+8),u=i[0]-n/2,h=i[1]-n/2,d=Math.max(o?0:-1/0,Math.floor((0-u)/l)),p=Math.min(o?c:1/0,Math.ceil((e[0]-u)/l)),f=Math.max(r?0:-1/0,Math.floor((0-h)/l)),m=Math.min(r?c:1/0,Math.ceil((e[1]-h)/l)),g=[];for(let t=f;m>t;++t)for(let e=d;p>e;++e)g.push([e,t,a]);return{tiles:g,translate:[u/l,h/l],scale:l}}({size:[o,r],scale:2*c*Math.PI,translate:l}),h=at();let d=!0;for(const e of u.tiles){const[i,o,r]=De(e),c=`${r}/${i}/${o}`;let l=s.get(c);if(!l){const t=new Image;t.crossOrigin="anonymous";const e={img:t,loaded:!1,key:c,lastUsed:performance.now()};s.set(c,e),t.onload=()=>{e.loaded=!0,a?.()},t.onerror=()=>{e.loaded=!0},t.src=je(n,r,i,o,h),l=e}if(!l.loaded){d=!1;continue}const p=u.scale;t.drawImage(l.img,(e[0]+u.translate[0])*p-.5,(e[1]+u.translate[1])*p-.5,p+1,p+1)}return d}(n,{tileURL:ot,projection:e.scales.projection,width:rn,height:sn,tileCache:Cn.current,onTileLoad:()=>mn()});n.restore(),t||(r=!0)}}}if(P){const i=mt(t,nn,on,f);if(!i)return;i.clearRect(-on.left,-on.top,nn[0],nn[1]),ot||y(i,{background:kt,hasBackgroundGraphics:!!de,width:rn,height:sn}),i.save(),i.beginPath(),i.rect(0,0,rn,sn),i.clip();const s=e.scene,a=e.scales,l={width:rn,height:sn};if(j({context:i,nodes:s,renderMode:Nt,pixelRatio:f,paintBuiltIn:t=>{!function(t,e){const n=e.filter(t=>"geoarea"===t.type);for(const e of n){if(!e.pathData)continue;e._cachedPath2D||(e._cachedPath2D=new Path2D(e.pathData));const n=e._cachedPath2D,i=K(t,e.style.fill)||"#e0e0e0";if("none"!==i&&(t.fillStyle=i,t.globalAlpha=(e._decayOpacity??1)*(e.style.fillOpacity??1),t.fill(n)),e.style.stroke&&"none"!==e.style.stroke){if(t.strokeStyle=vt(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||.5,t.globalAlpha=e._decayOpacity??1,e.style.strokeDasharray){const n=e.style.strokeDasharray.split(",").map(Number);t.setLineDash(n)}else t.setLineDash([]);t.stroke(n)}M(t,e,n),t.globalAlpha=1,t.setLineDash([])}}(i,t),n(i,t,a,l),c(i,t,a,l),D(i,t,a,l)}}),v&&Nn.current){const t=Nn.current,e=s.filter(t=>"line"===t.type);if(e.length>0){const n=it||{},s=.3*(n.speedMultiplier??1),a=n.maxPerLine??ze(),c=n.spawnRate??(He()?.06:.15),l=n.radius??2,u=n.opacity??.7,h=o/1e3,d=On.current>0?Math.min(h-On.current,.1):.016;On.current=h;const p=e.map(t=>t.path),f=e.map(t=>t.style.strokeWidth||2);for(let n=0;e.length>n;n++)dn.random()<c&&t.countForLine(n)<a&&t.spawn(n,dn.random);t.step(d,s,p,f),i.globalAlpha=u;for(let o=0;t.particles.length>o;o++){const r=t.particles[o];if(!r.active)continue;const s=e[r.lineIndex],a="function"==typeof n.color?n.color(s?.datum??{}):"source"!==n.color&&n.color?n.color:s?.style.stroke||"#fff";i.beginPath(),i.arc(r.x,r.y,l,0,2*Math.PI),i.fillStyle=a,i.fill()}i.globalAlpha=1,r=!0}}i.restore()}const x=Fn.current,R=!(!x||"geoarea"!==x.type&&"point"!==x.type),A=g(R,Hn.current),S=ai.current;if(S&&A){const t=mt(S,nn,on,f);if(t){if(t.clearRect(-on.left,-on.top,nn[0],nn[1]),x&&"geoarea"===x.type){const e=new Path2D(x.pathData);t.fillStyle="rgba(255, 255, 255, 0.3)",t.fill(e),t.strokeStyle="rgba(0, 0, 0, 0.5)",t.lineWidth=2,t.stroke(e)}if(x&&"point"===x.type){const e=x,n="object"==typeof Gt?Gt:void 0,o=n?.pointColor||i(x);t.beginPath(),t.arc(e.x,e.y,e.r+3,0,2*Math.PI),o?(t.save(),t.globalAlpha=.4,t.fillStyle=o,t.fill(),t.restore()):(t.fillStyle="rgba(255, 255, 255, 0.4)",t.fill()),t.strokeStyle=o||"rgba(0, 0, 0, 0.5)",t.lineWidth=2,t.stroke()}}Hn.current=R}const L=$t!==Dn.current;L&&(Dn.current=$t),(p||L||h&&$t&&$t.length>0)&&(p||L||o-Un.current>=33)&&(Yn(t=>t+1),Un.current=o),(h||null!=e.activeTransition||w.pending||r)&&mn()},E(re,Sn,Je,mn,Qn,Vn),Tt(()=>{if("production"!==process.env.NODE_ENV&&ot){const t=qe(o);t&&"mercator"!==t&&console.warn(`[StreamGeoFrame] tileURL is set but projection is "${t}". Raster tiles use Web Mercator and will not align with other projections.`)}},[ot,o]),Tt(()=>{const t=Bn.current;if(!V||!t)return jn.current&&t&&(Ce(t).on(".zoom",null),jn.current=null),void(t&&Ce(t).on("mousedown.rotate",null).on("touchstart.rotate",null));const[e,n]=$||[1,8],i={width:rn,height:sn};if(xn){let o=Mn.current.k;const r=t=>{o=Math.max(e,Math.min(n,t)),Mn.current=ke.scale(o);const r=Sn.current;r&&(r.applyZoomScale(o,i),Je.current=!1,mn(),r.scales?.projection&&J?.({projection:r.scales.projection,zoom:r.currentZoom}))};jn.current={scaleBy:(t,e)=>r(o*e),transform:(t,e)=>r(e?.k??1)};const s=t=>{t.preventDefault(),r(o*(0>t.deltaY?1.1:1/1.1))},a=t=>{const e=t.target;e&&(e.closest("button")||e.closest(".stream-geo-zoom-controls"))||(t.preventDefault(),r(1.5*o))};t.addEventListener("wheel",s,{passive:!1}),t.addEventListener("dblclick",a);const c=.4,l=e=>{if(0!==e.button)return;const n=e.target;if(n.closest("button")||n.closest(".stream-geo-zoom-controls"))return;const i=Sn.current;if(!i)return;const o=i.getRotation();In.current={x:e.clientX,y:e.clientY,rotation:[...o]},t.setPointerCapture(e.pointerId),e.preventDefault()},u=t=>{const e=In.current;e&&(En.current=[e.rotation[0]+(t.clientX-e.x)*c,Math.max(-90,Math.min(90,e.rotation[1]-(t.clientY-e.y)*c)),e.rotation[2]],mn())},h=e=>{if(!In.current)return;In.current=null,t.releasePointerCapture(e.pointerId);const n=En.current;if(n){En.current=null;const t=Sn.current;t&&(t.applyRotation(n,i),mn())}const o=Sn.current;o?.scales?.projection&&J?.({projection:o.scales.projection,zoom:o.currentZoom})};return t.addEventListener("pointerdown",l),t.addEventListener("pointermove",u),t.addEventListener("pointerup",h),t.addEventListener("pointercancel",h),()=>{t.removeEventListener("wheel",s),t.removeEventListener("dblclick",a),t.removeEventListener("pointerdown",l),t.removeEventListener("pointermove",u),t.removeEventListener("pointerup",h),t.removeEventListener("pointercancel",h),jn.current=null}}const o=Le().scaleExtent([e,n]).extent([[0,0],[nn[0],nn[1]]]).translateExtent([[-1/0,-1/0],[1/0,1/0]]).on("zoom",t=>{const e=t.transform;Mn.current=e,Tn.current=!0;const n=Sn.current;n&&(n.applyZoomTransform(e,i),Je.current=!1,mn())}).on("end",t=>{Mn.current=t.transform,Tn.current=!1;const e=Sn.current;e?.scales?.projection&&J?.({projection:e.scales.projection,zoom:e.currentZoom})});return jn.current=o,Ce(t).call(o),()=>{Ce(t).on(".zoom",null)}},[V,$,xn,nn,rn,sn,on,J,mn]);const fi=zt&&!1!==Gt,mi=fi&&Zn?qt?qt(Zn):Xe(Oe,{data:Zn}):null,gi=mi?Xe(q,{x:Zn.x,y:Zn.y,containerWidth:rn,containerHeight:sn,margin:on,className:"stream-frame-tooltip",zIndex:10,children:mi}):null;if(ut||!yn&&vn){const t=Sn.current;t&&(bn||h||b)&&(bn&&t.setAreas(bn),h&&t.setPoints(wn),b&&t.setLines(Pn),t.computeScene({width:rn,height:sn}));const e=t?.scene??[];return Ye("div",{ref:_n,className:"stream-geo-frame"+(Lt?" "+Lt:""),role:"img","aria-label":Ne||("string"==typeof fe?fe:"Geographic chart"),style:{position:"relative",width:bt?"100%":nn[0],height:wt?"100%":nn[1]},children:[Xe(U,{summary:Fe}),Ye("svg",{xmlns:"http://www.w3.org/2000/svg",width:nn[0],height:nn[1],style:{position:"absolute",left:0,top:0},children:[Xe("g",{transform:`translate(${on.left},${on.top})`,children:cn}),Ye("g",{transform:`translate(${on.left},${on.top})`,children:[kt&&Xe("rect",{x:0,y:0,width:rn,height:sn,fill:kt}),e.map((t,e)=>T({node:t,index:e,renderMode:Nt,fallback:()=>st(t,e)}))]})]}),Xe(Se,{width:rn,height:sn,totalWidth:nn[0],totalHeight:nn[1],margin:on,showAxes:!1,title:fe,legend:me,legendPosition:ge,legendLayout:ye,legendHoverBehavior:we,legendClickBehavior:Pe,legendHighlightedCategory:xe,legendIsolatedCategories:Re,foregroundGraphics:x(an,O(Sn.current?.customLayoutOverlays,R??null)),annotations:$t,onAnnotationActivate:Jt,onObservation:Qt??Ut,chartId:Vt,chartType:"StreamGeoFrame",autoPlaceAnnotations:Kt,svgAnnotationRules:te,pointNodes:Ie(e),geoProjection:Sn.current?.scales?.projectedPoint})]})}return Ye("div",{ref:_n,className:"stream-geo-frame"+(Lt?" "+Lt:""),role:"group","aria-label":Ne||("string"==typeof fe?fe:"Geographic chart"),tabIndex:0,style:{position:"relative",width:bt?"100%":nn[0],height:wt?"100%":nn[1],overflow:Zt?"visible":"hidden",...V?{touchAction:"none"}:{}},onKeyDown:hi,children:["production"!==process.env.NODE_ENV&&Sn.current&&Xe(Y,{store:Sn.current,diagnostics:Gn.current}),Ee&&Xe(Q,{tableId:hn}),Ee&&Xe(H,{scene:Sn.current?.scene??[],chartType:"Geographic chart",tableId:hn,chartTitle:"string"==typeof fe?fe:void 0}),Xe(U,{summary:Fe}),Xe(z,{hoverPoint:Zn}),Ye("div",{role:"img","aria-label":Ne||("string"==typeof fe?fe:"Geographic chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:fi?di:void 0,onPointerLeave:fi?ri:void 0,onPointerDown:fi||Ve?pi:void 0,onClick:Ve?ci:void 0,children:[Xe(G,{size:nn,margin:on,children:cn}),ot&&Xe("canvas",{ref:Ln,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),Xe("canvas",{ref:si,"aria-label":tt(Sn.current?.scene??[],"Geographic chart"),style:{position:"absolute",left:0,top:0}}),Xe("canvas",{ref:ai,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),Xe(Se,{width:rn,height:sn,totalWidth:nn[0],totalHeight:nn[1],margin:on,showAxes:_e,title:fe,legend:me,legendPosition:ge,legendLayout:ye,legendHoverBehavior:we,legendClickBehavior:Pe,legendHighlightedCategory:xe,legendIsolatedCategories:Re,foregroundGraphics:x(an,O(Sn.current?.customLayoutOverlays,R??null)),annotations:$t,onAnnotationActivate:Jt,onObservation:Qt??Ut,chartId:Vt,chartType:"StreamGeoFrame",autoPlaceAnnotations:Kt,svgAnnotationRules:te,pointNodes:Ie(Sn.current?.scene),geoProjection:Sn.current?.scales?.projectedPoint}),re?.showBadge&&Xe(v,{isStale:Qn,position:re.badgePosition}),V&&Ye("div",{className:"stream-geo-zoom-controls",style:{position:"absolute",bottom:on.bottom+8,left:on.left+8,display:"flex",flexDirection:"column",gap:2,zIndex:2},children:[Xe("button",{type:"button","aria-label":"Zoom in",onClick:t=>{t.stopPropagation();const e=Bn.current,n=jn.current;e&&n?.scaleBy&&n.scaleBy(Ce(e),1.5)},style:Ge,children:"+"}),Xe("button",{type:"button","aria-label":"Zoom out",onClick:t=>{t.stopPropagation();const e=Bn.current,n=jn.current;e&&n?.scaleBy&&n.scaleBy(Ce(e),1/1.5)},style:Ge,children:"−"})]}),ht&&Xe("div",{className:"stream-geo-tile-attribution",style:{position:"absolute",bottom:on.bottom+2,right:on.right+4,fontSize:10,color:"rgba(0,0,0,0.6)",background:"rgba(255,255,255,0.7)",padding:"1px 4px",borderRadius:2,pointerEvents:"none",zIndex:2},children:ht}),Xe(Z,{active:li.current>=0,hoverPoint:Zn,margin:on,size:nn,shape:ui.current?.shape,width:ui.current?.w,height:ui.current?.h,pathData:ui.current?.pathData}),gi]})]})}));Ue.displayName="StreamGeoFrame";var Qe=Ue;import{forwardRef as Ve,useMemo as $e}from"react";import{jsx as Je}from"react/jsx-runtime";var Ke=Ve(function(n,i){const{points:o,areas:r,lines:s,layout:a,layoutConfig:c,onLayoutError:l,projection:u="equirectangular",xAccessor:h="lon",yAccessor:d="lat",lineDataAccessor:p,colorBy:f,colorScheme:m,tooltip:g,annotations:y,margin:v,selection:b,linkedHover:x,onObservation:R,onClick:A,chartId:S,loading:L,loadingContent:k,emptyContent:C,className:D,frameProps:j={}}=n,{frameRef:M,resolved:T,normalizedMargin:B}=e({imperativeRef:i,imperativeVariant:"geo-points",margin:v,width:n.width,height:n.height,enableHover:n.enableHover,title:n.title,description:n.description,summary:n.summary,accessibleTable:n.accessibleTable,mode:n.mode,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,responsiveRules:n.responsiveRules}),_=$e(()=>rt(o),[o]),I=$e(()=>rt(r),[r]),E=$e(()=>rt(s),[s]),N=$e(()=>[..._,...E,...I],[_,E,I]),O=t({data:N,rawData:void 0!==o||void 0!==s||void 0!==r?N:void 0,colorBy:f,colorScheme:m,legendInteraction:void 0,selection:b,linkedHover:x,fallbackFields:"string"==typeof f?[f]:[],unwrapData:!1,onObservation:R,onClick:A,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"GeoCustomChart",chartId:S,showLegend:!1,userMargin:B,marginDefaults:T.marginDefaults,loading:L,loadingContent:k,emptyContent:C,width:T.width,height:T.height,hasTitle:!!T.title}),W=O.effectiveSelectionHook,F=$e(()=>W?.isActive?{isActive:!0,predicate:W.predicate}:null,[W?.isActive,W?.predicate]);if(O.earlyReturn)return O.earlyReturn;const{width:H,height:z,enableHover:G,title:q,description:Z,summary:X,accessibleTable:Y}=T,U=dt(g),Q={projection:u,...null!=o&&{points:_},...null!=r&&{areas:I},...null!=s&&{lines:E},xAccessor:h,yAccessor:d,...null!=p&&{lineDataAccessor:p},customLayout:a,layoutConfig:c,onLayoutError:l,layoutSelection:F,colorBy:f,colorScheme:m,size:[H,z],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:O.margin,enableHover:G,...w({title:q,description:Z,summary:X,accessibleTable:Y,className:D,animate:n.animate,autoPlaceAnnotations:n.autoPlaceAnnotations}),...!1===g?{tooltipContent:()=>null}:U?{tooltipContent:U}:{},...P({linkedHover:x,selection:b,onObservation:R,onClick:A,hoverHighlight:!1,mobileInteraction:O.mobileInteraction,customHoverBehavior:O.customHoverBehavior,customClickBehavior:O.customClickBehavior,linkedHoverInClickPredicate:!1}),...y&&y.length>0&&{annotations:y},...j};return Je(kt,{componentName:"GeoCustomChart",width:H,height:z,children:Je(Qe,{ref:M,...Q})})});Ke.displayName="GeoCustomChart";export{Qe as StreamGeoFrame_default,Ke as GeoCustomChart};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{resolveCSSColor as n}from"./chunk-chunk-CWQ5YIHX.module.min.js";function r(n){const{background:r,hasBackgroundGraphics:t=!1,themeBackground:c=""}=n;return"transparent"===r||t?null:r||(c&&"transparent"!==c?c:"")||null}function t(t,c){const{background:o,hasBackgroundGraphics:u=!1,themeBackground:i="",x:a=0,y:e=0,width:d,height:h}=c,s=r({background:o,hasBackgroundGraphics:u,themeBackground:i});if(!s)return!1;const g=n(t,s);return!!g&&(t.fillStyle=g,t.fillRect(a,e,d,h),!0)}function c(n){return!!(n.dirtyOrRebuilt||n.transitioning||n.animationTicked||n.continuous||n.liveEncoding||n.forced)}function o(n,r){return n||r}export{r as resolveCanvasBackground,t as paintCanvasBackground,c as needsDataCanvasPaint,o as needsInteractionCanvasPaint};
2
+ import{resolveCSSColor as n}from"./chunk-chunk-PX5YQGDP.module.min.js";function r(n){const{background:r,hasBackgroundGraphics:t=!1,themeBackground:c=""}=n;return"transparent"===r||t?null:r||(c&&"transparent"!==c?c:"")||null}function t(t,c){const{background:o,hasBackgroundGraphics:u=!1,themeBackground:i="",x:a=0,y:e=0,width:d,height:h}=c,s=r({background:o,hasBackgroundGraphics:u,themeBackground:i});if(!s)return!1;const g=n(t,s);return!!g&&(t.fillStyle=g,t.fillRect(a,e,d,h),!0)}function c(n){return!!(n.dirtyOrRebuilt||n.transitioning||n.animationTicked||n.continuous||n.liveEncoding||n.forced)}function o(n,r){return n||r}export{r as resolveCanvasBackground,t as paintCanvasBackground,c as needsDataCanvasPaint,o as needsInteractionCanvasPaint};
@@ -0,0 +1 @@
1
+ function t(t){if(null==t)return()=>{};const n="function"==typeof t?t:n=>n[t];return t=>e(n(t))}function n(n,i){const e=t(n),o=t(i);return(t,n)=>{const i=o(t);return{value:i,x:e(t),y:i,category:n}}}function i(n,i){const e=t(i??"value"),o=null==n?void 0:"function"==typeof n?n:t=>t[n];return t=>{const n=o?o(t):void 0;return{value:e(t),category:null==n?void 0:n+""}}}function e(t){if("number"==typeof t)return Number.isFinite(t)?t:void 0;if("string"==typeof t&&""!==t.trim()){const n=Number(t);return Number.isFinite(n)?n:void 0}}function o(t,n,i){const o=null!=t.axis?i[t.axis]:null!=t.field?n[t.field]:i.value;if(void 0!==t.eq&&o!==t.eq)return!1;if(void 0!==t.ne&&o===t.ne)return!1;if(void 0!==t.in&&!t.in.includes(o))return!1;if(void 0===t.gt&&void 0===t.gte&&void 0===t.lt&&void 0===t.lte&&void 0===t.within&&void 0===t.outside)return!0;const r=e(o);if(void 0===r)return!1;if(void 0!==t.gt&&t.gt>=r)return!1;if(void 0!==t.gte&&t.gte>r)return!1;if(void 0!==t.lt&&r>=t.lt)return!1;if(void 0!==t.lte&&r>t.lte)return!1;if(void 0!==t.within){const[n,i]=t.within;if(n>r||r>i)return!1}if(void 0!==t.outside){const[n,i]=t.outside;if(r>=n&&i>=r)return!1}return!0}function r(t,n,i){const e=t.when;return void 0===e||!0===e||!1!==e&&("function"==typeof e?e(n,i):o(e,n,i))}function u(t,n,i){if(!n||0===n.length)return{};let e={};for(const o of n){if(!r(o,t,i))continue;const n="function"==typeof o.style?o.style(t,i):o.style;n&&(e={...e,...n})}return e}function f(t,n,i,e=t=>t){const o=t??(()=>({}));return n&&0!==n.length?(t,r)=>{const f=e(t),c={...o(t,r)};return Object.assign(c,u(f,n,i(f,r))),c}:o}function c(t,n,i){return t&&0!==t.length?(e,o)=>{const r=u(e,t,n(e,o)),f=i?i(e,o):void 0;return f?{...r,...f}:r}:i}function s(t,n,e,o){if(!t||0===t.length)return o;const r=i(n,e);return(n,i)=>{const e=n&&n.data||n,f=u(e,t,r(e)),c=o?o(n,i):void 0;return c?{...f,...c}:f}}function d(t,i,e,o){return c(t,n(i,e),o)}export{t as makeRuleValueResolver,n as makeXYRuleContext,i as makeNodeRuleContext,o as matchesThreshold,r as ruleMatches,u as resolveStyleRules,f as composeStyleRules,c as makeStyleRuleStyleFn,s as styleRulesToNodeStyle,d as styleRulesToXYStyle};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{StreamXYFrame_default as e}from"./chunk-chunk-AAF5LZAU.module.min.js";import{buildCustomBehaviorProps as t}from"./chunk-chunk-WYARAXHR.module.min.js";import{normalizeLinkedBrush as n,useBrushSelection as i,useChartLegendAndMargin as s,useChartMode as o,useChartSelection as r}from"./chunk-chunk-PX5YQGDP.module.min.js";import{renderEmptyState as a,renderLoadingState as l}from"./chunk-chunk-ACLDBMRH.module.min.js";var c=class e{constructor(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}push(e){if(!Number.isFinite(e))return;this._count+=1;const t=e-this._mean;this._mean+=t/this._count,this._m2+=t*(e-this._mean),this._min>e&&(this._min=e),e>this._max&&(this._max=e)}merge(e){if(0===e._count)return;if(0===this._count)return this._count=e._count,this._mean=e._mean,this._m2=e._m2,this._min=e._min,void(this._max=e._max);const t=this._count+e._count,n=e._mean-this._mean;this._mean+=n*e._count/t,this._m2+=e._m2+n*n*this._count*e._count/t,this._count=t,this._min>e._min&&(this._min=e._min),e._max>this._max&&(this._max=e._max)}clear(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}clone(){const t=new e;return t._count=this._count,t._mean=this._mean,t._m2=this._m2,t._min=this._min,t._max=this._max,t}get count(){return this._count}get mean(){return 0===this._count?0:this._mean}get sum(){return 0===this._count?0:this._mean*this._count}get variance(){return 2>this._count?0:this._m2/this._count}get stddev(){return Math.sqrt(this.variance)}get sampleVariance(){return 2>this._count?0:this._m2/(this._count-1)}get sampleStddev(){return Math.sqrt(this.sampleVariance)}get min(){return this._min}get max(){return this._max}},u=class{constructor(e){this.windows=new Map,this.sessions=[],this.latest=-1/0,this.type=e.window??"tumbling",this.size=e.size;const t=e.hop??e.size;this.hop=t>0&&e.size>=t?t:e.size,this.gap=e.gap??e.size,this.retain=null!=e.retain&&e.retain>0?e.retain:1/0}push(e,t){Number.isFinite(e)&&Number.isFinite(t)&&(e>this.latest&&(this.latest=e),"session"===this.type?this.pushSession(e,t):this.pushFixed(e,t),this.prune())}pushFixed(e,t){if("tumbling"===this.type||this.hop>=this.size)return void this.bump(Math.floor(e/this.size)*this.size,t);const n=this.hop,i=Math.floor(e/n);for(let s=Math.floor((e-this.size)/n)+1;i>=s;s++)this.bump(s*n,t)}bump(e,t){let n=this.windows.get(e);n||(n=new c,this.windows.set(e,n)),n.push(t)}pushSession(e,t){const n=this.gap,i=new c;i.push(t);let s=e,o=e;const r=[],a={start:s,end:o,stats:i};for(const t of this.sessions)e-n>t.end||t.start>e+n?r.push(t):(a.stats.merge(t.stats),s>t.start&&(s=t.start),t.end>o&&(o=t.end));a.start=s,a.end=o,r.push(a),r.sort((e,t)=>e.start-t.start),this.sessions=r}prune(){if(this.retain===1/0)return;if("session"===this.type)return void(this.sessions.length>this.retain&&(this.sessions=this.sessions.slice(this.sessions.length-this.retain)));if(this.retain>=this.windows.size)return;const e=[...this.windows.keys()].sort((e,t)=>e-t),t=e.length-this.retain;for(let n=0;t>n;n++)this.windows.delete(e[n])}emit(){return"session"===this.type?this.emitSessions():this.emitFixed()}emitFixed(){const e=[];for(const[t,n]of this.windows){const i=t+this.size;e.push(this.row(t,i,n,i>this.latest))}return e.sort((e,t)=>e.start-t.start),e}emitSessions(){return this.sessions.map(e=>this.row(e.start,e.end,e.stats,this.gap>this.latest-e.end))}row(e,t,n,i){return{start:e,end:t,count:n.count,mean:n.mean,sum:n.sum,min:n.min,max:n.max,stddev:n.stddev,partial:i}}get windowCount(){return"session"===this.type?this.sessions.length:this.windows.size}get watermark(){return this.latest}clear(){this.windows.clear(),this.sessions=[],this.latest=-1/0}};function m(e,t){switch(t){case"sum":return e.sum;case"min":return e.min;case"max":return e.max;case"count":return e.count;default:return e.mean}}function h(e,t,n,i=1){if("none"===t)return null;if("minmax"===t)return[e.min,e.max];const s=m(e,n),o=e.stddev*i;return[s-o,s+o]}var d={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},p=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g;function g(e){if("number"==typeof e)return Number.isFinite(e)&&e>0?e:null;if("string"!=typeof e)return null;const t=e.trim();if(""===t)return null;p.lastIndex=0;let n,i=0,s=0;for(;null!==(n=p.exec(t));){const e=parseFloat(n[1]),t=d[n[2]];if(null==t||!Number.isFinite(e))return null;i+=e*t,s+=n[0].length}return s!==t.length?null:i>0?i:null}var v=class{constructor(e){this.held=[],this._watermark=-1/0,this._lateCount=0,this.lateness=e.lateness>0?e.lateness:0,this.getTime=e.getTime,this.latePolicy=e.latePolicy??"drop"}push(e){const t=this.getTime(e);if(!Number.isFinite(t))return{released:[e],late:[]};const n=[];return this._watermark!==-1/0&&this._watermark-this.lateness>t?(this._lateCount+=1,n.push(e),"drop"===this.latePolicy?{released:[],late:n}:{released:[e],late:n}):(t>this._watermark&&(this._watermark=t),this.held.push(e),{released:this.drain(),late:n})}drain(){const e=this._watermark-this.lateness;if(0===this.held.length)return[];const t=[],n=[];for(const i of this.held)this.getTime(i)>e?n.push(i):t.push(i);return this.held=n,t.sort((e,t)=>this.getTime(e)-this.getTime(t)),t}flush(){const e=this.held;return this.held=[],e.sort((e,t)=>this.getTime(e)-this.getTime(t)),e}clear(){this.held=[],this._watermark=-1/0,this._lateCount=0}get watermark(){return this._watermark}get lateCount(){return this._lateCount}get heldCount(){return this.held.length}};import{useRef as f,useImperativeHandle as w,forwardRef as y,useCallback as b,useState as x,useEffect as A}from"react";import{jsx as _,jsxs as k}from"react/jsx-runtime";var H={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, #f3f4f6)",padding:"6px 10px",borderRadius:"var(--semiotic-tooltip-radius, 4px)",fontSize:"var(--semiotic-tooltip-font-size, 12px)",fontFamily:"var(--semiotic-tick-font-family, var(--semiotic-font-family, sans-serif))",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.25))",lineHeight:1.4,pointerEvents:"none",whiteSpace:"nowrap"},S={opacity:.7,marginRight:4};function z(e,t,n){if(null!=e)return"function"==typeof t?t(e):e["string"==typeof t?t:n]}function I(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function C(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:i="x",yLabel:s="y"}=e;return e=>{const o=e?.data??null,r=z(o,t,"time"),a=z(o,n,"value");return k("div",{className:"semiotic-tooltip",style:H,children:[k("div",{children:[k("span",{style:S,children:[i,":"]}),I(r)]}),k("div",{children:[k("span",{style:S,children:[s,":"]}),I(a)]})]})}}function T(e,t){return null!=e?e:Math.max(t?.length??0,200)}var R="time",P="value",F="__aggLower",M="__aggUpper",N="__aggPartial",D="count",E="__aggStart",B="__aggEnd";function O(e,t){const n=t.stat??"mean",i=t.band??"none",s=t.sigma??1;return e.emit().map(e=>{const t={[R]:(e.start+e.end)/2,[P]:m(e,n),[D]:e.count,[N]:e.partial,[E]:e.start,[B]:e.end},o=h(e,i,n,s);return o&&(t[F]=o[0],t[M]=o[1]),t})}import{jsx as j}from"react/jsx-runtime";function L(e,t,n){const i="function"==typeof t?t(e):e[t??n];if(null==i)return null;if(i instanceof Date)return i.getTime();const s=Number(i);return Number.isFinite(s)?s:null}var W=y(function(n,i){const s=o(n.mode,{width:n.size?.[0]??n.width,height:n.size?.[1]??n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,responsiveRules:n.responsiveRules}),{size:c,margin:m,className:h,arrowOfTime:d="right",windowMode:p="sliding",windowSize:y,data:_,timeAccessor:k,valueAccessor:H,timeExtent:S,valueExtent:z,extentPadding:I,stroke:N="#007bff",strokeWidth:D=2,strokeDasharray:E,opacity:B,background:W,tooltipContent:V,tooltip:$,onHover:X,annotations:Y,autoPlaceAnnotations:q,svgAnnotationRules:U,tickFormatTime:G,tickFormatValue:Q,decay:Z,pulse:J,staleness:K,transition:ee,linkedHover:te,selection:ne,onObservation:ie,chartId:se,loading:oe,loadingContent:re,emptyContent:ae,emphasis:le,legendPosition:ce,aggregate:ue,eventTime:me}=n,he=s.showAxes,de=s.enableHover,pe=m??s.marginDefaults,ge=c??[s.width,s.height],ve=V??$??C({timeAccessor:k,valueAccessor:H}),fe=f(null),{customHoverBehavior:we}=r({selection:ne,linkedHover:te,unwrapData:!0,onObservation:ie,chartType:"RealtimeLineChart",chartId:se}),ye=b(e=>{X&&X(e),we(e)},[X,we]),be=null!=ue,[xe,Ae]=x([]),_e=f(null),ke=f(ue);ke.current=ue;const He=f(be);He.current=be;const Se=f(xe);Se.current=xe;const ze=f({timeAccessor:k,valueAccessor:H});ze.current={timeAccessor:k,valueAccessor:H},A(()=>{if(!be)return void(_e.current=null);const e=ke.current,t=function(e){const t=e.window??"tumbling",n=g("session"===t?e.gap??e.size:e.size);if(null==n)return null;const i=null!=e.hop?g(e.hop):void 0,s=null!=e.gap?g(e.gap):void 0;return new u({window:t,size:n,hop:i??void 0,gap:s??void 0,retain:e.retain})}(e);if(_e.current=t,t&&_){const{timeAccessor:e,valueAccessor:n}=ze.current;for(const i of _){const s=L(i,e,"time"),o=L(i,n,"value");null!=s&&null!=o&&t.push(s,o)}}Ae(t?O(t,e):[])},[be?[ue.window??"tumbling",ue.size,ue.hop??"",ue.gap??"",ue.retain??""].join("|"):"",be,_]),A(()=>{be&&_e.current&&Ae(O(_e.current,ke.current))},[ue?.stat,ue?.band,ue?.sigma]);const Ie=b(e=>{const t=_e.current,n=ke.current;if(!t||!n)return;const{timeAccessor:i,valueAccessor:s}=ze.current;for(const n of e){const e=L(n,i,"time"),o=L(n,s,"value");null!=e&&null!=o&&t.push(e,o)}Ae(O(t,n))},[]),Ce=null!=me,Te=f(null),Re=f(me);Re.current=me;const Pe=f(Ce);Pe.current=Ce;const Fe=f(ie);Fe.current=ie;const Me=f(se);Me.current=se,A(()=>{Te.current=Ce?function(e){const t=g(e.lateness);return null==t?null:new v({lateness:t,getTime:e=>L(e,ze.current.timeAccessor,"time")??NaN,latePolicy:e.latePolicy??"drop"})}(Re.current):null},[Ce?`${me.lateness}|${me.latePolicy??"drop"}`:"",Ce]);const Ne=b(e=>{0!==e.length&&(He.current?Ie(e):fe.current?.pushMany(e))},[Ie]),De=b(e=>{const t=Te.current;if(!Pe.current||!t)return void Ne(e);const n=[];for(const i of e){const e=t.push(i);if(e.released.length&&n.push(...e.released),e.late.length){const n=Fe.current;if(n){const{timeAccessor:i}=ze.current,s=Re.current?.latePolicy??"drop";for(const o of e.late)n({type:"late-data",datum:o,eventTime:L(o,i,"time")??NaN,watermark:t.watermark,policy:s,lateCount:t.lateCount,timestamp:Date.now(),chartType:"RealtimeLineChart",chartId:Me.current})}}}Ne(n)},[Ne]);w(i,()=>({push:e=>De([e]),pushMany:e=>De(e),remove:e=>He.current?[]:fe.current?.remove(e)??[],update:(e,t)=>He.current?[]:fe.current?.update(e,t)??[],clear:()=>{Te.current?.clear(),He.current?(_e.current?.clear(),Ae([])):fe.current?.clear()},getData:()=>He.current?Se.current:fe.current?.getData()??[],getScales:()=>fe.current?.getScales()??null}),[De]);const Ee=l(oe,ge[0],ge[1],re),Be=Ee?null:a(be?void 0:_,ge[0],ge[1],ae),Oe={stroke:N,strokeWidth:D,strokeDasharray:E};null!=B&&(Oe.opacity=B);const je=T(y,_),Le=be?xe:_,We=be?R:k,Ve=be?P:H,$e=be&&ue&&"none"!==(ue.band??"none")?{y0Accessor:F,y1Accessor:M,perSeries:!1}:void 0;return Ee||Be||j(e,{ref:fe,chartType:"line",runtimeMode:"streaming",size:ge,margin:pe,className:le?`${h||""} semiotic-emphasis-${le}`.trim():h,arrowOfTime:d,windowMode:be?"growing":p,windowSize:be?Math.max(1,ue?.retain??Math.max(xe.length,600)):je,data:Le,timeAccessor:We,valueAccessor:Ve,xExtent:S,yExtent:z,extentPadding:I,band:$e,lineStyle:Oe,showAxes:he,background:W,hoverAnnotation:de,tooltipContent:ve,...t({linkedHover:te,selection:ne,onObservation:ie,forceHoverBehavior:!0,mobileInteraction:s.mobileInteraction,customHoverBehavior:ye}),annotations:Y,autoPlaceAnnotations:q,svgAnnotationRules:U,tickFormatTime:G,tickFormatValue:Q,decay:Z,pulse:J,staleness:K,transition:ee,pointIdAccessor:n.pointIdAccessor,legendPosition:ce})});W.displayName="RealtimeLineChart";import{useRef as V,useImperativeHandle as $,forwardRef as X,useCallback as Y,useMemo as q}from"react";function U(e,t,n){const i="function"==typeof t?t(e):e[t??n];if(null==i)return null;if(i instanceof Date)return i.getTime();if("string"==typeof i&&""===i.trim())return null;const s=Number(i);return Number.isFinite(s)?s:null}import{jsx as G}from"react/jsx-runtime";var Q=X(function(c,u){const m=o(c.mode,{width:c.size?.[0]??c.width,height:c.size?.[1]??c.height,showAxes:c.showAxes,showLegend:c.showLegend,enableHover:null!=c.enableHover?!!c.enableHover:void 0,linkedHover:c.linkedHover,mobileInteraction:c.mobileInteraction,mobileSemantics:c.mobileSemantics,responsiveRules:c.responsiveRules}),{binSize:h,size:d,margin:p,className:g,arrowOfTime:v="right",windowMode:f="sliding",windowSize:w,data:y,timeAccessor:b,valueAccessor:x,direction:A="up",timeExtent:C,valueExtent:R,extentPadding:P,categoryAccessor:F,colors:M,fill:N,stroke:D,strokeWidth:E,opacity:B,gap:O,background:j,tooltipContent:L,tooltip:W,onHover:X,annotations:Q,autoPlaceAnnotations:Z,svgAnnotationRules:J,tickFormatTime:K,tickFormatValue:ee,linkedHover:te,selection:ne,decay:ie,pulse:se,staleness:oe,transition:re,onObservation:ae,chartId:le,loading:ce,loadingContent:ue,emptyContent:me,emphasis:he,legendPosition:de,legend:pe,brush:ge,onBrush:ve,linkedBrush:fe}=c,we=m.showAxes,ye=m.enableHover,be=d??[m.width,m.height],xe=q(()=>M?e=>M[e]??N??"#999":void 0,[M,N]),{legend:Ae,margin:_e,legendPosition:ke}=s({data:y??[],colorBy:F,colorScale:xe,showLegend:m.showLegend,legendPosition:de,userMargin:p,defaults:m.marginDefaults,additionalLegend:pe,chartWidth:be[0]}),He=L??W??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const i=e?.data??null;if(null==i?.binStart||null==i?.binEnd){const e=z(i,t,"time"),s=z(i,n,"value");return k("div",{className:"semiotic-tooltip",style:H,children:[k("div",{children:[_("span",{style:S,children:"x:"}),I(e)]}),k("div",{children:[_("span",{style:S,children:"y:"}),I(s)]})]})}return k("div",{className:"semiotic-tooltip",style:H,children:[k("div",{children:[_("span",{style:S,children:"range:"}),I(i.binStart),"–",I(i.binEnd)]}),null!=i.total&&k("div",{children:[_("span",{style:S,children:"count:"}),I(i.total)]}),null!=i.category&&k("div",{children:[_("span",{style:S,children:"category:"}),I(i.category)]})]})}}({timeAccessor:b,valueAccessor:x}),Se=V(null),{customHoverBehavior:ze}=r({selection:ne,linkedHover:te,unwrapData:!0,onObservation:ae,chartType:"RealtimeHistogram",chartId:le}),Ie=Y(e=>{X&&X(e),ze(e)},[X,ze]),Ce=!0===ge?{dimension:"x",snap:"bin"}:"x"===ge?{dimension:"x"}:"object"==typeof ge?ge:void 0,Te=n(fe),Re="string"==typeof b?b:"time",Pe=i({name:Te?.name||"__unused_hist_brush__",xField:Te?.xField||Re,...Te?.yField?{yField:Te.yField}:{}}),Fe=V(Pe.brushInteraction);Fe.current=Pe.brushInteraction;const Me=Y(e=>{if(ve&&ve(e),ae&&ae(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:le}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:le}),Te){const t=Fe.current;t.end(e?"xBrush"===t.brush?e.x:"yBrush"===t.brush?e.y:[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:null)}},[ve,ae,le,Te]);$(u,()=>({push:e=>Se.current?.push(e),pushMany:e=>Se.current?.pushMany(e),remove:e=>Se.current?.remove(e)??[],update:(e,t)=>Se.current?.update(e,t)??[],clear:()=>Se.current?.clear(),getData:()=>Se.current?.getData()??[],getScales:()=>Se.current?.getScales()??null}),[]);const Ne=l(ce,be[0],be[1],ue),De=Ne?null:a(y,be[0],be[1],me),Ee={};null!=N&&(Ee.fill=N),null!=D&&(Ee.stroke=D),null!=E&&(Ee.strokeWidth=E),null!=B&&(Ee.opacity=B),null!=O&&(Ee.gap=O);const Be=he?`${g||""} semiotic-emphasis-${he}`.trim():g,Oe=T(w,y),je=q(()=>"down"!==A?R:function({data:e,valueAccessor:t,timeAccessor:n,binSize:i,valueExtent:s,extentPadding:o}){if(s)return[s[1],s[0]];if(!e||0===e.length)return;const r=new Map;for(const s of e){const e=U(s,n,"time"),o=U(s,t,"value");if(null==e||null==o)continue;const a=Math.floor(e/i)*i;r.set(a,(r.get(a)??0)+o)}let a=0;for(const e of r.values())a=Math.max(a,e);return[a>0?a+a*(o??.1):1,0]}({data:y,valueAccessor:x,timeAccessor:b,binSize:h,valueExtent:R,extentPadding:P}),[A,y,x,b,h,R,P]);return Ne||De||G(e,{ref:Se,chartType:"bar",runtimeMode:"streaming",size:be,margin:_e,className:Be,arrowOfTime:v,windowMode:f,windowSize:Oe,data:y,timeAccessor:b,valueAccessor:x,xExtent:C,yExtent:je,extentPadding:P,binSize:h,categoryAccessor:F,barColors:M,barStyle:Ee,showAxes:we,background:j,hoverAnnotation:ye,tooltipContent:He,...t({linkedHover:te,selection:ne,onObservation:ae,forceHoverBehavior:!0,mobileInteraction:m.mobileInteraction,customHoverBehavior:Ie}),annotations:Q,autoPlaceAnnotations:Z,svgAnnotationRules:J,tickFormatTime:K,tickFormatValue:ee,decay:ie,pulse:se,staleness:oe,transition:re,pointIdAccessor:c.pointIdAccessor,legend:Ae,legendPosition:ke,brush:Ce||(fe?{dimension:"x"}:void 0),onBrush:Ce||fe?Me:void 0})});function Z(e){return G(Q,{...e,windowMode:"growing"})}Q.displayName="RealtimeHistogram",Z.displayName="TemporalHistogram";var J=Q;import{useRef as K,useImperativeHandle as ee,forwardRef as te,useCallback as ne}from"react";import{jsx as ie}from"react/jsx-runtime";var se=te(function(n,i){const s=o(n.mode,{width:n.size?.[0]??n.width,height:n.size?.[1]??n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,responsiveRules:n.responsiveRules}),{size:c,margin:u,className:m,arrowOfTime:h="right",windowMode:d="sliding",windowSize:p,data:g,timeAccessor:v,valueAccessor:f,timeExtent:w,valueExtent:y,yScaleType:b,extentPadding:x,categoryAccessor:A,colors:_,radius:k,fill:H,opacity:S,stroke:z,strokeWidth:I,pointStyle:R,background:P,tooltipContent:F,tooltip:M,onHover:N,annotations:D,autoPlaceAnnotations:E,svgAnnotationRules:B,tickFormatTime:O,tickFormatValue:j,linkedHover:L,selection:W,onObservation:V,chartId:$,loading:X,loadingContent:Y,emptyContent:q,emphasis:U,legendPosition:G}=n,Q=s.showAxes,Z=s.enableHover,J=u??s.marginDefaults,te=c??[s.width,s.height],se=F??M??C({timeAccessor:v,valueAccessor:f}),oe=K(null),{customHoverBehavior:re}=r({selection:W,linkedHover:L,unwrapData:!0,onObservation:V,chartType:"RealtimeSwarmChart",chartId:$}),ae=ne(e=>{N&&N(e),re(e)},[N,re]);ee(i,()=>({push:e=>oe.current?.push(e),pushMany:e=>oe.current?.pushMany(e),remove:e=>oe.current?.remove(e)??[],update:(e,t)=>oe.current?.update(e,t)??[],clear:()=>oe.current?.clear(),getData:()=>oe.current?.getData()??[],getScales:()=>oe.current?.getScales()??null}),[]);const le=l(X,te[0],te[1],Y),ce=le?null:a(g,te[0],te[1],q),ue={};null!=k&&(ue.radius=k),null!=H&&(ue.fill=H),null!=S&&(ue.opacity=S),null!=z&&(ue.stroke=z),null!=I&&(ue.strokeWidth=I);const me=R,he=U?`${m||""} semiotic-emphasis-${U}`.trim():m,de=T(p,g);return le||ce||ie(e,{ref:oe,chartType:"swarm",runtimeMode:"streaming",size:te,margin:J,className:he,arrowOfTime:h,windowMode:d,windowSize:de,data:g,timeAccessor:v,valueAccessor:f,xExtent:w,yExtent:y,yScaleType:b,extentPadding:x,categoryAccessor:A,barColors:_,swarmStyle:ue,pointStyle:me,showAxes:Q,background:P,hoverAnnotation:Z,tooltipContent:se,...t({linkedHover:L,selection:W,onObservation:V,forceHoverBehavior:!0,mobileInteraction:s.mobileInteraction,customHoverBehavior:ae}),annotations:D,autoPlaceAnnotations:E,svgAnnotationRules:B,tickFormatTime:O,tickFormatValue:j,legendPosition:G,pointIdAccessor:n.pointIdAccessor})});se.displayName="RealtimeSwarmChart";import{useRef as oe,useImperativeHandle as re,forwardRef as ae,useCallback as le}from"react";import{jsx as ce}from"react/jsx-runtime";var ue=ae(function(n,i){const s=o(n.mode,{width:n.size?.[0]??n.width,height:n.size?.[1]??n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,responsiveRules:n.responsiveRules}),{size:c,margin:u,className:m,arrowOfTime:h="right",windowMode:d="sliding",windowSize:p,data:g,timeAccessor:v,valueAccessor:f,timeExtent:w,valueExtent:y,extentPadding:b,positiveColor:x,negativeColor:A,connectorStroke:C,connectorWidth:R,gap:P,stroke:F,strokeWidth:M,opacity:N,background:D,tooltipContent:E,tooltip:B,onHover:O,annotations:j,autoPlaceAnnotations:L,svgAnnotationRules:W,tickFormatTime:V,tickFormatValue:$,linkedHover:X,selection:Y,onObservation:q,chartId:U,loading:G,loadingContent:Q,emptyContent:Z,emphasis:J,legendPosition:K}=n,ee=s.showAxes,te=s.enableHover,ne=u??s.marginDefaults,ie=c??[s.width,s.height],se=E??B??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const i=e?.data??null,s=z(i,t,"time"),o=i?.delta??z(i,n,"value"),r=i?.cumEnd,a="number"==typeof o?0>o?I(o):"+"+I(o):I(o);return k("div",{className:"semiotic-tooltip",style:H,children:[k("div",{children:[_("span",{style:S,children:"x:"}),I(s)]}),k("div",{children:[_("span",{style:S,children:"Δ:"}),a]}),null!=r&&k("div",{children:[_("span",{style:S,children:"total:"}),I(r)]})]})}}({timeAccessor:v,valueAccessor:f}),ae=oe(null),{customHoverBehavior:ue}=r({selection:Y,linkedHover:X,unwrapData:!0,onObservation:q,chartType:"RealtimeWaterfallChart",chartId:U}),me=le(e=>{O&&O(e),ue(e)},[O,ue]);re(i,()=>({push:e=>ae.current?.push(e),pushMany:e=>ae.current?.pushMany(e),remove:e=>ae.current?.remove(e)??[],update:(e,t)=>ae.current?.update(e,t)??[],clear:()=>ae.current?.clear(),getData:()=>ae.current?.getData()??[],getScales:()=>ae.current?.getScales()??null}),[]);const he=l(G,ie[0],ie[1],Q),de=he?null:a(g,ie[0],ie[1],Z),pe={};null!=x&&(pe.positiveColor=x),null!=A&&(pe.negativeColor=A),null!=C&&(pe.connectorStroke=C),null!=R&&(pe.connectorWidth=R),null!=P&&(pe.gap=P),null!=F&&(pe.stroke=F),null!=M&&(pe.strokeWidth=M),null!=N&&(pe.opacity=N);const ge=J?`${m||""} semiotic-emphasis-${J}`.trim():m,ve=T(p,g);return he||de||ce(e,{ref:ae,chartType:"waterfall",runtimeMode:"streaming",size:ie,margin:ne,className:ge,arrowOfTime:h,windowMode:d,windowSize:ve,data:g,timeAccessor:v,valueAccessor:f,xExtent:w,yExtent:y,extentPadding:b,waterfallStyle:pe,showAxes:ee,background:D,hoverAnnotation:te,tooltipContent:se,...t({linkedHover:X,selection:Y,onObservation:q,forceHoverBehavior:!0,mobileInteraction:s.mobileInteraction,customHoverBehavior:me}),annotations:j,autoPlaceAnnotations:L,svgAnnotationRules:W,tickFormatTime:V,tickFormatValue:$,legendPosition:K,pointIdAccessor:n.pointIdAccessor})});ue.displayName="RealtimeWaterfallChart";import{useRef as me,useImperativeHandle as he,forwardRef as de,useCallback as pe}from"react";import{jsx as ge}from"react/jsx-runtime";var ve=de(function(n,i){const s=o(n.mode,{width:n.size?.[0]??n.width,height:n.size?.[1]??n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,responsiveRules:n.responsiveRules}),{size:c,margin:u,className:m,arrowOfTime:h="right",windowMode:d="sliding",windowSize:p,data:g,timeAccessor:v,valueAccessor:f,categoryAccessor:w,timeExtent:y,valueExtent:b,extentPadding:x,heatmapXBins:A=20,heatmapYBins:C=20,aggregation:R="count",background:P,tooltipContent:F,tooltip:M,onHover:N,annotations:D,autoPlaceAnnotations:E,svgAnnotationRules:B,tickFormatTime:O,tickFormatValue:j,decay:L,pulse:W,staleness:V,linkedHover:$,selection:X,onObservation:Y,chartId:q,loading:U,loadingContent:G,emptyContent:Q,emphasis:Z,legendPosition:J}=n,K=s.showAxes,ee=s.enableHover,te=u??s.marginDefaults,ne=c??[s.width,s.height],ie=F??M??function(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:i="x",yLabel:s="y"}=e;return e=>{const o=e?.data??null,r=o?.xCenter??z(o,t,"time"),a=o?.yCenter??z(o,n,"value"),l=o?.count,c=o?.sum,u=o?.value,m=o?.agg??"count";return k("div",{className:"semiotic-tooltip",style:H,children:[k("div",{children:[k("span",{style:S,children:[i,":"]}),I(r)]}),k("div",{children:[k("span",{style:S,children:[s,":"]}),I(a)]}),null!=l&&k("div",{children:[_("span",{style:S,children:"count:"}),I(l)]}),"sum"===m&&null!=c&&k("div",{children:[_("span",{style:S,children:"sum:"}),I(c)]}),"mean"===m&&null!=u&&k("div",{children:[_("span",{style:S,children:"mean:"}),I(u)]})]})}}({timeAccessor:v,valueAccessor:f}),se=me(null),{customHoverBehavior:oe}=r({selection:X,linkedHover:$,unwrapData:!0,onObservation:Y,chartType:"RealtimeHeatmap",chartId:q}),re=pe(e=>{N&&N(e),oe(e)},[N,oe]);he(i,()=>({push:e=>se.current?.push(e),pushMany:e=>se.current?.pushMany(e),remove:e=>se.current?.remove(e)??[],update:(e,t)=>se.current?.update(e,t)??[],clear:()=>se.current?.clear(),getData:()=>se.current?.getData()??[],getScales:()=>se.current?.getScales()??null}),[]);const ae=l(U,ne[0],ne[1],G),le=ae?null:a(g,ne[0],ne[1],Q),ce=Z?`${m||""} semiotic-emphasis-${Z}`.trim():m,ue=T(p,g);return ae||le||ge(e,{ref:se,chartType:"heatmap",runtimeMode:"streaming",size:ne,margin:te,className:ce,arrowOfTime:h,windowMode:d,windowSize:ue,data:g,timeAccessor:v,valueAccessor:f,categoryAccessor:w,xExtent:y,yExtent:b,extentPadding:x,heatmapXBins:A,heatmapYBins:C,heatmapAggregation:R,showAxes:K,background:P,hoverAnnotation:ee,tooltipContent:ie,...t({linkedHover:$,selection:X,onObservation:Y,forceHoverBehavior:!0,mobileInteraction:s.mobileInteraction,customHoverBehavior:re}),annotations:D,autoPlaceAnnotations:E,svgAnnotationRules:B,tickFormatTime:O,tickFormatValue:j,decay:L,pulse:W,staleness:V,legendPosition:J,pointIdAccessor:n.pointIdAccessor})});ve.displayName="RealtimeHeatmap";export{c as RunningStats,u as WindowAccumulator,m as statValue,h as bandBounds,g as parseWindowDuration,v as ReorderBuffer,W as RealtimeLineChart,Q as RealtimeHistogram,Z as TemporalHistogram,J as RealtimeTemporalHistogram,se as RealtimeSwarmChart,ue as RealtimeWaterfallChart,ve as RealtimeHeatmap};
@@ -0,0 +1 @@
1
+ import{mulberry32 as t}from"./chunk-chunk-SIRIJ3DY.module.min.js";import{UpdateResultTracker as e}from"./chunk-chunk-5RKXZQ2P.module.min.js";var i={seed:1,gravity:{x:0,y:980},fixedDt:1/120,cellSize:64,collisionIterations:6,velocityDamping:.995,sleepSpeed:8,sleepAfter:.35,restitution:.1,friction:.35,maxVelocity:1600,contactWakeSpeed:200},s=1e-9,n=.005;function o(t){return"circle"===t.type?{type:"circle",radius:t.radius}:{type:"aabb",width:t.width,height:t.height}}function r(t){return"aabb"===t.type?{type:"aabb",x:t.x,y:t.y,width:t.width,height:t.height}:{type:"segment",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,thickness:t.thickness}}function a(t,e,i){return Math.max(e,Math.min(i,t))}function d(t){return 0>t?-1:1}function h(t){if("circle"===t.shape.type){const e=t.shape.radius;return{minX:t.x-e,minY:t.y-e,maxX:t.x+e,maxY:t.y+e}}const e=t.shape.width/2,i=t.shape.height/2;return{minX:t.x-e,minY:t.y-i,maxX:t.x+e,maxY:t.y+i}}function c(t){const e=t.shape;if("aabb"===e.type){const t=e.width/2,i=e.height/2;return{minX:e.x-t,minY:e.y-i,maxX:e.x+t,maxY:e.y+i}}const i=(e.thickness??0)/2;return{minX:Math.min(e.x1,e.x2)-i,minY:Math.min(e.y1,e.y2)-i,maxX:Math.max(e.x1,e.x2)+i,maxY:Math.max(e.y1,e.y2)+i}}function l(t,e){return!(t.minX>e.maxX||e.minX>t.maxX||t.minY>e.maxY||e.minY>t.maxY)}function u(t,e,i,s,n,o,r,a){const h=n-t,c=(i+r)/2-Math.abs(h);if(0>=c)return null;const l=o-e,u=(s+a)/2-Math.abs(l);return u>0?u>c?{nx:d(h),ny:0,penetration:c}:{nx:0,ny:d(l),penetration:u}:null}function p(t,e,i,n,o,r,d){const h=r/2,c=d/2;let l=t-a(t,n-h,n+h),u=e-a(e,o-c,o+c);const p=l*l+u*u;if(p>i*i)return null;if(s>=p){const s=Math.abs(t-(n-h)),r=Math.abs(t-(n+h)),a=Math.abs(e-(o-c)),d=Math.abs(e-(o+c)),p=Math.min(s,r,a,d);return p===s?(l=-1,u=0,{nx:l,ny:u,penetration:i+s}):p===r?(l=1,u=0,{nx:l,ny:u,penetration:i+r}):p===a?(l=0,u=-1,{nx:l,ny:u,penetration:i+a}):(l=0,u=1,{nx:l,ny:u,penetration:i+d})}const m=Math.sqrt(p);return{nx:l/m,ny:u/m,penetration:i-m}}function m(t,e){if("circle"===t.shape.type&&"circle"===e.shape.type)return function(t,e,i,n,o,r){const a=n-t,d=o-e,h=i+r,c=a*a+d*d;if(c>=h*h)return null;if(s>=c)return{nx:1,ny:0,penetration:h};const l=Math.sqrt(c);return{nx:a/l,ny:d/l,penetration:h-l}}(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.radius);if("aabb"===t.shape.type&&"aabb"===e.shape.type)return u(t.x,t.y,t.shape.width,t.shape.height,e.x,e.y,e.shape.width,e.shape.height);if("circle"===t.shape.type&&"aabb"===e.shape.type){const i=p(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height);return i?{nx:-i.nx,ny:-i.ny,penetration:i.penetration}:null}return"aabb"===t.shape.type&&"circle"===e.shape.type?p(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.width,t.shape.height):null}function y(t,e){const i=e.shape;return"aabb"===i.type?"circle"===t.shape.type?p(t.x,t.y,t.shape.radius,i.x,i.y,i.width,i.height):u(i.x,i.y,i.width,i.height,t.x,t.y,t.shape.width,t.shape.height):function(t,e,i,n,o,r,d,h=0){const c=r-n,l=d-o,u=c*c+l*l,p=u>s?a(((t-n)*c+(e-o)*l)/u,0,1):0,m=i+h/2,y=t-(n+c*p),f=e-(o+l*p),v=y*y+f*f;if(v>=m*m)return null;if(s>=v){const t=Math.sqrt(u);return t>s?{nx:-l/t,ny:c/t,penetration:m}:{nx:1,ny:0,penetration:m}}const b=Math.sqrt(v);return{nx:y/b,ny:f/b,penetration:m-b}}(t.x,t.y,"circle"===t.shape.type?t.shape.radius:Math.sqrt(t.shape.width*t.shape.width+t.shape.height*t.shape.height)/2,i.x1,i.y1,i.x2,i.y2,i.thickness??0)}function f(t,e){return`${t}\0${e}`}function v(t){const e=t.indexOf("\0");return{sensorId:t.slice(0,e),bodyId:t.slice(e+1)}}function b(t){return{id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,bodyCollisions:t.bodyCollisions,shape:o(t.shape),sleeping:t.sleeping,datum:t.datum,index:t.index,sleepTime:t.sleepTime,restitution:t.restitution,friction:t.friction}}function g(t){return t&&"function"!=typeof t?{property:t.property,equals:t.equals,notEquals:t.notEquals,oneOf:t.oneOf?.slice(),notOneOf:t.notOneOf?.slice()}:t}function x(t){return{id:t.id,shape:r(t.shape),sensor:t.sensor,restitution:t.restitution,friction:t.friction,bodyFilter:g(t.bodyFilter),index:t.index}}function S(t,e){return!!e?.some(e=>Object.is(t,e))}function w(t,e){const i=t.bodyFilter;if(!i)return!0;if("function"==typeof i)return i(e);const s=function(t,e){if(!e)return;let i=t;for(const t of e.split(".")){if(null==i||"object"!=typeof i)return;i=i[t]}return i}(e,i.property);return!("equals"in i&&!Object.is(s,i.equals)||"notEquals"in i&&Object.is(s,i.notEquals)||i.oneOf&&!S(s,i.oneOf)||i.notOneOf&&S(s,i.notOneOf))}var I=class{constructor(e={}){this.capabilities={determinism:"strict",sensors:!0,joints:!1,ccd:!1,maxBodiesHint:5e3,worker:!1},this.bodies=new Map,this.colliders=new Map,this.springs=new Map,this.activeSensors=new Set,this.supportedThisStep=new Set,this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0,this.options={...i,...e},this.random=t(this.options.seed)}init(e={}){this.options={...i,...e},this.random=t(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0}spawn(t){const e={id:t.id,x:t.x,y:t.y,prevX:t.x,prevY:t.y,vx:t.vx??0,vy:t.vy??0,angle:t.angle??0,mass:Math.max(s,t.mass??1),bodyCollisions:t.bodyCollisions??!0,shape:o(t.shape),sleeping:!1,datum:t.datum,restitution:t.restitution,friction:t.friction,index:this.nextBodyIndex,sleepTime:0};this.nextBodyIndex+=1,this.bodies.set(t.id,e)}remove(t){for(const e of t){this.bodies.delete(e);for(const t of Array.from(this.activeSensors))v(t).bodyId===e&&this.activeSensors.delete(t)}}setColliders(t){this.colliders.clear(),this.activeSensors.clear(),this.nextColliderIndex=0;for(const e of t)this.colliders.set(e.id,{...e,shape:r(e.shape),bodyFilter:g(e.bodyFilter),index:this.nextColliderIndex}),this.nextColliderIndex+=1}setConstraint(t){const e=t.id??"spring-"+this.nextSpringIndex;return this.springs.set(e,{id:e,bodyId:t.bodyId,target:t.target,restLength:t.restLength??0,stiffness:t.stiffness??40,damping:t.damping??3}),this.nextSpringIndex+=1,e}removeConstraint(t){this.springs.delete(t)}applyImpulse(t,e,i){const s=this.bodies.get(t);s&&(s.vx+=e/s.mass,s.vy+=i/s.mass,this.wake(s))}step(t=this.options.fixedDt){const e=Math.max(0,t);if(this.lastEvents=[],0===e)return;const i=this.sortedBodies();for(const t of i)t.prevX=t.x,t.prevY=t.y;this.applySprings(e);const s=this.options.maxVelocity;for(const t of i)if(!t.sleeping){if(t.vx+=this.options.gravity.x*e,t.vy+=this.options.gravity.y*e,t.vx*=this.options.velocityDamping,t.vy*=this.options.velocityDamping,s>0){const e=Math.sqrt(t.vx*t.vx+t.vy*t.vy);if(e>s){const i=s/e;t.vx*=i,t.vy*=i}}t.x+=t.vx*e,t.y+=t.vy*e}this.supportedThisStep.clear();const n=this.bodyPairKeys(i),o=this.sortedColliders().filter(t=>!t.sensor);for(let t=0;this.options.collisionIterations>t;t+=1)this.resolveBodyPairs(i,n,0===t),this.resolveColliders(i,o,0===t);this.updateSensors(i),this.updateSleeping(i,e)}settle(t=1200,e=this.options.fixedDt){let i=0;for(;t>i&&!this.allSleeping();)this.step(e),i+=1;return i}readState(t=[]){t.length=0;for(const e of this.sortedBodies())t.push({id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,shape:o(e.shape),sleeping:e.sleeping,datum:e.datum});return t}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(v)}allSleeping(){for(const t of this.bodies.values())if(!t.sleeping)return!1;return!0}snapshot(){return{options:{...this.options,gravity:{...this.options.gravity}},bodies:this.sortedBodies().map(b),colliders:this.sortedColliders().map(x),springs:Array.from(this.springs.values()).map(t=>({...t,target:{...t.target}})),activeSensors:Array.from(this.activeSensors).sort()}}restore(e){this.options={...e.options,gravity:{...e.options.gravity}},this.random=t(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors=new Set(e.activeSensors),this.lastEvents=[],this.nextBodyIndex=0;for(const t of e.bodies){const e=b(t);this.bodies.set(e.id,e),this.nextBodyIndex=Math.max(this.nextBodyIndex,e.index+1)}this.nextColliderIndex=0;for(const t of e.colliders){const e=x(t);this.colliders.set(e.id,e),this.nextColliderIndex=Math.max(this.nextColliderIndex,e.index+1)}this.nextSpringIndex=0;for(const t of e.springs){this.springs.set(t.id,{...t,target:{...t.target}});const e=/^spring-(\d+)$/.exec(t.id);e&&(this.nextSpringIndex=Math.max(this.nextSpringIndex,Number(e[1])+1))}}dispose(){this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[]}sortedBodies(){return Array.from(this.bodies.values()).sort((t,e)=>t.index-e.index)}sortedColliders(){return Array.from(this.colliders.values()).sort((t,e)=>t.index-e.index)}applySprings(t){for(const e of Array.from(this.springs.values()).sort((t,e)=>t.id.localeCompare(e.id))){const i=this.bodies.get(e.bodyId);if(!i||i.sleeping)continue;const n="point"===e.target.type?e.target:this.bodies.get(e.target.bodyId);if(!n)continue;const o=n.x-i.x,r=n.y-i.y,a=Math.sqrt(o*o+r*r);if(s>=a)continue;const d=o/a,h=r/a,c=(a-e.restLength)*e.stiffness+((("vx"in n?n.vx:0)-i.vx)*d+(("vy"in n?n.vy:0)-i.vy)*h)*e.damping;i.vx+=c*d*t/i.mass,i.vy+=c*h*t/i.mass}}resolveBodyPairs(t,e,i){for(const s of e){const[e,n]=s.split(":").map(Number),o=t[e],r=t[n];if(!o||!r)continue;const a=m(o,r);a&&(this.resolveDynamicCollision(o,r,a),i&&this.lastEvents.push({type:"contact",bodyId:o.id,otherId:r.id,sensor:!1}))}}bodyPairKeys(t){const e=Math.max(1,this.options.cellSize),i=new Map;for(let s=0;t.length>s;s+=1){if(!1===t[s].bodyCollisions)continue;const n=h(t[s]),o=Math.floor(n.minX/e),r=Math.floor(n.maxX/e),a=Math.floor(n.minY/e),d=Math.floor(n.maxY/e);for(let t=o;r>=t;t+=1)for(let e=a;d>=e;e+=1){const n=`${t}:${e}`,o=i.get(n);o?o.push(s):i.set(n,[s])}}const s=new Set;for(const e of Array.from(i.keys()).sort()){const n=i.get(e)??[];n.sort((t,e)=>t-e);for(let e=0;n.length>e;e+=1)for(let i=e+1;n.length>i;i+=1){const o=n[e],r=n[i];!1!==t[o].bodyCollisions&&!1!==t[r].bodyCollisions&&l(h(t[o]),h(t[r]))&&s.add(`${o}:${r}`)}}return Array.from(s).sort((t,e)=>{const[i,s]=t.split(":").map(Number),[n,o]=e.split(":").map(Number);return i===n?s-o:i-n})}resolveDynamicCollision(t,e,i){t.sleeping&&this.contactOpposesGravity(i.nx,i.ny)&&this.supportedThisStep.add(e.id),e.sleeping&&this.contactOpposesGravity(-i.nx,-i.ny)&&this.supportedThisStep.add(t.id);const o=t.sleeping?0:1/t.mass,r=e.sleeping?0:1/e.mass,a=o+r;if(s>=a)return;const d=Math.max(0,i.penetration-n)/a;t.x-=i.nx*d*o,t.y-=i.ny*d*o,e.x+=i.nx*d*r,e.y+=i.ny*d*r;const h=(e.vx-t.vx)*i.nx+(e.vy-t.vy)*i.ny;if(h>0)return;const c=Math.abs(h),l=-(1+Math.min(t.restitution??this.options.restitution,e.restitution??this.options.restitution))*h/a,u=l*i.nx,p=l*i.ny;t.vx-=u*o,t.vy-=p*o,e.vx+=u*r,e.vy+=p*r,this.applyFriction(t,e,i,l,o,r),c>this.options.contactWakeSpeed&&(this.wake(t),this.wake(e))}applyFriction(t,e,i,n,o,r){const d=-i.ny,h=i.nx,c=(e.vx-t.vx)*d+(e.vy-t.vy)*h,l=o+r;if(s>=Math.abs(c)||s>=l)return;const u=Math.max(0,Math.min(1,Math.max(t.friction??this.options.friction,e.friction??this.options.friction))),p=a(-c/l,-n*u,n*u),m=p*d,y=p*h;t.vx-=m*o,t.vy-=y*o,e.vx+=m*r,e.vy+=y*r}resolveColliders(t,e,i){for(const s of t)for(const t of e){if(!w(t,s))continue;if(!l(h(s),c(t)))continue;const e=y(s,t);e&&(this.resolveStaticCollision(s,t,e),this.contactOpposesGravity(e.nx,e.ny)&&this.supportedThisStep.add(s.id),i&&this.lastEvents.push({type:"contact",bodyId:s.id,otherId:t.id,sensor:!1}))}}resolveStaticCollision(t,e,i){t.x+=i.nx*Math.max(0,i.penetration-n),t.y+=i.ny*Math.max(0,i.penetration-n);const s=t.vx*i.nx+t.vy*i.ny;if(0>s){const n=Math.min(t.restitution??this.options.restitution,e.restitution??this.options.restitution);t.vx-=(1+n)*s*i.nx,t.vy-=(1+n)*s*i.ny;const o=-i.ny,r=i.nx,a=t.vx*o+t.vy*r,d=Math.max(0,Math.min(1,Math.max(t.friction??this.options.friction,e.friction??this.options.friction)));t.vx-=a*o*d,t.vy-=a*r*d}}updateSensors(t){const e=new Set,i=this.sortedColliders().filter(t=>t.sensor);for(const s of t){const t=h(s);for(const n of i){if(!w(n,s))continue;if(!l(t,c(n)))continue;if(!y(s,n))continue;const i=f(n.id,s.id);e.add(i),this.activeSensors.has(i)||this.lastEvents.push({type:"sensor-enter",bodyId:s.id,sensorId:n.id})}}for(const t of Array.from(this.activeSensors).sort()){if(e.has(t))continue;const{sensorId:i,bodyId:s}=v(t);this.lastEvents.push({type:"sensor-exit",bodyId:s,sensorId:i})}this.activeSensors=e}updateSleeping(t,e){const i=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(const s of t)Math.sqrt(s.vx*s.vx+s.vy*s.vy)>=this.options.sleepSpeed||Math.sqrt((s.x-s.prevX)*(s.x-s.prevX)+(s.y-s.prevY)*(s.y-s.prevY))>=this.options.sleepSpeed*e||i&&!this.supportedThisStep.has(s.id)?s.sleeping?this.wake(s):s.sleepTime=0:(s.sleepTime+=e,s.sleeping||this.options.sleepAfter>s.sleepTime||(s.sleeping=!0,s.vx=0,s.vy=0,this.lastEvents.push({type:"sleep",bodyId:s.id})))}contactOpposesGravity(t,e){const{x:i,y:s}=this.options.gravity,n=Math.hypot(i,s);return 1e-9>=n||-.2>(t*i+e*s)/n}wake(t){t.sleeping&&this.lastEvents.push({type:"wake",bodyId:t.id}),t.sleeping=!1,t.sleepTime=0}nextRandom(){return this.random()}},M=class{constructor(t={}){this.id="builtin",this.capabilities={...(new I).capabilities,engine:"builtin"},this.world=new I(t)}init(t={}){this.world.init(t)}spawn(t){this.world.spawn(t)}remove(t){this.world.remove(t)}setColliders(t){this.world.setColliders(t)}setConstraint(t){return this.world.setConstraint(t)}removeConstraint(t){this.world.removeConstraint(t)}applyImpulse(t,e,i){this.world.applyImpulse(t,e,i)}step(t){this.world.step(t)}settle(t,e){return this.world.settle(t,e)}readState(t){return this.world.readState(t)}events(){return this.world.events()}activeSensorPairs(){return this.world.activeSensorPairs()}allSleeping(){return this.world.allSleeping()}snapshot(){return this.world.snapshot()}restore(t){this.world.restore(t)}nextRandom(){return this.world.nextRandom()}dispose(){this.world.dispose()}};function B(t={}){return new M(t)}function k(t,e={}){return t?"function"==typeof t?t(e):(t.init(e),t):B(e)}var O=["binId","targetBin","category","windowIndex","lane","group"];function q(t,e){if(!Number.isFinite(e))return;t.count+=1,t.total+=e,t.min=Math.min(t.min,e),t.max=Math.max(t.max,e);const i=e-t.mean;t.mean+=i/t.count,t.m2+=i*(e-t.mean)}function C(t){return{count:t.count,total:t.total,mean:t.count>0?t.mean:0,min:t.count>0?t.min:0,max:t.count>0?t.max:0,variance:t.count>1?t.m2/(t.count-1):0}}function T(t){return{count:t.count,total:t.total,mean:t.mean,m2:t.variance*Math.max(0,t.count-1),min:t.count>0?t.min:1/0,max:t.count>0?t.max:-1/0}}function R(t,e){if(null!=t[e])return t[e];const i=t.datum;return i&&"object"==typeof i?i[e]:void 0}function D(t,e,i){return"function"==typeof t?t(e,i):"string"==typeof t?R(e,t):void 0}function A(t){if(null==t)return;const e=t+"";return e.trim()?e:void 0}function Y(t){const e=C(t.value);return{id:t.id,label:t.label,count:e.count,total:e.total,bodyIds:t.bodyIds.slice(),lastBodyId:t.lastBodyId,lastDatum:t.lastDatum,x:C(t.x),y:C(t.y),value:e}}var F=class{constructor(t=!1){this.bins=new Map,this.nextIndex=0,this.config=t}updateConfig(t){void 0!==t&&(this.config=t,!1===t&&this.clear())}isEnabled(){return!1!==this.config}add(t){if(!1===this.config)return null;const e=this.nextIndex;this.nextIndex+=1;const i=A(D(this.config.binAccessor,t,e))??function(t){for(const e of O){const i=A(R(t,e));if(i)return i}return"sediment"}(t),s=A(D(this.config.labelAccessor,t,e))??i,n=function(t,e,i){if("number"==typeof t)return t;const s="function"==typeof t?t(e,i):"string"==typeof t?R(e,t):1,n="number"==typeof s?s:Number(s);return Number.isFinite(n)?n:1}(this.config.valueAccessor,t,e),o=Math.max(0,Math.floor(this.config.retainBodyIds??12));let r=this.bins.get(i);return r||(r={id:i,label:s,bodyIds:[],x:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},y:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},value:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0}},this.bins.set(i,r)),r.label=s,r.lastBodyId=t.id,r.lastDatum=t.datum,q(r.x,t.x),q(r.y,t.y),q(r.value,n),o>0&&(r.bodyIds.push(t.id),r.bodyIds.length>o&&(r.bodyIds=r.bodyIds.slice(r.bodyIds.length-o))),Y(r)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(Y)}restore(t=[]){this.bins.clear();for(const e of t)this.bins.set(e.id,{id:e.id,label:e.label,bodyIds:e.bodyIds.slice(),lastBodyId:e.lastBodyId,lastDatum:e.lastDatum,x:T(e.x),y:T(e.y),value:T(e.value)});this.nextIndex=t.reduce((t,e)=>t+e.count,0)}totals(){const t=this.snapshot();return{bins:t.length,count:t.reduce((t,e)=>t+e.count,0),total:t.reduce((t,e)=>t+e.total,0)}}};function E(t,e={}){const{baselineY:i=0,binWidth:s=24,gap:n=2,maxHeight:o=80,value:r="count",x:a}=e,d=Math.max(1,...t.map(t=>t[r]));return t.map((t,e)=>{const h=Math.max(0,t[r]/d*o),c=a?.(t,e)??e*(s+n);return{binId:t.id,label:t.label,index:e,count:t.count,total:t.total,x:c,y:i-h,width:s,height:h,meanX:t.x.mean,meanY:t.y.mean}})}function P(t){const e=Number(t);if(Number.isFinite(e)&&e>0)return Math.floor(e)}function L(t){const e=Math.max(0,Math.floor(t.liveBodies)),i=Math.max(0,Math.floor(t.queuedBodies??0)),s=e+i,n=P(t.bodyLimit),o=P(t.engineMaxBodiesHint),r=function(t,e,i){if(!1===i)return;const s=P(i?.warnAt);return null!=s?s:null!=t?Math.max(1,Math.floor(.8*t)):null!=e?Math.max(1,Math.floor(.8*e)):void 0}(n,o,t.options),a=null==n?0:Math.max(0,e-n),d=a>0?"overflow":null==r||r>s?"ok":"warning";return{action:"overflow"!==d?"continue":t.sedimentEnabled?"sediment":t.evictionEnabled?"evict":"retain",bodyLimit:n,engineMaxBodiesHint:o,liveBodies:e,overflow:a,projectedBodies:s,queuedBodies:i,state:d,warnAt:r}}var X={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},N={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0};function j(t={},e=N){return{chartId:t.chartId??e.chartId,chartType:t.chartType??e.chartType,sensors:t.sensors??e.sensors,onObservation:t.onObservation??e.onObservation,onSimulationStateChange:t.onSimulationStateChange??e.onSimulationStateChange}}function K(t){return{...t,shape:{...t.shape},datum:t.datum,springs:t.springs?.map(t=>({...t,target:{...t.target}}))}}function $(t){if(t instanceof Date){const e=t.getTime();return Number.isFinite(e)?e:void 0}const e="number"==typeof t?t:"string"==typeof t&&t.trim()?Number(t):NaN;return Number.isFinite(e)?e:void 0}function W(t,e){if(null!=t[e])return t[e];const i=t.datum;return i&&"object"==typeof i?i[e]:void 0}function H(t,e={}){const i=$(e.startAt)??0,s=e.pacing??"immediate";if("arrival"===s){const s=t.map((t,i)=>function(t,e,i){return"function"==typeof i?$(i(t,e)):"string"==typeof i?$(W(t,i)):$(t.spawnAt)??$(W(t,"arrivalTime"))??$(W(t,"timestamp"))??$(W(t,"time"))??$(W(t,"eventTime"))}(t,i,e.timeAccessor)),n=s.filter(t=>null!=t),o=n.length>0?Math.min(...n):0,r=$(e.timeScale)??1,a=r>0?r:1;return t.map((t,e)=>{const n=s[e],r=null==n?0:Math.max(0,n-o);return{...K(t),spawnAt:i+r/a}})}if("object"==typeof s){const e=$(s.ratePerSec);if(e&&e>0)return t.map((t,s)=>({...K(t),spawnAt:i+s/e}))}return t.map(t=>({...K(t),spawnAt:i}))}function z(t){return{...K(t),sequence:t.sequence,spawnAt:t.spawnAt}}function V(t){return t.map(t=>({...t,shape:{...t.shape},bodyFilter:t.bodyFilter&&"function"!=typeof t.bodyFilter?{...t.bodyFilter,oneOf:t.bodyFilter.oneOf?.slice(),notOneOf:t.bodyFilter.notOneOf?.slice()}:t.bodyFilter}))}function G(t){return!1!==t&&{...t}}function U(t,e){return t.spawnAt===e.spawnAt?t.sequence-e.sequence:t.spawnAt-e.spawnAt}function J(t){return{...t,gravity:{...t.gravity}}}function Q(t,e,i,s){if("circle"===t.shape.type){const n=t.x-e,o=t.y-i,r=t.shape.radius+s,a=n*n+o*o;return a>r*r?null:a}const n=Math.max(Math.abs(e-t.x)-t.shape.width/2,0),o=Math.max(Math.abs(i-t.y)-t.shape.height/2,0),r=n*n+o*o;return r>s*s?null:r}function Z(t){const e=t.indexOf("\0");return{sensorId:t.slice(0,e),bodyId:t.slice(e+1)}}function _(t,e={}){const{idPrefix:i="plot",includeFloor:s=!0,includeCeiling:n=!1,includeLeftWall:o=!0,includeRightWall:r=!0,wallThickness:a=20,floorThickness:d=a}=e,h=[],c=t.x+t.width/2,l=t.y+t.height/2;return s&&h.push({id:i+"-floor",shape:{type:"aabb",x:c,y:t.y+t.height+d/2,width:t.width+2*a,height:d}}),n&&h.push({id:i+"-ceiling",shape:{type:"aabb",x:c,y:t.y-d/2,width:t.width+2*a,height:d}}),o&&h.push({id:i+"-left-wall",shape:{type:"aabb",x:t.x-a/2,y:l,width:a,height:t.height+2*d}}),r&&h.push({id:i+"-right-wall",shape:{type:"aabb",x:t.x+t.width+a/2,y:l,width:a,height:t.height+2*d}}),h}function tt(t){const{idPrefix:e="bin",count:i,domainStart:s,domainStep:n,xScale:o,yTop:r,yBottom:a,wallThickness:d=4,includeBoundaryWalls:h=!0,includeInteriorWalls:c=!0,closedBefore:l,lidY:u=r,lidThickness:p=Math.max(2,d)}=t,m=[],y=r+(a-r)/2,f=Math.abs(a-r),v=h?i:i-1;if(c||h)for(let t=h?0:1;v>=t;t+=1){if(!c&&t>0&&i>t)continue;const r=o(s+t*n);m.push({id:`${e}-wall-${t}`,shape:{type:"aabb",x:r,y:y,width:d,height:f}})}if(null!=l)for(let t=0;i>t;t+=1){const i=s+t*n,r=i+n;if(r>=l)continue;const a=o(i),h=o(r);m.push({id:`${e}-lid-${t}`,shape:{type:"segment",x1:Math.min(a,h)+d/2,y1:u,x2:Math.max(a,h)-d/2,y2:u,thickness:p}})}return m}import{quadtree as et}from"d3-quadtree";var it=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(t,e,i,s,n,o=0){const r=this.ensure(t,e);if(!r)return null;let a=null,d=1/0;const h=Math.max(0,o)+this.maxSearchRadius,c=s-h,l=s+h,u=n-h,p=n+h;return r.visit((t,e,r,h,m)=>{if(c>h||e>l||u>m||r>p)return!0;if(t.length)return!1;let y=t;for(;y;){const t=y.data;if(t){const e=Q(t,s,n,Math.max(0,o));null!=e&&(d>e||e===d&&i.indexOf(t.id)>i.indexOf(a?.id??""))&&(a=t,d=e)}y=y.next}return!1}),a}ensure(t,e){if(this.tree&&this.revision===e)return this.tree;const i=t.readState();return 0===i.length?(this.tree=null,this.maxSearchRadius=0,this.revision=e,null):(this.maxSearchRadius=i.reduce((t,e)=>Math.max(t,function(t){return"circle"===t.shape.type?t.shape.radius:Math.hypot(t.shape.width,t.shape.height)/2}(e)),0),this.tree=et().x(t=>t.x).y(t=>t.y).addAll(i),this.revision=e,this.tree)}},st=["data","scene-geometry","data-paint","accessibility","evidence"],nt=["scene-geometry","data-paint","accessibility","evidence"],ot=["overlay","accessibility","evidence"],rt=(t,e)=>({retainedData:t,invalidations:e}),at=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],dt=["scene-geometry","data-paint","accessibility","evidence"],ht=[],ct={engine:rt("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:rt("preserve",dt),colliders:rt("preserve",dt),sediment:rt("preserve",dt),bodyBudget:rt("preserve",at),bodyLimit:rt("preserve",at),eviction:rt("preserve",at),fixedDt:rt("preserve",ht),maxDeltaSeconds:rt("preserve",ht),maxSubsteps:rt("preserve",ht),settleStepLimit:rt("preserve",ht),timeScale:rt("preserve",ht),observation:rt("preserve",ht)},lt=rt("preserve",at);function ut(t){let e="preserve";const i=new Set;for(const s of t){const t=ct[s]??lt;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)i.add(e)}return{retainedData:e,invalidations:i}}var pt=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"];function mt(t,e){return t===e||!(!t||!e)&&t.gravity?.x===e.gravity?.x&&t.gravity?.y===e.gravity?.y&&pt.every(i=>t[i]===e[i])}function yt(t,e,i,s){return t||!e?"paused":i||!s?"running":"settled"}var ft=class{constructor(){this.seconds=0,this.speed=8,this.scratch=[]}setKernelOptions(t){this.speed=function(t){const e=t?.sleepSpeed;return"number"==typeof e&&Number.isFinite(e)&&e>0?e:8}(t)}reset(){this.seconds=0}isAtRest(){return this.seconds>=.6}refresh(t,e,i){if(i>0)return void(this.seconds=0);const s=t.readState(this.scratch),n=this.speed*this.speed;let o=!0;for(const t of s)if(!t.sleeping&&t.vx*t.vx+t.vy*t.vy>=n){o=!1;break}this.seconds=o?this.seconds+Math.max(0,e):0}},vt=class{constructor(t={}){this.activeSensorPairs=new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new it,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new e,this.simulationState="settled",this.visible=!0,this.quiescence=new ft;const{bodyBudget:i,colliders:s,engine:n,kernel:o,observation:r,sediment:a,...d}=t;this.config={...X,...d},this.configInput={...t},this.bodyBudget=i??{},this.engineInput=n,this.observation=j(r),this.sediment=new F(a??!1),this.world=k(n,{fixedDt:this.config.fixedDt,...o}),this.quiescence.setKernelOptions(o),s&&this.world.setColliders(V(s))}updateConfig(t){const e=function(t,e){return Object.keys(t).filter(i=>"kernel"===i?!mt(t.kernel,e.kernel):t[i]!==e[i])}(t,this.configInput),{colliders:i,bodyBudget:s,engine:n,kernel:o,observation:r,sediment:a,...d}=t;if(this.config={...this.config,...d},void 0!==s&&(this.bodyBudget=s,!1===s&&(this.bodyBudgetObservationKey="ok")),n&&n!==this.engineInput){const t=this.world.snapshot();this.world.dispose(),this.engineInput=n,this.world=k(n,t.options),this.world.restore(t),this.revision+=1}if(o&&!mt(o,this.configInput.kernel)){const t=this.world.snapshot(),e={...t.options,...o,gravity:{...t.options.gravity,...o.gravity}};this.world.restore({...t,options:e}),this.quiescence.setKernelOptions(e),this.revision+=1}r&&(this.observation=j(r,this.observation)),this.sediment.updateConfig(a),i&&(this.world.setColliders(V(i)),this.revision+=1),this.configInput={...this.configInput,...t};const h=ut(e);this.updateResults.record({kind:"config",keys:e},h.invalidations)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}setColliders(t){this.world.setColliders(V(t)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},ut(["colliders"]).invalidations)}enqueue(t,e){const i=Array.isArray(t)?t:[t],s=e?H(i,{...e,startAt:e.startAt??this.elapsedSeconds}):i;for(const t of s)this.queue.push({...K(t),sequence:this.nextSequence,spawnAt:t.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(U),s.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:s.length},s.length?st:[])}enqueueWithResult(t,e){return this.enqueue(t,e),this.updateResults.last}spawnNow(t){this.spawnOne(K(t)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},st)}materializeDueSpawns(){const t=this.revision,e=[],i=[];return this.spawnDue(e,i),0===e.length||(this.observeBodyBudget(i),this.evictOverflow(i),this.syncSimulationState(i),this.revision+=1,this.updateResults.record({kind:"enqueue",count:e.length},this.revision!==t?st:[])),e}clear(){const t=this.world.snapshot().options;this.world.init({...t,fixedDt:this.config.fixedDt}),this.activeSensorPairs.clear(),this.liveBodyOrder=[],this.queue=[],this.accumulator=0,this.elapsedSeconds=0,this.nextSequence=0,this.quiescence.reset(),this.sediment.clear(),this.bodyBudgetObservationKey="ok",this.revision+=1,this.syncSimulationState(),this.updateResults.record({kind:"clear"},st)}tick(t){const e=this.revision,i=[],s=[],n=[],o=[],r=[];if(this.paused||!this.visible){const t=this.result(0,i,s,n,o,r,!1);return this.updateResults.record({kind:"tick",count:0},[]),t}const a=Math.max(0,Math.min(t,this.config.maxDeltaSeconds))*this.config.timeScale;this.elapsedSeconds+=a,this.spawnDue(i,r);const d=this.observeBodyBudget(r),h=this.evictOverflow(r);s.push(...h.evicted),n.push(...h.sedimented),this.syncSimulationState(r),this.accumulator+=a;let c=0;for(;this.accumulator>=this.config.fixedDt&&this.config.maxSubsteps>c;){this.world.step(this.config.fixedDt);const t=this.world.events();o.push(...t),this.observeKernelEvents(t,r),this.observeSensorTransitions(r),this.accumulator-=this.config.fixedDt,c+=1}c===this.config.maxSubsteps&&(this.accumulator=Math.min(this.accumulator,this.config.fixedDt)),this.quiescence.refresh(this.world,a,i.length),(c>0||i.length>0||s.length>0||n.length>0||o.length>0)&&(this.revision+=1);const l=this.result(c,i,s,n,o,r,void 0,d);return this.updateResults.record({kind:"tick",count:c},this.revision!==e?i.length||s.length||n.length?st:nt:[]),l}settle(t=this.config.settleStepLimit){const e=this.revision;this.spawnDue([],[]);const i=this.world.settle(t,this.config.fixedDt);return i>0&&(this.revision+=1),this.syncSimulationState(),this.updateResults.record({kind:"settle",count:i},this.revision!==e?nt:[]),i}settleWithObservations(t=this.config.settleStepLimit){const e=this.revision,i=[],s=[],n=[],o=[],r=[];if(this.paused||!this.visible){const t=this.result(0,i,s,n,o,r,!1);return this.updateResults.record({kind:"settle",count:0},[]),t}this.spawnDue(i,r);const a=this.observeBodyBudget(r),d=this.evictOverflow(r);s.push(...d.evicted),n.push(...d.sedimented),this.syncSimulationState(r);let h=0;for(i.length>0&&this.quiescence.reset();t>h&&!this.atRest();){this.world.step(this.config.fixedDt);const t=this.world.events();o.push(...t),this.observeKernelEvents(t,r),this.observeSensorTransitions(r),h+=1,this.quiescence.refresh(this.world,this.config.fixedDt,0)}(h>0||i.length>0||s.length>0||n.length>0||o.length>0)&&(this.revision+=1);const c=this.result(h,i,s,n,o,r,void 0,a);return this.updateResults.record({kind:"settle",count:h},this.revision!==e?i.length||s.length||n.length?st:nt:[]),c}readBodies(t=[]){return this.world.readState(t)}readSediment(){return this.sediment.snapshot()}bodyBudgetStatus(){return this.evaluateBodyBudget()}sedimentTotals(){return this.sediment.totals()}sedimentHeightfield(t={}){return E(this.readSediment(),t)}hitTest(t,e,i=0){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,t,e,i)}events(){return this.world.events()}allSleeping(){return this.world.allSleeping()}atRest(){return this.world.allSleeping()||this.quiescence.isAtRest()}hasPendingWork(){return this.queue.length>0||!this.atRest()}queueSize(){return this.queue.length}liveBodyCount(){return this.liveBodyOrder.length}elapsed(){return this.elapsedSeconds}recordObservation(t){const{timestamp:e,chartType:i,chartId:s,...n}=t,o={...n,timestamp:e??this.elapsedSeconds,chartType:i??this.observation.chartType,chartId:s??this.observation.chartId};return this.emitObservation(o),this.updateResults.record({kind:"update",count:1},["evidence"]),o}getLastUpdateResult(){return this.updateResults.last}getUpdateSnapshot(){return this.updateResults.last}subscribeUpdateResult(t){return this.updateResults.subscribe(t)}version(){return this.revision}setPaused(t){const e=this.paused!==t;this.paused=t,this.syncSimulationState(),this.updateResults.record({kind:"pause"},e?ot:[])}setVisible(t){const e=this.visible!==t;this.visible=t,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},e?ot:[])}remove(t){const e=new Set(t),i=new Set(this.liveBodyOrder),s=new Set(this.queue.map(t=>t.id));this.queue=this.queue.filter(t=>!e.has(t.id)),this.liveBodyOrder=this.liveBodyOrder.filter(t=>!e.has(t)),this.world.remove(t),this.removeActiveSensorPairsForBodies(e);const n=t.filter(t=>i.has(t)||s.has(t));return n.length>0&&(this.revision+=1,this.syncSimulationState()),this.updateResults.record({kind:"remove",keys:n,count:n.length},n.length?st:[]),n}setConstraint(t){const e=this.world.setConstraint(t);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},nt),e}removeConstraint(t){this.world.removeConstraint(t),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},nt)}applyImpulse(t,e,i){this.world.applyImpulse(t,e,i),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[t]},nt)}nextRandom(){return this.world.nextRandom()}controls(){return t=this,{applyImpulse:(e,i,s)=>t.applyImpulse(e,i,s),clear:()=>t.clear(),hitTest:(e,i,s)=>t.hitTest(e,i,s),pause:()=>t.setPaused(!0),push:(e,i)=>t.enqueue(e,i),pushMany:(e,i)=>t.enqueue(e,i),bodyBudgetStatus:()=>t.bodyBudgetStatus(),readBodies:e=>t.readBodies(e),readSediment:()=>t.readSediment(),recordObservation:e=>t.recordObservation(e),remove:e=>t.remove(e),restore:e=>t.restore(e),resume:()=>t.setPaused(!1),settle:e=>t.settle(e),settleWithObservations:e=>t.settleWithObservations(e),snapshot:()=>t.snapshot(),sedimentHeightfield:e=>t.sedimentHeightfield(e),sedimentTotals:()=>t.sedimentTotals(),step:e=>t.tick(e)};var t}snapshot(){const t=this.world.snapshot();return{accumulator:this.accumulator,activeSensorPairs:Array.from(this.activeSensorPairs).sort(),bodyBudget:G(this.bodyBudget),config:{...this.config,kernel:J(t.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(z),revision:this.revision,sediment:this.readSediment(),simulationState:this.simulationState,liveBodyOrder:this.liveBodyOrder.slice(),visible:this.visible,world:t}}restore(t){this.config={bodyLimit:t.config.bodyLimit,eviction:t.config.eviction,fixedDt:t.config.fixedDt,maxDeltaSeconds:t.config.maxDeltaSeconds,maxSubsteps:t.config.maxSubsteps,settleStepLimit:t.config.settleStepLimit,timeScale:t.config.timeScale},this.configInput={...t.config,bodyBudget:G(t.bodyBudget??{}),kernel:J(t.world.options)},this.bodyBudget=G(t.bodyBudget??{}),this.bodyBudgetObservationKey="ok",this.quiescence.setKernelOptions(t.world.options),this.quiescence.reset(),this.activeSensorPairs=new Set(t.activeSensorPairs),this.accumulator=t.accumulator,this.elapsedSeconds=t.elapsedSeconds,this.paused=t.paused,this.queue=t.queue.map(z).sort(U),this.revision=t.revision,this.sediment.restore(t.sediment??[]),this.simulationState=t.simulationState??yt(t.paused,t.visible,t.queue.length>0,t.world.bodies.every(t=>t.sleeping)),this.liveBodyOrder=t.liveBodyOrder.slice(),this.visible=t.visible,this.nextSequence=this.queue.reduce((t,e)=>Math.max(t,e.sequence),-1)+1,this.world.restore(t.world),this.updateResults.record({kind:"restore"},st)}spawnDue(t,e){for(;this.queue.length>0&&this.elapsedSeconds>=this.queue[0].spawnAt;){const i=this.queue.shift();if(!i)return;this.spawnOne(i,e),t.push(i.id)}}spawnOne(t,e){this.liveBodyOrder=this.liveBodyOrder.filter(e=>e!==t.id),this.removeActiveSensorPairsForBodies(new Set([t.id])),this.world.spawn(t),this.liveBodyOrder.push(t.id);for(const e of t.springs??[])this.world.setConstraint({...e,bodyId:t.id});const i=this.world.readState().find(e=>e.id===t.id);this.emitObservation({type:"physics-spawn",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:t.id,datum:i?.datum??t.datum,x:i?.x??t.x,y:i?.y??t.y},e)}result(t,e,i,s,n,o,r,a=this.evaluateBodyBudget()){this.syncSimulationState(o);const d=this.world.allSleeping();return{budget:a,elapsedSeconds:this.elapsedSeconds,evicted:i,events:n,observations:o,queueSize:this.queue.length,revision:this.revision,shouldContinue:r??(this.queue.length>0||!this.atRest()),sleeping:d,sedimented:s,spawned:e,steps:t}}observeKernelEvents(t,e){!function(t,e,i){if(0===e.length)return;const s=new Map(t.readState().map(t=>[t.id,t]));for(const t of e){if("sleep"!==t.type)continue;const e=s.get(t.bodyId);i.emit({type:"physics-settle",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:t.bodyId,datum:e?.datum,x:e?.x,y:e?.y})}}(this.world,t,this.observationContext(e))}observeSensorTransitions(t){this.activeSensorPairs=function(t,e,i){const s=new Set(t.activeSensorPairs().map(t=>`${t.sensorId}\0${t.bodyId}`));if(0===s.size&&0===e.size)return s;const n=new Map(t.readState().map(t=>[t.id,t])),o=(t,e)=>{const{sensorId:s,bodyId:o}=Z(e),r=i.observation.sensors[s],a=n.get(o);i.emit({type:"enter"===t?r?.enterType??"physics-bin-enter":r?.exitType??"physics-bin-exit",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:o,datum:a?.datum,x:a?.x,y:a?.y,sensorId:s,binId:r?.binId??s})};for(const t of Array.from(s).sort())e.has(t)||o("enter",t);for(const t of Array.from(e).sort())s.has(t)||o("exit",t);return s}(this.world,this.activeSensorPairs,this.observationContext(t))}removeActiveSensorPairsForBodies(t){!function(t,e){for(const i of t)e.has(Z(i).bodyId)&&t.delete(i)}(this.activeSensorPairs,t)}observationContext(t){return{elapsedSeconds:this.elapsedSeconds,observation:this.observation,emit:e=>this.emitObservation(e,t)}}emitObservation(t,e){e?.push(t),this.observation.onObservation?.(t)}evaluateBodyBudget(){return L({bodyLimit:this.config.bodyLimit,engineMaxBodiesHint:this.world.capabilities.maxBodiesHint,evictionEnabled:!1!==this.config.eviction,liveBodies:this.liveBodyOrder.length,queuedBodies:this.queue.length,sedimentEnabled:this.sediment.isEnabled(),options:this.bodyBudget})}observeBodyBudget(t){const e=this.evaluateBodyBudget();if("ok"===e.state||!1===this.bodyBudget)return this.bodyBudgetObservationKey="ok",e;const i=`${e.state}:${e.action}`;return i===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=i,this.emitObservation({type:"overflow"===e.state?"physics-budget-overflow":"physics-budget-warning",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,budgetAction:e.action,bodyLimit:e.bodyLimit,engineMaxBodiesHint:e.engineMaxBodiesHint,liveBodies:e.liveBodies,overflow:e.overflow,projectedBodies:e.projectedBodies,queuedBodies:e.queuedBodies,warnAt:e.warnAt},t)),e}syncSimulationState(t){const e=yt(this.paused,this.visible,this.queue.length>0,this.atRest());if(e===this.simulationState)return;const i=this.simulationState;this.simulationState=e,function(t,e,i){i.observation.onSimulationStateChange?.(e,t),"running"!==e&&"settled"!==e||i.emit({type:"running"===e?"sim-active":"sim-idle",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,simulationState:e,previousSimulationState:t})}(i,e,this.observationContext(t))}evictOverflow(t){const{evicted:e,sedimented:i,liveBodyOrder:s}=function(t,e,i,s,n,o){const r={evicted:[],sedimented:[],liveBodyOrder:n};if(!1===i)return r;const a=Math.max(0,Math.floor(s));if(!Number.isFinite(a))return r;const d=n.length-a;if(0>=d)return r;const h=function(t,e,i){if("sleeping-first"!==e)return i.slice();const s=new Map(t.readState().map(t=>[t.id,t.sleeping])),n=[],o=[];for(const t of i)s.get(t)?n.push(t):o.push(t);return[...n,...o]}(t,i,n),c=h.slice(0,d);if(0===c.length)return r;const l=function(t,e,i,s){const n=new Map(t.readState().map(t=>[t.id,t])),o=[];for(const t of i){const i=n.get(t);if(!i)continue;const r=e.add(i);r&&(o.push(t),s.emit({type:"physics-sediment",timestamp:s.elapsedSeconds,chartType:s.observation.chartType,chartId:s.observation.chartId,bodyId:t,datum:i.datum,x:i.x,y:i.y,binId:r.id,count:r.count,total:r.total}))}return o}(t,e,c,o);t.remove(c);const u=new Set(c);return{evicted:c,sedimented:l,liveBodyOrder:n.filter(t=>!u.has(t))}}(this.world,this.sediment,this.config.eviction,this.config.bodyLimit,this.liveBodyOrder,this.observationContext(t));return e.length>0&&(this.liveBodyOrder=s,this.removeActiveSensorPairsForBodies(new Set(e))),{evicted:e,sedimented:i}}};function bt(t,e){if("region-enter"!==e.type)return t;const i=e.region.id,s=t[i]??{id:i,label:e.region.label??i,count:0,bodyIds:[]};if(s.bodyIds.includes(e.bodyId))return t;const n=[...s.bodyIds,e.bodyId];return{...t,[i]:{...s,count:n.length,bodyIds:n}}}function gt(t,e){return(e??Object.keys(t)).map(e=>t[e]).filter(t=>null!=t).map(t=>({label:t.label??t.id,value:t.count}))}function xt(t,e){const i=e instanceof Set?e:new Set(e);return t.map(t=>{const e=t.bodyIds??[],s=e.filter(t=>!i.has(t)),n=e.length-s.length,o=t.completion?.mode??"allMembersAbsorbed",r=t.completion?.valueByBodyId,a=t=>{const e=r?.[t];return Number.isFinite(e)&&Number(e)>=0?Number(e):1},d=e.reduce((t,e)=>t+a(e),0),h=e.reduce((t,e)=>t+(i.has(e)?a(e):0),0),c=t.completion?.threshold,l="threshold"===o?Number.isFinite(c)&&Number(c)>=0?Number(c):d:void 0;return{id:t.id,label:t.label??t.id,mode:o,complete:e.length>0&&("anyAbsorbed"===o?n>0:"threshold"===o?h>=(l??d):0===s.length),absorbed:n,total:e.length,absorbedValue:h,totalValue:d,threshold:l,missing:s}})}function St(t,e,i){return Math.max(e,Math.min(i,t))}function wt(t,e,i={}){const s=i.random??Math.random,n=t.stages.find(t=>t.id===e)??t.stages[t.stages.length-1],o=St(i.along??.5,.05,.95),r=i.jitterX??0,a=i.padY??20,d=n.x0+(n.x1-n.x0)*o+(2*s()-1)*r,h=Math.min(1,n.width/2),c=St(d,n.x0+h,n.x1-h),l=t.boundaryY(c,"top")+a,u=t.boundaryY(c,"bottom")-a;return{x:c,y:u>l?l+s()*Math.max(1,u-l):t.midY}}function It(t){return"bowtie"===t.shape?[{id:"incoming",role:"incoming",points:[[t.left,t.topY],[t.centerLeft,t.pinchTop],[t.centerLeft,t.pinchBottom],[t.left,t.bottomY]]},{id:"center",role:"center",points:[[t.centerLeft,t.pinchTop],[t.centerRight,t.pinchTop],[t.centerRight,t.pinchBottom],[t.centerLeft,t.pinchBottom]]},{id:"outgoing",role:"outgoing",points:[[t.centerRight,t.pinchTop],[t.right,t.topY],[t.right,t.bottomY],[t.centerRight,t.pinchBottom]]}]:[{id:"volume",role:"volume",points:[[t.left,t.topY],[t.right,"funnel"===t.shape?t.pinchTop:t.topY],[t.right,"funnel"===t.shape?t.pinchBottom:t.bottomY],[t.left,t.bottomY]]}]}function Mt(t,e,i){return Math.max(e,Math.min(i,t))}function Bt(t,e,i,s,n,o={}){return{id:t,friction:o.friction,restitution:o.restitution,bodyFilter:o.bodyFilter,shape:{type:"segment",x1:e,y1:i,x2:s,y2:n,thickness:o.thickness??8}}}function kt(t){const e=t.shape??"lane",i=Math.max(1,Math.round(t.width)),s=Math.max(1,Math.round(t.height)),n=t.padX??46,o=t.padY??72,r=n,a=i-n,d=o,h=s-Math.max(24,Math.round(.45*o)),c=(d+h)/2,l=Math.max(1,h-d),u=Mt(t.pinchRatio??.18,.06,.5),p=Number(t.pinchHeightOffset??0),m=Number.isFinite(p)?p:0,y=Mt(l*u+m,.06*l,.5*l),f=y/2,v=c-f,b=c+f,g=t.idPrefix??"process",x=t.friction??.58,S=t.restitution??.18,w=t.wallThickness??8,I=t.stages;if(!I.length)throw Error("processStageLayout requires at least one stage");const M=Mt(t.centerStageIndex??Math.floor(I.length/2),0,I.length-1),B=function(t){const e=t.reduce((t,e)=>t+(e.share??1),0);return e>0?e:t.length}(I),k=a-r;let O=r;const q=I.map((t,e)=>{const i=O,s=e===I.length-1?a:O+(t.share??1)/B*k;return O=s,{id:t.id,label:t.label,description:t.description,kind:t.kind??"stage",index:e,x0:i,x1:s,x:(i+s)/2,width:s-i,y:c,height:l}}),C=q[M],T=C.x0,R=C.x1,D=(t,i)=>{if("lane"===e)return"top"===i?d:h;if("funnel"===e){const e=Mt((t-r)/Math.max(1,a-r),0,1);return"top"===i?d+(v-d)*e:h+(b-h)*e}if(T>=t){const e=Mt((t-r)/Math.max(1,T-r),0,1);return"top"===i?d+(v-d)*e:h+(b-h)*e}if(R>=t)return"top"===i?v:b;const s=Mt((t-R)/Math.max(1,a-R),0,1);return"top"===i?v+(d-v)*s:b+(h-b)*s},A=q.map(t=>{const e=Math.min(D(t.x0,"top"),D(t.x1,"top")),i=Math.max(D(t.x0,"bottom"),D(t.x1,"bottom"));return{...t,y:(e+i)/2,height:Math.max(1,i-e)}}),Y={thickness:w,friction:x,restitution:S},F=[];"lane"===e?F.push(Bt(g+"-top",r,d,a,d,Y),Bt(g+"-bottom",r,h,a,h,Y),Bt(g+"-left",r,d,r,h,{...Y,thickness:Math.max(6,w-2)}),Bt(g+"-right",a,d,a,h,{...Y,thickness:Math.max(6,w)})):"funnel"===e?F.push(Bt(g+"-top",r,d,a,v,Y),Bt(g+"-bottom",r,h,a,b,Y),Bt(g+"-left",r,d,r,h,{...Y,thickness:Math.max(6,w-2)}),Bt(g+"-right",a,v,a,b,{...Y,thickness:Math.max(6,w)})):F.push(Bt(g+"-left-top",r,d,T,v,Y),Bt(g+"-left-bottom",r,h,T,b,Y),Bt(g+"-center-top",T,v,R,v,Y),Bt(g+"-center-bottom",T,b,R,b,Y),Bt(g+"-right-top",R,v,a,d,Y),Bt(g+"-right-bottom",R,b,a,h,Y),Bt(g+"-left",r,d,r,h,{...Y,thickness:Math.max(6,w-2)}),Bt(g+"-right",a,d,a,h,{...Y,thickness:Math.max(6,w)}));const E=t.membraneDampingScale??.5,P=r,L=Math.max(1,("bowtie"===e?T:a)-P),X=(t.membranes??[]).map(t=>{const e=P+Mt(t.offset,0,1)*L,i=t.width??18+18*t.cost,s=l-16,n=c+.25*(t.wobble??0);return{...t,x:e,y:n,width:i,height:s}}),N=!1===t.includeMembraneRegions?[]:X.map(t=>Ct({id:t.id,label:t.label??t.id,description:t.description??(t.label??t.id)+" is a permeable region. It taxes energy and damps velocity while bodies overlap it.",x:t.x,y:t.y,width:t.width,height:t.height,cost:t.cost,dampingScale:t.dampingScale??E,bodyStyle:t.bodyStyle,metadata:t.metadata,semanticItem:t.semanticItem,color:t.color}));return{shape:e,width:i,height:s,padX:n,padY:o,left:r,right:a,topY:d,bottomY:h,midY:c,centerLeft:T,centerRight:R,pinchHeight:y,pinchTop:v,pinchBottom:b,stages:A,membranes:X,colliders:F,regionEffects:N,boundaryY:D}}function Ot(t){return{id:t.id,label:t.label,description:t.description,kind:t.kind,shape:(e=t.x,i=t.y,s=t.width,n=t.height,{type:"aabb",x:e,y:i,width:s,height:n}),bodyFilter:t.bodyFilter,collider:t.collider,colliderThickness:t.colliderThickness,friction:t.friction,restitution:t.restitution,semanticItem:t.semanticItem,metadata:t.metadata,bodyStyle:t.bodyStyle,attributes:t.attributes,onEnter:t.onEnter,onExit:t.onExit};var e,i,s,n}function qt(t,e={}){const i=e.idPrefix??"stage",s=Math.max(0,e.insetX??0),n=Math.max(0,e.insetY??1);return t.stages.map(t=>{const o="function"==typeof e.metadata?e.metadata(t):e.metadata??{};return{...Ot({id:i?`${i}:${t.id}`:t.id,label:t.label??t.id,description:t.description,kind:"region",x:t.x,y:t.y,width:Math.max(1,t.width-2*s),height:Math.max(1,t.height-2*n),bodyFilter:e.bodyFilter,semanticItem:e.semanticItem,attributes:{primitive:"processStage",stageId:t.id,stageIndex:t.index},metadata:{...o,primitive:"processStage",stageId:t.id,stageIndex:t.index}})}})}function Ct(t){const e=t.dampingScale??.5,i=t.energyScale??1,s=Mt(t.cost,0,2);return{...Ot({...t,kind:t.kind??"membrane",attributes:{primitive:"membrane",membraneCost:s,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),damping:s*e,energyDelta:-s*i}}function Tt(t){return{...Ot({...t,kind:t.kind??"charge-gate",attributes:{primitive:"chargeGate",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),charge:t.charge??!0,energyDelta:t.energyDelta,impulseOnEnter:t.impulseOnEnter}}function Rt(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force??{x:12,y:0};return{...Ot({...t,kind:t.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping??.015}}function Dt(t){const e=t.pressure??t.occupancy??0,i=t.baseDamping??.08,s=t.dampingPerUnit??.12,n=t.energyPerUnit??0;return{...Ot({...t,kind:t.kind??"membrane",attributes:{primitive:"pressureField",pressure:e,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),damping:i+e*s,energyDelta:n?-e*n:void 0,force:t.force}}function At(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force;return{...Ot({...t,kind:t.kind??"force-field",attributes:{primitive:"capacitatedSensor",capacity:t.capacity,unitsPerSecond:t.unitsPerSecond??t.capacity,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping,charge:t.charge??t.capacity}}function Yt(t){return{...Ot({...t,kind:t.kind??"force-field",attributes:{primitive:"portal",targetStage:t.targetStage,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:t.force,impulseOnEnter:t.impulseOnEnter,damping:t.damping??.08}}function Ft(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force??{x:24,y:0};return{...Ot({...t,kind:t.kind??"sink",attributes:{primitive:"absorb",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping??.02,charge:t.charge??"absorbed"}}function Et(t){return{...Ot({...t,kind:t.kind??"force-field",attributes:{primitive:"forceField",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:t.force,damping:t.damping,energyDelta:t.energyDelta}}function Pt(t){const e=t.x??t.anchor?.x??0,i=t.y??t.anchor?.y??0;return{id:t.id,label:t.label,description:t.description,group:t.group,bodyIds:t.bodyIds,datum:t.datum,state:t.state,x:e,y:i,width:t.width,height:t.height,anchor:t.anchor??{x:e,y:i},completion:t.completion,tether:t.tether,semanticItem:t.semanticItem}}function Lt(t){const e=t.idPrefix??"lane",i={thickness:t.thickness??8,friction:t.friction??.5,restitution:t.restitution??.16},s=[Bt(e+"-top",t.left,t.top,t.right,t.top,i),Bt(e+"-bottom",t.left,t.bottom,t.right,t.bottom,i)];return t.openEnds||s.push(Bt(e+"-left",t.left,t.top,t.left,t.bottom,i),Bt(e+"-right",t.right,t.top,t.right,t.bottom,i)),s}export{M as BuiltInPhysicsEngineAdapter,B as createDefaultPhysicsEngineAdapter,F as PhysicsSedimentAccumulator,E as sedimentHeightfield,L as evaluatePhysicsBodyBudget,H as schedulePhysicsSpawns,_ as collidersFromPlotBounds,tt as collidersFromXScaleBins,vt as PhysicsPipelineStore,bt as aggregateRegionCounts,gt as regionCountsToProjectionRows,xt as groupCompletionRows,wt as stageTargetInVolume,It as processVolumePolygons,kt as processStageLayout,qt as processStageRegions,Ct as membraneRegion,Tt as chargeGateRegion,Rt as routeSurfaceRegion,Dt as pressureFieldRegion,At as capacitatedRegion,Yt as portalRegion,Ft as absorbRegion,Et as forceFieldRegion,Pt as bodyGroupSpec,Lt as processLaneWalls};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{buildNavGraph as t,extractGeoNavPoints as e,extractOrdinalNavPoints as r,extractXYNavPoints as n,navPointToHover as i,nextGraphIndex as s,nextIndex as o,renderCirclePulse as c,resolvePosition as u}from"./chunk-chunk-WYARAXHR.module.min.js";import{emitClickObservations as a,emitHoverObservations as l,isInteractiveKeyboardTarget as f,resolveCanvasFill as h}from"./chunk-chunk-PX5YQGDP.module.min.js";var p=class{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const r of t){const t=this.push(r);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;return{next:()=>this._size>t?{done:!1,value:this.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++)t(this.buffer[(e+r)%this._capacity],r)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++)t[r]=this.buffer[(e+r)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray();let r=0,n=[];e.length>t&&(r=e.length-t,n=e.slice(0,r)),this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(let t=r;e.length>t;t++)this.push(e[t]);return n}update(t,e){const r=[],n=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++){const s=(n+i)%this._capacity,o=this.buffer[s];if(t(o)){let t;t="object"!=typeof o||null===o?o:Array.isArray(o)?[...o]:{...o},r.push(t),this.buffer[s]=e(o)}}return r}remove(t){const e=[],r=[];if(this.forEach(n=>{t(n)?r.push(n):e.push(n)}),0===r.length)return r;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return r}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}};function y(t,e,r,n){return"function"==typeof e.style?e.style(n||{},r):e.style&&"object"==typeof e.style?e.style:t.resolveBoundsStyle(r,n)}function d(t,e,r,n){if(!t.scales)return null;const i=[],s=[];for(const r of e){const e=t.getX(r);if(!Number.isFinite(e))continue;const o=n.getTop(r),c=n.getBottom(r);if(!Number.isFinite(o)||!Number.isFinite(c))continue;const u=t.scales.x(e),a=t.scales.y(o),l=t.scales.y(c);Number.isFinite(u)&&Number.isFinite(a)&&Number.isFinite(l)&&(i.push([u,a]),s.push([u,l]))}return 2>i.length?null:{type:"area",topPath:i,bottomPath:s,...t.config.curve&&"linear"!==t.config.curve&&{curve:t.config.curve},style:y(t,n,r,e[0]),datum:e,group:r,interactive:n.interactive}}function v(t){const e=[],r=[];if(!t)return{perSeries:e,aggregate:r};for(const n of t)n.perSeries?e.push(n):r.push(n);return{perSeries:e,aggregate:r}}function _(t,e,r){const n=[];for(const i of r){const r=d(t,e,"__ribbon_aggregate",i);r&&n.push(r)}return n}function g(t,e,r,n){const i=[];for(const s of n){const n=d(t,e,r,s);n&&i.push(n)}return i}function m(t,e){if(!t)return{};if(!e||0===e.length)return t;const r=[];for(const n of e){if("band"!==n.kind)continue;const e=n.getTop(t),i=n.getBottom(t);Number.isFinite(i)&&Number.isFinite(e)&&r.push({y0:i,y1:e})}return 0===r.length?t:{...t,band:r[0],bands:r}}function b(t,e,r,n){const i=n.current,s=!0===t.lastCustomLayoutFailure?.preservedLastGoodScene,o=!s&&t.hasActivePulsesAt(e),c=!(r||s||!o&&!i)&&t.refreshPulse(e);return n.current=o,{changed:c,pending:o}}import{useCallback as k,useRef as z}from"react";function A(t,e,r,n){const i=z({accessor:e,onChange:r,readData:n}),s=z([]);return i.current={accessor:e,onChange:r,readData:n},k(()=>{const{accessor:e,onChange:r,readData:n}=i.current;if(!r||!e)return;const o=function(t,e){if(!e)return[];const r=new Set,n=[];for(const i of t){if(!i||"object"!=typeof i)continue;const t="function"==typeof e?e(i):i[e];if(null==t)continue;const s=t+"";r.has(s)||(r.add(s),n.push(s))}return n}(t.current?n(t.current):[],e);(function(t,e){if(t.length!==e.length)return!1;for(let r=0;t.length>r;r++)if(t[r]!==e[r])return!1;return!0})(o,s.current)||(s.current=o,r(o))},[t])}var R=(t,e,r,n)=>{const i=e.filter(t=>"point"===t.type);if(0!==i.length){t.save();try{const e=t.globalAlpha;for(const r of i)t.beginPath(),t.arc(r.x,r.y,r.r,0,2*Math.PI),t.globalAlpha=e*(r.style.opacity??r.style.fillOpacity??1),t.fillStyle=h(t,r.style.fill,"#4e79a7"),t.fill(),r.style.stroke&&"none"!==r.style.stroke&&(t.strokeStyle=h(t,r.style.stroke,r.style.stroke),t.lineWidth=r.style.strokeWidth||1,t.stroke()),c(t,r)}finally{t.restore()}}};import{useCallback as w}from"react";function x({customHoverBehavior:t,customClickBehavior:e,onObservation:r,chartId:n,chartType:i}){return{customHoverBehavior:w((e,s)=>{t?.(e,s),l({onObservation:r,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:i,chartId:n,context:s})},[n,i,t,r]),customClickBehavior:w((t,s)=>{e?.(t,s),a({onObservation:r,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:i,chartId:n,context:s})},[n,i,e,r]),hasClickBehavior:!(!e&&!r)}}import{useCallback as P,useRef as D}from"react";function C({storeRef:e,hoverRef:r,hoveredNodeRef:n,setHoverPoint:i,customHoverBehavior:o,customClickBehavior:c,scheduleRender:a,extractPoints:l,toHover:h}){const p=D(-1),y=D(null),d=D(null),v=P(v=>{if(f(v))return;const _=e.current;if(!_)return;const g=()=>{p.current=-1,y.current=null,r.current=null,n&&(n.current=null),i(null),o(null),a()};if(0===_.scene.length)return void(0>p.current||g());let m;if(d.current?.version===_.version)m=d.current.graph;else{const e=l(_.scene);if(0===e.length)return void(0>p.current||g());m=t(e),d.current={version:_.version,graph:m}}let b=p.current;if(m.flat.length>b||(g(),b=-1),("Enter"===v.key||" "===v.key)&&b>=0)return v.preventDefault(),void c(h(m.flat[b],_),{type:"activate",inputType:"keyboard"});if(0>b){if("Escape"===v.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(v.key))return;v.preventDefault(),p.current=0;const t=m.flat[0];y.current=t;const e=h(t,_);return r.current=e,i(e),o(e,{type:"focus",inputType:"keyboard"}),void a()}const k=s(v.key,u(m,b),m);if(null===k)return;if(v.preventDefault(),0>k)return void g();p.current=k;const z=m.flat[k];y.current=z;const A=h(z,_);r.current=A,i(A),o(A,{type:"focus",inputType:"keyboard"}),a()},[c,o,l,r,n,a,i,e,h]);return{kbFocusIndexRef:p,focusedNavPointRef:y,onKeyDown:v}}function B(t){return C({...t,extractPoints:n,toHover:(t,e)=>i({...t,datum:m(t.datum,e.resolvedRibbons)})})}function H({chartType:t,oAccessor:e,rAccessor:n,...s}){return C({...s,extractPoints:r,toHover:r=>({...i(r),__oAccessor:"string"==typeof e?e:void 0,__rAccessor:"string"==typeof n?n:void 0,__chartType:t})})}function N(t){const e=t.datum;return{...e||{},...e?.properties||{},data:e,properties:e?.properties,x:t.x,y:t.y,__semioticHoverData:!0}}function T({storeRef:t,hoverRef:r,hoveredNodeRef:n,setHoverPoint:i,customHoverBehavior:s,customClickBehavior:c,scheduleRender:u}){const a=D(-1),l=D(null),h=P(h=>{if(f(h))return;const p=t.current;if(!p)return;const y=()=>{a.current=-1,l.current=null,r.current=null,n&&(n.current=null),i(null),s(null),u()};if(0===p.scene.length)return void(0>a.current||y());const d=e(p.scene);if(0===d.length)return void(0>a.current||y());let v=a.current;if(d.length>v||(y(),v=-1),("Enter"===h.key||" "===h.key)&&v>=0)return h.preventDefault(),void c(N(d[v]),{type:"activate",inputType:"keyboard"});const _=o(h.key,0>v?-1:v,d.length);if(null===_)return;if(h.preventDefault(),0>_)return void y();const g=0>v?0:_;a.current=g;const m=d[g];l.current=m;const b=N(m);r.current=b,i(b),s(b,{type:"focus",inputType:"keyboard"}),u()},[c,s,r,n,u,i,t]);return{kbFocusIndexRef:a,focusedNavPointRef:l,onKeyDown:h}}function F(t,e,r){const n=t.duration??500,i=r-e;return n>i?1-i/n:0}function E(t,e,r,n,i,s=("undefined"!=typeof performance?performance.now():Date.now())){const o=t.color??"rgba(255,255,255,0.6)",c=t.glowRadius??4;let u=!1;const a=i??(()=>{const t=new Map;for(let e=0;r.length>e;e++)t.set(r[e],e);return t})();for(const r of e){if("line"===r.type)continue;if("area"===r.type){const e=Array.isArray(r.datum)?r.datum:[r.datum];let i=0,c=!1;for(const r of e){const e=a.get(r);if(null==e)continue;c=!0;const o=n.get(e);if(null==o)continue;const u=F(t,o,s);u>i&&(i=u)}c&&(u=I(r,i,o)||u);continue}const e=a.get(r.datum);if(null==e)continue;const i=n.get(e);u=I(r,null==i?0:F(t,i,s),o,c)||u}return u}function I(t,e,r,n){let i=!1;return e>0?(t._pulseIntensity!==e&&(t._pulseIntensity=e,i=!0),t._pulseColor!==r&&(t._pulseColor=r,i=!0),t._pulseGlowRadius!==n&&(t._pulseGlowRadius=n,i=!0),i):(0!==t._pulseIntensity&&(t._pulseIntensity=0,i=!0),void 0!==t._pulseColor&&(t._pulseColor=void 0,i=!0),void 0!==t._pulseGlowRadius&&(t._pulseGlowRadius=void 0,i=!0),i)}function S(t,e,r=("undefined"!=typeof performance?performance.now():Date.now())){if(!e||0===e.size)return!1;const n=t.duration??500,i=e.peek();return null!=i&&n>r-i}function G(t,e,r){e>t.capacity&&(t.resize(e),r&&e>r.capacity&&r.resize(e))}function j(t,e){const r=new p(t.capacity);return t.forEach(()=>r.push(e)),r}function O(t,e,r,n){const i=t.push(e);return r&&r.push(n),i}function L(t,e,r){if(!e||0===e.size)return;const n=new Set;if(t.forEach((t,e)=>{r(t)&&n.add(e)}),0===n.size)return;const i=e.toArray();e.clear();for(let t=0;i.length>t;t++)n.has(t)||e.push(i[t])}export{p as RingBuffer,F as computePulseIntensity,E as applyPulse,I as setPulseState,S as hasActivePulses,v as partitionRibbons,_ as buildAggregateRibbons,g as buildPerSeriesRibbons,m as enrichDatumWithBand,G as ensureRingBufferCapacity,j as createTimestampBufferForData,O as pushWithTimestamp,L as compactTimestampBufferForRemoval,b as refreshIdlePulse,A as useLegendCategoryEmission,R as pointCanvasRenderer,x as useSemanticFrameInteractions,B as useXYKeyboardNavigation,H as useOrdinalKeyboardNavigation,T as useGeoKeyboardNavigation};