semiotic 3.8.2 → 3.8.3

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 (113) hide show
  1. package/CLAUDE.md +1 -1
  2. package/README.md +34 -33
  3. package/ai/schema.json +1 -1
  4. package/ai/surface-manifest.json +1 -1
  5. package/ai/system-prompt.md +1 -1
  6. package/dist/{chunk-chunk-C6EJ4IOD.module.min.js → chunk-chunk-2CCFBTQC.module.min.js} +1 -1
  7. package/dist/chunk-chunk-2RXP3FS3.module.min.js +1 -0
  8. package/dist/chunk-chunk-4TMZXLCR.module.min.js +1 -0
  9. package/dist/{chunk-chunk-H4PPRW6N.module.min.js → chunk-chunk-5APBQXZA.module.min.js} +1 -1
  10. package/dist/{chunk-chunk-NO4MCQVD.module.min.js → chunk-chunk-5RKXZQ2P.module.min.js} +1 -1
  11. package/dist/chunk-chunk-6HSGDMTA.module.min.js +2 -0
  12. package/dist/{chunk-chunk-7LHMKRKE.module.min.js → chunk-chunk-7FW6EGLP.module.min.js} +1 -1
  13. package/dist/{chunk-chunk-RH5TSQPH.module.min.js → chunk-chunk-7OEOSCBP.module.min.js} +1 -1
  14. package/dist/{chunk-chunk-FAKO3RGQ.module.min.js → chunk-chunk-A63CTACR.module.min.js} +1 -1
  15. package/dist/chunk-chunk-ANYDWOZF.module.min.js +1 -0
  16. package/dist/{chunk-chunk-ZLKRTF5N.module.min.js → chunk-chunk-AZJUDQRM.module.min.js} +1 -1
  17. package/dist/{chunk-chunk-W3DB2MN4.module.min.js → chunk-chunk-B6V35LMY.module.min.js} +1 -1
  18. package/dist/chunk-chunk-BOSVL645.module.min.js +2 -0
  19. package/dist/chunk-chunk-EMO5NUGE.module.min.js +1 -0
  20. package/dist/chunk-chunk-F25UA5HT.module.min.js +1 -0
  21. package/dist/chunk-chunk-FRIO6MCV.module.min.js +1 -0
  22. package/dist/{chunk-chunk-T27ZEV6A.module.min.js → chunk-chunk-GWSWSPXN.module.min.js} +1 -1
  23. package/dist/chunk-chunk-I6C3KR5H.module.min.js +2 -0
  24. package/dist/chunk-chunk-IP2UE74X.module.min.js +1 -0
  25. package/dist/chunk-chunk-J5RL6GXU.module.min.js +2 -0
  26. package/dist/chunk-chunk-JNCHKRIR.module.min.js +2 -0
  27. package/dist/{chunk-chunk-Z5KXAVQD.module.min.js → chunk-chunk-L3H6DQCR.module.min.js} +1 -1
  28. package/dist/{chunk-chunk-5WEFWNUW.module.min.js → chunk-chunk-M7VYYHCE.module.min.js} +1 -1
  29. package/dist/chunk-chunk-MC35ILYP.module.min.js +2 -0
  30. package/dist/{chunk-chunk-2VUEY5TH.module.min.js → chunk-chunk-N72SWNBV.module.min.js} +1 -1
  31. package/dist/chunk-chunk-OBQRFTIL.module.min.js +2 -0
  32. package/dist/chunk-chunk-OQTLSTGI.module.min.js +2 -0
  33. package/dist/{chunk-chunk-2UN3ANRN.module.min.js → chunk-chunk-SA3D43RA.module.min.js} +1 -1
  34. package/dist/chunk-chunk-SANERMIZ.module.min.js +2 -0
  35. package/dist/{chunk-chunk-DNY43POY.module.min.js → chunk-chunk-UHSZEB74.module.min.js} +1 -1
  36. package/dist/{chunk-chunk-CYIML3AV.module.min.js → chunk-chunk-XQYVEKEJ.module.min.js} +1 -1
  37. package/dist/{chunk-chunk-27HVVXS6.module.min.js → chunk-chunk-Y6AXCRVO.module.min.js} +1 -1
  38. package/dist/components/charts/custom/XYCustomChart.d.ts +3 -0
  39. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +5 -6
  40. package/dist/components/charts/realtime/temporalHistogramConfig.d.ts +11 -0
  41. package/dist/components/charts/shared/areaSeriesData.d.ts +15 -0
  42. package/dist/components/charts/shared/chartMode.d.ts +67 -0
  43. package/dist/components/charts/shared/colorUtils.d.ts +8 -0
  44. package/dist/components/charts/shared/geoStyleDefaults.d.ts +3 -0
  45. package/dist/components/charts/shared/hooks.d.ts +13 -80
  46. package/dist/components/charts/shared/useChartSetup.d.ts +3 -0
  47. package/dist/components/charts/shared/useCustomChartSetup.d.ts +3 -0
  48. package/dist/components/charts/shared/useXYLineStyle.d.ts +3 -2
  49. package/dist/components/charts/shared/xyLineStyle.d.ts +21 -0
  50. package/dist/components/charts/xy/LineChart.d.ts +3 -0
  51. package/dist/components/legendLayout.d.ts +31 -0
  52. package/dist/components/server/serverChartConfigShared.d.ts +29 -0
  53. package/dist/components/server/serverChartConfigs.d.ts +2 -13
  54. package/dist/components/server/serverChartConfigsXY.d.ts +3 -0
  55. package/dist/components/server/serverGaugeOverlay.d.ts +28 -0
  56. package/dist/components/server/staticLegend.d.ts +7 -1
  57. package/dist/components/server/staticSVGChrome.d.ts +57 -0
  58. package/dist/components/stream/GeoPipelineStore.d.ts +2 -0
  59. package/dist/components/stream/GeoSVGOverlay.d.ts +2 -0
  60. package/dist/components/stream/SceneToSVG.d.ts +8 -6
  61. package/dist/components/stream/SceneToSVGGeo.d.ts +10 -0
  62. package/dist/components/stream/SceneToSVGNetwork.d.ts +12 -0
  63. package/dist/components/stream/canvasBackground.d.ts +7 -0
  64. package/dist/components/stream/networkTypes.d.ts +2 -4
  65. package/dist/components/stream/renderBackend.d.ts +14 -0
  66. package/dist/components/stream/sceneToSVGShared.d.ts +51 -0
  67. package/dist/components/types/legendTypes.d.ts +16 -3
  68. package/dist/geo.min.js +1 -1
  69. package/dist/geo.module.min.js +1 -1
  70. package/dist/network.min.js +1 -1
  71. package/dist/network.module.min.js +1 -1
  72. package/dist/ordinal.min.js +1 -1
  73. package/dist/ordinal.module.min.js +1 -1
  74. package/dist/physics.min.js +1 -1
  75. package/dist/physics.module.min.js +1 -1
  76. package/dist/realtime.min.js +1 -1
  77. package/dist/realtime.module.min.js +1 -1
  78. package/dist/semiotic-ai-core.min.js +1 -1
  79. package/dist/semiotic-ai-core.module.min.js +1 -1
  80. package/dist/semiotic-ai.min.js +1 -1
  81. package/dist/semiotic-ai.module.min.js +1 -1
  82. package/dist/semiotic-experimental.min.js +1 -1
  83. package/dist/semiotic-experimental.module.min.js +1 -1
  84. package/dist/semiotic-realtime-core.min.js +1 -1
  85. package/dist/semiotic-realtime-core.module.min.js +1 -1
  86. package/dist/semiotic-recipes-core.module.min.js +1 -1
  87. package/dist/semiotic-recipes.module.min.js +1 -1
  88. package/dist/semiotic-server-edge.min.js +1 -1
  89. package/dist/semiotic-server-edge.module.min.js +1 -1
  90. package/dist/semiotic-server-node.min.js +1 -1
  91. package/dist/semiotic-server-node.module.min.js +1 -1
  92. package/dist/semiotic-utils-core.module.min.js +1 -1
  93. package/dist/semiotic-utils.module.min.js +1 -1
  94. package/dist/semiotic.min.js +1 -1
  95. package/dist/semiotic.module.min.js +1 -1
  96. package/dist/server.min.js +1 -1
  97. package/dist/server.module.min.js +1 -1
  98. package/dist/xy.min.js +1 -1
  99. package/dist/xy.module.min.js +1 -1
  100. package/package.json +1 -1
  101. package/dist/chunk-chunk-6F6GEAQU.module.min.js +0 -1
  102. package/dist/chunk-chunk-BHYTYMY2.module.min.js +0 -2
  103. package/dist/chunk-chunk-E7MIQX7D.module.min.js +0 -2
  104. package/dist/chunk-chunk-ES4DCG3L.module.min.js +0 -1
  105. package/dist/chunk-chunk-IFYPMWKY.module.min.js +0 -1
  106. package/dist/chunk-chunk-L6D3I3V7.module.min.js +0 -2
  107. package/dist/chunk-chunk-ODUZEEBH.module.min.js +0 -2
  108. package/dist/chunk-chunk-P6UBCMSQ.module.min.js +0 -2
  109. package/dist/chunk-chunk-STZFFTAN.module.min.js +0 -2
  110. package/dist/chunk-chunk-U3AGQ5EF.module.min.js +0 -2
  111. package/dist/chunk-chunk-WDIN4LRC.module.min.js +0 -1
  112. package/dist/chunk-chunk-XOYX77KF.module.min.js +0 -2
  113. package/dist/chunk-chunk-ZTNVDWAK.module.min.js +0 -2
@@ -1 +1 @@
1
- import{getHitRadius as e,hitTestRect as t,isTimeLandmark as n,normalizeAngle as o}from"./chunk-chunk-CP3EN6KZ.module.min.js";import{CustomLayoutSelectionProvider as r,canUseForceWorker as s,createFrameForceWorkerRequest as i,runForceLayoutWorker as a,shouldUseForceWorker as l,wrapWithCustomLayoutSelection as c}from"./chunk-chunk-RH5TSQPH.module.min.js";import{AccessibleDataTable as u,AriaLiveTooltip as d,CanvasFrameBackground as h,FlippingTooltip as f,FocusRing as p,NetworkAccessibleDataTable as y,SceneRevisionDiagnosticsObserver as g,ScreenReaderSummary as m,SkipToTableLink as v,buildColorStopGradient as x,buildLinearFillGradient as b,computeCanvasAriaLabel as k,computeNetworkAriaLabel as w,createDefaultAnnotationRules as A,getDevicePixelRatio as S,prepareCanvas as _,renderAnnotationPass as T,renderEmptyState as C,renderLegendFromConfig as P,renderLoadingState as R,resolveCanvasFill as M,resolveCurveFactory as N,runSceneBuild as I,useFrame as D,useFrameCanvasHost as E,useHydration as W,useSceneRevisionDiagnostics as z,useWasHydratingFromSSR as B}from"./chunk-chunk-6F6GEAQU.module.min.js";import{annotationActivationProps as L,buildHoverData as O,defaultTooltipStyle as H,getPointerHitRadius as F,isAnnotationActivationTarget as j,smartTooltipEntries as $,useAnnotationActivationOptions as Y}from"./chunk-chunk-255KDHW5.module.min.js";import"./chunk-chunk-SV4XAZ3Q.module.min.js";import{PipelineStore as X,attachUpdateResultStore as V,compileMotionEncoding as G,computeDecayOpacity as q,createCustomLayoutFailureDiagnostic as U,deriveMotionVector as Q,enrichDatumWithBand as K,getLayoutPlugin as J,opacityFromAge as Z,paintSceneWithBackend as ee,renderSceneWithBackend as te,resolveMotionAccessor as ne,resolveMotionVector as oe,ticksForMode as re,warnCustomLayoutDiagnostics as se}from"./chunk-chunk-T27ZEV6A.module.min.js";import{IncrementalExtent as ie,RingBuffer as ae}from"./chunk-chunk-VVCA3DB7.module.min.js";import"./chunk-chunk-H4PPRW6N.module.min.js";import{ANNOTATION_DISCLOSURE_REVEAL_CSS as le,DEFAULT_COLORS as ce,TITLE_BASELINE as ue,buildResolveColor as de,clampCornerRadii as he,computeEasing as fe,computeRawProgress as pe,emitClickObservations as ye,emitHoverObservations as ge,filterSparseArray as me,hasAnyCornerRadius as ve,isInteractiveKeyboardTarget as xe,isServerEnvironment as be,lerp as ke,networkLabelToSVG as we,networkSceneEdgeToSVG as Ae,networkSceneNodeToSVG as Se,normalizeLinkedBrush as _e,now as Te,observationInputType as Ce,resolveCustomLayoutPalette as Pe,unlockCrosshair as Re,useBrushSelection as Me,useChartMode as Ne,useChartSelection as Ie,useCrosshairPosition as De,xySceneNodeToSVG as Ee}from"./chunk-chunk-ES4DCG3L.module.min.js";import"./chunk-chunk-XEVJDUTH.module.min.js";import{DEFAULT_LIFECYCLE_THRESHOLDS as We,bandFromAge as ze}from"./chunk-chunk-2WVCH4PL.module.min.js";import{UpdateResultTracker as Be,annotationLayout as Le,drawGlyphParts as Oe,glyphFractionClipRect as He,glyphHitGeometry as Fe,glyphPlacement as je,schemeCategory10 as $e,symbolPathString as Ye,symbolRadius as Xe}from"./chunk-chunk-NO4MCQVD.module.min.js";import"./chunk-chunk-U66USBWU.module.min.js";import{getMax as Ve}from"./chunk-chunk-JJ2OOIET.module.min.js";import{getCSSColorCacheVersion as Ge,resolveCSSColor as qe}from"./chunk-chunk-QRIBHZYW.module.min.js";import"./chunk-chunk-J3QOW4OE.module.min.js";import{resolveThemeSemanticColors as Ue}from"./chunk-chunk-DSNGDNJY.module.min.js";import*as Qe from"react";import{useRef as Ke,useState as Je,useEffect as Ze,useMemo as et,useCallback as tt,useImperativeHandle as nt,useId as ot,forwardRef as rt,memo as st}from"react";import*as it from"react";import{jsx as at}from"react/jsx-runtime";var lt=null,ct=null;function ut(e){const[t,n]=it.useState(()=>lt);return it.useEffect(()=>{if(t)return;let e=!1;return(lt?Promise.resolve(lt):(ct||(ct=import("./chunk-XYBrushOverlay-ECZJJLAJ.module.min.js").then(e=>lt=e.XYBrushOverlay)),ct)).then(t=>{e||n(()=>t)}),()=>{e=!0}},[t]),t?at(t,{...e}):null}var dt=class{constructor(e,t){this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=t?.chunkThreshold??5e3,this.chunkSize=t?.chunkSize??5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(e=me(e),this.lastBoundedData===e)return;if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(e){if(e=me(e),this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){null!=e&&"object"==typeof e&&(this.pushBuffer.push(e),this.scheduleFlush())}pushMany(e){if(0===e.length)return;let t=0;for(let n=0;e.length>n;n++){const o=e[n];null!=o&&"object"==typeof o&&(this.pushBuffer.push(o),t++)}0!==t&&this.scheduleFlush()}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}};import*as ht from"react";function ft(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:ht.createElement(ht.Fragment,null,...t)}import{useEffect as pt,useRef as yt}from"react";function gt(e,t,n,o){pt(()=>{e.current?.updateConfig(t),n.current=!0,o()},[t,o,e,n])}function mt(e,t,n,o){const r=yt(null);pt(()=>{const s=e.current;if(!s)return;const i=t??null;r.current!==i&&(r.current=i,s.setLayoutSelection(i),s.hasCustomRestyle?s.restyleScene(i):n.current=!0,o())},[t,o,e,n])}function vt(t,n,o,r,s,i=e=>e.x,a=e=>e.y,l=e=>e.r){const c=Math.max(r,s+5,12),u=n-c,d=n+c,h=o-c,f=o+c;let p=null,y=1/0;return t.visit((t,s,c,g,m)=>{if(s>d||u>g||c>f||h>m)return!0;if(!t.length){let s=t;do{const t=s.data,c=i(t)-n,u=a(t)-o,d=Math.sqrt(c*c+u*u);e(l(t),r)>=d&&y>d&&(p=t,y=d),s=s.next}while(s)}return!1}),p?{node:p,distance:y}:null}import{line as xt}from"d3-shape";var bt=new WeakMap;function kt(e,t){const n=N(t);if(!n)return e;const o=bt.get(e);if(o)return o;const r=function(e,t,n=8){if(!t||2>e.length)return e.map(([e,t])=>[e,t]);const o=[];let r=null;const s={moveTo(e,t){r=[e,t],o.push([e,t])},lineTo(e,t){r=[e,t],o.push([e,t])},bezierCurveTo(e,t,s,i,a,l){if(!r)return r=[a,l],void o.push([a,l]);const[c,u]=r;for(let r=1;n>=r;r++){const d=r/n,h=1-d;o.push([h*h*h*c+3*h*h*d*e+3*h*d*d*s+d*d*d*a,h*h*h*u+3*h*h*d*t+3*h*d*d*i+d*d*d*l])}r=[a,l]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(e,t,n,s){r=[n,s],o.push([n,s])}};return xt().x(e=>e[0]).y(e=>e[1]).curve(t).context(s)(e),o}(e,n);return bt.set(e,r),r}function wt(e,t,n,o=30,r,s=0){let i=null;if(r){const e=vt(r,t,n,o,s);e&&(i={node:e.node,datum:e.node.datum,x:e.node.x,y:e.node.y,distance:e.distance})}for(const s of e){let e=null;switch(s.type){case"point":if(r)break;e=St(s,t,n,o);break;case"symbol":e=_t(s,t,n,o);break;case"glyph":e=Tt(s,t,n,o);break;case"line":e=Ct(s,t,n,o);break;case"rect":if(null==s.datum)break;e=Rt(s,t,n);break;case"heatcell":e=Mt(s,t,n);break;case"area":if(!1===s.interactive)break;e=It(s,t,n);break;case"candlestick":e=Nt(s,t,n)}e&&o>e.distance&&(i&&e.distance>=i.distance||(i=e))}return i}function At(e,t,n){if(0===e.length)return null;if(e[0][0]>t||t>e[e.length-1][0])return null;const o=Dt(e,t);if(0>o)return null;if(Math.abs(e[o][0]-t)>n)return null;let r=o,s=o;o>0&&e[o][0]>=t?(r=o-1,s=o):e.length-1>o&&(r=o,s=o+1);const[i,a]=e[r],[l,c]=e[s];return l===i?a:a+Math.max(0,Math.min(1,(t-i)/(l-i)))*(c-a)}function St(t,n,o,r=30){const s=n-t.x,i=o-t.y,a=Math.sqrt(s*s+i*i);return a>e(t.r,r)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:a}}function _t(t,n,o,r=30){const s=n-t.x,i=o-t.y,a=Math.sqrt(s*s+i*i);return a>e(Xe(t.size),r)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:a}}function Tt(t,n,o,r=30){if(null==t.datum)return null;const s=Fe(t.glyph,t.size),i=t.x+s.centerDx,a=t.y+s.centerDy,l=n-i,c=o-a,u=Math.sqrt(l*l+c*c);return u>e(s.radius,r)?null:{node:t,datum:t.datum,x:i,y:a,distance:u}}function Ct(e,t,n,o=30){if(0===e.path.length)return null;const r=Dt(e.path,t);if(0>r)return null;const[s,i]=e.path[r];let a;if(e.path.length>1){let o=1/0;const s=Math.max(0,r-1),i=Math.min(e.path.length-2,r);for(let r=s;i>=r;r++){const[s,i]=e.path[r],[a,l]=e.path[r+1],c=Pt(t,n,s,i,a,l);o>c&&(o=c)}a=o}else{const e=t-s,o=n-i;a=Math.sqrt(e*e+o*o)}const l=e.style;return a>Math.max(5,(l.strokeWidth??l.lineWidth??1)/2+2,o)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[r]?e.datum[r]:e.datum,x:s,y:i,distance:a}}function Pt(e,t,n,o,r,s){const i=r-n,a=s-o,l=i*i+a*a;if(0===l)return Math.sqrt((e-n)**2+(t-o)**2);let c=((e-n)*i+(t-o)*a)/l;return c=Math.max(0,Math.min(1,c)),Math.sqrt((e-(n+c*i))**2+(t-(o+c*a))**2)}function Rt(e,n,o){const r=t(n,o,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function Mt(e,n,o){const r=t(n,o,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function Nt(e,t,n){const o=e.bodyWidth/2,r=Math.min(e.openY,e.closeY);if(!(e.x-o-3>t||t>e.x+o+3||e.highY-3>n||n>e.lowY+3)){const o=r+Math.max(Math.max(e.openY,e.closeY)-r,1)/2,s=t-e.x,i=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(s*s+i*i)}}return null}function It(e,t,n){if(0===e.topPath.length)return null;const o=Dt(e.topPath,t);if(0>o)return null;const[r,s]=e.topPath[o],i=t-r,a=n-s,l=Math.sqrt(i*i+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:r,y:s,distance:l}}function Dt(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const r=n+o>>1;t>e[r][0]?n=r+1:o=r}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}import{useEffect as Et,useRef as Wt}from"react";var zt={fresh:1,aging:.7,stale:.45,expired:.25},Bt={alpha:1,band:"fresh",isStale:!1};function Lt(e,t){if(!e||0>=t)return Bt;const n=null!=e.threshold&&e.threshold>0?e.threshold:5e3,o=e.graded;if(o){const e="object"==typeof o?o:{},r=ze(t,n,e.thresholds);return{alpha:{...zt,...e.opacities??{}}[r],band:r,isStale:"fresh"!==r}}return t>n?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:Bt}function Ot(e,t,n,o,r,s){const i=Wt("fresh");Et(()=>{if(!e)return;const a=setInterval(()=>{const a=t.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=Lt(e,l-a.lastIngestTime);c.band===i.current&&c.isStale===r||(i.current=c.band,c.isStale!==r&&s(c.isStale),n.current=!0,o())},1e3);return()=>clearInterval(a)},[e,r,o,t,s,n])}import{jsx as Ht}from"react/jsx-runtime";function Ft({isStale:e,position:t}){return Ht("div",{className:"stream-staleness-badge",style:{position:"absolute",..."top-left"===t?{top:4,left:4}:"bottom-left"===t?{bottom:4,left:4}:"bottom-right"===t?{bottom:4,right:4}:{top:4,right:4},padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:e?"#dc3545":"#28a745",color:"white"},children:e?"STALE":"LIVE"})}import{useMemo as jt,useRef as $t,useEffect as Yt}from"react";import{useMemo as Xt}from"react";import{bin as Vt}from"d3-array";import{jsx as Gt,jsxs as qt}from"react/jsx-runtime";function Ut(e){return"string"==typeof e?{type:e}:e}function Qt({orient:e,config:t,values:n,scale:o,size:r,length:s}){const i=function(e){return{type:e.type,bins:e.bins??20,fill:e.fill??"#4e79a7",fillOpacity:e.fillOpacity??.5,stroke:e.stroke??"none",strokeWidth:e.strokeWidth??1}}(t),a="top"===e||"bottom"===e,l=Xt(()=>{if(0===n.length)return null;const t=o.domain(),l=r-8;if("boxplot"===i.type){const t=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],r=t[Math.floor(.5*n)],s=t[Math.floor(.75*n)],i=s-o;return{q1:o,median:r,q3:s,whiskerLow:Math.max(t[0],o-1.5*i),whiskerHigh:Math.min(t[n-1],s+1.5*i)}}(n);if(!t)return null;const{q1:r,median:s,q3:c,whiskerLow:u,whiskerHigh:d}=t,h=Math.min(.5*l,20),f=(l-h)/2+4;if(a){const t=o(r),n=o(c),a=o(s),l=o(u),p=o(d),y="top"===e?-1:1,g=0;return qt("g",{"data-testid":"marginal-boxplot-"+e,children:[Gt("line",{x1:l,y1:g+y*(f+h/2),x2:p,y2:g+y*(f+h/2),stroke:i.fill,strokeWidth:i.strokeWidth}),Gt("line",{x1:l,y1:g+y*f,x2:l,y2:g+y*(f+h),stroke:i.fill,strokeWidth:i.strokeWidth}),Gt("line",{x1:p,y1:g+y*f,x2:p,y2:g+y*(f+h),stroke:i.fill,strokeWidth:i.strokeWidth}),Gt("rect",{x:Math.min(t,n),y:"top"===e?g-f-h:g+f,width:Math.abs(n-t),height:h,fill:i.fill,fillOpacity:i.fillOpacity,stroke:"none"===i.stroke?i.fill:i.stroke,strokeWidth:i.strokeWidth}),Gt("line",{x1:a,y1:"top"===e?g-f-h:g+f,x2:a,y2:"top"===e?g-f:g+f+h,stroke:i.fill,strokeWidth:2})]})}{const t=o(r),n=o(c),a=o(s),l=o(u),p=o(d),y="left"===e?-1:1,g=0;return qt("g",{"data-testid":"marginal-boxplot-"+e,children:[Gt("line",{x1:g+y*(f+h/2),y1:l,x2:g+y*(f+h/2),y2:p,stroke:i.fill,strokeWidth:i.strokeWidth}),Gt("line",{x1:g+y*f,y1:l,x2:g+y*(f+h),y2:l,stroke:i.fill,strokeWidth:i.strokeWidth}),Gt("line",{x1:g+y*f,y1:p,x2:g+y*(f+h),y2:p,stroke:i.fill,strokeWidth:i.strokeWidth}),Gt("rect",{x:"left"===e?g-f-h:g+f,y:Math.min(t,n),width:h,height:Math.abs(n-t),fill:i.fill,fillOpacity:i.fillOpacity,stroke:"none"===i.stroke?i.fill:i.stroke,strokeWidth:i.strokeWidth}),Gt("line",{x1:"left"===e?g-f-h:g+f,y1:a,x2:"left"===e?g-f:g+f+h,y2:a,stroke:i.fill,strokeWidth:2})]})}}const c=Vt().domain(t).thresholds(i.bins)(n);if(0===c.length)return null;const u=Ve(c.map(e=>e.length));if(0===u)return null;if("histogram"===i.type)return Gt("g",{"data-testid":"marginal-histogram-"+e,children:c.map((t,n)=>{if(null==t.x0||null==t.x1)return null;const r=t.length/u*l;if(a){const s=o(t.x0),a=o(t.x1)-o(t.x0);return Gt("rect",{x:s,y:"top"===e?-4-r:4,width:Math.max(a,.5),height:r,fill:i.fill,fillOpacity:i.fillOpacity,stroke:i.stroke,strokeWidth:i.strokeWidth},n)}{const s=o(t.x0),a=o(t.x1)-o(t.x0);return Gt("rect",{x:"left"===e?-4-r:4,y:Math.min(s,s+a),width:r,height:Math.abs(a),fill:i.fill,fillOpacity:i.fillOpacity,stroke:i.stroke,strokeWidth:i.strokeWidth},n)}})});if("violin"===i.type){const t=l/2+4,n=[];for(const r of c){if(null==r.x0||null==r.x1)continue;const s=r.length/u*(l/2),i=o((r.x0+r.x1)/2);n.push(a?`${i},${"top"===e?-(t-s):t-s}`:`${"left"===e?-(t-s):t-s},${i}`)}for(let r=c.length-1;r>=0;r--){const s=c[r];if(null==s.x0||null==s.x1)continue;const i=s.length/u*(l/2),d=o((s.x0+s.x1)/2);n.push(a?`${d},${"top"===e?-(t+i):t+i}`:`${"left"===e?-(t+i):t+i},${d}`)}return Gt("g",{"data-testid":"marginal-violin-"+e,children:Gt("polygon",{points:n.join(" "),fill:i.fill,fillOpacity:i.fillOpacity,stroke:"none"===i.stroke?i.fill:i.stroke,strokeWidth:i.strokeWidth})})}if("ridgeline"===i.type){const t=[];if(a){const n=0,r=null!=c[0].x0?o(c[0].x0):0;t.push(`M${r},${n}`);for(const n of c){if(null==n.x0||null==n.x1)continue;const r=n.length/u*l,s=o((n.x0+n.x1)/2);t.push(`L${s},${"top"===e?-r-4:r+4}`)}const i=null!=c[c.length-1].x1?o(c[c.length-1].x1):s;t.push(`L${i},${n}`),t.push("Z")}else{const n=0,r=null!=c[0].x0?o(c[0].x0):0;t.push(`M${n},${r}`);for(const n of c){if(null==n.x0||null==n.x1)continue;const r=n.length/u*l,s=o((n.x0+n.x1)/2);t.push(`L${"left"===e?-r-4:r+4},${s}`)}const i=null!=c[c.length-1].x1?o(c[c.length-1].x1):s;t.push(`L${n},${i}`),t.push("Z")}return Gt("g",{"data-testid":"marginal-ridgeline-"+e,children:Gt("path",{d:t.join(" "),fill:i.fill,fillOpacity:i.fillOpacity,stroke:"none"===i.stroke?i.fill:i.stroke,strokeWidth:i.strokeWidth})})}return null},[n,o,i,r,s,e,a,4]);return l?Gt("g",{className:"marginal-"+e,"data-testid":"marginal-"+e,children:l}):null}function Kt(e,t,n){if("edges"===e){if(t)return"start";if(n)return"end"}return"middle"}function Jt(e,t,n){if("edges"===e){if(t)return"hanging";if(n)return"auto"}return"middle"}function Zt(e){if(0===e.length)return{min:null,max:null};let t=1/0,n=-1/0;for(const o of e)t>o.pixel&&(t=o.pixel),o.pixel>n&&(n=o.pixel);return{min:t,max:n}}function en(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function tn(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,r="left"===e?-1:1,s=Math.ceil(t/8);let i="M0,"+o;for(let e=0;s>e;e++){const n=8*(e+1);i+=`L${Math.min(8*e+4,t)},${o+4*r}`,i+=`L${Math.min(n,t)},${o}`}return i}const o="bottom"===e?0:t,r="bottom"===e?1:-1,s=Math.ceil(n/8);let i=`M${o},0`;for(let e=0;s>e;e++){const t=8*(e+1);i+=`L${o+4*r},${Math.min(8*e+4,n)}`,i+=`L${o},${Math.min(t,n)}`}return i}import{Fragment as nn,jsx as on,jsxs as rn}from"react/jsx-runtime";function sn(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:s,scales:i,showAxes:a,axes:l,showGrid:c,xFormat:u,yFormat:d,axisExtent:h}=e,f=jt(()=>{if(!i)return[];const e=l?.find(e=>"bottom"===e.orient),n=e?.tickFormat||u||an,o=Math.max(2,Math.floor(t/70)),r=e?.ticks??5,s="exact"===h?Math.max(2,r):Math.min(r,o),a=e?.tickValues??re(i.x,s,h),c=a.map(e=>e.valueOf()),d=a.map((e,t)=>({value:e,pixel:i.x(e),label:n(e,t,c)})),f=d.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0);return ln(d,Math.max(55,f+8))},[i,l,u,t,h]),p=jt(()=>{if(!i)return[];const e=l?.find(e=>"left"===e.orient),t=e?.tickFormat||d||an,o=Math.max(2,Math.floor(n/30)),r=e?.ticks??5,s="exact"===h?Math.max(2,r):Math.min(r,o);return ln((e?.tickValues??re(i.y,s,h)).map(e=>({value:e,pixel:i.y(e),label:t(e)})),22)},[i,l,d,n,h]),y=c&&i,g=a&&i;if(!y&&!g)return null;const m=l?.find(e=>"bottom"===e.orient),v=l?.find(e=>"left"===e.orient),x=g&&(!m||!1!==m.baseline),b=g&&(!v||!1!==v.baseline),k=m?.jaggedBase||!1,w=v?.jaggedBase||!1,A="var(--semiotic-border, #ccc)";return on("svg",{width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:rn("g",{transform:`translate(${s.left},${s.top})`,children:[y&&(()=>{const e=en(l?.find(e=>"bottom"===e.orient)?.gridStyle),o=en(l?.find(e=>"left"===e.orient)?.gridStyle);return rn("g",{className:"stream-grid",children:[f.map((t,o)=>on("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+o)),p.map((e,n)=>on("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"ygrid-"+n))]})})(),x&&!k&&on("line",{x1:0,y1:n,x2:t,y2:n,stroke:A,strokeWidth:1}),k&&on("path",{d:tn("bottom",t,n),fill:"none",stroke:A,strokeWidth:1}),b&&!w&&on("line",{x1:0,y1:0,x2:0,y2:n,stroke:A,strokeWidth:1}),w&&on("path",{d:tn("left",t,n),fill:"none",stroke:A,strokeWidth:1})]})})}function an(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function ln(e,t){if(2>=e.length)return e;const n=[e[0]];for(let o=1;e.length-1>o;o++)t>Math.abs(e[o].pixel-n[n.length-1].pixel)||n.push(e[o]);const o=e[e.length-1];return t>Math.abs(o.pixel-n[n.length-1].pixel)?n[n.length-1]=o:n.push(o),n}function cn(e){const{width:t,height:o,totalWidth:r,totalHeight:s,margin:i,scales:a,showAxes:l,axes:c,xLabel:u,yLabel:d,yLabelRight:h,xFormat:f,yFormat:p,axisExtent:y,showGrid:g,title:m,legend:v,legendHoverBehavior:x,legendClickBehavior:b,legendHighlightedCategory:k,legendIsolatedCategories:w,legendPosition:S="right",legendLayout:_,foregroundGraphics:C,marginalGraphics:R,xValues:M,yValues:N,annotations:I,onAnnotationActivate:D,onObservation:E,chartId:W,chartType:z,autoPlaceAnnotations:B,svgAnnotationRules:L,xAccessor:O,yAccessor:H,annotationData:F,pointNodes:j,curve:$,underlayRendered:X,canvasObscuresUnderlay:V=!0,linkedCrosshairName:G,linkedCrosshairSourceId:q,children:U}=e,Q=Y({onAnnotationActivate:D,onObservation:E,chartId:W,chartType:z}),K=jt(()=>{if(!l||!a)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||f||an,o=Math.max(2,Math.floor(t/70)),r=e?.ticks??5,s="exact"===y?Math.max(2,r):Math.min(r,o),i=e?.tickValues??re(a.x,s,y),u=i.map(e=>e.valueOf()),d=i.map((e,t)=>({value:e,pixel:a.x(e),label:n(e,t,u)})),h=d.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),p=e?.autoRotate?Math.max(20,Math.min(h+8,55)):Math.max(55,h+8);let g=ln(d,p);if(g.length>1&&(g=g.filter((e,t)=>0===t||e.label+""!=g[t-1].label+"")),e?.includeMax&&g.length>0&&"exact"!==y&&!e?.tickValues){const e=a.x.domain()[1],t=a.x(e),o=g[g.length-1].pixel;if(Math.abs(t-o)>1){const r=n(e,g.length,u);p>t-o&&g.length>1&&(g=g.slice(0,-1)),g.push({value:e,pixel:t,label:r})}}return g},[l,a,c,f,t,y]),J=jt(()=>{if(!l||!a)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||p||an,n=Math.max(2,Math.floor(o/30)),r=e?.ticks??5,s="exact"===y?Math.max(2,r):Math.min(r,n);let i=ln((e?.tickValues??re(a.y,s,y)).map(e=>({value:e,pixel:a.y(e),label:t(e)})),22);if(i.length>1&&(i=i.filter((e,t)=>0===t||e.label+""!=i[t-1].label+"")),e?.includeMax&&i.length>0&&"exact"!==y&&!e?.tickValues){const e=a.y.domain()[1],n=a.y(e),o=i[i.length-1].pixel;if(Math.abs(n-o)>1){const r=t(e);22>Math.abs(n-o)&&i.length>1&&(i=i.slice(0,-1)),i.push({value:e,pixel:n,label:r})}}return i},[l,a,c,p,o,y]),Z=jt(()=>{if(!l||!a)return[];const e=c?.find(e=>"right"===e.orient);if(!e)return[];const t=e.tickFormat||p||an,n=Math.max(2,Math.floor(o/30)),r=e.ticks??5;return ln((e.tickValues??re(a.y,"exact"===y?Math.max(2,r):Math.min(r,n),y)).map(e=>({value:e,pixel:a.y(e),label:t(e)})),22)},[l,a,c,p,o,y]),ee=$t(new Map),te=$t(I?.length??0),ne=I?.length??0;te.current!==ne&&(te.current=ne,ee.current=new Map);const oe=jt(()=>{if(!I||0===I.length)return null;const e=A("xy",Q),n={scales:a?{x:a.x,y:a.y,time:a.x,value:a.y}:null,timeAxis:"x",xAccessor:O,yAccessor:H,width:t,height:o,data:F,frameType:"xy",pointNodes:j,curve:$,stickyPositionCache:ee.current},r=B?Le({annotations:I,context:n,..."object"==typeof B?B:{}}):I;return T(r,e,L,n)},[I,B,L,t,o,O,H,F,a,j,$,Q]),se=De(G);return Yt(()=>{if(!se?.locked||!G)return;const e=e=>{"Escape"===e.key&&Re(G)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[se?.locked,G]),l||m||v||C||R||oe&&oe.length>0||g||U||se?rn("svg",{role:"img",width:r,height:s,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[on("title",{children:"string"==typeof m?m:"XY Chart"}),on("desc",{children:"string"==typeof m?m+" (XY data visualization)":"XY data visualization"}),rn("g",{transform:`translate(${i.left},${i.top})`,children:[g&&a&&(!X||V)&&(()=>{const e=en(c?.find(e=>"bottom"===e.orient)?.gridStyle),n=en(c?.find(e=>"left"===e.orient)?.gridStyle);return rn("g",{className:"stream-grid",children:[K.map((t,n)=>on("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+n)),J.map((e,o)=>on("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:n},"ygrid-"+o))]})})(),l&&a&&(()=>{const e=c?.find(e=>"left"===e.orient),r=c?.find(e=>"bottom"===e.orient),s=!e||!1!==e.baseline,a=!r||!1!==r.baseline,l=e?.jaggedBase||!1,f=r?.jaggedBase||!1,p=r?.landmarkTicks,y=e?.landmarkTicks,g="var(--semiotic-border, #ccc)",m="var(--semiotic-text-secondary, var(--semiotic-text, #666))",v="var(--semiotic-text, #333)",x=!!r?.autoRotate&&K.length>1&&(()=>{const e=t/Math.max(K.length-1,1);return K.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})(),b=x?12:18,k=o+(x?58:40),w={fontSize:"var(--semiotic-tick-font-size, 12px)"},A={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},S={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},_=r?.tickAnchor,T=e?.tickAnchor,C=Zt(K),P=Zt(J);return rn("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[rn("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!X||V)&&a&&!f&&on("line",{x1:0,y1:o,x2:t,y2:o,stroke:g,strokeWidth:1}),(!X||V)&&f&&on("path",{d:tn("bottom",t,o),fill:"none",stroke:g,strokeWidth:1}),K.map((e,t)=>{const r=!!p&&("function"==typeof p?p(e.value,t):n(e.value,t>0?K[t-1].value:void 0));return rn("g",{transform:`translate(${e.pixel},${o})`,children:[on("line",{y2:5,stroke:g,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?on("text",{y:b,textAnchor:x?"end":Kt(_,e.pixel===C.min,e.pixel===C.max),fontWeight:r?600:400,fill:m,className:"semiotic-axis-tick",style:{userSelect:"none",...r?A:w},transform:x?"rotate(-45)":void 0,children:e.label}):on("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:on("div",{style:{textAlign:"center",userSelect:"none",...w},children:e.label})})]},"xtick-"+t)}),u&&on("text",{x:t/2,y:k,textAnchor:"middle",fill:v,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:u})]}),rn("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!X||V)&&s&&!l&&on("line",{x1:0,y1:0,x2:0,y2:o,stroke:g,strokeWidth:1}),(!X||V)&&l&&on("path",{d:tn("left",t,o),fill:"none",stroke:g,strokeWidth:1}),J.map((e,t)=>{const o=!!y&&("function"==typeof y?y(e.value,t):n(e.value,t>0?J[t-1].value:void 0));return rn("g",{transform:`translate(0,${e.pixel})`,children:[on("line",{x2:-5,stroke:g,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?on("text",{x:-8,textAnchor:"end",dominantBaseline:Jt(T,e.pixel===P.min,e.pixel===P.max),fontWeight:o?600:400,fill:m,className:"semiotic-axis-tick",style:{userSelect:"none",...o?A:w},children:e.label}):on("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:on("div",{style:{textAlign:"right",userSelect:"none",...w},children:e.label})})]},"ytick-"+t)}),(()=>{const t=e?.label||d;return t?on("text",{x:15-i.left,y:o/2,textAnchor:"middle",fill:v,transform:`rotate(-90, ${15-i.left}, ${o/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:t}):null})()]}),(()=>{const e=c?.find(e=>"right"===e.orient);if(!e||0===Z.length)return null;const r=!1!==e.baseline,s=e.landmarkTicks,a=e.label||h,l=e.tickAnchor,u=Zt(Z);return rn("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[r&&on("line",{x1:t,y1:0,x2:t,y2:o,stroke:g,strokeWidth:1}),Z.map((e,o)=>{const r=!!s&&("function"==typeof s?s(e.value,o):n(e.value,o>0?Z[o-1].value:void 0));return rn("g",{transform:`translate(${t},${e.pixel})`,children:[on("line",{x2:5,stroke:g,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?on("text",{x:8,textAnchor:"start",dominantBaseline:Jt(l,e.pixel===u.min,e.pixel===u.max),fontWeight:r?600:400,fill:m,className:"semiotic-axis-tick",style:{userSelect:"none",...r?A:w},children:e.label}):on("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:on("div",{style:{textAlign:"left",userSelect:"none",...w},children:e.label})})]},"ytick-r-"+o)}),a&&on("text",{x:t+i.right-15,y:o/2,textAnchor:"middle",fill:v,transform:`rotate(90, ${t+i.right-15}, ${o/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:a})]})})()]})})(),oe,R&&a&&M&&N&&rn(nn,{children:[R.top&&on("g",{transform:"translate(0, 0)",children:on(Qt,{orient:"top",config:Ut(R.top),values:M,scale:a.x,size:i.top,length:t})}),R.bottom&&on("g",{transform:`translate(0, ${o})`,children:on(Qt,{orient:"bottom",config:Ut(R.bottom),values:M,scale:a.x,size:i.bottom,length:t})}),R.left&&on("g",{transform:"translate(0, 0)",children:on(Qt,{orient:"left",config:Ut(R.left),values:N,scale:a.y,size:i.left,length:o})}),R.right&&on("g",{transform:`translate(${t}, 0)`,children:on(Qt,{orient:"right",config:Ut(R.right),values:N,scale:a.y,size:i.right,length:o})})]}),C,se&&se.sourceId!==q&&a?.x&&(()=>{const e=a.x(se.xValue);if(null==e||0>e||e>t)return null;const n=se.locked;return on("line",{x1:e,y1:0,x2:e,y2:o,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"})})(),U]}),m&&"string"==typeof m?on("text",{x:r/2,y:ue,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:m}):m?on("foreignObject",{x:0,y:0,width:r,height:i.top,children:m}):null,P({legend:v,totalWidth:r,totalHeight:s,margin:i,legendPosition:S,title:m,legendLayout:_,legendHoverBehavior:x,legendClickBehavior:b,legendHighlightedCategory:k,legendIsolatedCategories:w})]}):null}import{useRef as un}from"react";function dn(e){const t=un(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return fn(e,t);if(!pn(e)||!pn(t))return!1;const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;const n=e[o],r=t[o];if(!Object.is(n,r))if(Array.isArray(n)&&Array.isArray(r)){if(!fn(n,r))return!1}else{if(!pn(n)||!pn(r))return!1;if(!hn(n,r))return!1}}return!0}(t.current,e)||(t.current=e),t.current}function hn(e,t){const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;if(!Object.is(e[o],t[o]))return!1}return!0}function fn(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function pn(e){if(null===e||"object"!=typeof e)return!1;if(Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function yn(e,t){const{background:n,hasBackgroundGraphics:o=!1,themeBackground:r="",x:s=0,y:i=0,width:a,height:l}=t;if("transparent"===n)return!1;if(o)return!1;const c=n||(r&&"transparent"!==r?r:"")||null;if(!c)return!1;const u=qe(e,c);return!!u&&(e.fillStyle=u,e.fillRect(s,i,a,l),!0)}var gn={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 mn(e,t){const n=e.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const e=n[1],o=n[2],r=n[3];return`#${e}${e}${o}${o}${r}${r}${t}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${t}`;const o=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return o?`rgba(${o[1]}, ${(parseInt(t,16)/255).toFixed(3)})`:n}function vn(e,t,n,o){return"function"==typeof e?e({size:t,margin:n,scales:o}):e}import{useCallback as xn,useRef as bn}from"react";function kn(e,t,n,o){return"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:n,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:o,fn:t}:{key:void 0,fn:null}}var wn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],An=3156e7;function Sn(e){const t=e[1]-e[0];return 864e5>t?e=>{const t=new Date(e);return`${(t.getUTCHours()+"").padStart(2,"0")}:${(t.getUTCMinutes()+"").padStart(2,"0")}`}:An>t?e=>{const t=new Date(e);return`${wn[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*An>t?e=>{const t=new Date(e);return`${wn[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}function _n(e){if(!e)return;const t=[];for(const n of e)if("point"===n.type)t.push(n);else if("symbol"===n.type)t.push({pointId:n.pointId,x:n.x,y:n.y,r:Xe(n.size)});else if("glyph"===n.type){const e=Fe(n.glyph,n.size);t.push({pointId:n.pointId,x:n.x+e.centerDx,y:n.y+e.centerDy,r:e.radius})}return t}import{line as Tn}from"d3-shape";function Cn(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}function Pn(e,t,n,o,r,s){if(2>t.length)return;const i=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],o=t[e][1]-t[e-1][1];i.push(i[e-1]+Math.sqrt(n*n+o*o))}const a=i[i.length-1];if(0===a)return;const l=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=o,e.lineCap=s;for(let n=0;t.length-1>n;n++){const o=(i[n]+i[n+1])/2;let s=r;l>o&&(s*=o/l),l>a-o&&(s*=(a-o)/l),e.globalAlpha=Math.max(0,s),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}var Rn=(e,t,n,o)=>{const r=t.filter(e=>"line"===e.type);for(const t of r){if(2>t.path.length)continue;const n=t._introClipFraction;void 0!==n&&1>n&&(e.save(),e.beginPath(),e.rect(0,0,o.width*n,o.height),e.clip());const r=t.style.stroke||"#007bff",s=qe(e,r)||r,i=t.style.strokeWidth||2,a=t.colorThresholds,l=t.rawValues;if(e.setLineDash(t.style.strokeDasharray?t.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),e.lineWidth=i,e.lineCap=t.style.strokeLinecap||"butt",t.style._edgeFade){Pn(e,t.path,s,i,t.style.opacity??1,t.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const c=N(t.curve),u=a&&a.length>0&&l&&l.length===t.path.length,d=t._decayOpacities;if(d&&d.length===t.path.length&&!u){e.strokeStyle=s;const n=t.style.opacity??1;for(let o=0;t.path.length-1>o;o++)e.globalAlpha=.5*(d[o]+d[o+1])*n,e.beginPath(),e.moveTo(t.path[o][0],t.path[o][1]),e.lineTo(t.path[o+1][0],t.path[o+1][1]),e.stroke()}else if(u){let n=function(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),d=!0},o=function(){d&&(e.stroke(),d=!1)},r=null,i=null,c=null,u=null,d=!1;for(let d=0;t.path.length>d;d++){const[h,f]=t.path[d],p=l[d],y=Cn(p,a,s);if(null!==r&&null!==u&&null!==c){if(y===u)e.lineTo(h,f);else{const t=[];for(const e of a){const n=e.value;(c>n||n>p)&&(n>c||p>n)||c===n||p===n||t.push({t:(n-c)/(p-c)})}t.sort((e,t)=>e.t-t.t);for(const l of t){const t=r+(h-r)*l.t,u=i+(f-i)*l.t,d=Cn(c+(p-c)*Math.min(l.t+1e-4,1),a,s);e.lineTo(t,u),o(),n(d,t,u)}e.lineTo(h,f)}r=h,i=f,c=p,u=y}else n(y,h,f),r=h,i=f,c=p,u=y}o()}else{e.beginPath();const n=t.strokeGradient&&t.path.length>=2?x(e,t.strokeGradient,t.path[0][0],0,t.path[t.path.length-1][0],0):null;if(e.strokeStyle=n||s,c)Tn().x(e=>e[0]).y(e=>e[1]).curve(c).context(e)(t.path);else{const[n,o]=t.path[0];e.moveTo(n,o);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1])}e.stroke()}if(t.style.fill&&t.style.fillOpacity&&t.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=t.style.fillOpacity,e.fillStyle=M(e,t.style.fill,t.style.fill),c&&!u)Tn().x(e=>e[0]).y(e=>e[1]).curve(c).context(e)(t.path);else{const[n,o]=t.path[0];e.moveTo(n,o);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1])}const n=t.path[0][0];e.lineTo(t.path[t.path.length-1][0],o.height),e.lineTo(n,o.height),e.closePath(),e.fill()}void 0!==n&&1>n&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function Mn(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Nn(e,t,n=.3){Mn(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function In(e,t,n=.6){if(!Mn(t))return;const o=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,r=t.cx??t.x??0,s=t.cy??t.y??0;e.beginPath(),e.arc(r,s,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function Dn(e,t,n,o=.35){Mn(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}import{area as En,line as Wn}from"d3-shape";function zn(e,t){const n=N(t.curve);if(!n||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}else{const o=En().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),o(t.topPath)}}var Bn=(e,t,n,o)=>{const r=t.filter(e=>"area"===e.type);for(const t of r){if(2>t.topPath.length)continue;let n=!1;t.clipRect&&(e.save(),e.beginPath(),e.rect(t.clipRect.x,t.clipRect.y,t.clipRect.width,t.clipRect.height),e.clip(),n=!0);const r=t._introClipFraction;void 0!==r&&1>r&&(e.save(),e.beginPath(),e.rect(0,0,o.width*r,o.height),e.clip());const s=M(e,t.style.fill,"#4e79a7"),i=t._decayOpacities;if(i&&i.length===t.topPath.length){const n=t.style.fillOpacity??.7;e.fillStyle=s;for(let o=0;t.topPath.length-1>o;o++)e.globalAlpha=.5*(i[o]+i[o+1])*n,e.beginPath(),e.moveTo(t.topPath[o][0],t.topPath[o][1]),e.lineTo(t.topPath[o+1][0],t.topPath[o+1][1]),e.lineTo(t.bottomPath[o+1][0],t.bottomPath[o+1][1]),e.lineTo(t.bottomPath[o][0],t.bottomPath[o][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(i[n]+i[n+1]),e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.stroke()}e.globalAlpha=1;continue}const a=t.style.opacity??1;if(zn(e,t),t.fillGradient&&("colorStops"in t.fillGradient&&t.fillGradient.colorStops.length>=2||"topOpacity"in t.fillGradient)&&t.fillGradient){let n=1/0;for(const e of t.topPath)n>e[1]&&(n=e[1]);let o=-1/0;for(const e of t.bottomPath)e[1]>o&&(o=e[1]);const r=b(e,t.fillGradient,"string"==typeof s?s:"#4e79a7",0,n,0,o);e.fillStyle=r||s,e.globalAlpha=a}else e.globalAlpha=(t.style.fillOpacity??.7)*a,e.fillStyle=s;if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(zn(e,t),Dn(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=a;const n=t.strokeGradient&&t.topPath.length>=2?x(e,t.strokeGradient,t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0):null;e.strokeStyle=n||qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const o=N(t.curve);if(e.beginPath(),o)Wn().x(e=>e[0]).y(e=>e[1]).curve(o).context(e)(t.topPath);else{e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1])}e.stroke()}void 0!==r&&1>r&&e.restore(),n&&e.restore(),e.globalAlpha=1}},Ln=(e,t,n,o)=>{const r=t.filter(e=>"point"===e.type);if(0!==r.length){e.save();try{const t=e.globalAlpha;for(const n of r)e.beginPath(),e.arc(n.x,n.y,n.r,0,2*Math.PI),e.globalAlpha=t*(n.style.opacity??n.style.fillOpacity??1),e.fillStyle=M(e,n.style.fill,"#4e79a7"),e.fill(),n.style.stroke&&(e.strokeStyle=M(e,n.style.stroke,n.style.stroke),e.lineWidth=n.style.strokeWidth||1,e.stroke()),In(e,n)}finally{e.restore()}}},On=new Map;function Hn(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=On.get(t);return n||(n=new Path2D(Ye(e.symbolType,e.size)),On.size>256&&On.clear(),On.set(t,n)),n}catch{return null}}var Fn=(e,t)=>{const n=e.globalAlpha;for(const o of t){if("symbol"!==o.type)continue;const t=o;if(0>=t.size)continue;const r=Hn(t);if(!r)continue;e.save(),e.translate(t.x,t.y),t.rotation&&e.rotate(t.rotation);const s=(t.style.opacity??1)*(t._decayOpacity??1);t.style.fill&&(e.globalAlpha=n*s*(t.style.fillOpacity??1),e.fillStyle=M(e,t.style.fill,"#4e79a7"),e.fill(r)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*s,e.strokeStyle=M(e,t.style.stroke,t.style.stroke),e.lineWidth=t.style.strokeWidth??1,e.stroke(r)),e.restore()}e.globalAlpha=n};function jn(e,t,n,o,r){if(0>=t.size)return;const s=t.glyph;if(!s||!s.parts?.length)return;const i=je(s,t.size);if(0>=i.scale)return;const a=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=a)return;const l=t=>{const n=M(e,t,t);return"string"==typeof n?n:t},c=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(n,o),t.rotation&&e.rotate(t.rotation),e.translate(i.offsetX,i.offsetY),e.scale(i.scale,i.scale),e.globalAlpha=r*a*(t.style.fillOpacity??1);const u=He(s,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&Oe(e,s,c,t.accent,t.ghostColor,l),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),Oe(e,s,c,t.accent,void 0,l),e.restore()}function $n(e,t){const{x:n,y:o,w:r,h:s}=t,{tl:i,tr:a,br:l,bl:c}=he(t);e.beginPath(),e.moveTo(n+i,o),e.lineTo(n+r-a,o),a>0&&e.arcTo(n+r,o,n+r,o+a,a),e.lineTo(n+r,o+s-l),l>0&&e.arcTo(n+r,o+s,n+r-l,o+s,l),e.lineTo(n+c,o+s),c>0&&e.arcTo(n,o+s,n,o+s-c,c),e.lineTo(n,o+i),i>0&&e.arcTo(n,o,n+i,o,i),e.closePath()}function Yn(e){switch(e.roundedEdge){case"bottom":return{x0:e.x,y0:e.y+e.h,x1:e.x,y1:e.y};case"right":return{x0:e.x+e.w,y0:e.y,x1:e.x,y1:e.y};case"left":return{x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y};default:return{x0:e.x,y0:e.y,x1:e.x,y1:e.y+e.h}}}var Xn=(e,t,n,o)=>{const r=t.filter(e=>"rect"===e.type);for(const t of r){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)Vn(e,t);else if(t.cornerRadii&&ve(t.cornerRadii)){const n=M(e,t.style.fill,qe(e,"var(--semiotic-primary, #007bff)")),o=Yn(t),r=t.fillGradient&&"string"==typeof n?b(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;e.fillStyle=r||n,$n(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else if(t.roundedTop&&t.roundedTop>0){const n=M(e,t.style.fill,qe(e,"var(--semiotic-primary, #007bff)")),o=Yn(t),r=t.fillGradient&&"string"==typeof n?b(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;e.fillStyle=r||n;const s=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:i,y:a,w:l,h:c}=t;switch(t.roundedEdge){case"right":e.moveTo(i,a),e.lineTo(i+l-s,a),e.arcTo(i+l,a,i+l,a+s,s),e.lineTo(i+l,a+c-s),e.arcTo(i+l,a+c,i+l-s,a+c,s),e.lineTo(i,a+c);break;case"left":e.moveTo(i+l,a),e.lineTo(i+s,a),e.arcTo(i,a,i,a+s,s),e.lineTo(i,a+c-s),e.arcTo(i,a+c,i+s,a+c,s),e.lineTo(i+l,a+c);break;case"bottom":e.moveTo(i,a),e.lineTo(i+l,a),e.lineTo(i+l,a+c-s),e.arcTo(i+l,a+c,i+l-s,a+c,s),e.lineTo(i+s,a+c),e.arcTo(i,a+c,i,a+c-s,s);break;default:e.moveTo(i,a+c),e.lineTo(i,a+s),e.arcTo(i,a,i+s,a,s),e.lineTo(i+l-s,a),e.arcTo(i+l,a,i+l,a+s,s),e.lineTo(i+l,a+c)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else{const n=M(e,t.style.fill,qe(e,"var(--semiotic-primary, #007bff)")),o=Yn(t),r=t.fillGradient&&"string"==typeof n?b(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;e.fillStyle=r||n,e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))}Nn(e,t),e.globalAlpha=1}};function Vn(e,t){const n=t.style.icon,o=t.style.iconPadding||2,r=Math.min(t.w,t.h)-o;if(0>=r)return;const s=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),s){const s=r+o,i=t.x+(t.w-r)/2;for(let o=t.y+t.h-r;o>=t.y-r;o-=s)e.drawImage(n,i,o,r,r)}else{const s=r+o,i=t.y+(t.h-r)/2;for(let o=t.x;t.x+t.w>o;o+=s)e.drawImage(n,o,i,r,r)}e.restore()}function Gn(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>128?"#000":"#fff"}function qn(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}var Un=(e,t,n,o)=>{const r=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of r){const n=t.style;if(null!=n?.opacity&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle=qe(e,"var(--semiotic-surface, #fff)"),e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),Nn(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const n=t.valueFormat?t.valueFormat(t.value):qn(t.value),o=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),r=t.x+t.w/2,s=t.y+t.h/2;e.fillStyle=Gn(t.fill),e.font=o+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,r,s)}}}finally{e.restore()}},Qn=(e,t,n,o)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const r=(t._decayOpacity??1)*(t.style?.opacity??1);1!==r&&(e.globalAlpha=r);const s=qe(e,t.wickColor)||t.wickColor,i=60>o.height,a=i?Math.max(t.wickWidth,2):t.wickWidth,l=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=s,e.lineWidth=a,e.stroke()};if(i||l(),t.isRange){const n=Math.max(2,Math.min(t.bodyWidth/2,.12*o.height));e.fillStyle=s,e.beginPath(),e.arc(t.x,t.highY,n,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,n,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const n=Math.min(t.openY,t.closeY),o=Math.abs(t.openY-t.closeY),r=t.isUp?t.upColor:t.downColor,s=qe(e,r)||r;e.fillStyle=s,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1)),e.strokeStyle=s,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1))}i&&l(),e.restore()}},Kn={line:[Bn,Rn,Ln],area:[Bn,Ln],stackedarea:[Bn,Ln],scatter:[Ln,Fn],bubble:[Ln,Fn],heatmap:[Un],bar:[Xn],swarm:[Ln],waterfall:[(e,t,n,o)=>{Xn(e,t);const r=t.filter(e=>"rect"===e.type);if(2>r.length)return;const s=r[0].datum,i=s?._connectorStroke;if(i){e.save(),e.strokeStyle=qe(e,i)||i,e.lineWidth=s?._connectorWidth??1,e.setLineDash([]);for(let t=0;r.length-1>t;t++){const o=r[t],s=r[t+1],i=o.datum,a=s.datum;if(null==i?.cumEnd||null==a?.baseline)continue;const l=n.y(i.cumEnd),c=o.x+o.w,u=s.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[Qn],mixed:[Bn,Rn,Ln],custom:[Bn,Xn,Un,Rn,Ln,Fn,(e,t)=>{const n=e.globalAlpha;for(const o of t)"glyph"===o.type&&jn(e,o,o.x,o.y,n);e.globalAlpha=n},Qn]};import{jsx as Jn,jsxs as Zn}from"react/jsx-runtime";import{jsx as eo,jsxs as to}from"react/jsx-runtime";function no(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function oo({hover:e}){const t=e.data??{},n=t.y??t.value,o=t.x??t.time;if(void 0===n&&void 0===o){const e=$(t);if(null!=e.title||e.entries.length>0)return to("div",{className:"semiotic-tooltip",style:H,children:[null!=e.title&&eo("div",{style:{fontWeight:600,marginBottom:e.entries.length?2:0},children:e.title+""}),e.entries.map(e=>to("div",{style:{opacity:.7,fontSize:11},children:[e.key,":"," ",eo("span",{style:{fontWeight:600},children:no(e.value)})]},e.key))]})}return to("div",{className:"semiotic-tooltip",style:H,children:[eo("div",{style:{fontWeight:600,marginBottom:2},children:no(n)}),eo("div",{style:{opacity:.7,fontSize:11},children:no(o)})]})}oo.ownsChrome=!0;import{useCallback as ro}from"react";import{useCallback as so,useRef as io}from"react";function ao(e){const t=new Map;for(const n of e){const e=n.group??"_default";let o=t.get(e);o||(o=[],t.set(e,o)),o.push(n)}for(const e of t.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const n=Array.from(t.keys()).sort((e,n)=>{const o=t.get(e),r=t.get(n);return(o.length>0?o[0].y:0)-(r.length>0?r[0].y:0)}),o=Array.from(t.values()).flat();o.sort((e,t)=>e.x-t.x||e.y-t.y);const r=new Map;for(let e=0;o.length>e;e++){o[e]._flatIndex=e;const t=o[e].datum?.id;null!=t&&r.set(t+"",e)}return{flat:o,groups:n,byGroup:t,idToIdx:r}}function lo(e,t){if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const n=Math.max(0,Math.min(t,e.flat.length-1)),o=e.flat[n];return{flatIndex:n,group:o.group??"_default",indexInGroup:o._groupIndex??0}}function co(e,t,n){const{group:o,indexInGroup:r}=t,s=n.byGroup.get(o);switch(e){case"ArrowRight":return s.length-1>r?s[r+1]._flatIndex:t.flatIndex;case"ArrowLeft":return r>0?s[r-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(o);return n.groups.length-1>e?uo(n,n.groups[e+1],s[r]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(o);return e>0?uo(n,n.groups[e-1],s[r]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function uo(e,t,n){const o=e.byGroup.get(t);let r=0,s=Math.abs(o[0].x-n.x);for(let e=1;o.length>e;e++){const t=Math.abs(o[e].x-n.x);s>t&&(s=t,r=e)}return o[r]._flatIndex}function ho(e){const t=[];for(const n of e)switch(n.type){case"point":t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"symbol":if(0>=n.size)break;t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"glyph":{if(0>=n.size||null==n.datum)break;const e=Fe(n.glyph,n.size);t.push({x:n.x+e.centerDx,y:n.y+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:"_default"});break}case"line":{const e=n,o=Array.isArray(e.datum)?e.datum:[],r=e.group??"_default";for(let n=0;e.path.length>n&&o.length>n;n++)t.push({x:e.path[n][0],y:e.path[n][1],datum:o[n],shape:"circle",group:r});break}case"area":{const e=n,o=Array.isArray(e.datum)?e.datum:[],r=e.group??"_default";for(let n=0;e.topPath.length>n&&o.length>n;n++)t.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:o[n],shape:"circle",group:r});break}case"rect":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.group??"_default"});break;case"heatcell":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}function fo(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}import{jsx as po,jsxs as yo}from"react/jsx-runtime";var go={top:20,right:20,bottom:30,left:40},mo=gn;function vo(e){if(e)return"x"===e.dimension?"pan-y":"y"===e.dimension?"pan-x":"none"}var xo=st(rt(function(e,t){const{chartType:n,runtimeMode:o,data:r,chunkThreshold:s,chunkSize:i,xAccessor:a,yAccessor:l,accessorRevision:y,colorAccessor:x,sizeAccessor:b,symbolAccessor:w,symbolMap:A,groupAccessor:T,lineDataAccessor:C,curve:P,normalize:R,baseline:M,stackOrder:N,binSize:I,valueAccessor:L,arrowOfTime:H="right",windowMode:$="sliding",windowSize:Y=200,timeAccessor:V,xExtent:G,yExtent:q,extentPadding:U=.1,scalePadding:Q,sizeRange:J,size:Z=[500,300],responsiveWidth:ne,responsiveHeight:oe,margin:re,className:se,background:ie,renderMode:ae,lineStyle:le,pointStyle:ce,areaStyle:ue,barStyle:de,waterfallStyle:he,swarmStyle:fe,barColors:pe,colorScheme:ve,boundsAccessor:ke,boundsStyle:we,y0Accessor:Ae,band:Se,gradientFill:_e,lineGradient:Te,areaGroups:Pe,openAccessor:Re,highAccessor:Me,lowAccessor:Ne,closeAccessor:Ie,candlestickStyle:De,showAxes:We=!0,axes:ze,xLabel:Be,yLabel:Le,yLabelRight:Oe,xFormat:He,yFormat:Fe,axisExtent:je,tickFormatTime:$e,tickFormatValue:Ye,hoverAnnotation:Xe,tooltipContent:Ve,customHoverBehavior:qe,customClickBehavior:rt,onObservation:st,annotationObservationCallback:it,chartId:at,enableHover:lt,hoverRadius:ct=30,tooltipMode:ht,annotations:pt,onAnnotationActivate:yt,autoPlaceAnnotations:vt,svgAnnotationRules:xt,showGrid:bt,legend:St,legendHoverBehavior:_t,legendClickBehavior:Tt,legendHighlightedCategory:Ct,legendIsolatedCategories:Pt,legendPosition:Rt,legendLayout:Mt,legendCategoryAccessor:Nt,onCategoriesChange:It,backgroundGraphics:Et,foregroundGraphics:Wt,canvasPreRenderers:zt,svgPreRenderers:Bt,title:Ht,categoryAccessor:jt,brush:$t,onBrush:Yt,decay:Xt,pulse:Vt,transition:Gt,animate:qt,staleness:Ut,frameScheduler:Qt,clock:Kt,random:Jt,seed:Zt,paused:en=!1,suspendWhenHidden:tn=!0,heatmapAggregation:nn,heatmapXBins:on,heatmapYBins:rn,showValues:an,heatmapValueFormat:ln,marginalGraphics:un,pointIdAccessor:hn,xScaleType:fn,yScaleType:pn,accessibleTable:wn=!0,description:An,summary:Tn,linkedCrosshairName:Cn,linkedCrosshairSourceId:Pn,customLayout:Rn,onLayoutError:Mn,layoutConfig:Nn,layoutSelection:In}=e,{customHoverBehavior:Dn,customClickBehavior:En,hasClickBehavior:Wn}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:o,chartType:r}){return{customHoverBehavior:ro((t,s)=>{e?.(t,s),ge({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:r,chartId:o,context:s})},[o,r,e,n]),customClickBehavior:ro((e,s)=>{t?.(e,s),ye({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:r,chartId:o,context:s})},[o,r,t,n]),hasClickBehavior:!(!t&&!n)}}({customHoverBehavior:qe,customClickBehavior:rt,onObservation:st,chartId:at,chartType:"StreamXYFrame"}),zn=ot().replace(/:/g,""),Bn=Ke(!1),Ln=Ke({w:-1,h:-1}),On=Ke(!1),Hn=D({sizeProp:Z,responsiveWidth:ne,responsiveHeight:oe,userMargin:re,marginDefault:go,title:Ht,legend:St,legendPosition:Rt,animate:qt,transitionProp:Gt,frameScheduler:Qt,clock:Kt,random:Jt,seed:Zt,paused:en,suspendWhenHidden:tn,themeDirtyRef:Bn}),Fn=W(),jn=B(),{reducedMotionRef:$n,responsiveRef:Yn,size:Xn,currentTheme:Vn,transition:Gn,introEnabled:qn,tableId:Un,rafRef:Qn,renderFnRef:Jn,scheduleRender:Zn,frameRuntime:eo}=Hn;let to=Hn.margin;if(un){const e=60,t={...Hn.margin};un.top&&e>t.top&&(t.top=e),un.bottom&&e>t.bottom&&(t.bottom=e),un.left&&e>t.left&&(t.left=e),un.right&&e>t.right&&(t.right=e),to=t}const no=Xn[0]-to.left-to.right,uo=Xn[1]-to.top-to.bottom,fo=et(()=>me(r),[r]),xo=Xe??lt,[bo,ko]=Je(0),wo=Ke(0),[Ao,So]=Je(null),_o=vn(Wt,Xn,to,Ao),To=vn(Et,Xn,to,Ao),Co=Ke(null),Po=Ke(null),Ro=Ke(void 0),[Mo,No]=Je(null),Io=Ke(mo.primary),Do=Ke(function(){let e=-1,t=gn;return{resolve(n){if(!n)return gn;const o=Ge();return o===e||(t=function(e){if(!e)return gn;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),r=t.getPropertyValue("--semiotic-bg").trim(),s=t.getPropertyValue("--semiotic-primary").trim(),i=o||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),l=n||t.getPropertyValue("--surface-3").trim(),c=r||t.getPropertyValue("--surface-0").trim();return i||a||n||s?{axisStroke:l||gn.axisStroke,tickText:i||gn.tickText,crosshair:i?mn(i,"66"):gn.crosshair,hoverFill:c?mn(c,"4D"):gn.hoverFill,hoverStroke:i?mn(i,"99"):gn.hoverStroke,pointRing:c||gn.pointRing,primary:s||gn.primary,background:c||gn.background}:gn}(n),e=o),t},invalidate(){e=-1}}}()),Eo=Ke(!1),Wo=z("StreamXYFrame"),[zo,Bo]=Je(!1),[Lo,Oo]=Je([]),[Ho,Fo]=Je([]),jo="streaming"===o||["bar","swarm","waterfall"].includes(n),$o=dn(et(()=>({chartType:n,runtimeMode:jo?"streaming":"bounded",windowSize:Y,windowMode:$,arrowOfTime:jo?H:"right",extentPadding:U,scalePadding:Q,axisExtent:je,xAccessor:a,yAccessor:l,accessorRevision:y,timeAccessor:jo?V:void 0,valueAccessor:L,colorAccessor:x,sizeAccessor:b,symbolAccessor:w,symbolMap:A,groupAccessor:T||(C?"_lineGroup":void 0),categoryAccessor:jt,lineDataAccessor:C,xScaleType:fn,yScaleType:pn,xExtent:G,yExtent:q,sizeRange:J,binSize:I,normalize:R,baseline:M,stackOrder:N,boundsAccessor:ke,boundsStyle:we,y0Accessor:Ae,band:Se,gradientFill:!0===_e?{topOpacity:.8,bottomOpacity:.05}:!1===_e?void 0:_e,areaGroups:Pe?new Set(Pe):void 0,lineGradient:Te,openAccessor:Re,highAccessor:Me,lowAccessor:Ne,closeAccessor:Ie,candlestickStyle:De,lineStyle:le,pointStyle:ce,areaStyle:ue,swarmStyle:fe,waterfallStyle:he,colorScheme:ve,barColors:pe,barStyle:de,annotations:pt,decay:Xt,pulse:Vt,transition:Gn,introAnimation:qn,staleness:Ut,clock:eo.now,heatmapAggregation:nn,heatmapXBins:on,heatmapYBins:rn,showValues:an,heatmapValueFormat:ln,pointIdAccessor:hn,curve:P,themeCategorical:Vn?.colors?.categorical,themeSemantic:Ue(Vn),themeSequential:Vn?.colors?.sequential,themeDiverging:Vn?.colors?.diverging,customLayout:Rn,onLayoutError:Mn,layoutConfig:Nn,layoutMargin:to}),[n,jo,Y,$,H,U,Q,je,a,l,y,V,L,x,b,w,A,T,C,jt,fn,pn,G,q,J,I,R,M,N,ke,we,Ae,Se,_e,Pe,Te,Re,Me,Ne,Ie,De,le,ce,ue,fe,he,ve,pe,de,pt,Xt,Vt,Gn,qn,Ut,eo.now,nn,on,rn,an,ln,hn,P,Vn,Rn,Mn,Nn,to])),Yo=Ke(null);Yo.current||(Yo.current=new X($o));const Xo=function(e,t,n,o){const r=bn({accessor:t,onChange:n,readData:o}),s=bn([]);return r.current={accessor:t,onChange:n,readData:o},xn(()=>{const{accessor:t,onChange:n,readData:o}=r.current;if(!n||!t)return;const i=function(e,t){if(!t)return[];const n=new Set,o=[];for(const r of e){if(!r||"object"!=typeof r)continue;const e="function"==typeof t?t(r):r[t];if(null==e)continue;const s=e+"";n.has(s)||(n.add(s),o.push(s))}return o}(e.current?o(e.current):[],t);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(i,s.current)||(s.current=i,n(i))},[e])}(Yo,Nt,It,e=>e.getData());gt(Yo,$o,Bn,Zn),mt(Yo,In,Bn,Zn);const Vo=Ke(null);Vo.current||(Vo.current=new dt(e=>{const t=Yo.current;t&&t.ingest(e)&&(Bn.current=!0,Zn())},{chunkThreshold:s,chunkSize:i})),Ze(()=>{Vo.current?.updateChunkOptions({chunkThreshold:s,chunkSize:i})},[s,i]);const Go=tt(e=>{Vo.current?.push(e)},[]),qo=tt(e=>{Vo.current?.pushMany(e)},[]),Uo=tt(()=>{Vo.current?.clear(),Yo.current?.clear(),Bn.current=!0,Zn()},[Zn]);nt(t,()=>({push:Go,pushMany:qo,remove:e=>{Vo.current?.flush();const t=Yo.current?.remove(e)??[];return t.length>0&&(Co.current&&t.some(e=>e===Co.current?.data)&&(Co.current=null,No(null)),Bn.current=!0,Zn()),t},update:(e,t)=>{Vo.current?.flush();const n=Yo.current?.update(e,t)??[];return n.length>0&&(Bn.current=!0,Zn()),n},clear:Uo,getData:()=>(Vo.current?.flush(),Yo.current?.getData()??[]),getScales:()=>Yo.current?.scales??null,getExtents:()=>Yo.current?.getExtents()??null,getCustomLayout:()=>Yo.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Yo.current?.lastCustomLayoutFailure??null}),[Go,qo,Uo,Zn]),Ze(()=>{if(r){if(C&&fo.length>0&&"object"==typeof fo[0]&&null!==fo[0]){const e="string"==typeof C?C:"coordinates";if(Array.isArray(fo[0][e])){const t=[];for(const n of fo){const o=n[e];if(Array.isArray(o)){const e=n.label||n.id||n.key;if(null!=e)for(const n of o)t.push({...n,_lineGroup:e});else for(const e of o)t.push(e)}}return void Vo.current?.setBoundedData(t)}}Vo.current?.setBoundedData(fo)}},[r,fo,C]);const{canvasRef:Qo,interactionCanvasRef:Ko}=E(Hn,{storeRef:Yo,dirtyRef:Bn,hydrated:Fn,wasHydratingFromSSR:jn,cleanup:()=>Vo.current?.clear(),canvasPaintDependencies:[n,no,uo,We,ie,Et,le,ae,zt,Zn]}),{hoverHandlerRef:Jo,hoverLeaveRef:Zo,onPointerMove:er,onPointerLeave:tr}=Hn;Jo.current=e=>{if(!xo)return;const t=Qo.current;if(!t)return;const o=t.getBoundingClientRect(),r=e.clientX-o.left-to.left,s=e.clientY-o.top-to.top;if(0>r||r>no||0>s||s>uo)return void(Co.current&&(Co.current=null,Po.current=null,No(null),Dn&&(Dn(null),Bn.current=!0),Zn()));const i=Yo.current;if(!i||0===i.scene.length)return;const l=F(ct,e.pointerType),c=wt(i.scene,r,s,l,i.quadtree,i.maxPointRadius),u="multi"===ht,d=()=>{Co.current&&(Co.current=null,Po.current=null,No(null),Dn&&Dn(null),Zn())};if(!c&&!u)return void d();const h=u||!c?r:c.x,f=u||!c?s:c.y,p=c?.datum?K(c.datum,i.resolvedRibbons):{},y=i.scales?.x?.invert,g="function"==typeof y?y(h):void 0;let m=O(p,h,f,null!=g?{xValue:g,xPx:h}:void 0);if(u&&i.scene.length>0&&i.scales){const e=function(e,t,n=30){const o=[];for(const r of e)if("line"===r.type){const e=r;if(2>e.path.length)continue;const s=At(kt(e.path,e.curve),t,n);if(null===s)continue;const i=Dt(e.path,t);o.push({node:r,datum:Array.isArray(e.datum)&&e.datum[i]?e.datum[i]:e.datum,x:e.path[i][0],y:s,group:e.group,color:e.style.stroke})}else if("area"===r.type){const e=r;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const s=kt(e.topPath,e.curve),i=kt(e.bottomPath,e.curve),a=At(s,t,n);if(null===a)continue;const l=At(i,t,n),c=Dt(e.topPath,t);o.push({node:r,datum:Array.isArray(e.datum)&&e.datum[c]?e.datum[c]:e.datum,x:e.topPath[c][0],y:a,y0:l??void 0,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return o}(i.scene,h,Math.max(l,no));if(e.length>0){const t=i.scales.y.invert,o=Io.current,r=y?y(h):h;if(c)m.xValue=r,m.xPx=h;else{const e={xValue:r};"string"==typeof a&&(e[a]=r),m=O(e,h,f,{xValue:r,xPx:h})}m.allSeries=e.map(e=>{const r=t?t(e.y):e.y,s=null!=e.y0?t?t(e.y0):e.y0:void 0;return{group:e.group||"",value:"stackedarea"===n&&null!=s?r-s:r,valuePx:e.y,color:e.color||o,datum:K(e.datum,i.resolvedRibbons)}})}}c||m.allSeries?.length?(Co.current=m,Po.current=c?.node??null,No(m),Dn&&(Dn(m),Bn.current=!0),Zn()):d()},Zo.current=()=>{Co.current&&(Co.current=null,Po.current=null,No(null),Dn&&(Dn(null),Bn.current=!0),Zn())};const nr=Ke(()=>{});nr.current=e=>{if(j(e.target))return;if(!En)return;const t=Qo.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-to.left,r=e.clientY-n.top-to.top;if(0>o||o>no||0>r||r>uo)return void En(null);const s=Yo.current;if(!s||0===s.scene.length)return void En(null);const i=F(ct,Ro.current),a=wt(s.scene,o,r,i,s.quadtree,s.maxPointRadius);if(!a)return void En(null);const l=a.datum||{},c=s.scales?.x?.invert,u="function"==typeof c?c(a.x):void 0;En(O(l,a.x,a.y,null!=u?{xValue:u,xPx:a.x}:void 0),{type:"activate",inputType:Ce(Ro.current)})};const or=tt(e=>nr.current(e),[]),{kbFocusIndexRef:rr,focusedNavPointRef:sr,onKeyDown:ir}=(ur={storeRef:Yo,hoverRef:Co,hoveredNodeRef:Po,setHoverPoint:No,customHoverBehavior:Dn,customClickBehavior:En,scheduleRender:Zn},function({storeRef:e,hoverRef:t,hoveredNodeRef:n,setHoverPoint:o,customHoverBehavior:r,customClickBehavior:s,scheduleRender:i,extractPoints:a,toHover:l}){const c=io(-1),u=io(null),d=io(null),h=so(h=>{if(xe(h))return;const f=e.current;if(!f)return;const p=()=>{c.current=-1,u.current=null,t.current=null,n&&(n.current=null),o(null),r(null),i()};if(0===f.scene.length)return void(0>c.current||p());let y;if(d.current?.version===f.version)y=d.current.graph;else{const e=a(f.scene);if(0===e.length)return void(0>c.current||p());y=ao(e),d.current={version:f.version,graph:y}}let g=c.current;if(y.flat.length>g||(p(),g=-1),("Enter"===h.key||" "===h.key)&&g>=0)return h.preventDefault(),void s(l(y.flat[g],f),{type:"activate",inputType:"keyboard"});if(0>g){if("Escape"===h.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(h.key))return;h.preventDefault(),c.current=0;const e=y.flat[0];u.current=e;const n=l(e,f);return t.current=n,o(n),r(n,{type:"focus",inputType:"keyboard"}),void i()}const m=co(h.key,lo(y,g),y);if(null===m)return;if(h.preventDefault(),0>m)return void p();c.current=m;const v=y.flat[m];u.current=v;const x=l(v,f);t.current=x,o(x),r(x,{type:"focus",inputType:"keyboard"}),i()},[s,r,a,t,n,i,o,e,l]);return{kbFocusIndexRef:c,focusedNavPointRef:u,onKeyDown:h}}({...ur,extractPoints:ho,toHover:(e,t)=>function(e){return{data:e.datum||{},x:e.x,y:e.y,__semioticHoverData:!0}}({...e,datum:K(e.datum,t.resolvedRibbons)})})),ar=tt(e=>{Ro.current=e.pointerType,rr.current=-1,sr.current=null,er(e)},[sr,rr,er]),lr=tt(e=>{Ro.current="mouse",rr.current=-1,sr.current=null,er({clientX:e.clientX,clientY:e.clientY,pointerType:"mouse"})},[sr,rr,er]),cr=tt(e=>{Ro.current=e.pointerType},[]);var ur;Jn.current=()=>{if(Qn.current=null,!eo.isActive)return;const e=Qo.current,t=Ko.current;if(!e||!t)return;const o=Yo.current;if(!o)return;const r=eo.now(),s=o.advanceTransition($n.current?r+1e6:r),i=!$n.current&&s,c=Ln.current.w!==no||Ln.current.h!==uo,u=Bn.current||s||c,d=o.consumeStylePaintPending();let h=!1;const f=o.getLastUpdateResult(),p=Wo.current.beforeCompute(f,i);!u||i&&!c||(o.computeScene({width:no,height:uo}),Ln.current={w:no,h:uo},h=!0,Xo()),Wo.current.afterCompute(p,h,c);const y=function(e,t,n,o){const r=o.current,s=!0===e.lastCustomLayoutFailure?.preservedLastGoodScene,i=!s&&e.hasActivePulsesAt(t),a=!(n||s||!i&&!r)&&e.refreshPulse(t);return o.current=i,{changed:a,pending:i}}(o,r,h,On),g=S(),m=Do.current.resolve(e);Io.current=m.primary;const v=Lt(Ut,o.lastIngestTime>0?r-o.lastIngestTime:0),x=Ut&&v.isStale;if(u||d||y.changed){const t=_(e,Xn,to,g);if(t){if(t.clearRect(-to.left,-to.top,Xn[0],Xn[1]),Ut&&1>v.alpha&&(t.globalAlpha=v.alpha),yn(t,{background:ie,hasBackgroundGraphics:!!Et,themeBackground:m.background,x:-to.left,y:-to.top,width:Xn[0],height:Xn[1]}),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,no,uo),t.clip()),zt&&o.scales)for(const e of zt)t.save(),e(t,o.scene,o.scales,{width:no,height:uo}),t.restore();const e=Rn?Kn.custom:Kn[n];ee({context:t,nodes:o.scene,renderMode:ae,pixelRatio:g,paintBuiltIn:n=>{if(e&&o.scales)for(const r of e)r(t,n,o.scales,{width:no,height:uo})}}),t.restore(),Ut&&1>v.alpha&&(t.globalAlpha=1)}}const b=!!(xo&&Co.current&&o.scales),w=!!(Po.current&&Array.isArray(Xe)&&Xe.some(e=>e&&"object"==typeof e&&"highlight"===e.type)),A=b||w;if(A||Eo.current){const e=_(t,Xn,to,g);if(e&&(e.clearRect(-to.left,-to.top,Xn[0],Xn[1]),b&&Co.current&&function(e,t,n,o,r,s,i){if(!1===r.crosshair)return;const a=t.allSeries,l=a&&a.length>0,c=t.xPx??t.x;e.save();const u="object"==typeof r.crosshair?r.crosshair:{};if(e.strokeStyle=u.stroke||i.crosshair,e.lineWidth=u.strokeWidth||1,e.setLineDash(u.strokeDasharray?u.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(l?c:t.x,0),e.lineTo(l?c:t.x,o),e.stroke(),l||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),l){e.lineWidth=2,e.strokeStyle=i.pointRing;for(const t of a)null!=t.valuePx&&(e.beginPath(),e.arc(c,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||i.primary,e.fill(),e.stroke())}else{const n=r.pointColor||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const n="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||n||null:n||t.stroke||null}(s)||i.primary;e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=n,e.fill(),e.strokeStyle=i.pointRing,e.lineWidth=2,e.stroke()}}(e,Co.current,no,uo,"object"==typeof xo?xo:{},Po.current,m),w&&Po.current&&Array.isArray(Xe))){const t=Xe.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,o,r){if(!n)return;const s="group"in n?n.group:void 0;if(void 0!==s)for(const n of t){if("line"!==n.type)continue;if(n.group!==s)continue;if(2>n.path.length)continue;const t="function"==typeof o.style?n.datum?o.style(n.datum):{}:o.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||r.primary,e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=t.opacity??1,e.stroke(),e.restore()}}(e,o.scene,Po.current,t,m)}Eo.current=A}u&&e&&e.setAttribute("aria-label",k(o.scene,n+" chart"));const T=Bn.current;if(Bn.current=T&&i&&!h,T&&o.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!Ao||e(Ao.x.domain()[0])!==e(o.scales.x.domain()[0])||e(Ao.x.domain()[1])!==e(o.scales.x.domain()[1])||e(Ao.y.domain()[0])!==e(o.scales.y.domain()[0])||e(Ao.y.domain()[1])!==e(o.scales.y.domain()[1])||Ao.x.range()[0]!==o.scales.x.range()[0]||Ao.x.range()[1]!==o.scales.x.range()[1]||Ao.y.range()[0]!==o.scales.y.range()[0]||Ao.y.range()[1]!==o.scales.y.range()[1])&&So(o.scales),un){const e=o.getData(),t="function"==typeof a?a:e=>e[a||"x"],n="function"==typeof l?l:e=>e[l||"y"];Oo(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),Fo(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}!((pt&&pt.length>0||Rn)&&(h||i))||!h&&33>r-wo.current||(ko(e=>e+1),wo.current=r),Ut?.showBadge&&Bo(!!x),(i||null!=o.activeTransition||y.pending)&&Zn()},Ot(Ut,Yo,Bn,Zn,zo,Bo);const dr=et(()=>{if(He||$e)return;const e=Yo.current;return e?.xIsDate&&Ao?Sn(Ao.x.domain()):void 0},[He,$e,Ao]),hr=He||$e||dr,fr=xo&&Mo?Ve?Ve(Mo):po(oo,{hover:Mo}):null,pr=fr?po(f,{x:Mo.x,y:Mo.y,containerWidth:no,containerHeight:uo,margin:to,className:"stream-frame-tooltip",children:fr}):null,yr=sr.current,gr=po(p,{active:rr.current>=0,hoverPoint:Mo,margin:to,size:Xn,shape:yr?.shape,width:yr?.w,height:yr?.h}),mr=kn(a,V,"__semiotic_resolvedX","__semiotic_resolvedTime"),vr=kn(l,L,"__semiotic_resolvedY","__semiotic_resolvedValue"),xr=mr.key,br=vr.key,kr=function(e,t,n){return o=>{if(!o||!n||!e.fn&&!t.fn)return o;let r=!1;const s=o.map(n=>{const o=e.fn&&e.key&&!(e.key in n),s=t.fn&&t.key&&!(t.key in n);if(!o&&!s)return n;r=!0;const i={...n};return o&&(i[e.key]=e.fn(n)),s&&(i[t.key]=t.fn(n)),i});return r?s:o}}(mr,vr,pt&&pt.length>0||!1);if(be||!Fn&&jn){const e=Yo.current;e&&r&&(e.ingest({inserts:fo,bounded:!0}),e.computeScene({width:no,height:uo}));const t=e?.scene??[],n=e?.scales??null,o=vn(Wt,Xn,to,n),s=vn(Et,Xn,to,n),i=hr||(()=>{if(e?.xIsDate&&n)return Sn(n.x.domain())})();return yo("div",{ref:Yn,className:"stream-xy-frame"+(se?" "+se:""),role:"img","aria-label":An||("string"==typeof Ht?Ht:"XY chart"),style:{position:"relative",width:ne?"100%":Xn[0],height:oe?"100%":Xn[1]},children:[po(m,{summary:Tn}),yo("svg",{xmlns:"http://www.w3.org/2000/svg",width:Xn[0],height:Xn[1],style:{position:"absolute",left:0,top:0},children:[po("g",{transform:`translate(${to.left},${to.top})`,children:s}),yo("g",{transform:`translate(${to.left},${to.top})`,children:[ie&&po("rect",{x:0,y:0,width:no,height:uo,fill:ie}),Bt&&n&&Bt.map((e,o)=>po(Qe.Fragment,{children:e(t,n,{width:no,height:uo})},"svgpre-"+o)),t.map((e,t)=>te({node:e,index:t,renderMode:ae,fallback:()=>Ee(e,t,zn)})).filter(Boolean)]})]}),po(cn,{width:no,height:uo,totalWidth:Xn[0],totalHeight:Xn[1],margin:to,scales:n,showAxes:We,axes:ze,xLabel:Be,yLabel:Le,yLabelRight:Oe,xFormat:i,yFormat:Fe||Ye,axisExtent:je,showGrid:bt,title:Ht,legend:St,legendHoverBehavior:_t,legendClickBehavior:Tt,legendHighlightedCategory:Ct,legendIsolatedCategories:Pt,legendPosition:Rt,legendLayout:Mt,foregroundGraphics:ft(o,c(Yo.current?.customLayoutOverlays,In??null)),marginalGraphics:un,xValues:[],yValues:[],annotations:pt,onAnnotationActivate:yt,onObservation:it??st,chartId:at,chartType:"StreamXYFrame",autoPlaceAnnotations:vt,svgAnnotationRules:xt,annotationFrame:0,xAccessor:xr,yAccessor:br,annotationData:kr(Yo.current?.getData()),pointNodes:_n(Yo.current?.scene),curve:"string"==typeof P?P:void 0,linkedCrosshairName:Cn,linkedCrosshairSourceId:Pn})]})}return yo("div",{ref:Yn,className:"stream-xy-frame"+(se?" "+se:""),role:"group","aria-label":An||("string"==typeof Ht?Ht:"XY chart"),tabIndex:0,style:{position:"relative",width:ne?"100%":Xn[0],height:oe?"100%":Xn[1],overflow:"visible",touchAction:vo($t)},onKeyDown:ir,children:["production"!==process.env.NODE_ENV&&Yo.current&&po(g,{store:Yo.current,diagnostics:Wo.current}),wn&&po(v,{tableId:Un}),wn&&po(u,{scene:Yo.current?.scene??[],chartType:n+" chart",tableId:Un,chartTitle:"string"==typeof Ht?Ht:void 0}),po(m,{summary:Tn}),po(d,{hoverPoint:Mo}),yo("div",{role:"img","aria-label":An||("string"==typeof Ht?Ht:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:xo?ar:void 0,onMouseMove:xo?lr:void 0,onPointerLeave:xo?tr:void 0,onMouseLeave:xo?tr:void 0,onPointerDown:xo||Wn?cr:void 0,onClick:Wn?or:void 0,children:[po(h,{size:Xn,margin:to,children:To}),po(sn,{width:no,height:uo,totalWidth:Xn[0],totalHeight:Xn[1],margin:to,scales:Ao,showAxes:We,axes:ze,showGrid:bt,xFormat:hr,yFormat:Fe||Ye,axisExtent:je}),po("canvas",{ref:Qo,"aria-label":k(Yo.current?.scene??[],n+" chart"),style:{position:"absolute",left:0,top:0}}),po("canvas",{ref:Ko,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),po(cn,{width:no,height:uo,totalWidth:Xn[0],totalHeight:Xn[1],margin:to,scales:Ao,showAxes:We,axes:ze,xLabel:Be,yLabel:Le,yLabelRight:Oe,xFormat:hr,yFormat:Fe||Ye,axisExtent:je,showGrid:bt,title:Ht,legend:St,legendHoverBehavior:_t,legendClickBehavior:Tt,legendHighlightedCategory:Ct,legendIsolatedCategories:Pt,legendPosition:Rt,legendLayout:Mt,foregroundGraphics:ft(_o,c(Yo.current?.customLayoutOverlays,In??null)),marginalGraphics:un,xValues:Lo,yValues:Ho,annotations:pt,onAnnotationActivate:yt,onObservation:it??st,chartId:at,chartType:"StreamXYFrame",autoPlaceAnnotations:vt,svgAnnotationRules:xt,annotationFrame:bo,xAccessor:xr,yAccessor:br,annotationData:kr(Yo.current?.getData()),pointNodes:_n(Yo.current?.scene),curve:"string"==typeof P?P:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==ie&&!Et,linkedCrosshairName:Cn,linkedCrosshairSourceId:Pn}),($t||Yt)&&po(ut,{width:no,height:uo,totalWidth:Xn[0],totalHeight:Xn[1],margin:to,dimension:$t?.dimension??"xy",scales:Ao,onBrush:Yt??(()=>{}),binSize:I,snap:$t?.snap,binBoundaries:$t?.binBoundaries??("bar"===n?Yo.current?.getBinBoundaries():void 0),snapDuring:$t?.snapDuring,streaming:"streaming"===o}),Ut?.showBadge&&po(Ft,{isStale:zo,position:Ut.badgePosition}),gr,pr]})]})}));xo.displayName="StreamXYFrame";var bo=xo;import{useRef as ko,useState as wo,useEffect as Ao,useMemo as So,useCallback as _o,useImperativeHandle as To,forwardRef as Co,memo as Po}from"react";var Ro={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Mo={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1},No=class{constructor(e){this.capacity=e,this.particles=Array(e),this._freeIndices=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[t]=e-1-t}spawn(e,t=Math.random){const n=this._freeIndices.pop();if(void 0===n)return null;const o=this.particles[n];return o.active=!0,o.t=0,o.offset=t()-.5,o.edgeIndex=e,o.x=0,o.y=0,o}step(e,t,n,o){for(let r=0;this.capacity>r;r++){const s=this.particles[r];if(!s.active)continue;const i=n[s.edgeIndex];i&&i.bezier?(s.t+=e*t*(o?o[s.edgeIndex]??1:1)*(i.bezier.circular?.3:1),1>s.t?Io(i.bezier,s.t,s.offset,s):(s.active=!1,this._freeIndices.push(r))):(s.active=!1,this._freeIndices.push(r))}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1;this._freeIndices.length=0;for(let e=this.capacity-1;e>=0;e--)this._freeIndices.push(e)}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let n=0;e>n;n++)t.length>n?this.particles[n]=t[n]:(this.particles[n]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(n));this.capacity=e}};function Io(e,t,n,o){if(e.circular&&e.segments)return void function(e,t,n,o,r){const s=e.length,i=t*s,a=Math.min(Math.floor(i),s-1),l=i-a,[c,u,d,h]=e[a];Do(c,u,d,h,l,r);const f=h.x-c.x,p=h.y-c.y,y=Math.sqrt(f*f+p*p);if(y>.001){const e=f/y;r.x+=-p/y*n*o*2,r.y+=e*n*o*2}}(e.segments,t,n,e.halfWidth,o);if(!e.points)return o.x=0,void(o.y=0);const[r,s,i,a]=e.points;Do(r,s,i,a,t,o);const l=a.x-r.x,c=a.y-r.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;o.x+=-c/u*n*e.halfWidth*2,o.y+=t*n*e.halfWidth*2}}function Do(e,t,n,o,r,s){const i=1-r,a=i*i,l=a*i,c=r*r,u=c*r;s.x=l*e.x+3*a*r*t.x+3*i*c*n.x+u*o.x,s.y=l*e.y+3*a*r*t.y+3*i*c*n.y+u*o.y}import{quadtree as Eo}from"d3-quadtree";function Wo(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function zo(e){if(!e||"object"!=typeof e)return!1;const t=e;if("boolean"!=typeof t.circular)return!1;if("number"!=typeof t.halfWidth||!Number.isFinite(t.halfWidth))return!1;if(t.circular){if(!Array.isArray(t.segments)||0===t.segments.length)return!1;for(const e of t.segments)if(!Bo(e))return!1;return!0}return Bo(t.points)}function Bo(e){if(!Array.isArray(e)||4!==e.length)return!1;for(const t of e){if(!t||"object"!=typeof t)return!1;const e=t;if("number"!=typeof e.x||!Number.isFinite(e.x))return!1;if("number"!=typeof e.y||!Number.isFinite(e.y))return!1}return!0}import{interpolateNumber as Lo}from"d3-interpolate";var Oo="rgba(34, 197, 94, 0.7)",Ho=2e3,Fo=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],jo=["scene-style","data-paint","accessibility","evidence"],$o=(e,t)=>({retainedData:e,invalidations:t}),Yo=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Xo=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Vo=["scene-geometry","data-paint","overlay","accessibility","evidence"],Go=["scene-style","data-paint","accessibility","evidence"],qo=["scene-geometry","data-paint","overlay","accessibility","evidence"],Uo=[],Qo={chartType:$o("rebuild",Yo),nodeIDAccessor:$o("rebuild",Yo),sourceAccessor:$o("rebuild",Yo),targetAccessor:$o("rebuild",Yo),valueAccessor:$o("rebuild",Yo),edgeIdAccessor:$o("rebuild",Yo),childrenAccessor:$o("rebuild",Yo),hierarchySum:$o("rebuild",Yo),orientation:$o("preserve",Xo),nodeAlign:$o("preserve",Xo),nodePaddingRatio:$o("preserve",Xo),nodeWidth:$o("preserve",Xo),edgeSort:$o("preserve",Xo),iterations:$o("preserve",Xo),forceStrength:$o("preserve",Xo),padAngle:$o("preserve",Xo),groupWidth:$o("preserve",Xo),sortGroups:$o("preserve",Xo),treeOrientation:$o("preserve",Xo),edgeType:$o("preserve",Xo),padding:$o("preserve",Xo),paddingTop:$o("preserve",Xo),orbitMode:$o("preserve",Xo),orbitSize:$o("preserve",Xo),orbitSpeed:$o("preserve",Xo),orbitRevolution:$o("preserve",Xo),orbitRevolutionStyle:$o("preserve",Xo),orbitEccentricity:$o("preserve",Xo),orbitShowRings:$o("preserve",Xo),orbitAnimated:$o("preserve",Xo),customNetworkLayout:$o("preserve",Xo),layoutConfig:$o("preserve",Xo),nodeSize:$o("preserve",Vo),nodeSizeRange:$o("preserve",Vo),colorByDepth:$o("preserve",Vo),nodeLabel:$o("preserve",qo),showLabels:$o("preserve",qo),labelMode:$o("preserve",qo),nodeStyle:$o("preserve",Go),edgeStyle:$o("preserve",Go),colorBy:$o("preserve",Go),colorScheme:$o("preserve",Go),themeCategorical:$o("preserve",Go),themeSemantic:$o("preserve",Go),edgeColorBy:$o("preserve",Go),edgeOpacity:$o("preserve",Go),showParticles:$o("preserve",Go),particleStyle:$o("preserve",Go),decay:$o("preserve",Go),pulse:$o("preserve",Go),thresholds:$o("preserve",Go),staleness:$o("preserve",Go),layoutSelection:$o("preserve",Go),clock:$o("preserve",Uo),random:$o("preserve",Uo),seed:$o("preserve",Uo),tensionConfig:$o("preserve",Uo),transition:$o("preserve",Uo),introAnimation:$o("preserve",Uo),onLayoutError:$o("preserve",Uo),__skipForceSimulation:$o("preserve",Uo),__hierarchyRoot:$o("preserve",Uo),__orbitState:$o("preserve",Uo),__previousPositions:$o("preserve",Uo)},Ko=$o("preserve",Xo),Jo=class{constructor(){this.tracker=new Be}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},Fo)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},jo):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const o of e){const e=Qo[o]??Ko;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}},Zo=class e{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this.customLayoutHtmlMarks=[],this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._nodeQuadtree=null,this._maxNodeRadius=0,this._sceneNodesRevision=0,this._nodeQuadtreeRevision=-1,this._nodesArrCache=null,this._edgesArrCache=null,this._arrCacheVersion=-1,this.particlePool=null,this.updateResults=new Jo,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this._decayAgeMap=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._networkDecayCache=null,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig={...Ro,...e.tensionConfig},e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new No(2e3))}currentTime(){return this.config.clock?.()??Te()}updateConfig(e){const t=this.config,n={...t,...e};t.__orbitState&&(n.__orbitState=t.__orbitState),t.__hierarchyRoot&&(n.__hierarchyRoot=t.__hierarchyRoot),void 0===e.layoutSelection&&null!=t.layoutSelection&&(n.layoutSelection=t.layoutSelection);const o=[...new Set([...Object.keys(t),...Object.keys(n)])].filter(e=>t[e]!==n[e]);this.config=n,this.tensionConfig={...Ro,...n.tensionConfig},!n.showParticles||"sankey"!==n.chartType&&!n.customNetworkLayout||this.particlePool||(this.particlePool=new No(2e3)),this.updateResults.recordConfig(o)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}ingestHierarchy(e,t){this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null,this.updateResults.recordData("replace",1)}ingestBounded(e,t,n,o){const{nodeIDAccessor:r="id",sourceAccessor:s="source",targetAccessor:i="target",valueAccessor:a="value"}=this.config,l="function"==typeof r?r:e=>e[r],c="function"==typeof s?s:e=>e[s],u="function"==typeof i?i:e=>e[i],d="function"==typeof a?a:e=>e[a]??1;this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this._boundedEdgeSnapshot=new Map;for(const[,e]of this.edges)e.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,{y0:e.y0,y1:e.y1,sankeyWidth:e.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const t of e){const e=l(t)+"";this.nodes.set(e,{...Wo(e),data:t})}for(let e=0;t.length>e;e++){const n=t[e],o=c(n)+"",r=u(n)+"",s=d(n),i=null==s?NaN:Number(s),a=Number.isFinite(i)?i:1;this.nodes.has(o)||this.nodes.set(o,{...Wo(o),data:n}),this.nodes.has(r)||this.nodes.set(r,{...Wo(r),data:n});const l=`${o}\0${r}\0${e}`,h={source:o,target:r,value:a,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:l};n&&"object"==typeof n&&zo(n.bezier)&&(h.bezier=n.bezier),this.edges.set(l,h)}o?.deferLayout||this.runLayout(n),this.updateResults.recordData("replace",e.length+t.length)}ingestBoundedWithResult(e,t,n,o){return this.ingestBounded(e,t,n,o),this.updateResults.last}applyForceLayoutPositions(e,t){for(const[t,n]of Object.entries(e)){const e=this.nodes.get(t);e&&(e.x=n.x,e.y=n.y)}this.config.__skipForceSimulation=!0;try{this.runLayout(t)}finally{this.config.__skipForceSimulation=void 0}}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:o}=e,r=0===this.nodes.size;let s=!1;const i=this.currentTime();this.lastIngestTime=i,this._decaySortedNodes=null,this._networkDecayCache=null,this.nodes.has(t)||(this.nodes.set(t,Wo(t)),this.nodeTimestamps.set(t,i),this.tension+=this.tensionConfig.newNode,s=!0),this.nodes.has(n)||(this.nodes.set(n,Wo(n)),this.nodeTimestamps.set(n,i),this.tension+=this.tensionConfig.newNode,s=!0);const a=this.edgeKey(t,n),l=this.edges.get(a);let c=!1;l?(l.value+=o,this.edgeTimestamps.set(a,i),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(a,{source:t,target:n,value:o,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,i),this.tension+=this.tensionConfig.newEdge,s=!0);const u=r||s||c||this.tension>=this.tensionConfig.threshold;return this.updateResults.recordData("ingest",1),u}ingestEdgeWithResult(e){return this.ingestEdge(e),this.updateResults.last}runLayout(e){if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const t=J(this.config.chartType);if(!t)return;let n=Array.from(this.nodes.values());const o=Array.from(this.edges.values());if(0===n.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.supportsStreaming&&!t.hierarchical){const e=new Map;for(const t of n)void 0!==t._prevX0?e.set(t.id,{x:(t._prevX0??0)+((t._prevX1??0)-(t._prevX0??0))/2,y:(t._prevY0??0)+((t._prevY1??0)-(t._prevY0??0))/2}):0===t.x&&0===t.y||e.set(t.id,{x:t.x,y:t.y});if(this._lastPositionSnapshot)for(const[t,n]of this._lastPositionSnapshot)e.has(t)||e.set(t,n);this.config.__previousPositions=e.size>0?e:void 0}if(t.computeLayout(n,o,this.config,e),this.config.__previousPositions=void 0,t.hierarchical&&n.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const e of n)this.nodes.set(e.id,e);for(let e=0;o.length>e;e++){const t=o[e],n=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=n,this.edges.set(n,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const n=e.get(t.id);n&&(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,n=Array.from(this.nodes.values())}this.finalizeLayout();const r=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||r.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=r,this.saveTargetPositions();const s=n.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),i=this.config.transition?.duration??this.tensionConfig.transitionDuration,a=["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType);if(!this._hasRenderedOnce&&this.config.introAnimation&&a&&n.length>0&&i>0){const t=e[0]/2,n=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=n,e._prevY1=n;for(const e of this.edges.values())e._prevY0=n,e._prevY1=n,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:i}}else s&&i>0&&(this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:i});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const e=new Set(this.nodes.keys()),t=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of e)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)e.has(t)||this.removedNodes.add(t);for(const e of t)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)t.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime=this.currentTime()),this.previousNodeIds=e,this.previousEdgeKeys=t}restyleScene(e){const t=function({nodes:e,edges:t,restyle:n,restyleEdge:o,baseStyles:r,selection:s}){const i=!(!n&&!o);if(n)for(const t of e){const e=r.get(t)??t.style,o=n(t,s);t.style=o?{...e,...o}:e}if(o)for(const e of t){const t=r.get(e)??e.style,n=o(e,s);e.style=n?{...t,...n}:t}return i}({nodes:this.sceneNodes,edges:this.sceneEdges,restyle:this._customRestyle,restyleEdge:this._customRestyleEdge,baseStyles:this._baseStyles,selection:e});this.markStylePaintPending(),this.updateResults.recordRestyle(t)}buildScene(e){if(this.config.customNetworkLayout){const t=function({config:e,customLayout:t,size:n,nodes:o,edges:r,previousResult:s,revision:i}){const a=Pe(e.colorScheme,e.themeCategorical,$e),l={nodes:o,edges:r,dimensions:{width:n[0],height:n[1],plot:{x:0,y:0,width:n[0],height:n[1]}},theme:{semantic:e.themeSemantic??{},categorical:[...a]},resolveColor:de(a,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};try{return{kind:"success",result:t(l)}}catch(t){const n=null!==s,o=U("network",t,n,i);"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",t);try{e.onLayoutError?.(o)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:o,preservedLastGoodScene:n}}}({config:this.config,customLayout:this.config.customNetworkLayout,size:e,nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values()),previousResult:this.lastCustomLayoutResult,revision:this.layoutVersion});if("failure"===t.kind)return this.lastCustomLayoutFailure=t.diagnostic,void(t.preservedLastGoodScene||(this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._sceneNodesRevision++));const n=t.result;return this.sceneNodes=n.sceneNodes??[],this.sceneEdges=n.sceneEdges??[],this.labels=n.labels??[],this.customLayoutOverlays=n.overlays??null,this.customLayoutHtmlMarks=n.htmlMarks??[],this.lastCustomLayoutResult=n,this.lastCustomLayoutFailure=null,this._sceneNodesRevision++,this._customRestyle=n.restyle,this._customRestyleEdge=n.restyleEdge,this.hasCustomRestyle=!(!n.restyle&&!n.restyleEdge),this.hasCustomRestyle&&(this._baseStyles=function(e,t){const n=new WeakMap;for(const t of e)n.set(t,t.style);for(const e of t)n.set(e,e.style);return n}(this.sceneNodes,this.sceneEdges),this.restyleScene(this.config.layoutSelection??null)),void se({label:"customNetworkLayout",nodes:this.sceneNodes,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned})}this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null;const t=J(this.config.chartType);if(!t)return void this._sceneNodesRevision++;const n=t.hierarchical?Array.from(this.nodes.values()):this.nodesArray,o=t.hierarchical?Array.from(this.edges.values()):this.edgesArray,{sceneNodes:r,sceneEdges:s,labels:i}=t.buildScene(n,o,this.config,e);this.sceneNodes=r,this.sceneEdges=s,this.labels=i,this._sceneNodesRevision++}rebuildNodeQuadtree(){let t=0,n=0;for(const e of this.sceneNodes)"circle"===e.type&&(t++,e.r>n&&(n=e.r));if(this._maxNodeRadius=n,e.QUADTREE_THRESHOLD>=t)return void(this._nodeQuadtree=null);const o=Array(t);let r=0;for(const e of this.sceneNodes)"circle"===e.type&&(o[r++]=e);this._nodeQuadtree=Eo().x(e=>e.cx).y(e=>e.cy).addAll(o)}get nodeQuadtree(){return this._nodeQuadtreeRevision!==this._sceneNodesRevision&&(this.rebuildNodeQuadtree(),this._nodeQuadtreeRevision=this._sceneNodesRevision),this._nodeQuadtree}get maxNodeRadius(){return this._maxNodeRadius}_ensureArrays(){this._arrCacheVersion===this.layoutVersion&&this._nodesArrCache&&this._edgesArrCache||(this._nodesArrCache=Array.from(this.nodes.values()),this._edgesArrCache=Array.from(this.edges.values()),this._arrCacheVersion=this.layoutVersion)}get nodesArray(){return this._ensureArrays(),this._nodesArrCache}get edgesArray(){return this._ensureArrays(),this._edgesArrCache}get isAnimating(){const e=J(this.config.chartType);return!!e?.supportsAnimation&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=J(this.config.chartType);if(!n?.tick)return!1;const o=n.hierarchical?Array.from(this.nodes.values()):this.nodesArray,r=n.hierarchical?Array.from(this.edges.values()):this.edgesArray;return n.tick(o,r,this.config,e,t)}cancelIntroAnimation(){this.transition=null;for(const e of this.nodes.values())e._prevX0=void 0,e._prevX1=void 0,e._prevY0=void 0,e._prevY1=void 0;for(const e of this.edges.values())e._prevY0=void 0,e._prevY1=void 0,e._prevSankeyWidth=void 0,e._introFromZero=!1}advanceTransition(e){if(!this.transition)return!1;const t=pe(e,this.transition),n=fe(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=ke(e._prevX0,e._targetX0,n),e.x1=ke(e._prevX1,e._targetX1,n),e.y0=ke(e._prevY0,e._targetY0,n),e.y1=ke(e._prevY1,e._targetY1,n));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&(e._prevSankeyWidth>0||e._introFromZero)&&(e.y0=ke(e._prevY0,e._targetY0,n),e.y1=ke(e._prevY1,e._targetY1,n),e.sankeyWidth=ke(e._prevSankeyWidth,e._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const n=e?.get(t.id);n&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1):(t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1)}const t=this._boundedEdgeSnapshot;for(const e of this.edges.values()){if(t&&0===e.sankeyWidth){const n=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(n){e._prevY0=n.y0,e._prevY1=n.y1,e._prevSankeyWidth=n.sankeyWidth;continue}}e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth),e._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(e){!function(e,t,n=.5){const o="string"==typeof e.source?t.get(e.source):e.source,r="string"==typeof e.target?t.get(e.target):e.target;!o||!r||(e.bezier=e.circular&&e.circularPathData?function(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(!n)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),o=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-o,y:n.targetY},{x:n.targetX-.66*o,y:n.targetY},{x:n.targetX-.33*o,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let o;o="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const r=[];for(let e=0;o.length-1>e;e++){const t=o[e],n=o[e+1],s=n.x-t.x,i=n.y-t.y;r.push([t,{x:t.x+s/3,y:t.y+i/3},{x:t.x+2*s/3,y:t.y+2*i/3},n])}return{circular:!0,segments:r,halfWidth:t}}(e):function(e,t,n,o=.5){const r=(e.sankeyWidth||1)/2;if("down"===e.direction){const s=t.x1,i=n.x0,a=Lo(s,i);return{circular:!1,points:[{x:e.y0,y:s},{x:e.y0,y:a(o)},{x:e.y1,y:a(1-o)},{x:e.y1,y:i}],halfWidth:r}}const s=t.x1,i=n.x0,a=Lo(s,i);return{circular:!1,points:[{x:s,y:e.y0},{x:a(o),y:e.y0},{x:a(1-o),y:e.y1},{x:i,y:e.y1}],halfWidth:r}}(e,o,r,n))}(e,this.nodes,.5)}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){!function(e){const t=e.pulse;if(!t)return;const n=t.duration??500,o=t.color??"rgba(255,255,255,0.6)",r=t.glowRadius??4,{now:s}=e;for(const t of e.sceneNodes){const i=t.id;if(!i)continue;const a=e.nodeTimestamps.get(i);if(!a)continue;const l=s-a;n>l&&(t._pulseIntensity=1-l/n,t._pulseColor=o,t._pulseGlowRadius=r)}for(const t of e.sceneEdges){const r=t.datum;if(!r)continue;const i="object"==typeof r.source?r.source?.id:r.source,a="object"==typeof r.target?r.target?.id:r.target;if(!i||!a)continue;const l=e.edgeTimestamps.get(`${i}\0${a}`);if(!l)continue;const c=s-l;n>c&&(t._pulseIntensity=1-c/n,t._pulseColor=o)}}({sceneNodes:this.sceneNodes,sceneEdges:this.sceneEdges,nodeTimestamps:this.nodeTimestamps,edgeTimestamps:this.edgeTimestamps,pulse:this.config.pulse,now:e})}applyDecay(){this._networkDecayCache||(this._networkDecayCache={sortedNodes:null,ageMap:null}),this._decaySortedNodes||(this._networkDecayCache.sortedNodes=null,this._networkDecayCache.ageMap=null),function(e){const t=e.decay;if(!t)return;const n=e.nodeTimestamps.size;if(1>=n)return;if(!e.cache.sortedNodes){e.cache.sortedNodes=Array.from(e.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]);const t=new Map;for(let n=0;e.cache.sortedNodes.length>n;n++)t.set(e.cache.sortedNodes[n][0],n);e.cache.ageMap=t}const o=e.cache.ageMap;for(const r of e.sceneNodes){const e=r.id;if(!e)continue;const s=o.get(e);if(void 0===s)continue;const i=q(t,s,n);r.style={...r.style,opacity:(r.style?.opacity??1)*i}}}({sceneNodes:this.sceneNodes,nodeTimestamps:this.nodeTimestamps,decay:this.config.decay,cache:this._networkDecayCache}),this._decaySortedNodes=this._networkDecayCache.sortedNodes,this._decayAgeMap=this._networkDecayCache.ageMap}applyTopologyDiff(e){!function(e){for(const t of e.sceneNodes)t._pulseColor===Oo&&(t._pulseIntensity=0,t._pulseColor=void 0,t._pulseGlowRadius=void 0);if(0===e.addedNodes.size)return;const t=e.now-e.lastTopologyChangeTime;if(t>=Ho)return;const n=1-t/Ho;for(const t of e.sceneNodes){const o=t.id;o&&e.addedNodes.has(o)&&(t._pulseIntensity=Math.max(t._pulseIntensity??0,n),t._pulseColor=Oo,t._pulseGlowRadius=8)}}({sceneNodes:this.sceneNodes,addedNodes:this.addedNodes,lastTopologyChangeTime:this.lastTopologyChangeTime,now:e})}get hasActiveTopologyDiff(){return function(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){return 0!==e.size&&Ho>n-t}(this.addedNodes,this.lastTopologyChangeTime)}applyThresholds(e){!function(e){const t=e.thresholds;if(!t)return;const n=t.warningColor??"#f59e0b",o=t.criticalColor??"#ef4444",r=!1!==t.pulse;for(const s of e.sceneNodes){const i=s.id;if(!i)continue;const a=e.nodes.get(i);if(!a)continue;const l=t.metric(a);let c=null;void 0===t.critical||t.critical>l?void 0===t.warning||t.warning>l||(c=n):c=o,c&&(s.style={...s.style,fill:c},r&&(s._pulseIntensity=.6+.4*Math.sin(e.now/300),s._pulseColor=c,s._pulseGlowRadius=6))}}({sceneNodes:this.sceneNodes,nodes:this.nodes,thresholds:this.config.thresholds,now:e})}get hasActiveThresholds(){return function(e,t){if(!t)return!1;for(const n of e){const e=t.metric(n);if(void 0!==t.warning&&e>=t.warning||void 0!==t.critical&&e>=t.critical)return!0}return!1}(this.nodes.values(),this.config.thresholds)}get hasActivePulses(){return function(e){const t=e.pulse;if(!t||0===e.lastIngestTime)return!1;const n=e.now??("undefined"!=typeof performance?performance.now():Date.now());return(t.duration??500)>n-e.lastIngestTime}({pulse:this.config.pulse,lastIngestTime:this.lastIngestTime})}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){const n=this.nodes.get(e);if(!n)return this.updateResults.recordNoop("update"),null;const o=n.data?{...n.data}:{};return n.data=t(n.data??{}),this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",1),o}updateEdge(e,t,n){const o=this.config.valueAccessor,r="function"==typeof o?o:o?e=>e[o]:e=>e.value,s=[];for(const[,o]of this.edges)if(("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t){s.push(o.data?{...o.data}:{}),o.data=n(o.data??{});const e=r(o.data);null!=e&&(o.value=Number(e))}return s.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",s.length)):this.updateResults.recordNoop("update"),s}removeNode(e){if(!this.nodes.has(e))return this.updateResults.recordNoop("remove"),!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==e&&("string"==typeof n.target?n.target:n.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",1),!0}removeEdge(e,t){const n=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const o="function"==typeof t?t:e=>e?.[t];for(const[t,r]of this.edges)r.data&&o(r.data)===e&&n.push(t)}else for(const[o,r]of this.edges)("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t&&n.push(o);for(const e of n)this.edges.delete(e),this.edgeTimestamps.delete(e);return n.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",n.length)):this.updateResults.recordNoop("remove"),n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this._decayAgeMap=null,this._nodeQuadtree=null,this._nodesArrCache=null,this._edgesArrCache=null,this._sceneNodesRevision++,this.tension=0,this.layoutVersion++,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.particlePool&&this.particlePool.clear(),this.updateResults.recordData("clear")}};Zo.QUADTREE_THRESHOLD=500;var er=Zo;V(er);import*as tr from"react";import{Fragment as nr,jsx as or,jsxs as rr}from"react/jsx-runtime";function sr(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:s,labels:i,title:a,legend:l,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h,legendPosition:f="right",legendLayout:p,foregroundGraphics:y,sceneNodes:g,annotations:m,onAnnotationActivate:v,onObservation:x,chartId:b,chartType:k,autoPlaceAnnotations:w,svgAnnotationRules:S}=e,_=Y({onAnnotationActivate:v,onObservation:x,chartId:b,chartType:k}),C=tr.useMemo(()=>{const e=(g||[]).flatMap(e=>{const t=function(e){if("glyph"===e.type&&e.glyph&&"number"==typeof e.size){const t=e.cx??e.x,n=e.cy??e.y;if("number"!=typeof t||"number"!=typeof n)return null;const o=Fe(e.glyph,e.size);return{x:t+o.centerDx,y:n+o.centerDy,r:Math.max(1,o.radius)}}const t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),n=e.cy??(null!=e.y&&null!=e.h?e.y+e.h/2:e.y);return"number"!=typeof t||"number"!=typeof n?null:{x:t,y:n,r:"number"==typeof e.r?Math.max(1,e.r):"number"==typeof e.outerR?Math.max(1,e.outerR):"number"==typeof e.size?Math.max(1,Xe(e.size)):Math.max(1,e.w??0,e.h??0)/2}}(e),n=function(e){const t=e.id??e.datum?.id??e.datum?.data?.id??e.datum?.data?.name;return null==t?void 0:t+""}(e);return t?[{pointId:n,...t}]:[]});return{scales:null,width:t,height:n,frameType:"network",pointNodes:e,sceneNodes:g}},[n,g,t]),R=tr.useMemo(()=>m&&w?Le({annotations:m,context:C,..."object"==typeof w?w:{}}):m,[m,w,C]),M=tr.useMemo(()=>A("network"),[]),N=R?T(R.filter(e=>"widget"!==e.type),M,S,C):null,I=!0===R?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return rr(nr,{children:[I&&or("style",{children:le},"annotation-widget-disclosure-style"),rr("svg",{role:"img",width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[or("title",{children:"string"==typeof a?a:"Network Chart"}),or("desc",{children:"string"==typeof a?a+" (network data visualization)":"Network data visualization"}),rr("g",{transform:`translate(${s.left},${s.top})`,children:[i.map((e,t)=>or("text",{x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"},children:e.text},"label-"+t)),N,y]}),a&&"string"==typeof a?or("text",{x:o/2,y:ue,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:a}):a?or("foreignObject",{x:0,y:0,width:o,height:s.top,children:a}):null,P({legend:l,totalWidth:o,totalHeight:r,margin:s,legendPosition:f,title:a,legendLayout:p,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})]}),R?.filter(e=>"widget"===e.type&&e.nodeId&&g).map((e,t)=>{const n=!0===e._annotationDeferred,o=g.find(t=>t.id===e.nodeId||t.datum?.id===e.nodeId||t.datum?.data?.id===e.nodeId||t.datum?.data?.name===e.nodeId);if(!o)return null;const r=s.left+(o.cx??(null!=o.x&&null!=o.w?o.x+o.w/2:o.x??0)),i=s.top+(o.cy??(null!=o.y&&null!=o.h?o.y+o.h/2:o.y??0)),a=e.dx??0,l=e.dy??-16,c=e.width??32,u=e.height??32,d=e.content??or("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return or("div",{...L(e,_),className:n?"annotation-deferred":void 0,"data-annotation-disclosure":n?"deferred":void 0,style:{position:"absolute",left:r+a-c/2,top:i+l-u/2,width:c,height:u,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:d},"widget-"+t)})]})}sr.displayName="NetworkSVGOverlay";import*as ir from"react";import{jsx as ar}from"react/jsx-runtime";var lr={position:"absolute",top:0,left:0,pointerEvents:"none"};function cr({marks:e,margin:t,selection:n=null,overscan:o=400}){const s=ir.useRef(null),i=function(e,t,n){const[o,r]=ir.useState(null);return ir.useLayoutEffect(()=>{const e=t.current,n=function(e){let t=e?.parentElement??null;for(;t;){const{overflow:e,overflowX:n,overflowY:o}=window.getComputedStyle(t);if(/(auto|scroll|overlay)/.test(`${e} ${o} ${n}`))return t;t=t.parentElement}return null}(e);if(!e||!n)return void r(null);let o=0;const s=()=>{o=0;const t=n.getBoundingClientRect(),s=e.getBoundingClientRect();r(0!==t.width&&0!==t.height?{scroll:{left:t.left,top:t.top,right:t.right,bottom:t.bottom},originX:s.left,originY:s.top}:null)},i=()=>{0===o&&(o=window.requestAnimationFrame(s))};s(),n.addEventListener("scroll",i,{passive:!0});const a=new ResizeObserver(i);return a.observe(n),()=>{0!==o&&window.cancelAnimationFrame(o),n.removeEventListener("scroll",i),a.disconnect()}},[t,e,n]),ir.useMemo(()=>{if(!e||!o)return e;const{scroll:t,originX:r,originY:s}=o,i=t.left-n,a=t.right+n,l=t.top-n,c=t.bottom+n;return e.filter(e=>{const t=r+e.x,n=s+e.y;return!(i>t+e.width||t>a||l>n+e.height||n>c)})},[e,o,n])}(e,s,o);if(!e||0===e.length)return null;const a=ar("div",{className:"semiotic-network-html-marks",ref:s,style:{...lr,transform:`translate(${t.left}px, ${t.top}px)`},children:(i??e).map(e=>ar("div",{className:"semiotic-network-html-mark","data-mark-id":e.id,style:{position:"absolute",transform:`translate(${e.x}px, ${e.y}px)`,width:e.width,height:e.height,pointerEvents:"none"},children:e.content},e.id))});return null!=n?ar(r,{value:n,children:a}):a}import{jsx as ur,jsxs as dr}from"react/jsx-runtime";function hr({props:e,store:t,responsiveRef:n,size:o,margin:r,adjustedWidth:s,adjustedHeight:i,resolvedBackground:a,resolvedForeground:l}){const{chartType:u,nodes:d,edges:h,data:f,className:p,description:y,title:g,responsiveWidth:v,responsiveHeight:x,summary:b,background:k,renderMode:w,legend:A,legendPosition:S,legendLayout:_,legendHoverBehavior:T,legendClickBehavior:C,legendHighlightedCategory:P,legendIsolatedCategories:R,layoutSelection:M,annotations:N,onAnnotationActivate:I,annotationObservationCallback:D,onObservation:E,chartId:W,autoPlaceAnnotations:z,svgAnnotationRules:B}=e;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(u),n=e?f||(Array.isArray(h)?void 0:h):void 0;if(e&&n)t.ingestHierarchy(n,[s,i]),t.buildScene([s,i]);else{const e=me(d),n=Array.isArray(h)?me(h):[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[s,i]),t.buildScene([s,i]))}}const L=t?.sceneNodes??[],O=t?.sceneEdges??[],H=t?.labels??[];return dr("div",{ref:n,className:"stream-network-frame"+(p?" "+p:""),role:"img","aria-label":y||("string"==typeof g?g:"Network chart"),style:{position:"relative",width:v?"100%":o[0],height:x?"100%":o[1]},children:[ur(m,{summary:b}),dr("svg",{xmlns:"http://www.w3.org/2000/svg",width:o[0],height:o[1],style:{position:"absolute",left:0,top:0},children:[a&&ur("g",{transform:`translate(${r.left},${r.top})`,children:a}),dr("g",{transform:`translate(${r.left},${r.top})`,children:[k&&ur("rect",{x:0,y:0,width:s,height:i,fill:k}),O.map((e,t)=>te({node:e,index:t,renderMode:w,fallback:()=>Ae(e,t)})).filter(Boolean),L.map((e,t)=>te({node:e,index:t,renderMode:w,fallback:()=>Se(e,t)})).filter(Boolean),H.map((e,t)=>we(e,t)).filter(Boolean)]})]}),ur(sr,{width:s,height:i,totalWidth:o[0],totalHeight:o[1],margin:r,labels:H,sceneNodes:L,title:g,legend:A,legendPosition:S,legendLayout:_,legendHoverBehavior:T,legendClickBehavior:C,legendHighlightedCategory:P,legendIsolatedCategories:R,foregroundGraphics:ft(l,c(t?.customLayoutOverlays,M??null)),annotations:N,onAnnotationActivate:I,onObservation:D??E,chartId:W,chartType:"StreamNetworkFrame",autoPlaceAnnotations:z,svgAnnotationRules:B,annotationFrame:0}),ur(cr,{marks:t?.customLayoutHtmlMarks,margin:r,selection:M??null})]})}import{jsx as fr,jsxs as pr}from"react/jsx-runtime";var yr=/^(value|amount|total|count|weight|score)$/i;function gr({data:e}){if("edge"===e.nodeOrEdge){const t=e.data;return t?pr("div",{className:"semiotic-tooltip",style:H,children:[pr("div",{style:{fontWeight:600},children:["object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target]}),null!=t.value&&pr("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]})]}):null}const t=e.data;if(!t)return null;const n=t.__hierarchyNode;if(n){const e=[];let o=n;for(;o;){const n=o.data?.name??o.data?.id??t.id;null!=n&&e.unshift(n+""),o=o.parent}e.length>1&&e.shift();const r=e.length-1;return pr("div",{className:"semiotic-tooltip",style:H,children:[fr("div",{children:e.map((e,t)=>pr("span",{children:[t>0&&fr("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),t===r?fr("strong",{children:e}):fr("span",{style:{opacity:.7},children:e})]},t))}),null!=t.value&&t.value>0&&fr("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof t.value?t.value.toLocaleString():t.value+""})]})}const o=(t.sourceLinks?.length||0)+(t.targetLinks?.length||0),r=(t.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(t.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0),s=$(t.data??t),i=null!=s.title?s.title+"":t.id,a=s.entries.some(e=>yr.test(e.key));return pr("div",{className:"semiotic-tooltip",style:H,children:[fr("div",{style:{fontWeight:600},children:i}),s.entries.map(e=>{return pr("div",{style:{marginTop:4,opacity:.8},children:[e.key,": ",(t=e.value,null==t?"–":"number"==typeof t?Math.abs(t)>9999?t.toLocaleString():t+"":t instanceof Date?t.toLocaleDateString():t+"")]},e.key);var t}),!a&&null!=t.value&&t.value>0&&pr("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]}),o>0&&pr("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",o,r!==o&&` (weighted: ${r.toLocaleString()})`]})]})}function mr(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function vr(e,t){if(!t.pathD)return;e.save();const n=mr(t);if(t.style.fill&&"none"!==t.style.fill){const o=t._gradient;if(o){const n=e.createLinearGradient(o.x0,0,o.x1,0),r=t.style.fillOpacity??t.style.opacity??.5,s="string"==typeof t.style.fill?t.style.fill:"#999",i=qe(e,s)||s;n.addColorStop(0,1===o.from?i:"transparent"),n.addColorStop(1,1===o.to?i:"transparent"),e.fillStyle=n,e.globalAlpha=r}else e.fillStyle=M(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5;e.fill(n)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.5*(t.style.opacity??1),e.stroke(n)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(n)),e.restore()}function xr(e,t){e.save();const n=t.style.stroke||"#999";e.strokeStyle=qe(e,n)||n,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(t.style.strokeWidth??1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function br(e,t){if(!t.pathD)return;e.save();const n=mr(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=M(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5,e.fill(n)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.3*(t.style.opacity??1),e.stroke(n)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(n)),e.restore()}function kr(e,t){if(!t.pathD)return;e.save();const n=mr(t),o=t.style.stroke||"#999";e.strokeStyle=qe(e,o)||o,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(n),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=M(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??.1,e.fill(n)),e.restore()}gr.ownsChrome=!0;var wr=new Map;function Ar(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=wr.get(t);return n||(n=new Path2D(Ye(e.symbolType,e.size)),wr.size>256&&wr.clear(),wr.set(t,n)),n}catch{return null}}function Sr(e){const{sceneNodes:t,nodes:n,nodeColorMap:o,colorScheme:r}=e;for(const e of t)e.id&&"string"==typeof e.style?.fill&&o.set(e.id,e.style.fill);const s=Array.isArray(r)?r:ce,i=Array.from(n);for(let e=0;i.length>e;e++){const t=i[e];o.has(t.id)||o.set(t.id,s[e%s.length])}return i.length}function _r(n,r,s,i=30){switch(n.type){case"circle":return function(t,n,o,r=30){const s=n-t.cx,i=o-t.cy,a=Math.sqrt(s*s+i*i);return a>e(t.r,r)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:a}}(n,r,s,i);case"rect":return function(e,n,o){const r=t(n,o,e);return r.hit?{type:"node",datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}(n,r,s);case"arc":return function(e,t,n){const r=t-e.cx,s=n-e.cy,i=Math.sqrt(r*r+s*s);if(e.innerR-2>i||i>e.outerR+2)return null;const a=o(Math.atan2(s,r)),l=o(e.startAngle),c=o(e.endAngle);if(l>c?a>=l||c>=a:a>=l&&c>=a){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(n,r,s);case"symbol":return function(t,n,o,r=30){const s=n-t.cx,i=o-t.cy,a=Math.sqrt(s*s+i*i);return a>e(Xe(t.size),r)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:a}}(n,r,s,i);case"glyph":return function(t,n,o,r=30){if(null==t.datum)return null;const s=Fe(t.glyph,t.size),i=t.cx+s.centerDx,a=t.cy+s.centerDy,l=n-i,c=o-a,u=Math.sqrt(l*l+c*c);return u>e(s.radius,r)?null:{type:"node",datum:t.datum,x:i,y:a,distance:u}}(n,r,s,i);default:return null}}var Tr=null,Cr=null;function Pr(){return Cr||((Tr=document.createElement("canvas")).width=1,Tr.height=1,Cr=Tr.getContext("2d")),Cr}function Rr(e){if(e._cachedPath2D&&e._cachedPath2DSource===e.pathD)return e._cachedPath2D;try{return e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD,e._cachedPath2D}catch{return null}}function Mr(e,t,n){switch(e.type){case"bezier":return function(e,t,n){if(!e.pathD)return null;const o=Rr(e),r=Pr();if(!o||!r)return null;try{if(r.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const s=r.lineWidth;r.lineWidth=10;const i=r.isPointInStroke(o,t,n);if(r.lineWidth=s,i)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);case"line":return function(e,t,n){const o=e.x2-e.x1,r=e.y2-e.y1,s=o*o+r*r;if(0===s)return null;let i=((t-e.x1)*o+(n-e.y1)*r)/s;i=Math.max(0,Math.min(1,i));const a=e.x1+i*o,l=e.y1+i*r,c=Math.sqrt((t-a)**2+(n-l)**2);return c>5?null:{type:"edge",datum:e.datum,x:a,y:l,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;const o=Rr(e),r=Pr();if(!o||!r)return null;try{if(r.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const s=r.lineWidth;r.lineWidth=10;const i=r.isPointInStroke(o,t,n);if(r.lineWidth=s,i)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);default:return null}}function Nr(e){const{clientX:t,clientY:n,canvasRect:o,margin:r,adjustedWidth:s,adjustedHeight:i,sceneNodes:a,sceneEdges:l,nodeQuadtree:c,maxNodeRadius:u,hitRadius:d=30}=e,h=t-o.left-r.left,f=n-o.top-r.top;if(0>h||h>s||0>f||f>i)return{kind:"miss-outside"};const p=function(e,t,n,o,r=30,s,i=0){let a=null,l=r,c=1/0;if(s){const e=vt(s,n,o,r,i,e=>e.cx,e=>e.cy,e=>e.r);e&&(a={type:"node",datum:e.node.datum,x:e.node.cx,y:e.node.cy,distance:e.distance},l=e.distance)}for(const t of e){if(s&&"circle"===t.type)continue;const e=_r(t,n,o,r);if(e)if("rect"===t.type){const n=t.w*t.h;c>n&&(a=e,c=n)}else l>e.distance&&(a=e,l=e.distance)}if(a)return a;for(const e of t){if(!1===e.interactive)continue;const t=Mr(e,n,o);t&&l>t.distance&&(a=t,l=t.distance)}return a}(a,l,h,f,d,c,u);return p?{kind:"hit",hover:O(p.datum||{},p.x,p.y,{nodeOrEdge:p.type})}:{kind:"miss"}}import{useCallback as Ir}from"react";var Dr="StreamNetworkFrame";import{jsx as Er,jsxs as Wr}from"react/jsx-runtime";var zr={top:20,right:80,bottom:20,left:80},Br={top:40,right:40,bottom:40,left:40},Lr=new Set(["chord","force","circlepack","orbit"]),Or=[800,600],Hr=Po(Co(function(e,t){const{chartType:n,nodes:o,edges:r,data:u,initialEdges:x,nodeIDAccessor:b="id",sourceAccessor:k="source",targetAccessor:A="target",valueAccessor:T="value",edgeIdAccessor:C,childrenAccessor:P,hierarchySum:N,orientation:L="horizontal",nodeAlign:H="justify",nodePaddingRatio:F=.05,nodeWidth:$=15,iterations:Y=300,forceStrength:X=.1,layoutExecution:V="auto",layoutLoadingContent:G,onLayoutStateChange:q,padAngle:U=.01,groupWidth:Q=20,sortGroups:K,edgeSort:J,treeOrientation:Z="vertical",edgeType:te="curve",padding:ne,paddingTop:oe,tensionConfig:re,showParticles:se=!1,particleStyle:ie,renderMode:ae,nodeStyle:le,edgeStyle:ue,colorBy:de,colorScheme:he="category10",edgeColorBy:fe="source",edgeOpacity:pe=.5,colorByDepth:ve=!1,nodeSize:ke=8,nodeSizeRange:we=[5,20],nodeLabel:Ae,showLabels:Se=!0,labelMode:_e,size:Te=Or,responsiveWidth:Pe,responsiveHeight:Re,margin:Me,className:Ne,background:Ie,enableHover:De=!0,tooltipContent:Ee,customHoverBehavior:We,customClickBehavior:ze,onObservation:Be,annotationObservationCallback:Le,chartId:Oe,onTopologyChange:He,annotations:je,onAnnotationActivate:$e,autoPlaceAnnotations:Ye,svgAnnotationRules:Xe,legend:Ve,legendPosition:Ge,legendLayout:Qe,legendHoverBehavior:Ke,legendClickBehavior:Je,legendHighlightedCategory:Ze,legendIsolatedCategories:et,title:tt,foregroundGraphics:nt,backgroundGraphics:ot,decay:rt,pulse:st,transition:it,animate:at,staleness:lt,frameScheduler:ct,clock:ut,random:dt,seed:ht,paused:pt=!1,suspendWhenHidden:yt=!0,thresholds:vt,accessibleTable:xt=!0,description:bt,summary:kt,orbitMode:wt,orbitSize:At,orbitSpeed:St,orbitRevolution:_t,orbitRevolutionStyle:Tt,orbitEccentricity:Ct,orbitShowRings:Pt,orbitAnimated:Rt,customNetworkLayout:Mt,onLayoutError:Nt,layoutConfig:It,layoutSelection:Dt}=e,Et=Lr.has(n)?Br:zr,Wt=ko(!0),zt=D({sizeProp:Te,responsiveWidth:Pe,responsiveHeight:Re,userMargin:Me,marginDefault:Et,title:tt,legend:Ve,legendPosition:Ge,foregroundGraphics:nt,backgroundGraphics:ot,animate:at,transitionProp:it,frameScheduler:ct,clock:ut,random:dt,seed:ht,paused:pt,suspendWhenHidden:yt,themeDirtyRef:Wt}),{reducedMotionRef:Bt,responsiveRef:Lt,size:Ht,margin:jt,adjustedWidth:$t,adjustedHeight:Yt,resolvedForeground:Xt,resolvedBackground:Vt,transition:Gt,introEnabled:qt,tableId:Ut,rafRef:Qt,renderFnRef:Kt,scheduleRender:Jt,frameRuntime:Zt,currentTheme:en}=zt,tn=W(),nn=B(),on=So(()=>me(o),[o]),rn=So(()=>Array.isArray(r)?me(r):r,[r]),sn=So(()=>({...Ro,...re}),[re]),an=So(()=>({...Mo,...ie}),[ie]),ln=So(()=>{return{chartType:(e={chartType:n,clock:Zt.now,random:dt,seed:ht,nodeIDAccessor:b,sourceAccessor:k,targetAccessor:A,valueAccessor:T,edgeIdAccessor:C,childrenAccessor:P,hierarchySum:N,orientation:L,nodeAlign:H,nodePaddingRatio:F,nodeWidth:$,iterations:Y,forceStrength:X,padAngle:U,groupWidth:Q,sortGroups:K,edgeSort:J,treeOrientation:Z,edgeType:te,padding:ne,paddingTop:oe,tensionConfig:sn,showParticles:se,particleStyle:an,nodeStyle:le,edgeStyle:ue,nodeLabel:Ae,showLabels:Se,labelMode:_e,colorBy:de,colorScheme:he,edgeColorBy:fe,edgeOpacity:pe,colorByDepth:ve,nodeSize:ke,nodeSizeRange:we,decay:rt,pulse:st,transition:Gt,introAnimation:qt,staleness:lt,thresholds:vt,orbitMode:wt,orbitSize:At,orbitSpeed:St,orbitRevolution:_t,orbitRevolutionStyle:Tt,orbitEccentricity:Ct,orbitShowRings:Pt,orbitAnimated:Rt,customNetworkLayout:Mt,onLayoutError:Nt,layoutConfig:It,currentTheme:en}).chartType,clock:e.clock,random:e.random,seed:e.seed,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,edgeIdAccessor:e.edgeIdAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,tensionConfig:e.tensionConfig,showParticles:e.showParticles,particleStyle:e.particleStyle,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,labelMode:e.labelMode,colorBy:e.colorBy,colorScheme:e.colorScheme,themeCategorical:e.currentTheme?.colors?.categorical,themeSemantic:Ue(e.currentTheme),edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,decay:e.decay,pulse:e.pulse,transition:e.transition,introAnimation:e.introAnimation,staleness:e.staleness,thresholds:e.thresholds,orbitMode:e.orbitMode,orbitSize:e.orbitSize,orbitSpeed:e.orbitSpeed,orbitRevolution:e.orbitRevolution,orbitRevolutionStyle:e.orbitRevolutionStyle,orbitEccentricity:e.orbitEccentricity,orbitShowRings:e.orbitShowRings,orbitAnimated:e.orbitAnimated,customNetworkLayout:e.customNetworkLayout,onLayoutError:e.onLayoutError,layoutConfig:e.layoutConfig};var e},[n,Zt.now,dt,ht,b,k,A,T,C,P,N,L,H,F,$,Y,X,U,Q,K,J,Z,te,ne,oe,sn,se,an,le,ue,Ae,Se,_e,de,he,fe,pe,ve,ke,we,rt,st,Gt,qt,lt,vt,wt,At,St,_t,Tt,Ct,Pt,Rt,Mt,Nt,It,en]),cn=dn(ln),un=dn({chartType:(hn={chartType:n,nodeIDAccessor:b,sourceAccessor:k,targetAccessor:A,valueAccessor:T,edgeIdAccessor:C,childrenAccessor:P,hierarchySum:N,orientation:L,nodeAlign:H,nodePaddingRatio:F,nodeWidth:$,iterations:Y,forceStrength:X,padAngle:U,groupWidth:Q,sortGroups:K,edgeSort:J,treeOrientation:Z,edgeType:te,padding:ne,paddingTop:oe,random:dt,seed:ht,tensionConfig:sn,customNetworkLayout:Mt,orbitMode:wt,orbitSize:At,orbitEccentricity:Ct}).chartType,nodeIDAccessor:hn.nodeIDAccessor,sourceAccessor:hn.sourceAccessor,targetAccessor:hn.targetAccessor,valueAccessor:hn.valueAccessor,edgeIdAccessor:hn.edgeIdAccessor,childrenAccessor:hn.childrenAccessor,hierarchySum:hn.hierarchySum,orientation:hn.orientation,nodeAlign:hn.nodeAlign,nodePaddingRatio:hn.nodePaddingRatio,nodeWidth:hn.nodeWidth,iterations:hn.iterations,forceStrength:hn.forceStrength,padAngle:hn.padAngle,groupWidth:hn.groupWidth,sortGroups:hn.sortGroups,edgeSort:hn.edgeSort,treeOrientation:hn.treeOrientation,edgeType:hn.edgeType,padding:hn.padding,paddingTop:hn.paddingTop,random:hn.random,seed:hn.seed,tensionConfig:hn.tensionConfig,customNetworkLayout:hn.customNetworkLayout,orbitMode:hn.orbitMode,orbitSize:hn.orbitSize,orbitEccentricity:hn.orbitEccentricity});var hn;const fn=ko(0),pn=ko(0),gn=ko(!1),mn=ko(null);mn.current||(mn.current=new er(cn));const vn=z("StreamNetworkFrame"),xn=_o((e,t,n=!1)=>I(vn.current,e,()=>e.buildScene(t),n),[vn]),[bn,kn]=wo(null),[wn,An]=wo(0),[Sn,_n]=wo(0),[Tn,Cn]=wo(!1),[Pn,Rn]=wo(!1),Mn=ko(0),Dn=ko(null),En=ko(!1),Wn=ko(q);Wn.current=q;const zn=ko(cn);zn.current=cn;const Bn=ko(null),Ln=ko(new Map),On=ko(0),Hn=_o(e=>function(e){const{node:t,colorBy:n,colorScheme:o,nodeColorMap:r,colorIndexRef:s}=e;if("function"==typeof n)return n(t)+"";if("string"==typeof n&&t.data){const e=t.data[n];if(void 0!==e){if(!r.has(e+"")){const t=Array.isArray(o)?o:ce;r.set(e+"",t[s.current++%t.length])}return r.get(e+"")}}if(r.has(t.id))return r.get(t.id);const i=Array.isArray(o)?o:ce,a=n?i[s.current++%i.length]:i[0];return r.set(t.id,a),a}({node:e,colorBy:de,colorScheme:he,nodeColorMap:Ln.current,colorIndexRef:On}),[de,he]),Fn=($n=en,$n?.colors?.border||$n?.colors?.secondary||$n?.colors?.primary||"#999");var $n;const Yn=_o(e=>function(e,t){return e?"object"==typeof e?e:t?.get(e)??null:null}(e,mn.current?.nodes),[]),Xn=_o(e=>function(e){const{edge:t,edgeColorBy:n,getNodeColor:o,resolveEndpoint:r,fallback:s}=e;if("function"==typeof n)return n(t);const i=r(t.source),a=r(t.target);return"target"===n&&a?o(a):i?o(i):s}({edge:e,edgeColorBy:fe,getNodeColor:Hn,resolveEndpoint:Yn,fallback:Fn}),[fe,Hn,Fn,Yn]),Vn=_o(e=>function(e){const{edge:t,particleStyleColor:n,particleColorBy:o,hasExplicitParticleColorBy:r,getEdgeColor:s,getNodeColor:i,resolveEndpoint:a,fallback:l}=e;if("function"==typeof n){const e=a(t.source);return e?n(t,e):l}if(!r)return s(t);const c=o,u=a(t.source),d=a(t.target);return"target"===c&&d?i(d):u?i(u):l}({edge:e,particleStyleColor:an.color,particleColorBy:an.colorBy,hasExplicitParticleColorBy:!!ie?.colorBy,getEdgeColor:Xn,getNodeColor:Hn,resolveEndpoint:Yn,fallback:Fn}),[ie?.colorBy,an.color,an.colorBy,Hn,Xn,Fn,Yn]),Gn=function(e,t,n,o,r){return("sankey"===e||t)&&n||o||r}(n,!!Mt,se,!!st,mn.current?.isAnimating??!1);gt(mn,cn,Wt,Jt),mt(mn,Dt,Wt,Jt),Ao(()=>{const e=mn.current;e&&(xn(e,[$t,Yt]),On.current=Sr({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Ln.current,colorScheme:he}),Wt.current=!0,Jt())},[en,$t,Yt,xn,Jt,he]);const qn=_o(()=>{const e=mn.current;if(e&&(e.runLayout([$t,Yt]),xn(e,[$t,Yt]),Wt.current=!0,On.current=Sr({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Ln.current,colorScheme:he}),An(e.layoutVersion),He)){const{nodes:t,edges:n}=e.getLayoutData();He(t,n)}},[$t,Yt,xn,He,he]),Un=_o(e=>{if(null==e||"object"!=typeof e)return;const t=mn.current;t&&(t.ingestEdge(e)&&qn(),Jt())},[qn,Jt]),Qn=_o(e=>{const t=mn.current;if(!t)return;let n=!1;for(const o of e)null!=o&&"object"==typeof o&&t.ingestEdge(o)&&(n=!0);n&&qn(),Jt()},[qn,Jt]),Kn=_o(()=>{mn.current?.clear(),Ln.current.clear(),On.current=0,An(mn.current?.layoutVersion??0),kn(null),Bn.current=null,Wt.current=!0,Jt()},[Jt]),Jn=_o(()=>{const e=mn.current;e&&(e.tension+=999,qn(),Jt())},[qn,Jt]);To(t,()=>({push:Un,pushMany:Qn,removeNode:e=>{const t=mn.current?.removeNode(e)??!1;if(t){const t=Bn.current?.data?"function"==typeof b?b(Bn.current.data):Bn.current.data[b]:void 0;Bn.current&&"node"===Bn.current.nodeOrEdge&&t===e&&(Bn.current=null,kn(null)),Ln.current.delete(e),qn(),Wt.current=!0,Jt()}return t},removeEdge:(e,t)=>{const n=mn.current?.removeEdge(e,t)??!1;if(n){if(Bn.current&&"edge"===Bn.current.nodeOrEdge){const n=Bn.current.data;let o;o=void 0!==t?("object"==typeof n?.source?n.source.id:n?.source)===e&&("object"==typeof n?.target?n.target.id:n?.target)===t:!C||!n||("function"==typeof C?C:e=>e?.[C])(n)===e,o&&(Bn.current=null,kn(null))}qn(),Wt.current=!0,Jt()}return n},updateNode:(e,t)=>{const n=mn.current?.updateNode(e,t)??null;return n&&(Wt.current=!0,Jt()),n},updateEdge:(e,t,n)=>{const o=mn.current?.updateEdge(e,t,n)??[];return o.length>0&&(qn(),Wt.current=!0,Jt()),o},clear:Kn,getTopology:()=>mn.current?.getLayoutData()??{nodes:[],edges:[]},getCustomLayout:()=>mn.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>mn.current?.lastCustomLayoutFailure??null,getTopologyDiff:()=>{const e=mn.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:Jn,getTension:()=>mn.current?.tension??0}),[Un,Qn,Kn,Jn,b,qn,Jt,C]);const Zn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(n),eo=Zn?u||(Array.isArray(r)?void 0:r):void 0;Ao(()=>{const e=mn.current;if(!e)return;const t=++Mn.current;if(Dn.current?.abort(),Dn.current=null,Zn&&eo)e.ingestHierarchy(eo,[$t,Yt]),xn(e,[$t,Yt]),Rn(!1),Wn.current?.("ready"),Wt.current=!0,Jt();else{const c=on,u=Array.isArray(rn)?rn:[];if(0===c.length&&0===u.length)return null==o&&null==r||0>=e.nodes.size&&0>=e.edges.size||Kn(),Rn(!1),void Wn.current?.("ready");const d=[$t,Yt],h="force"===n&&!Mt&&s()&&!dt&&l(V,c.length,u.length,Y);if(h&&nn&&!En.current&&e.sceneNodes.length>0)return En.current=!0,Rn(!1),Wn.current?.("ready"),Wt.current=!0,void Jt();if(h){const n=new AbortController;Dn.current=n;const o=e._lastPositionSnapshot;e.ingestBounded(c,u,d,{deferLayout:!0});const r=e.getLayoutData(),s=i(r.nodes,r.edges,zn.current,d,o);return Rn(!0),Wn.current?.("pending"),a(s,n.signal).then(({positions:n})=>{t===Mn.current&&(e.applyForceLayoutPositions(n,d),xn(e,d),On.current=Sr({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Ln.current,colorScheme:he}),Rn(!1),Wn.current?.("ready"),An(e.layoutVersion),Wt.current=!0,Jt())}).catch(n=>{"AbortError"!==n.name&&t===Mn.current&&(e.runLayout(d),xn(e,d),On.current=Sr({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Ln.current,colorScheme:he}),Rn(!1),Wn.current?.("error"),An(e.layoutVersion),Wt.current=!0,Jt())}),()=>n.abort()}e.ingestBounded(c,u,d),xn(e,d),Rn(!1),Wn.current?.("ready"),On.current=Sr({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Ln.current,colorScheme:he}),Wt.current=!0,Jt()}},[on,rn,o,r,u,eo,Zn,$t,Yt,un,V,Y,nn,n,Mt,dt,Jt,Kn,he,xn]),Ao(()=>{x&&x.length>0&&Qn(x)},[x,Qn]);const{customHoverBehavior:to,customClickBehavior:no}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:o}){return{customHoverBehavior:Ir((t,r)=>{e?.(t,r),ge({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:Dr,chartId:o,context:r})},[e,n,o]),customClickBehavior:Ir((e,r)=>{t?.(e,r),ye({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:Dr,chartId:o,context:r})},[t,n,o])}}({customHoverBehavior:We,customClickBehavior:ze,onObservation:Be,chartId:Oe}),{hoverHandlerRef:oo,hoverLeaveRef:ro,onPointerMove:so,onPointerLeave:io}=zt,uo=()=>!Mt||(mn.current?.hasCustomRestyle??!1);oo.current=e=>{if(!De)return;const t=uo(),n=bo.current;if(!n)return;const o=mn.current;if(!o)return;const r=Nr({clientX:e.clientX,clientY:e.clientY,canvasRect:n.getBoundingClientRect(),margin:jt,adjustedWidth:$t,adjustedHeight:Yt,sceneNodes:o.sceneNodes,sceneEdges:o.sceneEdges,nodeQuadtree:o.nodeQuadtree,maxNodeRadius:o.maxNodeRadius});"hit"===r.kind?(Bn.current=r.hover,kn(r.hover),to&&(to(r.hover),t&&(Wt.current=!0)),t&&Jt()):Bn.current&&(Bn.current=null,kn(null),to&&(to(null),t&&(Wt.current=!0)),t&&Jt())},ro.current=()=>{if(Bn.current){const e=uo();Bn.current=null,kn(null),to&&(to(null),e&&(Wt.current=!0)),e&&Jt()}};const ho=ko(()=>{});ho.current=e=>{if(j(e.target))return;if(!ze&&!Be)return;const t=bo.current;if(!t)return;const n=mn.current;if(!n)return;const o=Nr({clientX:e.clientX,clientY:e.clientY,canvasRect:t.getBoundingClientRect(),margin:jt,adjustedWidth:$t,adjustedHeight:Yt,sceneNodes:n.sceneNodes,sceneEdges:n.sceneEdges,nodeQuadtree:n.nodeQuadtree,maxNodeRadius:n.maxNodeRadius});"hit"===o.kind?no(o.hover,{type:"activate",inputType:Ce(e.nativeEvent.pointerType)}):"miss"===o.kind&&no(null)};const po=_o(e=>ho.current(e),[]),yo=ko(-1),go=ko(null),mo=ko(-1),vo=_o(e=>{if(xe(e))return;const t=mn.current;if(!t)return;const n=()=>{yo.current=-1,go.current=null,mo.current=-1,Bn.current=null,kn(null),to&&(to(null),Wt.current=!0),Jt()},o=function(e){const t=[];for(const n of e)if("circle"===n.type&&null!=n.cx){if(0>=n.r)continue;t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("rect"===n.type&&null!=n.x){if(0>=n.w||0>=n.h)continue;t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.datum?.id??"_default"})}else if("arc"===n.type&&null!=n.cx)t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"});else if("symbol"===n.type&&null!=n.cx){if(0>=n.size)continue;t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("glyph"===n.type&&null!=n.cx){if(0>=n.size||null==n.datum)continue;const e=Fe(n.glyph,n.size);t.push({x:n.cx+e.centerDx,y:n.cy+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:n.datum?.id??"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.sceneNodes);if(0===o.length)return void(0>yo.current||n());const r=ao(o);let s=yo.current;if(r.flat.length>s||(n(),s=-1)," "===e.key&&s>=0){e.preventDefault();const t=r.flat[s];return void no(O(t.datum||{},t.x,t.y,{nodeOrEdge:"node"}),{type:"activate",inputType:"keyboard"})}if(0>s){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),yo.current=0,mo.current=-1;const t=r.flat[0];go.current={shape:t.shape,w:t.w,h:t.h};const n=O(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Bn.current=n,kn(n),to&&(to(n,{type:"focus",inputType:"keyboard"}),Wt.current=!0),void Jt()}const i=lo(r,s),a=function(e,t,n,o,r){const s=n.flat[t.flatIndex];if(!s)return co(e,t,n);const i=s.datum?.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const o=function(e,t,n){let o=null,r=1/0;for(let s=0;e.flat.length>s;s++){const i=e.flat[s];if(i===t)continue;const a=i.x-t.x,l=i.y-t.y;let c=!1;switch(n){case"right":c=a>0&&Math.abs(a)>=Math.abs(l);break;case"left":c=0>a&&Math.abs(a)>=Math.abs(l);break;case"down":c=l>0&&Math.abs(l)>=Math.abs(a);break;case"up":c=0>l&&Math.abs(l)>=Math.abs(a)}if(!c)continue;const u=a*a+l*l;r>u&&(r=u,o=s)}return o}(n,s,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up")??t.flatIndex;return o!==t.flatIndex&&(r.current=-1),o}case"Enter":{if(null==i)return t.flatIndex;const e=function(e,t){const n=e+"",o=[];for(const e of t){const t=e.datum??e,r=fo(t.source),s=fo(t.target),i=null!=r,a=null!=s;i&&r+""===n&&a?o.push(s+""):a&&s+""===n&&i&&o.push(r+"")}return o}(i,o);if(0===e.length)return t.flatIndex;const s=n.idToIdx.get(e[(r.current+1)%e.length])??-1;return 0>s?t.flatIndex:(r.current=-1,s)}default:{const o=co(e,t,n);return null!==o&&o!==t.flatIndex&&(r.current=-1),o}}}(e.key,i,r,t.sceneEdges??[],mo);if(null===a)return;if(e.preventDefault(),0>a)return void n();yo.current=a;const l=r.flat[a];go.current={shape:l.shape,w:l.w,h:l.h};const c={data:l.datum||{},x:l.x,y:l.y,__semioticHoverData:!0,nodeOrEdge:"node"};Bn.current=c,kn(c),to&&(to(c,{type:"focus",inputType:"keyboard"}),Wt.current=!0),Jt()},[no,to,Jt]),xo=_o(e=>{yo.current=-1,go.current=null,so(e)},[so]);Kt.current=()=>{if(Qt.current=null,!Zt.isActive)return;const e=bo.current;if(!e)return;const t=mn.current;t&&function(e){const{canvas:t,store:n,sceneRevisionDiagnostics:o,size:r,margin:s,adjustedWidth:i,adjustedHeight:a,background:l,renderMode:c,hasBackgroundGraphics:u=!1,dirtyRef:d,lastFrameTimeRef:h,now:f,random:p,reducedMotion:y,showParticles:g,isContinuous:m,animate:v,decay:x,pulse:b,thresholds:k,staleness:A,particleStyle:T,getParticleColor:C,pendingAnnotationFrameRef:P,lastAnnotationFrameTimeRef:R,setAnnotationFrame:N,scheduleNextFrame:I}=e,D=t.getContext("2d");if(!D)return;const E=h.current?Math.min((f-h.current)/1e3,.1):.016;h.current=f;const W=n.advanceTransition(y?f+1e6:f),z=!y&&W,B=!y&&n.tickAnimation([i,a],E),L=d.current,O=o?.beforeCompute(n.getLastUpdateResult(),z),H=W||L||B;H&&n.buildScene([i,a]),O&&o?.afterCompute(O,H,!1);const F=g&&!y&&!!n.particlePool,j=!!(($={dirtyOrRebuilt:L,transitioning:z,animationTicked:B,continuous:F||m,liveEncoding:!!x||!!b||!!k||!1!==v&&n.hasActiveTopologyDiff||n.hasActivePulses||n.hasActiveThresholds,forced:n.consumeStylePaintPending()}).dirtyOrRebuilt||$.transitioning||$.animationTicked||$.continuous||$.liveEncoding||$.forced);var $;const Y=!!A&&n.lastIngestTime>0&&f-n.lastIngestTime>(A?.threshold??5e3);if(j){const e=S();if(!_(t,r,s,e))return;if(D.clearRect(-s.left,-s.top,r[0],r[1]),yn(D,{background:l,hasBackgroundGraphics:u,width:i,height:a}),x&&n.applyDecay(),b&&n.applyPulse(f),k&&n.applyThresholds(f),!1!==v&&n.applyTopologyDiff(f),Y&&(D.globalAlpha=A?.dimOpacity??.5),ee({context:D,nodes:n.sceneEdges,renderMode:c,pixelRatio:e,paintBuiltIn:e=>function(e,t){for(const n of t)switch(n.type){case"bezier":vr(e,n);break;case"line":xr(e,n);break;case"ribbon":br(e,n);break;case"curved":kr(e,n)}}(D,e)}),ee({context:D,nodes:n.sceneNodes,renderMode:c,pixelRatio:e,paintBuiltIn:e=>{const t=e;!function(e,t){for(const n of t){if("rect"!==n.type)continue;const t=n;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=M(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.strokeRect(t.x,t.y,t.w,t.h)),Nn(e,t),e.restore())}}(D,t),function(e,t){for(const n of t){if("circle"!==n.type)continue;const t=n;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=M(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),In(e,t),e.restore())}}(D,t),function(e,t){for(const n of t){if("arc"!==n.type)continue;const t=n;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=M(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),e.restore()}}(D,t),function(e,t){const n=e.globalAlpha;for(const o of t){if("symbol"!==o.type)continue;const t=o;if(0>=t.size)continue;const r=Ar(t);if(!r)continue;e.save(),e.translate(t.cx,t.cy),t.rotation&&e.rotate(t.rotation);const s=t.style.opacity??1;t.style.fill&&(e.globalAlpha=n*s*(t.style.fillOpacity??1),e.fillStyle=M(e,t.style.fill,"#007bff"),e.fill(r)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*s,e.strokeStyle=qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.stroke(r)),e.restore()}}(D,t),function(e,t){const n=e.globalAlpha;for(const o of t)"glyph"===o.type&&jn(e,o,o.cx,o.cy,n);e.globalAlpha=n}(D,t)}}),F&&!Y){const e=n.edgesArray;if(e.length>0){!function(e,t,n,o,r=Math.random){const s=o.spawnRate??.1,i=o.maxPerEdge??50;for(let o=0;t.length>o;o++){const a=t[o];if(!a.bezier)continue;if(e.countForEdge(o)>=i)continue;const l=a.value*s*n*(a.bezier.circular?.3:1),c=Math.floor(l),u=l-c;let d=c;r()<u&&d++;for(let t=0;d>t&&e.countForEdge(o)<i;t++)e.spawn(o,r)}}(n.particlePool,e,E,T,p);const t=.5*(T.speedMultiplier??1);let o;if(T.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);o=e.map(e=>.3+(e.value||1)/t*1.7)}n.particlePool.step(E,t,e,o),function(e,t,n,o,r){const s=o.radius??3;e.globalAlpha=o.opacity??.7;for(let i=0;t.particles.length>i;i++){const a=t.particles[i];if(!a.active)continue;const l=n[a.edgeIndex];if(!l)continue;let c;c="string"==typeof o.color&&"inherit"!==o.color?o.color:r(l),e.fillStyle=qe(e,c)||c,e.beginPath(),e.arc(a.x,a.y,s,0,2*Math.PI),e.fill()}e.globalAlpha=1}(D,n.particlePool,e,T,C)}}Y&&(D.globalAlpha=1)}d.current=!1,(L||z||B)&&t.setAttribute("aria-label",w(n.sceneNodes?.length??0,n.sceneEdges?.length??0,"Network chart"));const X=L||z||B||P.current;X&&f-R.current>=33?(N(e=>e+1),R.current=f,P.current=!1):P.current=!!X,(m||z||null!=n.transition||B||n.hasActivePulses||n.hasActiveThresholds||!1!==v&&n.hasActiveTopologyDiff||P.current)&&I()}({canvas:e,store:t,sceneRevisionDiagnostics:vn.current,size:Ht,margin:jt,adjustedWidth:$t,adjustedHeight:Yt,background:Ie,renderMode:ae,hasBackgroundGraphics:!!ot,dirtyRef:Wt,lastFrameTimeRef:fn,now:Zt.now(),random:Zt.random,reducedMotion:!!Bt.current,showParticles:se,isContinuous:Gn,animate:at,decay:rt,pulse:st,thresholds:vt,staleness:lt,particleStyle:an,getParticleColor:Vn,pendingAnnotationFrameRef:gn,lastAnnotationFrameTimeRef:pn,setAnnotationFrame:_n,scheduleNextFrame:()=>{Jt()}})};const{canvasRef:bo}=E(zt,{hydrated:tn,wasHydratingFromSSR:nn,storeRef:mn,dirtyRef:Wt,canvasPaintDependencies:[n,$t,Yt,Ie,ot,ae,Jt]});Ot(lt,mn,Wt,Jt,Tn,Cn);const Co=De&&bn?Er(f,{x:bn.x,y:bn.y,containerWidth:$t,containerHeight:Yt,margin:jt,className:"stream-network-tooltip",zIndex:2,children:Ee?Ee(bn):Er(gr,{data:bn})}):null;if(be||!tn&&nn)return Er(hr,{props:e,store:mn.current,responsiveRef:Lt,size:Ht,margin:jt,adjustedWidth:$t,adjustedHeight:Yt,resolvedBackground:Vt,resolvedForeground:Xt});const Po=mn.current;return Wr("div",{ref:Lt,className:"stream-network-frame"+(Ne?" "+Ne:""),role:"group","aria-label":bt||("string"==typeof tt?tt:"Network chart"),tabIndex:0,"aria-busy":Pn||void 0,style:{position:"relative",width:Pe?"100%":Ht[0],height:Re?"100%":Ht[1],overflow:"visible"},onKeyDown:vo,children:["production"!==process.env.NODE_ENV&&mn.current&&Er(g,{store:mn.current,diagnostics:vn.current}),xt&&Er(v,{tableId:Ut}),xt&&Er(y,{nodes:Po?.sceneNodes??[],edges:Po?.sceneEdges??[],chartType:"Network chart",tableId:Ut,chartTitle:"string"==typeof tt?tt:void 0}),Er(m,{summary:kt}),Er(d,{hoverPoint:bn}),Wr("div",{role:"img","aria-label":bt||("string"==typeof tt?tt:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:De?xo:void 0,onMouseLeave:De?io:void 0,onClick:ze||Be?po:void 0,children:[Pn&&!1!==G&&Er("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:R(!0,Ht[0],Ht[1],G)}),Er(h,{size:Ht,margin:jt,overflowVisible:!0,children:Vt}),Er("canvas",{ref:bo,"aria-label":w(Po?.sceneNodes?.length??0,Po?.sceneEdges?.length??0,"Network chart"),style:{position:"absolute",top:0,left:0}}),Er(sr,{width:$t,height:Yt,totalWidth:Ht[0],totalHeight:Ht[1],margin:jt,labels:Po?.labels||[],sceneNodes:Po?.sceneNodes,title:tt,legend:Ve,legendPosition:Ge,legendLayout:Qe,legendHoverBehavior:Ke,legendClickBehavior:Je,legendHighlightedCategory:Ze,legendIsolatedCategories:et,foregroundGraphics:ft(Xt,c(mn.current?.customLayoutOverlays,Dt??null)),annotations:je,onAnnotationActivate:$e,onObservation:Le??Be,chartId:Oe,chartType:"StreamNetworkFrame",autoPlaceAnnotations:Ye,svgAnnotationRules:Xe,annotationFrame:Sn}),Er(cr,{marks:Po?.customLayoutHtmlMarks,margin:jt,selection:Dt??null}),Er(p,{active:yo.current>=0,hoverPoint:bn,margin:jt,size:Ht,shape:go.current?.shape,width:go.current?.w,height:go.current?.h}),Co,lt?.showBadge&&Er(Ft,{isStale:Tn,position:lt.badgePosition})]})]})}));Hr.displayName="StreamNetworkFrame";var Fr=Hr,jr=class e{constructor(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}push(e){if(!Number.isFinite(e))return;this._count+=1;const t=e-this._mean;this._mean+=t/this._count,this._m2+=t*(e-this._mean),this._min>e&&(this._min=e),e>this._max&&(this._max=e)}merge(e){if(0===e._count)return;if(0===this._count)return this._count=e._count,this._mean=e._mean,this._m2=e._m2,this._min=e._min,void(this._max=e._max);const t=this._count+e._count,n=e._mean-this._mean;this._mean+=n*e._count/t,this._m2+=e._m2+n*n*this._count*e._count/t,this._count=t,this._min>e._min&&(this._min=e._min),e._max>this._max&&(this._max=e._max)}clear(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}clone(){const t=new e;return t._count=this._count,t._mean=this._mean,t._m2=this._m2,t._min=this._min,t._max=this._max,t}get count(){return this._count}get mean(){return 0===this._count?0:this._mean}get sum(){return 0===this._count?0:this._mean*this._count}get variance(){return 2>this._count?0:this._m2/this._count}get stddev(){return Math.sqrt(this.variance)}get sampleVariance(){return 2>this._count?0:this._m2/(this._count-1)}get sampleStddev(){return Math.sqrt(this.sampleVariance)}get min(){return this._min}get max(){return this._max}},$r=class{constructor(e){this.windows=new Map,this.sessions=[],this.latest=-1/0,this.type=e.window??"tumbling",this.size=e.size;const t=e.hop??e.size;this.hop=t>0&&e.size>=t?t:e.size,this.gap=e.gap??e.size,this.retain=null!=e.retain&&e.retain>0?e.retain:1/0}push(e,t){Number.isFinite(e)&&Number.isFinite(t)&&(e>this.latest&&(this.latest=e),"session"===this.type?this.pushSession(e,t):this.pushFixed(e,t),this.prune())}pushFixed(e,t){if("tumbling"===this.type||this.hop>=this.size)return void this.bump(Math.floor(e/this.size)*this.size,t);const n=this.hop,o=Math.floor(e/n);for(let r=Math.floor((e-this.size)/n)+1;o>=r;r++)this.bump(r*n,t)}bump(e,t){let n=this.windows.get(e);n||(n=new jr,this.windows.set(e,n)),n.push(t)}pushSession(e,t){const n=this.gap,o=new jr;o.push(t);let r=e,s=e;const i=[],a={start:r,end:s,stats:o};for(const t of this.sessions)e-n>t.end||t.start>e+n?i.push(t):(a.stats.merge(t.stats),r>t.start&&(r=t.start),t.end>s&&(s=t.end));a.start=r,a.end=s,i.push(a),i.sort((e,t)=>e.start-t.start),this.sessions=i}prune(){if(this.retain===1/0)return;if("session"===this.type)return void(this.sessions.length>this.retain&&(this.sessions=this.sessions.slice(this.sessions.length-this.retain)));if(this.retain>=this.windows.size)return;const e=[...this.windows.keys()].sort((e,t)=>e-t),t=e.length-this.retain;for(let n=0;t>n;n++)this.windows.delete(e[n])}emit(){return"session"===this.type?this.emitSessions():this.emitFixed()}emitFixed(){const e=[];for(const[t,n]of this.windows){const o=t+this.size;e.push(this.row(t,o,n,o>this.latest))}return e.sort((e,t)=>e.start-t.start),e}emitSessions(){return this.sessions.map(e=>this.row(e.start,e.end,e.stats,this.gap>this.latest-e.end))}row(e,t,n,o){return{start:e,end:t,count:n.count,mean:n.mean,sum:n.sum,min:n.min,max:n.max,stddev:n.stddev,partial:o}}get windowCount(){return"session"===this.type?this.sessions.length:this.windows.size}get watermark(){return this.latest}clear(){this.windows.clear(),this.sessions=[],this.latest=-1/0}};function Yr(e,t){switch(t){case"sum":return e.sum;case"min":return e.min;case"max":return e.max;case"count":return e.count;default:return e.mean}}function Xr(e,t,n,o=1){if("none"===t)return null;if("minmax"===t)return[e.min,e.max];const r=Yr(e,n),s=e.stddev*o;return[r-s,r+s]}var Vr={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},Gr=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g;function qr(e){if("number"==typeof e)return Number.isFinite(e)&&e>0?e:null;if("string"!=typeof e)return null;const t=e.trim();if(""===t)return null;Gr.lastIndex=0;let n,o=0,r=0;for(;null!==(n=Gr.exec(t));){const e=parseFloat(n[1]),t=Vr[n[2]];if(null==t||!Number.isFinite(e))return null;o+=e*t,r+=n[0].length}return r!==t.length?null:o>0?o:null}var Ur=class{constructor(e){this.held=[],this._watermark=-1/0,this._lateCount=0,this.lateness=e.lateness>0?e.lateness:0,this.getTime=e.getTime,this.latePolicy=e.latePolicy??"drop"}push(e){const t=this.getTime(e);if(!Number.isFinite(t))return{released:[e],late:[]};const n=[];return this._watermark!==-1/0&&this._watermark-this.lateness>t?(this._lateCount+=1,n.push(e),"drop"===this.latePolicy?{released:[],late:n}:{released:[e],late:n}):(t>this._watermark&&(this._watermark=t),this.held.push(e),{released:this.drain(),late:n})}drain(){const e=this._watermark-this.lateness;if(0===this.held.length)return[];const t=[],n=[];for(const o of this.held)this.getTime(o)>e?n.push(o):t.push(o);return this.held=n,t.sort((e,t)=>this.getTime(e)-this.getTime(t)),t}flush(){const e=this.held;return this.held=[],e.sort((e,t)=>this.getTime(e)-this.getTime(t)),e}clear(){this.held=[],this._watermark=-1/0,this._lateCount=0}get watermark(){return this._watermark}get lateCount(){return this._lateCount}get heldCount(){return this.held.length}};import{useRef as Qr,useImperativeHandle as Kr,forwardRef as Jr,useCallback as Zr,useState as es,useEffect as ts}from"react";import{jsx as ns,jsxs as os}from"react/jsx-runtime";var rs={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, #f3f4f6)",padding:"6px 10px",borderRadius:"var(--semiotic-tooltip-radius, 4px)",fontSize:"var(--semiotic-tooltip-font-size, 12px)",fontFamily:"var(--semiotic-tick-font-family, var(--semiotic-font-family, sans-serif))",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.25))",lineHeight:1.4,pointerEvents:"none",whiteSpace:"nowrap"},ss={opacity:.7,marginRight:4};function is(e,t,n){if(null!=e)return"function"==typeof t?t(e):e["string"==typeof t?t:n]}function as(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function ls(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:o="x",yLabel:r="y"}=e;return e=>{const s=e?.data??null,i=is(s,t,"time"),a=is(s,n,"value");return os("div",{className:"semiotic-tooltip",style:rs,children:[os("div",{children:[os("span",{style:ss,children:[o,":"]}),as(i)]}),os("div",{children:[os("span",{style:ss,children:[r,":"]}),as(a)]})]})}}function cs(e,t){return null!=e?e:Math.max(t?.length??0,200)}var us="time",ds="value",hs="__aggLower",fs="__aggUpper",ps="__aggPartial",ys="count",gs="__aggStart",ms="__aggEnd";function vs(e,t){const n=t.stat??"mean",o=t.band??"none",r=t.sigma??1;return e.emit().map(e=>{const t={[us]:(e.start+e.end)/2,[ds]:Yr(e,n),[ys]:e.count,[ps]:e.partial,[gs]:e.start,[ms]:e.end},s=Xr(e,o,n,r);return s&&(t[hs]=s[0],t[fs]=s[1]),t})}function xs(e){const{linkedHover:t,selection:n,onObservation:o,onClick:r,hoverRadius:s,hoverHighlight:i,forceHoverBehavior:a,forceClickBehavior:l,mobileInteraction:c,customHoverBehavior:u,customClickBehavior:d,linkedHoverInClickPredicate:h=!0}=e,f={};o&&(f.annotationObservationCallback=o);const p=c?.enabled?Math.max(s??30,Math.ceil((c.targetSize||44)/2),24):s;return(a||t||o||r||i)&&(f.customHoverBehavior=u),d&&(l||(h?o||r||t:o||r)||c?.enabled&&(c.tapToSelect||c.tapToLockTooltip)&&(t||i||n))&&(f.customClickBehavior=d),null!=p&&(f.hoverRadius=p),f}import{jsx as bs}from"react/jsx-runtime";function ks(e,t,n){const o="function"==typeof t?t(e):e[t??n];if(null==o)return null;if(o instanceof Date)return o.getTime();const r=Number(o);return Number.isFinite(r)?r:null}var ws=Jr(function(e,t){const n=Ne(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:o,margin:r,className:s,arrowOfTime:i="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:d,timeExtent:h,valueExtent:f,extentPadding:p,stroke:y="#007bff",strokeWidth:g=2,strokeDasharray:m,opacity:v,background:x,tooltipContent:b,tooltip:k,onHover:w,annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:T,tickFormatValue:P,decay:M,pulse:N,staleness:I,transition:D,linkedHover:E,selection:W,onObservation:z,chartId:B,loading:L,loadingContent:O,emptyContent:H,emphasis:F,legendPosition:j,aggregate:$,eventTime:Y}=e,X=n.showAxes,V=n.enableHover,G=r??n.marginDefaults,q=o??[n.width,n.height],U=b??k??ls({timeAccessor:u,valueAccessor:d}),Q=Qr(null),{customHoverBehavior:K}=Ie({selection:W,linkedHover:E,unwrapData:!0,onObservation:z,chartType:"RealtimeLineChart",chartId:B}),J=Zr(e=>{w&&w(e),K(e)},[w,K]),Z=null!=$,[ee,te]=es([]),ne=Qr(null),oe=Qr($);oe.current=$;const re=Qr(Z);re.current=Z;const se=Qr(ee);se.current=ee;const ie=Qr({timeAccessor:u,valueAccessor:d});ie.current={timeAccessor:u,valueAccessor:d},ts(()=>{if(!Z)return void(ne.current=null);const e=oe.current,t=function(e){const t=e.window??"tumbling",n=qr("session"===t?e.gap??e.size:e.size);if(null==n)return null;const o=null!=e.hop?qr(e.hop):void 0,r=null!=e.gap?qr(e.gap):void 0;return new $r({window:t,size:n,hop:o??void 0,gap:r??void 0,retain:e.retain})}(e);if(ne.current=t,t&&c){const{timeAccessor:e,valueAccessor:n}=ie.current;for(const o of c){const r=ks(o,e,"time"),s=ks(o,n,"value");null!=r&&null!=s&&t.push(r,s)}}te(t?vs(t,e):[])},[Z?[$.window??"tumbling",$.size,$.hop??"",$.gap??"",$.retain??""].join("|"):"",Z,c]),ts(()=>{Z&&ne.current&&te(vs(ne.current,oe.current))},[$?.stat,$?.band,$?.sigma]);const ae=Zr(e=>{const t=ne.current,n=oe.current;if(!t||!n)return;const{timeAccessor:o,valueAccessor:r}=ie.current;for(const n of e){const e=ks(n,o,"time"),s=ks(n,r,"value");null!=e&&null!=s&&t.push(e,s)}te(vs(t,n))},[]),le=null!=Y,ce=Qr(null),ue=Qr(Y);ue.current=Y;const de=Qr(le);de.current=le;const he=Qr(z);he.current=z;const fe=Qr(B);fe.current=B,ts(()=>{ce.current=le?function(e){const t=qr(e.lateness);return null==t?null:new Ur({lateness:t,getTime:e=>ks(e,ie.current.timeAccessor,"time")??NaN,latePolicy:e.latePolicy??"drop"})}(ue.current):null},[le?`${Y.lateness}|${Y.latePolicy??"drop"}`:"",le]);const pe=Zr(e=>{0!==e.length&&(re.current?ae(e):Q.current?.pushMany(e))},[ae]),ye=Zr(e=>{const t=ce.current;if(!de.current||!t)return void pe(e);const n=[];for(const o of e){const e=t.push(o);if(e.released.length&&n.push(...e.released),e.late.length){const n=he.current;if(n){const{timeAccessor:o}=ie.current,r=ue.current?.latePolicy??"drop";for(const s of e.late)n({type:"late-data",datum:s,eventTime:ks(s,o,"time")??NaN,watermark:t.watermark,policy:r,lateCount:t.lateCount,timestamp:Date.now(),chartType:"RealtimeLineChart",chartId:fe.current})}}}pe(n)},[pe]);Kr(t,()=>({push:e=>ye([e]),pushMany:e=>ye(e),remove:e=>re.current?[]:Q.current?.remove(e)??[],update:(e,t)=>re.current?[]:Q.current?.update(e,t)??[],clear:()=>{ce.current?.clear(),re.current?(ne.current?.clear(),te([])):Q.current?.clear()},getData:()=>re.current?se.current:Q.current?.getData()??[],getScales:()=>Q.current?.getScales()??null}),[ye]);const ge=R(L,q[0],q[1],O),me=ge?null:C(Z?void 0:c,q[0],q[1],H),ve={stroke:y,strokeWidth:g,strokeDasharray:m};null!=v&&(ve.opacity=v);const xe=cs(l,c),be=Z?ee:c,ke=Z?us:u,we=Z?ds:d,Ae=Z&&$&&"none"!==($.band??"none")?{y0Accessor:hs,y1Accessor:fs,perSeries:!1}:void 0;return ge||me||bs(bo,{ref:Q,chartType:"line",runtimeMode:"streaming",size:q,margin:G,className:F?`${s||""} semiotic-emphasis-${F}`.trim():s,arrowOfTime:i,windowMode:Z?"growing":a,windowSize:Z?Math.max(1,$?.retain??Math.max(ee.length,600)):xe,data:be,timeAccessor:ke,valueAccessor:we,xExtent:h,yExtent:f,extentPadding:p,band:Ae,lineStyle:ve,showAxes:X,background:x,hoverAnnotation:V,tooltipContent:U,...xs({linkedHover:E,selection:W,onObservation:z,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:J}),annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:T,tickFormatValue:P,decay:M,pulse:N,staleness:I,transition:D,pointIdAccessor:e.pointIdAccessor,legendPosition:j})});ws.displayName="RealtimeLineChart";import{useRef as As,useImperativeHandle as Ss,forwardRef as _s,useCallback as Ts,useMemo as Cs}from"react";import{jsx as Ps}from"react/jsx-runtime";function Rs(e,t,n){const o="function"==typeof t?t(e):e[t??n];if(null==o)return null;if(o instanceof Date)return o.getTime();if("string"==typeof o&&""===o.trim())return null;const r=Number(o);return Number.isFinite(r)?r:null}var Ms=_s(function(e,t){const n=Ne(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,showAxes:e.showAxes,enableHover:null!=e.enableHover?!!e.enableHover:void 0,linkedHover:e.linkedHover,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{binSize:o,size:r,margin:s,className:i,arrowOfTime:a="right",windowMode:l="sliding",windowSize:c,data:u,timeAccessor:d,valueAccessor:h,direction:f="up",timeExtent:p,valueExtent:y,extentPadding:g,categoryAccessor:m,colors:v,fill:x,stroke:b,strokeWidth:k,opacity:w,gap:A,background:S,tooltipContent:_,tooltip:T,onHover:P,annotations:M,autoPlaceAnnotations:N,svgAnnotationRules:I,tickFormatTime:D,tickFormatValue:E,linkedHover:W,selection:z,decay:B,pulse:L,staleness:O,transition:H,onObservation:F,chartId:j,loading:$,loadingContent:Y,emptyContent:X,emphasis:V,legendPosition:G,brush:q,onBrush:U,linkedBrush:Q}=e,K=n.showAxes,J=n.enableHover,Z=s??n.marginDefaults,ee=r??[n.width,n.height],te=_??T??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const o=e?.data??null;if(null==o?.binStart||null==o?.binEnd){const e=is(o,t,"time"),r=is(o,n,"value");return os("div",{className:"semiotic-tooltip",style:rs,children:[os("div",{children:[ns("span",{style:ss,children:"x:"}),as(e)]}),os("div",{children:[ns("span",{style:ss,children:"y:"}),as(r)]})]})}return os("div",{className:"semiotic-tooltip",style:rs,children:[os("div",{children:[ns("span",{style:ss,children:"range:"}),as(o.binStart),"–",as(o.binEnd)]}),null!=o.total&&os("div",{children:[ns("span",{style:ss,children:"count:"}),as(o.total)]}),null!=o.category&&os("div",{children:[ns("span",{style:ss,children:"category:"}),as(o.category)]})]})}}({timeAccessor:d,valueAccessor:h}),ne=As(null),{customHoverBehavior:oe}=Ie({selection:z,linkedHover:W,unwrapData:!0,onObservation:F,chartType:"RealtimeHistogram",chartId:j}),re=Ts(e=>{P&&P(e),oe(e)},[P,oe]),se=!0===q?{dimension:"x",snap:"bin"}:"x"===q?{dimension:"x"}:"object"==typeof q?q:void 0,ie=_e(Q),ae="string"==typeof d?d:"time",le=Me({name:ie?.name||"__unused_hist_brush__",xField:ie?.xField||ae,...ie?.yField?{yField:ie.yField}:{}}),ce=As(le.brushInteraction);ce.current=le.brushInteraction;const ue=Ts(e=>{if(U&&U(e),F&&F(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:j}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:j}),ie){const t=ce.current;t.end(e?"xBrush"===t.brush?e.x:"yBrush"===t.brush?e.y:[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:null)}},[U,F,j,ie]);Ss(t,()=>({push:e=>ne.current?.push(e),pushMany:e=>ne.current?.pushMany(e),remove:e=>ne.current?.remove(e)??[],update:(e,t)=>ne.current?.update(e,t)??[],clear:()=>ne.current?.clear(),getData:()=>ne.current?.getData()??[],getScales:()=>ne.current?.getScales()??null}),[]);const de=R($,ee[0],ee[1],Y),he=de?null:C(u,ee[0],ee[1],X),fe={};null!=x&&(fe.fill=x),null!=b&&(fe.stroke=b),null!=k&&(fe.strokeWidth=k),null!=w&&(fe.opacity=w),null!=A&&(fe.gap=A);const pe=V?`${i||""} semiotic-emphasis-${V}`.trim():i,ye=cs(c,u),ge=Cs(()=>"down"!==f?y:function({data:e,valueAccessor:t,timeAccessor:n,binSize:o,valueExtent:r,extentPadding:s}){if(r)return[r[1],r[0]];if(!e||0===e.length)return;const i=new Map;for(const r of e){const e=Rs(r,n,"time"),s=Rs(r,t,"value");if(null==e||null==s)continue;const a=Math.floor(e/o)*o;i.set(a,(i.get(a)??0)+s)}let a=0;for(const e of i.values())e>a&&(a=e);return[a>0?a+a*(s??.1):1,0]}({data:u,valueAccessor:h,timeAccessor:d,binSize:o,valueExtent:y,extentPadding:g}),[f,u,h,d,o,y,g]);return de||he||Ps(bo,{ref:ne,chartType:"bar",runtimeMode:"streaming",size:ee,margin:Z,className:pe,arrowOfTime:a,windowMode:l,windowSize:ye,data:u,timeAccessor:d,valueAccessor:h,xExtent:p,yExtent:ge,extentPadding:g,binSize:o,categoryAccessor:m,barColors:v,barStyle:fe,showAxes:K,background:S,hoverAnnotation:J,tooltipContent:te,...xs({linkedHover:W,selection:z,onObservation:F,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:re}),annotations:M,autoPlaceAnnotations:N,svgAnnotationRules:I,tickFormatTime:D,tickFormatValue:E,decay:B,pulse:L,staleness:O,transition:H,pointIdAccessor:e.pointIdAccessor,legendPosition:G,brush:se||(Q?{dimension:"x"}:void 0),onBrush:se||Q?ue:void 0})});function Ns(e){return Ps(Ms,{...e,windowMode:"growing"})}Ms.displayName="RealtimeHistogram",Ns.displayName="TemporalHistogram";import{useRef as Is,useImperativeHandle as Ds,forwardRef as Es,useCallback as Ws}from"react";import{jsx as zs}from"react/jsx-runtime";var Bs=Es(function(e,t){const n=Ne(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:o,margin:r,className:s,arrowOfTime:i="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:d,timeExtent:h,valueExtent:f,yScaleType:p,extentPadding:y,categoryAccessor:g,colors:m,radius:v,fill:x,opacity:b,stroke:k,strokeWidth:w,pointStyle:A,background:S,tooltipContent:_,tooltip:T,onHover:P,annotations:M,autoPlaceAnnotations:N,svgAnnotationRules:I,tickFormatTime:D,tickFormatValue:E,linkedHover:W,selection:z,onObservation:B,chartId:L,loading:O,loadingContent:H,emptyContent:F,emphasis:j,legendPosition:$}=e,Y=n.showAxes,X=n.enableHover,V=r??n.marginDefaults,G=o??[n.width,n.height],q=_??T??ls({timeAccessor:u,valueAccessor:d}),U=Is(null),{customHoverBehavior:Q}=Ie({selection:z,linkedHover:W,unwrapData:!0,onObservation:B,chartType:"RealtimeSwarmChart",chartId:L}),K=Ws(e=>{P&&P(e),Q(e)},[P,Q]);Ds(t,()=>({push:e=>U.current?.push(e),pushMany:e=>U.current?.pushMany(e),remove:e=>U.current?.remove(e)??[],update:(e,t)=>U.current?.update(e,t)??[],clear:()=>U.current?.clear(),getData:()=>U.current?.getData()??[],getScales:()=>U.current?.getScales()??null}),[]);const J=R(O,G[0],G[1],H),Z=J?null:C(c,G[0],G[1],F),ee={};null!=v&&(ee.radius=v),null!=x&&(ee.fill=x),null!=b&&(ee.opacity=b),null!=k&&(ee.stroke=k),null!=w&&(ee.strokeWidth=w);const te=A,ne=j?`${s||""} semiotic-emphasis-${j}`.trim():s,oe=cs(l,c);return J||Z||zs(bo,{ref:U,chartType:"swarm",runtimeMode:"streaming",size:G,margin:V,className:ne,arrowOfTime:i,windowMode:a,windowSize:oe,data:c,timeAccessor:u,valueAccessor:d,xExtent:h,yExtent:f,yScaleType:p,extentPadding:y,categoryAccessor:g,barColors:m,swarmStyle:ee,pointStyle:te,showAxes:Y,background:S,hoverAnnotation:X,tooltipContent:q,...xs({linkedHover:W,selection:z,onObservation:B,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:K}),annotations:M,autoPlaceAnnotations:N,svgAnnotationRules:I,tickFormatTime:D,tickFormatValue:E,legendPosition:$,pointIdAccessor:e.pointIdAccessor})});Bs.displayName="RealtimeSwarmChart";import{useRef as Ls,useImperativeHandle as Os,forwardRef as Hs,useCallback as Fs}from"react";import{jsx as js}from"react/jsx-runtime";var $s=Hs(function(e,t){const n=Ne(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:o,margin:r,className:s,arrowOfTime:i="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:d,timeExtent:h,valueExtent:f,extentPadding:p,positiveColor:y,negativeColor:g,connectorStroke:m,connectorWidth:v,gap:x,stroke:b,strokeWidth:k,opacity:w,background:A,tooltipContent:S,tooltip:_,onHover:T,annotations:P,autoPlaceAnnotations:M,svgAnnotationRules:N,tickFormatTime:I,tickFormatValue:D,linkedHover:E,selection:W,onObservation:z,chartId:B,loading:L,loadingContent:O,emptyContent:H,emphasis:F,legendPosition:j}=e,$=n.showAxes,Y=n.enableHover,X=r??n.marginDefaults,V=o??[n.width,n.height],G=S??_??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const o=e?.data??null,r=is(o,t,"time"),s=o?.delta??is(o,n,"value"),i=o?.cumEnd,a="number"==typeof s?0>s?as(s):"+"+as(s):as(s);return os("div",{className:"semiotic-tooltip",style:rs,children:[os("div",{children:[ns("span",{style:ss,children:"x:"}),as(r)]}),os("div",{children:[ns("span",{style:ss,children:"Δ:"}),a]}),null!=i&&os("div",{children:[ns("span",{style:ss,children:"total:"}),as(i)]})]})}}({timeAccessor:u,valueAccessor:d}),q=Ls(null),{customHoverBehavior:U}=Ie({selection:W,linkedHover:E,unwrapData:!0,onObservation:z,chartType:"RealtimeWaterfallChart",chartId:B}),Q=Fs(e=>{T&&T(e),U(e)},[T,U]);Os(t,()=>({push:e=>q.current?.push(e),pushMany:e=>q.current?.pushMany(e),remove:e=>q.current?.remove(e)??[],update:(e,t)=>q.current?.update(e,t)??[],clear:()=>q.current?.clear(),getData:()=>q.current?.getData()??[],getScales:()=>q.current?.getScales()??null}),[]);const K=R(L,V[0],V[1],O),J=K?null:C(c,V[0],V[1],H),Z={};null!=y&&(Z.positiveColor=y),null!=g&&(Z.negativeColor=g),null!=m&&(Z.connectorStroke=m),null!=v&&(Z.connectorWidth=v),null!=x&&(Z.gap=x),null!=b&&(Z.stroke=b),null!=k&&(Z.strokeWidth=k),null!=w&&(Z.opacity=w);const ee=F?`${s||""} semiotic-emphasis-${F}`.trim():s,te=cs(l,c);return K||J||js(bo,{ref:q,chartType:"waterfall",runtimeMode:"streaming",size:V,margin:X,className:ee,arrowOfTime:i,windowMode:a,windowSize:te,data:c,timeAccessor:u,valueAccessor:d,xExtent:h,yExtent:f,extentPadding:p,waterfallStyle:Z,showAxes:$,background:A,hoverAnnotation:Y,tooltipContent:G,...xs({linkedHover:E,selection:W,onObservation:z,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:Q}),annotations:P,autoPlaceAnnotations:M,svgAnnotationRules:N,tickFormatTime:I,tickFormatValue:D,legendPosition:j,pointIdAccessor:e.pointIdAccessor})});$s.displayName="RealtimeWaterfallChart";import{useRef as Ys,useImperativeHandle as Xs,forwardRef as Vs,useCallback as Gs}from"react";import{jsx as qs}from"react/jsx-runtime";var Us=Vs(function(e,t){const n=Ne(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:o,margin:r,className:s,arrowOfTime:i="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:d,categoryAccessor:h,timeExtent:f,valueExtent:p,extentPadding:y,heatmapXBins:g=20,heatmapYBins:m=20,aggregation:v="count",background:x,tooltipContent:b,tooltip:k,onHover:w,annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:T,tickFormatValue:P,decay:M,pulse:N,staleness:I,linkedHover:D,selection:E,onObservation:W,chartId:z,loading:B,loadingContent:L,emptyContent:O,emphasis:H,legendPosition:F}=e,j=n.showAxes,$=n.enableHover,Y=r??n.marginDefaults,X=o??[n.width,n.height],V=b??k??function(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:o="x",yLabel:r="y"}=e;return e=>{const s=e?.data??null,i=s?.xCenter??is(s,t,"time"),a=s?.yCenter??is(s,n,"value"),l=s?.count,c=s?.sum,u=s?.value,d=s?.agg??"count";return os("div",{className:"semiotic-tooltip",style:rs,children:[os("div",{children:[os("span",{style:ss,children:[o,":"]}),as(i)]}),os("div",{children:[os("span",{style:ss,children:[r,":"]}),as(a)]}),null!=l&&os("div",{children:[ns("span",{style:ss,children:"count:"}),as(l)]}),"sum"===d&&null!=c&&os("div",{children:[ns("span",{style:ss,children:"sum:"}),as(c)]}),"mean"===d&&null!=u&&os("div",{children:[ns("span",{style:ss,children:"mean:"}),as(u)]})]})}}({timeAccessor:u,valueAccessor:d}),G=Ys(null),{customHoverBehavior:q}=Ie({selection:E,linkedHover:D,unwrapData:!0,onObservation:W,chartType:"RealtimeHeatmap",chartId:z}),U=Gs(e=>{w&&w(e),q(e)},[w,q]);Xs(t,()=>({push:e=>G.current?.push(e),pushMany:e=>G.current?.pushMany(e),remove:e=>G.current?.remove(e)??[],update:(e,t)=>G.current?.update(e,t)??[],clear:()=>G.current?.clear(),getData:()=>G.current?.getData()??[],getScales:()=>G.current?.getScales()??null}),[]);const Q=R(B,X[0],X[1],L),K=Q?null:C(c,X[0],X[1],O),J=H?`${s||""} semiotic-emphasis-${H}`.trim():s,Z=cs(l,c);return Q||K||qs(bo,{ref:G,chartType:"heatmap",runtimeMode:"streaming",size:X,margin:Y,className:J,arrowOfTime:i,windowMode:a,windowSize:Z,data:c,timeAccessor:u,valueAccessor:d,categoryAccessor:h,xExtent:f,yExtent:p,extentPadding:y,heatmapXBins:g,heatmapYBins:m,heatmapAggregation:v,showAxes:j,background:x,hoverAnnotation:$,tooltipContent:V,...xs({linkedHover:D,selection:E,onObservation:W,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:U}),annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:T,tickFormatValue:P,decay:M,pulse:N,staleness:I,legendPosition:F,pointIdAccessor:e.pointIdAccessor})});Us.displayName="RealtimeHeatmap";export{We as DEFAULT_LIFECYCLE_THRESHOLDS,ie as IncrementalExtent,Us as RealtimeHeatmap,Ms as RealtimeHistogram,ws as RealtimeLineChart,Bs as RealtimeSwarmChart,$s as RealtimeWaterfallChart,Ur as ReorderBuffer,ae as RingBuffer,jr as RunningStats,Fr as StreamNetworkFrame,bo as StreamXYFrame,Ns as TemporalHistogram,$r as WindowAccumulator,Xr as bandBounds,ze as bandFromAge,G as compileMotionEncoding,Q as deriveMotionVector,Z as opacityFromAge,qr as parseWindowDuration,ne as resolveMotionAccessor,oe as resolveMotionVector,Yr as statValue};
1
+ import{getHitRadius as e,hitTestRect as t,isTimeLandmark as n,normalizeAngle as o}from"./chunk-chunk-CP3EN6KZ.module.min.js";import{CustomLayoutSelectionProvider as r,canUseForceWorker as s,createFrameForceWorkerRequest as i,runForceLayoutWorker as a,shouldUseForceWorker as l,wrapWithCustomLayoutSelection as c}from"./chunk-chunk-7OEOSCBP.module.min.js";import{AccessibleDataTable as u,AriaLiveTooltip as d,CanvasFrameBackground as h,FlippingTooltip as p,FocusRing as f,NetworkAccessibleDataTable as y,SceneRevisionDiagnosticsObserver as g,ScreenReaderSummary as m,SkipToTableLink as v,computeCanvasAriaLabel as x,computeNetworkAriaLabel as b,createDefaultAnnotationRules as k,getDevicePixelRatio as w,prepareCanvas as A,renderAnnotationPass as S,renderEmptyState as _,renderLegendFromConfig as T,renderLoadingState as C,runSceneBuild as P,useFrame as R,useFrameCanvasHost as M,useHydration as N,useSceneRevisionDiagnostics as I,useWasHydratingFromSSR as W}from"./chunk-chunk-FRIO6MCV.module.min.js";import{annotationActivationProps as D,buildHoverData as E,defaultTooltipStyle as z,getPointerHitRadius as B,isAnnotationActivationTarget as L,smartTooltipEntries as O,useAnnotationActivationOptions as H}from"./chunk-chunk-255KDHW5.module.min.js";import"./chunk-chunk-SV4XAZ3Q.module.min.js";import{PipelineStore as F,attachUpdateResultStore as j,compileMotionEncoding as $,computeDecayOpacity as Y,createCustomLayoutFailureDiagnostic as X,deriveMotionVector as V,enrichDatumWithBand as G,getLayoutPlugin as q,opacityFromAge as U,paintSceneWithBackend as Q,renderSceneWithBackend as K,resolveDownwardHistogramExtent as Z,resolveMotionAccessor as J,resolveMotionVector as ee,ticksForMode as te,warnCustomLayoutDiagnostics as ne}from"./chunk-chunk-GWSWSPXN.module.min.js";import{IncrementalExtent as oe,RingBuffer as re}from"./chunk-chunk-VVCA3DB7.module.min.js";import"./chunk-chunk-5APBQXZA.module.min.js";import{ANNOTATION_DISCLOSURE_REVEAL_CSS as se,DEFAULT_COLORS as ie,TITLE_BASELINE as ae,buildColorStopGradient as le,buildLinearFillGradient as ce,buildResolveColor as ue,clampCornerRadii as de,computeEasing as he,computeRawProgress as pe,emitClickObservations as fe,emitHoverObservations as ye,filterSparseArray as ge,hasAnyCornerRadius as me,isInteractiveKeyboardTarget as ve,isServerEnvironment as xe,lerp as be,networkLabelToSVG as ke,networkSceneEdgeToSVG as we,networkSceneNodeToSVG as Ae,normalizeLinkedBrush as Se,now as _e,observationInputType as Te,resolveCanvasFill as Ce,resolveCurveFactory as Pe,resolveCustomLayoutPalette as Re,unlockCrosshair as Me,useBrushSelection as Ne,useChartLegendAndMargin as Ie,useChartMode as We,useChartSelection as De,useCrosshairPosition as Ee,xySceneNodeToSVG as ze}from"./chunk-chunk-F25UA5HT.module.min.js";import"./chunk-chunk-XEVJDUTH.module.min.js";import{DEFAULT_LIFECYCLE_THRESHOLDS as Be,bandFromAge as Le}from"./chunk-chunk-2WVCH4PL.module.min.js";import{UpdateResultTracker as Oe,annotationLayout as He,drawGlyphParts as Fe,glyphFractionClipRect as je,glyphHitGeometry as $e,glyphPlacement as Ye,schemeCategory10 as Xe,symbolPathString as Ve,symbolRadius as Ge}from"./chunk-chunk-5RKXZQ2P.module.min.js";import"./chunk-chunk-U66USBWU.module.min.js";import{getMax as qe}from"./chunk-chunk-JJ2OOIET.module.min.js";import{getCSSColorCacheVersion as Ue,resolveCSSColor as Qe}from"./chunk-chunk-QRIBHZYW.module.min.js";import"./chunk-chunk-J3QOW4OE.module.min.js";import{resolveThemeSemanticColors as Ke}from"./chunk-chunk-DSNGDNJY.module.min.js";import*as Ze from"react";import{useRef as Je,useState as et,useEffect as tt,useMemo as nt,useCallback as ot,useImperativeHandle as rt,useId as st,forwardRef as it,memo as at}from"react";import*as lt from"react";import{jsx as ct}from"react/jsx-runtime";var ut=null,dt=null;function ht(e){const[t,n]=lt.useState(()=>ut);return lt.useEffect(()=>{if(t)return;let e=!1;return(ut?Promise.resolve(ut):(dt||(dt=import("./chunk-XYBrushOverlay-ECZJJLAJ.module.min.js").then(e=>ut=e.XYBrushOverlay)),dt)).then(t=>{e||n(()=>t)}),()=>{e=!0}},[t]),t?ct(t,{...e}):null}var pt=class{constructor(e,t){this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=t?.chunkThreshold??5e3,this.chunkSize=t?.chunkSize??5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(e=ge(e),this.lastBoundedData===e)return;if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(e){if(e=ge(e),this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){null!=e&&"object"==typeof e&&(this.pushBuffer.push(e),this.scheduleFlush())}pushMany(e){if(0===e.length)return;let t=0;for(let n=0;e.length>n;n++){const o=e[n];null!=o&&"object"==typeof o&&(this.pushBuffer.push(o),t++)}0!==t&&this.scheduleFlush()}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}};import*as ft from"react";function yt(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:ft.createElement(ft.Fragment,null,...t)}import{useEffect as gt,useRef as mt}from"react";function vt(e,t,n,o){gt(()=>{e.current?.updateConfig(t),n.current=!0,o()},[t,o,e,n])}function xt(e,t,n,o){const r=mt(null);gt(()=>{const s=e.current;if(!s)return;const i=t??null;r.current!==i&&(r.current=i,s.setLayoutSelection(i),s.hasCustomRestyle?s.restyleScene(i):n.current=!0,o())},[t,o,e,n])}function bt(t,n,o,r,s,i=e=>e.x,a=e=>e.y,l=e=>e.r){const c=Math.max(r,s+5,12),u=n-c,d=n+c,h=o-c,p=o+c;let f=null,y=1/0;return t.visit((t,s,c,g,m)=>{if(s>d||u>g||c>p||h>m)return!0;if(!t.length){let s=t;do{const t=s.data,c=i(t)-n,u=a(t)-o,d=Math.sqrt(c*c+u*u);e(l(t),r)>=d&&y>d&&(f=t,y=d),s=s.next}while(s)}return!1}),f?{node:f,distance:y}:null}import{line as kt}from"d3-shape";var wt=new WeakMap;function At(e,t){const n=Pe(t);if(!n)return e;const o=wt.get(e);if(o)return o;const r=function(e,t,n=8){if(!t||2>e.length)return e.map(([e,t])=>[e,t]);const o=[];let r=null;const s={moveTo(e,t){r=[e,t],o.push([e,t])},lineTo(e,t){r=[e,t],o.push([e,t])},bezierCurveTo(e,t,s,i,a,l){if(!r)return r=[a,l],void o.push([a,l]);const[c,u]=r;for(let r=1;n>=r;r++){const d=r/n,h=1-d;o.push([h*h*h*c+3*h*h*d*e+3*h*d*d*s+d*d*d*a,h*h*h*u+3*h*h*d*t+3*h*d*d*i+d*d*d*l])}r=[a,l]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(e,t,n,s){r=[n,s],o.push([n,s])}};return kt().x(e=>e[0]).y(e=>e[1]).curve(t).context(s)(e),o}(e,n);return wt.set(e,r),r}function St(e,t,n,o=30,r,s=0){let i=null;if(r){const e=bt(r,t,n,o,s);e&&(i={node:e.node,datum:e.node.datum,x:e.node.x,y:e.node.y,distance:e.distance})}for(const s of e){let e=null;switch(s.type){case"point":if(r)break;e=Tt(s,t,n,o);break;case"symbol":e=Ct(s,t,n,o);break;case"glyph":e=Pt(s,t,n,o);break;case"line":e=Rt(s,t,n,o);break;case"rect":if(null==s.datum)break;e=Nt(s,t,n);break;case"heatcell":e=It(s,t,n);break;case"area":if(!1===s.interactive)break;e=Dt(s,t,n);break;case"candlestick":e=Wt(s,t,n)}e&&o>e.distance&&(i&&e.distance>=i.distance||(i=e))}return i}function _t(e,t,n){if(0===e.length)return null;if(e[0][0]>t||t>e[e.length-1][0])return null;const o=Et(e,t);if(0>o)return null;if(Math.abs(e[o][0]-t)>n)return null;let r=o,s=o;o>0&&e[o][0]>=t?(r=o-1,s=o):e.length-1>o&&(r=o,s=o+1);const[i,a]=e[r],[l,c]=e[s];return l===i?a:a+Math.max(0,Math.min(1,(t-i)/(l-i)))*(c-a)}function Tt(t,n,o,r=30){const s=n-t.x,i=o-t.y,a=Math.sqrt(s*s+i*i);return a>e(t.r,r)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:a}}function Ct(t,n,o,r=30){const s=n-t.x,i=o-t.y,a=Math.sqrt(s*s+i*i);return a>e(Ge(t.size),r)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:a}}function Pt(t,n,o,r=30){if(null==t.datum)return null;const s=$e(t.glyph,t.size),i=t.x+s.centerDx,a=t.y+s.centerDy,l=n-i,c=o-a,u=Math.sqrt(l*l+c*c);return u>e(s.radius,r)?null:{node:t,datum:t.datum,x:i,y:a,distance:u}}function Rt(e,t,n,o=30){if(0===e.path.length)return null;const r=Et(e.path,t);if(0>r)return null;const[s,i]=e.path[r];let a;if(e.path.length>1){let o=1/0;const s=Math.max(0,r-1),i=Math.min(e.path.length-2,r);for(let r=s;i>=r;r++){const[s,i]=e.path[r],[a,l]=e.path[r+1],c=Mt(t,n,s,i,a,l);o>c&&(o=c)}a=o}else{const e=t-s,o=n-i;a=Math.sqrt(e*e+o*o)}const l=e.style;return a>Math.max(5,(l.strokeWidth??l.lineWidth??1)/2+2,o)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[r]?e.datum[r]:e.datum,x:s,y:i,distance:a}}function Mt(e,t,n,o,r,s){const i=r-n,a=s-o,l=i*i+a*a;if(0===l)return Math.sqrt((e-n)**2+(t-o)**2);let c=((e-n)*i+(t-o)*a)/l;return c=Math.max(0,Math.min(1,c)),Math.sqrt((e-(n+c*i))**2+(t-(o+c*a))**2)}function Nt(e,n,o){const r=t(n,o,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function It(e,n,o){const r=t(n,o,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function Wt(e,t,n){const o=e.bodyWidth/2,r=Math.min(e.openY,e.closeY);if(!(e.x-o-3>t||t>e.x+o+3||e.highY-3>n||n>e.lowY+3)){const o=r+Math.max(Math.max(e.openY,e.closeY)-r,1)/2,s=t-e.x,i=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(s*s+i*i)}}return null}function Dt(e,t,n){if(0===e.topPath.length)return null;const o=Et(e.topPath,t);if(0>o)return null;const[r,s]=e.topPath[o],i=t-r,a=n-s,l=Math.sqrt(i*i+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:r,y:s,distance:l}}function Et(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const r=n+o>>1;t>e[r][0]?n=r+1:o=r}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}import{useEffect as zt,useRef as Bt}from"react";var Lt={fresh:1,aging:.7,stale:.45,expired:.25},Ot={alpha:1,band:"fresh",isStale:!1};function Ht(e,t){if(!e||0>=t)return Ot;const n=null!=e.threshold&&e.threshold>0?e.threshold:5e3,o=e.graded;if(o){const e="object"==typeof o?o:{},r=Le(t,n,e.thresholds);return{alpha:{...Lt,...e.opacities??{}}[r],band:r,isStale:"fresh"!==r}}return t>n?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:Ot}function Ft(e,t,n,o,r,s){const i=Bt("fresh");zt(()=>{if(!e)return;const a=setInterval(()=>{const a=t.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=Ht(e,l-a.lastIngestTime);c.band===i.current&&c.isStale===r||(i.current=c.band,c.isStale!==r&&s(c.isStale),n.current=!0,o())},1e3);return()=>clearInterval(a)},[e,r,o,t,s,n])}import{jsx as jt}from"react/jsx-runtime";function $t({isStale:e,position:t}){return jt("div",{className:"stream-staleness-badge",style:{position:"absolute",..."top-left"===t?{top:4,left:4}:"bottom-left"===t?{bottom:4,left:4}:"bottom-right"===t?{bottom:4,right:4}:{top:4,right:4},padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:e?"#dc3545":"#28a745",color:"white"},children:e?"STALE":"LIVE"})}import{useMemo as Yt,useRef as Xt,useEffect as Vt}from"react";import{useMemo as Gt}from"react";import{bin as qt}from"d3-array";import{jsx as Ut,jsxs as Qt}from"react/jsx-runtime";function Kt(e){return"string"==typeof e?{type:e}:e}function Zt({orient:e,config:t,values:n,scale:o,size:r,length:s}){const i=function(e){return{type:e.type,bins:e.bins??20,fill:e.fill??"#4e79a7",fillOpacity:e.fillOpacity??.5,stroke:e.stroke??"none",strokeWidth:e.strokeWidth??1}}(t),a="top"===e||"bottom"===e,l=Gt(()=>{if(0===n.length)return null;const t=o.domain(),l=r-8;if("boxplot"===i.type){const t=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],r=t[Math.floor(.5*n)],s=t[Math.floor(.75*n)],i=s-o;return{q1:o,median:r,q3:s,whiskerLow:Math.max(t[0],o-1.5*i),whiskerHigh:Math.min(t[n-1],s+1.5*i)}}(n);if(!t)return null;const{q1:r,median:s,q3:c,whiskerLow:u,whiskerHigh:d}=t,h=Math.min(.5*l,20),p=(l-h)/2+4;if(a){const t=o(r),n=o(c),a=o(s),l=o(u),f=o(d),y="top"===e?-1:1,g=0;return Qt("g",{"data-testid":"marginal-boxplot-"+e,children:[Ut("line",{x1:l,y1:g+y*(p+h/2),x2:f,y2:g+y*(p+h/2),stroke:i.fill,strokeWidth:i.strokeWidth}),Ut("line",{x1:l,y1:g+y*p,x2:l,y2:g+y*(p+h),stroke:i.fill,strokeWidth:i.strokeWidth}),Ut("line",{x1:f,y1:g+y*p,x2:f,y2:g+y*(p+h),stroke:i.fill,strokeWidth:i.strokeWidth}),Ut("rect",{x:Math.min(t,n),y:"top"===e?g-p-h:g+p,width:Math.abs(n-t),height:h,fill:i.fill,fillOpacity:i.fillOpacity,stroke:"none"===i.stroke?i.fill:i.stroke,strokeWidth:i.strokeWidth}),Ut("line",{x1:a,y1:"top"===e?g-p-h:g+p,x2:a,y2:"top"===e?g-p:g+p+h,stroke:i.fill,strokeWidth:2})]})}{const t=o(r),n=o(c),a=o(s),l=o(u),f=o(d),y="left"===e?-1:1,g=0;return Qt("g",{"data-testid":"marginal-boxplot-"+e,children:[Ut("line",{x1:g+y*(p+h/2),y1:l,x2:g+y*(p+h/2),y2:f,stroke:i.fill,strokeWidth:i.strokeWidth}),Ut("line",{x1:g+y*p,y1:l,x2:g+y*(p+h),y2:l,stroke:i.fill,strokeWidth:i.strokeWidth}),Ut("line",{x1:g+y*p,y1:f,x2:g+y*(p+h),y2:f,stroke:i.fill,strokeWidth:i.strokeWidth}),Ut("rect",{x:"left"===e?g-p-h:g+p,y:Math.min(t,n),width:h,height:Math.abs(n-t),fill:i.fill,fillOpacity:i.fillOpacity,stroke:"none"===i.stroke?i.fill:i.stroke,strokeWidth:i.strokeWidth}),Ut("line",{x1:"left"===e?g-p-h:g+p,y1:a,x2:"left"===e?g-p:g+p+h,y2:a,stroke:i.fill,strokeWidth:2})]})}}const c=qt().domain(t).thresholds(i.bins)(n);if(0===c.length)return null;const u=qe(c.map(e=>e.length));if(0===u)return null;if("histogram"===i.type)return Ut("g",{"data-testid":"marginal-histogram-"+e,children:c.map((t,n)=>{if(null==t.x0||null==t.x1)return null;const r=t.length/u*l;if(a){const s=o(t.x0),a=o(t.x1)-o(t.x0);return Ut("rect",{x:s,y:"top"===e?-4-r:4,width:Math.max(a,.5),height:r,fill:i.fill,fillOpacity:i.fillOpacity,stroke:i.stroke,strokeWidth:i.strokeWidth},n)}{const s=o(t.x0),a=o(t.x1)-o(t.x0);return Ut("rect",{x:"left"===e?-4-r:4,y:Math.min(s,s+a),width:r,height:Math.abs(a),fill:i.fill,fillOpacity:i.fillOpacity,stroke:i.stroke,strokeWidth:i.strokeWidth},n)}})});if("violin"===i.type){const t=l/2+4,n=[];for(const r of c){if(null==r.x0||null==r.x1)continue;const s=r.length/u*(l/2),i=o((r.x0+r.x1)/2);n.push(a?`${i},${"top"===e?-(t-s):t-s}`:`${"left"===e?-(t-s):t-s},${i}`)}for(let r=c.length-1;r>=0;r--){const s=c[r];if(null==s.x0||null==s.x1)continue;const i=s.length/u*(l/2),d=o((s.x0+s.x1)/2);n.push(a?`${d},${"top"===e?-(t+i):t+i}`:`${"left"===e?-(t+i):t+i},${d}`)}return Ut("g",{"data-testid":"marginal-violin-"+e,children:Ut("polygon",{points:n.join(" "),fill:i.fill,fillOpacity:i.fillOpacity,stroke:"none"===i.stroke?i.fill:i.stroke,strokeWidth:i.strokeWidth})})}if("ridgeline"===i.type){const t=[];if(a){const n=0,r=null!=c[0].x0?o(c[0].x0):0;t.push(`M${r},${n}`);for(const n of c){if(null==n.x0||null==n.x1)continue;const r=n.length/u*l,s=o((n.x0+n.x1)/2);t.push(`L${s},${"top"===e?-r-4:r+4}`)}const i=null!=c[c.length-1].x1?o(c[c.length-1].x1):s;t.push(`L${i},${n}`),t.push("Z")}else{const n=0,r=null!=c[0].x0?o(c[0].x0):0;t.push(`M${n},${r}`);for(const n of c){if(null==n.x0||null==n.x1)continue;const r=n.length/u*l,s=o((n.x0+n.x1)/2);t.push(`L${"left"===e?-r-4:r+4},${s}`)}const i=null!=c[c.length-1].x1?o(c[c.length-1].x1):s;t.push(`L${n},${i}`),t.push("Z")}return Ut("g",{"data-testid":"marginal-ridgeline-"+e,children:Ut("path",{d:t.join(" "),fill:i.fill,fillOpacity:i.fillOpacity,stroke:"none"===i.stroke?i.fill:i.stroke,strokeWidth:i.strokeWidth})})}return null},[n,o,i,r,s,e,a,4]);return l?Ut("g",{className:"marginal-"+e,"data-testid":"marginal-"+e,children:l}):null}function Jt(e,t,n){if("edges"===e){if(t)return"start";if(n)return"end"}return"middle"}function en(e,t,n){if("edges"===e){if(t)return"hanging";if(n)return"auto"}return"middle"}function tn(e){if(0===e.length)return{min:null,max:null};let t=1/0,n=-1/0;for(const o of e)t>o.pixel&&(t=o.pixel),o.pixel>n&&(n=o.pixel);return{min:t,max:n}}function nn(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function on(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,r="left"===e?-1:1,s=Math.ceil(t/8);let i="M0,"+o;for(let e=0;s>e;e++){const n=8*(e+1);i+=`L${Math.min(8*e+4,t)},${o+4*r}`,i+=`L${Math.min(n,t)},${o}`}return i}const o="bottom"===e?0:t,r="bottom"===e?1:-1,s=Math.ceil(n/8);let i=`M${o},0`;for(let e=0;s>e;e++){const t=8*(e+1);i+=`L${o+4*r},${Math.min(8*e+4,n)}`,i+=`L${o},${Math.min(t,n)}`}return i}import{Fragment as rn,jsx as sn,jsxs as an}from"react/jsx-runtime";function ln(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:s,scales:i,showAxes:a,axes:l,showGrid:c,xFormat:u,yFormat:d,axisExtent:h}=e,p=Yt(()=>{if(!i)return[];const e=l?.find(e=>"bottom"===e.orient),n=e?.tickFormat||u||cn,o=Math.max(2,Math.floor(t/70)),r=e?.ticks??5,s="exact"===h?Math.max(2,r):Math.min(r,o),a=e?.tickValues??te(i.x,s,h),c=a.map(e=>e.valueOf()),d=a.map((e,t)=>({value:e,pixel:i.x(e),label:n(e,t,c)})),p=d.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0);return un(d,Math.max(55,p+8))},[i,l,u,t,h]),f=Yt(()=>{if(!i)return[];const e=l?.find(e=>"left"===e.orient),t=e?.tickFormat||d||cn,o=Math.max(2,Math.floor(n/30)),r=e?.ticks??5,s="exact"===h?Math.max(2,r):Math.min(r,o);return un((e?.tickValues??te(i.y,s,h)).map(e=>({value:e,pixel:i.y(e),label:t(e)})),22)},[i,l,d,n,h]),y=c&&i,g=a&&i;if(!y&&!g)return null;const m=l?.find(e=>"bottom"===e.orient),v=l?.find(e=>"left"===e.orient),x=g&&(!m||!1!==m.baseline),b=g&&(!v||!1!==v.baseline),k=m?.jaggedBase||!1,w=v?.jaggedBase||!1,A="var(--semiotic-border, #ccc)";return sn("svg",{width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:an("g",{transform:`translate(${s.left},${s.top})`,children:[y&&(()=>{const e=nn(l?.find(e=>"bottom"===e.orient)?.gridStyle),o=nn(l?.find(e=>"left"===e.orient)?.gridStyle);return an("g",{className:"stream-grid",children:[p.map((t,o)=>sn("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+o)),f.map((e,n)=>sn("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"ygrid-"+n))]})})(),x&&!k&&sn("line",{x1:0,y1:n,x2:t,y2:n,stroke:A,strokeWidth:1}),k&&sn("path",{d:on("bottom",t,n),fill:"none",stroke:A,strokeWidth:1}),b&&!w&&sn("line",{x1:0,y1:0,x2:0,y2:n,stroke:A,strokeWidth:1}),w&&sn("path",{d:on("left",t,n),fill:"none",stroke:A,strokeWidth:1})]})})}function cn(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function un(e,t){if(2>=e.length)return e;const n=[e[0]];for(let o=1;e.length-1>o;o++)t>Math.abs(e[o].pixel-n[n.length-1].pixel)||n.push(e[o]);const o=e[e.length-1];return t>Math.abs(o.pixel-n[n.length-1].pixel)?n[n.length-1]=o:n.push(o),n}function dn(e){const{width:t,height:o,totalWidth:r,totalHeight:s,margin:i,scales:a,showAxes:l,axes:c,xLabel:u,yLabel:d,yLabelRight:h,xFormat:p,yFormat:f,axisExtent:y,showGrid:g,title:m,legend:v,legendHoverBehavior:x,legendClickBehavior:b,legendHighlightedCategory:w,legendIsolatedCategories:A,legendPosition:_="right",legendLayout:C,foregroundGraphics:P,marginalGraphics:R,xValues:M,yValues:N,annotations:I,onAnnotationActivate:W,onObservation:D,chartId:E,chartType:z,autoPlaceAnnotations:B,svgAnnotationRules:L,xAccessor:O,yAccessor:F,annotationData:j,pointNodes:$,curve:Y,underlayRendered:X,canvasObscuresUnderlay:V=!0,linkedCrosshairName:G,linkedCrosshairSourceId:q,children:U}=e,Q=H({onAnnotationActivate:W,onObservation:D,chartId:E,chartType:z}),K=Yt(()=>{if(!l||!a)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||p||cn,o=Math.max(2,Math.floor(t/70)),r=e?.ticks??5,s="exact"===y?Math.max(2,r):Math.min(r,o),i=e?.tickValues??te(a.x,s,y),u=i.map(e=>e.valueOf()),d=i.map((e,t)=>({value:e,pixel:a.x(e),label:n(e,t,u)})),h=d.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),f=e?.autoRotate?Math.max(20,Math.min(h+8,55)):Math.max(55,h+8);let g=un(d,f);if(g.length>1&&(g=g.filter((e,t)=>0===t||e.label+""!=g[t-1].label+"")),e?.includeMax&&g.length>0&&"exact"!==y&&!e?.tickValues){const e=a.x.domain()[1],t=a.x(e),o=g[g.length-1].pixel;if(Math.abs(t-o)>1){const r=n(e,g.length,u);f>t-o&&g.length>1&&(g=g.slice(0,-1)),g.push({value:e,pixel:t,label:r})}}return g},[l,a,c,p,t,y]),Z=Yt(()=>{if(!l||!a)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||f||cn,n=Math.max(2,Math.floor(o/30)),r=e?.ticks??5,s="exact"===y?Math.max(2,r):Math.min(r,n);let i=un((e?.tickValues??te(a.y,s,y)).map(e=>({value:e,pixel:a.y(e),label:t(e)})),22);if(i.length>1&&(i=i.filter((e,t)=>0===t||e.label+""!=i[t-1].label+"")),e?.includeMax&&i.length>0&&"exact"!==y&&!e?.tickValues){const e=a.y.domain()[1],n=a.y(e),o=i[i.length-1].pixel;if(Math.abs(n-o)>1){const r=t(e);22>Math.abs(n-o)&&i.length>1&&(i=i.slice(0,-1)),i.push({value:e,pixel:n,label:r})}}return i},[l,a,c,f,o,y]),J=Yt(()=>{if(!l||!a)return[];const e=c?.find(e=>"right"===e.orient);if(!e)return[];const t=e.tickFormat||f||cn,n=Math.max(2,Math.floor(o/30)),r=e.ticks??5;return un((e.tickValues??te(a.y,"exact"===y?Math.max(2,r):Math.min(r,n),y)).map(e=>({value:e,pixel:a.y(e),label:t(e)})),22)},[l,a,c,f,o,y]),ee=Xt(new Map),ne=Xt(I?.length??0),oe=I?.length??0;ne.current!==oe&&(ne.current=oe,ee.current=new Map);const re=Yt(()=>{if(!I||0===I.length)return null;const e=k("xy",Q),n={scales:a?{x:a.x,y:a.y,time:a.x,value:a.y}:null,timeAxis:"x",xAccessor:O,yAccessor:F,width:t,height:o,data:j,frameType:"xy",pointNodes:$,curve:Y,stickyPositionCache:ee.current},r=B?He({annotations:I,context:n,..."object"==typeof B?B:{}}):I;return S(r,e,L,n)},[I,B,L,t,o,O,F,j,a,$,Y,Q]),se=Ee(G);return Vt(()=>{if(!se?.locked||!G)return;const e=e=>{"Escape"===e.key&&Me(G)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[se?.locked,G]),l||m||v||P||R||re&&re.length>0||g||U||se?an("svg",{role:"img",width:r,height:s,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[sn("title",{children:"string"==typeof m?m:"XY Chart"}),sn("desc",{children:"string"==typeof m?m+" (XY data visualization)":"XY data visualization"}),an("g",{transform:`translate(${i.left},${i.top})`,children:[g&&a&&(!X||V)&&(()=>{const e=nn(c?.find(e=>"bottom"===e.orient)?.gridStyle),n=nn(c?.find(e=>"left"===e.orient)?.gridStyle);return an("g",{className:"stream-grid",children:[K.map((t,n)=>sn("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+n)),Z.map((e,o)=>sn("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:n},"ygrid-"+o))]})})(),l&&a&&(()=>{const e=c?.find(e=>"left"===e.orient),r=c?.find(e=>"bottom"===e.orient),s=!e||!1!==e.baseline,a=!r||!1!==r.baseline,l=e?.jaggedBase||!1,p=r?.jaggedBase||!1,f=r?.landmarkTicks,y=e?.landmarkTicks,g="var(--semiotic-border, #ccc)",m="var(--semiotic-text-secondary, var(--semiotic-text, #666))",v="var(--semiotic-text, #333)",x=!!r?.autoRotate&&K.length>1&&(()=>{const e=t/Math.max(K.length-1,1);return K.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})(),b=x?12:18,k=o+(x?58:40),w={fontSize:"var(--semiotic-tick-font-size, 12px)"},A={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},S={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},_=r?.tickAnchor,T=e?.tickAnchor,C=tn(K),P=tn(Z);return an("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[an("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!X||V)&&a&&!p&&sn("line",{x1:0,y1:o,x2:t,y2:o,stroke:g,strokeWidth:1}),(!X||V)&&p&&sn("path",{d:on("bottom",t,o),fill:"none",stroke:g,strokeWidth:1}),K.map((e,t)=>{const r=!!f&&("function"==typeof f?f(e.value,t):n(e.value,t>0?K[t-1].value:void 0));return an("g",{transform:`translate(${e.pixel},${o})`,children:[sn("line",{y2:5,stroke:g,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?sn("text",{y:b,textAnchor:x?"end":Jt(_,e.pixel===C.min,e.pixel===C.max),fontWeight:r?600:400,fill:m,className:"semiotic-axis-tick",style:{userSelect:"none",...r?A:w},transform:x?"rotate(-45)":void 0,children:e.label}):sn("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:sn("div",{style:{textAlign:"center",userSelect:"none",...w},children:e.label})})]},"xtick-"+t)}),u&&sn("text",{x:t/2,y:k,textAnchor:"middle",fill:v,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:u})]}),an("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!X||V)&&s&&!l&&sn("line",{x1:0,y1:0,x2:0,y2:o,stroke:g,strokeWidth:1}),(!X||V)&&l&&sn("path",{d:on("left",t,o),fill:"none",stroke:g,strokeWidth:1}),Z.map((e,t)=>{const o=!!y&&("function"==typeof y?y(e.value,t):n(e.value,t>0?Z[t-1].value:void 0));return an("g",{transform:`translate(0,${e.pixel})`,children:[sn("line",{x2:-5,stroke:g,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?sn("text",{x:-8,textAnchor:"end",dominantBaseline:en(T,e.pixel===P.min,e.pixel===P.max),fontWeight:o?600:400,fill:m,className:"semiotic-axis-tick",style:{userSelect:"none",...o?A:w},children:e.label}):sn("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:sn("div",{style:{textAlign:"right",userSelect:"none",...w},children:e.label})})]},"ytick-"+t)}),(()=>{const t=e?.label||d;return t?sn("text",{x:15-i.left,y:o/2,textAnchor:"middle",fill:v,transform:`rotate(-90, ${15-i.left}, ${o/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:t}):null})()]}),(()=>{const e=c?.find(e=>"right"===e.orient);if(!e||0===J.length)return null;const r=!1!==e.baseline,s=e.landmarkTicks,a=e.label||h,l=e.tickAnchor,u=tn(J);return an("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[r&&sn("line",{x1:t,y1:0,x2:t,y2:o,stroke:g,strokeWidth:1}),J.map((e,o)=>{const r=!!s&&("function"==typeof s?s(e.value,o):n(e.value,o>0?J[o-1].value:void 0));return an("g",{transform:`translate(${t},${e.pixel})`,children:[sn("line",{x2:5,stroke:g,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?sn("text",{x:8,textAnchor:"start",dominantBaseline:en(l,e.pixel===u.min,e.pixel===u.max),fontWeight:r?600:400,fill:m,className:"semiotic-axis-tick",style:{userSelect:"none",...r?A:w},children:e.label}):sn("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:sn("div",{style:{textAlign:"left",userSelect:"none",...w},children:e.label})})]},"ytick-r-"+o)}),a&&sn("text",{x:t+i.right-15,y:o/2,textAnchor:"middle",fill:v,transform:`rotate(90, ${t+i.right-15}, ${o/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:a})]})})()]})})(),re,R&&a&&M&&N&&an(rn,{children:[R.top&&sn("g",{transform:"translate(0, 0)",children:sn(Zt,{orient:"top",config:Kt(R.top),values:M,scale:a.x,size:i.top,length:t})}),R.bottom&&sn("g",{transform:`translate(0, ${o})`,children:sn(Zt,{orient:"bottom",config:Kt(R.bottom),values:M,scale:a.x,size:i.bottom,length:t})}),R.left&&sn("g",{transform:"translate(0, 0)",children:sn(Zt,{orient:"left",config:Kt(R.left),values:N,scale:a.y,size:i.left,length:o})}),R.right&&sn("g",{transform:`translate(${t}, 0)`,children:sn(Zt,{orient:"right",config:Kt(R.right),values:N,scale:a.y,size:i.right,length:o})})]}),P,se&&se.sourceId!==q&&a?.x&&(()=>{const e=a.x(se.xValue);if(null==e||0>e||e>t)return null;const n=se.locked;return sn("line",{x1:e,y1:0,x2:e,y2:o,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"})})(),U]}),m&&"string"==typeof m?sn("text",{x:r/2,y:ae,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:m}):m?sn("foreignObject",{x:0,y:0,width:r,height:i.top,children:m}):null,T({legend:v,totalWidth:r,totalHeight:s,margin:i,legendPosition:_,title:m,legendLayout:C,legendHoverBehavior:x,legendClickBehavior:b,legendHighlightedCategory:w,legendIsolatedCategories:A})]}):null}import{useRef as hn}from"react";function pn(e){const t=hn(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return yn(e,t);if(!gn(e)||!gn(t))return!1;const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;const n=e[o],r=t[o];if(!Object.is(n,r))if(Array.isArray(n)&&Array.isArray(r)){if(!yn(n,r))return!1}else{if(!gn(n)||!gn(r))return!1;if(!fn(n,r))return!1}}return!0}(t.current,e)||(t.current=e),t.current}function fn(e,t){const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;if(!Object.is(e[o],t[o]))return!1}return!0}function yn(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function gn(e){if(null===e||"object"!=typeof e)return!1;if(Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function mn(e){const{background:t,hasBackgroundGraphics:n=!1,themeBackground:o=""}=e;return"transparent"===t||n?null:t||(o&&"transparent"!==o?o:"")||null}function vn(e,t){const{background:n,hasBackgroundGraphics:o=!1,themeBackground:r="",x:s=0,y:i=0,width:a,height:l}=t,c=mn({background:n,hasBackgroundGraphics:o,themeBackground:r});if(!c)return!1;const u=Qe(e,c);return!!u&&(e.fillStyle=u,e.fillRect(s,i,a,l),!0)}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 bn(e,t){const n=e.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const e=n[1],o=n[2],r=n[3];return`#${e}${e}${o}${o}${r}${r}${t}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${t}`;const o=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return o?`rgba(${o[1]}, ${(parseInt(t,16)/255).toFixed(3)})`:n}function kn(e,t,n,o){return"function"==typeof e?e({size:t,margin:n,scales:o}):e}import{useCallback as wn,useRef as An}from"react";function Sn(e,t,n,o){return"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:n,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:o,fn:t}:{key:void 0,fn:null}}var _n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Tn=3156e7;function Cn(e){const t=e[1]-e[0];return 864e5>t?e=>{const t=new Date(e);return`${(t.getUTCHours()+"").padStart(2,"0")}:${(t.getUTCMinutes()+"").padStart(2,"0")}`}:Tn>t?e=>{const t=new Date(e);return`${_n[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*Tn>t?e=>{const t=new Date(e);return`${_n[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}function Pn(e){if(!e)return;const t=[];for(const n of e)if("point"===n.type)t.push(n);else if("symbol"===n.type)t.push({pointId:n.pointId,x:n.x,y:n.y,r:Ge(n.size)});else if("glyph"===n.type){const e=$e(n.glyph,n.size);t.push({pointId:n.pointId,x:n.x+e.centerDx,y:n.y+e.centerDy,r:e.radius})}return t}import{line as Rn}from"d3-shape";function Mn(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}function Nn(e,t,n,o,r,s){if(2>t.length)return;const i=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],o=t[e][1]-t[e-1][1];i.push(i[e-1]+Math.sqrt(n*n+o*o))}const a=i[i.length-1];if(0===a)return;const l=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=o,e.lineCap=s;for(let n=0;t.length-1>n;n++){const o=(i[n]+i[n+1])/2;let s=r;l>o&&(s*=o/l),l>a-o&&(s*=(a-o)/l),e.globalAlpha=Math.max(0,s),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}var In=(e,t,n,o)=>{const r=t.filter(e=>"line"===e.type);for(const t of r){if(2>t.path.length)continue;const n=t._introClipFraction;void 0!==n&&1>n&&(e.save(),e.beginPath(),e.rect(0,0,o.width*n,o.height),e.clip());const r=t.style.stroke||"#007bff",s=Qe(e,r)||r,i=t.style.strokeWidth||2,a=t.colorThresholds,l=t.rawValues;if(e.setLineDash(t.style.strokeDasharray?t.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),e.lineWidth=i,e.lineCap=t.style.strokeLinecap||"butt",t.style._edgeFade){Nn(e,t.path,s,i,t.style.opacity??1,t.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const c=Pe(t.curve),u=a&&a.length>0&&l&&l.length===t.path.length,d=t._decayOpacities;if(d&&d.length===t.path.length&&!u){e.strokeStyle=s;const n=t.style.opacity??1;for(let o=0;t.path.length-1>o;o++)e.globalAlpha=.5*(d[o]+d[o+1])*n,e.beginPath(),e.moveTo(t.path[o][0],t.path[o][1]),e.lineTo(t.path[o+1][0],t.path[o+1][1]),e.stroke()}else if(u){let n=function(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),d=!0},o=function(){d&&(e.stroke(),d=!1)},r=null,i=null,c=null,u=null,d=!1;for(let d=0;t.path.length>d;d++){const[h,p]=t.path[d],f=l[d],y=Mn(f,a,s);if(null!==r&&null!==u&&null!==c){if(y===u)e.lineTo(h,p);else{const t=[];for(const e of a){const n=e.value;(c>n||n>f)&&(n>c||f>n)||c===n||f===n||t.push({t:(n-c)/(f-c)})}t.sort((e,t)=>e.t-t.t);for(const l of t){const t=r+(h-r)*l.t,u=i+(p-i)*l.t,d=Mn(c+(f-c)*Math.min(l.t+1e-4,1),a,s);e.lineTo(t,u),o(),n(d,t,u)}e.lineTo(h,p)}r=h,i=p,c=f,u=y}else n(y,h,p),r=h,i=p,c=f,u=y}o()}else{e.beginPath();const n=t.strokeGradient&&t.path.length>=2?le(e,t.strokeGradient,t.path[0][0],0,t.path[t.path.length-1][0],0):null;if(e.strokeStyle=n||s,c)Rn().x(e=>e[0]).y(e=>e[1]).curve(c).context(e)(t.path);else{const[n,o]=t.path[0];e.moveTo(n,o);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1])}e.stroke()}if(t.style.fill&&t.style.fillOpacity&&t.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=t.style.fillOpacity,e.fillStyle=Ce(e,t.style.fill,t.style.fill),c&&!u)Rn().x(e=>e[0]).y(e=>e[1]).curve(c).context(e)(t.path);else{const[n,o]=t.path[0];e.moveTo(n,o);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1])}const n=t.path[0][0];e.lineTo(t.path[t.path.length-1][0],o.height),e.lineTo(n,o.height),e.closePath(),e.fill()}void 0!==n&&1>n&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function Wn(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Dn(e,t,n=.3){Wn(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function En(e,t,n=.6){if(!Wn(t))return;const o=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,r=t.cx??t.x??0,s=t.cy??t.y??0;e.beginPath(),e.arc(r,s,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function zn(e,t,n,o=.35){Wn(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}import{area as Bn,line as Ln}from"d3-shape";function On(e,t){const n=Pe(t.curve);if(!n||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}else{const o=Bn().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),o(t.topPath)}}var Hn=(e,t,n,o)=>{const r=t.filter(e=>"area"===e.type);for(const t of r){if(2>t.topPath.length)continue;let n=!1;t.clipRect&&(e.save(),e.beginPath(),e.rect(t.clipRect.x,t.clipRect.y,t.clipRect.width,t.clipRect.height),e.clip(),n=!0);const r=t._introClipFraction;void 0!==r&&1>r&&(e.save(),e.beginPath(),e.rect(0,0,o.width*r,o.height),e.clip());const s=Ce(e,t.style.fill,"#4e79a7"),i=t._decayOpacities;if(i&&i.length===t.topPath.length){const n=t.style.fillOpacity??.7;e.fillStyle=s;for(let o=0;t.topPath.length-1>o;o++)e.globalAlpha=.5*(i[o]+i[o+1])*n,e.beginPath(),e.moveTo(t.topPath[o][0],t.topPath[o][1]),e.lineTo(t.topPath[o+1][0],t.topPath[o+1][1]),e.lineTo(t.bottomPath[o+1][0],t.bottomPath[o+1][1]),e.lineTo(t.bottomPath[o][0],t.bottomPath[o][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=Qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(i[n]+i[n+1]),e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.stroke()}e.globalAlpha=1;continue}const a=t.style.opacity??1;if(On(e,t),t.fillGradient&&("colorStops"in t.fillGradient&&t.fillGradient.colorStops.length>=2||"topOpacity"in t.fillGradient)&&t.fillGradient){let n=1/0;for(const e of t.topPath)n>e[1]&&(n=e[1]);let o=-1/0;for(const e of t.bottomPath)e[1]>o&&(o=e[1]);const r=ce(e,t.fillGradient,"string"==typeof s?s:"#4e79a7",0,n,0,o);e.fillStyle=r||s,e.globalAlpha=a}else e.globalAlpha=(t.style.fillOpacity??.7)*a,e.fillStyle=s;if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(On(e,t),zn(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=a;const n=t.strokeGradient&&t.topPath.length>=2?le(e,t.strokeGradient,t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0):null;e.strokeStyle=n||Qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const o=Pe(t.curve);if(e.beginPath(),o)Ln().x(e=>e[0]).y(e=>e[1]).curve(o).context(e)(t.topPath);else{e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1])}e.stroke()}void 0!==r&&1>r&&e.restore(),n&&e.restore(),e.globalAlpha=1}},Fn=(e,t,n,o)=>{const r=t.filter(e=>"point"===e.type);if(0!==r.length){e.save();try{const t=e.globalAlpha;for(const n of r)e.beginPath(),e.arc(n.x,n.y,n.r,0,2*Math.PI),e.globalAlpha=t*(n.style.opacity??n.style.fillOpacity??1),e.fillStyle=Ce(e,n.style.fill,"#4e79a7"),e.fill(),n.style.stroke&&(e.strokeStyle=Ce(e,n.style.stroke,n.style.stroke),e.lineWidth=n.style.strokeWidth||1,e.stroke()),En(e,n)}finally{e.restore()}}},jn=new Map;function $n(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=jn.get(t);return n||(n=new Path2D(Ve(e.symbolType,e.size)),jn.size>256&&jn.clear(),jn.set(t,n)),n}catch{return null}}var Yn=(e,t)=>{const n=e.globalAlpha;for(const o of t){if("symbol"!==o.type)continue;const t=o;if(0>=t.size)continue;const r=$n(t);if(!r)continue;e.save(),e.translate(t.x,t.y),t.rotation&&e.rotate(t.rotation);const s=(t.style.opacity??1)*(t._decayOpacity??1);t.style.fill&&(e.globalAlpha=n*s*(t.style.fillOpacity??1),e.fillStyle=Ce(e,t.style.fill,"#4e79a7"),e.fill(r)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*s,e.strokeStyle=Ce(e,t.style.stroke,t.style.stroke),e.lineWidth=t.style.strokeWidth??1,e.stroke(r)),e.restore()}e.globalAlpha=n};function Xn(e,t,n,o,r){if(0>=t.size)return;const s=t.glyph;if(!s||!s.parts?.length)return;const i=Ye(s,t.size);if(0>=i.scale)return;const a=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=a)return;const l=t=>{const n=Ce(e,t,t);return"string"==typeof n?n:t},c=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(n,o),t.rotation&&e.rotate(t.rotation),e.translate(i.offsetX,i.offsetY),e.scale(i.scale,i.scale),e.globalAlpha=r*a*(t.style.fillOpacity??1);const u=je(s,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&Fe(e,s,c,t.accent,t.ghostColor,l),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),Fe(e,s,c,t.accent,void 0,l),e.restore()}function Vn(e,t){const{x:n,y:o,w:r,h:s}=t,{tl:i,tr:a,br:l,bl:c}=de(t);e.beginPath(),e.moveTo(n+i,o),e.lineTo(n+r-a,o),a>0&&e.arcTo(n+r,o,n+r,o+a,a),e.lineTo(n+r,o+s-l),l>0&&e.arcTo(n+r,o+s,n+r-l,o+s,l),e.lineTo(n+c,o+s),c>0&&e.arcTo(n,o+s,n,o+s-c,c),e.lineTo(n,o+i),i>0&&e.arcTo(n,o,n+i,o,i),e.closePath()}function Gn(e){switch(e.roundedEdge){case"bottom":return{x0:e.x,y0:e.y+e.h,x1:e.x,y1:e.y};case"right":return{x0:e.x+e.w,y0:e.y,x1:e.x,y1:e.y};case"left":return{x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y};default:return{x0:e.x,y0:e.y,x1:e.x,y1:e.y+e.h}}}var qn=(e,t,n,o)=>{const r=t.filter(e=>"rect"===e.type);for(const t of r){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)Un(e,t);else if(t.cornerRadii&&me(t.cornerRadii)){const n=Ce(e,t.style.fill,Qe(e,"var(--semiotic-primary, #007bff)")),o=Gn(t),r=t.fillGradient&&"string"==typeof n?ce(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;e.fillStyle=r||n,Vn(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else if(t.roundedTop&&t.roundedTop>0){const n=Ce(e,t.style.fill,Qe(e,"var(--semiotic-primary, #007bff)")),o=Gn(t),r=t.fillGradient&&"string"==typeof n?ce(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;e.fillStyle=r||n;const s=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:i,y:a,w:l,h:c}=t;switch(t.roundedEdge){case"right":e.moveTo(i,a),e.lineTo(i+l-s,a),e.arcTo(i+l,a,i+l,a+s,s),e.lineTo(i+l,a+c-s),e.arcTo(i+l,a+c,i+l-s,a+c,s),e.lineTo(i,a+c);break;case"left":e.moveTo(i+l,a),e.lineTo(i+s,a),e.arcTo(i,a,i,a+s,s),e.lineTo(i,a+c-s),e.arcTo(i,a+c,i+s,a+c,s),e.lineTo(i+l,a+c);break;case"bottom":e.moveTo(i,a),e.lineTo(i+l,a),e.lineTo(i+l,a+c-s),e.arcTo(i+l,a+c,i+l-s,a+c,s),e.lineTo(i+s,a+c),e.arcTo(i,a+c,i,a+c-s,s);break;default:e.moveTo(i,a+c),e.lineTo(i,a+s),e.arcTo(i,a,i+s,a,s),e.lineTo(i+l-s,a),e.arcTo(i+l,a,i+l,a+s,s),e.lineTo(i+l,a+c)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else{const n=Ce(e,t.style.fill,Qe(e,"var(--semiotic-primary, #007bff)")),o=Gn(t),r=t.fillGradient&&"string"==typeof n?ce(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;e.fillStyle=r||n,e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))}Dn(e,t),e.globalAlpha=1}};function Un(e,t){const n=t.style.icon,o=t.style.iconPadding||2,r=Math.min(t.w,t.h)-o;if(0>=r)return;const s=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),s){const s=r+o,i=t.x+(t.w-r)/2;for(let o=t.y+t.h-r;o>=t.y-r;o-=s)e.drawImage(n,i,o,r,r)}else{const s=r+o,i=t.y+(t.h-r)/2;for(let o=t.x;t.x+t.w>o;o+=s)e.drawImage(n,o,i,r,r)}e.restore()}function Qn(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>128?"#000":"#fff"}function Kn(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}var Zn=(e,t,n,o)=>{const r=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of r){const n=t.style;if(null!=n?.opacity&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle=Qe(e,"var(--semiotic-surface, #fff)"),e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),Dn(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const n=t.valueFormat?t.valueFormat(t.value):Kn(t.value),o=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),r=t.x+t.w/2,s=t.y+t.h/2;e.fillStyle=Qn(t.fill),e.font=o+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,r,s)}}}finally{e.restore()}},Jn=(e,t,n,o)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const r=(t._decayOpacity??1)*(t.style?.opacity??1);1!==r&&(e.globalAlpha=r);const s=Qe(e,t.wickColor)||t.wickColor,i=60>o.height,a=i?Math.max(t.wickWidth,2):t.wickWidth,l=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=s,e.lineWidth=a,e.stroke()};if(i||l(),t.isRange){const n=Math.max(2,Math.min(t.bodyWidth/2,.12*o.height));e.fillStyle=s,e.beginPath(),e.arc(t.x,t.highY,n,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,n,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const n=Math.min(t.openY,t.closeY),o=Math.abs(t.openY-t.closeY),r=t.isUp?t.upColor:t.downColor,s=Qe(e,r)||r;e.fillStyle=s,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1)),e.strokeStyle=s,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1))}i&&l(),e.restore()}},eo={line:[Hn,In,Fn],area:[Hn,Fn],stackedarea:[Hn,Fn],scatter:[Fn,Yn],bubble:[Fn,Yn],heatmap:[Zn],bar:[qn],swarm:[Fn],waterfall:[(e,t,n,o)=>{qn(e,t);const r=t.filter(e=>"rect"===e.type);if(2>r.length)return;const s=r[0].datum,i=s?._connectorStroke;if(i){e.save(),e.strokeStyle=Qe(e,i)||i,e.lineWidth=s?._connectorWidth??1,e.setLineDash([]);for(let t=0;r.length-1>t;t++){const o=r[t],s=r[t+1],i=o.datum,a=s.datum;if(null==i?.cumEnd||null==a?.baseline)continue;const l=n.y(i.cumEnd),c=o.x+o.w,u=s.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[Jn],mixed:[Hn,In,Fn],custom:[Hn,qn,Zn,In,Fn,Yn,(e,t)=>{const n=e.globalAlpha;for(const o of t)"glyph"===o.type&&Xn(e,o,o.x,o.y,n);e.globalAlpha=n},Jn]};import{jsx as to,jsxs as no}from"react/jsx-runtime";import{jsx as oo,jsxs as ro}from"react/jsx-runtime";function so(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function io({hover:e}){const t=e.data??{},n=t.y??t.value,o=t.x??t.time;if(void 0===n&&void 0===o){const e=O(t);if(null!=e.title||e.entries.length>0)return ro("div",{className:"semiotic-tooltip",style:z,children:[null!=e.title&&oo("div",{style:{fontWeight:600,marginBottom:e.entries.length?2:0},children:e.title+""}),e.entries.map(e=>ro("div",{style:{opacity:.7,fontSize:11},children:[e.key,":"," ",oo("span",{style:{fontWeight:600},children:so(e.value)})]},e.key))]})}return ro("div",{className:"semiotic-tooltip",style:z,children:[oo("div",{style:{fontWeight:600,marginBottom:2},children:so(n)}),oo("div",{style:{opacity:.7,fontSize:11},children:so(o)})]})}io.ownsChrome=!0;import{useCallback as ao}from"react";import{useCallback as lo,useRef as co}from"react";function uo(e){const t=new Map;for(const n of e){const e=n.group??"_default";let o=t.get(e);o||(o=[],t.set(e,o)),o.push(n)}for(const e of t.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const n=Array.from(t.keys()).sort((e,n)=>{const o=t.get(e),r=t.get(n);return(o.length>0?o[0].y:0)-(r.length>0?r[0].y:0)}),o=Array.from(t.values()).flat();o.sort((e,t)=>e.x-t.x||e.y-t.y);const r=new Map;for(let e=0;o.length>e;e++){o[e]._flatIndex=e;const t=o[e].datum?.id;null!=t&&r.set(t+"",e)}return{flat:o,groups:n,byGroup:t,idToIdx:r}}function ho(e,t){if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const n=Math.max(0,Math.min(t,e.flat.length-1)),o=e.flat[n];return{flatIndex:n,group:o.group??"_default",indexInGroup:o._groupIndex??0}}function po(e,t,n){const{group:o,indexInGroup:r}=t,s=n.byGroup.get(o);switch(e){case"ArrowRight":return s.length-1>r?s[r+1]._flatIndex:t.flatIndex;case"ArrowLeft":return r>0?s[r-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(o);return n.groups.length-1>e?fo(n,n.groups[e+1],s[r]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(o);return e>0?fo(n,n.groups[e-1],s[r]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function fo(e,t,n){const o=e.byGroup.get(t);let r=0,s=Math.abs(o[0].x-n.x);for(let e=1;o.length>e;e++){const t=Math.abs(o[e].x-n.x);s>t&&(s=t,r=e)}return o[r]._flatIndex}function yo(e){const t=[];for(const n of e)switch(n.type){case"point":t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"symbol":if(0>=n.size)break;t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"glyph":{if(0>=n.size||null==n.datum)break;const e=$e(n.glyph,n.size);t.push({x:n.x+e.centerDx,y:n.y+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:"_default"});break}case"line":{const e=n,o=Array.isArray(e.datum)?e.datum:[],r=e.group??"_default";for(let n=0;e.path.length>n&&o.length>n;n++)t.push({x:e.path[n][0],y:e.path[n][1],datum:o[n],shape:"circle",group:r});break}case"area":{const e=n,o=Array.isArray(e.datum)?e.datum:[],r=e.group??"_default";for(let n=0;e.topPath.length>n&&o.length>n;n++)t.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:o[n],shape:"circle",group:r});break}case"rect":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.group??"_default"});break;case"heatcell":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}function go(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}import{jsx as mo,jsxs as vo}from"react/jsx-runtime";var xo={top:20,right:20,bottom:30,left:40},bo=xn;function ko(e){if(e)return"x"===e.dimension?"pan-y":"y"===e.dimension?"pan-x":"none"}var wo=at(it(function(e,t){const{chartType:n,runtimeMode:o,data:r,chunkThreshold:s,chunkSize:i,xAccessor:a,yAccessor:l,accessorRevision:y,colorAccessor:b,sizeAccessor:k,symbolAccessor:S,symbolMap:_,groupAccessor:T,lineDataAccessor:C,curve:P,normalize:D,baseline:z,stackOrder:O,binSize:H,valueAccessor:j,arrowOfTime:$="right",windowMode:Y="sliding",windowSize:X=200,timeAccessor:V,xExtent:q,yExtent:U,extentPadding:Z=.1,scalePadding:J,sizeRange:ee,size:te=[500,300],responsiveWidth:ne,responsiveHeight:oe,margin:re,className:se,background:ie,renderMode:ae,lineStyle:le,pointStyle:ce,areaStyle:ue,barStyle:de,waterfallStyle:he,swarmStyle:pe,barColors:me,colorScheme:be,boundsAccessor:ke,boundsStyle:we,y0Accessor:Ae,band:Se,gradientFill:_e,lineGradient:Ce,areaGroups:Pe,openAccessor:Re,highAccessor:Me,lowAccessor:Ne,closeAccessor:Ie,candlestickStyle:We,showAxes:De=!0,axes:Ee,xLabel:Be,yLabel:Le,yLabelRight:Oe,xFormat:He,yFormat:Fe,axisExtent:je,tickFormatTime:$e,tickFormatValue:Ye,hoverAnnotation:Xe,tooltipContent:Ve,customHoverBehavior:Ge,customClickBehavior:qe,onObservation:Qe,annotationObservationCallback:it,chartId:at,enableHover:lt,hoverRadius:ct=30,tooltipMode:ut,annotations:dt,onAnnotationActivate:ft,autoPlaceAnnotations:gt,svgAnnotationRules:mt,showGrid:bt,legend:kt,legendHoverBehavior:wt,legendClickBehavior:Tt,legendHighlightedCategory:Ct,legendIsolatedCategories:Pt,legendPosition:Rt,legendLayout:Mt,legendCategoryAccessor:Nt,onCategoriesChange:It,backgroundGraphics:Wt,foregroundGraphics:Dt,canvasPreRenderers:zt,svgPreRenderers:Bt,title:Lt,categoryAccessor:Ot,brush:jt,onBrush:Yt,decay:Xt,pulse:Vt,transition:Gt,animate:qt,staleness:Ut,frameScheduler:Qt,clock:Kt,random:Zt,seed:Jt,paused:en=!1,suspendWhenHidden:tn=!0,heatmapAggregation:nn,heatmapXBins:on,heatmapYBins:rn,showValues:sn,heatmapValueFormat:an,marginalGraphics:cn,pointIdAccessor:un,xScaleType:hn,yScaleType:fn,accessibleTable:yn=!0,description:gn,summary:_n,linkedCrosshairName:Tn,linkedCrosshairSourceId:Rn,customLayout:Mn,onLayoutError:Nn,layoutConfig:In,layoutSelection:Wn}=e,{customHoverBehavior:Dn,customClickBehavior:En,hasClickBehavior:zn}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:o,chartType:r}){return{customHoverBehavior:ao((t,s)=>{e?.(t,s),ye({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:r,chartId:o,context:s})},[o,r,e,n]),customClickBehavior:ao((e,s)=>{t?.(e,s),fe({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:r,chartId:o,context:s})},[o,r,t,n]),hasClickBehavior:!(!t&&!n)}}({customHoverBehavior:Ge,customClickBehavior:qe,onObservation:Qe,chartId:at,chartType:"StreamXYFrame"}),Bn=st().replace(/:/g,""),Ln=Je(!1),On=Je({w:-1,h:-1}),Hn=Je(!1),Fn=R({sizeProp:te,responsiveWidth:ne,responsiveHeight:oe,userMargin:re,marginDefault:xo,title:Lt,legend:kt,legendPosition:Rt,animate:qt,transitionProp:Gt,frameScheduler:Qt,clock:Kt,random:Zt,seed:Jt,paused:en,suspendWhenHidden:tn,themeDirtyRef:Ln}),jn=N(),$n=W(),{reducedMotionRef:Yn,responsiveRef:Xn,size:Vn,currentTheme:Gn,transition:qn,introEnabled:Un,tableId:Qn,rafRef:Kn,renderFnRef:Zn,scheduleRender:Jn,frameRuntime:to}=Fn;let no=Fn.margin;if(cn){const e=60,t={...Fn.margin};cn.top&&e>t.top&&(t.top=e),cn.bottom&&e>t.bottom&&(t.bottom=e),cn.left&&e>t.left&&(t.left=e),cn.right&&e>t.right&&(t.right=e),no=t}const oo=Vn[0]-no.left-no.right,ro=Vn[1]-no.top-no.bottom,so=nt(()=>ge(r),[r]),fo=Xe??lt,[go,wo]=et(0),Ao=Je(0),[So,_o]=et(null),To=kn(Dt,Vn,no,So),Co=kn(Wt,Vn,no,So),Po=Je(null),Ro=Je(null),Mo=Je(void 0),[No,Io]=et(null),Wo=Je(bo.primary),Do=Je(function(){let e=-1,t=xn;return{resolve(n){if(!n)return xn;const o=Ue();return o===e||(t=function(e){if(!e)return xn;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),r=t.getPropertyValue("--semiotic-bg").trim(),s=t.getPropertyValue("--semiotic-primary").trim(),i=o||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),l=n||t.getPropertyValue("--surface-3").trim(),c=r||t.getPropertyValue("--surface-0").trim();return i||a||n||s?{axisStroke:l||xn.axisStroke,tickText:i||xn.tickText,crosshair:i?bn(i,"66"):xn.crosshair,hoverFill:c?bn(c,"4D"):xn.hoverFill,hoverStroke:i?bn(i,"99"):xn.hoverStroke,pointRing:c||xn.pointRing,primary:s||xn.primary,background:c||xn.background}:xn}(n),e=o),t},invalidate(){e=-1}}}()),Eo=Je(!1),zo=I("StreamXYFrame"),[Bo,Lo]=et(!1),[Oo,Ho]=et([]),[Fo,jo]=et([]),$o="streaming"===o||["bar","swarm","waterfall"].includes(n),Yo=pn(nt(()=>({chartType:n,runtimeMode:$o?"streaming":"bounded",windowSize:X,windowMode:Y,arrowOfTime:$o?$:"right",extentPadding:Z,scalePadding:J,axisExtent:je,xAccessor:a,yAccessor:l,accessorRevision:y,timeAccessor:$o?V:void 0,valueAccessor:j,colorAccessor:b,sizeAccessor:k,symbolAccessor:S,symbolMap:_,groupAccessor:T||(C?"_lineGroup":void 0),categoryAccessor:Ot,lineDataAccessor:C,xScaleType:hn,yScaleType:fn,xExtent:q,yExtent:U,sizeRange:ee,binSize:H,normalize:D,baseline:z,stackOrder:O,boundsAccessor:ke,boundsStyle:we,y0Accessor:Ae,band:Se,gradientFill:!0===_e?{topOpacity:.8,bottomOpacity:.05}:!1===_e?void 0:_e,areaGroups:Pe?new Set(Pe):void 0,lineGradient:Ce,openAccessor:Re,highAccessor:Me,lowAccessor:Ne,closeAccessor:Ie,candlestickStyle:We,lineStyle:le,pointStyle:ce,areaStyle:ue,swarmStyle:pe,waterfallStyle:he,colorScheme:be,barColors:me,barStyle:de,annotations:dt,decay:Xt,pulse:Vt,transition:qn,introAnimation:Un,staleness:Ut,clock:to.now,heatmapAggregation:nn,heatmapXBins:on,heatmapYBins:rn,showValues:sn,heatmapValueFormat:an,pointIdAccessor:un,curve:P,themeCategorical:Gn?.colors?.categorical,themeSemantic:Ke(Gn),themeSequential:Gn?.colors?.sequential,themeDiverging:Gn?.colors?.diverging,customLayout:Mn,onLayoutError:Nn,layoutConfig:In,layoutMargin:no}),[n,$o,X,Y,$,Z,J,je,a,l,y,V,j,b,k,S,_,T,C,Ot,hn,fn,q,U,ee,H,D,z,O,ke,we,Ae,Se,_e,Pe,Ce,Re,Me,Ne,Ie,We,le,ce,ue,pe,he,be,me,de,dt,Xt,Vt,qn,Un,Ut,to.now,nn,on,rn,sn,an,un,P,Gn,Mn,Nn,In,no])),Xo=Je(null);Xo.current||(Xo.current=new F(Yo));const Vo=function(e,t,n,o){const r=An({accessor:t,onChange:n,readData:o}),s=An([]);return r.current={accessor:t,onChange:n,readData:o},wn(()=>{const{accessor:t,onChange:n,readData:o}=r.current;if(!n||!t)return;const i=function(e,t){if(!t)return[];const n=new Set,o=[];for(const r of e){if(!r||"object"!=typeof r)continue;const e="function"==typeof t?t(r):r[t];if(null==e)continue;const s=e+"";n.has(s)||(n.add(s),o.push(s))}return o}(e.current?o(e.current):[],t);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(i,s.current)||(s.current=i,n(i))},[e])}(Xo,Nt,It,e=>e.getData());vt(Xo,Yo,Ln,Jn),xt(Xo,Wn,Ln,Jn);const Go=Je(null);Go.current||(Go.current=new pt(e=>{const t=Xo.current;t&&t.ingest(e)&&(Ln.current=!0,Jn())},{chunkThreshold:s,chunkSize:i})),tt(()=>{Go.current?.updateChunkOptions({chunkThreshold:s,chunkSize:i})},[s,i]);const qo=ot(e=>{Go.current?.push(e)},[]),Uo=ot(e=>{Go.current?.pushMany(e)},[]),Qo=ot(()=>{Go.current?.clear(),Xo.current?.clear(),Ln.current=!0,Jn()},[Jn]);rt(t,()=>({push:qo,pushMany:Uo,remove:e=>{Go.current?.flush();const t=Xo.current?.remove(e)??[];return t.length>0&&(Po.current&&t.some(e=>e===Po.current?.data)&&(Po.current=null,Io(null)),Ln.current=!0,Jn()),t},update:(e,t)=>{Go.current?.flush();const n=Xo.current?.update(e,t)??[];return n.length>0&&(Ln.current=!0,Jn()),n},clear:Qo,getData:()=>(Go.current?.flush(),Xo.current?.getData()??[]),getScales:()=>Xo.current?.scales??null,getExtents:()=>Xo.current?.getExtents()??null,getCustomLayout:()=>Xo.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Xo.current?.lastCustomLayoutFailure??null}),[qo,Uo,Qo,Jn]),tt(()=>{if(r){if(C&&so.length>0&&"object"==typeof so[0]&&null!==so[0]){const e="string"==typeof C?C:"coordinates";if(Array.isArray(so[0][e])){const t=[];for(const n of so){const o=n[e];if(Array.isArray(o)){const e=n.label||n.id||n.key;if(null!=e)for(const n of o)t.push({...n,_lineGroup:e});else for(const e of o)t.push(e)}}return void Go.current?.setBoundedData(t)}}Go.current?.setBoundedData(so)}},[r,so,C]);const{canvasRef:Ko,interactionCanvasRef:Zo}=M(Fn,{storeRef:Xo,dirtyRef:Ln,hydrated:jn,wasHydratingFromSSR:$n,cleanup:()=>Go.current?.clear(),canvasPaintDependencies:[n,oo,ro,De,ie,Wt,le,ae,zt,Jn]}),{hoverHandlerRef:Jo,hoverLeaveRef:er,onPointerMove:tr,onPointerLeave:nr}=Fn;Jo.current=e=>{if(!fo)return;const t=Ko.current;if(!t)return;const o=t.getBoundingClientRect(),r=e.clientX-o.left-no.left,s=e.clientY-o.top-no.top;if(0>r||r>oo||0>s||s>ro)return void(Po.current&&(Po.current=null,Ro.current=null,Io(null),Dn&&(Dn(null),Ln.current=!0),Jn()));const i=Xo.current;if(!i||0===i.scene.length)return;const l=B(ct,e.pointerType),c=St(i.scene,r,s,l,i.quadtree,i.maxPointRadius),u="multi"===ut,d=()=>{Po.current&&(Po.current=null,Ro.current=null,Io(null),Dn&&Dn(null),Jn())};if(!c&&!u)return void d();const h=u||!c?r:c.x,p=u||!c?s:c.y,f=c?.datum?G(c.datum,i.resolvedRibbons):{},y=i.scales?.x?.invert,g="function"==typeof y?y(h):void 0;let m=E(f,h,p,null!=g?{xValue:g,xPx:h}:void 0);if(u&&i.scene.length>0&&i.scales){const e=function(e,t,n=30){const o=[];for(const r of e)if("line"===r.type){const e=r;if(2>e.path.length)continue;const s=_t(At(e.path,e.curve),t,n);if(null===s)continue;const i=Et(e.path,t);o.push({node:r,datum:Array.isArray(e.datum)&&e.datum[i]?e.datum[i]:e.datum,x:e.path[i][0],y:s,group:e.group,color:e.style.stroke})}else if("area"===r.type){const e=r;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const s=At(e.topPath,e.curve),i=At(e.bottomPath,e.curve),a=_t(s,t,n);if(null===a)continue;const l=_t(i,t,n),c=Et(e.topPath,t);o.push({node:r,datum:Array.isArray(e.datum)&&e.datum[c]?e.datum[c]:e.datum,x:e.topPath[c][0],y:a,y0:l??void 0,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return o}(i.scene,h,Math.max(l,oo));if(e.length>0){const t=i.scales.y.invert,o=Wo.current,r=y?y(h):h;if(c)m.xValue=r,m.xPx=h;else{const e={xValue:r};"string"==typeof a&&(e[a]=r),m=E(e,h,p,{xValue:r,xPx:h})}m.allSeries=e.map(e=>{const r=t?t(e.y):e.y,s=null!=e.y0?t?t(e.y0):e.y0:void 0;return{group:e.group||"",value:"stackedarea"===n&&null!=s?r-s:r,valuePx:e.y,color:e.color||o,datum:G(e.datum,i.resolvedRibbons)}})}}c||m.allSeries?.length?(Po.current=m,Ro.current=c?.node??null,Io(m),Dn&&(Dn(m),Ln.current=!0),Jn()):d()},er.current=()=>{Po.current&&(Po.current=null,Ro.current=null,Io(null),Dn&&(Dn(null),Ln.current=!0),Jn())};const or=Je(()=>{});or.current=e=>{if(L(e.target))return;if(!En)return;const t=Ko.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-no.left,r=e.clientY-n.top-no.top;if(0>o||o>oo||0>r||r>ro)return void En(null);const s=Xo.current;if(!s||0===s.scene.length)return void En(null);const i=B(ct,Mo.current),a=St(s.scene,o,r,i,s.quadtree,s.maxPointRadius);if(!a)return void En(null);const l=a.datum||{},c=s.scales?.x?.invert,u="function"==typeof c?c(a.x):void 0;En(E(l,a.x,a.y,null!=u?{xValue:u,xPx:a.x}:void 0),{type:"activate",inputType:Te(Mo.current)})};const rr=ot(e=>or.current(e),[]),{kbFocusIndexRef:sr,focusedNavPointRef:ir,onKeyDown:ar}=(dr={storeRef:Xo,hoverRef:Po,hoveredNodeRef:Ro,setHoverPoint:Io,customHoverBehavior:Dn,customClickBehavior:En,scheduleRender:Jn},function({storeRef:e,hoverRef:t,hoveredNodeRef:n,setHoverPoint:o,customHoverBehavior:r,customClickBehavior:s,scheduleRender:i,extractPoints:a,toHover:l}){const c=co(-1),u=co(null),d=co(null),h=lo(h=>{if(ve(h))return;const p=e.current;if(!p)return;const f=()=>{c.current=-1,u.current=null,t.current=null,n&&(n.current=null),o(null),r(null),i()};if(0===p.scene.length)return void(0>c.current||f());let y;if(d.current?.version===p.version)y=d.current.graph;else{const e=a(p.scene);if(0===e.length)return void(0>c.current||f());y=uo(e),d.current={version:p.version,graph:y}}let g=c.current;if(y.flat.length>g||(f(),g=-1),("Enter"===h.key||" "===h.key)&&g>=0)return h.preventDefault(),void s(l(y.flat[g],p),{type:"activate",inputType:"keyboard"});if(0>g){if("Escape"===h.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(h.key))return;h.preventDefault(),c.current=0;const e=y.flat[0];u.current=e;const n=l(e,p);return t.current=n,o(n),r(n,{type:"focus",inputType:"keyboard"}),void i()}const m=po(h.key,ho(y,g),y);if(null===m)return;if(h.preventDefault(),0>m)return void f();c.current=m;const v=y.flat[m];u.current=v;const x=l(v,p);t.current=x,o(x),r(x,{type:"focus",inputType:"keyboard"}),i()},[s,r,a,t,n,i,o,e,l]);return{kbFocusIndexRef:c,focusedNavPointRef:u,onKeyDown:h}}({...dr,extractPoints:yo,toHover:(e,t)=>function(e){return{data:e.datum||{},x:e.x,y:e.y,__semioticHoverData:!0}}({...e,datum:G(e.datum,t.resolvedRibbons)})})),lr=ot(e=>{Mo.current=e.pointerType,sr.current=-1,ir.current=null,tr(e)},[ir,sr,tr]),cr=ot(e=>{Mo.current="mouse",sr.current=-1,ir.current=null,tr({clientX:e.clientX,clientY:e.clientY,pointerType:"mouse"})},[ir,sr,tr]),ur=ot(e=>{Mo.current=e.pointerType},[]);var dr;Zn.current=()=>{if(Kn.current=null,!to.isActive)return;const e=Ko.current,t=Zo.current;if(!e||!t)return;const o=Xo.current;if(!o)return;const r=to.now(),s=o.advanceTransition(Yn.current?r+1e6:r),i=!Yn.current&&s,c=On.current.w!==oo||On.current.h!==ro,u=Ln.current||s||c,d=o.consumeStylePaintPending();let h=!1;const p=o.getLastUpdateResult(),f=zo.current.beforeCompute(p,i);!u||i&&!c||(o.computeScene({width:oo,height:ro}),On.current={w:oo,h:ro},h=!0,Vo()),zo.current.afterCompute(f,h,c);const y=function(e,t,n,o){const r=o.current,s=!0===e.lastCustomLayoutFailure?.preservedLastGoodScene,i=!s&&e.hasActivePulsesAt(t),a=!(n||s||!i&&!r)&&e.refreshPulse(t);return o.current=i,{changed:a,pending:i}}(o,r,h,Hn),g=w(),m=Do.current.resolve(e);Wo.current=m.primary;const v=Ht(Ut,o.lastIngestTime>0?r-o.lastIngestTime:0),b=Ut&&v.isStale;if(u||d||y.changed){const t=A(e,Vn,no,g);if(t){if(t.clearRect(-no.left,-no.top,Vn[0],Vn[1]),Ut&&1>v.alpha&&(t.globalAlpha=v.alpha),vn(t,{background:ie,hasBackgroundGraphics:!!Wt,themeBackground:m.background,x:-no.left,y:-no.top,width:Vn[0],height:Vn[1]}),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,oo,ro),t.clip()),zt&&o.scales)for(const e of zt)t.save(),e(t,o.scene,o.scales,{width:oo,height:ro}),t.restore();const e=Mn?eo.custom:eo[n];Q({context:t,nodes:o.scene,renderMode:ae,pixelRatio:g,paintBuiltIn:n=>{if(e&&o.scales)for(const r of e)r(t,n,o.scales,{width:oo,height:ro})}}),t.restore(),Ut&&1>v.alpha&&(t.globalAlpha=1)}}const k=!!(fo&&Po.current&&o.scales),S=!!(Ro.current&&Array.isArray(Xe)&&Xe.some(e=>e&&"object"==typeof e&&"highlight"===e.type)),_=k||S;if(_||Eo.current){const e=A(t,Vn,no,g);if(e&&(e.clearRect(-no.left,-no.top,Vn[0],Vn[1]),k&&Po.current&&function(e,t,n,o,r,s,i){if(!1===r.crosshair)return;const a=t.allSeries,l=a&&a.length>0,c=t.xPx??t.x;e.save();const u="object"==typeof r.crosshair?r.crosshair:{};if(e.strokeStyle=u.stroke||i.crosshair,e.lineWidth=u.strokeWidth||1,e.setLineDash(u.strokeDasharray?u.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(l?c:t.x,0),e.lineTo(l?c:t.x,o),e.stroke(),l||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),l){e.lineWidth=2,e.strokeStyle=i.pointRing;for(const t of a)null!=t.valuePx&&(e.beginPath(),e.arc(c,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||i.primary,e.fill(),e.stroke())}else{const n=r.pointColor||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const n="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||n||null:n||t.stroke||null}(s)||i.primary;e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=n,e.fill(),e.strokeStyle=i.pointRing,e.lineWidth=2,e.stroke()}}(e,Po.current,oo,ro,"object"==typeof fo?fo:{},Ro.current,m),S&&Ro.current&&Array.isArray(Xe))){const t=Xe.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,o,r){if(!n)return;const s="group"in n?n.group:void 0;if(void 0!==s)for(const n of t){if("line"!==n.type)continue;if(n.group!==s)continue;if(2>n.path.length)continue;const t="function"==typeof o.style?n.datum?o.style(n.datum):{}:o.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||r.primary,e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=t.opacity??1,e.stroke(),e.restore()}}(e,o.scene,Ro.current,t,m)}Eo.current=_}u&&e&&e.setAttribute("aria-label",x(o.scene,n+" chart"));const T=Ln.current;if(Ln.current=T&&i&&!h,T&&o.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!So||e(So.x.domain()[0])!==e(o.scales.x.domain()[0])||e(So.x.domain()[1])!==e(o.scales.x.domain()[1])||e(So.y.domain()[0])!==e(o.scales.y.domain()[0])||e(So.y.domain()[1])!==e(o.scales.y.domain()[1])||So.x.range()[0]!==o.scales.x.range()[0]||So.x.range()[1]!==o.scales.x.range()[1]||So.y.range()[0]!==o.scales.y.range()[0]||So.y.range()[1]!==o.scales.y.range()[1])&&_o(o.scales),cn){const e=o.getData(),t="function"==typeof a?a:e=>e[a||"x"],n="function"==typeof l?l:e=>e[l||"y"];Ho(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),jo(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}!((dt&&dt.length>0||Mn)&&(h||i))||!h&&33>r-Ao.current||(wo(e=>e+1),Ao.current=r),Ut?.showBadge&&Lo(!!b),(i||null!=o.activeTransition||y.pending)&&Jn()},Ft(Ut,Xo,Ln,Jn,Bo,Lo);const hr=nt(()=>{if(He||$e)return;const e=Xo.current;return e?.xIsDate&&So?Cn(So.x.domain()):void 0},[He,$e,So]),pr=He||$e||hr,fr=fo&&No?Ve?Ve(No):mo(io,{hover:No}):null,yr=fr?mo(p,{x:No.x,y:No.y,containerWidth:oo,containerHeight:ro,margin:no,className:"stream-frame-tooltip",children:fr}):null,gr=ir.current,mr=mo(f,{active:sr.current>=0,hoverPoint:No,margin:no,size:Vn,shape:gr?.shape,width:gr?.w,height:gr?.h}),vr=Sn(a,V,"__semiotic_resolvedX","__semiotic_resolvedTime"),xr=Sn(l,j,"__semiotic_resolvedY","__semiotic_resolvedValue"),br=vr.key,kr=xr.key,wr=function(e,t,n){return o=>{if(!o||!n||!e.fn&&!t.fn)return o;let r=!1;const s=o.map(n=>{const o=e.fn&&e.key&&!(e.key in n),s=t.fn&&t.key&&!(t.key in n);if(!o&&!s)return n;r=!0;const i={...n};return o&&(i[e.key]=e.fn(n)),s&&(i[t.key]=t.fn(n)),i});return r?s:o}}(vr,xr,dt&&dt.length>0||!1);if(xe||!jn&&$n){const e=Xo.current;e&&r&&(e.ingest({inserts:so,bounded:!0}),e.computeScene({width:oo,height:ro}));const t=e?.scene??[],n=e?.scales??null,o=kn(Dt,Vn,no,n),s=kn(Wt,Vn,no,n),i=pr||(()=>{if(e?.xIsDate&&n)return Cn(n.x.domain())})();return vo("div",{ref:Xn,className:"stream-xy-frame"+(se?" "+se:""),role:"img","aria-label":gn||("string"==typeof Lt?Lt:"XY chart"),style:{position:"relative",width:ne?"100%":Vn[0],height:oe?"100%":Vn[1]},children:[mo(m,{summary:_n}),vo("svg",{xmlns:"http://www.w3.org/2000/svg",width:Vn[0],height:Vn[1],style:{position:"absolute",left:0,top:0},children:[mo("g",{transform:`translate(${no.left},${no.top})`,children:s}),vo("g",{transform:`translate(${no.left},${no.top})`,children:[ie&&mo("rect",{x:0,y:0,width:oo,height:ro,fill:ie}),Bt&&n&&Bt.map((e,o)=>mo(Ze.Fragment,{children:e(t,n,{width:oo,height:ro})},"svgpre-"+o)),t.map((e,t)=>K({node:e,index:t,renderMode:ae,fallback:()=>ze(e,t,Bn)})).filter(Boolean)]})]}),mo(dn,{width:oo,height:ro,totalWidth:Vn[0],totalHeight:Vn[1],margin:no,scales:n,showAxes:De,axes:Ee,xLabel:Be,yLabel:Le,yLabelRight:Oe,xFormat:i,yFormat:Fe||Ye,axisExtent:je,showGrid:bt,title:Lt,legend:kt,legendHoverBehavior:wt,legendClickBehavior:Tt,legendHighlightedCategory:Ct,legendIsolatedCategories:Pt,legendPosition:Rt,legendLayout:Mt,foregroundGraphics:yt(o,c(Xo.current?.customLayoutOverlays,Wn??null)),marginalGraphics:cn,xValues:[],yValues:[],annotations:dt,onAnnotationActivate:ft,onObservation:it??Qe,chartId:at,chartType:"StreamXYFrame",autoPlaceAnnotations:gt,svgAnnotationRules:mt,annotationFrame:0,xAccessor:br,yAccessor:kr,annotationData:wr(Xo.current?.getData()),pointNodes:Pn(Xo.current?.scene),curve:"string"==typeof P?P:void 0,linkedCrosshairName:Tn,linkedCrosshairSourceId:Rn})]})}return vo("div",{ref:Xn,className:"stream-xy-frame"+(se?" "+se:""),role:"group","aria-label":gn||("string"==typeof Lt?Lt:"XY chart"),tabIndex:0,style:{position:"relative",width:ne?"100%":Vn[0],height:oe?"100%":Vn[1],overflow:"visible",touchAction:ko(jt)},onKeyDown:ar,children:["production"!==process.env.NODE_ENV&&Xo.current&&mo(g,{store:Xo.current,diagnostics:zo.current}),yn&&mo(v,{tableId:Qn}),yn&&mo(u,{scene:Xo.current?.scene??[],chartType:n+" chart",tableId:Qn,chartTitle:"string"==typeof Lt?Lt:void 0}),mo(m,{summary:_n}),mo(d,{hoverPoint:No}),vo("div",{role:"img","aria-label":gn||("string"==typeof Lt?Lt:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:fo?lr:void 0,onMouseMove:fo?cr:void 0,onPointerLeave:fo?nr:void 0,onMouseLeave:fo?nr:void 0,onPointerDown:fo||zn?ur:void 0,onClick:zn?rr:void 0,children:[mo(h,{size:Vn,margin:no,children:Co}),mo(ln,{width:oo,height:ro,totalWidth:Vn[0],totalHeight:Vn[1],margin:no,scales:So,showAxes:De,axes:Ee,showGrid:bt,xFormat:pr,yFormat:Fe||Ye,axisExtent:je}),mo("canvas",{ref:Ko,"aria-label":x(Xo.current?.scene??[],n+" chart"),style:{position:"absolute",left:0,top:0}}),mo("canvas",{ref:Zo,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),mo(dn,{width:oo,height:ro,totalWidth:Vn[0],totalHeight:Vn[1],margin:no,scales:So,showAxes:De,axes:Ee,xLabel:Be,yLabel:Le,yLabelRight:Oe,xFormat:pr,yFormat:Fe||Ye,axisExtent:je,showGrid:bt,title:Lt,legend:kt,legendHoverBehavior:wt,legendClickBehavior:Tt,legendHighlightedCategory:Ct,legendIsolatedCategories:Pt,legendPosition:Rt,legendLayout:Mt,foregroundGraphics:yt(To,c(Xo.current?.customLayoutOverlays,Wn??null)),marginalGraphics:cn,xValues:Oo,yValues:Fo,annotations:dt,onAnnotationActivate:ft,onObservation:it??Qe,chartId:at,chartType:"StreamXYFrame",autoPlaceAnnotations:gt,svgAnnotationRules:mt,annotationFrame:go,xAccessor:br,yAccessor:kr,annotationData:wr(Xo.current?.getData()),pointNodes:Pn(Xo.current?.scene),curve:"string"==typeof P?P:void 0,underlayRendered:!0,canvasObscuresUnderlay:!!mn({background:ie,hasBackgroundGraphics:!!Wt,themeBackground:Gn?.colors.background}),linkedCrosshairName:Tn,linkedCrosshairSourceId:Rn}),(jt||Yt)&&mo(ht,{width:oo,height:ro,totalWidth:Vn[0],totalHeight:Vn[1],margin:no,dimension:jt?.dimension??"xy",scales:So,onBrush:Yt??(()=>{}),binSize:H,snap:jt?.snap,binBoundaries:jt?.binBoundaries??("bar"===n?Xo.current?.getBinBoundaries():void 0),snapDuring:jt?.snapDuring,streaming:"streaming"===o}),Ut?.showBadge&&mo($t,{isStale:Bo,position:Ut.badgePosition}),mr,yr]})]})}));wo.displayName="StreamXYFrame";var Ao=wo;import{useRef as So,useState as _o,useEffect as To,useMemo as Co,useCallback as Po,useImperativeHandle as Ro,forwardRef as Mo,memo as No}from"react";var Io={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Wo={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1},Do=class{constructor(e){this.capacity=e,this.particles=Array(e),this._freeIndices=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[t]=e-1-t}spawn(e,t=Math.random){const n=this._freeIndices.pop();if(void 0===n)return null;const o=this.particles[n];return o.active=!0,o.t=0,o.offset=t()-.5,o.edgeIndex=e,o.x=0,o.y=0,o}step(e,t,n,o){for(let r=0;this.capacity>r;r++){const s=this.particles[r];if(!s.active)continue;const i=n[s.edgeIndex];i&&i.bezier?(s.t+=e*t*(o?o[s.edgeIndex]??1:1)*(i.bezier.circular?.3:1),1>s.t?Eo(i.bezier,s.t,s.offset,s):(s.active=!1,this._freeIndices.push(r))):(s.active=!1,this._freeIndices.push(r))}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1;this._freeIndices.length=0;for(let e=this.capacity-1;e>=0;e--)this._freeIndices.push(e)}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let n=0;e>n;n++)t.length>n?this.particles[n]=t[n]:(this.particles[n]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(n));this.capacity=e}};function Eo(e,t,n,o){if(e.circular&&e.segments)return void function(e,t,n,o,r){const s=e.length,i=t*s,a=Math.min(Math.floor(i),s-1),l=i-a,[c,u,d,h]=e[a];zo(c,u,d,h,l,r);const p=h.x-c.x,f=h.y-c.y,y=Math.sqrt(p*p+f*f);if(y>.001){const e=p/y;r.x+=-f/y*n*o*2,r.y+=e*n*o*2}}(e.segments,t,n,e.halfWidth,o);if(!e.points)return o.x=0,void(o.y=0);const[r,s,i,a]=e.points;zo(r,s,i,a,t,o);const l=a.x-r.x,c=a.y-r.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;o.x+=-c/u*n*e.halfWidth*2,o.y+=t*n*e.halfWidth*2}}function zo(e,t,n,o,r,s){const i=1-r,a=i*i,l=a*i,c=r*r,u=c*r;s.x=l*e.x+3*a*r*t.x+3*i*c*n.x+u*o.x,s.y=l*e.y+3*a*r*t.y+3*i*c*n.y+u*o.y}import{quadtree as Bo}from"d3-quadtree";function Lo(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function Oo(e){if(!e||"object"!=typeof e)return!1;const t=e;if("boolean"!=typeof t.circular)return!1;if("number"!=typeof t.halfWidth||!Number.isFinite(t.halfWidth))return!1;if(t.circular){if(!Array.isArray(t.segments)||0===t.segments.length)return!1;for(const e of t.segments)if(!Ho(e))return!1;return!0}return Ho(t.points)}function Ho(e){if(!Array.isArray(e)||4!==e.length)return!1;for(const t of e){if(!t||"object"!=typeof t)return!1;const e=t;if("number"!=typeof e.x||!Number.isFinite(e.x))return!1;if("number"!=typeof e.y||!Number.isFinite(e.y))return!1}return!0}import{interpolateNumber as Fo}from"d3-interpolate";var jo="rgba(34, 197, 94, 0.7)",$o=2e3,Yo=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Xo=["scene-style","data-paint","accessibility","evidence"],Vo=(e,t)=>({retainedData:e,invalidations:t}),Go=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],qo=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Uo=["scene-geometry","data-paint","overlay","accessibility","evidence"],Qo=["scene-style","data-paint","accessibility","evidence"],Ko=["scene-geometry","data-paint","overlay","accessibility","evidence"],Zo=[],Jo={chartType:Vo("rebuild",Go),nodeIDAccessor:Vo("rebuild",Go),sourceAccessor:Vo("rebuild",Go),targetAccessor:Vo("rebuild",Go),valueAccessor:Vo("rebuild",Go),edgeIdAccessor:Vo("rebuild",Go),childrenAccessor:Vo("rebuild",Go),hierarchySum:Vo("rebuild",Go),orientation:Vo("preserve",qo),nodeAlign:Vo("preserve",qo),nodePaddingRatio:Vo("preserve",qo),nodeWidth:Vo("preserve",qo),edgeSort:Vo("preserve",qo),iterations:Vo("preserve",qo),forceStrength:Vo("preserve",qo),padAngle:Vo("preserve",qo),groupWidth:Vo("preserve",qo),sortGroups:Vo("preserve",qo),treeOrientation:Vo("preserve",qo),edgeType:Vo("preserve",qo),padding:Vo("preserve",qo),paddingTop:Vo("preserve",qo),orbitMode:Vo("preserve",qo),orbitSize:Vo("preserve",qo),orbitSpeed:Vo("preserve",qo),orbitRevolution:Vo("preserve",qo),orbitRevolutionStyle:Vo("preserve",qo),orbitEccentricity:Vo("preserve",qo),orbitShowRings:Vo("preserve",qo),orbitAnimated:Vo("preserve",qo),customNetworkLayout:Vo("preserve",qo),layoutConfig:Vo("preserve",qo),nodeSize:Vo("preserve",Uo),nodeSizeRange:Vo("preserve",Uo),colorByDepth:Vo("preserve",Uo),nodeLabel:Vo("preserve",Ko),showLabels:Vo("preserve",Ko),labelMode:Vo("preserve",Ko),nodeStyle:Vo("preserve",Qo),edgeStyle:Vo("preserve",Qo),colorBy:Vo("preserve",Qo),colorScheme:Vo("preserve",Qo),themeCategorical:Vo("preserve",Qo),themeSemantic:Vo("preserve",Qo),edgeColorBy:Vo("preserve",Qo),edgeOpacity:Vo("preserve",Qo),showParticles:Vo("preserve",Qo),particleStyle:Vo("preserve",Qo),decay:Vo("preserve",Qo),pulse:Vo("preserve",Qo),thresholds:Vo("preserve",Qo),staleness:Vo("preserve",Qo),layoutSelection:Vo("preserve",Qo),clock:Vo("preserve",Zo),random:Vo("preserve",Zo),seed:Vo("preserve",Zo),tensionConfig:Vo("preserve",Zo),transition:Vo("preserve",Zo),introAnimation:Vo("preserve",Zo),onLayoutError:Vo("preserve",Zo),__skipForceSimulation:Vo("preserve",Zo),__hierarchyRoot:Vo("preserve",Zo),__orbitState:Vo("preserve",Zo),__previousPositions:Vo("preserve",Zo)},er=Vo("preserve",qo),tr=class{constructor(){this.tracker=new Oe}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},Yo)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Xo):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const o of e){const e=Jo[o]??er;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}},nr=class e{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this.customLayoutHtmlMarks=[],this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._nodeQuadtree=null,this._maxNodeRadius=0,this._sceneNodesRevision=0,this._nodeQuadtreeRevision=-1,this._nodesArrCache=null,this._edgesArrCache=null,this._arrCacheVersion=-1,this.particlePool=null,this.updateResults=new tr,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this._decayAgeMap=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._networkDecayCache=null,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig={...Io,...e.tensionConfig},e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new Do(2e3))}currentTime(){return this.config.clock?.()??_e()}updateConfig(e){const t=this.config,n={...t,...e};t.__orbitState&&(n.__orbitState=t.__orbitState),t.__hierarchyRoot&&(n.__hierarchyRoot=t.__hierarchyRoot),void 0===e.layoutSelection&&null!=t.layoutSelection&&(n.layoutSelection=t.layoutSelection);const o=[...new Set([...Object.keys(t),...Object.keys(n)])].filter(e=>t[e]!==n[e]);this.config=n,this.tensionConfig={...Io,...n.tensionConfig},!n.showParticles||"sankey"!==n.chartType&&!n.customNetworkLayout||this.particlePool||(this.particlePool=new Do(2e3)),this.updateResults.recordConfig(o)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}ingestHierarchy(e,t){this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null,this.updateResults.recordData("replace",1)}ingestBounded(e,t,n,o){const{nodeIDAccessor:r="id",sourceAccessor:s="source",targetAccessor:i="target",valueAccessor:a="value"}=this.config,l="function"==typeof r?r:e=>e[r],c="function"==typeof s?s:e=>e[s],u="function"==typeof i?i:e=>e[i],d="function"==typeof a?a:e=>e[a]??1;this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this._boundedEdgeSnapshot=new Map;for(const[,e]of this.edges)e.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,{y0:e.y0,y1:e.y1,sankeyWidth:e.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const t of e){const e=l(t)+"";this.nodes.set(e,{...Lo(e),data:t})}for(let e=0;t.length>e;e++){const n=t[e],o=c(n)+"",r=u(n)+"",s=d(n),i=null==s?NaN:Number(s),a=Number.isFinite(i)?i:1;this.nodes.has(o)||this.nodes.set(o,{...Lo(o),data:n}),this.nodes.has(r)||this.nodes.set(r,{...Lo(r),data:n});const l=`${o}\0${r}\0${e}`,h={source:o,target:r,value:a,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:l};n&&"object"==typeof n&&Oo(n.bezier)&&(h.bezier=n.bezier),this.edges.set(l,h)}o?.deferLayout||this.runLayout(n),this.updateResults.recordData("replace",e.length+t.length)}ingestBoundedWithResult(e,t,n,o){return this.ingestBounded(e,t,n,o),this.updateResults.last}applyForceLayoutPositions(e,t){for(const[t,n]of Object.entries(e)){const e=this.nodes.get(t);e&&(e.x=n.x,e.y=n.y)}this.config.__skipForceSimulation=!0;try{this.runLayout(t)}finally{this.config.__skipForceSimulation=void 0}}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:o}=e,r=0===this.nodes.size;let s=!1;const i=this.currentTime();this.lastIngestTime=i,this._decaySortedNodes=null,this._networkDecayCache=null,this.nodes.has(t)||(this.nodes.set(t,Lo(t)),this.nodeTimestamps.set(t,i),this.tension+=this.tensionConfig.newNode,s=!0),this.nodes.has(n)||(this.nodes.set(n,Lo(n)),this.nodeTimestamps.set(n,i),this.tension+=this.tensionConfig.newNode,s=!0);const a=this.edgeKey(t,n),l=this.edges.get(a);let c=!1;l?(l.value+=o,this.edgeTimestamps.set(a,i),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(a,{source:t,target:n,value:o,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,i),this.tension+=this.tensionConfig.newEdge,s=!0);const u=r||s||c||this.tension>=this.tensionConfig.threshold;return this.updateResults.recordData("ingest",1),u}ingestEdgeWithResult(e){return this.ingestEdge(e),this.updateResults.last}runLayout(e){if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const t=q(this.config.chartType);if(!t)return;let n=Array.from(this.nodes.values());const o=Array.from(this.edges.values());if(0===n.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.supportsStreaming&&!t.hierarchical){const e=new Map;for(const t of n)void 0!==t._prevX0?e.set(t.id,{x:(t._prevX0??0)+((t._prevX1??0)-(t._prevX0??0))/2,y:(t._prevY0??0)+((t._prevY1??0)-(t._prevY0??0))/2}):0===t.x&&0===t.y||e.set(t.id,{x:t.x,y:t.y});if(this._lastPositionSnapshot)for(const[t,n]of this._lastPositionSnapshot)e.has(t)||e.set(t,n);this.config.__previousPositions=e.size>0?e:void 0}if(t.computeLayout(n,o,this.config,e),this.config.__previousPositions=void 0,t.hierarchical&&n.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const e of n)this.nodes.set(e.id,e);for(let e=0;o.length>e;e++){const t=o[e],n=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=n,this.edges.set(n,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const n=e.get(t.id);n&&(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,n=Array.from(this.nodes.values())}this.finalizeLayout();const r=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||r.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=r,this.saveTargetPositions();const s=n.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),i=this.config.transition?.duration??this.tensionConfig.transitionDuration,a=["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType);if(!this._hasRenderedOnce&&this.config.introAnimation&&a&&n.length>0&&i>0){const t=e[0]/2,n=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=n,e._prevY1=n;for(const e of this.edges.values())e._prevY0=n,e._prevY1=n,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:i}}else s&&i>0&&(this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:i});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const e=new Set(this.nodes.keys()),t=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of e)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)e.has(t)||this.removedNodes.add(t);for(const e of t)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)t.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime=this.currentTime()),this.previousNodeIds=e,this.previousEdgeKeys=t}restyleScene(e){const t=function({nodes:e,edges:t,restyle:n,restyleEdge:o,baseStyles:r,selection:s}){const i=!(!n&&!o);if(n)for(const t of e){const e=r.get(t)??t.style,o=n(t,s);t.style=o?{...e,...o}:e}if(o)for(const e of t){const t=r.get(e)??e.style,n=o(e,s);e.style=n?{...t,...n}:t}return i}({nodes:this.sceneNodes,edges:this.sceneEdges,restyle:this._customRestyle,restyleEdge:this._customRestyleEdge,baseStyles:this._baseStyles,selection:e});this.markStylePaintPending(),this.updateResults.recordRestyle(t)}buildScene(e){if(this.config.customNetworkLayout){const t=function({config:e,customLayout:t,size:n,nodes:o,edges:r,previousResult:s,revision:i}){const a=Re(e.colorScheme,e.themeCategorical,Xe),l={nodes:o,edges:r,dimensions:{width:n[0],height:n[1],plot:{x:0,y:0,width:n[0],height:n[1]}},theme:{semantic:e.themeSemantic??{},categorical:[...a]},resolveColor:ue(a,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};try{return{kind:"success",result:t(l)}}catch(t){const n=null!==s,o=X("network",t,n,i);"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",t);try{e.onLayoutError?.(o)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:o,preservedLastGoodScene:n}}}({config:this.config,customLayout:this.config.customNetworkLayout,size:e,nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values()),previousResult:this.lastCustomLayoutResult,revision:this.layoutVersion});if("failure"===t.kind)return this.lastCustomLayoutFailure=t.diagnostic,void(t.preservedLastGoodScene||(this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._sceneNodesRevision++));const n=t.result;return this.sceneNodes=n.sceneNodes??[],this.sceneEdges=n.sceneEdges??[],this.labels=n.labels??[],this.customLayoutOverlays=n.overlays??null,this.customLayoutHtmlMarks=n.htmlMarks??[],this.lastCustomLayoutResult=n,this.lastCustomLayoutFailure=null,this._sceneNodesRevision++,this._customRestyle=n.restyle,this._customRestyleEdge=n.restyleEdge,this.hasCustomRestyle=!(!n.restyle&&!n.restyleEdge),this.hasCustomRestyle&&(this._baseStyles=function(e,t){const n=new WeakMap;for(const t of e)n.set(t,t.style);for(const e of t)n.set(e,e.style);return n}(this.sceneNodes,this.sceneEdges),this.restyleScene(this.config.layoutSelection??null)),void ne({label:"customNetworkLayout",nodes:this.sceneNodes,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned})}this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null;const t=q(this.config.chartType);if(!t)return void this._sceneNodesRevision++;const n=t.hierarchical?Array.from(this.nodes.values()):this.nodesArray,o=t.hierarchical?Array.from(this.edges.values()):this.edgesArray,{sceneNodes:r,sceneEdges:s,labels:i}=t.buildScene(n,o,this.config,e);this.sceneNodes=r,this.sceneEdges=s,this.labels=i,this._sceneNodesRevision++}rebuildNodeQuadtree(){let t=0,n=0;for(const e of this.sceneNodes)"circle"===e.type&&(t++,e.r>n&&(n=e.r));if(this._maxNodeRadius=n,e.QUADTREE_THRESHOLD>=t)return void(this._nodeQuadtree=null);const o=Array(t);let r=0;for(const e of this.sceneNodes)"circle"===e.type&&(o[r++]=e);this._nodeQuadtree=Bo().x(e=>e.cx).y(e=>e.cy).addAll(o)}get nodeQuadtree(){return this._nodeQuadtreeRevision!==this._sceneNodesRevision&&(this.rebuildNodeQuadtree(),this._nodeQuadtreeRevision=this._sceneNodesRevision),this._nodeQuadtree}get maxNodeRadius(){return this._maxNodeRadius}_ensureArrays(){this._arrCacheVersion===this.layoutVersion&&this._nodesArrCache&&this._edgesArrCache||(this._nodesArrCache=Array.from(this.nodes.values()),this._edgesArrCache=Array.from(this.edges.values()),this._arrCacheVersion=this.layoutVersion)}get nodesArray(){return this._ensureArrays(),this._nodesArrCache}get edgesArray(){return this._ensureArrays(),this._edgesArrCache}get isAnimating(){const e=q(this.config.chartType);return!!e?.supportsAnimation&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=q(this.config.chartType);if(!n?.tick)return!1;const o=n.hierarchical?Array.from(this.nodes.values()):this.nodesArray,r=n.hierarchical?Array.from(this.edges.values()):this.edgesArray;return n.tick(o,r,this.config,e,t)}cancelIntroAnimation(){this.transition=null;for(const e of this.nodes.values())e._prevX0=void 0,e._prevX1=void 0,e._prevY0=void 0,e._prevY1=void 0;for(const e of this.edges.values())e._prevY0=void 0,e._prevY1=void 0,e._prevSankeyWidth=void 0,e._introFromZero=!1}advanceTransition(e){if(!this.transition)return!1;const t=pe(e,this.transition),n=he(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=be(e._prevX0,e._targetX0,n),e.x1=be(e._prevX1,e._targetX1,n),e.y0=be(e._prevY0,e._targetY0,n),e.y1=be(e._prevY1,e._targetY1,n));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&(e._prevSankeyWidth>0||e._introFromZero)&&(e.y0=be(e._prevY0,e._targetY0,n),e.y1=be(e._prevY1,e._targetY1,n),e.sankeyWidth=be(e._prevSankeyWidth,e._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const n=e?.get(t.id);n&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1):(t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1)}const t=this._boundedEdgeSnapshot;for(const e of this.edges.values()){if(t&&0===e.sankeyWidth){const n=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(n){e._prevY0=n.y0,e._prevY1=n.y1,e._prevSankeyWidth=n.sankeyWidth;continue}}e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth),e._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(e){!function(e,t,n=.5){const o="string"==typeof e.source?t.get(e.source):e.source,r="string"==typeof e.target?t.get(e.target):e.target;!o||!r||(e.bezier=e.circular&&e.circularPathData?function(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(!n)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),o=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-o,y:n.targetY},{x:n.targetX-.66*o,y:n.targetY},{x:n.targetX-.33*o,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let o;o="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const r=[];for(let e=0;o.length-1>e;e++){const t=o[e],n=o[e+1],s=n.x-t.x,i=n.y-t.y;r.push([t,{x:t.x+s/3,y:t.y+i/3},{x:t.x+2*s/3,y:t.y+2*i/3},n])}return{circular:!0,segments:r,halfWidth:t}}(e):function(e,t,n,o=.5){const r=(e.sankeyWidth||1)/2;if("down"===e.direction){const s=t.x1,i=n.x0,a=Fo(s,i);return{circular:!1,points:[{x:e.y0,y:s},{x:e.y0,y:a(o)},{x:e.y1,y:a(1-o)},{x:e.y1,y:i}],halfWidth:r}}const s=t.x1,i=n.x0,a=Fo(s,i);return{circular:!1,points:[{x:s,y:e.y0},{x:a(o),y:e.y0},{x:a(1-o),y:e.y1},{x:i,y:e.y1}],halfWidth:r}}(e,o,r,n))}(e,this.nodes,.5)}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){!function(e){const t=e.pulse;if(!t)return;const n=t.duration??500,o=t.color??"rgba(255,255,255,0.6)",r=t.glowRadius??4,{now:s}=e;for(const t of e.sceneNodes){const i=t.id;if(!i)continue;const a=e.nodeTimestamps.get(i);if(!a)continue;const l=s-a;n>l&&(t._pulseIntensity=1-l/n,t._pulseColor=o,t._pulseGlowRadius=r)}for(const t of e.sceneEdges){const r=t.datum;if(!r)continue;const i="object"==typeof r.source?r.source?.id:r.source,a="object"==typeof r.target?r.target?.id:r.target;if(!i||!a)continue;const l=e.edgeTimestamps.get(`${i}\0${a}`);if(!l)continue;const c=s-l;n>c&&(t._pulseIntensity=1-c/n,t._pulseColor=o)}}({sceneNodes:this.sceneNodes,sceneEdges:this.sceneEdges,nodeTimestamps:this.nodeTimestamps,edgeTimestamps:this.edgeTimestamps,pulse:this.config.pulse,now:e})}applyDecay(){this._networkDecayCache||(this._networkDecayCache={sortedNodes:null,ageMap:null}),this._decaySortedNodes||(this._networkDecayCache.sortedNodes=null,this._networkDecayCache.ageMap=null),function(e){const t=e.decay;if(!t)return;const n=e.nodeTimestamps.size;if(1>=n)return;if(!e.cache.sortedNodes){e.cache.sortedNodes=Array.from(e.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]);const t=new Map;for(let n=0;e.cache.sortedNodes.length>n;n++)t.set(e.cache.sortedNodes[n][0],n);e.cache.ageMap=t}const o=e.cache.ageMap;for(const r of e.sceneNodes){const e=r.id;if(!e)continue;const s=o.get(e);if(void 0===s)continue;const i=Y(t,s,n);r.style={...r.style,opacity:(r.style?.opacity??1)*i}}}({sceneNodes:this.sceneNodes,nodeTimestamps:this.nodeTimestamps,decay:this.config.decay,cache:this._networkDecayCache}),this._decaySortedNodes=this._networkDecayCache.sortedNodes,this._decayAgeMap=this._networkDecayCache.ageMap}applyTopologyDiff(e){!function(e){for(const t of e.sceneNodes)t._pulseColor===jo&&(t._pulseIntensity=0,t._pulseColor=void 0,t._pulseGlowRadius=void 0);if(0===e.addedNodes.size)return;const t=e.now-e.lastTopologyChangeTime;if(t>=$o)return;const n=1-t/$o;for(const t of e.sceneNodes){const o=t.id;o&&e.addedNodes.has(o)&&(t._pulseIntensity=Math.max(t._pulseIntensity??0,n),t._pulseColor=jo,t._pulseGlowRadius=8)}}({sceneNodes:this.sceneNodes,addedNodes:this.addedNodes,lastTopologyChangeTime:this.lastTopologyChangeTime,now:e})}get hasActiveTopologyDiff(){return function(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){return 0!==e.size&&$o>n-t}(this.addedNodes,this.lastTopologyChangeTime)}applyThresholds(e){!function(e){const t=e.thresholds;if(!t)return;const n=t.warningColor??"#f59e0b",o=t.criticalColor??"#ef4444",r=!1!==t.pulse;for(const s of e.sceneNodes){const i=s.id;if(!i)continue;const a=e.nodes.get(i);if(!a)continue;const l=t.metric(a);let c=null;void 0===t.critical||t.critical>l?void 0===t.warning||t.warning>l||(c=n):c=o,c&&(s.style={...s.style,fill:c},r&&(s._pulseIntensity=.6+.4*Math.sin(e.now/300),s._pulseColor=c,s._pulseGlowRadius=6))}}({sceneNodes:this.sceneNodes,nodes:this.nodes,thresholds:this.config.thresholds,now:e})}get hasActiveThresholds(){return function(e,t){if(!t)return!1;for(const n of e){const e=t.metric(n);if(void 0!==t.warning&&e>=t.warning||void 0!==t.critical&&e>=t.critical)return!0}return!1}(this.nodes.values(),this.config.thresholds)}get hasActivePulses(){return function(e){const t=e.pulse;if(!t||0===e.lastIngestTime)return!1;const n=e.now??("undefined"!=typeof performance?performance.now():Date.now());return(t.duration??500)>n-e.lastIngestTime}({pulse:this.config.pulse,lastIngestTime:this.lastIngestTime})}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){const n=this.nodes.get(e);if(!n)return this.updateResults.recordNoop("update"),null;const o=n.data?{...n.data}:{};return n.data=t(n.data??{}),this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",1),o}updateEdge(e,t,n){const o=this.config.valueAccessor,r="function"==typeof o?o:o?e=>e[o]:e=>e.value,s=[];for(const[,o]of this.edges)if(("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t){s.push(o.data?{...o.data}:{}),o.data=n(o.data??{});const e=r(o.data);null!=e&&(o.value=Number(e))}return s.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",s.length)):this.updateResults.recordNoop("update"),s}removeNode(e){if(!this.nodes.has(e))return this.updateResults.recordNoop("remove"),!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==e&&("string"==typeof n.target?n.target:n.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",1),!0}removeEdge(e,t){const n=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const o="function"==typeof t?t:e=>e?.[t];for(const[t,r]of this.edges)r.data&&o(r.data)===e&&n.push(t)}else for(const[o,r]of this.edges)("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t&&n.push(o);for(const e of n)this.edges.delete(e),this.edgeTimestamps.delete(e);return n.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",n.length)):this.updateResults.recordNoop("remove"),n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this._decayAgeMap=null,this._nodeQuadtree=null,this._nodesArrCache=null,this._edgesArrCache=null,this._sceneNodesRevision++,this.tension=0,this.layoutVersion++,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.particlePool&&this.particlePool.clear(),this.updateResults.recordData("clear")}};nr.QUADTREE_THRESHOLD=500;var or=nr;j(or);import*as rr from"react";import{Fragment as sr,jsx as ir,jsxs as ar}from"react/jsx-runtime";function lr(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:s,labels:i,title:a,legend:l,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h,legendPosition:p="right",legendLayout:f,foregroundGraphics:y,sceneNodes:g,annotations:m,onAnnotationActivate:v,onObservation:x,chartId:b,chartType:w,autoPlaceAnnotations:A,svgAnnotationRules:_}=e,C=H({onAnnotationActivate:v,onObservation:x,chartId:b,chartType:w}),P=rr.useMemo(()=>{const e=(g||[]).flatMap(e=>{const t=function(e){if("glyph"===e.type&&e.glyph&&"number"==typeof e.size){const t=e.cx??e.x,n=e.cy??e.y;if("number"!=typeof t||"number"!=typeof n)return null;const o=$e(e.glyph,e.size);return{x:t+o.centerDx,y:n+o.centerDy,r:Math.max(1,o.radius)}}const t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),n=e.cy??(null!=e.y&&null!=e.h?e.y+e.h/2:e.y);return"number"!=typeof t||"number"!=typeof n?null:{x:t,y:n,r:"number"==typeof e.r?Math.max(1,e.r):"number"==typeof e.outerR?Math.max(1,e.outerR):"number"==typeof e.size?Math.max(1,Ge(e.size)):Math.max(1,e.w??0,e.h??0)/2}}(e),n=function(e){const t=e.id??e.datum?.id??e.datum?.data?.id??e.datum?.data?.name;return null==t?void 0:t+""}(e);return t?[{pointId:n,...t}]:[]});return{scales:null,width:t,height:n,frameType:"network",pointNodes:e,sceneNodes:g}},[n,g,t]),R=rr.useMemo(()=>m&&A?He({annotations:m,context:P,..."object"==typeof A?A:{}}):m,[m,A,P]),M=rr.useMemo(()=>k("network"),[]),N=R?S(R.filter(e=>"widget"!==e.type),M,_,P):null,I=!0===R?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return ar(sr,{children:[I&&ir("style",{children:se},"annotation-widget-disclosure-style"),ar("svg",{role:"img",width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[ir("title",{children:"string"==typeof a?a:"Network Chart"}),ir("desc",{children:"string"==typeof a?a+" (network data visualization)":"Network data visualization"}),ar("g",{transform:`translate(${s.left},${s.top})`,children:[i.map((e,t)=>ir("text",{x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"},children:e.text},"label-"+t)),N,y]}),a&&"string"==typeof a?ir("text",{x:o/2,y:ae,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:a}):a?ir("foreignObject",{x:0,y:0,width:o,height:s.top,children:a}):null,T({legend:l,totalWidth:o,totalHeight:r,margin:s,legendPosition:p,title:a,legendLayout:f,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})]}),R?.filter(e=>"widget"===e.type&&e.nodeId&&g).map((e,t)=>{const n=!0===e._annotationDeferred,o=g.find(t=>t.id===e.nodeId||t.datum?.id===e.nodeId||t.datum?.data?.id===e.nodeId||t.datum?.data?.name===e.nodeId);if(!o)return null;const r=s.left+(o.cx??(null!=o.x&&null!=o.w?o.x+o.w/2:o.x??0)),i=s.top+(o.cy??(null!=o.y&&null!=o.h?o.y+o.h/2:o.y??0)),a=e.dx??0,l=e.dy??-16,c=e.width??32,u=e.height??32,d=e.content??ir("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return ir("div",{...D(e,C),className:n?"annotation-deferred":void 0,"data-annotation-disclosure":n?"deferred":void 0,style:{position:"absolute",left:r+a-c/2,top:i+l-u/2,width:c,height:u,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:d},"widget-"+t)})]})}lr.displayName="NetworkSVGOverlay";import*as cr from"react";import{jsx as ur}from"react/jsx-runtime";var dr={position:"absolute",top:0,left:0,pointerEvents:"none"};function hr({marks:e,margin:t,selection:n=null,overscan:o=400}){const s=cr.useRef(null),i=function(e,t,n){const[o,r]=cr.useState(null);return cr.useLayoutEffect(()=>{const e=t.current,n=function(e){let t=e?.parentElement??null;for(;t;){const{overflow:e,overflowX:n,overflowY:o}=window.getComputedStyle(t);if(/(auto|scroll|overlay)/.test(`${e} ${o} ${n}`))return t;t=t.parentElement}return null}(e);if(!e||!n)return void r(null);let o=0;const s=()=>{o=0;const t=n.getBoundingClientRect(),s=e.getBoundingClientRect();r(0!==t.width&&0!==t.height?{scroll:{left:t.left,top:t.top,right:t.right,bottom:t.bottom},originX:s.left,originY:s.top}:null)},i=()=>{0===o&&(o=window.requestAnimationFrame(s))};s(),n.addEventListener("scroll",i,{passive:!0});const a=new ResizeObserver(i);return a.observe(n),()=>{0!==o&&window.cancelAnimationFrame(o),n.removeEventListener("scroll",i),a.disconnect()}},[t,e,n]),cr.useMemo(()=>{if(!e||!o)return e;const{scroll:t,originX:r,originY:s}=o,i=t.left-n,a=t.right+n,l=t.top-n,c=t.bottom+n;return e.filter(e=>{const t=r+e.x,n=s+e.y;return!(i>t+e.width||t>a||l>n+e.height||n>c)})},[e,o,n])}(e,s,o);if(!e||0===e.length)return null;const a=ur("div",{className:"semiotic-network-html-marks",ref:s,style:{...dr,transform:`translate(${t.left}px, ${t.top}px)`},children:(i??e).map(e=>ur("div",{className:"semiotic-network-html-mark","data-mark-id":e.id,style:{position:"absolute",transform:`translate(${e.x}px, ${e.y}px)`,width:e.width,height:e.height,pointerEvents:"none"},children:e.content},e.id))});return null!=n?ur(r,{value:n,children:a}):a}import{jsx as pr,jsxs as fr}from"react/jsx-runtime";function yr({props:e,store:t,responsiveRef:n,size:o,margin:r,adjustedWidth:s,adjustedHeight:i,resolvedBackground:a,resolvedForeground:l}){const{chartType:u,nodes:d,edges:h,data:p,className:f,description:y,title:g,responsiveWidth:v,responsiveHeight:x,summary:b,background:k,renderMode:w,legend:A,legendPosition:S,legendLayout:_,legendHoverBehavior:T,legendClickBehavior:C,legendHighlightedCategory:P,legendIsolatedCategories:R,layoutSelection:M,annotations:N,onAnnotationActivate:I,annotationObservationCallback:W,onObservation:D,chartId:E,autoPlaceAnnotations:z,svgAnnotationRules:B}=e;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(u),n=e?p||(Array.isArray(h)?void 0:h):void 0;if(e&&n)t.ingestHierarchy(n,[s,i]),t.buildScene([s,i]);else{const e=ge(d),n=Array.isArray(h)?ge(h):[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[s,i]),t.buildScene([s,i]))}}const L=t?.sceneNodes??[],O=t?.sceneEdges??[],H=t?.labels??[];return fr("div",{ref:n,className:"stream-network-frame"+(f?" "+f:""),role:"img","aria-label":y||("string"==typeof g?g:"Network chart"),style:{position:"relative",width:v?"100%":o[0],height:x?"100%":o[1]},children:[pr(m,{summary:b}),fr("svg",{xmlns:"http://www.w3.org/2000/svg",width:o[0],height:o[1],style:{position:"absolute",left:0,top:0},children:[a&&pr("g",{transform:`translate(${r.left},${r.top})`,children:a}),fr("g",{transform:`translate(${r.left},${r.top})`,children:[k&&pr("rect",{x:0,y:0,width:s,height:i,fill:k}),O.map((e,t)=>K({node:e,index:t,renderMode:w,fallback:()=>we(e,t)})).filter(Boolean),L.map((e,t)=>K({node:e,index:t,renderMode:w,fallback:()=>Ae(e,t)})).filter(Boolean),H.map((e,t)=>ke(e,t)).filter(Boolean)]})]}),pr(lr,{width:s,height:i,totalWidth:o[0],totalHeight:o[1],margin:r,labels:H,sceneNodes:L,title:g,legend:A,legendPosition:S,legendLayout:_,legendHoverBehavior:T,legendClickBehavior:C,legendHighlightedCategory:P,legendIsolatedCategories:R,foregroundGraphics:yt(l,c(t?.customLayoutOverlays,M??null)),annotations:N,onAnnotationActivate:I,onObservation:W??D,chartId:E,chartType:"StreamNetworkFrame",autoPlaceAnnotations:z,svgAnnotationRules:B,annotationFrame:0}),pr(hr,{marks:t?.customLayoutHtmlMarks,margin:r,selection:M??null})]})}import{jsx as gr,jsxs as mr}from"react/jsx-runtime";var vr=/^(value|amount|total|count|weight|score)$/i;function xr({data:e}){if("edge"===e.nodeOrEdge){const t=e.data;return t?mr("div",{className:"semiotic-tooltip",style:z,children:[mr("div",{style:{fontWeight:600},children:["object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target]}),null!=t.value&&mr("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]})]}):null}const t=e.data;if(!t)return null;const n=t.__hierarchyNode;if(n){const e=[];let o=n;for(;o;){const n=o.data?.name??o.data?.id??t.id;null!=n&&e.unshift(n+""),o=o.parent}e.length>1&&e.shift();const r=e.length-1;return mr("div",{className:"semiotic-tooltip",style:z,children:[gr("div",{children:e.map((e,t)=>mr("span",{children:[t>0&&gr("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),t===r?gr("strong",{children:e}):gr("span",{style:{opacity:.7},children:e})]},t))}),null!=t.value&&t.value>0&&gr("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof t.value?t.value.toLocaleString():t.value+""})]})}const o=(t.sourceLinks?.length||0)+(t.targetLinks?.length||0),r=(t.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(t.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0),s=O(t.data??t),i=null!=s.title?s.title+"":t.id,a=s.entries.some(e=>vr.test(e.key));return mr("div",{className:"semiotic-tooltip",style:z,children:[gr("div",{style:{fontWeight:600},children:i}),s.entries.map(e=>{return mr("div",{style:{marginTop:4,opacity:.8},children:[e.key,": ",(t=e.value,null==t?"–":"number"==typeof t?Math.abs(t)>9999?t.toLocaleString():t+"":t instanceof Date?t.toLocaleDateString():t+"")]},e.key);var t}),!a&&null!=t.value&&t.value>0&&mr("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]}),o>0&&mr("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",o,r!==o&&` (weighted: ${r.toLocaleString()})`]})]})}function br(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function kr(e,t){if(!t.pathD)return;e.save();const n=br(t);if(t.style.fill&&"none"!==t.style.fill){const o=t._gradient;if(o){const n=e.createLinearGradient(o.x0,0,o.x1,0),r=t.style.fillOpacity??t.style.opacity??.5,s="string"==typeof t.style.fill?t.style.fill:"#999",i=Qe(e,s)||s;n.addColorStop(0,1===o.from?i:"transparent"),n.addColorStop(1,1===o.to?i:"transparent"),e.fillStyle=n,e.globalAlpha=r}else e.fillStyle=Ce(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5;e.fill(n)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.5*(t.style.opacity??1),e.stroke(n)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(n)),e.restore()}function wr(e,t){e.save();const n=t.style.stroke||"#999";e.strokeStyle=Qe(e,n)||n,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(t.style.strokeWidth??1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function Ar(e,t){if(!t.pathD)return;e.save();const n=br(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=Ce(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5,e.fill(n)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.3*(t.style.opacity??1),e.stroke(n)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(n)),e.restore()}function Sr(e,t){if(!t.pathD)return;e.save();const n=br(t),o=t.style.stroke||"#999";e.strokeStyle=Qe(e,o)||o,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(n),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=Ce(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??.1,e.fill(n)),e.restore()}xr.ownsChrome=!0;var _r=new Map;function Tr(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=_r.get(t);return n||(n=new Path2D(Ve(e.symbolType,e.size)),_r.size>256&&_r.clear(),_r.set(t,n)),n}catch{return null}}function Cr(e){const{sceneNodes:t,nodes:n,nodeColorMap:o,colorScheme:r}=e;for(const e of t)e.id&&"string"==typeof e.style?.fill&&o.set(e.id,e.style.fill);const s=Array.isArray(r)?r:ie,i=Array.from(n);for(let e=0;i.length>e;e++){const t=i[e];o.has(t.id)||o.set(t.id,s[e%s.length])}return i.length}function Pr(n,r,s,i=30){switch(n.type){case"circle":return function(t,n,o,r=30){const s=n-t.cx,i=o-t.cy,a=Math.sqrt(s*s+i*i);return a>e(t.r,r)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:a}}(n,r,s,i);case"rect":return function(e,n,o){const r=t(n,o,e);return r.hit?{type:"node",datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}(n,r,s);case"arc":return function(e,t,n){const r=t-e.cx,s=n-e.cy,i=Math.sqrt(r*r+s*s);if(e.innerR-2>i||i>e.outerR+2)return null;const a=o(Math.atan2(s,r)),l=o(e.startAngle),c=o(e.endAngle);if(l>c?a>=l||c>=a:a>=l&&c>=a){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(n,r,s);case"symbol":return function(t,n,o,r=30){const s=n-t.cx,i=o-t.cy,a=Math.sqrt(s*s+i*i);return a>e(Ge(t.size),r)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:a}}(n,r,s,i);case"glyph":return function(t,n,o,r=30){if(null==t.datum)return null;const s=$e(t.glyph,t.size),i=t.cx+s.centerDx,a=t.cy+s.centerDy,l=n-i,c=o-a,u=Math.sqrt(l*l+c*c);return u>e(s.radius,r)?null:{type:"node",datum:t.datum,x:i,y:a,distance:u}}(n,r,s,i);default:return null}}var Rr=null,Mr=null;function Nr(){return Mr||((Rr=document.createElement("canvas")).width=1,Rr.height=1,Mr=Rr.getContext("2d")),Mr}function Ir(e){if(e._cachedPath2D&&e._cachedPath2DSource===e.pathD)return e._cachedPath2D;try{return e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD,e._cachedPath2D}catch{return null}}function Wr(e,t,n){switch(e.type){case"bezier":return function(e,t,n){if(!e.pathD)return null;const o=Ir(e),r=Nr();if(!o||!r)return null;try{if(r.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const s=r.lineWidth;r.lineWidth=10;const i=r.isPointInStroke(o,t,n);if(r.lineWidth=s,i)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);case"line":return function(e,t,n){const o=e.x2-e.x1,r=e.y2-e.y1,s=o*o+r*r;if(0===s)return null;let i=((t-e.x1)*o+(n-e.y1)*r)/s;i=Math.max(0,Math.min(1,i));const a=e.x1+i*o,l=e.y1+i*r,c=Math.sqrt((t-a)**2+(n-l)**2);return c>5?null:{type:"edge",datum:e.datum,x:a,y:l,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;const o=Ir(e),r=Nr();if(!o||!r)return null;try{if(r.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const s=r.lineWidth;r.lineWidth=10;const i=r.isPointInStroke(o,t,n);if(r.lineWidth=s,i)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);default:return null}}function Dr(e){const{clientX:t,clientY:n,canvasRect:o,margin:r,adjustedWidth:s,adjustedHeight:i,sceneNodes:a,sceneEdges:l,nodeQuadtree:c,maxNodeRadius:u,hitRadius:d=30}=e,h=t-o.left-r.left,p=n-o.top-r.top;if(0>h||h>s||0>p||p>i)return{kind:"miss-outside"};const f=function(e,t,n,o,r=30,s,i=0){let a=null,l=r,c=1/0;if(s){const e=bt(s,n,o,r,i,e=>e.cx,e=>e.cy,e=>e.r);e&&(a={type:"node",datum:e.node.datum,x:e.node.cx,y:e.node.cy,distance:e.distance},l=e.distance)}for(const t of e){if(s&&"circle"===t.type)continue;const e=Pr(t,n,o,r);if(e)if("rect"===t.type){const n=t.w*t.h;c>n&&(a=e,c=n)}else l>e.distance&&(a=e,l=e.distance)}if(a)return a;for(const e of t){if(!1===e.interactive)continue;const t=Wr(e,n,o);t&&l>t.distance&&(a=t,l=t.distance)}return a}(a,l,h,p,d,c,u);return f?{kind:"hit",hover:E(f.datum||{},f.x,f.y,{nodeOrEdge:f.type})}:{kind:"miss"}}import{useCallback as Er}from"react";var zr="StreamNetworkFrame";import{jsx as Br,jsxs as Lr}from"react/jsx-runtime";var Or={top:20,right:80,bottom:20,left:80},Hr={top:40,right:40,bottom:40,left:40},Fr=new Set(["chord","force","circlepack","orbit"]),jr=[800,600],$r=No(Mo(function(e,t){const{chartType:n,nodes:o,edges:r,data:u,initialEdges:x,nodeIDAccessor:k="id",sourceAccessor:S="source",targetAccessor:_="target",valueAccessor:T="value",edgeIdAccessor:D,childrenAccessor:z,hierarchySum:B,orientation:O="horizontal",nodeAlign:H="justify",nodePaddingRatio:F=.05,nodeWidth:j=15,iterations:$=300,forceStrength:Y=.1,layoutExecution:X="auto",layoutLoadingContent:V,onLayoutStateChange:G,padAngle:q=.01,groupWidth:U=20,sortGroups:K,edgeSort:Z,treeOrientation:J="vertical",edgeType:ee="curve",padding:te,paddingTop:ne,tensionConfig:oe,showParticles:re=!1,particleStyle:se,renderMode:ae,nodeStyle:le,edgeStyle:ce,colorBy:ue,colorScheme:de="category10",edgeColorBy:he="source",edgeOpacity:pe=.5,colorByDepth:me=!1,nodeSize:be=8,nodeSizeRange:ke=[5,20],nodeLabel:we,showLabels:Ae=!0,labelMode:Se,size:_e=jr,responsiveWidth:Pe,responsiveHeight:Re,margin:Me,className:Ne,background:Ie,enableHover:We=!0,tooltipContent:De,customHoverBehavior:Ee,customClickBehavior:ze,onObservation:Be,annotationObservationCallback:Le,chartId:Oe,onTopologyChange:He,annotations:Fe,onAnnotationActivate:je,autoPlaceAnnotations:Ye,svgAnnotationRules:Xe,legend:Ve,legendPosition:Ge,legendLayout:qe,legendHoverBehavior:Ue,legendClickBehavior:Ze,legendHighlightedCategory:Je,legendIsolatedCategories:et,title:tt,foregroundGraphics:nt,backgroundGraphics:ot,decay:rt,pulse:st,transition:it,animate:at,staleness:lt,frameScheduler:ct,clock:ut,random:dt,seed:ht,paused:pt=!1,suspendWhenHidden:ft=!0,thresholds:gt,accessibleTable:mt=!0,description:bt,summary:kt,orbitMode:wt,orbitSize:At,orbitSpeed:St,orbitRevolution:_t,orbitRevolutionStyle:Tt,orbitEccentricity:Ct,orbitShowRings:Pt,orbitAnimated:Rt,customNetworkLayout:Mt,onLayoutError:Nt,layoutConfig:It,layoutSelection:Wt}=e,Dt=Fr.has(n)?Hr:Or,Et=So(!0),zt=R({sizeProp:_e,responsiveWidth:Pe,responsiveHeight:Re,userMargin:Me,marginDefault:Dt,title:tt,legend:Ve,legendPosition:Ge,foregroundGraphics:nt,backgroundGraphics:ot,animate:at,transitionProp:it,frameScheduler:ct,clock:ut,random:dt,seed:ht,paused:pt,suspendWhenHidden:ft,themeDirtyRef:Et}),{reducedMotionRef:Bt,responsiveRef:Lt,size:Ot,margin:Ht,adjustedWidth:jt,adjustedHeight:Yt,resolvedForeground:Xt,resolvedBackground:Vt,transition:Gt,introEnabled:qt,tableId:Ut,rafRef:Qt,renderFnRef:Kt,scheduleRender:Zt,frameRuntime:Jt,currentTheme:en}=zt,tn=N(),nn=W(),on=Co(()=>ge(o),[o]),rn=Co(()=>Array.isArray(r)?ge(r):r,[r]),sn=Co(()=>({...Io,...oe}),[oe]),an=Co(()=>({...Wo,...se}),[se]),ln=Co(()=>{return{chartType:(e={chartType:n,clock:Jt.now,random:dt,seed:ht,nodeIDAccessor:k,sourceAccessor:S,targetAccessor:_,valueAccessor:T,edgeIdAccessor:D,childrenAccessor:z,hierarchySum:B,orientation:O,nodeAlign:H,nodePaddingRatio:F,nodeWidth:j,iterations:$,forceStrength:Y,padAngle:q,groupWidth:U,sortGroups:K,edgeSort:Z,treeOrientation:J,edgeType:ee,padding:te,paddingTop:ne,tensionConfig:sn,showParticles:re,particleStyle:an,nodeStyle:le,edgeStyle:ce,nodeLabel:we,showLabels:Ae,labelMode:Se,colorBy:ue,colorScheme:de,edgeColorBy:he,edgeOpacity:pe,colorByDepth:me,nodeSize:be,nodeSizeRange:ke,decay:rt,pulse:st,transition:Gt,introAnimation:qt,staleness:lt,thresholds:gt,orbitMode:wt,orbitSize:At,orbitSpeed:St,orbitRevolution:_t,orbitRevolutionStyle:Tt,orbitEccentricity:Ct,orbitShowRings:Pt,orbitAnimated:Rt,customNetworkLayout:Mt,onLayoutError:Nt,layoutConfig:It,currentTheme:en}).chartType,clock:e.clock,random:e.random,seed:e.seed,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,edgeIdAccessor:e.edgeIdAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,tensionConfig:e.tensionConfig,showParticles:e.showParticles,particleStyle:e.particleStyle,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,labelMode:e.labelMode,colorBy:e.colorBy,colorScheme:e.colorScheme,themeCategorical:e.currentTheme?.colors?.categorical,themeSemantic:Ke(e.currentTheme),edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,decay:e.decay,pulse:e.pulse,transition:e.transition,introAnimation:e.introAnimation,staleness:e.staleness,thresholds:e.thresholds,orbitMode:e.orbitMode,orbitSize:e.orbitSize,orbitSpeed:e.orbitSpeed,orbitRevolution:e.orbitRevolution,orbitRevolutionStyle:e.orbitRevolutionStyle,orbitEccentricity:e.orbitEccentricity,orbitShowRings:e.orbitShowRings,orbitAnimated:e.orbitAnimated,customNetworkLayout:e.customNetworkLayout,onLayoutError:e.onLayoutError,layoutConfig:e.layoutConfig};var e},[n,Jt.now,dt,ht,k,S,_,T,D,z,B,O,H,F,j,$,Y,q,U,K,Z,J,ee,te,ne,sn,re,an,le,ce,we,Ae,Se,ue,de,he,pe,me,be,ke,rt,st,Gt,qt,lt,gt,wt,At,St,_t,Tt,Ct,Pt,Rt,Mt,Nt,It,en]),cn=pn(ln),un=pn({chartType:(dn={chartType:n,nodeIDAccessor:k,sourceAccessor:S,targetAccessor:_,valueAccessor:T,edgeIdAccessor:D,childrenAccessor:z,hierarchySum:B,orientation:O,nodeAlign:H,nodePaddingRatio:F,nodeWidth:j,iterations:$,forceStrength:Y,padAngle:q,groupWidth:U,sortGroups:K,edgeSort:Z,treeOrientation:J,edgeType:ee,padding:te,paddingTop:ne,random:dt,seed:ht,tensionConfig:sn,customNetworkLayout:Mt,orbitMode:wt,orbitSize:At,orbitEccentricity:Ct}).chartType,nodeIDAccessor:dn.nodeIDAccessor,sourceAccessor:dn.sourceAccessor,targetAccessor:dn.targetAccessor,valueAccessor:dn.valueAccessor,edgeIdAccessor:dn.edgeIdAccessor,childrenAccessor:dn.childrenAccessor,hierarchySum:dn.hierarchySum,orientation:dn.orientation,nodeAlign:dn.nodeAlign,nodePaddingRatio:dn.nodePaddingRatio,nodeWidth:dn.nodeWidth,iterations:dn.iterations,forceStrength:dn.forceStrength,padAngle:dn.padAngle,groupWidth:dn.groupWidth,sortGroups:dn.sortGroups,edgeSort:dn.edgeSort,treeOrientation:dn.treeOrientation,edgeType:dn.edgeType,padding:dn.padding,paddingTop:dn.paddingTop,random:dn.random,seed:dn.seed,tensionConfig:dn.tensionConfig,customNetworkLayout:dn.customNetworkLayout,orbitMode:dn.orbitMode,orbitSize:dn.orbitSize,orbitEccentricity:dn.orbitEccentricity});var dn;const hn=So(0),fn=So(0),yn=So(!1),gn=So(null);gn.current||(gn.current=new or(cn));const mn=I("StreamNetworkFrame"),xn=Po((e,t,n=!1)=>P(mn.current,e,()=>e.buildScene(t),n),[mn]),[bn,kn]=_o(null),[wn,An]=_o(0),[Sn,_n]=_o(0),[Tn,Cn]=_o(!1),[Pn,Rn]=_o(!1),Mn=So(0),Nn=So(null),In=So(!1),Wn=So(G);Wn.current=G;const zn=So(cn);zn.current=cn;const Bn=So(null),Ln=So(new Map),On=So(0),Hn=Po(e=>function(e){const{node:t,colorBy:n,colorScheme:o,nodeColorMap:r,colorIndexRef:s}=e;if("function"==typeof n)return n(t)+"";if("string"==typeof n&&t.data){const e=t.data[n];if(void 0!==e){if(!r.has(e+"")){const t=Array.isArray(o)?o:ie;r.set(e+"",t[s.current++%t.length])}return r.get(e+"")}}if(r.has(t.id))return r.get(t.id);const i=Array.isArray(o)?o:ie,a=n?i[s.current++%i.length]:i[0];return r.set(t.id,a),a}({node:e,colorBy:ue,colorScheme:de,nodeColorMap:Ln.current,colorIndexRef:On}),[ue,de]),Fn=(jn=en,jn?.colors?.border||jn?.colors?.secondary||jn?.colors?.primary||"#999");var jn;const $n=Po(e=>function(e,t){return e?"object"==typeof e?e:t?.get(e)??null:null}(e,gn.current?.nodes),[]),Yn=Po(e=>function(e){const{edge:t,edgeColorBy:n,getNodeColor:o,resolveEndpoint:r,fallback:s}=e;if("function"==typeof n)return n(t);const i=r(t.source),a=r(t.target);return"target"===n&&a?o(a):i?o(i):s}({edge:e,edgeColorBy:he,getNodeColor:Hn,resolveEndpoint:$n,fallback:Fn}),[he,Hn,Fn,$n]),Vn=Po(e=>function(e){const{edge:t,particleStyleColor:n,particleColorBy:o,hasExplicitParticleColorBy:r,getEdgeColor:s,getNodeColor:i,resolveEndpoint:a,fallback:l}=e;if("function"==typeof n){const e=a(t.source);return e?n(t,e):l}if(!r)return s(t);const c=o,u=a(t.source),d=a(t.target);return"target"===c&&d?i(d):u?i(u):l}({edge:e,particleStyleColor:an.color,particleColorBy:an.colorBy,hasExplicitParticleColorBy:!!se?.colorBy,getEdgeColor:Yn,getNodeColor:Hn,resolveEndpoint:$n,fallback:Fn}),[se?.colorBy,an.color,an.colorBy,Hn,Yn,Fn,$n]),Gn=function(e,t,n,o,r){return("sankey"===e||t)&&n||o||r}(n,!!Mt,re,!!st,gn.current?.isAnimating??!1);vt(gn,cn,Et,Zt),xt(gn,Wt,Et,Zt),To(()=>{const e=gn.current;e&&(xn(e,[jt,Yt]),On.current=Cr({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Ln.current,colorScheme:de}),Et.current=!0,Zt())},[en,jt,Yt,xn,Zt,de]);const qn=Po(()=>{const e=gn.current;if(e&&(e.runLayout([jt,Yt]),xn(e,[jt,Yt]),Et.current=!0,On.current=Cr({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Ln.current,colorScheme:de}),An(e.layoutVersion),He)){const{nodes:t,edges:n}=e.getLayoutData();He(t,n)}},[jt,Yt,xn,He,de]),Un=Po(e=>{if(null==e||"object"!=typeof e)return;const t=gn.current;t&&(t.ingestEdge(e)&&qn(),Zt())},[qn,Zt]),Qn=Po(e=>{const t=gn.current;if(!t)return;let n=!1;for(const o of e)null!=o&&"object"==typeof o&&t.ingestEdge(o)&&(n=!0);n&&qn(),Zt()},[qn,Zt]),Kn=Po(()=>{gn.current?.clear(),Ln.current.clear(),On.current=0,An(gn.current?.layoutVersion??0),kn(null),Bn.current=null,Et.current=!0,Zt()},[Zt]),Zn=Po(()=>{const e=gn.current;e&&(e.tension+=999,qn(),Zt())},[qn,Zt]);Ro(t,()=>({push:Un,pushMany:Qn,removeNode:e=>{const t=gn.current?.removeNode(e)??!1;if(t){const t=Bn.current?.data?"function"==typeof k?k(Bn.current.data):Bn.current.data[k]:void 0;Bn.current&&"node"===Bn.current.nodeOrEdge&&t===e&&(Bn.current=null,kn(null)),Ln.current.delete(e),qn(),Et.current=!0,Zt()}return t},removeEdge:(e,t)=>{const n=gn.current?.removeEdge(e,t)??!1;if(n){if(Bn.current&&"edge"===Bn.current.nodeOrEdge){const n=Bn.current.data;let o;o=void 0!==t?("object"==typeof n?.source?n.source.id:n?.source)===e&&("object"==typeof n?.target?n.target.id:n?.target)===t:!D||!n||("function"==typeof D?D:e=>e?.[D])(n)===e,o&&(Bn.current=null,kn(null))}qn(),Et.current=!0,Zt()}return n},updateNode:(e,t)=>{const n=gn.current?.updateNode(e,t)??null;return n&&(Et.current=!0,Zt()),n},updateEdge:(e,t,n)=>{const o=gn.current?.updateEdge(e,t,n)??[];return o.length>0&&(qn(),Et.current=!0,Zt()),o},clear:Kn,getTopology:()=>gn.current?.getLayoutData()??{nodes:[],edges:[]},getCustomLayout:()=>gn.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>gn.current?.lastCustomLayoutFailure??null,getTopologyDiff:()=>{const e=gn.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:Zn,getTension:()=>gn.current?.tension??0}),[Un,Qn,Kn,Zn,k,qn,Zt,D]);const Jn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(n),eo=Jn?u||(Array.isArray(r)?void 0:r):void 0;To(()=>{const e=gn.current;if(!e)return;const t=++Mn.current;if(Nn.current?.abort(),Nn.current=null,Jn&&eo)e.ingestHierarchy(eo,[jt,Yt]),xn(e,[jt,Yt]),Rn(!1),Wn.current?.("ready"),Et.current=!0,Zt();else{const c=on,u=Array.isArray(rn)?rn:[];if(0===c.length&&0===u.length)return null==o&&null==r||0>=e.nodes.size&&0>=e.edges.size||Kn(),Rn(!1),void Wn.current?.("ready");const d=[jt,Yt],h="force"===n&&!Mt&&s()&&!dt&&l(X,c.length,u.length,$);if(h&&nn&&!In.current&&e.sceneNodes.length>0)return In.current=!0,Rn(!1),Wn.current?.("ready"),Et.current=!0,void Zt();if(h){const n=new AbortController;Nn.current=n;const o=e._lastPositionSnapshot;e.ingestBounded(c,u,d,{deferLayout:!0});const r=e.getLayoutData(),s=i(r.nodes,r.edges,zn.current,d,o);return Rn(!0),Wn.current?.("pending"),a(s,n.signal).then(({positions:n})=>{t===Mn.current&&(e.applyForceLayoutPositions(n,d),xn(e,d),On.current=Cr({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Ln.current,colorScheme:de}),Rn(!1),Wn.current?.("ready"),An(e.layoutVersion),Et.current=!0,Zt())}).catch(n=>{"AbortError"!==n.name&&t===Mn.current&&(e.runLayout(d),xn(e,d),On.current=Cr({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Ln.current,colorScheme:de}),Rn(!1),Wn.current?.("error"),An(e.layoutVersion),Et.current=!0,Zt())}),()=>n.abort()}e.ingestBounded(c,u,d),xn(e,d),Rn(!1),Wn.current?.("ready"),On.current=Cr({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Ln.current,colorScheme:de}),Et.current=!0,Zt()}},[on,rn,o,r,u,eo,Jn,jt,Yt,un,X,$,nn,n,Mt,dt,Zt,Kn,de,xn]),To(()=>{x&&x.length>0&&Qn(x)},[x,Qn]);const{customHoverBehavior:to,customClickBehavior:no}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:o}){return{customHoverBehavior:Er((t,r)=>{e?.(t,r),ye({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:zr,chartId:o,context:r})},[e,n,o]),customClickBehavior:Er((e,r)=>{t?.(e,r),fe({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:zr,chartId:o,context:r})},[t,n,o])}}({customHoverBehavior:Ee,customClickBehavior:ze,onObservation:Be,chartId:Oe}),{hoverHandlerRef:oo,hoverLeaveRef:ro,onPointerMove:so,onPointerLeave:io}=zt,ao=()=>!Mt||(gn.current?.hasCustomRestyle??!1);oo.current=e=>{if(!We)return;const t=ao(),n=bo.current;if(!n)return;const o=gn.current;if(!o)return;const r=Dr({clientX:e.clientX,clientY:e.clientY,canvasRect:n.getBoundingClientRect(),margin:Ht,adjustedWidth:jt,adjustedHeight:Yt,sceneNodes:o.sceneNodes,sceneEdges:o.sceneEdges,nodeQuadtree:o.nodeQuadtree,maxNodeRadius:o.maxNodeRadius});"hit"===r.kind?(Bn.current=r.hover,kn(r.hover),to&&(to(r.hover),t&&(Et.current=!0)),t&&Zt()):Bn.current&&(Bn.current=null,kn(null),to&&(to(null),t&&(Et.current=!0)),t&&Zt())},ro.current=()=>{if(Bn.current){const e=ao();Bn.current=null,kn(null),to&&(to(null),e&&(Et.current=!0)),e&&Zt()}};const lo=So(()=>{});lo.current=e=>{if(L(e.target))return;if(!ze&&!Be)return;const t=bo.current;if(!t)return;const n=gn.current;if(!n)return;const o=Dr({clientX:e.clientX,clientY:e.clientY,canvasRect:t.getBoundingClientRect(),margin:Ht,adjustedWidth:jt,adjustedHeight:Yt,sceneNodes:n.sceneNodes,sceneEdges:n.sceneEdges,nodeQuadtree:n.nodeQuadtree,maxNodeRadius:n.maxNodeRadius});"hit"===o.kind?no(o.hover,{type:"activate",inputType:Te(e.nativeEvent.pointerType)}):"miss"===o.kind&&no(null)};const co=Po(e=>lo.current(e),[]),fo=So(-1),yo=So(null),mo=So(-1),vo=Po(e=>{if(ve(e))return;const t=gn.current;if(!t)return;const n=()=>{fo.current=-1,yo.current=null,mo.current=-1,Bn.current=null,kn(null),to&&(to(null),Et.current=!0),Zt()},o=function(e){const t=[];for(const n of e)if("circle"===n.type&&null!=n.cx){if(0>=n.r)continue;t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("rect"===n.type&&null!=n.x){if(0>=n.w||0>=n.h)continue;t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.datum?.id??"_default"})}else if("arc"===n.type&&null!=n.cx)t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"});else if("symbol"===n.type&&null!=n.cx){if(0>=n.size)continue;t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("glyph"===n.type&&null!=n.cx){if(0>=n.size||null==n.datum)continue;const e=$e(n.glyph,n.size);t.push({x:n.cx+e.centerDx,y:n.cy+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:n.datum?.id??"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.sceneNodes);if(0===o.length)return void(0>fo.current||n());const r=uo(o);let s=fo.current;if(r.flat.length>s||(n(),s=-1)," "===e.key&&s>=0){e.preventDefault();const t=r.flat[s];return void no(E(t.datum||{},t.x,t.y,{nodeOrEdge:"node"}),{type:"activate",inputType:"keyboard"})}if(0>s){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),fo.current=0,mo.current=-1;const t=r.flat[0];yo.current={shape:t.shape,w:t.w,h:t.h};const n=E(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Bn.current=n,kn(n),to&&(to(n,{type:"focus",inputType:"keyboard"}),Et.current=!0),void Zt()}const i=ho(r,s),a=function(e,t,n,o,r){const s=n.flat[t.flatIndex];if(!s)return po(e,t,n);const i=s.datum?.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const o=function(e,t,n){let o=null,r=1/0;for(let s=0;e.flat.length>s;s++){const i=e.flat[s];if(i===t)continue;const a=i.x-t.x,l=i.y-t.y;let c=!1;switch(n){case"right":c=a>0&&Math.abs(a)>=Math.abs(l);break;case"left":c=0>a&&Math.abs(a)>=Math.abs(l);break;case"down":c=l>0&&Math.abs(l)>=Math.abs(a);break;case"up":c=0>l&&Math.abs(l)>=Math.abs(a)}if(!c)continue;const u=a*a+l*l;r>u&&(r=u,o=s)}return o}(n,s,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up")??t.flatIndex;return o!==t.flatIndex&&(r.current=-1),o}case"Enter":{if(null==i)return t.flatIndex;const e=function(e,t){const n=e+"",o=[];for(const e of t){const t=e.datum??e,r=go(t.source),s=go(t.target),i=null!=r,a=null!=s;i&&r+""===n&&a?o.push(s+""):a&&s+""===n&&i&&o.push(r+"")}return o}(i,o);if(0===e.length)return t.flatIndex;const s=n.idToIdx.get(e[(r.current+1)%e.length])??-1;return 0>s?t.flatIndex:(r.current=-1,s)}default:{const o=po(e,t,n);return null!==o&&o!==t.flatIndex&&(r.current=-1),o}}}(e.key,i,r,t.sceneEdges??[],mo);if(null===a)return;if(e.preventDefault(),0>a)return void n();fo.current=a;const l=r.flat[a];yo.current={shape:l.shape,w:l.w,h:l.h};const c={data:l.datum||{},x:l.x,y:l.y,__semioticHoverData:!0,nodeOrEdge:"node"};Bn.current=c,kn(c),to&&(to(c,{type:"focus",inputType:"keyboard"}),Et.current=!0),Zt()},[no,to,Zt]),xo=Po(e=>{fo.current=-1,yo.current=null,so(e)},[so]);Kt.current=()=>{if(Qt.current=null,!Jt.isActive)return;const e=bo.current;if(!e)return;const t=gn.current;t&&function(e){const{canvas:t,store:n,sceneRevisionDiagnostics:o,size:r,margin:s,adjustedWidth:i,adjustedHeight:a,background:l,renderMode:c,hasBackgroundGraphics:u=!1,dirtyRef:d,lastFrameTimeRef:h,now:p,random:f,reducedMotion:y,showParticles:g,isContinuous:m,animate:v,decay:x,pulse:k,thresholds:S,staleness:_,particleStyle:T,getParticleColor:C,pendingAnnotationFrameRef:P,lastAnnotationFrameTimeRef:R,setAnnotationFrame:M,scheduleNextFrame:N}=e,I=t.getContext("2d");if(!I)return;const W=h.current?Math.min((p-h.current)/1e3,.1):.016;h.current=p;const D=n.advanceTransition(y?p+1e6:p),E=!y&&D,z=!y&&n.tickAnimation([i,a],W),B=d.current,L=o?.beforeCompute(n.getLastUpdateResult(),E),O=D||B||z;O&&n.buildScene([i,a]),L&&o?.afterCompute(L,O,!1);const H=g&&!y&&!!n.particlePool,F=!!((j={dirtyOrRebuilt:B,transitioning:E,animationTicked:z,continuous:H||m,liveEncoding:!!x||!!k||!!S||!1!==v&&n.hasActiveTopologyDiff||n.hasActivePulses||n.hasActiveThresholds,forced:n.consumeStylePaintPending()}).dirtyOrRebuilt||j.transitioning||j.animationTicked||j.continuous||j.liveEncoding||j.forced);var j;const $=!!_&&n.lastIngestTime>0&&p-n.lastIngestTime>(_?.threshold??5e3);if(F){const e=w();if(!A(t,r,s,e))return;if(I.clearRect(-s.left,-s.top,r[0],r[1]),vn(I,{background:l,hasBackgroundGraphics:u,width:i,height:a}),x&&n.applyDecay(),k&&n.applyPulse(p),S&&n.applyThresholds(p),!1!==v&&n.applyTopologyDiff(p),$&&(I.globalAlpha=_?.dimOpacity??.5),Q({context:I,nodes:n.sceneEdges,renderMode:c,pixelRatio:e,paintBuiltIn:e=>function(e,t){for(const n of t)switch(n.type){case"bezier":kr(e,n);break;case"line":wr(e,n);break;case"ribbon":Ar(e,n);break;case"curved":Sr(e,n)}}(I,e)}),Q({context:I,nodes:n.sceneNodes,renderMode:c,pixelRatio:e,paintBuiltIn:e=>{const t=e;!function(e,t){for(const n of t){if("rect"!==n.type)continue;const t=n;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=Ce(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.strokeRect(t.x,t.y,t.w,t.h)),Dn(e,t),e.restore())}}(I,t),function(e,t){for(const n of t){if("circle"!==n.type)continue;const t=n;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=Ce(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),En(e,t),e.restore())}}(I,t),function(e,t){for(const n of t){if("arc"!==n.type)continue;const t=n;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=Ce(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),e.restore()}}(I,t),function(e,t){const n=e.globalAlpha;for(const o of t){if("symbol"!==o.type)continue;const t=o;if(0>=t.size)continue;const r=Tr(t);if(!r)continue;e.save(),e.translate(t.cx,t.cy),t.rotation&&e.rotate(t.rotation);const s=t.style.opacity??1;t.style.fill&&(e.globalAlpha=n*s*(t.style.fillOpacity??1),e.fillStyle=Ce(e,t.style.fill,"#007bff"),e.fill(r)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*s,e.strokeStyle=Qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.stroke(r)),e.restore()}}(I,t),function(e,t){const n=e.globalAlpha;for(const o of t)"glyph"===o.type&&Xn(e,o,o.cx,o.cy,n);e.globalAlpha=n}(I,t)}}),H&&!$){const e=n.edgesArray;if(e.length>0){!function(e,t,n,o,r=Math.random){const s=o.spawnRate??.1,i=o.maxPerEdge??50;for(let o=0;t.length>o;o++){const a=t[o];if(!a.bezier)continue;if(e.countForEdge(o)>=i)continue;const l=a.value*s*n*(a.bezier.circular?.3:1),c=Math.floor(l),u=l-c;let d=c;r()<u&&d++;for(let t=0;d>t&&e.countForEdge(o)<i;t++)e.spawn(o,r)}}(n.particlePool,e,W,T,f);const t=.5*(T.speedMultiplier??1);let o;if(T.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);o=e.map(e=>.3+(e.value||1)/t*1.7)}n.particlePool.step(W,t,e,o),function(e,t,n,o,r){const s=o.radius??3;e.globalAlpha=o.opacity??.7;for(let i=0;t.particles.length>i;i++){const a=t.particles[i];if(!a.active)continue;const l=n[a.edgeIndex];if(!l)continue;let c;c="string"==typeof o.color&&"inherit"!==o.color?o.color:r(l),e.fillStyle=Qe(e,c)||c,e.beginPath(),e.arc(a.x,a.y,s,0,2*Math.PI),e.fill()}e.globalAlpha=1}(I,n.particlePool,e,T,C)}}$&&(I.globalAlpha=1)}d.current=!1,(B||E||z)&&t.setAttribute("aria-label",b(n.sceneNodes?.length??0,n.sceneEdges?.length??0,"Network chart"));const Y=B||E||z||P.current;Y&&p-R.current>=33?(M(e=>e+1),R.current=p,P.current=!1):P.current=!!Y,(m||E||null!=n.transition||z||n.hasActivePulses||n.hasActiveThresholds||!1!==v&&n.hasActiveTopologyDiff||P.current)&&N()}({canvas:e,store:t,sceneRevisionDiagnostics:mn.current,size:Ot,margin:Ht,adjustedWidth:jt,adjustedHeight:Yt,background:Ie,renderMode:ae,hasBackgroundGraphics:!!ot,dirtyRef:Et,lastFrameTimeRef:hn,now:Jt.now(),random:Jt.random,reducedMotion:!!Bt.current,showParticles:re,isContinuous:Gn,animate:at,decay:rt,pulse:st,thresholds:gt,staleness:lt,particleStyle:an,getParticleColor:Vn,pendingAnnotationFrameRef:yn,lastAnnotationFrameTimeRef:fn,setAnnotationFrame:_n,scheduleNextFrame:()=>{Zt()}})};const{canvasRef:bo}=M(zt,{hydrated:tn,wasHydratingFromSSR:nn,storeRef:gn,dirtyRef:Et,canvasPaintDependencies:[n,jt,Yt,Ie,ot,ae,Zt]});Ft(lt,gn,Et,Zt,Tn,Cn);const ko=We&&bn?Br(p,{x:bn.x,y:bn.y,containerWidth:jt,containerHeight:Yt,margin:Ht,className:"stream-network-tooltip",zIndex:2,children:De?De(bn):Br(xr,{data:bn})}):null;if(xe||!tn&&nn)return Br(yr,{props:e,store:gn.current,responsiveRef:Lt,size:Ot,margin:Ht,adjustedWidth:jt,adjustedHeight:Yt,resolvedBackground:Vt,resolvedForeground:Xt});const wo=gn.current;return Lr("div",{ref:Lt,className:"stream-network-frame"+(Ne?" "+Ne:""),role:"group","aria-label":bt||("string"==typeof tt?tt:"Network chart"),tabIndex:0,"aria-busy":Pn||void 0,style:{position:"relative",width:Pe?"100%":Ot[0],height:Re?"100%":Ot[1],overflow:"visible"},onKeyDown:vo,children:["production"!==process.env.NODE_ENV&&gn.current&&Br(g,{store:gn.current,diagnostics:mn.current}),mt&&Br(v,{tableId:Ut}),mt&&Br(y,{nodes:wo?.sceneNodes??[],edges:wo?.sceneEdges??[],chartType:"Network chart",tableId:Ut,chartTitle:"string"==typeof tt?tt:void 0}),Br(m,{summary:kt}),Br(d,{hoverPoint:bn}),Lr("div",{role:"img","aria-label":bt||("string"==typeof tt?tt:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:We?xo:void 0,onMouseLeave:We?io:void 0,onClick:ze||Be?co:void 0,children:[Pn&&!1!==V&&Br("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:C(!0,Ot[0],Ot[1],V)}),Br(h,{size:Ot,margin:Ht,overflowVisible:!0,children:Vt}),Br("canvas",{ref:bo,"aria-label":b(wo?.sceneNodes?.length??0,wo?.sceneEdges?.length??0,"Network chart"),style:{position:"absolute",top:0,left:0}}),Br(lr,{width:jt,height:Yt,totalWidth:Ot[0],totalHeight:Ot[1],margin:Ht,labels:wo?.labels||[],sceneNodes:wo?.sceneNodes,title:tt,legend:Ve,legendPosition:Ge,legendLayout:qe,legendHoverBehavior:Ue,legendClickBehavior:Ze,legendHighlightedCategory:Je,legendIsolatedCategories:et,foregroundGraphics:yt(Xt,c(gn.current?.customLayoutOverlays,Wt??null)),annotations:Fe,onAnnotationActivate:je,onObservation:Le??Be,chartId:Oe,chartType:"StreamNetworkFrame",autoPlaceAnnotations:Ye,svgAnnotationRules:Xe,annotationFrame:Sn}),Br(hr,{marks:wo?.customLayoutHtmlMarks,margin:Ht,selection:Wt??null}),Br(f,{active:fo.current>=0,hoverPoint:bn,margin:Ht,size:Ot,shape:yo.current?.shape,width:yo.current?.w,height:yo.current?.h}),ko,lt?.showBadge&&Br($t,{isStale:Tn,position:lt.badgePosition})]})]})}));$r.displayName="StreamNetworkFrame";var Yr=$r,Xr=class e{constructor(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}push(e){if(!Number.isFinite(e))return;this._count+=1;const t=e-this._mean;this._mean+=t/this._count,this._m2+=t*(e-this._mean),this._min>e&&(this._min=e),e>this._max&&(this._max=e)}merge(e){if(0===e._count)return;if(0===this._count)return this._count=e._count,this._mean=e._mean,this._m2=e._m2,this._min=e._min,void(this._max=e._max);const t=this._count+e._count,n=e._mean-this._mean;this._mean+=n*e._count/t,this._m2+=e._m2+n*n*this._count*e._count/t,this._count=t,this._min>e._min&&(this._min=e._min),e._max>this._max&&(this._max=e._max)}clear(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}clone(){const t=new e;return t._count=this._count,t._mean=this._mean,t._m2=this._m2,t._min=this._min,t._max=this._max,t}get count(){return this._count}get mean(){return 0===this._count?0:this._mean}get sum(){return 0===this._count?0:this._mean*this._count}get variance(){return 2>this._count?0:this._m2/this._count}get stddev(){return Math.sqrt(this.variance)}get sampleVariance(){return 2>this._count?0:this._m2/(this._count-1)}get sampleStddev(){return Math.sqrt(this.sampleVariance)}get min(){return this._min}get max(){return this._max}},Vr=class{constructor(e){this.windows=new Map,this.sessions=[],this.latest=-1/0,this.type=e.window??"tumbling",this.size=e.size;const t=e.hop??e.size;this.hop=t>0&&e.size>=t?t:e.size,this.gap=e.gap??e.size,this.retain=null!=e.retain&&e.retain>0?e.retain:1/0}push(e,t){Number.isFinite(e)&&Number.isFinite(t)&&(e>this.latest&&(this.latest=e),"session"===this.type?this.pushSession(e,t):this.pushFixed(e,t),this.prune())}pushFixed(e,t){if("tumbling"===this.type||this.hop>=this.size)return void this.bump(Math.floor(e/this.size)*this.size,t);const n=this.hop,o=Math.floor(e/n);for(let r=Math.floor((e-this.size)/n)+1;o>=r;r++)this.bump(r*n,t)}bump(e,t){let n=this.windows.get(e);n||(n=new Xr,this.windows.set(e,n)),n.push(t)}pushSession(e,t){const n=this.gap,o=new Xr;o.push(t);let r=e,s=e;const i=[],a={start:r,end:s,stats:o};for(const t of this.sessions)e-n>t.end||t.start>e+n?i.push(t):(a.stats.merge(t.stats),r>t.start&&(r=t.start),t.end>s&&(s=t.end));a.start=r,a.end=s,i.push(a),i.sort((e,t)=>e.start-t.start),this.sessions=i}prune(){if(this.retain===1/0)return;if("session"===this.type)return void(this.sessions.length>this.retain&&(this.sessions=this.sessions.slice(this.sessions.length-this.retain)));if(this.retain>=this.windows.size)return;const e=[...this.windows.keys()].sort((e,t)=>e-t),t=e.length-this.retain;for(let n=0;t>n;n++)this.windows.delete(e[n])}emit(){return"session"===this.type?this.emitSessions():this.emitFixed()}emitFixed(){const e=[];for(const[t,n]of this.windows){const o=t+this.size;e.push(this.row(t,o,n,o>this.latest))}return e.sort((e,t)=>e.start-t.start),e}emitSessions(){return this.sessions.map(e=>this.row(e.start,e.end,e.stats,this.gap>this.latest-e.end))}row(e,t,n,o){return{start:e,end:t,count:n.count,mean:n.mean,sum:n.sum,min:n.min,max:n.max,stddev:n.stddev,partial:o}}get windowCount(){return"session"===this.type?this.sessions.length:this.windows.size}get watermark(){return this.latest}clear(){this.windows.clear(),this.sessions=[],this.latest=-1/0}};function Gr(e,t){switch(t){case"sum":return e.sum;case"min":return e.min;case"max":return e.max;case"count":return e.count;default:return e.mean}}function qr(e,t,n,o=1){if("none"===t)return null;if("minmax"===t)return[e.min,e.max];const r=Gr(e,n),s=e.stddev*o;return[r-s,r+s]}var Ur={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},Qr=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g;function Kr(e){if("number"==typeof e)return Number.isFinite(e)&&e>0?e:null;if("string"!=typeof e)return null;const t=e.trim();if(""===t)return null;Qr.lastIndex=0;let n,o=0,r=0;for(;null!==(n=Qr.exec(t));){const e=parseFloat(n[1]),t=Ur[n[2]];if(null==t||!Number.isFinite(e))return null;o+=e*t,r+=n[0].length}return r!==t.length?null:o>0?o:null}var Zr=class{constructor(e){this.held=[],this._watermark=-1/0,this._lateCount=0,this.lateness=e.lateness>0?e.lateness:0,this.getTime=e.getTime,this.latePolicy=e.latePolicy??"drop"}push(e){const t=this.getTime(e);if(!Number.isFinite(t))return{released:[e],late:[]};const n=[];return this._watermark!==-1/0&&this._watermark-this.lateness>t?(this._lateCount+=1,n.push(e),"drop"===this.latePolicy?{released:[],late:n}:{released:[e],late:n}):(t>this._watermark&&(this._watermark=t),this.held.push(e),{released:this.drain(),late:n})}drain(){const e=this._watermark-this.lateness;if(0===this.held.length)return[];const t=[],n=[];for(const o of this.held)this.getTime(o)>e?n.push(o):t.push(o);return this.held=n,t.sort((e,t)=>this.getTime(e)-this.getTime(t)),t}flush(){const e=this.held;return this.held=[],e.sort((e,t)=>this.getTime(e)-this.getTime(t)),e}clear(){this.held=[],this._watermark=-1/0,this._lateCount=0}get watermark(){return this._watermark}get lateCount(){return this._lateCount}get heldCount(){return this.held.length}};import{useRef as Jr,useImperativeHandle as es,forwardRef as ts,useCallback as ns,useState as os,useEffect as rs}from"react";import{jsx as ss,jsxs as is}from"react/jsx-runtime";var as={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, #f3f4f6)",padding:"6px 10px",borderRadius:"var(--semiotic-tooltip-radius, 4px)",fontSize:"var(--semiotic-tooltip-font-size, 12px)",fontFamily:"var(--semiotic-tick-font-family, var(--semiotic-font-family, sans-serif))",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.25))",lineHeight:1.4,pointerEvents:"none",whiteSpace:"nowrap"},ls={opacity:.7,marginRight:4};function cs(e,t,n){if(null!=e)return"function"==typeof t?t(e):e["string"==typeof t?t:n]}function us(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function ds(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:o="x",yLabel:r="y"}=e;return e=>{const s=e?.data??null,i=cs(s,t,"time"),a=cs(s,n,"value");return is("div",{className:"semiotic-tooltip",style:as,children:[is("div",{children:[is("span",{style:ls,children:[o,":"]}),us(i)]}),is("div",{children:[is("span",{style:ls,children:[r,":"]}),us(a)]})]})}}function hs(e,t){return null!=e?e:Math.max(t?.length??0,200)}var ps="time",fs="value",ys="__aggLower",gs="__aggUpper",ms="__aggPartial",vs="count",xs="__aggStart",bs="__aggEnd";function ks(e,t){const n=t.stat??"mean",o=t.band??"none",r=t.sigma??1;return e.emit().map(e=>{const t={[ps]:(e.start+e.end)/2,[fs]:Gr(e,n),[vs]:e.count,[ms]:e.partial,[xs]:e.start,[bs]:e.end},s=qr(e,o,n,r);return s&&(t[ys]=s[0],t[gs]=s[1]),t})}function ws(e){const{linkedHover:t,selection:n,onObservation:o,onClick:r,hoverRadius:s,hoverHighlight:i,forceHoverBehavior:a,forceClickBehavior:l,mobileInteraction:c,customHoverBehavior:u,customClickBehavior:d,linkedHoverInClickPredicate:h=!0}=e,p={};o&&(p.annotationObservationCallback=o);const f=c?.enabled?Math.max(s??30,Math.ceil((c.targetSize||44)/2),24):s;return(a||t||o||r||i)&&(p.customHoverBehavior=u),d&&(l||(h?o||r||t:o||r)||c?.enabled&&(c.tapToSelect||c.tapToLockTooltip)&&(t||i||n))&&(p.customClickBehavior=d),null!=f&&(p.hoverRadius=f),p}import{jsx as As}from"react/jsx-runtime";function Ss(e,t,n){const o="function"==typeof t?t(e):e[t??n];if(null==o)return null;if(o instanceof Date)return o.getTime();const r=Number(o);return Number.isFinite(r)?r:null}var _s=ts(function(e,t){const n=We(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:o,margin:r,className:s,arrowOfTime:i="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:d,timeExtent:h,valueExtent:p,extentPadding:f,stroke:y="#007bff",strokeWidth:g=2,strokeDasharray:m,opacity:v,background:x,tooltipContent:b,tooltip:k,onHover:w,annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:T,tickFormatTime:P,tickFormatValue:R,decay:M,pulse:N,staleness:I,transition:W,linkedHover:D,selection:E,onObservation:z,chartId:B,loading:L,loadingContent:O,emptyContent:H,emphasis:F,legendPosition:j,aggregate:$,eventTime:Y}=e,X=n.showAxes,V=n.enableHover,G=r??n.marginDefaults,q=o??[n.width,n.height],U=b??k??ds({timeAccessor:u,valueAccessor:d}),Q=Jr(null),{customHoverBehavior:K}=De({selection:E,linkedHover:D,unwrapData:!0,onObservation:z,chartType:"RealtimeLineChart",chartId:B}),Z=ns(e=>{w&&w(e),K(e)},[w,K]),J=null!=$,[ee,te]=os([]),ne=Jr(null),oe=Jr($);oe.current=$;const re=Jr(J);re.current=J;const se=Jr(ee);se.current=ee;const ie=Jr({timeAccessor:u,valueAccessor:d});ie.current={timeAccessor:u,valueAccessor:d},rs(()=>{if(!J)return void(ne.current=null);const e=oe.current,t=function(e){const t=e.window??"tumbling",n=Kr("session"===t?e.gap??e.size:e.size);if(null==n)return null;const o=null!=e.hop?Kr(e.hop):void 0,r=null!=e.gap?Kr(e.gap):void 0;return new Vr({window:t,size:n,hop:o??void 0,gap:r??void 0,retain:e.retain})}(e);if(ne.current=t,t&&c){const{timeAccessor:e,valueAccessor:n}=ie.current;for(const o of c){const r=Ss(o,e,"time"),s=Ss(o,n,"value");null!=r&&null!=s&&t.push(r,s)}}te(t?ks(t,e):[])},[J?[$.window??"tumbling",$.size,$.hop??"",$.gap??"",$.retain??""].join("|"):"",J,c]),rs(()=>{J&&ne.current&&te(ks(ne.current,oe.current))},[$?.stat,$?.band,$?.sigma]);const ae=ns(e=>{const t=ne.current,n=oe.current;if(!t||!n)return;const{timeAccessor:o,valueAccessor:r}=ie.current;for(const n of e){const e=Ss(n,o,"time"),s=Ss(n,r,"value");null!=e&&null!=s&&t.push(e,s)}te(ks(t,n))},[]),le=null!=Y,ce=Jr(null),ue=Jr(Y);ue.current=Y;const de=Jr(le);de.current=le;const he=Jr(z);he.current=z;const pe=Jr(B);pe.current=B,rs(()=>{ce.current=le?function(e){const t=Kr(e.lateness);return null==t?null:new Zr({lateness:t,getTime:e=>Ss(e,ie.current.timeAccessor,"time")??NaN,latePolicy:e.latePolicy??"drop"})}(ue.current):null},[le?`${Y.lateness}|${Y.latePolicy??"drop"}`:"",le]);const fe=ns(e=>{0!==e.length&&(re.current?ae(e):Q.current?.pushMany(e))},[ae]),ye=ns(e=>{const t=ce.current;if(!de.current||!t)return void fe(e);const n=[];for(const o of e){const e=t.push(o);if(e.released.length&&n.push(...e.released),e.late.length){const n=he.current;if(n){const{timeAccessor:o}=ie.current,r=ue.current?.latePolicy??"drop";for(const s of e.late)n({type:"late-data",datum:s,eventTime:Ss(s,o,"time")??NaN,watermark:t.watermark,policy:r,lateCount:t.lateCount,timestamp:Date.now(),chartType:"RealtimeLineChart",chartId:pe.current})}}}fe(n)},[fe]);es(t,()=>({push:e=>ye([e]),pushMany:e=>ye(e),remove:e=>re.current?[]:Q.current?.remove(e)??[],update:(e,t)=>re.current?[]:Q.current?.update(e,t)??[],clear:()=>{ce.current?.clear(),re.current?(ne.current?.clear(),te([])):Q.current?.clear()},getData:()=>re.current?se.current:Q.current?.getData()??[],getScales:()=>Q.current?.getScales()??null}),[ye]);const ge=C(L,q[0],q[1],O),me=ge?null:_(J?void 0:c,q[0],q[1],H),ve={stroke:y,strokeWidth:g,strokeDasharray:m};null!=v&&(ve.opacity=v);const xe=hs(l,c),be=J?ee:c,ke=J?ps:u,we=J?fs:d,Ae=J&&$&&"none"!==($.band??"none")?{y0Accessor:ys,y1Accessor:gs,perSeries:!1}:void 0;return ge||me||As(Ao,{ref:Q,chartType:"line",runtimeMode:"streaming",size:q,margin:G,className:F?`${s||""} semiotic-emphasis-${F}`.trim():s,arrowOfTime:i,windowMode:J?"growing":a,windowSize:J?Math.max(1,$?.retain??Math.max(ee.length,600)):xe,data:be,timeAccessor:ke,valueAccessor:we,xExtent:h,yExtent:p,extentPadding:f,band:Ae,lineStyle:ve,showAxes:X,background:x,hoverAnnotation:V,tooltipContent:U,...ws({linkedHover:D,selection:E,onObservation:z,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:Z}),annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:T,tickFormatTime:P,tickFormatValue:R,decay:M,pulse:N,staleness:I,transition:W,pointIdAccessor:e.pointIdAccessor,legendPosition:j})});_s.displayName="RealtimeLineChart";import{useRef as Ts,useImperativeHandle as Cs,forwardRef as Ps,useCallback as Rs,useMemo as Ms}from"react";import{jsx as Ns}from"react/jsx-runtime";var Is=Ps(function(e,t){const n=We(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,showAxes:e.showAxes,showLegend:e.showLegend,enableHover:null!=e.enableHover?!!e.enableHover:void 0,linkedHover:e.linkedHover,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{binSize:o,size:r,margin:s,className:i,arrowOfTime:a="right",windowMode:l="sliding",windowSize:c,data:u,timeAccessor:d,valueAccessor:h,direction:p="up",timeExtent:f,valueExtent:y,extentPadding:g,categoryAccessor:m,colors:v,fill:x,stroke:b,strokeWidth:k,opacity:w,gap:A,background:S,tooltipContent:T,tooltip:P,onHover:R,annotations:M,autoPlaceAnnotations:N,svgAnnotationRules:I,tickFormatTime:W,tickFormatValue:D,linkedHover:E,selection:z,decay:B,pulse:L,staleness:O,transition:H,onObservation:F,chartId:j,loading:$,loadingContent:Y,emptyContent:X,emphasis:V,legendPosition:G,legend:q,brush:U,onBrush:Q,linkedBrush:K}=e,J=n.showAxes,ee=n.enableHover,te=r??[n.width,n.height],ne=Ms(()=>v?e=>v[e]??x??"#999":void 0,[v,x]),{legend:oe,margin:re,legendPosition:se}=Ie({data:u??[],colorBy:m,colorScale:ne,showLegend:n.showLegend,legendPosition:G,userMargin:s,defaults:n.marginDefaults,additionalLegend:q}),ie=T??P??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const o=e?.data??null;if(null==o?.binStart||null==o?.binEnd){const e=cs(o,t,"time"),r=cs(o,n,"value");return is("div",{className:"semiotic-tooltip",style:as,children:[is("div",{children:[ss("span",{style:ls,children:"x:"}),us(e)]}),is("div",{children:[ss("span",{style:ls,children:"y:"}),us(r)]})]})}return is("div",{className:"semiotic-tooltip",style:as,children:[is("div",{children:[ss("span",{style:ls,children:"range:"}),us(o.binStart),"–",us(o.binEnd)]}),null!=o.total&&is("div",{children:[ss("span",{style:ls,children:"count:"}),us(o.total)]}),null!=o.category&&is("div",{children:[ss("span",{style:ls,children:"category:"}),us(o.category)]})]})}}({timeAccessor:d,valueAccessor:h}),ae=Ts(null),{customHoverBehavior:le}=De({selection:z,linkedHover:E,unwrapData:!0,onObservation:F,chartType:"RealtimeHistogram",chartId:j}),ce=Rs(e=>{R&&R(e),le(e)},[R,le]),ue=!0===U?{dimension:"x",snap:"bin"}:"x"===U?{dimension:"x"}:"object"==typeof U?U:void 0,de=Se(K),he="string"==typeof d?d:"time",pe=Ne({name:de?.name||"__unused_hist_brush__",xField:de?.xField||he,...de?.yField?{yField:de.yField}:{}}),fe=Ts(pe.brushInteraction);fe.current=pe.brushInteraction;const ye=Rs(e=>{if(Q&&Q(e),F&&F(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:j}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:j}),de){const t=fe.current;t.end(e?"xBrush"===t.brush?e.x:"yBrush"===t.brush?e.y:[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:null)}},[Q,F,j,de]);Cs(t,()=>({push:e=>ae.current?.push(e),pushMany:e=>ae.current?.pushMany(e),remove:e=>ae.current?.remove(e)??[],update:(e,t)=>ae.current?.update(e,t)??[],clear:()=>ae.current?.clear(),getData:()=>ae.current?.getData()??[],getScales:()=>ae.current?.getScales()??null}),[]);const ge=C($,te[0],te[1],Y),me=ge?null:_(u,te[0],te[1],X),ve={};null!=x&&(ve.fill=x),null!=b&&(ve.stroke=b),null!=k&&(ve.strokeWidth=k),null!=w&&(ve.opacity=w),null!=A&&(ve.gap=A);const xe=V?`${i||""} semiotic-emphasis-${V}`.trim():i,be=hs(c,u),ke=Ms(()=>"down"!==p?y:Z({data:u,valueAccessor:h,timeAccessor:d,binSize:o,valueExtent:y,extentPadding:g}),[p,u,h,d,o,y,g]);return ge||me||Ns(Ao,{ref:ae,chartType:"bar",runtimeMode:"streaming",size:te,margin:re,className:xe,arrowOfTime:a,windowMode:l,windowSize:be,data:u,timeAccessor:d,valueAccessor:h,xExtent:f,yExtent:ke,extentPadding:g,binSize:o,categoryAccessor:m,barColors:v,barStyle:ve,showAxes:J,background:S,hoverAnnotation:ee,tooltipContent:ie,...ws({linkedHover:E,selection:z,onObservation:F,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:ce}),annotations:M,autoPlaceAnnotations:N,svgAnnotationRules:I,tickFormatTime:W,tickFormatValue:D,decay:B,pulse:L,staleness:O,transition:H,pointIdAccessor:e.pointIdAccessor,legend:oe,legendPosition:se,brush:ue||(K?{dimension:"x"}:void 0),onBrush:ue||K?ye:void 0})});function Ws(e){return Ns(Is,{...e,windowMode:"growing"})}Is.displayName="RealtimeHistogram",Ws.displayName="TemporalHistogram";import{useRef as Ds,useImperativeHandle as Es,forwardRef as zs,useCallback as Bs}from"react";import{jsx as Ls}from"react/jsx-runtime";var Os=zs(function(e,t){const n=We(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:o,margin:r,className:s,arrowOfTime:i="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:d,timeExtent:h,valueExtent:p,yScaleType:f,extentPadding:y,categoryAccessor:g,colors:m,radius:v,fill:x,opacity:b,stroke:k,strokeWidth:w,pointStyle:A,background:S,tooltipContent:T,tooltip:P,onHover:R,annotations:M,autoPlaceAnnotations:N,svgAnnotationRules:I,tickFormatTime:W,tickFormatValue:D,linkedHover:E,selection:z,onObservation:B,chartId:L,loading:O,loadingContent:H,emptyContent:F,emphasis:j,legendPosition:$}=e,Y=n.showAxes,X=n.enableHover,V=r??n.marginDefaults,G=o??[n.width,n.height],q=T??P??ds({timeAccessor:u,valueAccessor:d}),U=Ds(null),{customHoverBehavior:Q}=De({selection:z,linkedHover:E,unwrapData:!0,onObservation:B,chartType:"RealtimeSwarmChart",chartId:L}),K=Bs(e=>{R&&R(e),Q(e)},[R,Q]);Es(t,()=>({push:e=>U.current?.push(e),pushMany:e=>U.current?.pushMany(e),remove:e=>U.current?.remove(e)??[],update:(e,t)=>U.current?.update(e,t)??[],clear:()=>U.current?.clear(),getData:()=>U.current?.getData()??[],getScales:()=>U.current?.getScales()??null}),[]);const Z=C(O,G[0],G[1],H),J=Z?null:_(c,G[0],G[1],F),ee={};null!=v&&(ee.radius=v),null!=x&&(ee.fill=x),null!=b&&(ee.opacity=b),null!=k&&(ee.stroke=k),null!=w&&(ee.strokeWidth=w);const te=A,ne=j?`${s||""} semiotic-emphasis-${j}`.trim():s,oe=hs(l,c);return Z||J||Ls(Ao,{ref:U,chartType:"swarm",runtimeMode:"streaming",size:G,margin:V,className:ne,arrowOfTime:i,windowMode:a,windowSize:oe,data:c,timeAccessor:u,valueAccessor:d,xExtent:h,yExtent:p,yScaleType:f,extentPadding:y,categoryAccessor:g,barColors:m,swarmStyle:ee,pointStyle:te,showAxes:Y,background:S,hoverAnnotation:X,tooltipContent:q,...ws({linkedHover:E,selection:z,onObservation:B,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:K}),annotations:M,autoPlaceAnnotations:N,svgAnnotationRules:I,tickFormatTime:W,tickFormatValue:D,legendPosition:$,pointIdAccessor:e.pointIdAccessor})});Os.displayName="RealtimeSwarmChart";import{useRef as Hs,useImperativeHandle as Fs,forwardRef as js,useCallback as $s}from"react";import{jsx as Ys}from"react/jsx-runtime";var Xs=js(function(e,t){const n=We(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:o,margin:r,className:s,arrowOfTime:i="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:d,timeExtent:h,valueExtent:p,extentPadding:f,positiveColor:y,negativeColor:g,connectorStroke:m,connectorWidth:v,gap:x,stroke:b,strokeWidth:k,opacity:w,background:A,tooltipContent:S,tooltip:T,onHover:P,annotations:R,autoPlaceAnnotations:M,svgAnnotationRules:N,tickFormatTime:I,tickFormatValue:W,linkedHover:D,selection:E,onObservation:z,chartId:B,loading:L,loadingContent:O,emptyContent:H,emphasis:F,legendPosition:j}=e,$=n.showAxes,Y=n.enableHover,X=r??n.marginDefaults,V=o??[n.width,n.height],G=S??T??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const o=e?.data??null,r=cs(o,t,"time"),s=o?.delta??cs(o,n,"value"),i=o?.cumEnd,a="number"==typeof s?0>s?us(s):"+"+us(s):us(s);return is("div",{className:"semiotic-tooltip",style:as,children:[is("div",{children:[ss("span",{style:ls,children:"x:"}),us(r)]}),is("div",{children:[ss("span",{style:ls,children:"Δ:"}),a]}),null!=i&&is("div",{children:[ss("span",{style:ls,children:"total:"}),us(i)]})]})}}({timeAccessor:u,valueAccessor:d}),q=Hs(null),{customHoverBehavior:U}=De({selection:E,linkedHover:D,unwrapData:!0,onObservation:z,chartType:"RealtimeWaterfallChart",chartId:B}),Q=$s(e=>{P&&P(e),U(e)},[P,U]);Fs(t,()=>({push:e=>q.current?.push(e),pushMany:e=>q.current?.pushMany(e),remove:e=>q.current?.remove(e)??[],update:(e,t)=>q.current?.update(e,t)??[],clear:()=>q.current?.clear(),getData:()=>q.current?.getData()??[],getScales:()=>q.current?.getScales()??null}),[]);const K=C(L,V[0],V[1],O),Z=K?null:_(c,V[0],V[1],H),J={};null!=y&&(J.positiveColor=y),null!=g&&(J.negativeColor=g),null!=m&&(J.connectorStroke=m),null!=v&&(J.connectorWidth=v),null!=x&&(J.gap=x),null!=b&&(J.stroke=b),null!=k&&(J.strokeWidth=k),null!=w&&(J.opacity=w);const ee=F?`${s||""} semiotic-emphasis-${F}`.trim():s,te=hs(l,c);return K||Z||Ys(Ao,{ref:q,chartType:"waterfall",runtimeMode:"streaming",size:V,margin:X,className:ee,arrowOfTime:i,windowMode:a,windowSize:te,data:c,timeAccessor:u,valueAccessor:d,xExtent:h,yExtent:p,extentPadding:f,waterfallStyle:J,showAxes:$,background:A,hoverAnnotation:Y,tooltipContent:G,...ws({linkedHover:D,selection:E,onObservation:z,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:Q}),annotations:R,autoPlaceAnnotations:M,svgAnnotationRules:N,tickFormatTime:I,tickFormatValue:W,legendPosition:j,pointIdAccessor:e.pointIdAccessor})});Xs.displayName="RealtimeWaterfallChart";import{useRef as Vs,useImperativeHandle as Gs,forwardRef as qs,useCallback as Us}from"react";import{jsx as Qs}from"react/jsx-runtime";var Ks=qs(function(e,t){const n=We(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:o,margin:r,className:s,arrowOfTime:i="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:d,categoryAccessor:h,timeExtent:p,valueExtent:f,extentPadding:y,heatmapXBins:g=20,heatmapYBins:m=20,aggregation:v="count",background:x,tooltipContent:b,tooltip:k,onHover:w,annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:T,tickFormatTime:P,tickFormatValue:R,decay:M,pulse:N,staleness:I,linkedHover:W,selection:D,onObservation:E,chartId:z,loading:B,loadingContent:L,emptyContent:O,emphasis:H,legendPosition:F}=e,j=n.showAxes,$=n.enableHover,Y=r??n.marginDefaults,X=o??[n.width,n.height],V=b??k??function(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:o="x",yLabel:r="y"}=e;return e=>{const s=e?.data??null,i=s?.xCenter??cs(s,t,"time"),a=s?.yCenter??cs(s,n,"value"),l=s?.count,c=s?.sum,u=s?.value,d=s?.agg??"count";return is("div",{className:"semiotic-tooltip",style:as,children:[is("div",{children:[is("span",{style:ls,children:[o,":"]}),us(i)]}),is("div",{children:[is("span",{style:ls,children:[r,":"]}),us(a)]}),null!=l&&is("div",{children:[ss("span",{style:ls,children:"count:"}),us(l)]}),"sum"===d&&null!=c&&is("div",{children:[ss("span",{style:ls,children:"sum:"}),us(c)]}),"mean"===d&&null!=u&&is("div",{children:[ss("span",{style:ls,children:"mean:"}),us(u)]})]})}}({timeAccessor:u,valueAccessor:d}),G=Vs(null),{customHoverBehavior:q}=De({selection:D,linkedHover:W,unwrapData:!0,onObservation:E,chartType:"RealtimeHeatmap",chartId:z}),U=Us(e=>{w&&w(e),q(e)},[w,q]);Gs(t,()=>({push:e=>G.current?.push(e),pushMany:e=>G.current?.pushMany(e),remove:e=>G.current?.remove(e)??[],update:(e,t)=>G.current?.update(e,t)??[],clear:()=>G.current?.clear(),getData:()=>G.current?.getData()??[],getScales:()=>G.current?.getScales()??null}),[]);const Q=C(B,X[0],X[1],L),K=Q?null:_(c,X[0],X[1],O),Z=H?`${s||""} semiotic-emphasis-${H}`.trim():s,J=hs(l,c);return Q||K||Qs(Ao,{ref:G,chartType:"heatmap",runtimeMode:"streaming",size:X,margin:Y,className:Z,arrowOfTime:i,windowMode:a,windowSize:J,data:c,timeAccessor:u,valueAccessor:d,categoryAccessor:h,xExtent:p,yExtent:f,extentPadding:y,heatmapXBins:g,heatmapYBins:m,heatmapAggregation:v,showAxes:j,background:x,hoverAnnotation:$,tooltipContent:V,...ws({linkedHover:W,selection:D,onObservation:E,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:U}),annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:T,tickFormatTime:P,tickFormatValue:R,decay:M,pulse:N,staleness:I,legendPosition:F,pointIdAccessor:e.pointIdAccessor})});Ks.displayName="RealtimeHeatmap";export{Be as DEFAULT_LIFECYCLE_THRESHOLDS,oe as IncrementalExtent,Ks as RealtimeHeatmap,Is as RealtimeHistogram,_s as RealtimeLineChart,Os as RealtimeSwarmChart,Xs as RealtimeWaterfallChart,Zr as ReorderBuffer,re as RingBuffer,Xr as RunningStats,Yr as StreamNetworkFrame,Ao as StreamXYFrame,Ws as TemporalHistogram,Vr as WindowAccumulator,qr as bandBounds,Le as bandFromAge,$ as compileMotionEncoding,V as deriveMotionVector,U as opacityFromAge,Kr as parseWindowDuration,J as resolveMotionAccessor,ee as resolveMotionVector,Gr as statValue};