semiotic 3.8.6 → 3.8.7

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 (213) hide show
  1. package/CLAUDE.md +33 -7
  2. package/README.md +82 -55
  3. package/ai/behaviorContracts.cjs +86 -1
  4. package/ai/componentMetadata.cjs +4 -9
  5. package/ai/dist/mcp-server.js +97 -10
  6. package/ai/examples.md +154 -7
  7. package/ai/schema.json +1611 -145
  8. package/ai/surface-manifest.json +12 -10
  9. package/ai/system-prompt.md +9 -3
  10. package/dist/{chunk-chartContainerDataAudit-FEOD5GTQ.module.min.js → chunk-chartContainerDataAudit-JDSVSKGM.module.min.js} +1 -1
  11. package/dist/chunk-chunk-2YAZHXL4.module.min.js +2 -0
  12. package/dist/{chunk-chunk-G7WFWHAD.module.min.js → chunk-chunk-4ITOQRXM.module.min.js} +1 -1
  13. package/dist/chunk-chunk-5SD6BHVW.module.min.js +2 -0
  14. package/dist/chunk-chunk-6V5VQVCT.module.min.js +2 -0
  15. package/dist/chunk-chunk-7TTBHSAG.module.min.js +2 -0
  16. package/dist/chunk-chunk-7ZDJSYKI.module.min.js +2 -0
  17. package/dist/chunk-chunk-BGHPD3RA.module.min.js +1 -0
  18. package/dist/chunk-chunk-BMRZ2SPU.module.min.js +2 -0
  19. package/dist/chunk-chunk-BNGBEY7N.module.min.js +2 -0
  20. package/dist/chunk-chunk-C7APLVQD.module.min.js +2 -0
  21. package/dist/chunk-chunk-DGWFBOGB.module.min.js +1 -0
  22. package/dist/{chunk-chunk-Q2BS46W2.module.min.js → chunk-chunk-DIVE2DRA.module.min.js} +1 -1
  23. package/dist/chunk-chunk-FBUNUIPV.module.min.js +2 -0
  24. package/dist/chunk-chunk-FQPKOAIH.module.min.js +2 -0
  25. package/dist/chunk-chunk-FRO4TRXK.module.min.js +2 -0
  26. package/dist/chunk-chunk-G7QVPZUD.module.min.js +2 -0
  27. package/dist/chunk-chunk-GBPYV4FP.module.min.js +2 -0
  28. package/dist/chunk-chunk-GU2EJIDJ.module.min.js +2 -0
  29. package/dist/chunk-chunk-J5QD4RAM.module.min.js +2 -0
  30. package/dist/{chunk-chunk-RA7JCG7D.module.min.js → chunk-chunk-JWXLNZSM.module.min.js} +1 -1
  31. package/dist/chunk-chunk-KXAFCCDB.module.min.js +2 -0
  32. package/dist/chunk-chunk-LG7YKJAK.module.min.js +2 -0
  33. package/dist/{chunk-chunk-XP3OHHFX.module.min.js → chunk-chunk-LVHDZAT3.module.min.js} +1 -1
  34. package/dist/chunk-chunk-LWITSR2O.module.min.js +2 -0
  35. package/dist/{chunk-chunk-SMVD3EQJ.module.min.js → chunk-chunk-MX35T6RX.module.min.js} +1 -1
  36. package/dist/chunk-chunk-NH4MEAKP.module.min.js +2 -0
  37. package/dist/chunk-chunk-NJETWX42.module.min.js +2 -0
  38. package/dist/chunk-chunk-NW25WGLS.module.min.js +2 -0
  39. package/dist/{chunk-chunk-GFTVACTO.module.min.js → chunk-chunk-OI7R7EJB.module.min.js} +1 -1
  40. package/dist/{chunk-chunk-OM6NWS4H.module.min.js → chunk-chunk-ONMLEXHR.module.min.js} +1 -1
  41. package/dist/chunk-chunk-OY66GCE6.module.min.js +1 -0
  42. package/dist/chunk-chunk-PZFT457G.module.min.js +1 -0
  43. package/dist/chunk-chunk-Q3WW6JGR.module.min.js +1 -0
  44. package/dist/chunk-chunk-Q6XKQTOQ.module.min.js +1 -0
  45. package/dist/chunk-chunk-RJRM2E6P.module.min.js +1 -0
  46. package/dist/chunk-chunk-RPL7WYXI.module.min.js +1 -0
  47. package/dist/chunk-chunk-SV4XAZ3Q.module.min.js +1 -0
  48. package/dist/chunk-chunk-TSCFL235.module.min.js +1 -0
  49. package/dist/chunk-chunk-UOQRPGPK.module.min.js +2 -0
  50. package/dist/chunk-chunk-V3OAKG32.module.min.js +1 -0
  51. package/dist/chunk-chunk-WLOIUMWG.module.min.js +2 -0
  52. package/dist/chunk-chunk-XEGXX4F7.module.min.js +1 -0
  53. package/dist/chunk-chunk-XFRBLXYM.module.min.js +1 -0
  54. package/dist/chunk-chunk-Z2AJERX5.module.min.js +2 -0
  55. package/dist/chunk-chunk-ZXYDYAB7.module.min.js +2 -0
  56. package/dist/components/ai/SemioticVACPBridge.d.ts +22 -0
  57. package/dist/components/ai/chartCapabilities.d.ts +4 -3
  58. package/dist/components/ai/conversationArc.d.ts +2 -176
  59. package/dist/components/ai/conversationArcTypes.d.ts +202 -0
  60. package/dist/components/ai/readerGrounding.d.ts +12 -0
  61. package/dist/components/ai/vacpAdapter.d.ts +13 -0
  62. package/dist/components/ai/vacpAdapterActions.d.ts +2 -0
  63. package/dist/components/ai/vacpAdapterModel.d.ts +7 -0
  64. package/dist/components/ai/vacpAdapterRuntime.d.ts +26 -0
  65. package/dist/components/ai/vacpAdapterState.d.ts +3 -0
  66. package/dist/components/ai/vacpAdapterTypes.d.ts +169 -0
  67. package/dist/components/ai/vacpTypes.d.ts +160 -0
  68. package/dist/components/charts/index.d.ts +4 -4
  69. package/dist/components/charts/physics/ChainReactionChart.capability.d.ts +9 -0
  70. package/dist/components/charts/physics/ChainReactionChart.d.ts +29 -0
  71. package/dist/components/charts/physics/CollisionSwarmChart.d.ts +1 -1
  72. package/dist/components/charts/physics/EventDropChart.d.ts +7 -2
  73. package/dist/components/charts/physics/GaltonBoardChart.d.ts +1 -1
  74. package/dist/components/charts/physics/{PhysicsPileChart.capability.d.ts → PacketFlowChart.capability.d.ts} +1 -1
  75. package/dist/components/charts/physics/{PhysicalFlowChart.d.ts → PacketFlowChart.d.ts} +22 -6
  76. package/dist/components/charts/physics/PhysicsCustomChart.d.ts +1 -1
  77. package/dist/components/charts/physics/ProcessFlowChart.d.ts +7 -4
  78. package/dist/components/charts/physics/{PhysicalFlowChart.capability.d.ts → UnitPileChart.capability.d.ts} +1 -1
  79. package/dist/components/charts/physics/{PhysicsPileChart.d.ts → UnitPileChart.d.ts} +19 -6
  80. package/dist/components/charts/physics/crucibleChartProps.d.ts +1 -1
  81. package/dist/components/charts/physics/crucibleChartUtils.d.ts +9 -0
  82. package/dist/components/charts/physics/gauntletChartProps.d.ts +6 -1
  83. package/dist/components/charts/physics/gauntletTerminal.d.ts +61 -0
  84. package/dist/components/charts/physics/packetFlowSemantics.d.ts +6 -0
  85. package/dist/components/charts/physics/physicsHocUtils.d.ts +45 -2
  86. package/dist/components/charts/shared/auditAccessibilityStyles.d.ts +9 -0
  87. package/dist/components/charts/shared/knownChartComponents.d.ts +1 -1
  88. package/dist/components/charts/shared/useChartLegend.d.ts +8 -1
  89. package/dist/components/charts/shared/useChartSetup.d.ts +7 -0
  90. package/dist/components/data/portability/capabilityBinding.d.ts +41 -0
  91. package/dist/components/data/portability/index.d.ts +2 -0
  92. package/dist/components/legendLayout.d.ts +56 -0
  93. package/dist/components/recipes/geographicDotGrid.d.ts +82 -0
  94. package/dist/components/recipes/geographicGrid.d.ts +100 -0
  95. package/dist/components/recipes/physics.d.ts +2 -0
  96. package/dist/components/recipes/physicsStageGeography.d.ts +137 -0
  97. package/dist/components/semiotic-ai.d.ts +4 -3
  98. package/dist/components/semiotic-experimental-vacp.d.ts +11 -0
  99. package/dist/components/semiotic-experimental.d.ts +6 -3
  100. package/dist/components/semiotic-geo.d.ts +4 -0
  101. package/dist/components/semiotic-physics.d.ts +9 -6
  102. package/dist/components/semiotic-recipes-core.d.ts +6 -1
  103. package/dist/components/server/renderEvidence.d.ts +1 -1
  104. package/dist/components/server/renderToStaticSVG.d.ts +2 -1
  105. package/dist/components/server/serverChartConfigHeatmap.d.ts +6 -0
  106. package/dist/components/server/serverChartConfigNetworkStyles.d.ts +12 -0
  107. package/dist/components/server/serverChartConfigShared.d.ts +16 -0
  108. package/dist/components/server/serverChartConfigs.d.ts +2 -2
  109. package/dist/components/server/serverChartConfigsPhysics.d.ts +2 -2
  110. package/dist/components/server/serverChartConfigsXY.d.ts +0 -1
  111. package/dist/components/server/staticLegend.d.ts +6 -0
  112. package/dist/components/server/staticSVGChrome.d.ts +10 -2
  113. package/dist/components/server/staticValue.d.ts +8 -0
  114. package/dist/components/stream/geoPipelineConfig.d.ts +10 -0
  115. package/dist/components/stream/legendRenderer.d.ts +8 -0
  116. package/dist/components/stream/physics/PhysicsEvidence.d.ts +37 -0
  117. package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +9 -0
  118. package/dist/components/stream/physics/PhysicsSettledScene.d.ts +5 -0
  119. package/dist/components/stream/physics/physicsFramePipelineConfig.d.ts +19 -0
  120. package/dist/components/stream/physics/physicsPipelineSettle.d.ts +52 -0
  121. package/dist/components/stream/physics/physicsRegionRuntime.d.ts +23 -0
  122. package/dist/components/stream/types.d.ts +2 -0
  123. package/dist/components/types/legendTypes.d.ts +17 -1
  124. package/dist/controls.min.js +1 -1
  125. package/dist/controls.module.min.js +1 -1
  126. package/dist/geo.min.js +1 -1
  127. package/dist/geo.module.min.js +1 -1
  128. package/dist/network.min.js +1 -1
  129. package/dist/network.module.min.js +1 -1
  130. package/dist/ordinal.min.js +1 -1
  131. package/dist/ordinal.module.min.js +1 -1
  132. package/dist/physics.min.js +1 -1
  133. package/dist/physics.module.min.js +1 -1
  134. package/dist/physicsWorker.js +1 -1
  135. package/dist/realtime.min.js +1 -1
  136. package/dist/realtime.module.min.js +1 -1
  137. package/dist/semiotic-ai-core.min.js +1 -1
  138. package/dist/semiotic-ai-core.module.min.js +1 -1
  139. package/dist/semiotic-ai.d.ts +4 -3
  140. package/dist/semiotic-ai.min.js +1 -1
  141. package/dist/semiotic-ai.module.min.js +1 -1
  142. package/dist/semiotic-data.module.min.js +1 -1
  143. package/dist/semiotic-experimental-vacp.d.ts +11 -0
  144. package/dist/semiotic-experimental-vacp.min.js +1 -0
  145. package/dist/semiotic-experimental-vacp.module.min.js +1 -0
  146. package/dist/semiotic-experimental.d.ts +6 -3
  147. package/dist/semiotic-experimental.min.js +2 -1
  148. package/dist/semiotic-experimental.module.min.js +2 -1
  149. package/dist/semiotic-geo.d.ts +4 -0
  150. package/dist/semiotic-physics.d.ts +9 -6
  151. package/dist/semiotic-realtime-core.min.js +1 -1
  152. package/dist/semiotic-realtime-core.module.min.js +1 -1
  153. package/dist/semiotic-recipes-core.d.ts +6 -1
  154. package/dist/semiotic-recipes-core.min.js +1 -1
  155. package/dist/semiotic-recipes-core.module.min.js +1 -1
  156. package/dist/semiotic-recipes.min.js +1 -1
  157. package/dist/semiotic-recipes.module.min.js +1 -1
  158. package/dist/semiotic-server-edge.min.js +1 -1
  159. package/dist/semiotic-server-edge.module.min.js +1 -1
  160. package/dist/semiotic-server-node.min.js +1 -1
  161. package/dist/semiotic-server-node.module.min.js +1 -1
  162. package/dist/semiotic-utils-core.min.js +1 -1
  163. package/dist/semiotic-utils-core.module.min.js +1 -1
  164. package/dist/semiotic-utils.min.js +1 -1
  165. package/dist/semiotic-utils.module.min.js +1 -1
  166. package/dist/semiotic.min.js +1 -1
  167. package/dist/semiotic.module.min.js +1 -1
  168. package/dist/server.min.js +1 -1
  169. package/dist/server.module.min.js +1 -1
  170. package/dist/xy.min.js +1 -1
  171. package/dist/xy.module.min.js +1 -1
  172. package/package.json +18 -2
  173. package/spec/README.md +94 -2
  174. package/spec/bindings/README.md +14 -3
  175. package/spec/v0.1/examples/annotation-provenance-reviewed-revision.json +27 -0
  176. package/spec/v0.1/examples/annotation-provenance-watcher-threshold.json +21 -0
  177. package/spec/v0.1/examples/audience-profile-executive-review.json +24 -0
  178. package/spec/v0.1/examples/audience-profile-incident-operators.json +42 -0
  179. package/spec/v0.1/examples/chart-capability-bar-comparison.json +48 -0
  180. package/spec/v0.1/examples/chart-capability-service-flow.json +54 -0
  181. package/dist/chunk-chunk-2CHN2TA3.module.min.js +0 -1
  182. package/dist/chunk-chunk-3SHB24AG.module.min.js +0 -1
  183. package/dist/chunk-chunk-4MMOOYTX.module.min.js +0 -2
  184. package/dist/chunk-chunk-5RKXZQ2P.module.min.js +0 -1
  185. package/dist/chunk-chunk-75OTQSXS.module.min.js +0 -1
  186. package/dist/chunk-chunk-7ALTGHK6.module.min.js +0 -1
  187. package/dist/chunk-chunk-A5GRQUOF.module.min.js +0 -1
  188. package/dist/chunk-chunk-AAF5LZAU.module.min.js +0 -2
  189. package/dist/chunk-chunk-ARZGA4LJ.module.min.js +0 -2
  190. package/dist/chunk-chunk-C4YA6TDR.module.min.js +0 -1
  191. package/dist/chunk-chunk-CAFLML4L.module.min.js +0 -2
  192. package/dist/chunk-chunk-CO5KQMGH.module.min.js +0 -1
  193. package/dist/chunk-chunk-FHBN7OEB.module.min.js +0 -2
  194. package/dist/chunk-chunk-GMQ5AYTD.module.min.js +0 -1
  195. package/dist/chunk-chunk-IP2UE74X.module.min.js +0 -1
  196. package/dist/chunk-chunk-ITDWLZXV.module.min.js +0 -2
  197. package/dist/chunk-chunk-JCG72SGW.module.min.js +0 -2
  198. package/dist/chunk-chunk-LPSPATPC.module.min.js +0 -1
  199. package/dist/chunk-chunk-PX5YQGDP.module.min.js +0 -2
  200. package/dist/chunk-chunk-QSQVBIJA.module.min.js +0 -1
  201. package/dist/chunk-chunk-RCF52Z42.module.min.js +0 -2
  202. package/dist/chunk-chunk-RNUHEXZA.module.min.js +0 -2
  203. package/dist/chunk-chunk-ROZWKEUG.module.min.js +0 -1
  204. package/dist/chunk-chunk-T2FKJD4O.module.min.js +0 -2
  205. package/dist/chunk-chunk-UDREYOLV.module.min.js +0 -1
  206. package/dist/chunk-chunk-VOWE3SAP.module.min.js +0 -2
  207. package/dist/chunk-chunk-VQPNBUSW.module.min.js +0 -2
  208. package/dist/chunk-chunk-WAWCIHFJ.module.min.js +0 -1
  209. package/dist/chunk-chunk-WYARAXHR.module.min.js +0 -2
  210. package/dist/chunk-chunk-XV3KGYTR.module.min.js +0 -2
  211. package/dist/chunk-chunk-YC2IVEPX.module.min.js +0 -1
  212. package/dist/chunk-chunk-ZOAQDIJO.module.min.js +0 -1
  213. package/dist/chunk-chunk-ZXIXAPRE.module.min.js +0 -2
@@ -1 +0,0 @@
1
- import{IncrementalExtent as t,RingBuffer as e,getHitRadius as r,hitTestRect as n,isTimeLandmark as i}from"./chunk-chunk-7ALTGHK6.module.min.js";import{forceLayoutPlugin as o,wrapWithCustomLayoutSelection as a,wrapWithDataHint as s}from"./chunk-chunk-C4YA6TDR.module.min.js";import{AccessibleDataTable as c,AriaLiveTooltip as l,CanvasFrameBackground as u,FlippingTooltip as h,FocusRing as f,STREAMING_PALETTE as d,SceneRevisionDiagnosticsObserver as y,ScreenReaderSummary as p,SkipToTableLink as g,TITLE_BASELINE as m,buildColorStopGradient as x,buildLinearFillGradient as v,buildThresholdLineSegments as b,clampCornerRadii as k,computeCanvasAriaLabel as w,computeEasing as A,computeRawProgress as P,createDefaultAnnotationRules as S,emitClickObservations as M,emitHoverObservations as _,filterSparseArray as C,getDevicePixelRatio as L,hasAnyCornerRadius as T,isInteractiveKeyboardTarget as D,isServerEnvironment as E,lerp as R,now as Y,observationInputType as N,prepareCanvas as $,renderAnnotationPass as W,renderLegendFromConfig as I,resolveCanvasFill as O,resolveCurveFactory as F,resolveLegendSideGutter as z,unlockCrosshair as B,useCrosshairPosition as X,useFrame as j,useFrameCanvasHost as G,useHydration as H,useSceneRevisionDiagnostics as V,useWasHydratingFromSSR as q,xySceneNodeToSVG as U}from"./chunk-chunk-A5GRQUOF.module.min.js";import{accessorsEquivalent as K,bandFromAge as Z,buildHoverData as J,coerceDateLikeValue as Q,defaultTooltipStyle as tt,filterAnnotationsByStatus as et,getPointerHitRadius as rt,isAnnotationActivationTarget as nt,parseDateLikeString as it,resolveAccessor as ot,resolveRawAccessor as at,resolveStringAccessor as st,smartTooltipEntries as ct,useAnnotationActivationOptions as lt}from"./chunk-chunk-CO5KQMGH.module.min.js";import{SEQUENTIAL_INTERPOLATORS as ut,SYMBOL_SEQUENCE as ht,UpdateResultTracker as ft,annotationLayout as dt,drawGlyphParts as yt,getSequentialInterpolator as pt,glyphFractionClipRect as gt,glyphHitGeometry as mt,glyphPlacement as xt,schemeCategory10 as vt,symbolPathString as bt,symbolRadius as kt}from"./chunk-chunk-5RKXZQ2P.module.min.js";import{getMax as wt}from"./chunk-chunk-JJ2OOIET.module.min.js";import{getCSSColorCacheVersion as At,resolveCSSColor as Pt}from"./chunk-chunk-IY7RYD4S.module.min.js";import{resolveThemeSemanticColors as St}from"./chunk-chunk-DSNGDNJY.module.min.js";function Mt(t,e,r){if(null!=t)return"function"==typeof t?t(e,r):"object"==typeof t&&null!==t&&"constant"in t?t.constant:e[t]}function _t(t){const{data:e,encoding:r}=t,n=[],i=new Map;return e.forEach((t,e)=>{const o=Mt(r.id,t,e);if(null==o||""===o)throw Error(`[semiotic] Motion encoding row ${e} resolved an empty id.`);const a=o+"";if(i.has(a))throw Error(`[semiotic] Duplicate motion encoding id "${a}".`);const s=Mt(r.process?.group,t,e),c=Mt(r.process?.stage,t,e),l=Mt(r.accessible?.group,t,e)??(null!=s?s+"":null!=c?c+"":void 0),u={};for(const n of Object.keys(r.evidence??{}))u[n]=Mt(r.evidence?.[n],t,e);const h={id:a,datum:t,time:{arrival:Mt(r.time?.arrival,t,e),basis:r.time?.basis,unit:r.time?.unit},placement:{x:Mt(r.placement?.x,t,e),y:Mt(r.placement?.y,t,e),lane:Mt(r.placement?.lane,t,e),space:r.placement?.space},kinematics:{velocityX:Mt(r.kinematics?.velocityX,t,e),velocityY:Mt(r.kinematics?.velocityY,t,e),space:r.kinematics?.space},process:{group:s,stage:c,target:Mt(r.process?.target,t,e),work:Mt(r.process?.work,t,e)},evidence:u,accessible:{description:Mt(r.accessible?.description,t,e),group:l,label:Mt(r.accessible?.label,t,e)??a}};n.push(h),i.set(a,h)}),{rows:n,byId:i}}function Ct(t){const e=Math.max(0,Math.min(1,t.minOpacity??.1));if(Number.isNaN(t.age))return 1;if(t.age===1/0)return e;if(!Number.isFinite(t.extent)||0>=t.extent)return 1;const r=Math.max(0,t.age);if("step"===t.type)return(t.threshold??.5*t.extent)>r?1:e;if("exponential"===t.type){const n=t.halfLife??t.extent/2;return e+Math.pow(.5,r/(n>0?n:t.extent/2))*(1-e)}return e+Math.max(0,Math.min(1,1-r/t.extent))*(1-e)}function Lt(t,e){const r=Number.isFinite(t)?t:0,n=Number.isFinite(e)?e:0;return{velocityX:r,velocityY:n,speed:Math.hypot(r,n),direction:Math.atan2(n,r)}}function Tt(t,e,r){return Number.isFinite(r)&&r>0?Lt((e.x-t.x)/r,(e.y-t.y)/r):Lt(0,0)}import*as Dt from"react";import{useRef as Et,useState as Rt,useEffect as Yt,useMemo as Nt,useCallback as $t,useImperativeHandle as Wt,useId as It,forwardRef as Ot,memo as Ft}from"react";import*as zt from"react";import{jsx as Bt}from"react/jsx-runtime";var Xt=null,jt=null;function Gt(t){const[e,r]=zt.useState(()=>Xt);return zt.useEffect(()=>{if(e)return;let t=!1;return(Xt?Promise.resolve(Xt):(jt||(jt=import("./chunk-XYBrushOverlay-ECZJJLAJ.module.min.js").then(t=>Xt=t.XYBrushOverlay).catch(t=>{throw jt=null,t})),jt)).then(e=>{t||r(()=>e)}),()=>{t=!0}},[e]),e?Bt(e,{...t}):null}var Ht=class{constructor(t,e){this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=t,this.chunkThreshold=e?.chunkThreshold??5e3,this.chunkSize=e?.chunkSize??5e3}updateChunkOptions(t){null!=t.chunkThreshold&&(this.chunkThreshold=t.chunkThreshold),null!=t.chunkSize&&(this.chunkSize=t.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(t){if(t=C(t),this.lastBoundedData===t)return;if(this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,totalSize:t.length});let e=this.chunkSize;const r=()=>{if(e>=t.length)return void(this.chunkTimer=0);if(t!==this.lastBoundedData)return void(this.chunkTimer=0);const n=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,n),bounded:!1}),e=n,this.chunkTimer=t.length>e?requestAnimationFrame(r):0};this.chunkTimer=requestAnimationFrame(r)}setReplacementData(t){if(t=C(t),this.lastBoundedData=t,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=t.length)return void this.callback({inserts:t,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:t.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:t.length});let e=this.chunkSize;const r=()=>{if(e>=t.length)return void(this.chunkTimer=0);if(t!==this.lastBoundedData)return void(this.chunkTimer=0);const n=Math.min(e+this.chunkSize,t.length);this.callback({inserts:t.slice(e,n),bounded:!1}),e=n,this.chunkTimer=t.length>e?requestAnimationFrame(r):0};this.chunkTimer=requestAnimationFrame(r)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const t=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:t,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(t){null!=t&&"object"==typeof t&&(this.pushBuffer.push(t),this.scheduleFlush())}pushMany(t){if(0===t.length)return;let e=0;for(let r=0;t.length>r;r++){const n=t[r];null!=n&&"object"==typeof n&&(this.pushBuffer.push(n),e++)}0!==e&&this.scheduleFlush()}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}};function Vt(t){return new Set(Array.isArray(t)?t:[t])}function qt(t,e,r){if(1>=r)return 1;const n=r-1;return Ct({age:n-e,extent:n,type:t.type,halfLife:t.halfLife??r/2,threshold:t.stepThreshold??.5*r,minOpacity:t.minOpacity??.1})}function Ut(t){const e=new Map;for(let r=0;t.length>r;r++)e.set(t[r],r);return e}function Kt(t,e,r){const n=t.duration??500,i=r-e;return n>i?1-i/n:0}function Zt(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 Jt(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 Qt(t,e,r){if(e._transitionKey)return e._transitionKey;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const r=t.getX(e.datum),n=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${r}:${n}`;if(null!=r&&null!=n)return`p:${r}:${n}`}return"p:"+r;case"glyph":return e.pointId?"g:"+e.pointId:"g:"+r;case"rect":return`r:${e.group||""}:${e.datum?.binStart??e.datum?.category??r}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+r:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function te(t,e,r,n,i,o){const a=[];for(const i of t){const t=r(i),o=n(i);Number.isFinite(t)&&Number.isFinite(o)&&a.push({px:e.x(t),py:e.y(o),rawY:o,d:i})}a.sort((t,e)=>t.px-e.px);const s=Array(a.length),c=Array(a.length),l=Array(a.length);for(let t=0;a.length>t;t++){const e=a[t];s[t]=[e.px,e.py],c[t]=e.rawY,l[t]=e.d}return{type:"line",path:s,rawValues:c,style:i,datum:l,group:o}}function ee(t,e,r,n,i,o,a,s){const c=[];for(const o of t){const t=r(o),a=n(o);if(!Number.isFinite(t)||!Number.isFinite(a))continue;const l=e.x(t),u=s?s(o):i;c.push({px:l,topY:e.y(a),botY:e.y(u),rawY:a})}c.sort((t,e)=>t.px-e.px);const l=Array(c.length),u=Array(c.length),h=Array(c.length);for(let t=0;c.length>t;t++){const e=c[t];l[t]=[e.px,e.topY],u[t]=[e.px,e.botY],h[t]=e.rawY}return{type:"area",topPath:l,bottomPath:u,rawValues:h,style:o,datum:t,group:a}}function re(t,e,r,n){const i=new Map;if("silhouette"===n)for(const n of t){let t=0;for(const i of e)t+=r(i,n)||0;i.set(n,-t/2)}else if("wiggle"===n){t.length>0&&i.set(t[0],0);for(let n=1;t.length>n;n++){const o=t[n-1],a=t[n];let s=0,c=0,l=0;for(const t of e){const e=r(t,a)||0;s+=(2*l+e)*(e-(r(t,o)||0)),c+=e,l+=e}const u=i.get(o)??0;i.set(a,u-(c>0?s/(2*c):0))}if(t.length>0){let n=0;for(const o of t){let t=0;for(const n of e)t+=r(n,o)||0;n+=(i.get(o)??0)+t/2}const o=n/t.length;for(const e of t)i.set(e,(i.get(e)??0)-o)}}else for(const e of t)i.set(e,0);return i}function ne(t,e,r,n,i,o,a){const s=r(t),c=n(t);if(!Number.isFinite(s)||!Number.isFinite(c))return null;const l={type:"point",x:e.x(s),y:e.y(c),r:i,style:o,datum:t};return void 0!==a&&(l.pointId=a),l}function ie(t,e,r,n,i,o,a,s){const c=r(t),l=n(t);if(!Number.isFinite(c)||!Number.isFinite(l))return null;const u={type:"symbol",x:e.x(c),y:e.y(l),size:i,symbolType:o,style:a,datum:t};return void 0!==s&&(u.pointId=s),u}function oe(t,e,r,n,i,o,a){return{type:"rect",x:t,y:e,w:r,h:n,style:i,datum:o,group:a}}function ae(t,e,r,n,i,o,a){const s={type:"heatcell",x:t,y:e,w:r,h:n,fill:i,datum:o};return a?.showValues&&(s.showValues=!0,s.value=a.value,a.valueFormat&&(s.valueFormat=a.valueFormat)),s}function se(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 ce(t,e,r,n){if(!t.scales)return null;const i=[],o=[];for(const r of e){const e=t.getX(r);if(!Number.isFinite(e))continue;const a=n.getTop(r),s=n.getBottom(r);if(!Number.isFinite(a)||!Number.isFinite(s))continue;const c=t.scales.x(e),l=t.scales.y(a),u=t.scales.y(s);Number.isFinite(c)&&Number.isFinite(l)&&Number.isFinite(u)&&(i.push([c,l]),o.push([c,u]))}return 2>i.length?null:{type:"area",topPath:i,bottomPath:o,...t.config.curve&&"linear"!==t.config.curve&&{curve:t.config.curve},style:se(t,n,r,e[0]),datum:e,group:r,interactive:n.interactive}}function le(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 ue(t,e,r){const n=[];for(const i of r){const r=ce(t,e,"__ribbon_aggregate",i);r&&n.push(r)}return n}function he(t,e,r,n){const i=[];for(const o of n){const n=ce(t,e,r,o);n&&i.push(n)}return i}function fe(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 de(t,e,r,n){if(!t.config.pointStyle)return;const i=n??t.getY;for(const n of e){const e=t.resolveGroupColor(n.key);for(const o of n.data){let n=t.config.pointStyle(o);!n.fill&&e&&(n={...n,fill:e});const a=n.r??3,s=t.getPointId?t.getPointId(o)+"":void 0,c=ne(o,t.scales,t.getX,i,a,n,s);c&&r.push(c)}}}function ye(t){return"threshold"===t.type&&"string"==typeof t.color&&"number"==typeof t.value}var pe={stops:[{offset:0,opacity:.8},{offset:1,opacity:.05}]};function ge(t,e=pe){if(t)return!0===t?e:"stops"in t?Array.isArray(t.stops)?t:void 0:"colorStops"in t?Array.isArray(t.colorStops)?{stops:t.colorStops.map(({offset:t,color:e})=>({offset:t,color:e}))}:void 0:{stops:[{offset:0,opacity:t.topOpacity??e.stops[0]?.opacity??.8},{offset:1,opacity:t.bottomOpacity??e.stops.at(-1)?.opacity??.05}]}}function me(t){return t?ge(t):void 0}function xe(t){if(t)return Array.isArray(t)?{stops:t.map(({at:t,color:e,opacity:r})=>({offset:t/100,color:e,...null!=r&&{opacity:r}}))}:Array.isArray(t.stops)?t:void 0}function ve(t){return{stops:t.stops.map(t=>({...t,offset:1-t.offset})).sort((t,e)=>t.offset-e.offset)}}function be(t){return ge(t)}var ke=new Map;function we(t,e,r){const n=r.config.areaStyle?.(e);return n&&(t.style=n),t}function Ae(t,e,r,n,i){const o=new Map;for(const a of t){const t=e(a),s=r(a);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))continue;const c=Math.floor(t/n)*n;let l=o.get(c);if(l||(l={start:c,end:c+n,total:0,categories:new Map},o.set(c,l)),l.total+=s,i){const t=i(a);l.categories.set(t,(l.categories.get(t)||0)+s)}}return o}function Pe(t){if("production"===process.env.NODE_ENV)return;const{label:e,nodes:r,overlays:n,warned:i}=t;Se(n)&&0===r.length&&Me(i,"overlay-only",`[semiotic] ${e} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),r.length>0&&r.every(t=>null==t.datum)&&Me(i,"null-datums",`[semiotic] ${e} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function Se(t){return null!=t&&!1!==t&&""!==t&&(!Array.isArray(t)||t.some(Se))}function Me(t,e,r){t.has(e)||(t.add(e),console.warn(r))}function _e(t,e,r,n){const i=function(t){if(t instanceof Error)return{name:t.name||"Error",message:t.message||"Custom layout threw."};if("string"==typeof t)return{name:"Error",message:t};if(null==t)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:t+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(e),o="network"===t?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:t,source:o,message:`Semiotic ${t} ${o} failed: ${i.message}`,error:i,recovery:r?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:r,affectedRevision:n}}function Ce(t,e){const r="function"==typeof t?t:r=>r[t||e];return t=>{const e=r(t);return null==e?NaN:+e}}function Le(t){const e=[],r=["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode,n=Ce(r&&t.valueAccessor||t.yAccessor,r?"value":"y");if(t.boundsAccessor){const r=ot(t.boundsAccessor,"bounds");e.push({kind:"bounds",getTop:t=>{const e=n(t);if(!Number.isFinite(e))return NaN;const i=r(t);return Number.isFinite(i)&&0!==i?e+i:e},getBottom:t=>{const e=n(t);if(!Number.isFinite(e))return NaN;const i=r(t);return Number.isFinite(i)&&0!==i?e-i:e},style:t.boundsStyle,perSeries:!0,interactive:!1})}if(t.band){const r=Array.isArray(t.band)?t.band:[t.band];for(const t of r)e.push({kind:"band",getTop:Ce(t.y1Accessor,"y1"),getBottom:Ce(t.y0Accessor,"y0"),style:t.style,perSeries:!1!==t.perSeries,interactive:!0===t.interactive})}return e}import{scaleLinear as Te,scaleLog as De,scaleSymlog as Ee,scaleTime as Re}from"d3-scale";function Ye(t,e){return e?[e[0]??t[0],e[1]??t[1]]:t}function Ne(t,e,r){if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return De().domain(t).range(r).clamp(!0)}return"symlog"===t?Ee().domain(e).range(r):"time"===t?Re().domain([new Date(e[0]),new Date(e[1])]).range(r):Te().domain(e).range(r)}function $e(t,e,r){e>t.capacity&&(t.resize(e),r&&e>r.capacity&&r.resize(e))}function We(t,r){const n=new e(t.capacity);return t.forEach(()=>n.push(r)),n}function Ie(t,e,r,n){const i=t.push(e);return r&&r.push(n),i}function Oe(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])}var Fe=new WeakMap;function ze(){return this.updateResults.last}function Be(){return this.updateResults.last}function Xe(t){return this.updateResults.subscribe(t)}function je(t){this.config.layoutSelection=t}function Ge(){Fe.set(this,!0)}function He(){const t=!0===Fe.get(this);return Fe.delete(this),t}function Ve(t){Object.assign(t.prototype,{getLastUpdateResult:ze,getUpdateSnapshot:Be,subscribeUpdateResult:Xe,setLayoutSelection:je,markStylePaintPending:Ge,consumeStylePaintPending:He})}var qe=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ue=["scene-style","data-paint","accessibility","evidence"],Ke=(t,e)=>({retainedData:t,invalidations:e}),Ze=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Je=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Qe=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],tr=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],er=["scene-geometry","data-paint","accessibility","evidence"],rr=["scene-style","data-paint","accessibility","evidence"],nr=[],ir={chartType:Ke("rebuild",Ze),runtimeMode:Ke("rebuild",Ze),xAccessor:Ke("rebuild",Ze),yAccessor:Ke("rebuild",Ze),timeAccessor:Ke("rebuild",Ze),valueAccessor:Ke("rebuild",Ze),y0Accessor:Ke("rebuild",Ze),boundsAccessor:Ke("rebuild",Ze),band:Ke("rebuild",Ze),openAccessor:Ke("rebuild",Ze),highAccessor:Ke("rebuild",Ze),lowAccessor:Ke("rebuild",Ze),closeAccessor:Ke("rebuild",Ze),candlestickRangeMode:Ke("rebuild",Ze),accessorRevision:Ke("rebuild",Ze),groupAccessor:Ke("rebuild",Je),categoryAccessor:Ke("rebuild",Je),lineDataAccessor:Ke("rebuild",Je),colorAccessor:Ke("rebuild",rr),sizeAccessor:Ke("rebuild",er),symbolAccessor:Ke("rebuild",er),pointIdAccessor:Ke("rebuild",er),xScaleType:Ke("preserve",Qe),yScaleType:Ke("preserve",Qe),xExtent:Ke("preserve",Qe),yExtent:Ke("preserve",Qe),extentPadding:Ke("preserve",Qe),scalePadding:Ke("preserve",Qe),axisExtent:Ke("preserve",Qe),binSize:Ke("preserve",Qe),normalize:Ke("preserve",Qe),heatmapAggregation:Ke("preserve",Qe),heatmapXBins:Ke("preserve",Qe),heatmapYBins:Ke("preserve",Qe),arrowOfTime:Ke("preserve",tr),baseline:Ke("preserve",tr),stackOrder:Ke("preserve",tr),sizeRange:Ke("preserve",tr),curve:Ke("preserve",tr),areaGroups:Ke("preserve",tr),customLayout:Ke("preserve",tr),layoutConfig:Ke("preserve",tr),layoutMargin:Ke("preserve",tr),symbolMap:Ke("preserve",er),showValues:Ke("preserve",er),heatmapValueFormat:Ke("preserve",er),lineStyle:Ke("preserve",rr),pointStyle:Ke("preserve",rr),areaStyle:Ke("preserve",rr),barStyle:Ke("preserve",rr),swarmStyle:Ke("preserve",rr),waterfallStyle:Ke("preserve",rr),candlestickStyle:Ke("preserve",rr),boundsStyle:Ke("preserve",rr),gradientFill:Ke("preserve",rr),lineGradient:Ke("preserve",rr),semanticLineStops:Ke("preserve",rr),colorScheme:Ke("preserve",rr),themeCategorical:Ke("preserve",rr),themeSemantic:Ke("preserve",rr),themeSequential:Ke("preserve",rr),themeDiverging:Ke("preserve",rr),barColors:Ke("preserve",rr),decay:Ke("preserve",rr),pulse:Ke("preserve",rr),staleness:Ke("preserve",rr),layoutSelection:Ke("preserve",rr),annotations:Ke("preserve",["overlay","accessibility","evidence"]),windowSize:Ke("preserve",nr),windowMode:Ke("preserve",nr),maxCapacity:Ke("preserve",nr),clock:Ke("preserve",nr),transition:Ke("preserve",nr),introAnimation:Ke("preserve",nr),onLayoutError:Ke("preserve",nr)},or=Ke("preserve",tr),ar=class{constructor(){this.tracker=new ft}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}},qe)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},Ue):this.recordNoop("restyle")}recordConfig(t){const e=function(t){let e="preserve";const r=new Set;for(const n of t){const t=ir[n]??or;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)r.add(e)}return{retainedData:e,invalidations:r}}(t);return this.tracker.record({kind:"config",keys:t},e.invalidations)}};import{quadtree as sr}from"d3-quadtree";var cr=class{constructor(){this.maxRadius=0,this.tree=null}get quadtree(){return this.tree}get maxPointRadius(){return this.maxRadius}clear(){this.tree=null,this.maxRadius=0}rebuild(t,e){if("scatter"!==t&&"bubble"!==t&&"custom"!==t)return void this.clear();let r=0,n=0;for(const t of e)"point"===t.type&&(r++,t.r>n&&(n=t.r));if(this.maxRadius=n,500>=r)return void(this.tree=null);const i=Array(r);let o=0;for(const t of e)"point"===t.type&&(i[o++]=t);this.tree=sr().x(t=>t.x).y(t=>t.y).addAll(i)}},lr=class r{constructor(r){if(this.xExtent=new t,this.yExtent=new t,this.growingCapacityWarned=!1,this.windowSizeWarned=!1,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._datumIndexCache=null,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.updateResults=new ar,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.xIsDate=!1,this.spatialIndex=new cr,this._lastBoundedInsertsRef=null,this.applyPulse=(t,e,r)=>!(!this.config.pulse||!this.timestampBuffer)&&function(t,e,r,n,i,o=("undefined"!=typeof performance?performance.now():Date.now())){const a=t.color??"rgba(255,255,255,0.6)",s=t.glowRadius??4;let c=!1;const l=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,s=!1;for(const r of e){const e=l.get(r);if(null==e)continue;s=!0;const a=n.get(e);if(null==a)continue;const c=Kt(t,a,o);c>i&&(i=c)}s&&(c=Zt(r,i,a)||c);continue}const e=l.get(r.datum);if(null==e)continue;const i=n.get(e);c=Zt(r,null==i?0:Kt(t,i,o),a,s)||c}return c}(this.config.pulse,t,e,this.timestampBuffer,this.getDatumIndexMap(e),r),this.config=r,this.buffer=new e(r.windowSize),this.growingCap=r.windowSize,["bar","swarm","waterfall"].includes(r.chartType)||"streaming"===r.runtimeMode?(this.getX=ot(r.timeAccessor||r.xAccessor,"time"),this.getY=ot(r.valueAccessor||r.yAccessor,"value")):(this.getX=ot(r.xAccessor,"x"),this.getY=ot(r.yAccessor,"y")),this.getGroup=st(r.groupAccessor),this.getCategory=st(r.categoryAccessor),this.getSize=r.sizeAccessor?ot(r.sizeAccessor,"size"):void 0,this.getColor=st(r.colorAccessor),this.getSymbol=st(r.symbolAccessor),this.getY0=r.y0Accessor?ot(r.y0Accessor,"y0"):void 0,this.resolvedRibbons=Le(r),this.getPointId=st(r.pointIdAccessor),"candlestick"===r.chartType){const t=null!=r.openAccessor,e=null!=r.closeAccessor;this.getOpen=t?ot(r.openAccessor,"open"):void 0,this.getHigh=ot(r.highAccessor,"high"),this.getLow=ot(r.lowAccessor,"low"),this.getClose=e?ot(r.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e}r.pulse&&(this.timestampBuffer=new e(r.windowSize))}currentTime(){return this.config.clock?.()??Y()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=We(this.buffer,this.currentTime())):this.timestampBuffer=null}pushDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(t)),void this.yExtent.push(this.getLow(t));this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t));for(const e of this.resolvedRibbons){const r=e.getTop(t),n=e.getBottom(t);Number.isFinite(r)&&this.yExtent.push(r),Number.isFinite(n)&&this.yExtent.push(n)}}evictDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(t)),void this.yExtent.evict(this.getLow(t));this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t));for(const e of this.resolvedRibbons){const r=e.getTop(t),n=e.getBottom(t);Number.isFinite(r)&&this.yExtent.evict(r),Number.isFinite(n)&&this.yExtent.evict(n)}}rebuildYExtent(){this.yExtent.clear();for(const t of this.buffer)this.pushDatumYExtent(t)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const t of this.buffer)this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t)}ingest(t){if(t.bounded&&this._lastBoundedInsertsRef===t.inserts)return this.updateResults.recordNoop("replace"),!1;const e=this.currentTime();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.bounded){this._lastBoundedInsertsRef=t.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const r=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=r?ot(this.config.timeAccessor||this.config.xAccessor,"time"):ot(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],r=this.config.xAccessor,n="function"==typeof r?r(e):e[r||"x"],i=n instanceof Date,o="string"==typeof n&&Number.isFinite(it(n));if(this.xIsDate=i||o,o){const t="string"==typeof r?r:void 0;this.getX=t?e=>Q(e[t]):t=>Q(r(t))}}$e(this.buffer,t.totalSize||t.inserts.length,this.timestampBuffer);for(const r of t.inserts)Ie(this.buffer,r,this.timestampBuffer,e),this.xExtent.push(this.getX(r)),this.pushDatumYExtent(r)}else for(const r of t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity??1e5;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap),"production"===process.env.NODE_ENV||this.growingCapacityWarned||5e4>this.growingCap||(this.growingCapacityWarned=!0,console.warn(`[Semiotic] Growing window buffer reached ${this.growingCap} points (cap ${t}). Large canvas scenes are expensive — prefer a sliding window, aggregation, or an explicit maxCapacity if this is intentional.`)))}const t=Ie(this.buffer,r,this.timestampBuffer,e);this.xExtent.push(this.getX(r)),this.pushDatumYExtent(r),null!=t&&(this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t))}return this.updateResults.recordData(t.bounded?"replace":"ingest",t.inserts.length),!0}ingestWithResult(t){return this.ingest(t),this.updateResults.last}computeScene(t){const{config:e,buffer:r}=this,n=this.scales,i=this.lastLayout;if(!this.needsFullRebuild&&!e.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(this.config.scalePadding??0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);this.xExtent.dirty&&this.xExtent.recalculate(r,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const o=this.getBufferArray(),a=this.yExtent.extent;let s=Ye(this.xExtent.extent,e.xExtent),c=Ye(a,e.yExtent);const l=!(!(u=e.yExtent)||null==u[0]||null==u[1]);var u;const h="exact"===e.axisExtent;if("stackedarea"===e.chartType&&!l&&r.size>0){const t=function(t){const{config:e,groups:r,getX:n,getY:i}=t,o="exact"===e.axisExtent;if(e.normalize){const r=[0,o?1:1+e.extentPadding];return{yDomain:r,stackExtentCache:{key:`${t.bufferSize}:${t.ingestVersion}:norm`,yDomain:r}}}const a=`${t.bufferSize}:${t.ingestVersion}:${e.baseline??"zero"}:${e.stackOrder??"key"}`;if(t.stackExtentCache&&t.stackExtentCache.key===a)return{yDomain:t.stackExtentCache.yDomain,stackExtentCache:t.stackExtentCache};const s=new Map,c=new Set;let l=0;const u=new Map,h=new Map;for(const t of r){const e=new Map;let r=0;for(const o of t.data){const t=n(o),a=i(o);if(!Number.isFinite(t)||!Number.isFinite(a))continue;e.set(t,(e.get(t)||0)+a),c.add(t),r+=a;const s=(u.get(t)||0)+a;u.set(t,s),s>l&&(l=s)}s.set(t.key,e),h.set(t.key,r)}const f=e.stackOrder??"key",d=(t,e)=>e>t?-1:t>e?1:0;let y,p;if("input"===f)y=r.map(t=>t.key);else if("insideOut"===f){const t=[...r].map(t=>t.key).sort((t,e)=>{const r=(h.get(e)??0)-(h.get(t)??0);return 0!==r?r:d(t,e)}),e=[],n=[];let i=0,o=0;for(const r of t)o>i?(e.push(r),i+=h.get(r)??0):(n.push(r),o+=h.get(r)??0);y=[...n.reverse(),...e]}else y="asc"===f?r.map(t=>t.key).sort((t,e)=>{const r=(h.get(t)??0)-(h.get(e)??0);return 0!==r?r:d(t,e)}):"desc"===f?r.map(t=>t.key).sort((t,e)=>{const r=(h.get(e)??0)-(h.get(t)??0);return 0!==r?r:d(t,e)}):r.map(t=>t.key).sort(d);if("wiggle"===e.baseline||"silhouette"===e.baseline){const t=Array.from(c).sort((t,e)=>t-e),r=re(t,y,(t,e)=>s.get(t)?.get(e)||0,e.baseline);let n=1/0,i=-1/0;for(const e of t){const t=r.get(e)??0,o=u.get(e)??0;n>t&&(n=t),t+o>i&&(i=t+o)}Number.isFinite(n)&&Number.isFinite(i)||(n=0,i=0);const a=i-n,l=o?0:a>0?a*e.extentPadding:1;p=[n-l,i+l]}else if("diverging"===e.baseline){const t=Array.from(c).sort((t,e)=>t-e),[r,n]=function(t,e,r){let n=0,i=0;for(const o of t){let t=0,a=0;for(const n of e){const e=r(n,o)||0;0>e?a+=e:t+=e}n>a&&(n=a),t>i&&(i=t)}return[n,i]}(t,y,(t,e)=>s.get(t)?.get(e)||0),i=n-r,a=o?0:i>0?i*e.extentPadding:1;p=[r-a,n+a]}else p=[0,l+(o?0:l>0?l*e.extentPadding:1)];return{yDomain:p,stackExtentCache:{key:a,yDomain:p}}}({config:e,groups:this.groupData(o),getX:this.getX,getY:this.getY,bufferSize:r.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});c=t.yDomain,this._stackExtentCache=t.stackExtentCache}else"bar"===e.chartType&&e.binSize&&!l&&r.size>0?c=function(t,e,r,n,i,o,a){const[,s]=function(t,e,r,n,i){const o=Ae(t,e,r,n,i);if(0===o.size)return[0,0];let a=0;for(const t of o.values())t.total>a&&(a=t.total);return[0,a]}(t,e,r,n,i);return[0,a?s:s+s*o]}(r,this.getX,this.getY,e.binSize,this.getCategory,e.extentPadding,h):"waterfall"===e.chartType&&!l&&r.size>0?c=function(t,e,r,n){const[i,o]=function(t,e){let r=0,n=0,i=0;for(const o of t){const t=e(o);null==t||Number.isNaN(t)||(i+=t,r>i&&(r=i),i>n&&(n=i))}return[r,n]}(t,e),a=o-i,s=n?0:a>0?a*r:1;return[Math.min(0,i-Math.abs(s)),Math.max(0,o+Math.abs(s))]}(r,this.getY,e.extentPadding,h):l||c[0]===1/0||(c=function(t,e,r){if(!r.length)return t;let[n,i]=t;for(const t of e)for(const e of r){const r=e.getTop(t),o=e.getBottom(t);Number.isFinite(r)&&(n>r&&(n=r),r>i&&(i=r)),Number.isFinite(o)&&(n>o&&(n=o),o>i&&(i=o))}return[n,i]}(c,o,this.resolvedRibbons),c=function(t,e){const r=t[1]-t[0],n=e.exactMode?0:r>0?r*e.extentPadding:1,i=[null!=e.userMin?t[0]:t[0]-n,null!=e.userMax?t[1]:t[1]+n];return"log"!==e.yScaleType||i[0]>0||0>=e.dataYDomain[0]||e.exactMode||null==e.userMin&&(i[0]=e.dataYDomain[0]/(1+e.extentPadding)),i}(c,{exactMode:h,extentPadding:e.extentPadding,userMin:e.yExtent?.[0],userMax:e.yExtent?.[1],yScaleType:e.yScaleType,dataYDomain:a}));c=function(t,e,r){if(!e||r)return t;const n=e[0],i=e[1];return null==n&&null==i?t:[null!=n?n:t[0],null!=i?i:t[1]]}(c,e.yExtent,!!l),({xDomain:s,yDomain:c}=function(t,e,r){let n=t,i=e;if(n[0]===1/0||n[1]===-1/0)if("time"===r){const t=Date.now();n=[t-864e5,t]}else n=[0,1];return i[0]!==1/0&&i[1]!==-1/0||(i=[0,1]),{xDomain:n,yDomain:i}}(s,c,e.xScaleType)),this.scales=function(t){const{config:e,layout:r,xDomain:n,yDomain:i}=t,o="streaming"===e.runtimeMode,a=Math.max(0,Math.min(e.scalePadding||0,Math.min(r.width,r.height)/2-1));if(o){if("x"==("up"===(s=e.arrowOfTime)||"down"===s?"y":"x")){const t="right"===e.arrowOfTime?[a,r.width-a]:[r.width-a,a];return{x:Te().domain(n).range(t),y:Ne(e.yScaleType,i,[r.height-a,a])}}const t="down"===e.arrowOfTime?[a,r.height-a]:[r.height-a,a];return{x:Ne(e.yScaleType,i,[a,r.width-a]),y:Te().domain(n).range(t)}}var s;return{x:Ne(e.xScaleType,n,[a,r.width-a]),y:Ne(e.yScaleType,i,[r.height-a,a])}}({config:e,layout:t,xDomain:s,yDomain:c}),this._customLayoutFailedThisBuild=!1;const f=this.buildSceneNodes(t,o);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=n,this.lastLayout=i):(this.scene=[],this.spatialIndex.rebuild(this.config.chartType,this.scene)),void(this.needsFullRebuild=!0);this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=f,this.config.decay&&this.applyDecay(this.scene,o),this.config.pulse&&this.applyPulse(this.scene,o,this.currentTime()),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.spatialIndex.rebuild(this.config.chartType,this.scene),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(t){const e=t.width/this.lastLayout.width,r=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const n of t.path)n[0]*=e,n[1]*=r;break;case"area":for(const n of t.topPath)n[0]*=e,n[1]*=r;for(const n of t.bottomPath)n[0]*=e,n[1]*=r;t.clipRect&&(t.clipRect={x:t.clipRect.x*e,y:t.clipRect.y*r,width:t.clipRect.width*e,height:t.clipRect.height*r}),t.strokeColorBands&&(t.strokeColorBands=t.strokeColorBands.map(t=>({...t,y:t.y*r,height:t.height*r})));break;case"point":case"glyph":t.x*=e,t.y*=r;break;case"rect":case"heatcell":t.x*=e,t.y*=r,t.w*=e,t.h*=r;break;case"candlestick":t.x*=e,t.openY*=r,t.closeY*=r,t.highY*=r,t.lowY*=r}const n=this.scales.x.domain(),i=this.scales.y.domain(),o=this.scales.x.range(),a=this.scales.y.range(),s=Ne,c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),l=a[1]>a[0];this.scales={x:s(this.config.xScaleType,n,o[0]>o[1]?[t.width-c,c]:[c,t.width-c]),y:s(this.config.yScaleType,i,l?[c,t.height-c]:[t.height-c,c])},this.lastLayout={width:t.width,height:t.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(t,e){const{config:r,scales:n}=this;if(!n)return[];if(r.customLayout){const i={data:e,scales:n,dimensions:{width:t.width,height:t.height,margin:r.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:r.themeSemantic??{},categorical:r.themeCategorical??d},resolveColor:(t,e)=>{const n=this.resolveGroupColor(t);if(n)return n;const i=this.resolveLineStyle(t,e);return i.stroke?i.stroke:"string"==typeof i.fill?i.fill:r.themeSemantic?.primary??"#4e79a7"},config:r.layoutConfig??{},selection:r.layoutSelection??null};let o;try{o=r.customLayout(i)}catch(t){const e=null!==this.lastCustomLayoutResult,n=_e("xy",t,e,this.version);this.lastCustomLayoutFailure=n,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",t);try{r.onLayoutError?.(n)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return e?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=o.overlays??null,this.lastCustomLayoutResult=o,this.lastCustomLayoutFailure=null;const a=o.nodes??[];if(this._customRestyle=o.restyle,this.hasCustomRestyle=!!o.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const t of a)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(a,r.layoutSelection??null)}return Pe({label:"customLayout",nodes:a,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),a}if(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===e.length)return[];const i={scales:n,config:r,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getSymbol:this.getSymbol,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(r.chartType){case"line":return function(t,e){const r=t.groupData(e),n=[],i=t.config.annotations?.filter(ye).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.ribbons&&t.ribbons.length>0){const{perSeries:i,aggregate:o}=le(t.ribbons);if(o.length>0&&n.push(...ue(t,e,o)),i.length>0)for(const e of r)n.push(...he(t,e.data,e.key,i))}for(const e of r){const r=t.resolveLineStyle(e.key,e.data[0]),o=te(e.data,t.scales,t.getX,t.getY,r,e.key);i&&i.length>0&&(o.colorThresholds=i),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),n.push(o)}return de(t,r,n),n}(i,e);case"area":return function(t,e){const r=t.groupData(e),n=[];if(t.ribbons&&t.ribbons.length>0){const{perSeries:i,aggregate:o}=le(t.ribbons);if(o.length>0&&n.push(...ue(t,e,o)),i.length>0)for(const e of r)n.push(...he(t,e.data,e.key,i))}const i=t.scales.y.domain(),o=i[0],a=t.config.semanticLineStops?.filter(t=>Number.isFinite(t.offset)).map(t=>({value:i[0]+Math.max(0,Math.min(1,t.offset))*(i[1]-i[0]),color:t.color,thresholdType:"greater"})).sort((t,e)=>t.value-e.value),s=a&&a.length>0?(()=>{const e=a.reduce((t,e)=>(t.at(-1)?.value===e.value?t[t.length-1]=e:t.push(e),t),[]),r=[{from:i[0],to:e[0].value}];for(let t=0;e.length>t;t++)r.push({from:e[t].value,to:e[t+1]?.value??i[1],color:e[t].color});return r.map(({from:e,to:r,color:n})=>{const i=t.scales.y(e),o=t.scales.y(r);return{y:Math.min(i,o),height:Math.abs(o-i),color:n}}).filter(t=>t.height>0)})():void 0,c=t.getY0?e=>{const r=t.getY0(e);return null==r?o:r}:void 0;for(const e of r){const r=t.resolveAreaStyle(e.key,e.data[0]),i=ee(e.data,t.scales,t.getX,t.getY,o,r,e.key,c),l=be(t.config.gradientFill);l&&(i.fillGradient=l),t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),a&&a.length>0&&(i.colorThresholds=a,i.strokeColorBands=s),n.push(i)}return de(t,r,n),n}(i,e);case"mixed":return function(t,e){const r=t.groupData(e),n=[],i=t.config.areaGroups||new Set;if(t.ribbons&&t.ribbons.length>0){const{perSeries:i,aggregate:o}=le(t.ribbons);if(o.length>0&&n.push(...ue(t,e,o)),i.length>0)for(const e of r)n.push(...he(t,e.data,e.key,i))}const o=t.scales.y.domain()[0],a=t.getY0?e=>{const r=t.getY0(e);return null==r?o:r}:void 0;for(const e of r)if(i.has(e.key)){const r=t.resolveAreaStyle(e.key,e.data[0]),i=ee(e.data,t.scales,t.getX,t.getY,o,r,e.key,a),s=be(t.config.gradientFill);s&&(i.fillGradient=s),t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),n.push(i)}else{const r=t.resolveLineStyle(e.key,e.data[0]),i=te(e.data,t.scales,t.getX,t.getY,r,e.key);t.config.curve&&"linear"!==t.config.curve&&(i.curve=t.config.curve),t.config.lineGradient&&(i.strokeGradient=t.config.lineGradient),n.push(i)}return de(t,r,n),n}(i,e);case"stackedarea":return function(t,e){const r=t.groupData(e),n=t.config.stackOrder??"key",i=()=>r.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);if("input"===n);else if("key"===n)i();else if("asc"===n||"desc"===n||"insideOut"===n){const e=new Map;for(const n of r){let r=0;for(const e of n.data){const n=t.getX(e),i=t.getY(e);Number.isFinite(n)&&Number.isFinite(i)&&(r+=i)}e.set(n.key,r)}const i=(t,e)=>e>t?-1:t>e?1:0;if("asc"===n)r.sort((t,r)=>{const n=(e.get(t.key)??0)-(e.get(r.key)??0);return 0!==n?n:i(t.key,r.key)});else if("desc"===n)r.sort((t,r)=>{const n=(e.get(r.key)??0)-(e.get(t.key)??0);return 0!==n?n:i(t.key,r.key)});else{const t=[...r].sort((t,r)=>{const n=(e.get(r.key)??0)-(e.get(t.key)??0);return 0!==n?n:i(t.key,r.key)}),n=[],o=[];let a=0,s=0;for(const r of t)s>a?(n.push(r),a+=e.get(r.key)??0):(o.push(r),s+=e.get(r.key)??0);r.length=0,r.push(...o.reverse(),...n)}}else i();const o=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,a=t.config.normalize?"zero":t.config.baseline??"zero",{nodes:s,stackedTops:c}=function(t,e,r,n,i,o,a,s="zero"){const c=new Set;for(const e of t)for(const t of e.data){const e=r(t);Number.isFinite(e)&&c.add(e)}const l=Array.from(c).sort((t,e)=>t-e),u=new Map;for(const e of t){const t=new Map;for(const i of e.data){const e=r(i),o=n(i);Number.isFinite(e)&&Number.isFinite(o)&&t.set(e,(t.get(e)||0)+o)}u.set(e.key,t)}let h;if(o){h=new Map;for(const e of l){let r=0;for(const n of t)r+=u.get(n.key)?.get(e)||0;h.set(e,r||1)}}const f=re(l,t.map(t=>t.key),(t,e)=>u.get(t)?.get(e)||0,s),d="diverging"===s&&!o,y=[],p=new Map,g=new Map,m=new Map,x=new Map;for(const t of l)g.set(t,f.get(t)??0),m.set(t,0),x.set(t,0);for(const r of t){const t=u.get(r.key),n=new Map;let s=[],c=[];const f=()=>{if(s.length>=2){const t={type:"area",topPath:s,bottomPath:c,style:i(r.key,r.data[0]),datum:r.data,group:r.key};a&&(t.curve=a),y.push(t)}s=[],c=[]};for(const r of l){const i=t.has(r);let a,l,u=i?t.get(r):0;if(o&&i&&(u/=h.get(r)),!i||!Number.isFinite(u)||0===u){f();continue}d?u>0?(a=m.get(r),l=a+u,m.set(r,l)):(a=x.get(r),l=a+u,x.set(r,l)):(a=g.get(r),l=a+u,g.set(r,l));const y=e.x(r);c.push([y,e.y(a)]),s.push([y,e.y(l)]),n.set(r,l)}f(),p.set(r.key,n)}return{nodes:y,stackedTops:p}}(r,t.scales,t.getX,t.getY,(e,r)=>t.resolveAreaStyle(e,r),t.config.normalize,o,a),l=s;if(t.config.pointStyle){const e=new WeakMap;for(const n of r){const r=c.get(n.key);if(r)for(const i of n.data){const n=t.getX(i),o=t.getY(i);null==n||Number.isNaN(n)||null==o||Number.isNaN(o)||!r.has(n)||e.set(i,r.get(n))}}const n=r=>e.get(r)??t.getY(r);de(t,r,l,n)}return l}(i,e);case"scatter":case"bubble":return function(t,e){const r=[],n="bubble"===t.config.chartType?10:5,i=t.config.sizeRange||[3,15];let o=null;if(t.getSize&&!t.config.pointStyle){const r=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(r.length>0){let t=1/0,e=-1/0;for(const n of r)t>n&&(t=n),n>e&&(e=n);o=r=>t===e?(i[0]+i[1])/2:i[0]+(r-t)/(e-t)*(i[1]-i[0])}}const a=t.getColor?t.resolveColorMap(e):null,s=t.config.themeSemantic?.primary||"#4e79a7",c=t.getSymbol,l=t.config.symbolMap,u=new Map;let h=0;const f=t=>{const e=l?.[t];if(e)return e;let r=u.get(t);return r||(r=ht[h%ht.length],h++,u.set(t,r)),r};for(const i of e){let e=t.config.pointStyle?t.config.pointStyle(i):{fill:s,opacity:.8},l=e.r||n;if(o&&t.getSize){const e=t.getSize(i);null==e||Number.isNaN(e)||(l=o(e))}if(a&&t.getColor&&!e.fill){const r=t.getColor(i);r&&a.has(r)&&(e={...e,fill:a.get(r)})}const u=t.getPointId?t.getPointId(i)+"":void 0;if(c){const n=f(c(i)+""),o=ie(i,t.scales,t.getX,t.getY,Math.PI*l*l,n,e,u);o&&r.push(o)}else{const n=ne(i,t.scales,t.getX,t.getY,l,e,u);n&&r.push(n)}}return r}(i,e);case"heatmap":return function(t,e,r){if(t.config.heatmapAggregation)return function(t,e,r){const n=Math.max(1,Math.floor(t.config.heatmapXBins??20)),i=Math.max(1,Math.floor(t.config.heatmapYBins??20)),o=t.config.heatmapAggregation??"count",a=ot(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[s,c]=t.scales.x.domain(),[l,u]=t.scales.y.domain(),h=(c-s||1)/n,f=(u-l||1)/i,d=n*i;if(d>1e6)return[];const y=new Int32Array(d),p=new Float64Array(d);for(let r=0;e.length>r;r++){const o=e[r],c=t.getX(o),u=t.getY(o);if(!isFinite(c)||!isFinite(u))continue;const d=Math.min(Math.floor((c-s)/h),n-1),g=Math.min(Math.floor((u-l)/f),i-1);if(0>d||0>g)continue;const m=g*n+d;y[m]++;const x=a(o);p[m]+=isFinite(x)?x:0}let g=1/0,m=-1/0;for(let t=0;d>t;t++){if(0===y[t])continue;let e;switch(o){case"sum":e=p[t];break;case"mean":e=p[t]/y[t];break;default:e=y[t]}g>e&&(g=e),e>m&&(m=e)}if(!isFinite(g))return[];const x=m-g||1,v=r.width/n,b=r.height/i,k=t.config.showValues,w=t.config.heatmapValueFormat,A=[];for(let e=0;i>e;e++){const r=e*n;for(let a=0;n>a;a++){const n=r+a;if(0===y[n])continue;let c;switch(o){case"sum":c=p[n];break;case"mean":c=p[n]/y[n];break;default:c=y[n]}const u=(c-g)/x,d={xi:a,yi:e,value:c,count:y[n],sum:p[n],xCenter:s+(a+.5)*h,yCenter:l+(e+.5)*f,agg:o};A.push(we(ae(a*v,(i-1-e)*b,v,b,`rgb(${220-(180*u+.5)|0},${220-(100*u+.5)|0},${255-(50*u+.5)|0})`,d,k?{value:c,showValues:!0,valueFormat:w}:void 0),d,t))}}return A}(t,e,r);if(0===e.length)return[];const n=ot(t.config.valueAccessor,"value"),i=at(t.config.xAccessor,"x"),o=at(t.config.yAccessor,"y"),a=new Map,s=new Map,c=Array(e.length),l=Array(e.length);for(let t=0;e.length>t;t++){const r=e[t],n=i(r),u=o(r);c[t]=n,l[t]=u,a.has(n)||a.set(n,a.size),s.has(u)||s.set(u,s.size)}const u=a.size,h=s.size;if(0===u||0===h)return[];const f=Array.from(a.keys()),d=Array.from(s.keys()),y=f.every(t=>"number"==typeof t&&!isNaN(t)),p=d.every(t=>"number"==typeof t&&!isNaN(t));if(y){f.sort((t,e)=>Number(t)-Number(e)),a.clear();for(let t=0;f.length>t;t++)a.set(f[t],t)}if(p){d.sort((t,e)=>Number(t)-Number(e)),s.clear();for(let t=0;d.length>t;t++)s.set(d[t],t)}const g=new Float64Array(e.length),m=new Float64Array(e.length),x=Array(e.length),v=new Map;let b=0;for(let t=0;e.length>t;t++){const r=e[t],i=a.get(c[t]),o=s.get(l[t]);if(void 0===i||void 0===o)continue;const h=n(r),f=o*u+i,d=v.get(f);let y;void 0!==d?y=d:(y=b++,v.set(f,y)),g[y]=f,m[y]=h,x[y]=r}let k=1/0,w=-1/0;for(let t=0;b>t;t++){const e=m[t];isFinite(e)&&(k>e&&(k=e),e>w&&(w=e))}if(!isFinite(k)||!isFinite(w))return[];const A=function(t){const e=t in ut?t:"blues";let r=ke.get(e);if(r)return r;r=Array(256);const n=pt(e);for(let t=0;256>t;t++)r[t]=n(t/255);return ke.set(e,r),r}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),P=255/(w-k||1),S=r.width/u,M=r.height/h,_=t.config.showValues,C=t.config.heatmapValueFormat,L=[];for(let e=0;b>e;e++){const r=m[e];if(!isFinite(r))continue;const n=g[e],i=n%u,o=x[e];L.push(we(ae(i*S,(h-1-(n-i)/u)*M,S,M,A[Math.min((r-k)*P+.5|0,255)],o,_?{value:r,showValues:!0,valueFormat:C}:void 0),o,t))}return L}(i,e,t);case"bar":{const t=function(t,e){if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const r=Ae(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===r.size)return{nodes:[],binBoundaries:[]};let n=null;if(t.getCategory){const e=new Set;for(const t of r.values())for(const r of t.categories.keys())e.add(r);const i=t.config.barColors?Object.keys(t.config.barColors):[],o=new Set(i),a=Array.from(e).filter(t=>!o.has(t)).sort(),s=i.filter(t=>e.has(t)),c=s.join("\0")+""+a.join("\0");t.barCategoryCache&&t.barCategoryCache.key===c?n=t.barCategoryCache.order:(n=[...s,...a],t.barCategoryCache={key:c,order:n})}const i=[],o=t.scales,[a,s]=o.x.domain(),c=t.config.barStyle,l=t.config.themeSemantic?.primary,u=c?.gap,h="number"!=typeof u||0>u?1:u,f={};c?.stroke&&(f.stroke=c.stroke),"number"==typeof c?.strokeWidth&&(f.strokeWidth=c.strokeWidth),"number"==typeof c?.opacity&&(f.opacity=c.opacity);for(const e of r.values()){const r=Math.max(e.start,a),u=Math.min(e.end,s);if(r>=u)continue;const d=o.x(r),y=o.x(u),p=Math.abs(y-d),g=p>h+1?h:0,m=Math.min(d,y)+g/2,x=Math.max(p-g,1);if(x>0)if(n&&e.categories.size>0){let r=0;for(const a of n){const n=e.categories.get(a)||0;if(0===n)continue;const s=o.y(r),u=o.y(r+n);i.push(oe(m,Math.min(s,u),x,Math.abs(s-u),{fill:t.config.barColors?.[a]||c?.fill||l||"#4e79a7",...f},{binStart:e.start,binEnd:e.end,total:e.total,category:a,categoryValue:n},a)),r+=n}}else{const t=o.y(0),r=o.y(e.total);i.push(oe(m,Math.min(t,r),x,Math.abs(t-r),{fill:c?.fill||l||"#007bff",...f},{binStart:e.start,binEnd:e.end,total:e.total}))}}const d=new Set;for(const t of r.values())d.add(t.start),d.add(t.end);return{nodes:i,binBoundaries:Array.from(d).sort((t,e)=>t-e)}}(i,e);return this._barCategoryCache=i.barCategoryCache??null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){const r=[],n=t.config.swarmStyle||{},i=n.radius??3,o=n.fill??t.config.themeSemantic?.primary??"#007bff",a=n.opacity??.7,s=n.stroke,c=n.strokeWidth;for(const n of e){const e=t.getX(n),l=t.getY(n);if(null==l||Number.isNaN(l))continue;const u=t.scales.x(e),h=t.scales.y(l);let f=o;if(t.getCategory){const e=t.getCategory(n);f=t.config.barColors?.[e]||f}const{r:d,...y}=t.config.pointStyle?.(n)??{},p={type:"point",x:u,y:h,r:d??i,style:{fill:f,opacity:a,stroke:s,strokeWidth:c,...y},datum:n};t.getPointId&&(p.pointId=t.getPointId(n)+""),r.push(p)}return r}(i,e);case"waterfall":return function(t,e,r){const n=[],i=t.scales,o=t.config.waterfallStyle,a=e.filter(e=>{const r=t.getY(e),n=t.getX(e);return null!=r&&!Number.isNaN(r)&&null!=n&&isFinite(n)});if(0===a.length)return n;const s=o?.positiveColor??t.config.themeSemantic?.success??"#28a745",c=o?.negativeColor??t.config.themeSemantic?.danger??"#dc3545",l=o?.gap??1,u=o?.stroke,h=o?.strokeWidth,f=o?.opacity;let d=0;for(let e=0;a.length>e;e++){const y=a[e],p=t.getX(y),g=t.getY(y),m=d+g;let x;x=a.length-1>e?t.getX(a[e+1])-p:e>0?p-t.getX(a[e-1]):0;const v=i.x(p),b=0!==x?i.x(p+x):v+r.width/10,k=Math.min(v,b)+l/2,w=Math.max(v,b)-l/2-k;if(0>=w){d=m;continue}const A=i.y(d),P=i.y(m),S=Math.min(A,P),M=Math.abs(A-P),_={fill:0>g?c:s,stroke:u,strokeWidth:h};null!=f&&(_.opacity=f),n.push(oe(k,S,w,M,_,{...y,baseline:d,cumEnd:m,delta:g,_connectorStroke:o?.connectorStroke,_connectorWidth:o?.connectorWidth})),d=m}return n}(i,e,t);case"candlestick":return function(t,e,r){if(!t.getHigh||!t.getLow||!t.scales)return[];const n=t.config.candlestickRangeMode??!1;if(!(n||t.getOpen&&t.getClose))return[];const i=[],o=t.config.candlestickStyle||{},a=o.rangeColor||"#6366f1",s=n?a:o.upColor||"#28a745",c=n?a:o.downColor||"#dc3545",l=n?a:o.wickColor||"#333",u=o.wickWidth||(n?2:1),h=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let f=o.bodyWidth??0;if(null==o.bodyWidth)if(h.length>1){let e=1/0;for(let r=1;h.length>r;r++){const n=Math.abs(t.scales.x(h[r])-t.scales.x(h[r-1]));n>0&&e>n&&(e=n)}f=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else f=6;for(const o of e){const e=t.getX(o);if(null==e||Number.isNaN(e))continue;const a=t.getHigh(o),h=t.getLow(o);if(null==a||Number.isNaN(a)||null==h||Number.isNaN(h))continue;const d=n?a:t.getOpen(o),y=n?h:t.getClose(o);if(!n&&[d,y].some(t=>null==t||Number.isNaN(t)))continue;const p=y>=d,g={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(d),closeY:t.scales.y(y),highY:t.scales.y(a),lowY:t.scales.y(h),bodyWidth:f,upColor:s,downColor:c,wickColor:l,wickWidth:u,isUp:p,datum:o};n&&(g.isRange=!0,g.dotRadius=Math.max(2,Math.min(f/2,.12*r.height))),i.push(g)}return i}(i,e,t);default:return[]}}resolveBoundsStyle(t,e){return function(t,e,r,n){const i=t.boundsStyle;return"function"==typeof i?i(r||{},e):i&&"object"==typeof i?i:{fill:n(e,r).stroke||t.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,stroke:"none"}}(this.config,t,e,(t,e)=>this.resolveLineStyle(t,e))}computeDecayOpacity(t,e){const r=this.config.decay;return r&&e>1?qt(r,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const e=Ut(t);return this._datumIndexCache={version:this._ingestVersion,map:e},e}applyDecay(t,e){this.config.decay&&function(t,e,r,n=Ut(r)){const i=r.length;if(i>1)for(const r of e){if("line"===r.type){const e=Array.isArray(r.datum)?r.datum:[];if(2>e.length)continue;const o=Array(e.length);let a=!1;for(let r=0;e.length>r;r++){const s=n.get(e[r]);null!=s?(o[r]=qt(t,s,i),1>o[r]&&(a=!0)):o[r]=1}a&&(r._decayOpacities=o);continue}if("area"===r.type){const e=Array.isArray(r.datum)?r.datum:[],o=r.topPath?r.topPath.length:e.length;if(2>o)continue;if(e.length===o){const a=Array(o);let s=!1;for(let r=0;e.length>r;r++){const o=n.get(e[r]);null!=o?(a[r]=qt(t,o,i),1>a[r]&&(s=!0)):a[r]=1}s&&(r._decayOpacities=a)}else{let a=1;for(const r of e){const e=n.get(r);if(null!=e){const r=qt(t,e,i);a>r&&(a=r)}}if(1>a){const t=Array(o);t.fill(a),r._decayOpacities=t}}continue}const e=n.get(r.datum);if(null==e)continue;const o=qt(t,e,i);"heatcell"===r.type?r.style={opacity:o}:"candlestick"===r.type?r._decayOpacity=o:r.style={...r.style,opacity:(r.style?.opacity??1)*o}}}(this.config.decay,t,e,this.getDatumIndexMap(e))}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),t)}hasActivePulsesAt(t){return!!this.config.pulse&&Jt(this.config.pulse,this.timestampBuffer,t)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,r,n){r.clear(),n.clear();for(let i=0;e.length>i;i++){const o=e[i],a=Qt(t,o,i);a&&("point"===o.type?r.set(a,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity}):"glyph"===o.type?r.set(a,{x:o.x,y:o.y,r:o.size,opacity:o.style.opacity,glyph:o.glyph}):"rect"===o.type?r.set(a,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity}):"heatcell"===o.type?r.set(a,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style?.opacity}):"candlestick"===o.type?r.set(a,{x:o.x,y:o.openY,w:o.bodyWidth,openY:o.openY,closeY:o.closeY,highY:o.highY,lowY:o.lowY,opacity:o.style?.opacity}):"line"===o.type?n.set(a,{path:o.path.map(t=>[t[0],t[1]]),opacity:o.style?.opacity}):"area"===o.type&&n.set(a,{topPath:o.topPath.map(t=>[t[0],t[1]]),bottomPath:o.bottomPath.map(t=>[t[0],t[1]]),opacity:o.style?.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();const t=this.scales?.y(0)??0;for(let e=0;this.scene.length>e;e++){const r=this.scene[e],n=Qt(this.transitionContext,r,e);n&&("point"===r.type?this.prevPositionMap.set(n,{x:r.x,y:r.y,r:0,opacity:0}):"rect"===r.type?this.prevPositionMap.set(n,{x:r.x,y:t,w:r.w,h:0,opacity:r.style.opacity??1}):"heatcell"===r.type?this.prevPositionMap.set(n,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:0}):"line"===r.type?(r._introClipFraction=0,this.prevPathMap.set(n,{path:r.path.map(t=>[t[0],t[1]]),opacity:r.style.opacity})):"area"===r.type&&(r._introClipFraction=0,this.prevPathMap.set(n,{topPath:r.topPath.map(t=>[t[0],t[1]]),bottomPath:r.bottomPath.map(t=>[t[0],t[1]]),opacity:r.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,r,n,i,o=Y()){if(0===n.size&&0===i.size)return r;const a=e.duration??300;if(r.exitNodes.length>0){const t=new Set(r.exitNodes);r.scene=r.scene.filter(e=>!t.has(e)),r.exitNodes=[]}let s=!1;const c=new Set,l=new Set;for(let e=0;r.scene.length>e;e++){const o=r.scene[e],a=Qt(t,o,e);if(!a)continue;if(o._transitionKey=a,"line"===o.type||"area"===o.type){const t=i.get(a);if(t){if(l.add(a),"line"===o.type&&t.path&&t.path.length===o.path.length){o._targetPath=o.path.map(t=>[t[0],t[1]]),o._prevPath=t.path;for(let e=0;o.path.length>e;e++)o.path[e]=[t.path[e][0],t.path[e][1]];s=!0}else if("area"===o.type&&t.topPath&&t.bottomPath&&t.topPath.length===o.topPath.length&&t.bottomPath.length===o.bottomPath.length){o._targetTopPath=o.topPath.map(t=>[t[0],t[1]]),o._targetBottomPath=o.bottomPath.map(t=>[t[0],t[1]]),o._prevTopPath=t.topPath,o._prevBottomPath=t.bottomPath;for(let e=0;o.topPath.length>e;e++)o.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;o.bottomPath.length>e;e++)o.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];s=!0}o._targetOpacity=o.style.opacity??1,o._startOpacity=t.opacity??o.style.opacity??1}else o._targetOpacity=o.style.opacity??1,o._startOpacity=0,o.style={...o.style,opacity:0},s=!0;continue}const u=n.get(a);if("point"===o.type)if(u){c.add(a);const t={x:o.x,y:o.y,r:o.r};o._targetOpacity=o.style.opacity??1,u.x===t.x&&u.y===t.y&&u.r===t.r||(o._targetX=t.x,o._targetY=t.y,o._targetR=t.r,o.x=u.x,o.y=u.y,o.r=u.r??o.r,s=!0)}else o._targetOpacity=o.style.opacity??1,o.style={...o.style,opacity:0},s=!0;else if("glyph"===o.type)if(u){c.add(a);const t={x:o.x,y:o.y,size:o.size};o._targetOpacity=o.style.opacity??1,u.x===t.x&&u.y===t.y&&u.r===t.size||(o._targetX=t.x,o._targetY=t.y,o._targetR=t.size,o.x=u.x,o.y=u.y,o.size=u.r??o.size,s=!0)}else o._targetOpacity=o.style.opacity??1,o.style={...o.style,opacity:0},s=!0;else if("rect"===o.type)if(u){c.add(a);const t={x:o.x,y:o.y,w:o.w,h:o.h};o._targetOpacity=o.style.opacity??1,u.x===t.x&&u.y===t.y&&u.w===t.w&&u.h===t.h||(o._targetX=t.x,o._targetY=t.y,o._targetW=t.w,o._targetH=t.h,o.x=u.x,o.y=u.y,o.w=u.w??o.w,o.h=u.h??o.h,s=!0)}else o._targetOpacity=o.style.opacity??1,o.style={...o.style,opacity:0},s=!0;else if("heatcell"===o.type)if(u){c.add(a);const t={x:o.x,y:o.y,w:o.w,h:o.h};o._targetOpacity=o.style?.opacity??1,u.x===t.x&&u.y===t.y&&u.w===t.w&&u.h===t.h||(o._targetX=t.x,o._targetY=t.y,o._targetW=t.w,o._targetH=t.h,o.x=u.x,o.y=u.y,o.w=u.w??o.w,o.h=u.h??o.h,s=!0)}else o._targetOpacity=o.style?.opacity??1,o.style={...o.style||{},opacity:0},s=!0;else if("candlestick"===o.type)if(u&&null!=u.openY){c.add(a);const t={x:o.x,openY:o.openY,closeY:o.closeY,highY:o.highY,lowY:o.lowY};o._targetOpacity=o.style?.opacity??1,(u.x!==t.x||u.openY!==t.openY||u.closeY!==t.closeY||u.highY!==t.highY||u.lowY!==t.lowY)&&(o._targetX=t.x,o._targetOpenY=t.openY,o._targetCloseY=t.closeY,o._targetHighY=t.highY,o._targetLowY=t.lowY,o.x=u.x,o.openY=u.openY,o.closeY=u.closeY??o.closeY,o.highY=u.highY??o.highY,o.lowY=u.lowY??o.lowY,s=!0)}else o._targetOpacity=o.style?.opacity??1,o.style={...o.style||{},opacity:0},s=!0}for(const[t,e]of i)if(!l.has(t))if(t.startsWith("l:")&&e.path){const n={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t,datum:null};r.exitNodes.push(n),s=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const n={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t,datum:null};r.exitNodes.push(n),s=!0}for(const[t,e]of n)if(!c.has(t)){if(t.startsWith("p:"))r.exitNodes.push({type:"point",x:e.x,y:e.y,r:e.r??3,style:{opacity:e.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("g:")&&e.glyph)r.exitNodes.push({type:"glyph",x:e.x,y:e.y,size:e.r??12,glyph:e.glyph,color:"#999",accent:"#999",style:{opacity:e.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))r.exitNodes.push({type:"rect",x:e.x,y:e.y,w:e.w??0,h:e.h??0,style:{opacity:e.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("h:"))r.exitNodes.push({type:"heatcell",x:e.x,y:e.y,w:e.w??0,h:e.h??0,fill:"#999",datum:null,style:{opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t});else if(t.startsWith("c:")){const n=e.openY??e.y;r.exitNodes.push({type:"candlestick",x:e.x,openY:n,closeY:e.closeY??n,highY:e.highY??n,lowY:e.lowY??n,bodyWidth:e.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t})}s=!0}return r.exitNodes.length>0&&(r.scene=[...r.scene,...r.exitNodes]),s&&(r.activeTransition={startTime:o,duration:a}),r}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap,this.currentTime());this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},r=function(t,e,r,n){if(!r.activeTransition)return!1;const i=P(t,r.activeTransition),o=A(i,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of r.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const r=e?n.get(e):void 0;t.style.opacity=R(r?r.opacity??1:0,t._targetOpacity,o)}if(void 0===t._targetX)continue;if(!e)continue;const r=n.get(e);if(!r)continue;t.x=R(r.x,t._targetX,o),t.y=R(r.y,t._targetY,o),void 0!==t._targetR&&void 0!==r.r&&(t.r=R(r.r,t._targetR,o))}else if("glyph"===t.type){if(void 0!==t._targetOpacity){const r=e?n.get(e):void 0;t.style.opacity=R(r?r.opacity??1:0,t._targetOpacity,o)}if(void 0===t._targetX)continue;if(!e)continue;const r=n.get(e);if(!r)continue;t.x=R(r.x,t._targetX,o),t.y=R(r.y,t._targetY,o),void 0!==t._targetR&&void 0!==r.r&&(t.size=R(r.r,t._targetR,o))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const r=e?n.get(e):void 0;t.style.opacity=R(r?r.opacity??1:0,t._targetOpacity,o)}if(void 0===t._targetX)continue;if(!e)continue;const r=n.get(e);if(!r)continue;t.x=R(r.x,t._targetX,o),t.y=R(r.y,t._targetY,o),void 0!==r.w&&(t.w=R(r.w,t._targetW,o)),void 0!==r.h&&(t.h=R(r.h,t._targetH,o))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const r=e?n.get(e):void 0;t.style={...t.style||{},opacity:R(r?r.opacity??1:0,t._targetOpacity,o)}}if(void 0===t._targetX)continue;if(!e)continue;const r=n.get(e);if(!r)continue;t.x=R(r.x,t._targetX,o),t.y=R(r.y,t._targetY,o),void 0!==r.w&&(t.w=R(r.w,t._targetW,o)),void 0!==r.h&&(t.h=R(r.h,t._targetH,o))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const r=e?n.get(e):void 0;t.style={...t.style||{},opacity:R(r?r.opacity??1:0,t._targetOpacity,o)}}if(void 0===t._targetX)continue;if(!e)continue;const r=n.get(e);if(!r)continue;t.x=R(r.x,t._targetX,o),void 0!==r.openY&&(t.openY=R(r.openY,t._targetOpenY,o)),void 0!==r.closeY&&(t.closeY=R(r.closeY,t._targetCloseY,o)),void 0!==r.highY&&(t.highY=R(r.highY,t._targetHighY,o)),void 0!==r.lowY&&(t.lowY=R(r.lowY,t._targetLowY,o))}else if("line"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:R(t._startOpacity??0,t._targetOpacity,o)}),void 0!==t._introClipFraction&&(t._introClipFraction=o);const e=t._prevPath,r=t._targetPath;if(e&&r&&e.length===t.path.length)for(let n=0;t.path.length>n;n++)t.path[n][0]=R(e[n][0],r[n][0],o),t.path[n][1]=R(e[n][1],r[n][1],o)}else if("area"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:R(t._startOpacity??0,t._targetOpacity,o)}),void 0!==t._introClipFraction&&(t._introClipFraction=o);const e=t._prevTopPath,r=t._prevBottomPath,n=t._targetTopPath,i=t._targetBottomPath;if(e&&n&&e.length===t.topPath.length)for(let r=0;t.topPath.length>r;r++)t.topPath[r][0]=R(e[r][0],n[r][0],o),t.topPath[r][1]=R(e[r][1],n[r][1],o);if(r&&i&&r.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=R(r[e][0],i[e][0],o),t.bottomPath[e][1]=R(r[e][1],i[e][1],o)}}if(i>=1){for(const t of r.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style="line"===t.type||"area"===t.type?{...t.style,opacity:0===e?0:e}:{...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("glyph"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.size=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("candlestick"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let r=0;t.path.length>r;r++)t.path[r]=e[r];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,r=t._targetBottomPath;if(e)for(let r=0;t.topPath.length>r;r++)t.topPath[r]=e[r];if(r)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=r[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(r.exitNodes.length>0){const t=new Set(r.exitNodes);r.scene=r.scene.filter(e=>!t.has(e)),r.exitNodes=[]}return r.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,r}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const t of this.scene)"line"!==t.type&&"area"!==t.type||(t._introClipFraction=void 0)}groupData(t){const{result:e,cache:r}=function(t,e,r,n){if(n&&n.version===r&&n.group===e&&n.data===t)return{result:n.result,cache:n};let i;if(e){const r=new Map;for(const n of t){const t=e(n);r.has(t)||r.set(t,[]),r.get(t).push(n)}i=Array.from(r.entries()).map(([t,e])=>({key:t,data:e}))}else i=[{key:"_default",data:t}];return{result:i,cache:{version:r,group:e,data:t,result:i}}}(t,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=r,e}resolveColorMap(t){const{map:e,cache:r}=function(t,e,r,n,i){if(i&&i.version===n)return{map:i.map,cache:i};const o=new Set;if(e)for(const r of t){const t=e(r);t&&o.add(t)}const a=Array.from(o).sort(),s=a.join("\0");if(i&&i.key===s){const t={...i,version:n};return{map:t.map,cache:t}}const c=Array.isArray(r.colorScheme)?r.colorScheme:r.themeCategorical||d,l=new Map;for(let t=0;a.length>t;t++)l.set(a[t],c[t%c.length]);return{map:l,cache:{key:s,map:l,version:n}}}(t,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=r,e}resolveLineStyle(t,e){return function(t,e,r,n){const i=t.lineStyle;if("function"==typeof i){const t=i(r||{},e);if(t&&!t.stroke&&e){const r=n(e);if(r)return{...t,stroke:r}}return t}const o=t.themeSemantic?.primary;return i&&"object"==typeof i?{stroke:i.stroke||o||"#007bff",strokeWidth:i.strokeWidth||2,strokeDasharray:i.strokeDasharray,fill:i.fill,fillOpacity:i.fillOpacity,opacity:i.opacity}:{stroke:n(e)||o||"#007bff",strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveAreaStyle(t,e){return function(t,e,r,n){if(t.areaStyle){const i=t.areaStyle(r||{});if(i&&!i.fill&&e){const t=n(e);if(t)return{...i,fill:t,stroke:i.stroke||t}}return i}const i=t.lineStyle;if("function"==typeof i){const t=i(r||{},e);if(t&&!t.fill&&e){const r=n(e);if(r)return{...t,fill:r,stroke:t.stroke||r}}return t}const o=t.themeSemantic?.primary;if(i&&"object"==typeof i)return{fill:i.fill||i.stroke||o||"#4e79a7",fillOpacity:i.fillOpacity??.7,stroke:i.stroke||o||"#4e79a7",strokeWidth:i.strokeWidth||2};const a=n(e)||o||"#4e79a7";return{fill:a,fillOpacity:.7,stroke:a,strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveGroupColor(t){const{color:e,groupColorCounter:n}=function(t){const{group:e,colorMapCache:r,groupColorMap:n,groupColorMapCap:i,config:o}=t;let{groupColorCounter:a}=t;if(r){const t=r.map.get(e);if(t)return{color:t,groupColorCounter:a}}const s=n.get(e);if(s)return{color:s,groupColorCounter:a};const c=(Array.isArray(o.colorScheme)&&o.colorScheme.length>0?o.colorScheme:null)||(Array.isArray(o.themeCategorical)&&o.themeCategorical.length>0?o.themeCategorical:null)||d;if(0===c.length)return{color:null,groupColorCounter:a};const l=c[a%c.length];if(a++,n.set(e,l),n.size>i){const t=n.keys().next().value;void 0!==t&&n.delete(t)}return{color:l,groupColorCounter:a}}({group:t,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:r.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=n,e}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=Vt(t),r=this.getPointId,n=t=>e.has(r(t));Oe(this.buffer,this.timestampBuffer,n);const i=this.buffer.remove(n);if(0===i.length)return this.updateResults.recordNoop("remove"),i;for(const t of i)this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",i.length),i}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const r=Vt(t),n=this.getPointId,i=new Set;this.buffer.forEach((t,e)=>{r.has(n(t))&&i.add(e)});const o=this.buffer.update(t=>r.has(n(t)),e);if(0===o.length)return this.updateResults.recordNoop("update"),o;for(const t of o)this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t);return this.buffer.forEach((t,e)=>{i.has(e)&&(this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",o.length),o}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this._datumIndexCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.spatialIndex.clear(),this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}applyCustomRestyle(t,e){const r=this._customRestyle;if(r)for(const n of t){const t=this._baseStyles.get(n)??n.style??{},i=r(n,e);n.style=i?{...t,...i}:t}}restyleScene(t){this._customRestyle?(this.applyCustomRestyle(this.scene,t),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(t){const e={...this.config},r=Object.keys(t).filter(r=>t[r]!==e[r]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in t&&t.windowSize!==e.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${e.windowSize} → ${t.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"boundsAccessor"in t||"band"in t||"y0Accessor"in t||"openAccessor"in t||"highAccessor"in t||"lowAccessor"in t||"closeAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(this._stackExtentCache=null);let n=!1,i=!1;Object.assign(this.config,t),"pulse"in t&&this.syncPulseTimestampBuffer();const o="chartType"in t&&t.chartType!==e.chartType||"runtimeMode"in t&&t.runtimeMode!==e.runtimeMode;if(o||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const t=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,r=t&&this.config.valueAccessor||this.config.yAccessor,a=t&&e.valueAccessor||e.yAccessor,s=o||!K(t&&this.config.timeAccessor||this.config.xAccessor,t&&e.timeAccessor||e.xAccessor),c=o||!K(r,a);(s||c)&&(t?(this.getX=ot(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=ot(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=ot(this.config.xAccessor,"x"),this.getY=ot(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(t=>"bounds"===t.kind)&&(this.resolvedRibbons=Le(this.config)),n=!0,i=!0)}if("groupAccessor"in t&&!K(t.groupAccessor,e.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?st(this.config.groupAccessor):void 0,n=!0),"categoryAccessor"in t&&!K(t.categoryAccessor,e.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?st(this.config.categoryAccessor):void 0,n=!0),"sizeAccessor"in t&&!K(t.sizeAccessor,e.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?ot(this.config.sizeAccessor,"size"):void 0,n=!0),"symbolAccessor"in t&&!K(t.symbolAccessor,e.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?st(this.config.symbolAccessor):void 0,n=!0),"colorAccessor"in t&&!K(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?st(this.config.colorAccessor):void 0,n=!0),"y0Accessor"in t&&!K(t.y0Accessor,e.y0Accessor)&&(this.getY0=this.config.y0Accessor?ot(this.config.y0Accessor,"y0"):void 0,n=!0,i=!0),("boundsAccessor"in t&&!K(t.boundsAccessor,e.boundsAccessor)||"band"in t&&t.band!==e.band||"boundsStyle"in t&&t.boundsStyle!==e.boundsStyle)&&(this.resolvedRibbons=Le(this.config),n=!0,i=!0),"pointIdAccessor"in t&&!K(t.pointIdAccessor,e.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?st(this.config.pointIdAccessor):void 0,n=!0),"candlestick"===this.config.chartType&&(o||"openAccessor"in t&&!K(t.openAccessor,e.openAccessor)||"closeAccessor"in t&&!K(t.closeAccessor,e.closeAccessor)||"highAccessor"in t&&!K(t.highAccessor,e.highAccessor)||"lowAccessor"in t&&!K(t.lowAccessor,e.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?ot(this.config.openAccessor,"open"):void 0,this.getHigh=ot(this.config.highAccessor,"high"),this.getLow=ot(this.config.lowAccessor,"low"),this.getClose=e?ot(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,n=!0,i=!0}if("accessorRevision"in t&&t.accessorRevision!==e.accessorRevision&&(n=!0,i=!0),!n){const r=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const i of r)if(t[i]!==e[i]){n=!0;break}}n&&(i&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(r)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}};lr.GROUP_COLOR_MAP_CAP=1e3;var ur=lr;Ve(ur);import*as hr from"react";function fr(...t){const e=t.filter(t=>null!=t);return 0===e.length?null:1===e.length?e[0]:hr.createElement(hr.Fragment,null,...e)}import{useEffect as dr,useRef as yr}from"react";function pr(t,e,r,n){dr(()=>{t.current?.updateConfig(e),r.current=!0,n()},[e,n,t,r])}function gr(t,e,r,n){const i=yr(null);dr(()=>{const o=t.current;if(!o)return;const a=e??null;i.current!==a&&(i.current=a,o.setLayoutSelection(a),o.hasCustomRestyle?o.restyleScene(a):r.current=!0,n())},[e,n,t,r])}function mr(t,e,n,i,o,a=t=>t.x,s=t=>t.y,c=t=>t.r){const l=Math.max(i,o+5,12),u=e-l,h=e+l,f=n-l,d=n+l;let y=null,p=1/0;return t.visit((t,o,l,g,m)=>{if(o>h||u>g||l>d||f>m)return!0;if(!t.length){let o=t;do{const t=o.data,l=a(t)-e,u=s(t)-n,h=Math.sqrt(l*l+u*u);r(c(t),i)>=h&&p>h&&(y=t,p=h),o=o.next}while(o)}return!1}),y?{node:y,distance:p}:null}import{line as xr}from"d3-shape";var vr=new WeakMap;function br(t,e){const r=F(e);if(!r)return t;const n=vr.get(t);if(n)return n;const i=function(t,e,r=8){if(!e||2>t.length)return t.map(([t,e])=>[t,e]);const n=[];let i=null;const o={moveTo(t,e){i=[t,e],n.push([t,e])},lineTo(t,e){i=[t,e],n.push([t,e])},bezierCurveTo(t,e,o,a,s,c){if(!i)return i=[s,c],void n.push([s,c]);const[l,u]=i;for(let i=1;r>=i;i++){const h=i/r,f=1-h;n.push([f*f*f*l+3*f*f*h*t+3*f*h*h*o+h*h*h*s,f*f*f*u+3*f*f*h*e+3*f*h*h*a+h*h*h*c])}i=[s,c]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(t,e,r,o){i=[r,o],n.push([r,o])}};return xr().x(t=>t[0]).y(t=>t[1]).curve(e).context(o)(t),n}(t,r);return vr.set(t,i),i}function kr(t,e,r,n=30,i,o=0){let a=null;if(i){const t=mr(i,e,r,n,o);t&&(a={node:t.node,datum:t.node.datum,x:t.node.x,y:t.node.y,distance:t.distance})}for(const o of t){let t=null;switch(o.type){case"point":if(i)break;t=Ar(o,e,r,n);break;case"symbol":t=Pr(o,e,r,n);break;case"glyph":t=Sr(o,e,r,n);break;case"line":t=Mr(o,e,r,n);break;case"rect":if(null==o.datum)break;t=Cr(o,e,r);break;case"heatcell":t=Lr(o,e,r);break;case"area":if(!1===o.interactive)break;t=Dr(o,e,r);break;case"candlestick":t=Tr(o,e,r)}t&&n>t.distance&&(a&&t.distance>=a.distance||(a=t))}return a}function wr(t,e,r){if(0===t.length)return null;if(t[0][0]>e||e>t[t.length-1][0])return null;const n=Er(t,e);if(0>n)return null;if(Math.abs(t[n][0]-e)>r)return null;let i=n,o=n;n>0&&t[n][0]>=e?(i=n-1,o=n):t.length-1>n&&(i=n,o=n+1);const[a,s]=t[i],[c,l]=t[o];return c===a?s:s+Math.max(0,Math.min(1,(e-a)/(c-a)))*(l-s)}function Ar(t,e,n,i=30){const o=e-t.x,a=n-t.y,s=Math.sqrt(o*o+a*a);return s>r(t.r,i)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function Pr(t,e,n,i=30){const o=e-t.x,a=n-t.y,s=Math.sqrt(o*o+a*a);return s>r(kt(t.size),i)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:s}}function Sr(t,e,n,i=30){if(null==t.datum)return null;const o=mt(t.glyph,t.size),a=t.x+o.centerDx,s=t.y+o.centerDy,c=e-a,l=n-s,u=Math.sqrt(c*c+l*l);return u>r(o.radius,i)?null:{node:t,datum:t.datum,x:a,y:s,distance:u}}function Mr(t,e,r,n=30){if(0===t.path.length)return null;const i=Er(t.path,e);if(0>i)return null;const[o,a]=t.path[i];let s;if(t.path.length>1){let n=1/0;const o=Math.max(0,i-1),a=Math.min(t.path.length-2,i);for(let i=o;a>=i;i++){const[o,a]=t.path[i],[s,c]=t.path[i+1],l=_r(e,r,o,a,s,c);n>l&&(n=l)}s=n}else{const t=e-o,n=r-a;s=Math.sqrt(t*t+n*n)}const c=t.style;return s>Math.max(5,(c.strokeWidth??c.lineWidth??1)/2+2,n)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[i]?t.datum[i]:t.datum,x:o,y:a,distance:s}}function _r(t,e,r,n,i,o){const a=i-r,s=o-n,c=a*a+s*s;if(0===c)return Math.sqrt((t-r)**2+(e-n)**2);let l=((t-r)*a+(e-n)*s)/c;return l=Math.max(0,Math.min(1,l)),Math.sqrt((t-(r+l*a))**2+(e-(n+l*s))**2)}function Cr(t,e,r){const i=n(e,r,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function Lr(t,e,r){const i=n(e,r,t);return i.hit?{node:t,datum:t.datum,x:i.cx,y:i.cy,distance:0}:null}function Tr(t,e,r){const n=t.bodyWidth/2,i=Math.min(t.openY,t.closeY);if(!(t.x-n-3>e||e>t.x+n+3||t.highY-3>r||r>t.lowY+3)){const n=i+Math.max(Math.max(t.openY,t.closeY)-i,1)/2,o=e-t.x,a=r-n;return{node:t,datum:t.datum,x:t.x,y:n,distance:Math.sqrt(o*o+a*a)}}return null}function Dr(t,e,r){if(0===t.topPath.length)return null;const n=Er(t.topPath,e);if(0>n)return null;const[i,o]=t.topPath[n],a=e-i,s=r-o,c=Math.sqrt(a*a+s*s);return{node:t,datum:Array.isArray(t.datum)&&t.datum[n]?t.datum[n]:t.datum,x:i,y:o,distance:c}}function Er(t,e){if(0===t.length)return-1;let r=0,n=t.length-1;for(;n>r;){const i=r+n>>1;e>t[i][0]?r=i+1:n=i}return r>0&&Math.abs(t[r][0]-e)>=Math.abs(t[r-1][0]-e)?r-1:r}import{useEffect as Rr,useRef as Yr}from"react";var Nr={fresh:1,aging:.7,stale:.45,expired:.25},$r={alpha:1,band:"fresh",isStale:!1};function Wr(t,e){if(!t||0>=e)return $r;const r=null!=t.threshold&&t.threshold>0?t.threshold:5e3,n=t.graded;if(n){const t="object"==typeof n?n:{},i=Z(e,r,t.thresholds);return{alpha:{...Nr,...t.opacities??{}}[i],band:i,isStale:"fresh"!==i}}return e>r?{alpha:t.dimOpacity??.5,band:"stale",isStale:!0}:$r}function Ir(t,e,r,n,i,o){const a=Yr("fresh");Rr(()=>{if(!t)return;const s=setInterval(()=>{const s=e.current;if(!s||0===s.lastIngestTime)return;const c="undefined"!=typeof performance?performance.now():Date.now(),l=Wr(t,c-s.lastIngestTime);l.band===a.current&&l.isStale===i||(a.current=l.band,l.isStale!==i&&o(l.isStale),r.current=!0,n())},1e3);return()=>clearInterval(s)},[t,i,n,e,o,r])}import{jsx as Or}from"react/jsx-runtime";function Fr({isStale:t,position:e}){return Or("div",{className:"stream-staleness-badge",style:{position:"absolute",..."top-left"===e?{top:4,left:4}:"bottom-left"===e?{bottom:4,left:4}:"bottom-right"===e?{bottom:4,right:4}:{top:4,right:4},padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:t?"#dc3545":"#28a745",color:"white"},children:t?"STALE":"LIVE"})}import{useMemo as zr,useRef as Br,useEffect as Xr}from"react";import{useMemo as jr}from"react";import{bin as Gr}from"d3-array";import{jsx as Hr,jsxs as Vr}from"react/jsx-runtime";function qr(t){return"string"==typeof t?{type:t}:t}function Ur({orient:t,config:e,values:r,scale:n,size:i,length:o}){const a=function(t){return{type:t.type,bins:t.bins??20,fill:t.fill??"#4e79a7",fillOpacity:t.fillOpacity??.5,stroke:t.stroke??"none",strokeWidth:t.strokeWidth??1}}(e),s="top"===t||"bottom"===t,c=jr(()=>{if(0===r.length)return null;const e=n.domain(),c=i-8;if("boxplot"===a.type){const e=function(t){const e=[...t].sort((t,e)=>t-e),r=e.length;if(0===r)return null;const n=e[Math.floor(.25*r)],i=e[Math.floor(.5*r)],o=e[Math.floor(.75*r)],a=o-n;return{q1:n,median:i,q3:o,whiskerLow:Math.max(e[0],n-1.5*a),whiskerHigh:Math.min(e[r-1],o+1.5*a)}}(r);if(!e)return null;const{q1:i,median:o,q3:l,whiskerLow:u,whiskerHigh:h}=e,f=Math.min(.5*c,20),d=(c-f)/2+4;if(s){const e=n(i),r=n(l),s=n(o),c=n(u),y=n(h),p="top"===t?-1:1,g=0;return Vr("g",{"data-testid":"marginal-boxplot-"+t,children:[Hr("line",{x1:c,y1:g+p*(d+f/2),x2:y,y2:g+p*(d+f/2),stroke:a.fill,strokeWidth:a.strokeWidth}),Hr("line",{x1:c,y1:g+p*d,x2:c,y2:g+p*(d+f),stroke:a.fill,strokeWidth:a.strokeWidth}),Hr("line",{x1:y,y1:g+p*d,x2:y,y2:g+p*(d+f),stroke:a.fill,strokeWidth:a.strokeWidth}),Hr("rect",{x:Math.min(e,r),y:"top"===t?g-d-f:g+d,width:Math.abs(r-e),height:f,fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}),Hr("line",{x1:s,y1:"top"===t?g-d-f:g+d,x2:s,y2:"top"===t?g-d:g+d+f,stroke:a.fill,strokeWidth:2})]})}{const e=n(i),r=n(l),s=n(o),c=n(u),y=n(h),p="left"===t?-1:1,g=0;return Vr("g",{"data-testid":"marginal-boxplot-"+t,children:[Hr("line",{x1:g+p*(d+f/2),y1:c,x2:g+p*(d+f/2),y2:y,stroke:a.fill,strokeWidth:a.strokeWidth}),Hr("line",{x1:g+p*d,y1:c,x2:g+p*(d+f),y2:c,stroke:a.fill,strokeWidth:a.strokeWidth}),Hr("line",{x1:g+p*d,y1:y,x2:g+p*(d+f),y2:y,stroke:a.fill,strokeWidth:a.strokeWidth}),Hr("rect",{x:"left"===t?g-d-f:g+d,y:Math.min(e,r),width:f,height:Math.abs(r-e),fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth}),Hr("line",{x1:"left"===t?g-d-f:g+d,y1:s,x2:"left"===t?g-d:g+d+f,y2:s,stroke:a.fill,strokeWidth:2})]})}}const l=Gr().domain(e).thresholds(a.bins)(r);if(0===l.length)return null;const u=wt(l.map(t=>t.length));if(0===u)return null;if("histogram"===a.type)return Hr("g",{"data-testid":"marginal-histogram-"+t,children:l.map((e,r)=>{if(null==e.x0||null==e.x1)return null;const i=e.length/u*c;if(s){const o=n(e.x0),s=n(e.x1)-n(e.x0);return Hr("rect",{x:o,y:"top"===t?-4-i:4,width:Math.max(s,.5),height:i,fill:a.fill,fillOpacity:a.fillOpacity,stroke:a.stroke,strokeWidth:a.strokeWidth},r)}{const o=n(e.x0),s=n(e.x1)-n(e.x0);return Hr("rect",{x:"left"===t?-4-i:4,y:Math.min(o,o+s),width:i,height:Math.abs(s),fill:a.fill,fillOpacity:a.fillOpacity,stroke:a.stroke,strokeWidth:a.strokeWidth},r)}})});if("violin"===a.type){const e=c/2+4,r=[];for(const i of l){if(null==i.x0||null==i.x1)continue;const o=i.length/u*(c/2),a=n((i.x0+i.x1)/2);r.push(s?`${a},${"top"===t?-(e-o):e-o}`:`${"left"===t?-(e-o):e-o},${a}`)}for(let i=l.length-1;i>=0;i--){const o=l[i];if(null==o.x0||null==o.x1)continue;const a=o.length/u*(c/2),h=n((o.x0+o.x1)/2);r.push(s?`${h},${"top"===t?-(e+a):e+a}`:`${"left"===t?-(e+a):e+a},${h}`)}return Hr("g",{"data-testid":"marginal-violin-"+t,children:Hr("polygon",{points:r.join(" "),fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth})})}if("ridgeline"===a.type){const e=[];if(s){const r=0,i=null!=l[0].x0?n(l[0].x0):0;e.push(`M${i},${r}`);for(const r of l){if(null==r.x0||null==r.x1)continue;const i=r.length/u*c,o=n((r.x0+r.x1)/2);e.push(`L${o},${"top"===t?-i-4:i+4}`)}const a=null!=l[l.length-1].x1?n(l[l.length-1].x1):o;e.push(`L${a},${r}`),e.push("Z")}else{const r=0,i=null!=l[0].x0?n(l[0].x0):0;e.push(`M${r},${i}`);for(const r of l){if(null==r.x0||null==r.x1)continue;const i=r.length/u*c,o=n((r.x0+r.x1)/2);e.push(`L${"left"===t?-i-4:i+4},${o}`)}const a=null!=l[l.length-1].x1?n(l[l.length-1].x1):o;e.push(`L${r},${a}`),e.push("Z")}return Hr("g",{"data-testid":"marginal-ridgeline-"+t,children:Hr("path",{d:e.join(" "),fill:a.fill,fillOpacity:a.fillOpacity,stroke:"none"===a.stroke?a.fill:a.stroke,strokeWidth:a.strokeWidth})})}return null},[r,n,a,i,o,t,s,4]);return c?Hr("g",{className:"marginal-"+t,"data-testid":"marginal-"+t,children:c}):null}function Kr(t,e,r){return"exact"===r?function(t,e){const r=t.domain(),n=r[0],i=r[r.length-1],o=n instanceof Date,a=n instanceof Date?n.getTime():n,s=i instanceof Date?i.getTime():i;if(2>e||a===s)return o?[new Date(a),new Date(s)]:[a,s];const c=(s-a)/(e-1),l=Array(e);for(let t=0;e>t;t++){const r=t===e-1?s:a+t*c;l[t]=o?new Date(r):r}return l}(t,e):t.ticks(e)}function Zr(t,e,r){if("edges"===t){if(e)return"start";if(r)return"end"}return"middle"}function Jr(t,e,r){if("edges"===t){if(e)return"hanging";if(r)return"auto"}return"middle"}function Qr(t){if(0===t.length)return{min:null,max:null};let e=1/0,r=-1/0;for(const n of t)e>n.pixel&&(e=n.pixel),n.pixel>r&&(r=n.pixel);return{min:e,max:r}}function tn(t){if(t)return"dashed"===t?"6,4":"dotted"===t?"2,4":t}function en(t,e,r){if("left"===t||"right"===t){const n="left"===t?r:0,i="left"===t?-1:1,o=Math.ceil(e/8);let a="M0,"+n;for(let t=0;o>t;t++){const r=8*(t+1);a+=`L${Math.min(8*t+4,e)},${n+4*i}`,a+=`L${Math.min(r,e)},${n}`}return a}const n="bottom"===t?0:e,i="bottom"===t?1:-1,o=Math.ceil(r/8);let a=`M${n},0`;for(let t=0;o>t;t++){const e=8*(t+1);a+=`L${n+4*i},${Math.min(8*t+4,r)}`,a+=`L${n},${Math.min(e,r)}`}return a}import{Fragment as rn,jsx as nn,jsxs as on}from"react/jsx-runtime";function an(t){const{width:e,height:r,totalWidth:n,totalHeight:i,margin:o,scales:a,showAxes:s,axes:c,showGrid:l,xFormat:u,yFormat:h,axisExtent:f}=t,d=zr(()=>{if(!a)return[];const t=c?.find(t=>"bottom"===t.orient),r=t?.tickFormat||u||sn,n=Math.max(2,Math.floor(e/70)),i=t?.ticks??5,o="exact"===f?Math.max(2,i):Math.min(i,n),s=t?.tickValues??Kr(a.x,o,f),l=s.map(t=>t.valueOf()),h=s.map((t,e)=>({value:t,pixel:a.x(t),label:r(t,e,l)})),d=h.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0);return cn(h,Math.max(55,d+8))},[a,c,u,e,f]),y=zr(()=>{if(!a)return[];const t=c?.find(t=>"left"===t.orient),e=t?.tickFormat||h||sn,n=Math.max(2,Math.floor(r/30)),i=t?.ticks??5,o="exact"===f?Math.max(2,i):Math.min(i,n);return cn((t?.tickValues??Kr(a.y,o,f)).map(t=>({value:t,pixel:a.y(t),label:e(t)})),22)},[a,c,h,r,f]),p=l&&a,g=s&&a;if(!p&&!g)return null;const m=c?.find(t=>"bottom"===t.orient),x=c?.find(t=>"left"===t.orient),v=g&&(!m||!1!==m.baseline),b=g&&(!x||!1!==x.baseline),k=m?.jaggedBase||!1,w=x?.jaggedBase||!1,A="var(--semiotic-border, #ccc)";return nn("svg",{width:n,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:on("g",{transform:`translate(${o.left},${o.top})`,children:[p&&(()=>{const t=tn(c?.find(t=>"bottom"===t.orient)?.gridStyle),n=tn(c?.find(t=>"left"===t.orient)?.gridStyle);return on("g",{className:"stream-grid",children:[d.map((e,n)=>nn("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:r,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:t},"xgrid-"+n)),y.map((t,r)=>nn("line",{x1:0,y1:t.pixel,x2:e,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:n},"ygrid-"+r))]})})(),v&&!k&&nn("line",{x1:0,y1:r,x2:e,y2:r,stroke:A,strokeWidth:1}),k&&nn("path",{d:en("bottom",e,r),fill:"none",stroke:A,strokeWidth:1}),b&&!w&&nn("line",{x1:0,y1:0,x2:0,y2:r,stroke:A,strokeWidth:1}),w&&nn("path",{d:en("left",e,r),fill:"none",stroke:A,strokeWidth:1})]})})}function sn(t,e,r){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function cn(t,e){if(2>=t.length)return t;const r=[t[0]];for(let n=1;t.length-1>n;n++)e>Math.abs(t[n].pixel-r[r.length-1].pixel)||r.push(t[n]);const n=t[t.length-1];return e>Math.abs(n.pixel-r[r.length-1].pixel)?r[r.length-1]=n:r.push(n),r}function ln(t){const{width:e,height:r,totalWidth:n,totalHeight:o,margin:a,scales:s,showAxes:c,axes:l,xLabel:u,yLabel:h,yLabelRight:f,xFormat:d,yFormat:y,axisExtent:p,showGrid:g,title:x,legend:v,legendHoverBehavior:b,legendClickBehavior:k,legendHighlightedCategory:w,legendIsolatedCategories:A,legendPosition:P="right",legendLayout:M,foregroundGraphics:_,marginalGraphics:C,xValues:L,yValues:T,annotations:D,onAnnotationActivate:E,onObservation:R,chartId:Y,chartType:N,autoPlaceAnnotations:$,svgAnnotationRules:O,xAccessor:F,yAccessor:j,annotationData:G,pointNodes:H,curve:V,underlayRendered:q,canvasObscuresUnderlay:U=!0,linkedCrosshairName:K,linkedCrosshairSourceId:Z,children:J}=t,Q=lt({onAnnotationActivate:E,onObservation:R,chartId:Y,chartType:N}),tt=z(M),rt=v&&"left"===P&&tt>0?tt:a.left,nt=v&&"right"===P&&tt>0?tt:a.right,it=zr(()=>{if(!c||!s)return[];const t=l?.find(t=>"bottom"===t.orient),r=t?.tickFormat||d||sn,n=Math.max(2,Math.floor(e/70)),i=t?.ticks??5,o="exact"===p?Math.max(2,i):Math.min(i,n),a=t?.tickValues??Kr(s.x,o,p),u=a.map(t=>t.valueOf()),h=a.map((t,e)=>({value:t,pixel:s.x(t),label:r(t,e,u)})),f=h.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0),y=t?.autoRotate?Math.max(20,Math.min(f+8,55)):Math.max(55,f+8);let g=cn(h,y);if(g.length>1&&(g=g.filter((t,e)=>0===e||t.label+""!=g[e-1].label+"")),t?.includeMax&&g.length>0&&"exact"!==p&&!t?.tickValues){const t=s.x.domain()[1],e=s.x(t),n=g[g.length-1].pixel;if(Math.abs(e-n)>1){const i=r(t,g.length,u);y>e-n&&g.length>1&&(g=g.slice(0,-1)),g.push({value:t,pixel:e,label:i})}}return g},[c,s,l,d,e,p]),ot=zr(()=>{if(!c||!s)return[];const t=l?.find(t=>"left"===t.orient),e=t?.tickFormat||y||sn,n=Math.max(2,Math.floor(r/30)),i=t?.ticks??5,o="exact"===p?Math.max(2,i):Math.min(i,n);let a=cn((t?.tickValues??Kr(s.y,o,p)).map(t=>({value:t,pixel:s.y(t),label:e(t)})),22);if(a.length>1&&(a=a.filter((t,e)=>0===e||t.label+""!=a[e-1].label+"")),t?.includeMax&&a.length>0&&"exact"!==p&&!t?.tickValues){const t=s.y.domain()[1],r=s.y(t),n=a[a.length-1].pixel;if(Math.abs(r-n)>1){const i=e(t);22>Math.abs(r-n)&&a.length>1&&(a=a.slice(0,-1)),a.push({value:t,pixel:r,label:i})}}return a},[c,s,l,y,r,p]),at=zr(()=>{if(!c||!s)return[];const t=l?.find(t=>"right"===t.orient);if(!t)return[];const e=t.tickFormat||y||sn,n=Math.max(2,Math.floor(r/30)),i=t.ticks??5;return cn((t.tickValues??Kr(s.y,"exact"===p?Math.max(2,i):Math.min(i,n),p)).map(t=>({value:t,pixel:s.y(t),label:e(t)})),22)},[c,s,l,y,r,p]),st=Br(new Map),ct=Br(D?.length??0),ut=D?.length??0;ct.current!==ut&&(ct.current=ut,st.current=new Map);const ht=zr(()=>{if(!D||0===D.length)return null;const t=et(D),n=S("xy",Q),i={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:F,yAccessor:j,width:e,height:r,data:G,frameType:"xy",pointNodes:H,curve:V,stickyPositionCache:st.current},o=$?dt({annotations:t,context:i,..."object"==typeof $?$:{}}):t;return W(o,n,O,i)},[D,$,O,e,r,F,j,G,s,H,V,Q]),ft=X(K);return Xr(()=>{if(!ft?.locked||!K)return;const t=t=>{"Escape"===t.key&&B(K)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[ft?.locked,K]),c||x||v||_||C||ht&&ht.length>0||g||J||ft?on("svg",{role:"img",width:n,height:o,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[nn("title",{children:"string"==typeof x?x:"XY Chart"}),nn("desc",{children:"string"==typeof x?x+" (XY data visualization)":"XY data visualization"}),on("g",{transform:`translate(${a.left},${a.top})`,children:[g&&s&&(!q||U)&&(()=>{const t=tn(l?.find(t=>"bottom"===t.orient)?.gridStyle),n=tn(l?.find(t=>"left"===t.orient)?.gridStyle);return on("g",{className:"stream-grid",children:[it.map((e,n)=>nn("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:r,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:t},"xgrid-"+n)),ot.map((t,r)=>nn("line",{x1:0,y1:t.pixel,x2:e,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:n},"ygrid-"+r))]})})(),c&&s&&(()=>{const t=l?.find(t=>"left"===t.orient),n=l?.find(t=>"bottom"===t.orient),o=!t||!1!==t.baseline,a=!n||!1!==n.baseline,s=t?.jaggedBase||!1,c=n?.jaggedBase||!1,d=n?.landmarkTicks,y=t?.landmarkTicks,p="var(--semiotic-border, #ccc)",g="var(--semiotic-text-secondary, var(--semiotic-text, #666))",m="var(--semiotic-text, #333)",x=!!n?.autoRotate&&it.length>1&&(()=>{const t=e/Math.max(it.length-1,1);return it.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:60),0)+8>t})(),v=x?12:18,b=r+(x?58:40),k={fontSize:"var(--semiotic-tick-font-size, 12px)"},w={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},A={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},P=n?.tickAnchor,S=t?.tickAnchor,M=Qr(it),_=Qr(ot);return on("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[on("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!q||U)&&a&&!c&&nn("line",{x1:0,y1:r,x2:e,y2:r,stroke:p,strokeWidth:1}),(!q||U)&&c&&nn("path",{d:en("bottom",e,r),fill:"none",stroke:p,strokeWidth:1}),it.map((t,e)=>{const n=!!d&&("function"==typeof d?d(t.value,e):i(t.value,e>0?it[e-1].value:void 0));return on("g",{transform:`translate(${t.pixel},${r})`,children:[nn("line",{y2:5,stroke:p,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?nn("text",{y:v,textAnchor:x?"end":Zr(P,t.pixel===M.min,t.pixel===M.max),fontWeight:n?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...n?w:k},transform:x?"rotate(-45)":void 0,children:t.label}):nn("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:nn("div",{style:{textAlign:"center",userSelect:"none",...k},children:t.label})})]},"xtick-"+e)}),u&&nn("text",{x:e/2,y:b,textAnchor:"middle",fill:m,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:u})]}),on("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!q||U)&&o&&!s&&nn("line",{x1:0,y1:0,x2:0,y2:r,stroke:p,strokeWidth:1}),(!q||U)&&s&&nn("path",{d:en("left",e,r),fill:"none",stroke:p,strokeWidth:1}),ot.map((t,e)=>{const r=!!y&&("function"==typeof y?y(t.value,e):i(t.value,e>0?ot[e-1].value:void 0));return on("g",{transform:`translate(0,${t.pixel})`,children:[nn("line",{x2:-5,stroke:p,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?nn("text",{x:-8,textAnchor:"end",dominantBaseline:Jr(S,t.pixel===_.min,t.pixel===_.max),fontWeight:r?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...r?w:k},children:t.label}):nn("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:nn("div",{style:{textAlign:"right",userSelect:"none",...k},children:t.label})})]},"ytick-"+e)}),(()=>{const e=t?.label||h;return e?nn("text",{x:15-rt,y:r/2,textAnchor:"middle",fill:m,transform:`rotate(-90, ${15-rt}, ${r/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:e}):null})()]}),(()=>{const t=l?.find(t=>"right"===t.orient);if(!t||0===at.length)return null;const n=!1!==t.baseline,o=t.landmarkTicks,a=t.label||f,s=t.tickAnchor,c=Qr(at);return on("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[n&&nn("line",{x1:e,y1:0,x2:e,y2:r,stroke:p,strokeWidth:1}),at.map((t,r)=>{const n=!!o&&("function"==typeof o?o(t.value,r):i(t.value,r>0?at[r-1].value:void 0));return on("g",{transform:`translate(${e},${t.pixel})`,children:[nn("line",{x2:5,stroke:p,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?nn("text",{x:8,textAnchor:"start",dominantBaseline:Jr(s,t.pixel===c.min,t.pixel===c.max),fontWeight:n?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...n?w:k},children:t.label}):nn("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:nn("div",{style:{textAlign:"left",userSelect:"none",...k},children:t.label})})]},"ytick-r-"+r)}),a&&nn("text",{x:e+nt-15,y:r/2,textAnchor:"middle",fill:m,transform:`rotate(90, ${e+nt-15}, ${r/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:a})]})})()]})})(),ht,C&&s&&L&&T&&on(rn,{children:[C.top&&nn("g",{transform:"translate(0, 0)",children:nn(Ur,{orient:"top",config:qr(C.top),values:L,scale:s.x,size:a.top,length:e})}),C.bottom&&nn("g",{transform:`translate(0, ${r})`,children:nn(Ur,{orient:"bottom",config:qr(C.bottom),values:L,scale:s.x,size:a.bottom,length:e})}),C.left&&nn("g",{transform:"translate(0, 0)",children:nn(Ur,{orient:"left",config:qr(C.left),values:T,scale:s.y,size:a.left,length:r})}),C.right&&nn("g",{transform:`translate(${e}, 0)`,children:nn(Ur,{orient:"right",config:qr(C.right),values:T,scale:s.y,size:a.right,length:r})})]}),_,ft&&ft.sourceId!==Z&&s?.x&&(()=>{const t=s.x(ft.xValue);if(null==t||0>t||t>e)return null;const n=ft.locked;return nn("line",{x1:t,y1:0,x2:t,y2:r,stroke:n?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:n?1.5:1,strokeDasharray:n?"6,3":"4,4",pointerEvents:"none"})})(),J]}),x&&"string"==typeof x?nn("text",{x:n/2,y:m,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:x}):x?nn("foreignObject",{x:0,y:0,width:n,height:a.top,children:x}):null,I({legend:v,totalWidth:n,totalHeight:o,margin:a,legendPosition:P,title:x,legendLayout:M,legendHoverBehavior:b,legendClickBehavior:k,legendHighlightedCategory:w,legendIsolatedCategories:A})]}):null}import{useRef as un}from"react";function hn(t){const e=un(t);return function(t,e){if(Object.is(t,e))return!0;if(Array.isArray(t)&&Array.isArray(e))return dn(t,e);if(!yn(t)||!yn(e))return!1;const r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(const n of r){if(!Object.prototype.hasOwnProperty.call(e,n))return!1;const r=t[n],i=e[n];if(!Object.is(r,i))if(Array.isArray(r)&&Array.isArray(i)){if(!dn(r,i))return!1}else{if(!yn(r)||!yn(i))return!1;if(!fn(r,i))return!1}}return!0}(e.current,t)||(e.current=t),e.current}function fn(t,e){const r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(const n of r){if(!Object.prototype.hasOwnProperty.call(e,n))return!1;if(!Object.is(t[n],e[n]))return!1}return!0}function dn(t,e){if(t.length!==e.length)return!1;for(let r=0;t.length>r;r++)if(!Object.is(t[r],e[r]))return!1;return!0}function yn(t){if(null===t||"object"!=typeof t)return!1;if(Array.isArray(t))return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function pn(t){const{background:e,hasBackgroundGraphics:r=!1,themeBackground:n=""}=t;return"transparent"===e||r?null:e||(n&&"transparent"!==n?n:"")||null}function gn(t,e){const{background:r,hasBackgroundGraphics:n=!1,themeBackground:i="",x:o=0,y:a=0,width:s,height:c}=e,l=pn({background:r,hasBackgroundGraphics:n,themeBackground:i});if(!l)return!1;const u=Pt(t,l);return!!u&&(t.fillStyle=u,t.fillRect(o,a,s,c),!0)}function mn(t){return!!(t.dirtyOrRebuilt||t.transitioning||t.animationTicked||t.continuous||t.liveEncoding||t.forced)}var xn={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white",primary:"#007bff",background:""};function vn(t,e){const r=t.trim();if(/^#[0-9a-f]{3}$/i.test(r)){const t=r[1],n=r[2],i=r[3];return`#${t}${t}${n}${n}${i}${i}${e}`}if(/^#[0-9a-f]{6}$/i.test(r))return`${r}${e}`;const n=r.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return n?`rgba(${n[1]}, ${(parseInt(e,16)/255).toFixed(3)})`:r}function bn(t,e,r,n){return"function"==typeof t?t({size:e,margin:r,scales:n}):t}import{useCallback as kn,useRef as wn}from"react";function An(t,e,r,n){return"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:r,fn:t}:"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:n,fn:e}:{key:void 0,fn:null}}var Pn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Sn=3156e7;function Mn(t){const e=t[1]-t[0];return 864e5>e?t=>{const e=new Date(t);return`${(e.getUTCHours()+"").padStart(2,"0")}:${(e.getUTCMinutes()+"").padStart(2,"0")}`}:Sn>e?t=>{const e=new Date(t);return`${Pn[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*Sn>e?t=>{const e=new Date(t);return`${Pn[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}function _n(t){if(!t)return;const e=[];for(const r of t)if("point"===r.type)e.push(r);else if("symbol"===r.type)e.push({pointId:r.pointId,x:r.x,y:r.y,r:kt(r.size)});else if("glyph"===r.type){const t=mt(r.glyph,r.size);e.push({pointId:r.pointId,x:r.x+t.centerDx,y:r.y+t.centerDy,r:t.radius})}return e}import{line as Cn}from"d3-shape";function Ln(t,e,r,n,i,o){if(2>e.length)return;const a=[0];for(let t=1;e.length>t;t++){const r=e[t][0]-e[t-1][0],n=e[t][1]-e[t-1][1];a.push(a[t-1]+Math.sqrt(r*r+n*n))}const s=a[a.length-1];if(0===s)return;const c=Math.min(.2*s,40);t.strokeStyle=r,t.lineWidth=n,t.lineCap=o;for(let r=0;e.length-1>r;r++){const n=(a[r]+a[r+1])/2;let o=i;c>n&&(o*=n/c),c>s-n&&(o*=(s-n)/c),t.globalAlpha=Math.max(0,o),t.beginPath(),t.moveTo(e[r][0],e[r][1]),t.lineTo(e[r+1][0],e[r+1][1]),t.stroke()}}var Tn=(t,e,r,n)=>{const i=e.filter(t=>"line"===t.type);for(const e of i){if(2>e.path.length)continue;const r=e._introClipFraction;void 0!==r&&1>r&&(t.save(),t.beginPath(),t.rect(0,0,n.width*r,n.height),t.clip());const i=e.style.stroke||"#007bff",o=Pt(t,i)||i,a=e.style.strokeWidth||2,s=e.colorThresholds,c=e.rawValues;if(t.setLineDash(e.style.strokeDasharray?e.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),t.lineWidth=a,t.lineCap=e.style.strokeLinecap||"butt",e.style._edgeFade){Ln(t,e.path,o,a,e.style.opacity??1,e.style.strokeLinecap||"butt"),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt";continue}const l=F(e.curve),u=s&&s.length>0&&c&&c.length===e.path.length,h=e._decayOpacities;if(h&&h.length===e.path.length&&!u){t.strokeStyle=o;const r=e.style.opacity??1;for(let n=0;e.path.length-1>n;n++)t.globalAlpha=.5*(h[n]+h[n+1])*r,t.beginPath(),t.moveTo(e.path[n][0],e.path[n][1]),t.lineTo(e.path[n+1][0],e.path[n+1][1]),t.stroke()}else if(u){const r=b(e.path,c,s,o);for(const e of r){t.beginPath(),t.strokeStyle=Pt(t,e.color)||e.color,t.moveTo(e.path[0][0],e.path[0][1]);for(let r=1;e.path.length>r;r++)t.lineTo(e.path[r][0],e.path[r][1]);t.stroke()}}else{t.beginPath();const r=e.strokeGradient&&e.path.length>=2?x(t,e.strokeGradient,o,e.path[0][0],0,e.path[e.path.length-1][0],0):null;if(t.strokeStyle=r||o,l)Cn().x(t=>t[0]).y(t=>t[1]).curve(l).context(t)(e.path);else{const[r,n]=e.path[0];t.moveTo(r,n);for(let r=1;e.path.length>r;r++)t.lineTo(e.path[r][0],e.path[r][1])}t.stroke()}if(e.style.fill&&e.style.fillOpacity&&e.style.fillOpacity>0){if(t.beginPath(),t.globalAlpha=e.style.fillOpacity,t.fillStyle=O(t,e.style.fill,e.style.fill),l&&!u)Cn().x(t=>t[0]).y(t=>t[1]).curve(l).context(t)(e.path);else{const[r,n]=e.path[0];t.moveTo(r,n);for(let r=1;e.path.length>r;r++)t.lineTo(e.path[r][0],e.path[r][1])}const r=e.path[0][0];t.lineTo(e.path[e.path.length-1][0],n.height),t.lineTo(r,n.height),t.closePath(),t.fill()}void 0!==r&&1>r&&t.restore(),t.globalAlpha=1,t.setLineDash([]),t.lineCap="butt"}};function Dn(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function En(t,e,r=.3){Dn(e)&&(t.globalAlpha=e._pulseIntensity*r,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h))}function Rn(t,e,r=.6){if(!Dn(e))return;const n=e.r+(e._pulseGlowRadius??4)*e._pulseIntensity,i=e.cx??e.x??0,o=e.cy??e.y??0;t.beginPath(),t.arc(i,o,n,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=e._pulseIntensity*r,t.stroke()}function Yn(t,e,r,n=.35){Dn(e)&&(t.globalAlpha=e._pulseIntensity*n,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",r?t.fill(r):t.fill())}import{area as Nn,line as $n}from"d3-shape";function Wn(t,e){const r=F(e.curve);if(!r||2>e.topPath.length||2>e.bottomPath.length){t.beginPath(),t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let r=1;e.topPath.length>r;r++)t.lineTo(e.topPath[r][0],e.topPath[r][1]);for(let r=e.bottomPath.length-1;r>=0;r--)t.lineTo(e.bottomPath[r][0],e.bottomPath[r][1]);t.closePath()}else{const n=Nn().x(t=>t[0]).y0((t,r)=>e.bottomPath[r][1]).y1(t=>t[1]).curve(r).context(t);t.beginPath(),n(e.topPath)}}function In(t,e){const r=F(e.curve);if(t.beginPath(),r)$n().x(t=>t[0]).y(t=>t[1]).curve(r).context(t)(e.topPath);else{t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let r=1;e.topPath.length>r;r++)t.lineTo(e.topPath[r][0],e.topPath[r][1])}}var On=(t,e,r,n)=>{const i=e.filter(t=>"area"===t.type);for(const e of i){if(2>e.topPath.length)continue;let r=!1;e.clipRect&&(t.save(),t.beginPath(),t.rect(e.clipRect.x,e.clipRect.y,e.clipRect.width,e.clipRect.height),t.clip(),r=!0);const i=e._introClipFraction;void 0!==i&&1>i&&(t.save(),t.beginPath(),t.rect(0,0,n.width*i,n.height),t.clip());const o=O(t,e.style.fill,"#4e79a7"),a=e._decayOpacities,s=!(!e.colorThresholds?.length||!e.rawValues||e.rawValues.length!==e.topPath.length),c=!!e.strokeColorBands?.length;if(a&&a.length===e.topPath.length&&!s&&!c){const r=e.style.fillOpacity??.7;t.fillStyle=o;for(let n=0;e.topPath.length-1>n;n++)t.globalAlpha=.5*(a[n]+a[n+1])*r,t.beginPath(),t.moveTo(e.topPath[n][0],e.topPath[n][1]),t.lineTo(e.topPath[n+1][0],e.topPath[n+1][1]),t.lineTo(e.bottomPath[n+1][0],e.bottomPath[n+1][1]),t.lineTo(e.bottomPath[n][0],e.bottomPath[n][1]),t.closePath(),t.fill();if(e.style.stroke&&"none"!==e.style.stroke){t.strokeStyle=Pt(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);for(let r=0;e.topPath.length-1>r;r++)t.globalAlpha=.5*(a[r]+a[r+1]),t.beginPath(),t.moveTo(e.topPath[r][0],e.topPath[r][1]),t.lineTo(e.topPath[r+1][0],e.topPath[r+1][1]),t.stroke()}t.globalAlpha=1;continue}const l=e.style.opacity??1;if(Wn(t,e),e.fillGradient&&e.fillGradient.stops.length>=2&&e.fillGradient){let r=1/0;for(const t of e.topPath)r>t[1]&&(r=t[1]);let n=-1/0;for(const t of e.bottomPath)t[1]>n&&(n=t[1]);const i=v(t,e.fillGradient,"string"==typeof o?o:"#4e79a7",0,r,0,n);t.fillStyle=i||o,t.globalAlpha=l}else t.globalAlpha=(e.style.fillOpacity??.7)*l,t.fillStyle=o;if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(Wn(t,e),Yn(t,e)),e.style.stroke&&"none"!==e.style.stroke){t.globalAlpha=l;const r=Pt(t,e.style.stroke)||e.style.stroke,n=s||c||!e.strokeGradient||2>e.topPath.length?null:x(t,e.strokeGradient,r,e.topPath[0][0],0,e.topPath[e.topPath.length-1][0],0);if(t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]),c){let n=1/0,i=-1/0;for(const[t]of e.topPath)n=Math.min(n,t),i=Math.max(i,t);const o=t.lineWidth;for(const a of e.strokeColorBands){t.save(),t.beginPath(),t.rect(n-o,a.y,i-n+2*o,a.height),t.clip();const s=a.color??r;t.strokeStyle=Pt(t,s)||s,In(t,e),t.stroke(),t.restore()}}else if(s){const n=b(e.topPath,e.rawValues,e.colorThresholds,r);for(const e of n){t.beginPath(),t.strokeStyle=Pt(t,e.color)||e.color,t.moveTo(e.path[0][0],e.path[0][1]);for(let r=1;e.path.length>r;r++)t.lineTo(e.path[r][0],e.path[r][1]);t.stroke()}}else t.strokeStyle=n||r,In(t,e),t.stroke()}void 0!==i&&1>i&&t.restore(),r&&t.restore(),t.globalAlpha=1}},Fn=(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=O(t,r.style.fill,"#4e79a7"),t.fill(),r.style.stroke&&"none"!==r.style.stroke&&(t.strokeStyle=O(t,r.style.stroke,r.style.stroke),t.lineWidth=r.style.strokeWidth||1,t.stroke()),Rn(t,r)}finally{t.restore()}}},zn=new Map;function Bn(t){try{if(t.path)return new Path2D(t.path);const e=`${t.symbolType??"circle"}:${Math.round(t.size)}`;let r=zn.get(e);return r||(r=new Path2D(bt(t.symbolType,t.size)),zn.size>256&&zn.clear(),zn.set(e,r)),r}catch{return null}}var Xn=(t,e)=>{const r=t.globalAlpha;for(const n of e){if("symbol"!==n.type)continue;const e=n;if(0>=e.size)continue;const i=Bn(e);if(!i)continue;t.save(),t.translate(e.x,e.y),e.rotation&&t.rotate(e.rotation);const o=(e.style.opacity??1)*(e._decayOpacity??1);e.style.fill&&(t.globalAlpha=r*o*(e.style.fillOpacity??1),t.fillStyle=O(t,e.style.fill,"#4e79a7"),t.fill(i)),e.style.stroke&&"none"!==e.style.stroke&&(t.globalAlpha=r*o,t.strokeStyle=O(t,e.style.stroke,e.style.stroke),t.lineWidth=e.style.strokeWidth??1,t.stroke(i)),t.restore()}t.globalAlpha=r};function jn(t,e,r,n,i){if(0>=e.size)return;const o=e.glyph;if(!o||!o.parts?.length)return;const a=xt(o,e.size);if(0>=a.scale)return;const s=(e.style.opacity??1)*(e._decayOpacity??1);if(0>=s)return;const c=e=>{const r=O(t,e,e);return"string"==typeof r?r:e},l=e.color??("string"==typeof e.style.fill?e.style.fill:void 0);t.save(),t.translate(r,n),e.rotation&&t.rotate(e.rotation),t.translate(a.offsetX,a.offsetY),t.scale(a.scale,a.scale),t.globalAlpha=i*s*(e.style.fillOpacity??1);const u=gt(o,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal");u&&e.ghostColor&&yt(t,o,l,e.accent,e.ghostColor,c),u&&(t.beginPath(),t.rect(u.x,u.y,u.width,u.height),t.clip()),yt(t,o,l,e.accent,void 0,c),t.restore()}function Gn(t,e){const r=t.globalAlpha;for(const n of e)"glyph"===n.type&&jn(t,n,n.cx,n.cy,r);t.globalAlpha=r}function Hn(t,e){const{x:r,y:n,w:i,h:o}=e,{tl:a,tr:s,br:c,bl:l}=k(e);t.beginPath(),t.moveTo(r+a,n),t.lineTo(r+i-s,n),s>0&&t.arcTo(r+i,n,r+i,n+s,s),t.lineTo(r+i,n+o-c),c>0&&t.arcTo(r+i,n+o,r+i-c,n+o,c),t.lineTo(r+l,n+o),l>0&&t.arcTo(r,n+o,r,n+o-l,l),t.lineTo(r,n+a),a>0&&t.arcTo(r,n,r+a,n,a),t.closePath()}function Vn(t){switch(t.roundedEdge){case"bottom":return{x0:t.x,y0:t.y+t.h,x1:t.x,y1:t.y};case"right":return{x0:t.x+t.w,y0:t.y,x1:t.x,y1:t.y};case"left":return{x0:t.x,y0:t.y,x1:t.x+t.w,y1:t.y};default:return{x0:t.x,y0:t.y,x1:t.x,y1:t.y+t.h}}}var qn=(t,e,r,n)=>{const i=e.filter(t=>"rect"===t.type);for(const e of i){if(null!=e.style.opacity&&(t.globalAlpha=e.style.opacity),e.style.icon)Un(t,e);else if(e.cornerRadii&&T(e.cornerRadii)){const r=O(t,e.style.fill,Pt(t,"var(--semiotic-primary, #007bff)")),n=Vn(e),i=e.fillGradient&&"string"==typeof r?v(t,e.fillGradient,r,n.x0,n.y0,n.x1,n.y1):null;t.fillStyle=i||r,Hn(t,e),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Pt(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else if(e.roundedTop&&e.roundedTop>0){const r=O(t,e.style.fill,Pt(t,"var(--semiotic-primary, #007bff)")),n=Vn(e),i=e.fillGradient&&"string"==typeof r?v(t,e.fillGradient,r,n.x0,n.y0,n.x1,n.y1):null;t.fillStyle=i||r;const o=Math.min(e.roundedTop,e.w/2,e.h/2);t.beginPath();const{x:a,y:s,w:c,h:l}=e;switch(e.roundedEdge){case"right":t.moveTo(a,s),t.lineTo(a+c-o,s),t.arcTo(a+c,s,a+c,s+o,o),t.lineTo(a+c,s+l-o),t.arcTo(a+c,s+l,a+c-o,s+l,o),t.lineTo(a,s+l);break;case"left":t.moveTo(a+c,s),t.lineTo(a+o,s),t.arcTo(a,s,a,s+o,o),t.lineTo(a,s+l-o),t.arcTo(a,s+l,a+o,s+l,o),t.lineTo(a+c,s+l);break;case"bottom":t.moveTo(a,s),t.lineTo(a+c,s),t.lineTo(a+c,s+l-o),t.arcTo(a+c,s+l,a+c-o,s+l,o),t.lineTo(a+o,s+l),t.arcTo(a,s+l,a,s+l-o,o);break;default:t.moveTo(a,s+l),t.lineTo(a,s+o),t.arcTo(a,s,a+o,s,o),t.lineTo(a+c-o,s),t.arcTo(a+c,s,a+c,s+o,o),t.lineTo(a+c,s+l)}t.closePath(),t.fill(),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Pt(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.stroke())}else{const r=O(t,e.style.fill,Pt(t,"var(--semiotic-primary, #007bff)")),n=Vn(e),i=e.fillGradient&&"string"==typeof r?v(t,e.fillGradient,r,n.x0,n.y0,n.x1,n.y1):null;t.fillStyle=i||r,t.fillRect(e.x,e.y,e.w,e.h),e.style.stroke&&"none"!==e.style.stroke&&(t.strokeStyle=Pt(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||1,t.strokeRect(e.x,e.y,e.w,e.h))}En(t,e),t.globalAlpha=1}};function Un(t,e){const r=e.style.icon,n=e.style.iconPadding||2,i=Math.min(e.w,e.h)-n;if(0>=i)return;const o=e.h>e.w;if(t.save(),t.beginPath(),t.rect(e.x,e.y,e.w,e.h),t.clip(),o){const o=i+n,a=e.x+(e.w-i)/2;for(let n=e.y+e.h-i;n>=e.y-i;n-=o)t.drawImage(r,a,n,i,i)}else{const o=i+n,a=e.y+(e.h-i)/2;for(let n=e.x;e.x+e.w>n;n+=o)t.drawImage(r,n,a,i,i)}t.restore()}function Kn(t){const[e,r,n]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*r+.114*n>128?"#000":"#fff"}function Zn(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}var Jn=(t,e,r,n)=>{const i=e.filter(t=>"heatcell"===t.type);t.save();try{for(const e of i){const r=e.style;null!=r?.opacity&&(t.globalAlpha=r.opacity),t.fillStyle=e.fill,t.fillRect(e.x,e.y,e.w,e.h);const n=Math.max(0,r?.strokeWidth??1);if(n>0&&(t.strokeStyle=Pt(t,r?.stroke??"var(--semiotic-surface, #fff)"),t.lineWidth=n,t.strokeRect(e.x,e.y,e.w,e.h)),En(t,e),t.globalAlpha=1,e.showValues&&null!=e.value){if(20>e.w||20>e.h)continue;const r=e.valueFormat?e.valueFormat(e.value):Zn(e.value),n=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),i=e.x+e.w/2,o=e.y+e.h/2;t.fillStyle=Kn(e.fill),t.font=n+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(r,i,o)}}}finally{t.restore()}},Qn=(t,e,r,n)=>{for(const r of e){if("candlestick"!==r.type)continue;const e=r;t.save();const i=(e._decayOpacity??1)*(e.style?.opacity??1);1!==i&&(t.globalAlpha=i);const o=Pt(t,e.wickColor)||e.wickColor,a=60>n.height,s=a?Math.max(e.wickWidth,2):e.wickWidth,c=()=>{t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=o,t.lineWidth=s,t.stroke()};if(a||c(),e.isRange){const r=e.dotRadius??Math.max(2,Math.min(e.bodyWidth/2,.12*n.height));t.fillStyle=o,t.beginPath(),t.arc(e.x,e.highY,r,0,2*Math.PI),t.fill(),t.beginPath(),t.arc(e.x,e.lowY,r,0,2*Math.PI),t.fill()}else if(e.bodyWidth>0){const r=Math.min(e.openY,e.closeY),n=Math.abs(e.openY-e.closeY),i=e.isUp?e.upColor:e.downColor,o=Pt(t,i)||i;t.fillStyle=o,t.fillRect(e.x-e.bodyWidth/2,r,e.bodyWidth,Math.max(n,1)),t.strokeStyle=o,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,r,e.bodyWidth,Math.max(n,1))}a&&c(),t.restore()}},ti={line:[On,Tn,Fn],area:[On,Fn],stackedarea:[On,Fn],scatter:[Fn,Xn],bubble:[Fn,Xn],heatmap:[Jn],bar:[qn],swarm:[Fn],waterfall:[(t,e,r,n)=>{qn(t,e);const i=e.filter(t=>"rect"===t.type);if(2>i.length)return;const o=i[0].datum,a=o?._connectorStroke;if(a){t.save(),t.strokeStyle=Pt(t,a)||a,t.lineWidth=o?._connectorWidth??1,t.setLineDash([]);for(let e=0;i.length-1>e;e++){const n=i[e],o=i[e+1],a=n.datum,s=o.datum;if(null==a?.cumEnd||null==s?.baseline)continue;const c=r.y(a.cumEnd),l=n.x+n.w,u=o.x;t.beginPath(),t.moveTo(l,c),t.lineTo(u,c),t.stroke()}t.restore()}}],candlestick:[Qn],mixed:[On,Tn,Fn],custom:[On,qn,Jn,Tn,Fn,Xn,(t,e)=>{const r=t.globalAlpha;for(const n of e)"glyph"===n.type&&jn(t,n,n.x,n.y,r);t.globalAlpha=r},Qn]},ei=new Set;function ri(t,e){const r="function"==typeof t?t(e.datum??null,e):t;return(n=r)&&"object"==typeof n&&"string"==typeof n.id&&"function"==typeof n.cacheKey&&"function"==typeof n.drawCanvas&&"function"==typeof n.renderStaticSVG?r:void 0;var n}function ni(t,e){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const r=`${t}:${e}`;ei.has(r)||(ei.add(r),console.warn(`[Semiotic] Render backend "${t}" does not support scene node "${e}"; using the built-in renderer.`))}function ii(t){const{context:e,nodes:r,renderMode:n,pixelRatio:i,paintBuiltIn:o}=t;if(!n||"sketchy"===n)return void o(r);let a=[];const s=()=>{a.length&&(o(a),a=[])};for(const t of r){const r=ri(n,t);if(!r){a.push(t);continue}let c;s(),e.save();try{c=r.drawCanvas({context:e,node:t,style:t.style??{},pixelRatio:i})}finally{e.restore()}c||(ni(r.id,t.type??"unknown"),o([t]))}s()}function oi(t){const{node:e,index:r,renderMode:n,fallback:i}=t,o=ri(n,e);if(!o)return i();const a=o.renderStaticSVG({node:e,style:e.style??{},key:`${o.id}-${r}`});return null!=a?a:(ni(o.id,e.type??"unknown"),i())}function ai(t){const e=[];return t.nodes.forEach((r,n)=>{const i=oi({node:r,index:n,renderMode:t.renderMode,fallback:()=>t.fallback(r,n)});null!=i&&!1!==i&&e.push({node:r,element:i})}),e}import{jsx as si,jsxs as ci}from"react/jsx-runtime";function li(t){return null==t?"–":"number"==typeof t?Math.abs(t)>9999?t.toLocaleString():t+"":t instanceof Date?t.toLocaleDateString():t+""}import{jsx as ui,jsxs as hi}from"react/jsx-runtime";function fi(t){return null==t?"":"number"==typeof t?Number.isInteger(t)?t+"":t.toFixed(2):t instanceof Date?t.toLocaleString():t+""}function di({hover:t}){const e=t.data??{},r=e.y??e.value,n=e.x??e.time;if(void 0===r&&void 0===n){const t=ct(e);if(null!=t.title||t.entries.length>0)return hi("div",{className:"semiotic-tooltip",style:tt,children:[null!=t.title&&ui("div",{style:{fontWeight:600,marginBottom:t.entries.length?2:0},children:t.title+""}),t.entries.map(t=>hi("div",{style:{opacity:.7,fontSize:11},children:[t.key,":"," ",ui("span",{style:{fontWeight:600},children:fi(t.value)})]},t.key))]})}return hi("div",{className:"semiotic-tooltip",style:tt,children:[ui("div",{style:{fontWeight:600,marginBottom:2},children:fi(r)}),ui("div",{style:{opacity:.7,fontSize:11},children:fi(n)})]})}di.ownsChrome=!0;import{useCallback as yi}from"react";import{useCallback as pi,useRef as gi}from"react";function mi(t){const e=new Map;for(const r of t){const t=r.group??"_default";let n=e.get(t);n||(n=[],e.set(t,n)),n.push(r)}for(const t of e.values()){t.sort((t,e)=>t.x-e.x||t.y-e.y);for(let e=0;t.length>e;e++)t[e]._groupIndex=e}const r=Array.from(e.keys()).sort((t,r)=>{const n=e.get(t),i=e.get(r);return(n.length>0?n[0].y:0)-(i.length>0?i[0].y:0)}),n=Array.from(e.values()).flat();n.sort((t,e)=>t.x-e.x||t.y-e.y);const i=new Map;for(let t=0;n.length>t;t++){n[t]._flatIndex=t;const e=n[t].datum?.id;null!=e&&i.set(e+"",t)}return{flat:n,groups:r,byGroup:e,idToIdx:i}}function xi(t,e){if(0===t.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const r=Math.max(0,Math.min(e,t.flat.length-1)),n=t.flat[r];return{flatIndex:r,group:n.group??"_default",indexInGroup:n._groupIndex??0}}function vi(t,e,r){const{group:n,indexInGroup:i}=e,o=r.byGroup.get(n);switch(t){case"ArrowRight":return o.length-1>i?o[i+1]._flatIndex:e.flatIndex;case"ArrowLeft":return i>0?o[i-1]._flatIndex:e.flatIndex;case"ArrowDown":{const t=r.groups.indexOf(n);return r.groups.length-1>t?bi(r,r.groups[t+1],o[i]):e.flatIndex}case"ArrowUp":{const t=r.groups.indexOf(n);return t>0?bi(r,r.groups[t-1],o[i]):e.flatIndex}case"PageDown":return Math.min(e.flatIndex+Math.max(1,Math.floor(.1*r.flat.length)),r.flat.length-1);case"PageUp":return Math.max(e.flatIndex-Math.max(1,Math.floor(.1*r.flat.length)),0);case"Home":return 0;case"End":return r.flat.length-1;case"Escape":return-1;default:return null}}function bi(t,e,r){const n=t.byGroup.get(e);let i=0,o=Math.abs(n[0].x-r.x);for(let t=1;n.length>t;t++){const e=Math.abs(n[t].x-r.x);o>e&&(o=e,i=t)}return n[i]._flatIndex}function ki(t){const e=[];for(const r of t)switch(r.type){case"point":e.push({x:r.x,y:r.y,datum:r.datum,shape:"circle",group:"_default"});break;case"symbol":if(0>=r.size)break;e.push({x:r.x,y:r.y,datum:r.datum,shape:"circle",group:"_default"});break;case"glyph":{if(0>=r.size||null==r.datum)break;const t=mt(r.glyph,r.size);e.push({x:r.x+t.centerDx,y:r.y+t.centerDy,datum:r.datum,shape:"rect",w:2*t.halfWidth,h:2*t.halfHeight,group:"_default"});break}case"line":{const t=r,n=Array.isArray(t.datum)?t.datum:[],i=t.group??"_default";for(let r=0;t.path.length>r&&n.length>r;r++)e.push({x:t.path[r][0],y:t.path[r][1],datum:n[r],shape:"circle",group:i});break}case"area":{const t=r,n=Array.isArray(t.datum)?t.datum:[],i=t.group??"_default";for(let r=0;t.topPath.length>r&&n.length>r;r++)e.push({x:t.topPath[r][0],y:t.topPath[r][1],datum:n[r],shape:"circle",group:i});break}case"rect":e.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:r.group??"_default"});break;case"heatcell":e.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:"_default"})}return e.sort((t,e)=>t.x-e.x||t.y-e.y),e}function wi(t){const e=[];for(const r of t)if("circle"===r.type&&null!=r.cx){if(0>=r.r)continue;e.push({x:r.cx,y:r.cy,datum:r.datum,shape:"circle",group:r.datum?.id??"_default"})}else if("rect"===r.type&&null!=r.x){if(0>=r.w||0>=r.h)continue;e.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:r.datum?.id??"_default"})}else if("arc"===r.type&&null!=r.cx)e.push({x:r.cx,y:r.cy,datum:r.datum,shape:"circle",group:r.datum?.id??"_default"});else if("symbol"===r.type&&null!=r.cx){if(0>=r.size)continue;e.push({x:r.cx,y:r.cy,datum:r.datum,shape:"circle",group:r.datum?.id??"_default"})}else if("glyph"===r.type&&null!=r.cx){if(0>=r.size||null==r.datum)continue;const t=mt(r.glyph,r.size);e.push({x:r.cx+t.centerDx,y:r.cy+t.centerDy,datum:r.datum,shape:"rect",w:2*t.halfWidth,h:2*t.halfHeight,group:r.datum?.id??"_default"})}return e.sort((t,e)=>t.x-e.x||t.y-e.y),e}function Ai(t,e,r,n,i){const o=r.flat[e.flatIndex];if(!o)return vi(t,e,r);const a=o.datum?.id;switch(t){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const n=function(t,e,r){let n=null,i=1/0;for(let o=0;t.flat.length>o;o++){const a=t.flat[o];if(a===e)continue;const s=a.x-e.x,c=a.y-e.y;let l=!1;switch(r){case"right":l=s>0&&Math.abs(s)>=Math.abs(c);break;case"left":l=0>s&&Math.abs(s)>=Math.abs(c);break;case"down":l=c>0&&Math.abs(c)>=Math.abs(s);break;case"up":l=0>c&&Math.abs(c)>=Math.abs(s)}if(!l)continue;const u=s*s+c*c;i>u&&(i=u,n=o)}return n}(r,o,"ArrowRight"===t?"right":"ArrowLeft"===t?"left":"ArrowDown"===t?"down":"up")??e.flatIndex;return n!==e.flatIndex&&(i.current=-1),n}case"Enter":{if(null==a)return e.flatIndex;const t=function(t,e){const r=t+"",n=[];for(const t of e){const e=t.datum??t,i=Pi(e.source),o=Pi(e.target),a=null!=i,s=null!=o;a&&i+""===r&&s?n.push(o+""):s&&o+""===r&&a&&n.push(i+"")}return n}(a,n);if(0===t.length)return e.flatIndex;const o=r.idToIdx.get(t[(i.current+1)%t.length])??-1;return 0>o?e.flatIndex:(i.current=-1,o)}default:{const n=vi(t,e,r);return null!==n&&n!==e.flatIndex&&(i.current=-1),n}}}function Pi(t){return"object"==typeof t&&null!==t&&"id"in t?t.id:t}import{jsx as Si,jsxs as Mi}from"react/jsx-runtime";var _i={top:20,right:20,bottom:30,left:40},Ci=xn;function Li(t){if(t)return"x"===t.dimension?"pan-y":"y"===t.dimension?"pan-x":"none"}var Ti=Ft(Ot(function(t,e){const{chartType:r,runtimeMode:n,data:i,chunkThreshold:o,chunkSize:s,xAccessor:d,yAccessor:m,accessorRevision:x,colorAccessor:v,sizeAccessor:b,symbolAccessor:k,symbolMap:A,groupAccessor:P,lineDataAccessor:S,curve:T,normalize:R,baseline:Y,stackOrder:W,binSize:I,valueAccessor:O,arrowOfTime:F="right",windowMode:z="sliding",windowSize:B=200,timeAccessor:X,xExtent:K,yExtent:Z,extentPadding:Q=.1,scalePadding:tt,sizeRange:et,size:it=[500,300],responsiveWidth:ot,responsiveHeight:at,margin:st,className:ct,background:lt,renderMode:ut,lineStyle:ht,pointStyle:ft,areaStyle:dt,barStyle:yt,waterfallStyle:pt,swarmStyle:gt,barColors:mt,colorScheme:xt,boundsAccessor:vt,boundsStyle:bt,y0Accessor:kt,band:wt,gradientFill:Pt,lineGradient:Mt,semanticLineStops:_t,areaGroups:Ct,openAccessor:Lt,highAccessor:Tt,lowAccessor:Ot,closeAccessor:Ft,candlestickStyle:zt,showAxes:Bt=!0,axes:Xt,xLabel:jt,yLabel:Vt,yLabelRight:qt,xFormat:Ut,yFormat:Kt,axisExtent:Zt,tickFormatTime:Jt,tickFormatValue:Qt,hoverAnnotation:te,tooltipContent:ee,customHoverBehavior:re,customClickBehavior:ne,onObservation:ie,annotationObservationCallback:oe,chartId:ae,enableHover:se,hoverRadius:ce=30,tooltipMode:le,annotations:ue,onAnnotationActivate:he,autoPlaceAnnotations:de,svgAnnotationRules:ye,showGrid:pe,legend:xe,legendHoverBehavior:ve,legendClickBehavior:be,legendHighlightedCategory:ke,legendIsolatedCategories:we,legendPosition:Ae,legendLayout:Pe,legendCategoryAccessor:Se,onCategoriesChange:Me,backgroundGraphics:_e,foregroundGraphics:Ce,canvasPreRenderers:Le,svgPreRenderers:Te,title:De,categoryAccessor:Ee,brush:Re,onBrush:Ye,decay:Ne,pulse:$e,transition:We,animate:Ie,staleness:Oe,frameScheduler:Fe,clock:ze,random:Be,seed:Xe,paused:je=!1,suspendWhenHidden:Ge=!0,heatmapAggregation:He,heatmapXBins:Ve,heatmapYBins:qe,showValues:Ue,heatmapValueFormat:Ke,marginalGraphics:Ze,pointIdAccessor:Je,xScaleType:Qe,yScaleType:tr,accessibleTable:er=!0,description:rr,summary:nr,linkedCrosshairName:ir,linkedCrosshairSourceId:or,customLayout:ar,onLayoutError:sr,layoutConfig:cr,layoutSelection:lr}=t,{customHoverBehavior:hr,customClickBehavior:dr,hasClickBehavior:yr}=function({customHoverBehavior:t,customClickBehavior:e,onObservation:r,chartId:n,chartType:i}){return{customHoverBehavior:yi((e,o)=>{t?.(e,o),_({onObservation:r,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:i,chartId:n,context:o})},[n,i,t,r]),customClickBehavior:yi((t,o)=>{e?.(t,o),M({onObservation:r,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:i,chartId:n,context:o})},[n,i,e,r]),hasClickBehavior:!(!e&&!r)}}({customHoverBehavior:re,customClickBehavior:ne,onObservation:ie,chartId:ae,chartType:"StreamXYFrame"}),mr=It().replace(/:/g,""),xr=Et(!1),vr=Et({w:-1,h:-1}),Ar=Et(!1),Pr=j({sizeProp:it,responsiveWidth:ot,responsiveHeight:at,userMargin:st,marginDefault:_i,title:De,legend:xe,legendPosition:Ae,animate:Ie,transitionProp:We,frameScheduler:Fe,clock:ze,random:Be,seed:Xe,paused:je,suspendWhenHidden:Ge,themeDirtyRef:xr}),Sr=H(),Mr=q(),{reducedMotionRef:_r,responsiveRef:Cr,size:Lr,currentTheme:Tr,transition:Dr,introEnabled:Rr,tableId:Yr,rafRef:Nr,renderFnRef:$r,scheduleRender:Or,frameRuntime:zr}=Pr;let Br=Pr.margin;if(Ze){const t=60,e={...Pr.margin};Ze.top&&t>e.top&&(e.top=t),Ze.bottom&&t>e.bottom&&(e.bottom=t),Ze.left&&t>e.left&&(e.left=t),Ze.right&&t>e.right&&(e.right=t),Br=e}const Xr=Lr[0]-Br.left-Br.right,jr=Lr[1]-Br.top-Br.bottom,Gr=Nt(()=>C(i),[i]),Hr=te??se,[Vr,qr]=Rt(0),Ur=Et(0),[Kr,Zr]=Rt(null),Jr=bn(Ce,Lr,Br,Kr),Qr=bn(_e,Lr,Br,Kr),tn=Et(null),en=Et(null),rn=Et(void 0),[nn,on]=Rt(null),sn=Et(Ci.primary),cn=Et(function(){let t=-1,e=xn;return{resolve(r){if(!r)return xn;const n=At();return n===t||(e=function(t){if(!t)return xn;const e=getComputedStyle(t),r=e.getPropertyValue("--semiotic-border").trim(),n=e.getPropertyValue("--semiotic-text-secondary").trim(),i=e.getPropertyValue("--semiotic-bg").trim(),o=e.getPropertyValue("--semiotic-primary").trim(),a=n||e.getPropertyValue("--text-secondary").trim(),s=e.getPropertyValue("--text-primary").trim(),c=r||e.getPropertyValue("--surface-3").trim(),l=i||e.getPropertyValue("--surface-0").trim();return a||s||r||o?{axisStroke:c||xn.axisStroke,tickText:a||xn.tickText,crosshair:a?vn(a,"66"):xn.crosshair,hoverFill:l?vn(l,"4D"):xn.hoverFill,hoverStroke:a?vn(a,"99"):xn.hoverStroke,pointRing:l||xn.pointRing,primary:o||xn.primary,background:l||xn.background}:xn}(r),t=n),e},invalidate(){t=-1}}}()),un=Et(!1),fn=V("StreamXYFrame"),[dn,yn]=Rt(!1),[mn,Pn]=Rt([]),[Sn,Cn]=Rt([]),Ln="streaming"===n||["bar","swarm","waterfall"].includes(r),Tn=hn(Nt(()=>({chartType:r,runtimeMode:Ln?"streaming":"bounded",windowSize:B,windowMode:z,arrowOfTime:Ln?F:"right",extentPadding:Q,scalePadding:tt,axisExtent:Zt,xAccessor:d,yAccessor:m,accessorRevision:x,timeAccessor:Ln?X:void 0,valueAccessor:O,colorAccessor:v,sizeAccessor:b,symbolAccessor:k,symbolMap:A,groupAccessor:P||(S?"_lineGroup":void 0),categoryAccessor:Ee,lineDataAccessor:S,xScaleType:Qe,yScaleType:tr,xExtent:K,yExtent:Z,sizeRange:et,binSize:I,normalize:R,baseline:Y,stackOrder:W,boundsAccessor:vt,boundsStyle:bt,y0Accessor:kt,band:wt,gradientFill:ge(Pt),areaGroups:Ct?new Set(Ct):void 0,lineGradient:me(Mt),semanticLineStops:_t,openAccessor:Lt,highAccessor:Tt,lowAccessor:Ot,closeAccessor:Ft,candlestickStyle:zt,lineStyle:ht,pointStyle:ft,areaStyle:dt,swarmStyle:gt,waterfallStyle:pt,colorScheme:xt,barColors:mt,barStyle:yt,annotations:ue,decay:Ne,pulse:$e,transition:Dr,introAnimation:Rr,staleness:Oe,clock:zr.now,heatmapAggregation:He,heatmapXBins:Ve,heatmapYBins:qe,showValues:Ue,heatmapValueFormat:Ke,pointIdAccessor:Je,curve:T,themeCategorical:Tr?.colors?.categorical,themeSemantic:St(Tr),themeSequential:Tr?.colors?.sequential,themeDiverging:Tr?.colors?.diverging,customLayout:ar,onLayoutError:sr,layoutConfig:cr,layoutMargin:Br}),[r,Ln,B,z,F,Q,tt,Zt,d,m,x,X,O,v,b,k,A,P,S,Ee,Qe,tr,K,Z,et,I,R,Y,W,vt,bt,kt,wt,Pt,Ct,Mt,_t,Lt,Tt,Ot,Ft,zt,ht,ft,dt,gt,pt,xt,mt,yt,ue,Ne,$e,Dr,Rr,Oe,zr.now,He,Ve,qe,Ue,Ke,Je,T,Tr,ar,sr,cr,Br])),Dn=Et(null);Dn.current||(Dn.current=new ur(Tn));const En=function(t,e,r,n){const i=wn({accessor:e,onChange:r,readData:n}),o=wn([]);return i.current={accessor:e,onChange:r,readData:n},kn(()=>{const{accessor:e,onChange:r,readData:n}=i.current;if(!r||!e)return;const a=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 o=t+"";r.has(o)||(r.add(o),n.push(o))}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})(a,o.current)||(o.current=a,r(a))},[t])}(Dn,Se,Me,t=>t.getData());pr(Dn,Tn,xr,Or),gr(Dn,lr,xr,Or);const Rn=Et(null);Rn.current||(Rn.current=new Ht(t=>{const e=Dn.current;e&&e.ingest(t)&&(xr.current=!0,Or())},{chunkThreshold:o,chunkSize:s})),Yt(()=>{Rn.current?.updateChunkOptions({chunkThreshold:o,chunkSize:s})},[o,s]);const Yn=$t(t=>{Rn.current?.push(t)},[]),Nn=$t(t=>{Rn.current?.pushMany(t)},[]),$n=$t(()=>{Rn.current?.clear(),Dn.current?.clear(),xr.current=!0,Or()},[Or]);Wt(e,()=>({push:Yn,pushMany:Nn,remove:t=>{Rn.current?.flush();const e=Dn.current?.remove(t)??[];return e.length>0&&(tn.current&&e.some(t=>t===tn.current?.data)&&(tn.current=null,on(null)),xr.current=!0,Or()),e},update:(t,e)=>{Rn.current?.flush();const r=Dn.current?.update(t,e)??[];return r.length>0&&(xr.current=!0,Or()),r},clear:$n,getData:()=>(Rn.current?.flush(),Dn.current?.getData()??[]),getScales:()=>Dn.current?.scales??null,getExtents:()=>Dn.current?.getExtents()??null,getCustomLayout:()=>Dn.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Dn.current?.lastCustomLayoutFailure??null}),[Yn,Nn,$n,Or]),Yt(()=>{if(i){if(S&&Gr.length>0&&"object"==typeof Gr[0]&&null!==Gr[0]){const t="string"==typeof S?S:"coordinates";if(Array.isArray(Gr[0][t])){const e=[];for(const r of Gr){const n=r[t];if(Array.isArray(n)){const t=r.label||r.id||r.key;if(null!=t)for(const r of n)e.push({...r,_lineGroup:t});else for(const t of n)e.push(t)}}return void Rn.current?.setBoundedData(e)}}Rn.current?.setBoundedData(Gr)}},[i,Gr,S]);const{canvasRef:Wn,interactionCanvasRef:In}=G(Pr,{storeRef:Dn,dirtyRef:xr,hydrated:Sr,wasHydratingFromSSR:Mr,cleanup:()=>Rn.current?.clear(),canvasPaintDependencies:[r,Xr,jr,Bt,lt,_e,ht,ut,Le,Or]}),{hoverHandlerRef:On,hoverLeaveRef:Fn,onPointerMove:zn,onPointerLeave:Bn}=Pr;On.current=t=>{if(!Hr)return;const e=Wn.current;if(!e)return;const n=e.getBoundingClientRect(),i=t.clientX-n.left-Br.left,o=t.clientY-n.top-Br.top;if(0>i||i>Xr||0>o||o>jr)return void(tn.current&&(tn.current=null,en.current=null,on(null),hr&&(hr(null),xr.current=!0),Or()));const a=Dn.current;if(!a||0===a.scene.length)return;const s=rt(ce,t.pointerType),c=kr(a.scene,i,o,s,a.quadtree,a.maxPointRadius),l="multi"===le,u=()=>{tn.current&&(tn.current=null,en.current=null,on(null),hr&&hr(null),Or())};if(!c&&!l)return void u();const h=l||!c?i:c.x,f=l||!c?o:c.y,y=c?.datum?fe(c.datum,a.resolvedRibbons):{},p=a.scales?.x?.invert,g="function"==typeof p?p(h):void 0;let m=J(y,h,f,null!=g?{xValue:g,xPx:h}:void 0);if(l&&a.scene.length>0&&a.scales){const t=function(t,e,r=30){const n=[];for(const i of t)if("line"===i.type){const t=i;if(2>t.path.length)continue;const o=wr(br(t.path,t.curve),e,r);if(null===o)continue;const a=Er(t.path,e);n.push({node:i,datum:Array.isArray(t.datum)&&t.datum[a]?t.datum[a]:t.datum,x:t.path[a][0],y:o,group:t.group,color:t.style.stroke})}else if("area"===i.type){const t=i;if(!1===t.interactive)continue;if(2>t.topPath.length)continue;const o=br(t.topPath,t.curve),a=br(t.bottomPath,t.curve),s=wr(o,e,r);if(null===s)continue;const c=wr(a,e,r),l=Er(t.topPath,e);n.push({node:i,datum:Array.isArray(t.datum)&&t.datum[l]?t.datum[l]:t.datum,x:t.topPath[l][0],y:s,y0:c??void 0,group:t.group,color:"string"==typeof t.style.stroke?t.style.stroke:"string"==typeof t.style.fill?t.style.fill:void 0})}return n}(a.scene,h,Math.max(s,Xr));if(t.length>0){const e=a.scales.y.invert,n=sn.current,i=p?p(h):h;if(c)m.xValue=i,m.xPx=h;else{const t={xValue:i};"string"==typeof d&&(t[d]=i),m=J(t,h,f,{xValue:i,xPx:h})}m.allSeries=t.map(t=>{const i=e?e(t.y):t.y,o=null!=t.y0?e?e(t.y0):t.y0:void 0;return{group:t.group||"",value:"stackedarea"===r&&null!=o?i-o:i,valuePx:t.y,color:t.color||n,datum:fe(t.datum,a.resolvedRibbons)}})}}c||m.allSeries?.length?(tn.current=m,en.current=c?.node??null,on(m),hr&&(hr(m),xr.current=!0),Or()):u()},Fn.current=()=>{tn.current&&(tn.current=null,en.current=null,on(null),hr&&(hr(null),xr.current=!0),Or())};const Xn=Et(()=>{});Xn.current=t=>{if(nt(t.target))return;if(!dr)return;const e=Wn.current;if(!e)return;const r=e.getBoundingClientRect(),n=t.clientX-r.left-Br.left,i=t.clientY-r.top-Br.top;if(0>n||n>Xr||0>i||i>jr)return void dr(null);const o=Dn.current;if(!o||0===o.scene.length)return void dr(null);const a=rt(ce,rn.current),s=kr(o.scene,n,i,a,o.quadtree,o.maxPointRadius);if(!s)return void dr(null);const c=s.datum||{},l=o.scales?.x?.invert,u="function"==typeof l?l(s.x):void 0;dr(J(c,s.x,s.y,null!=u?{xValue:u,xPx:s.x}:void 0),{type:"activate",inputType:N(rn.current)})};const jn=$t(t=>Xn.current(t),[]),{kbFocusIndexRef:Gn,focusedNavPointRef:Hn,onKeyDown:Vn}=(Zn={storeRef:Dn,hoverRef:tn,hoveredNodeRef:en,setHoverPoint:on,customHoverBehavior:hr,customClickBehavior:dr,scheduleRender:Or},function({storeRef:t,hoverRef:e,hoveredNodeRef:r,setHoverPoint:n,customHoverBehavior:i,customClickBehavior:o,scheduleRender:a,extractPoints:s,toHover:c}){const l=gi(-1),u=gi(null),h=gi(null),f=pi(f=>{if(D(f))return;const d=t.current;if(!d)return;const y=()=>{l.current=-1,u.current=null,e.current=null,r&&(r.current=null),n(null),i(null),a()};if(0===d.scene.length)return void(0>l.current||y());let p;if(h.current?.version===d.version)p=h.current.graph;else{const t=s(d.scene);if(0===t.length)return void(0>l.current||y());p=mi(t),h.current={version:d.version,graph:p}}let g=l.current;if(p.flat.length>g||(y(),g=-1),("Enter"===f.key||" "===f.key)&&g>=0)return f.preventDefault(),void o(c(p.flat[g],d),{type:"activate",inputType:"keyboard"});if(0>g){if("Escape"===f.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(f.key))return;f.preventDefault(),l.current=0;const t=p.flat[0];u.current=t;const r=c(t,d);return e.current=r,n(r),i(r,{type:"focus",inputType:"keyboard"}),void a()}const m=vi(f.key,xi(p,g),p);if(null===m)return;if(f.preventDefault(),0>m)return void y();l.current=m;const x=p.flat[m];u.current=x;const v=c(x,d);e.current=v,n(v),i(v,{type:"focus",inputType:"keyboard"}),a()},[o,i,s,e,r,a,n,t,c]);return{kbFocusIndexRef:l,focusedNavPointRef:u,onKeyDown:f}}({...Zn,extractPoints:ki,toHover:(t,e)=>function(t){return{data:t.datum||{},x:t.x,y:t.y,__semioticHoverData:!0}}({...t,datum:fe(t.datum,e.resolvedRibbons)})})),qn=$t(t=>{rn.current=t.pointerType,Gn.current=-1,Hn.current=null,zn(t)},[Hn,Gn,zn]),Un=$t(t=>{rn.current="mouse",Gn.current=-1,Hn.current=null,zn({clientX:t.clientX,clientY:t.clientY,pointerType:"mouse"})},[Hn,Gn,zn]),Kn=$t(t=>{rn.current=t.pointerType},[]);var Zn;$r.current=()=>{if(Nr.current=null,!zr.isActive)return;const t=Wn.current,e=In.current;if(!t||!e)return;const n=Dn.current;if(!n)return;const i=zr.now(),o=n.advanceTransition(_r.current?i+1e6:i),a=!_r.current&&o,s=vr.current.w!==Xr||vr.current.h!==jr,c=xr.current||o||s,l=n.consumeStylePaintPending();let u=!1;const h=n.getLastUpdateResult(),f=fn.current.beforeCompute(h,a);!c||a&&!s||(n.computeScene({width:Xr,height:jr}),vr.current={w:Xr,h:jr},u=!0,En()),fn.current.afterCompute(f,u,s);const y=function(t,e,r,n){const i=n.current,o=!0===t.lastCustomLayoutFailure?.preservedLastGoodScene,a=!o&&t.hasActivePulsesAt(e),s=!(r||o||!a&&!i)&&t.refreshPulse(e);return n.current=a,{changed:s,pending:a}}(n,i,u,Ar),p=L(),g=cn.current.resolve(t);sn.current=g.primary;const x=Wr(Oe,n.lastIngestTime>0?i-n.lastIngestTime:0),v=Oe&&x.isStale;if(c||l||y.changed){const e=$(t,Lr,Br,p);if(e){if(e.clearRect(-Br.left,-Br.top,Lr[0],Lr[1]),Oe&&1>x.alpha&&(e.globalAlpha=x.alpha),gn(e,{background:lt,hasBackgroundGraphics:!!_e,themeBackground:g.background,x:-Br.left,y:-Br.top,width:Lr[0],height:Lr[1]}),e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,Xr,jr),e.clip()),Le&&n.scales)for(const t of Le)e.save(),t(e,n.scene,n.scales,{width:Xr,height:jr}),e.restore();const t=ar?ti.custom:ti[r];ii({context:e,nodes:n.scene,renderMode:ut,pixelRatio:p,paintBuiltIn:r=>{if(t&&n.scales)for(const i of t)i(e,r,n.scales,{width:Xr,height:jr})}}),e.restore(),Oe&&1>x.alpha&&(e.globalAlpha=1)}}const b=!!(Hr&&tn.current&&n.scales),k=!!(en.current&&Array.isArray(te)&&te.some(t=>t&&"object"==typeof t&&"highlight"===t.type)),A=b||k;if(A||un.current){const t=$(e,Lr,Br,p);if(t&&(t.clearRect(-Br.left,-Br.top,Lr[0],Lr[1]),b&&tn.current&&function(t,e,r,n,i,o,a){if(!1===i.crosshair)return;const s=e.allSeries,c=s&&s.length>0,l=e.xPx??e.x;t.save();const u="object"==typeof i.crosshair?i.crosshair:{};if(t.strokeStyle=u.stroke||a.crosshair,t.lineWidth=u.strokeWidth||1,t.setLineDash(u.strokeDasharray?u.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(c?l:e.x,0),t.lineTo(c?l:e.x,n),t.stroke(),c||(t.beginPath(),t.moveTo(0,e.y),t.lineTo(r,e.y),t.stroke()),t.restore(),c){t.lineWidth=2,t.strokeStyle=a.pointRing;for(const e of s)null!=e.valuePx&&(t.beginPath(),t.arc(l,e.valuePx,4,0,2*Math.PI),t.fillStyle=e.color||a.primary,t.fill(),t.stroke())}else{const r=i.pointColor||function(t){if(!t)return null;if("heatcell"===t.type)return t.fill||null;if("candlestick"===t.type)return t.isUp?t.upColor:t.downColor;const{style:e}=t;if(!e)return null;const r="string"==typeof e.fill?e.fill:null;return"line"===t.type||"area"===t.type?e.stroke||r||null:r||e.stroke||null}(o)||a.primary;t.beginPath(),t.arc(e.x,e.y,4,0,2*Math.PI),t.fillStyle=r,t.fill(),t.strokeStyle=a.pointRing,t.lineWidth=2,t.stroke()}}(t,tn.current,Xr,jr,"object"==typeof Hr?Hr:{},en.current,g),k&&en.current&&Array.isArray(te))){const e=te.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,r,n,i){if(!r)return;const o="group"in r?r.group:void 0;if(void 0!==o)for(const r of e){if("line"!==r.type)continue;if(r.group!==o)continue;if(2>r.path.length)continue;const e="function"==typeof n.style?r.datum?n.style(r.datum):{}:n.style||{};t.save(),t.beginPath(),t.moveTo(r.path[0][0],r.path[0][1]);for(let e=1;r.path.length>e;e++)t.lineTo(r.path[e][0],r.path[e][1]);t.strokeStyle=e.stroke||r.style.stroke||i.primary,t.lineWidth=e.strokeWidth||(r.style.strokeWidth||2)+2,t.globalAlpha=e.opacity??1,t.stroke(),t.restore()}}(t,n.scene,en.current,e,g)}un.current=A}c&&t&&t.setAttribute("aria-label",w(n.scene,r+" chart"));const P=xr.current;if(xr.current=P&&a&&!u,P&&n.scales){const t=t=>"object"==typeof t&&null!==t&&"function"==typeof t.valueOf?t.valueOf():t;if((!Kr||t(Kr.x.domain()[0])!==t(n.scales.x.domain()[0])||t(Kr.x.domain()[1])!==t(n.scales.x.domain()[1])||t(Kr.y.domain()[0])!==t(n.scales.y.domain()[0])||t(Kr.y.domain()[1])!==t(n.scales.y.domain()[1])||Kr.x.range()[0]!==n.scales.x.range()[0]||Kr.x.range()[1]!==n.scales.x.range()[1]||Kr.y.range()[0]!==n.scales.y.range()[0]||Kr.y.range()[1]!==n.scales.y.range()[1])&&Zr(n.scales),Ze){const t=n.getData(),e="function"==typeof d?d:t=>t[d||"x"],r="function"==typeof m?m:t=>t[m||"y"];Pn(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),Cn(t.map(t=>r(t)).filter(t=>"number"==typeof t&&isFinite(t)))}}!((ue&&ue.length>0||ar)&&(u||a))||!u&&33>i-Ur.current||(qr(t=>t+1),Ur.current=i),Oe?.showBadge&&yn(!!v),(a||null!=n.activeTransition||y.pending)&&Or()},Ir(Oe,Dn,xr,Or,dn,yn);const Jn=Nt(()=>{if(Ut||Jt)return;const t=Dn.current;return t?.xIsDate&&Kr?Mn(Kr.x.domain()):void 0},[Ut,Jt,Kr]),Qn=Ut||Jt||Jn,ei=Hr&&nn?ee?ee(nn):Si(di,{hover:nn}):null,ri=ei?Si(h,{x:nn.x,y:nn.y,containerWidth:Xr,containerHeight:jr,margin:Br,className:"stream-frame-tooltip",children:ei}):null,ni=Hn.current,ai=Si(f,{active:Gn.current>=0,hoverPoint:nn,margin:Br,size:Lr,shape:ni?.shape,width:ni?.w,height:ni?.h}),si=An(d,X,"__semiotic_resolvedX","__semiotic_resolvedTime"),ci=An(m,O,"__semiotic_resolvedY","__semiotic_resolvedValue"),li=si.key,ui=ci.key,hi=function(t,e,r){return n=>{if(!n||!r||!t.fn&&!e.fn)return n;let i=!1;const o=n.map(r=>{const n=t.fn&&t.key&&!(t.key in r),o=e.fn&&e.key&&!(e.key in r);if(!n&&!o)return r;i=!0;const a={...r};return n&&(a[t.key]=t.fn(r)),o&&(a[e.key]=e.fn(r)),a});return i?o:n}}(si,ci,ue&&ue.length>0||!1);if(E||!Sr&&Mr){const t=Dn.current;t&&i&&(t.ingest({inserts:Gr,bounded:!0}),t.computeScene({width:Xr,height:jr}));const e=t?.scene??[],r=t?.scales??null,n=bn(Ce,Lr,Br,r),o=bn(_e,Lr,Br,r),s=Qn||(()=>{if(t?.xIsDate&&r)return Mn(r.x.domain())})();return Mi("div",{ref:Cr,className:"stream-xy-frame"+(ct?" "+ct:""),role:"img","aria-label":rr||("string"==typeof De?De:"XY chart"),style:{position:"relative",width:ot?"100%":Lr[0],height:at?"100%":Lr[1]},children:[Si(p,{summary:nr}),Mi("svg",{xmlns:"http://www.w3.org/2000/svg",width:Lr[0],height:Lr[1],style:{position:"absolute",left:0,top:0},children:[Si("g",{transform:`translate(${Br.left},${Br.top})`,children:o}),Mi("g",{transform:`translate(${Br.left},${Br.top})`,children:[lt&&Si("rect",{x:0,y:0,width:Xr,height:jr,fill:lt}),Te&&r&&Te.map((t,n)=>Si(Dt.Fragment,{children:t(e,r,{width:Xr,height:jr})},"svgpre-"+n)),e.map((t,e)=>oi({node:t,index:e,renderMode:ut,fallback:()=>U(t,e,mr)})).filter(Boolean)]})]}),Si(ln,{width:Xr,height:jr,totalWidth:Lr[0],totalHeight:Lr[1],margin:Br,scales:r,showAxes:Bt,axes:Xt,xLabel:jt,yLabel:Vt,yLabelRight:qt,xFormat:s,yFormat:Kt||Qt,axisExtent:Zt,showGrid:pe,title:De,legend:xe,legendHoverBehavior:ve,legendClickBehavior:be,legendHighlightedCategory:ke,legendIsolatedCategories:we,legendPosition:Ae,legendLayout:Pe,foregroundGraphics:fr(n,a(Dn.current?.customLayoutOverlays,lr??null)),marginalGraphics:Ze,xValues:[],yValues:[],annotations:ue,onAnnotationActivate:he,onObservation:oe??ie,chartId:ae,chartType:"StreamXYFrame",autoPlaceAnnotations:de,svgAnnotationRules:ye,annotationFrame:0,xAccessor:li,yAccessor:ui,annotationData:hi(Dn.current?.getData()),pointNodes:_n(Dn.current?.scene),curve:"string"==typeof T?T:void 0,linkedCrosshairName:ir,linkedCrosshairSourceId:or})]})}return Mi("div",{ref:Cr,className:"stream-xy-frame"+(ct?" "+ct:""),role:"group","aria-label":rr||("string"==typeof De?De:"XY chart"),tabIndex:0,style:{position:"relative",width:ot?"100%":Lr[0],height:at?"100%":Lr[1],overflow:"visible",touchAction:Li(Re)},onKeyDown:Vn,children:["production"!==process.env.NODE_ENV&&Dn.current&&Si(y,{store:Dn.current,diagnostics:fn.current}),er&&Si(g,{tableId:Yr}),er&&Si(c,{scene:Dn.current?.scene??[],chartType:r+" chart",tableId:Yr,chartTitle:"string"==typeof De?De:void 0}),Si(p,{summary:nr}),Si(l,{hoverPoint:nn}),Mi("div",{role:"img","aria-label":rr||("string"==typeof De?De:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:Hr?qn:void 0,onMouseMove:Hr?Un:void 0,onPointerLeave:Hr?Bn:void 0,onMouseLeave:Hr?Bn:void 0,onPointerDown:Hr||yr?Kn:void 0,onClick:yr?jn:void 0,children:[Si(u,{size:Lr,margin:Br,children:Qr}),Si(an,{width:Xr,height:jr,totalWidth:Lr[0],totalHeight:Lr[1],margin:Br,scales:Kr,showAxes:Bt,axes:Xt,showGrid:pe,xFormat:Qn,yFormat:Kt||Qt,axisExtent:Zt}),Si("canvas",{ref:Wn,"aria-label":w(Dn.current?.scene??[],r+" chart"),style:{position:"absolute",left:0,top:0}}),Si("canvas",{ref:In,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),Si(ln,{width:Xr,height:jr,totalWidth:Lr[0],totalHeight:Lr[1],margin:Br,scales:Kr,showAxes:Bt,axes:Xt,xLabel:jt,yLabel:Vt,yLabelRight:qt,xFormat:Qn,yFormat:Kt||Qt,axisExtent:Zt,showGrid:pe,title:De,legend:xe,legendHoverBehavior:ve,legendClickBehavior:be,legendHighlightedCategory:ke,legendIsolatedCategories:we,legendPosition:Ae,legendLayout:Pe,foregroundGraphics:fr(Jr,a(Dn.current?.customLayoutOverlays,lr??null)),marginalGraphics:Ze,xValues:mn,yValues:Sn,annotations:ue,onAnnotationActivate:he,onObservation:oe??ie,chartId:ae,chartType:"StreamXYFrame",autoPlaceAnnotations:de,svgAnnotationRules:ye,annotationFrame:Vr,xAccessor:li,yAccessor:ui,annotationData:hi(Dn.current?.getData()),pointNodes:_n(Dn.current?.scene),curve:"string"==typeof T?T:void 0,underlayRendered:!0,canvasObscuresUnderlay:!!pn({background:lt,hasBackgroundGraphics:!!_e,themeBackground:Tr?.colors.background}),linkedCrosshairName:ir,linkedCrosshairSourceId:or}),(Re||Ye)&&Si(Gt,{width:Xr,height:jr,totalWidth:Lr[0],totalHeight:Lr[1],margin:Br,dimension:Re?.dimension??"xy",scales:Kr,onBrush:Ye??(()=>{}),binSize:I,snap:Re?.snap,binBoundaries:Re?.binBoundaries??("bar"===r?Dn.current?.getBinBoundaries():void 0),snapDuring:Re?.snapDuring,streaming:"streaming"===n}),Oe?.showBadge&&Si(Fr,{isStale:dn,position:Oe.badgePosition}),ai,ri]})]})}));Ti.displayName="StreamXYFrame";var Di=Ti;function Ei(t){const{title:e,description:r,summary:n,accessibleTable:i,className:o,animate:a,axisExtent:s,autoPlaceAnnotations:c}=t,l={};return e&&(l.title=e),r&&(l.description=r),n&&(l.summary=n),void 0!==i&&(l.accessibleTable=i),o&&(l.className=o),null!=a&&(l.animate=a),void 0!==s&&(l.axisExtent=s),void 0!==c&&(l.autoPlaceAnnotations=c),l}function Ri(t){const{linkedHover:e,selection:r,onObservation:n,onClick:i,hoverRadius:o,hoverHighlight:a,forceHoverBehavior:s,forceClickBehavior:c,mobileInteraction:l,customHoverBehavior:u,customClickBehavior:h,linkedHoverInClickPredicate:f=!0}=t,d={};n&&(d.annotationObservationCallback=n);const y=l?.enabled?Math.max(o??30,Math.ceil((l.targetSize||44)/2),24):o;return(s||e||n||i||a)&&(d.customHoverBehavior=u),h&&(c||(f?n||i||e:n||i)||l?.enabled&&(l.tapToSelect||l.tapToLockTooltip)&&(e||a||r))&&(d.customClickBehavior=h),null!=y&&(d.hoverRadius=y),d}function Yi(t,e,r){const n="function"==typeof e?e(t):t[e??r];if(null==n)return null;if(n instanceof Date)return n.getTime();if("string"==typeof n&&""===n.trim())return null;const i=Number(n);return Number.isFinite(i)?i:null}function Ni({data:t,valueAccessor:e,timeAccessor:r,binSize:n,valueExtent:i,extentPadding:o}){if(i)return[i[1],i[0]];if(!t||0===t.length)return;const a=new Map;for(const i of t){const t=Yi(i,r,"time"),o=Yi(i,e,"value");if(null==t||null==o)continue;const s=Math.floor(t/n)*n;a.set(s,(a.get(s)??0)+o)}let s=0;for(const t of a.values())s=Math.max(s,t);return[s>0?s+s*(o??.1):1,0]}function $i(t,e){var r=t.get(e);if(!r)throw Error("missing: "+e);return r}function Wi(t,e){var r,n=[],i=[],o=[],a={},s=[];function c(t){o[t]=!1,a.hasOwnProperty(t)&&Object.keys(a[t]).forEach(function(e){delete a[t][e],o[e]&&c(e)})}function l(t){var e,n,h=!1;for(i.push(t),o[t]=!0,e=0;s[t].length>e;e++)(n=s[t][e])===r?(u(r,i),h=!0):o[n]||(h=l(n));if(h)c(t);else for(e=0;s[t].length>e;e++){var f=a[n=s[t][e]];f||(a[n]=f={}),f[n]=!0}return i.pop(),h}function u(t,r){var i=[].concat(r).concat(t);e?e(i):n.push(i)}function h(e){!function(e){for(var r=0;t.length>r;r++)r>=e&&t[r]||(t[r]=[]),t[r]=t[r].filter(function(t){return t>=e})}(e);for(var r,n=function(t){for(var e=t.length,r=Array(e),n=Array(e),i=Array(e),o=Array(e),a=Array(e),s=Array(e),c=0;e>c;++c)r[c]=-1,n[c]=0,i[c]=!1,o[c]=0,a[c]=-1,s[c]=[];var l,u=0,h=[],f=[];function d(e){var c=[e],l=[e];for(r[e]=n[e]=u,i[e]=!0,u+=1;l.length>0;){var d=t[e=l[l.length-1]];if(d.length>o[e]){for(var y=o[e];d.length>y;++y){var p=d[y];if(0>r[p]){r[p]=n[p]=u,i[p]=!0,u+=1,c.push(p),l.push(p);break}i[p]&&(n[e]=0|Math.min(n[e],n[p])),0>a[p]||s[e].push(a[p])}o[e]=y}else{if(n[e]===r[e]){var g=[],m=[],x=0;for(y=c.length-1;y>=0;--y){var v=c[y];if(i[v]=!1,g.push(v),m.push(s[v]),x+=s[v].length,a[v]=h.length,v===e){c.length=y;break}}h.push(g);var b=Array(x);for(y=0;m.length>y;y++)for(var k=0;m[y].length>k;k++)b[--x]=m[y][k];f.push(b)}l.pop()}}}for(c=0;e>c;++c)0>r[c]&&d(c);for(c=0;f.length>c;c++){var y=f[c];if(0!==y.length){y.sort(function(t,e){return t-e}),l=[y[0]];for(var p=1;y.length>p;p++)y[p]!==y[p-1]&&l.push(y[p]);f[c]=l}}return{components:h,adjacencyList:f}}(t),i=n.components.filter(function(t){return t.length>1}),o=1/0,a=0;i.length>a;a++)for(var s=0;i[a].length>s;s++)o>i[a][s]&&(o=i[a][s],r=a);var c=i[r];return!!c&&{leastVertex:o,adjList:t.map(function(t,e){return-1===c.indexOf(e)?[]:t.filter(function(t){return-1!==c.indexOf(t)})})}}r=0;for(var f=t.length;f>r;){var d=h(r);if(r=d.leastVertex,s=d.adjList){for(var y=0;s.length>y;y++)for(var p=0;s[y].length>p;p++){var g=s[y][p];o[+g]=!1,a[g]={}}l(r),r+=1}else r=f}return e?void 0:n}function Ii(t){return t.y0-t.y1>0?"up":"down"}function Oi(t,e){return e(t.source)==e(t.target)}function Fi(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var r=0;return t.target.targetLinks.forEach(function(t){r=t.circular?r+1:r}),1>=e&&1>=r}function zi(t){return t.target.x0-t.source.x1}function Bi(t,e){var r=ji(t),n=zi(e)/Math.tan(r);return"up"==Ii(t)?t.y1-n:t.y1+n}function Xi(t,e){var r=ji(t),n=zi(e)/Math.tan(r);return"up"==Ii(t)?t.y1+n:t.y1-n}function ji(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function Gi(t,e){return e(t)}function Hi(t){return qi(t.source)}function Vi(t){return qi(t.target)}function qi(t){return(t.y0+t.y1)/2}function Ui(t){return t.virtual?0:t.value}function Ki(t,e){var r=0;t.sourceLinks.forEach(function(t){r=t.circular&&!Oi(t,e)?r+1:r});var n=0;return t.targetLinks.forEach(function(t){n=t.circular&&!Oi(t,e)?n+1:n}),r+n}function Zi(t){return t.target.depth}function Ji(t,e){return t.sourceLinks.length?t.depth:e-1}function Qi(t,e){return t.y0-e.y0}function to(t,e){return e.y0-t.y0}function eo(t,e){return t.y1-e.y1}function ro(t,e){return e.y1-t.y1}function no(t,e){return oo(t.source,e.source)||t.index-e.index}function io(t,e){return oo(t.target,e.target)||t.index-e.index}function oo(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function ao(t,e){return so(t)==so(e)?"bottom"==t.circularLinkType?to(t,e):Qi(t,e):so(e)-so(t)}function so(t){return t.target.column-t.source.column}function co(t,e){return lo(t)==lo(e)}function lo(t){return t.y0-t.y1>0?"up":"down"}import{min as uo}from"d3-array";function ho(t,e,r,n,i){let o=t;var a=Math.max(8,.15*(o.y1-o.y0));o.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,a))});var s=uo(o.links,function(t){return t.source.y0});o.links.forEach(function(t){t.circular&&(t.circularPathData={})});var c=o.links.filter(function(t){return t.circular});return c.sort(function(t,e){return e.value-t.value}),c.forEach(function(t,e){t._circularStub=e>=4}),fo(o.links.filter(function(t){return"top"==t.circularLinkType}),e,r),fo(o.links.filter(function(t){return"bottom"==t.circularLinkType}),e,r),o.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+n,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,Oi(t,e)&&Fi(t))t.circularPathData.rightSmallArcRadius=n+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=n+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=n+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=n+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+i+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-i-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var a=t.source.column,c=t.circularLinkType,l=o.links.filter(function(t){return t.source.column==a&&t.circularLinkType==c});l.sort("bottom"==t.circularLinkType?to:Qi);var u=0;l.forEach(function(e,i){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=n+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=n+t._circularWidth/2+i*r+u),u+=e._circularWidth||e.width}),a=t.target.column,(l=o.links.filter(function(t){return t.target.column==a&&t.circularLinkType==c})).sort("bottom"==t.circularLinkType?ro:eo),u=0,l.forEach(function(e,i){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=n+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=n+t._circularWidth/2+i*r+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(o.y1,t.source.y1,t.target.y1)+i+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=s-i-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,r=t.y0,n=t.target.x0,i=t.y1,o=(e+n)/2;return"M"+e+","+r+"C"+o+","+r+" "+o+","+i+" "+n+","+i}(t)}),o}function fo(t,e,r){t.sort(ao);var n=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,i){var o=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(Oi(t,e)&&Fi(t))t.circularPathData.verticalBuffer=o+t._circularWidth/2;else{for(var a=0;n.length>a;a++){var s=n[a];if(s!==t&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&yo(t,s)){var c=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+r;o=c>o?c:o}}t.circularPathData.verticalBuffer=o+t._circularWidth/2}}),t}function yo(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}import{min as po,max as go,sum as mo,mean as xo,group as vo,groups as bo}from"d3-array";function ko(t){return function(){return t}}function wo(t){return t.index}function Ao(t){return t.nodes}function Po(t){return t.links}function So(t,e,r){var n=bo(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});n.forEach(function(i,o){var a=i.length;if(e)i.sort(e);else if(o>0){var s=new Map;i.forEach(function(t,e){var r,n,i,o=(n=0,i=0,(r=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;i+=qi(t.source)*e,n+=e}}),r.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;i+=qi(t.target)*e,n+=e}}),n>0?i/n:NaN);s.set(t,{bc:o,idx:e})}),i.sort(function(t,e){var r=s.get(t),n=s.get(e),i=r.bc,o=n.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(i)||isNaN(o)?isNaN(i)?isNaN(o)?r.idx-n.idx:1:-1:i-o})}else i.sort(function(t,e){return t.circularLinkType==e.circularLinkType?Ki(e,r)-Ki(t,r):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});i.forEach(function(e,i){e.depth==n.length-1&&1==a||0==e.depth&&1==a?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==Ki(e,r)?(e.y0=t.y1/2+i,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+i,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-i,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/a*i,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-a/2+i,e.y1=e.y0+e.value*t.ky)})})}function Mo(t,e,r,n,i,o){var a=bo(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});u();for(var s=1,c=o;c>0;--c)l(s*=.99,r),u();function l(e,r){var n=a.length;a.forEach(function(i){var o=i.length,a=i[0].depth;i.forEach(function(i){var s;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&Ki(i,r)>0){var c=xo(i.sourceLinks,Vi),l=xo(i.targetLinks,Hi),u=c&&l?(c+l)/2:c||l;if(u){var h=(u-qi(i))*e*.3;i.y0+=h,i.y1+=h}}else if(0==a&&1==o)i.y0=t.y1/2-(s=i.y1-i.y0)/2,i.y1=t.y1/2+s/2;else if(a==n-1&&1==o)i.y0=t.y1/2-(s=i.y1-i.y0)/2,i.y1=t.y1/2+s/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)s=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+s;else{var f=xo(i.sourceLinks,Vi),d=xo(i.targetLinks,Hi),y=((f&&d?(f+d)/2:f||d)-qi(i))*e;i.y0+=y,i.y1+=y}})})}function u(){a.forEach(function(r){var o,a,s,c=t.y0,l=r.length;for(r.sort(e||oo),s=0;l>s;++s)(a=c-(o=r[s]).y0)>0&&(o.y0+=a,o.y1+=a),c=o.y1+n;if((a=c-n-t.y1)>0)for(c=o.y0-=a,o.y1-=a,s=l-2;s>=0;--s)(a=(o=r[s]).y1+i-c)>0&&(o.y0-=a,o.y1-=a),c=o.y0})}}function _o(t){t.nodes.forEach(function(t){t.sourceLinks.sort(io),t.targetLinks.sort(no)}),t.nodes.forEach(function(t){var e=t.y0,r=e,n=t.y1,i=n;t.sourceLinks.forEach(function(t){t.circular?(t.y0=n-t.width/2,n-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=i-t.width/2,i-=t.width):(t.y1=r+t.width/2,r+=t.width)})})}function Co(){var t=0,e=0,r=1,n=1,i=24,o=8,a=null,s=wo,c=Ji,l=void 0,u=32,h=2,f=Ao,d=Po;function y(){var y={nodes:f.apply(null,arguments),links:d.apply(null,arguments)};return function(f){f.x0=t,f.y0=e,f.x1=r,f.y1=n,f.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var r=function(t,e){var r=new Map;return vo(t,e).forEach(function(t,e){r.set(e,t[0])}),r}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var n=t.source,i=t.target;"object"!=typeof n&&(n=t.source=$i(r,n)),"object"!=typeof i&&(i=t.target=$i(r,i)),n.sourceLinks.push(t),i.targetLinks.push(t)})}(f,s),function(t,e){var r=0;if(null==e){for(var n=[],i=0;t.links.length>i;i++){var o=t.links[i],a=o.source.index,s=o.target.index;n[a]||(n[a]=[]),n[s]||(n[s]=[]),-1===n[a].indexOf(s)&&n[a].push(s)}var c=Wi(n);c.sort(function(t,e){return t.length-e.length});var l={};for(i=0;c.length>i;i++){var u=c[i].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,n=t.source.index;e===n||l[n]&&l[n][e]?(t.circular=!0,t.circularLinkID=r++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=r++)})}(f,l),function(t,e){var r=0,n=0;t.links.forEach(function(i){i.circular&&(i.circularLinkType=i.source.circularLinkType||i.target.circularLinkType?i.source.circularLinkType?i.source.circularLinkType:i.target.circularLinkType:n>r?"top":"bottom","top"==i.circularLinkType?r++:n++,t.nodes.forEach(function(t){Gi(t,e)!=Gi(i.source,e)&&Gi(t,e)!=Gi(i.target,e)||(t.circularLinkType=i.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),Oi(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(f,s),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(mo(t.sourceLinks,Ui),mo(t.targetLinks,Ui)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(f),function(t,e,r){var n,i,o;if(null!=e){t.nodes.sort(function(t,r){return e(t)<e(r)?-1:1});var a=0,s=e(t.nodes[0]);t.nodes.forEach(function(t){a=e(t)==s?a:a+1,s=e(t)==s?s:e(t),t.column=a})}for(n=t.nodes,i=[],o=0;n.length;++o,n=i,i=[])n.forEach(function(t){t.depth=o,t.sourceLinks.forEach(function(t){0>i.indexOf(t.target)&&!t.circular&&i.push(t.target)})});for(n=t.nodes,i=[],o=0;n.length;++o,n=i,i=[])n.forEach(function(t){t.height=o,t.targetLinks.forEach(function(t){0>i.indexOf(t.source)&&!t.circular&&i.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?r(t,o):t.column})}(f,l,c);var d=o;if(null!==a){var y=bo(f.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=go(y,function(t){return t.length});p>1&&(d=Math.max(1,(n-e)*a/(p-1)))}(function(t,e,r){var n=bo(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var i=po(n,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/mo(e,function(t){return t.value})});t.ky=i,t.links.forEach(function(e){e.width=e.value*t.ky});var o=go(t.nodes,function(t){return t.column});t.nodes.forEach(o>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-r)/o),e.x1=e.x0+r}:function(e){e.x0=t.x0,e.x1=e.x0+r})})(f,d,i),So(f,l,s),Mo(f,l,s,d,d,u),_o(f),ho(f,s,h,10,8),So(f,l,s),Mo(f,l,s,d,d,u),_o(f),ho(f,s,h,10,8),function(t,e){let r=t;r.nodes.forEach(function(t){t.y+(t.y1-t.y0)>r.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-r.y1));var n=r.links.filter(function(r){return Gi(r.source,e)==Gi(t,e)}),i=n.length;i>1&&n.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!co(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var r=Bi(e,t);return t.y1-r}if(e.target.column>t.target.column)return Bi(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var o=t.y0;n.forEach(function(t){t.y0=o+t.width/2,o+=t.width}),n.forEach(function(e,r){if("bottom"==e.circularLinkType){for(var o=r+1,a=0;i>o;o++)a+=n[o].width;e.y0=t.y1-a-e.width/2}})})}(f,s),function(t,e){let r=t;r.nodes.forEach(function(t){var n=r.links.filter(function(r){return Gi(r.target,e)==Gi(t,e)}),i=n.length;i>1&&n.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!co(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var r=Xi(e,t);return t.y0-r}if(e.source.column>t.source.column)return Xi(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var o=t.y0;n.forEach(function(t){t.y1=o+t.width/2,o+=t.width}),n.forEach(function(e,r){if("bottom"==e.circularLinkType){for(var o=r+1,a=0;i>o;o++)a+=n[o].width;e.y1=t.y1-a-e.width/2}})})}(f,s),function(t){var e=t.nodes,r=t.links,n=!1,i=!1;if(r.forEach(function(t){"top"==t.circularLinkType?n=!0:"bottom"==t.circularLinkType&&(i=!0)}),0==n||0==i){let n=function(e){return(e-o)/(a-o)*(t.y1-t.y0)+t.y0};var o=po(e,function(t){return t.y0}),a=go(e,function(t){return t.y1}),s=(t.y1-t.y0)/(a-o);1>s?(e.forEach(function(t){t.y0=n(t.y0),t.y1=n(t.y1)}),r.forEach(function(t){t.y0=n(t.y0),t.y1=n(t.y1),t.width=t.width*s})):e.forEach(function(t){var e=t.y1-t.y0,r=n(t.y0)-t.y0;t.y0=n(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+r}),t.targetLinks.forEach(function(t){t.y1=t.y1+r})})}}(f),ho(f,s,h,10,8)}(y),y}return y.update=function(t){return _o(t),ho(t,s,h,10,8),t},y.nodeWidth=function(t){return arguments.length?(i=+t,y):i},y.nodePadding=function(t){return arguments.length?(o=+t,y):o},y.nodePaddingRatio=function(t){return arguments.length?(a=+t,y):a},y.nodes=function(t){return arguments.length?(f="function"==typeof t?t:ko(t),y):f},y.links=function(t){return arguments.length?(d="function"==typeof t?t:ko(t),y):d},y.nodeId=function(t){return arguments.length?(s="function"==typeof t?t:ko(t),y):s},y.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:ko(t),y):c},y.nodeSort=function(t){return arguments.length?(l=t,y):l},y.iterations=function(t){return arguments.length?(u=+t,y):u},y.circularLinkGap=function(t){return arguments.length?(h=+t,y):h},y.extent=function(i){return arguments.length?(t=+i[0][0],e=+i[0][1],r=+i[1][0],n=+i[1][1],y):[[t,e],[r,n]]},y.size=function(i){return arguments.length?(t=e=0,r=+i[0],n=+i[1],y):[r-t,n-e]},y}import{interpolateNumber as Lo}from"d3-interpolate";import{line as To,curveLinearClosed as Do}from"d3-shape";function Eo(t){const{sx:e,sTop:r,sBot:n,tx:i,tTop:o,tBot:a,cp1X:s,cp2X:c}=t,l=(r+n)/2,u=(o+a)/2;return{pathD:[`M${e},${r}`,`C${s},${r} ${c},${o} ${i},${o}`,`L${i},${a}`,`C${c},${a} ${s},${n} ${e},${n}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:e,y:l},{x:s,y:l},{x:c,y:u},{x:i,y:u}],halfWidth:(n-r)/2}}}var Ro=t=>{let e,r,n,i,o,a,s,c,l;if("down"===t.direction)return e=t.y0-t.sankeyWidth/2,r=t.y1-t.sankeyWidth/2,n=t.y1+t.sankeyWidth/2,i=t.y0+t.sankeyWidth/2,o=t.source.x1,a=t.target.x0,s=Lo(o,a),c=s(.5),l=s(.5),`M${e},${o}C${e},${c} ${r},${l} ${r},${a}L${n},${a}C${n},${l} ${i},${c} ${i},${o}Z`;const u=t.sankeyWidth/2,h=Lo(t.source.x1,t.target.x0),{pathD:f}=Eo({sx:t.source.x1,sTop:t.y0-u,sBot:t.y0+u,tx:t.target.x0,tTop:t.y1-u,tBot:t.y1+u,cp1X:h(.5),cp2X:h(.5)});return f};function Yo(t){const e=t.sankeyWidth/2,r=(t._circularWidth??t.sankeyWidth)/2,n=t.circularPathData;if(!n)return null;if("down"===t.direction)return null;if(t._circularStub){const r=n.sourceX,i=n.sourceY,o=n.targetX,a=n.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const s=Math.max(15,Math.min(40,.33*(n.rightFullExtent-r))),c=Math.max(15,Math.min(40,.33*(o-n.leftFullExtent)));return`M${r},${i-e}L${r+s},${i-e}L${r+s},${i+e}L${r},${i+e}ZM${o},${a-e}L${o-c},${a-e}L${o-c},${a+e}L${o},${a+e}Z`}const i=n.sourceX,o=n.sourceY,a=n.targetX,s=n.targetY,c=n.rightFullExtent,l=n.leftFullExtent,u=n.verticalFullExtent,h="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(r,15));return`M${i},${o-h*e}L${c},${o-h*e}L${c+r},${o-h*e+h*f}L${c+r},${u+h*r-h*f}L${c+r-f},${u+h*r}L${l-r+f},${u+h*r}L${l-r},${u+h*r-h*f}L${l-r},${s-h*e+h*f}L${l-r+f},${s-h*e}L${a},${s-h*e}L${a},${s+h*e}L${l+r},${s+h*e}L${l+r},${u-h*r}L${c-r},${u-h*r}L${c-r},${o+h*e}L${i},${o+h*e}Z`}var No={left:function(t){return t.depth},right:function(t,e){return e-1-t.height},center:function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Math.min.apply(Math,t.sourceLinks.map(Zi))-1:0},justify:Ji};function $o(t){return"string"==typeof t?t:t.id}var Wo={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,r,n){if(0===t.length)return;const i="vertical"===r.orientation?"down":"right",o=r.nodeAlign||"justify",a=r.nodeWidth??15,s=r.nodePaddingRatio??.05,c=r.iterations??100,l=t.map(t=>({...t})),u=e.map(t=>({...t,source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let h;h="down"===i?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const f=Co().extent(h).links(u).nodes(l).nodeAlign(No[o]||Ji).nodeId(t=>t.id).nodeWidth(a).iterations(c);f.nodePaddingRatio&&f.nodePaddingRatio(s),f();{let t=1/0,e=-1/0,r=1/0,i=-1/0;for(const n of l)t>n.x0&&(t=n.x0),n.x1>e&&(e=n.x1),r>n.y0&&(r=n.y0),n.y1>i&&(i=n.y1);for(const n of u){if(!n.circular||!n.circularPathData)continue;const o=n.circularPathData,a=(n._circularWidth??n.width??0)/2;t>o.leftFullExtent-a&&(t=o.leftFullExtent-a),o.rightFullExtent+a>e&&(e=o.rightFullExtent+a),r>o.verticalFullExtent-a&&(r=o.verticalFullExtent-a),o.verticalFullExtent+a>i&&(i=o.verticalFullExtent+a)}const o=e-t,a=i-r,s=n[0],c=n[1];if(o>0&&a>0&&(0>t||0>r||e>s||i>c)){const e=Math.min(s/o,c/a),n=-t*e+(s-o*e)/2,i=-r*e+(c-a*e)/2;for(const t of l)t.x0=t.x0*e+n,t.x1=t.x1*e+n,t.y0=t.y0*e+i,t.y1=t.y1*e+i;for(const t of u)if(t.y0=t.y0*e+i,t.y1=t.y1*e+i,t.width=(t.width??0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const r=t.circularPathData;r.sourceX=r.sourceX*e+n,r.targetX=r.targetX*e+n,r.sourceY=r.sourceY*e+i,r.targetY=r.targetY*e+i,r.rightFullExtent=r.rightFullExtent*e+n,r.leftFullExtent=r.leftFullExtent*e+n,r.verticalFullExtent=r.verticalFullExtent*e+i,r.rightInnerExtent=r.rightInnerExtent*e+n,r.leftInnerExtent=r.leftInnerExtent*e+n,r.verticalRightInnerExtent=r.verticalRightInnerExtent*e+i,r.verticalLeftInnerExtent=r.verticalLeftInnerExtent*e+i,r.rightSmallArcRadius*=e,r.rightLargeArcRadius*=e,r.leftSmallArcRadius*=e,r.leftLargeArcRadius*=e,r.sourceWidth*=e,r.rightNodeBuffer*=e,r.leftNodeBuffer*=e,r.arcRadius*=e}}}const d=new Map;for(const e of t)d.set(e.id,e);for(const t of l){const e=d.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const y=new Map;for(const t of e)y.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of u){const e=$o(t.source),r=$o(t.target),n=y.get(t._edgeKey?t._edgeKey:`${e}\0${r}`);if(n){n.y0=t.y0,n.y1=t.y1,n.sankeyWidth=t.width??0,n.circular=!!t.circular,n.circularPathData=t.circularPathData,n._circularWidth=t._circularWidth,n._circularStub=t._circularStub,n.path=t.path,n.circularLinkType=t.circularLinkType,n.direction=i;const o=d.get(e),a=d.get(r);o&&(n.source=o),a&&(n.target=a)}}},buildScene(t,e,r,n){const i="vertical"===r.orientation?"down":"right",o=r.nodeStyle,a=r.edgeStyle,c=r.edgeOpacity??.5,l=r.edgeColorBy||"source",u=Array.isArray(r.colorScheme)?r.colorScheme:r.themeCategorical&&r.themeCategorical.length>0?r.themeCategorical:vt,h=new Map;t.forEach((t,e)=>{h.set(t.id,u[e%u.length])});const f=[],d=[],y=[],p=new Map;for(const e of t){const t=e.x1-e.x0,r=e.y1-e.y0;if(0>=t||0>=r)continue;const n=o?o(s(e,"nodeStyle")):{},a={fill:n.fill||h.get(e.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};p.set(e.id,("string"==typeof a.fill?a.fill:null)||h.get(e.id)||"#4d430c"),f.push("down"===i?{type:"rect",x:e.y0,y:e.x0,w:r,h:t,style:a,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:r,style:a,datum:e,id:e.id,label:e.id})}const g=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of g){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;if(!e||!n)continue;let i=r.themeSemantic?.border||r.themeSemantic?.secondary||"#999";i="function"==typeof l?l(t)||i:"target"===l?p.get(n.id)||h.get(n.id)||i:p.get(e.id)||h.get(e.id)||i;const o=a?a(s(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,r=t.sankeyWidth/2,n=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),a=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),s=o.fill||i;d.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-r}L${e.sourceX+n},${e.sourceY-r}L${e.sourceX+n},${e.sourceY+r}L${e.sourceX},${e.sourceY+r}Z`,style:{fill:s,fillOpacity:o.fillOpacity??c,stroke:"none",opacity:o.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+n}}),d.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-r}L${e.targetX-a},${e.targetY-r}L${e.targetX-a},${e.targetY+r}L${e.targetX},${e.targetY+r}Z`,style:{fill:s,fillOpacity:o.fillOpacity??c,stroke:"none",opacity:o.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-a,x1:e.targetX}});continue}let u;(u=t.circular&&t.circularPathData?Yo(t):Ro(t),u)&&d.push({type:"bezier",pathD:u,bezierCache:t.bezier,style:{fill:o.fill||i,fillOpacity:o.fillOpacity??c,stroke:o.stroke||"none",strokeWidth:o.strokeWidth,opacity:o.opacity},datum:t})}if(!1!==r.showLabels){const e=(m=r.nodeLabel)?"function"==typeof m?m:t=>t[m]||t.id:null;for(const r of t){const t=r.x1-r.x0,o=r.y1-r.y0;if(0>=t||0>=o)continue;const a=e?e(r):r.id;if(!a)continue;let s,c,l;"down"===i?(s=r.y0+(r.y1-r.y0)/2,c=r.x1+14,l="start"):(n[0]/2>r.x0+t/2?(s=r.x0-6,l="end"):(s=r.x1+6,l="start"),c=r.y0+o/2),y.push({x:s,y:c,text:a+"",anchor:"down"===i?"middle":l,baseline:"middle",fontSize:11})}}var m;return{sceneNodes:f,sceneEdges:d,labels:y}}};import{chord as Io,ribbon as Oo}from"d3-chord";import{arc as Fo}from"d3-shape";var zo=vt,Bo={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,r,n){if(0===t.length)return;const{padAngle:i=.01,groupWidth:o=20,sortGroups:a}=r,s=Math.min(n[0],n[1])/2,c=s-o,l=n[0]/2,u=n[1]/2,h=(f=r.valueAccessor)?"function"==typeof f?f:t=>t[f]??1:t=>t.value??1;var f;const d=new Map;for(let e=0;t.length>e;e++)d.set(t[e].id,e);const y=t.length,p=Array.from({length:y},()=>Array.from({length:y},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,r=d.get("string"==typeof t.source?t.source:t.source.id),n=d.get(e);if(void 0===r||void 0===n)continue;const i=h(t);p[r][n]=i}const g=Io().padAngle(i);a&&g.sortGroups(a);const m=g(p),x=m.groups,v=Fo().innerRadius(c).outerRadius(s);for(const e of x){const r=t[e.index],n=v.centroid({innerRadius:c,outerRadius:s,startAngle:e.startAngle,endAngle:e.endAngle});r.x=n[0]+l,r.y=n[1]+u,r.__arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,r=b.get("string"==typeof t.source?t.source:t.source.id),n=b.get(e);r&&(t.source=r),n&&(t.target=n)}const k=new Map;for(const t of e)k.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of m){const r=t[e.source.index].id,n=t[e.target.index].id,i=k.get(`${r}\0${n}`)||k.get(`${n}\0${r}`);i&&(i.__chordData=e)}},buildScene(t,e,r,n){const{groupWidth:i=20,edgeOpacity:o=.5}=r,a=Math.min(n[0],n[1])/2,c=a-i,l=n[0]/2,u=n[1]/2,h=r.nodeStyle,f=r.edgeStyle,d=r.edgeColorBy||"source",y=Array.isArray(r.colorScheme)?r.colorScheme:r.themeCategorical&&r.themeCategorical.length>0?r.themeCategorical:zo,p=new Map;t.forEach((t,e)=>{p.set(t.id,y[e%y.length])});const g=Oo().radius(c),m=[],x=[],v=[];for(let e=0;t.length>e;e++){const r=t[e],n=r.__arcData;if(!n)continue;let i;i=h?h(s(r,"nodeStyle")).fill||p.get(r.id)||y[e%y.length]:p.get(r.id)||y[e%y.length];const o=h?h(s(r,"nodeStyle")):{};m.push({type:"arc",cx:l,cy:u,innerR:c,outerR:a,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:{fill:i,stroke:o.stroke||"black",strokeWidth:o.strokeWidth??1,opacity:o.opacity},datum:r,id:r.id,label:r.id})}for(const t of e){const e=t.__chordData;if(!e)continue;const n=g(e);if(!n)continue;const i=Xo(n,l,u);let a=r.themeSemantic?.border||r.themeSemantic?.secondary||"#999";if(f)a=f(s(t,"edgeStyle")).fill||a;else{const e="object"==typeof t.source?t.source:null,r="object"==typeof t.target?t.target:null;"target"===d&&r?a=p.get(r.id)||a:e&&(a=p.get(e.id)||a)}const c=f?f(s(t,"edgeStyle")):{};x.push({type:"ribbon",pathD:i,style:{fill:a,fillOpacity:c.fillOpacity??o,stroke:c.stroke||"none",strokeWidth:c.strokeWidth,opacity:c.opacity},datum:t})}if(!1!==r.showLabels){const e=(b=r.nodeLabel)?"function"==typeof b?b:t=>t[b]||t.id:null,n=a+12;for(const r of t){const t=r.__arcData;if(!t)continue;const i=e?e(r):r.id;if(!i)continue;const o=(t.startAngle+t.endAngle)/2,a=o-Math.PI/2;v.push({x:l+Math.cos(a)*n,y:u+Math.sin(a)*n,text:i+"",anchor:o>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var b;return{sceneNodes:m,sceneEdges:x,labels:v}}};function Xo(t,e,r){const n=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return t;const i=[];let o=0;for(;n.length>o;){const t=n[o];if("M"===t||"L"===t)for(i.push(t),o++;n.length>o&&!isNaN(Number(n[o]));)i.push(Number(n[o])+e+""),o++,n.length>o&&!isNaN(Number(n[o]))&&(i.push(Number(n[o])+r+""),o++);else if("C"===t)for(i.push(t),o++;n.length>o&&!isNaN(Number(n[o]));)for(let t=0;3>t&&n.length>o&&!isNaN(Number(n[o]));t++)i.push(Number(n[o])+e+""),o++,n.length>o&&!isNaN(Number(n[o]))&&(i.push(Number(n[o])+r+""),o++);else if("Q"===t)for(i.push(t),o++;n.length>o&&!isNaN(Number(n[o]));)for(let t=0;2>t&&n.length>o&&!isNaN(Number(n[o]));t++)i.push(Number(n[o])+e+""),o++,n.length>o&&!isNaN(Number(n[o]))&&(i.push(Number(n[o])+r+""),o++);else if("A"===t)for(i.push(t),o++;n.length>o&&!isNaN(Number(n[o]));)i.push(n[o++]),n.length>o&&i.push(n[o++]),n.length>o&&i.push(n[o++]),n.length>o&&i.push(n[o++]),n.length>o&&i.push(n[o++]),n.length>o&&(i.push(Number(n[o])+e+""),o++),n.length>o&&(i.push(Number(n[o])+r+""),o++);else"Z"===t||"z"===t?(i.push(t),o++):(i.push(n[o]),o++)}return i.join(" ")}import{hierarchy as jo,tree as Go,cluster as Ho,treemap as Vo,pack as qo,partition as Uo,treemapBinary as Ko}from"d3-hierarchy";var Zo=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Jo(t){const[e,r,n]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*r+.114*n>150?"#222":"#fff"}function Qo(t,e,r){const n=e.nodeIDAccessor;return"function"==typeof n?n(t.data)+"":"string"==typeof n&&void 0!==t.data[n]?t.data[n]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+r}function ta(t){if(!t)return null;if("function"==typeof t){const e=t;return t=>e(t.data??t)}return e=>e.data?.[t]||e[t]||e.id}function ea(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:Zo}function ra(t){return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:t.themeSemantic?.primary?t.themeSemantic.primary:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical[0]:"#4d430c"}function na(t,e,r,n,i){if("horizontal"===i){const i=(t+r)/2;return`M ${t},${e} C ${i},${e} ${i},${n} ${r},${n}`}if("radial"===i){const i=(t+r)/2;return`M ${t},${e} Q ${i},${e} ${i},${(e+n)/2} T ${r},${n}`}{const i=(e+n)/2;return`M ${t},${e} C ${t},${i} ${r},${i} ${r},${n}`}}var ia={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,r,n){const i=r.__hierarchyRoot;if(!i)return;const o=r.chartType,a=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(r.childrenAccessor),s=r.hierarchySum,c="function"==typeof s?s:"string"==typeof s?t=>Number(t[s])||0:t=>Number(t.value)||0,l=jo(i,a);l.sum(c),l.sort((t,e)=>(e.value??0)-(t.value??0));const[u,h]=n;switch(o){case"tree":!function(t,e,r,n){const i=e.treeOrientation||"vertical",o=Go();o.size("horizontal"===i?[n,r]:"radial"===i?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),o(t)}(l,r,u,h);break;case"cluster":!function(t,e,r,n){const i=e.treeOrientation||"vertical",o=Ho();o.size("horizontal"===i?[n,r]:"radial"===i?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),o(t)}(l,r,u,h);break;case"treemap":!function(t,e,r,n){const i=e.padding??4,o=e.paddingTop??0,a=Vo().size([r,n]).tile(Ko).padding(i);o>0&&a.paddingTop(o),a(t)}(l,r,u,h);break;case"circlepack":!function(t,e,r,n){const i=e.padding??4;qo().size([r,n]).padding(i)(t)}(l,r,u,h);break;case"partition":!function(t,e,r,n){Uo().size([r,n]).padding(e.padding??1)(t)}(l,r,u,h)}const f=l.descendants();t.length=0,e.length=0;const d=new Map;for(let e=0;f.length>e;e++){const n=f[e],i={id:Qo(n,r,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:n.value??0,depth:n.depth,data:n.data,createdByFrame:!0};"tree"===o||"cluster"===o?oa(i,n,r):"treemap"===o||"partition"===o?aa(i,n):"circlepack"===o&&sa(i,n),i.__hierarchyNode=n,t.push(i),d.set(n,i)}if("tree"===o||"cluster"===o)for(const t of f)if(t.parent){const r=d.get(t.parent),n=d.get(t);r&&n&&e.push({source:r,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,r,n){const i=r.nodeStyle||(()=>({})),o=r.edgeStyle||(()=>({}));switch(r.chartType){case"tree":case"cluster":return function(t,e,r,n,i,o){const a=[],c=[],l=[],u=r.treeOrientation||"vertical",h="radial"===u,f=n[0]/2,d=n[1]/2,y="number"==typeof(p=r.nodeSize)?p:5;var p;for(const e of t){let t=e.x,n=e.y;h&&(t+=f,n+=d);const o=i(s(e,"nodeStyle"));let c=o.fill||ra(r);if(r.colorByDepth&&void 0!==e.depth){const t=ea(r);c=t[e.depth%t.length]}a.push({type:"circle",cx:t,cy:n,r:y,style:{fill:c,stroke:o.stroke||r.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??1,opacity:o.opacity},datum:e,id:e.id,label:e.id,depth:e.depth})}const g=r.edgeOpacity??.5;for(const t of e){const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;if(!e||!n)continue;let i=e.x,a=e.y,l=n.x,y=n.y;h&&(i+=f,a+=d,l+=f,y+=d);const p=na(i,a,l,y,u),m=o(s(t,"edgeStyle"));c.push({type:"curved",pathD:p,style:{fill:"none",stroke:m.stroke||r.themeSemantic?.border||r.themeSemantic?.secondary||"#999",strokeWidth:m.strokeWidth??1.5,opacity:m.opacity??g},datum:t})}if(!1!==r.showLabels){const e=ta(r.nodeLabel);for(const r of t){const t=e?e(r):r.id;if(!t)continue;let n,i,o,a=r.x,s=r.y;if(h&&(a+=f,s+=d),h){const t=a-f,e=s-d,r=Math.sqrt(t*t+e*e);r>0?(n=a+t/r*10,i=s+e/r*10,o=0>t?"end":"start"):(n=a,i=s-12,o="middle")}else"horizontal"===u?(r.data?.children&&0!==r.data.children.length?(n=a-y-6,o="end"):(n=a+y+6,o="start"),i=s):(n=a,i=s+y+14,o="middle");l.push({x:n,y:i,text:t+"",anchor:o,baseline:"middle",fontSize:11})}}return{sceneNodes:a,sceneEdges:c,labels:l}}(t,e,r,n,i,o);case"treemap":case"partition":return function(t,e,r,n){const i=[],o=[];for(const r of t){const t=r.x1-r.x0,o=r.y1-r.y0;if(0>=t||0>=o)continue;const a=n(s(r,"nodeStyle"));let c=a.fill||ra(e);if(e.colorByDepth&&void 0!==r.depth){const t=ea(e);c=t[r.depth%t.length]}i.push({type:"rect",x:r.x0,y:r.y0,w:t,h:o,style:{fill:c,stroke:a.stroke||e.themeSemantic?.surface||"#fff",strokeWidth:a.strokeWidth??1,opacity:a.opacity},datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==e.showLabels){const r=ta(e.nodeLabel),i=e.labelMode||"leaf",a="partition"===e.chartType;for(const c of t){const t=c.x1-c.x0,l=c.y1-c.y0;if(0>=t||0>=l)continue;const u=!(c.data?.children&&c.data.children.length>0);if(!a){if("leaf"===i&&!u)continue;if("parent"===i&&u)continue}const h=r?r(c):c.id;if(!h)continue;if((u?30:40)>t||(u?16:14)>l)continue;let f=n(s(c,"nodeStyle")).fill||ra(e);if(e.colorByDepth&&void 0!==c.depth){const t=ea(e);f=t[c.depth%t.length]}const d="string"==typeof f?Jo(f):e.themeSemantic?.text??"#000";o.push(u?{x:c.x0+t/2,y:c.y0+l/2,text:h+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,l)/6)),fill:d}:{x:c.x0+4,y:c.y0+12,text:h+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:d})}}return{sceneNodes:i,sceneEdges:[],labels:o}}(t,r,0,i);case"circlepack":return function(t,e,r,n){const i=[],o=[];for(const r of t){const t=r.__radius??5;if(0>=t)continue;const o=n(s(r,"nodeStyle"));let a=o.fill||ra(e);if(e.colorByDepth&&void 0!==r.depth){const t=ea(e);a=t[r.depth%t.length]}i.push({type:"circle",cx:r.x,cy:r.y,r:t,style:{fill:a,stroke:o.stroke||e.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.7},datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==e.showLabels){const r=ta(e.nodeLabel);for(const i of t){const t=i.__radius??5,a=r?r(i):i.id;if(!a)continue;if(15>t)continue;const c=!(i.data?.children&&i.data.children.length>0);let l=n(s(i,"nodeStyle")).fill||ra(e);if(e.colorByDepth&&void 0!==i.depth){const t=ea(e);l=t[i.depth%t.length]}if(c){const r="string"==typeof l?Jo(l):e.themeSemantic?.text??"#000";o.push({x:i.x,y:i.y,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:r})}else o.push({x:i.x,y:i.y-t+14,text:a+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:e.themeSemantic?.text||"#000",stroke:e.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:i,sceneEdges:[],labels:o}}(t,r,0,i);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function oa(t,e,r){const n=r.treeOrientation||"vertical";if("radial"===n){const r=e.x,n=e.y;t.x=n*Math.cos(r-Math.PI/2),t.y=n*Math.sin(r-Math.PI/2)}else"horizontal"===n?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function aa(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function sa(t,e){const r=e.r??0;t.x=e.x,t.y=e.y,t.x0=e.x-r,t.x1=e.x+r,t.y0=e.y-r,t.y1=e.y+r,t.width=2*r,t.height=2*r,t.__radius=r}import{pie as ca}from"d3-shape";function la(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}var ua={sankey:Wo,force:o,chord:Bo,tree:ia,cluster:ia,treemap:ia,circlepack:ia,partition:ia,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,r,n){const i=r.__hierarchyRoot;i&&function(t,e,r,n,i){const o=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(r.childrenAccessor),a=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>(t[e]??"")+""}(r.nodeIDAccessor),s=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(r.orbitMode),c=r.orbitSize??2.95,l=r.orbitEccentricity??1,u="number"==typeof c?()=>c:c,h="number"==typeof l?()=>l:l,f=la(r);f.metaMap.clear(),n.length=0,i.length=0;const d=new Map;function y(t){const e=d.get(t)??0;return d.set(t,e+1),0===e?t:`${t}__${e}`}const p=e[0]/2,g=e[1]/2,m=Math.min(e[0],e[1])/2*.85,x=y(a(t));n.push({id:x,x:p,y:g,x0:p,x1:p,y0:g,y1:g,width:0,height:0,value:0,depth:0,data:t}),f.metaMap.set(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,r,c,l,d,p,g){const m=o(e);if(!m?.length)return;const x=m.length;let v=0,b=0,k=0;for(;x>b;)b+=s[Math.min(k,s.length-1)],k++,v++;let w=0;for(let x=0;v>x;x++){const b=s[Math.min(x,s.length-1)],k=m.slice(w,w+b);if(!k.length)break;const A=(x+1)/v,P={id:r,depth:p,data:e,parentId:r},S=g?d/u(P)*A:d*A,M=ca().value(t=>{const e=o(t)?.length;return e?4:1}).sort(null)(k),_=h(P);for(let e=0;k.length>e;e++){const o=(M[e].startAngle+M[e].endAngle)/2,s=k[e],u=y(a(s)),h=c+S*Math.sin(o),d=l+S*Math.cos(o)*_;n.push({id:u,x:h,y:d,x0:h,x1:h,y0:d,y1:d,width:0,height:0,value:0,depth:p,data:s}),f.metaMap.set(u,{ring:S,angle:o,depth:p,parentId:r,eccentricity:_}),i.push({source:r,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:r,target:u}}),t(s,u,h,d,S,p+1,!0)}w+=b}}(t,x,p,g,m,1,!1)}(i,n,r,t,e)},buildScene(t,e,r,n){const i=r.nodeStyle,o=r.nodeSize,a="number"==typeof o?()=>o:"function"==typeof o?o:()=>6,c=[],l=[],u=[];if(!1!==r.orbitShowRings){const e=la(r),n=new Map;for(const e of t)n.set(e.id,e);const i=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=n.get(t.parentId);if(!e)continue;const r=`${t.parentId}:${t.ring}`;i.has(r)||i.set(r,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const o=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:r,ecc:n}]of i)for(let i=0;o>i;i++){const s=i/o*Math.PI*2,c=(i+1)/o*Math.PI*2;l.push({type:"line",x1:t+r*Math.sin(s),y1:e+r*Math.cos(s)*n,x2:t+r*Math.sin(c),y2:e+r*Math.cos(c)*n,style:a,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=a(s(e,"nodeSize")),n=i?i(s(e,"nodeStyle")):{};c.push({type:"circle",cx:e.x,cy:e.y,r:t,style:{fill:n.fill||r.themeSemantic?.primary||"#6366f1",stroke:n.stroke||r.themeSemantic?.surface||"#fff",strokeWidth:n.strokeWidth??1,opacity:n.opacity??(0===(e.depth??0)?1:.85)},datum:e,id:e.id,label:e.id,depth:e.depth})}const h=new Map;for(const e of t)h.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:h.get(t.source),r="object"==typeof t.target?t.target:h.get(t.target);e&&r&&(null!=e.x&&null!=r.x&&l.push({type:"line",x1:e.x,y1:e.y,x2:r.x,y2:r.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(r.showLabels){const e=r.nodeLabel;for(const r of t){const t=a(s(r,"nodeSize"));if(4>=t)continue;const n="function"==typeof e?e(r):e?r.data?.[e]??r.id:r.id;u.push({x:r.x,y:r.y+t+12,text:n+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:c,sceneEdges:l,labels:u}},tick:(t,e,r,n,i)=>!1!==r.orbitAnimated&&(function(t,e){const r=la(e),n=e.orbitSpeed??.25,i=e.orbitRevolution??function(t){switch(t){case"decay":return t=>Math.pow(.6,t.depth??0);case"alternate":return t=>{const e=t.depth??0;return(e%2==0?1:-1)/(e+1)};default:return t=>1/((t.depth??0)+1)}}(e.orbitRevolutionStyle),o=(("undefined"!=typeof performance?performance.now():Date.now())-r.startTime)/1e3,a=n*(Math.PI/6),s=new Map;for(const e of t)s.set(e.id,e);for(const e of t){const t=r.metaMap.get(e.id);if(!t||!t.parentId)continue;const n=s.get(t.parentId);if(!n)continue;const c=t.angle+o*a*i({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=n.x+t.ring*Math.sin(c),e.y=n.y+t.ring*Math.cos(c)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,r),!0)}};function ha(t){return ua[t]}export{Vt as toIdSet,Mt as resolveMotionAccessor,_t as compileMotionEncoding,Ct as opacityFromAge,Lt as resolveMotionVector,Tt as deriveMotionVector,qt as computeDecayOpacity,Ut as buildDatumIndexMap,Kt as computePulseIntensity,Zt as setPulseState,Jt as hasActivePulses,oe as buildRectNode,ge as normalizeGradient,me as normalizeColorGradient,xe as normalizeSemanticGradient,ve as reverseGradient,Pe as warnCustomLayoutDiagnostics,_e as createCustomLayoutFailureDiagnostic,$e as ensureRingBufferCapacity,We as createTimestampBufferForData,Ie as pushWithTimestamp,Oe as compactTimestampBufferForRemoval,Ve as attachUpdateResultStore,ur as PipelineStore,fr as composeOverlays,pr as useConfigSync,gr as useLayoutSelectionSync,mr as findHitPointInQuadtree,Ir as useStalenessCheck,Fr as StalenessBadge,Kr as ticksForMode,hn as useStableShallow,gn as paintCanvasBackground,mn as needsDataCanvasPaint,En as renderRectPulse,Rn as renderCirclePulse,Gn as networkGlyphRenderer,ii as paintSceneWithBackend,oi as renderSceneWithBackend,ai as renderSceneListWithBackend,li as formatVal,mi as buildNavGraph,xi as resolvePosition,wi as extractNetworkNavPoints,Ai as nextNetworkIndex,Di as StreamXYFrame_default,Eo as buildRibbonGeometry,ha as getLayoutPlugin,Ei as buildBaseMetadataProps,Ri as buildCustomBehaviorProps,Ni as resolveDownwardHistogramExtent};