semiotic 3.8.1 → 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 (178) hide show
  1. package/CLAUDE.md +3 -1
  2. package/README.md +54 -52
  3. package/ai/behaviorContracts.cjs +9 -0
  4. package/ai/dist/mcp-server.js +142 -13
  5. package/ai/schema.json +616 -42
  6. package/ai/surface-manifest.json +1 -1
  7. package/ai/system-prompt.md +5 -2
  8. package/dist/chunk-OrdinalBrushOverlay-PXHQYDB2.module.min.js +2 -0
  9. package/dist/chunk-XYBrushOverlay-ECZJJLAJ.module.min.js +1 -0
  10. package/dist/chunk-XYBrushOverlay-EP2SV3UI.module.min.js +2 -0
  11. package/dist/chunk-chunk-255KDHW5.module.min.js +1 -0
  12. package/dist/chunk-chunk-2CCFBTQC.module.min.js +2 -0
  13. package/dist/chunk-chunk-2CXCXRB4.module.min.js +1 -0
  14. package/dist/chunk-chunk-2JGJ5GUG.module.min.js +2 -0
  15. package/dist/chunk-chunk-2RXP3FS3.module.min.js +1 -0
  16. package/dist/chunk-chunk-2WVCH4PL.module.min.js +1 -0
  17. package/dist/chunk-chunk-4TMZXLCR.module.min.js +1 -0
  18. package/dist/chunk-chunk-5APBQXZA.module.min.js +1 -0
  19. package/dist/chunk-chunk-5RKXZQ2P.module.min.js +1 -0
  20. package/dist/chunk-chunk-5UKL5W76.module.min.js +2 -0
  21. package/dist/chunk-chunk-6HSGDMTA.module.min.js +2 -0
  22. package/dist/chunk-chunk-7FW6EGLP.module.min.js +2 -0
  23. package/dist/chunk-chunk-7OEOSCBP.module.min.js +1 -0
  24. package/dist/chunk-chunk-A63CTACR.module.min.js +2 -0
  25. package/dist/chunk-chunk-ANYDWOZF.module.min.js +1 -0
  26. package/dist/chunk-chunk-AZJUDQRM.module.min.js +2 -0
  27. package/dist/chunk-chunk-B6V35LMY.module.min.js +2 -0
  28. package/dist/chunk-chunk-BOSVL645.module.min.js +2 -0
  29. package/dist/chunk-chunk-CA3YDW6F.module.min.js +1 -0
  30. package/dist/chunk-chunk-CP3EN6KZ.module.min.js +1 -0
  31. package/dist/chunk-chunk-DSNGDNJY.module.min.js +1 -0
  32. package/dist/chunk-chunk-EMO5NUGE.module.min.js +2 -0
  33. package/dist/chunk-chunk-F25UA5HT.module.min.js +1 -0
  34. package/dist/chunk-chunk-FRIO6MCV.module.min.js +1 -0
  35. package/dist/chunk-chunk-FYY2ACNJ.module.min.js +2 -0
  36. package/dist/chunk-chunk-G7WFWHAD.module.min.js +2 -0
  37. package/dist/chunk-chunk-GMQ5AYTD.module.min.js +1 -0
  38. package/dist/chunk-chunk-GWSWSPXN.module.min.js +1 -0
  39. package/dist/chunk-chunk-I6C3KR5H.module.min.js +2 -0
  40. package/dist/chunk-chunk-IP2UE74X.module.min.js +1 -0
  41. package/dist/chunk-chunk-J3ELI22J.module.min.js +1 -0
  42. package/dist/chunk-chunk-J3QOW4OE.module.min.js +0 -0
  43. package/dist/chunk-chunk-J3XWETBJ.module.min.js +2 -0
  44. package/dist/chunk-chunk-J5RL6GXU.module.min.js +2 -0
  45. package/dist/chunk-chunk-JCG72SGW.module.min.js +2 -0
  46. package/dist/{semiotic-ai-chunk-OG7BQUUW.module.min.js → chunk-chunk-JJ2OOIET.module.min.js} +0 -1
  47. package/dist/chunk-chunk-JNCHKRIR.module.min.js +2 -0
  48. package/dist/chunk-chunk-KTWEBFMX.module.min.js +2 -0
  49. package/dist/chunk-chunk-L3H6DQCR.module.min.js +2 -0
  50. package/dist/chunk-chunk-M337NY6L.module.min.js +1 -0
  51. package/dist/chunk-chunk-M7VYYHCE.module.min.js +2 -0
  52. package/dist/chunk-chunk-MC35ILYP.module.min.js +2 -0
  53. package/dist/chunk-chunk-N72SWNBV.module.min.js +1 -0
  54. package/dist/chunk-chunk-OBQRFTIL.module.min.js +2 -0
  55. package/dist/chunk-chunk-OQTLSTGI.module.min.js +2 -0
  56. package/dist/chunk-chunk-Q2YADC2V.module.min.js +2 -0
  57. package/dist/chunk-chunk-QRIBHZYW.module.min.js +1 -0
  58. package/dist/chunk-chunk-QSQVBIJA.module.min.js +1 -0
  59. package/dist/chunk-chunk-RCF52Z42.module.min.js +2 -0
  60. package/dist/chunk-chunk-ROP4HI7H.module.min.js +2 -0
  61. package/dist/chunk-chunk-RZH7VZYS.module.min.js +2 -0
  62. package/dist/chunk-chunk-SA3D43RA.module.min.js +2 -0
  63. package/dist/chunk-chunk-SANERMIZ.module.min.js +2 -0
  64. package/dist/chunk-chunk-SIRIJ3DY.module.min.js +1 -0
  65. package/dist/chunk-chunk-SV4XAZ3Q.module.min.js +1 -0
  66. package/dist/chunk-chunk-U66USBWU.module.min.js +1 -0
  67. package/dist/chunk-chunk-UHSZEB74.module.min.js +1 -0
  68. package/dist/chunk-chunk-VVCA3DB7.module.min.js +1 -0
  69. package/dist/chunk-chunk-WCX6U47H.module.min.js +2 -0
  70. package/dist/chunk-chunk-XEVJDUTH.module.min.js +1 -0
  71. package/dist/chunk-chunk-XQYVEKEJ.module.min.js +2 -0
  72. package/dist/chunk-chunk-Y6AXCRVO.module.min.js +1 -0
  73. package/dist/chunk-chunk-YCQYG6J5.module.min.js +2 -0
  74. package/dist/chunk-chunk-YHNZCPOZ.module.min.js +2 -0
  75. package/dist/chunk-chunk-YWZB3KPI.module.min.js +2 -0
  76. package/dist/chunk-chunk-ZCNBUZPL.module.min.js +2 -0
  77. package/dist/chunk-statisticalOverlays-6MVAK5RW.module.min.js +2 -0
  78. package/dist/components/charts/custom/XYCustomChart.d.ts +3 -0
  79. package/dist/components/charts/physics/PhysicalFlowChart.d.ts +7 -0
  80. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +5 -6
  81. package/dist/components/charts/realtime/temporalHistogramConfig.d.ts +11 -0
  82. package/dist/components/charts/shared/areaSeriesData.d.ts +15 -0
  83. package/dist/components/charts/shared/auditAccessibilityText.d.ts +13 -0
  84. package/dist/components/charts/shared/chartMode.d.ts +67 -0
  85. package/dist/components/charts/shared/colorUtils.d.ts +8 -0
  86. package/dist/components/charts/shared/geoStyleDefaults.d.ts +3 -0
  87. package/dist/components/charts/shared/hooks.d.ts +13 -80
  88. package/dist/components/charts/shared/useChartSetup.d.ts +3 -0
  89. package/dist/components/charts/shared/useCustomChartSetup.d.ts +3 -0
  90. package/dist/components/charts/shared/useXYLineStyle.d.ts +3 -2
  91. package/dist/components/charts/shared/xyLineStyle.d.ts +21 -0
  92. package/dist/components/charts/xy/LineChart.d.ts +3 -0
  93. package/dist/components/legendLayout.d.ts +31 -0
  94. package/dist/components/server/serverChartConfigShared.d.ts +29 -0
  95. package/dist/components/server/serverChartConfigs.d.ts +2 -13
  96. package/dist/components/server/serverChartConfigsXY.d.ts +3 -0
  97. package/dist/components/server/serverGaugeOverlay.d.ts +28 -0
  98. package/dist/components/server/staticLegend.d.ts +7 -1
  99. package/dist/components/server/staticSVGChrome.d.ts +60 -2
  100. package/dist/components/stream/GeoPipelineStore.d.ts +2 -0
  101. package/dist/components/stream/GeoSVGOverlay.d.ts +2 -0
  102. package/dist/components/stream/OrdinalBrushOverlay.d.ts +1 -2
  103. package/dist/components/stream/OrdinalBrushOverlayLazy.d.ts +9 -0
  104. package/dist/components/stream/SceneToSVG.d.ts +8 -6
  105. package/dist/components/stream/SceneToSVGGeo.d.ts +10 -0
  106. package/dist/components/stream/SceneToSVGNetwork.d.ts +12 -0
  107. package/dist/components/stream/XYBrushOverlayLazy.d.ts +17 -0
  108. package/dist/components/stream/canvasBackground.d.ts +7 -0
  109. package/dist/components/stream/networkTypes.d.ts +2 -4
  110. package/dist/components/stream/renderBackend.d.ts +14 -0
  111. package/dist/components/stream/sceneToSVGShared.d.ts +51 -0
  112. package/dist/components/types/legendTypes.d.ts +16 -3
  113. package/dist/controls.min.js +1 -1
  114. package/dist/controls.module.min.js +1 -1
  115. package/dist/geo.min.js +1 -1
  116. package/dist/geo.module.min.js +1 -1
  117. package/dist/network.min.js +1 -1
  118. package/dist/network.module.min.js +1 -1
  119. package/dist/ordinal.min.js +1 -1
  120. package/dist/ordinal.module.min.js +1 -1
  121. package/dist/physics-matter.min.js +1 -1
  122. package/dist/physics-matter.module.min.js +1 -1
  123. package/dist/physics-rapier.min.js +1 -1
  124. package/dist/physics-rapier.module.min.js +1 -1
  125. package/dist/physics.min.js +1 -1
  126. package/dist/physics.module.min.js +1 -1
  127. package/dist/realtime.min.js +1 -1
  128. package/dist/realtime.module.min.js +1 -1
  129. package/dist/rough.min.js +1 -1
  130. package/dist/rough.module.min.js +1 -1
  131. package/dist/semiotic-ai-core.min.js +1 -1
  132. package/dist/semiotic-ai-core.module.min.js +1 -1
  133. package/dist/semiotic-ai.min.js +1 -1
  134. package/dist/semiotic-ai.module.min.js +1 -1
  135. package/dist/semiotic-data.min.js +1 -1
  136. package/dist/semiotic-data.module.min.js +1 -1
  137. package/dist/semiotic-experimental.min.js +1 -1
  138. package/dist/semiotic-experimental.module.min.js +1 -1
  139. package/dist/semiotic-realtime-core.min.js +1 -1
  140. package/dist/semiotic-realtime-core.module.min.js +1 -1
  141. package/dist/semiotic-realtime-react.min.js +1 -1
  142. package/dist/semiotic-realtime-react.module.min.js +1 -1
  143. package/dist/semiotic-recipes-core.min.js +1 -1
  144. package/dist/semiotic-recipes-core.module.min.js +1 -1
  145. package/dist/semiotic-recipes-react.min.js +1 -1
  146. package/dist/semiotic-recipes-react.module.min.js +1 -1
  147. package/dist/semiotic-recipes.min.js +1 -1
  148. package/dist/semiotic-recipes.module.min.js +1 -1
  149. package/dist/semiotic-server-edge.min.js +1 -1
  150. package/dist/semiotic-server-edge.module.min.js +1 -1
  151. package/dist/semiotic-server-node.min.js +1 -1
  152. package/dist/semiotic-server-node.module.min.js +1 -1
  153. package/dist/semiotic-themes-core.min.js +1 -1
  154. package/dist/semiotic-themes-core.module.min.js +1 -1
  155. package/dist/semiotic-themes-react.min.js +1 -1
  156. package/dist/semiotic-themes-react.module.min.js +1 -1
  157. package/dist/semiotic-themes.min.js +1 -1
  158. package/dist/semiotic-themes.module.min.js +1 -1
  159. package/dist/semiotic-utils-core.min.js +1 -1
  160. package/dist/semiotic-utils-core.module.min.js +1 -1
  161. package/dist/semiotic-utils-react.min.js +1 -1
  162. package/dist/semiotic-utils-react.module.min.js +1 -1
  163. package/dist/semiotic-utils.min.js +1 -1
  164. package/dist/semiotic-utils.module.min.js +1 -1
  165. package/dist/semiotic-value.min.js +1 -1
  166. package/dist/semiotic-value.module.min.js +1 -1
  167. package/dist/semiotic.min.js +1 -1
  168. package/dist/semiotic.module.min.js +1 -1
  169. package/dist/server.min.js +1 -1
  170. package/dist/server.module.min.js +1 -1
  171. package/dist/xy.min.js +1 -1
  172. package/dist/xy.module.min.js +1 -1
  173. package/package.json +4 -4
  174. package/dist/semiotic-ai-statisticalOverlays-CY4WKR4A.module.min.js +0 -2
  175. package/dist/semiotic-chunk-3FSVZ46U.module.min.js +0 -2
  176. package/dist/semiotic-statisticalOverlays-UOMSFKVJ.module.min.js +0 -2
  177. package/dist/xy-chunk-IWD6IB6V.module.min.js +0 -2
  178. package/dist/xy-statisticalOverlays-7RWG6LJT.module.min.js +0 -2
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";var e,t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,a=(e,t,o,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let c of i(t))s.call(e,c)||c===o||n(e,c,{get:()=>t[c],enumerable:!(a=r(t,c))||a.enumerable});return e},c=(e,r,i)=>(i=null!=e?t(o(e)):{},a(!r&&e&&e.__esModule?i:n(i,"default",{value:e,enumerable:!0}),e)),l={};((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})(l,{DEFAULT_LIFECYCLE_THRESHOLDS:()=>xe,IncrementalExtent:()=>$,RealtimeHeatmap:()=>Nh,RealtimeHistogram:()=>Sh,RealtimeLineChart:()=>bh,RealtimeSwarmChart:()=>Ph,RealtimeWaterfallChart:()=>Th,ReorderBuffer:()=>Du,RingBuffer:()=>W,RunningStats:()=>Mu,StreamNetworkFrame:()=>_u,StreamXYFrame:()=>Ia,TemporalHistogram:()=>_h,WindowAccumulator:()=>Cu,bandBounds:()=>Ru,bandFromAge:()=>ve,compileMotionEncoding:()=>ke,deriveMotionVector:()=>Se,opacityFromAge:()=>we,parseWindowDuration:()=>Eu,resolveMotionAccessor:()=>be,resolveMotionVector:()=>Ae,statValue:()=>Pu,syncPushBuffer:()=>zh,useStreamStatus:()=>Wh,useSyncedPushData:()=>Oh}),module.exports=(e=l,a(n({},"__esModule",{value:!0}),e));var u=c(require("react")),h=require("react"),d=require("react"),f=require("d3-selection"),y=require("d3-brush"),p=c(require("react")),g=require("react/jsx-runtime");function m(e,t,n,r){const[i,o]=[Math.min(...t),Math.max(...t)],s=(o-i)/20;let[a,c]=e;if(r)0>n?a=Math.max(i,a-s):c=Math.min(o,c+s);else{const e=c-a;a=Math.max(i,Math.min(o-e,a+n*s)),c=a+e}return[a,c]}function x(e,t){let n=0,r=t.length-1;for(;r>n;){const i=n+r+1>>1;t[i]>e?r=i-1:n=i}return t[n]}function v(e,t){let n=0,r=t.length-1;for(;r>n;){const i=n+r>>1;e>t[i]?n=i+1:r=i}return t[n]}function b({width:e,height:t,totalWidth:n,totalHeight:r,margin:i,dimension:o,scales:s,onBrush:a,binSize:c,snap:l,binBoundaries:u,snapDuring:h,streaming:b}){const k=(0,d.useRef)(null),w=(0,d.useRef)(null),A=(0,d.useRef)(a);A.current=a;const S=(0,d.useRef)(s);S.current=s;const _=(0,d.useMemo)(()=>u?[...u].sort((e,t)=>e-t):void 0,[u]),M=(0,d.useRef)(_);M.current=_;const C=(0,d.useRef)(!1),P=(0,d.useRef)(null),R=function({label:e="Data range brush",description:t="Use arrow keys to move the selected range, Shift plus an arrow key to resize it, and Escape to clear it.",onAction:n}={}){const r=p.useId().replace(/:/g,""),i=p.useRef(n);return i.current=n,{description:t,descriptionId:"semiotic-brush-description-"+r,svgProps:{role:"region",tabIndex:0,"aria-label":e,"aria-describedby":"semiotic-brush-description-"+r,onKeyDown:p.useCallback(e=>{const t=function(e){return"Escape"===e.key?{type:"clear"}:"ArrowLeft"===e.key?{type:"nudge",direction:"left",resize:e.shiftKey}:"ArrowRight"===e.key?{type:"nudge",direction:"right",resize:e.shiftKey}:"ArrowUp"===e.key?{type:"nudge",direction:"up",resize:e.shiftKey}:"ArrowDown"===e.key?{type:"nudge",direction:"down",resize:e.shiftKey}:null}(e);t&&(e.preventDefault(),i.current?.(t))},[])}}}({label:"xy"===o?"Two-dimensional data range brush":o.toUpperCase()+" data range brush",onAction:e=>{const t=S.current,n=w.current;if(!t||!n||!k.current)return;const r=(0,f.select)(k.current).select(".brush-g");if("clear"===e.type)return C.current=!0,r.call(n.move,null),C.current=!1,P.current=null,void A.current(null);const i=t.x.domain(),s=t.y.domain(),a=P.current;let c=a?.x??[i[0]+.4*(i[1]-i[0]),i[0]+.6*(i[1]-i[0])],l=a?.y??[s[0]+.4*(s[1]-s[0]),s[0]+.6*(s[1]-s[0])];const u="left"===e.direction||"right"===e.direction,h="left"===e.direction||"down"===e.direction?-1:1;if(u&&"y"!==o&&(c=m(c,i,h,e.resize)),u||"x"===o||(l=m(l,s,h,e.resize)),u&&"y"===o||!u&&"x"===o)return;const d={x:c,y:l};C.current=!0,r.call(n.move,"x"===o?[t.x(c[0]),t.x(c[1])]:"y"===o?[t.y(l[1]),t.y(l[0])]:[[t.x(c[0]),t.y(l[1])],[t.x(c[1]),t.y(l[0])]]),C.current=!1,P.current=d,A.current(d)}});return(0,d.useEffect)(()=>{if(!k.current)return;const n=(0,f.select)(k.current).select(".brush-g"),r="x"===o?(0,y.brushX)():"y"===o?(0,y.brushY)():(0,y.brush)();return r.extent([[0,0],[e,t]]),r.on("brush end",i=>{if(C.current)return;const s=S.current;if(!s)return;if(!i.selection)return P.current=null,void A.current(null);let a,u;if("x"===o){const[e,n]=i.selection;a=[s.x.invert(e),s.x.invert(n)],u=[s.y.invert(t),s.y.invert(0)]}else if("y"===o){const[t,n]=i.selection;a=[s.x.invert(0),s.x.invert(e)],u=[s.y.invert(n),s.y.invert(t)]}else{const[[e,t],[n,r]]=i.selection;a=[s.x.invert(e),s.x.invert(n)],u=[s.y.invert(r),s.y.invert(t)]}if("bin"===l&&"y"!==o&&("end"===i.type||"brush"===i.type&&h)){const e=M.current;e&&e.length>0?a=function(e,t){return 0===t.length?e:[x(e[0],t),v(e[1],t)]}(a,e):c&&c>0&&(a=[Math.floor(a[0]/c)*c,Math.ceil(a[1]/c)*c]);const t=s.x(a[0]),l=s.x(a[1]);if(C.current=!0,"x"===o)n.call(r.move,[t,l]);else if("xy"===o){const e=i.selection;n.call(r.move,[[t,e[0][1]],[l,e[1][1]]])}C.current=!1}const d={x:a,y:u};P.current=d,A.current(d)}),n.call(r),w.current=r,n.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null),w.current=null}},[e,t,o,l,c,h]),(0,d.useEffect)(()=>{if(!(b&&s&&w.current&&P.current))return;if(!k.current)return;if("y"===o)return;const e=P.current,t=s.x.domain()[0],n=(0,f.select)(k.current).select(".brush-g");if(t>=e.x[1])return C.current=!0,n.call(w.current.move,null),C.current=!1,P.current=null,void A.current(null);let r=e.x[0],i=!1;if(t>e.x[0]){if(r=t,"bin"===l){const e=M.current;e&&e.length>0?r=v(t,e):c&&c>0&&(r=Math.ceil(t/c)*c)}if(r>=e.x[1])return C.current=!0,n.call(w.current.move,null),C.current=!1,P.current=null,void A.current(null);i=!0}const a=s.x(r),u=s.x(e.x[1]);if(C.current=!0,"x"===o)n.call(w.current.move,[a,u]);else{const t=s.y(e.y[1]),r=s.y(e.y[0]);n.call(w.current.move,[[a,t],[u,r]])}if(C.current=!1,i){const t={x:[r,e.x[1]],y:e.y};P.current=t,A.current(t)}},[s,b,o,l,c]),(0,g.jsxs)("svg",{ref:k,width:n,height:r,...R.svgProps,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:[(0,g.jsx)("title",{children:R.svgProps["aria-label"]}),(0,g.jsx)("desc",{id:R.descriptionId,children:R.description}),(0,g.jsx)("g",{className:"brush-g",transform:`translate(${i.left},${i.top})`})]})}var k=Object.freeze([]);function w(e){if(!e)return k;let t=!1;for(let n=0;e.length>n;n++){const r=e[n];if(null==r||"object"!=typeof r){t=!0;break}}if(!t)return e;const n=[];for(const t of e)null!=t&&"object"==typeof t&&n.push(t);return n}var A=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=w(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 r=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,r),bounded:!1}),t=r,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(e){if(e=w(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 r=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,r),bounded:!1}),t=r,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 r=e[n];null!=r&&"object"==typeof r&&(this.pushBuffer.push(r),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}},S=require("react"),_=require("react/jsx-runtime");function M(e){let t=null;const n=()=>(t||(t=(0,S.createContext)(null)),t),r=C(e);return[function({children:t,initialState:r}){const i=(0,S.useRef)(r),o=(0,S.useMemo)(()=>C(e,i.current),[]),s=n();return(0,_.jsx)(s.Provider,{value:o,children:t})},(e,t)=>{const i=n(),o=(0,S.useContext)(i)??r,s=(0,S.useRef)(e);s.current=e;const a=(0,S.useRef)({hasValue:!1,value:void 0}),c=(0,S.useCallback)(()=>{const e=s.current(o.getState()),n=a.current;return n.hasValue&&t&&t(n.value,e)?n.value:(a.current={hasValue:!0,value:e},e)},[o,t]),l=(0,S.useCallback)(()=>s.current(o.getState()),[o]);return(0,S.useSyncExternalStore)(o.subscribe,c,l)}]}function C(e,t){const n=new Set;let r={...e(function(e){const t=e(r);if(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}(t)){r={...r,...t};for(const e of n)e()}}),...t??{}};return{getState:()=>r,subscribe:function(e){return n.add(e),()=>{n.delete(e)}}}}function P(e){if(!e?.colors)return;const t=e.colors;return{primary:t.primary,secondary:t.secondary||t.primary,surface:t.surface||t.background,success:t.success,danger:t.danger,warning:t.warning,error:t.error,info:t.info,text:t.text,textSecondary:t.textSecondary,border:t.border,grid:t.grid}}function R(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:j}}),e.accessibility.highContrast){const e="dark"===t.mode;t={...t,colors:{...t.colors,text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"}}}return t}var j=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],T={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},E={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},D={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:j,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function N(e,t){if("light"===t)return T;if("dark"===t)return E;if("high-contrast"===t)return D;if("string"==typeof t)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${t}". Keeping current theme.`),e;if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?E:T;return R({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}return R({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}var[L,I]=M(e=>({theme:T,setTheme(t){e(e=>({theme:N(e.theme,t)}))}})),W=class{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;return{next:()=>this._size>e?{done:!1,value:this.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray();let n=0,r=[];t.length>e&&(n=t.length-e,r=t.slice(0,n)),this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(let e=n;t.length>e;e++)this.push(t[e]);return r}update(e,t){const n=[],r=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++){const o=(r+i)%this._capacity,s=this.buffer[o];if(e(s)){let e;e="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:{...s},n.push(e),this.buffer[o]=t(s)}}return n}remove(e){const t=[],n=[];if(this.forEach(r=>{e(r)?n.push(r):t.push(r)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}},$=class{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}};function z(e,t){return e===t}function O(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function F(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function B(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}var Y=/^\d{4}-\d{1,2}$/;function H(e){const t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;const n=Y.test(t)?t+"-01":t;if(n===t&&10>t.length)return NaN;const r=Date.parse(n);return Number.isFinite(r)?r:NaN}function X(e){return e instanceof Date?e.getTime():"string"==typeof e?H(e):+e}function q(e){return new Set(Array.isArray(e)?e:[e])}function G(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function V(e,t,n){const r=e=>e.toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function U(e){const t=e.map(G),n=t.length-1;return e=>{if(0>=e){const[e,n,r]=t[0];return V(e,n,r)}if(e>=1){const[e,r,i]=t[n];return V(e,r,i)}const r=e*n,i=Math.floor(r),o=r-i,[s,a,c]=t[i],[l,u,h]=t[i+1];return V(Math.round(s+(l-s)*o),Math.round(a+(u-a)*o),Math.round(c+(h-c)*o))}}require("d3-scale");var K=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Q=U(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),Z=U(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),J=U(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),ee=U(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),te=U(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),ne=U(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),re=U(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),ie=U(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),oe=U(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),se=U(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),ae=U(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),ce=U(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),le={blues:Q,reds:Z,greens:J,viridis:re,oranges:ee,purples:te,greys:ne,plasma:ie,inferno:oe,magma:se,cividis:ae,turbo:ce};U(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),U(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),U(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),U(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),U(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),U(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),U(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);var ue={category10:K,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...le},he=K,de=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function fe(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;const n=e[t];return"string"==typeof n&&n.length>0?n:void 0}function ye(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function pe(e,t){return Math.min((e-t.startTime)/t.duration,1)}function ge(e,t,n){return e+(t-e)*n}function me(){return"undefined"!=typeof performance?performance.now():Date.now()}var xe={fresh:1,aging:1.5,stale:3};function ve(e,t,n={}){return Number.isFinite(t)&&t>0?Number.isNaN(e)?"fresh":e===1/0?"expired":0>e||t*(n.fresh??xe.fresh)>e?"fresh":t*(n.aging??xe.aging)>e?"aging":t*(n.stale??xe.stale)>e?"stale":"expired":"fresh"}function be(e,t,n){if(null!=e)return"function"==typeof e?e(t,n):"object"==typeof e&&null!==e&&"constant"in e?e.constant:t[e]}function ke(e){const{data:t,encoding:n}=e,r=[],i=new Map;return t.forEach((e,t)=>{const o=be(n.id,e,t);if(null==o||""===o)throw Error(`[semiotic] Motion encoding row ${t} resolved an empty id.`);const s=o+"";if(i.has(s))throw Error(`[semiotic] Duplicate motion encoding id "${s}".`);const a=be(n.process?.group,e,t),c=be(n.process?.stage,e,t),l=be(n.accessible?.group,e,t)??(null!=a?a+"":null!=c?c+"":void 0),u={};for(const r of Object.keys(n.evidence??{}))u[r]=be(n.evidence?.[r],e,t);const h={id:s,datum:e,time:{arrival:be(n.time?.arrival,e,t),basis:n.time?.basis,unit:n.time?.unit},placement:{x:be(n.placement?.x,e,t),y:be(n.placement?.y,e,t),lane:be(n.placement?.lane,e,t),space:n.placement?.space},kinematics:{velocityX:be(n.kinematics?.velocityX,e,t),velocityY:be(n.kinematics?.velocityY,e,t),space:n.kinematics?.space},process:{group:a,stage:c,target:be(n.process?.target,e,t),work:be(n.process?.work,e,t)},evidence:u,accessible:{description:be(n.accessible?.description,e,t),group:l,label:be(n.accessible?.label,e,t)??s}};r.push(h),i.set(s,h)}),{rows:r,byId:i}}function we(e){const t=Math.max(0,Math.min(1,e.minOpacity??.1));if(Number.isNaN(e.age))return 1;if(e.age===1/0)return t;if(!Number.isFinite(e.extent)||0>=e.extent)return 1;const n=Math.max(0,e.age);if("step"===e.type)return(e.threshold??.5*e.extent)>n?1:t;if("exponential"===e.type){const r=e.halfLife??e.extent/2;return t+Math.pow(.5,n/(r>0?r:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-n/e.extent))*(1-t)}function Ae(e,t){const n=Number.isFinite(e)?e:0,r=Number.isFinite(t)?t:0;return{velocityX:n,velocityY:r,speed:Math.hypot(n,r),direction:Math.atan2(r,n)}}function Se(e,t,n){return Number.isFinite(n)&&n>0?Ae((t.x-e.x)/n,(t.y-e.y)/n):Ae(0,0)}function _e(e,t,n){if(1>=n)return 1;const r=n-1;return we({age:r-t,extent:r,type:e.type,halfLife:e.halfLife??n/2,threshold:e.stepThreshold??.5*n,minOpacity:e.minOpacity??.1})}function Me(e){const t=new Map;for(let n=0;e.length>n;n++)t.set(e[n],n);return t}function Ce(e,t,n){const r=e.duration??500,i=n-t;return r>i?1-i/r:0}function Pe(e,t,n,r){let i=!1;return t>0?(e._pulseIntensity!==t&&(e._pulseIntensity=t,i=!0),e._pulseColor!==n&&(e._pulseColor=n,i=!0),e._pulseGlowRadius!==r&&(e._pulseGlowRadius=r,i=!0),i):(0!==e._pulseIntensity&&(e._pulseIntensity=0,i=!0),void 0!==e._pulseColor&&(e._pulseColor=void 0,i=!0),void 0!==e._pulseGlowRadius&&(e._pulseGlowRadius=void 0,i=!0),i)}function Re(e,t,n){if(t._transitionKey)return t._transitionKey;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){const n=e.getX(t.datum),r=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${n}:${r}`;if(null!=n&&null!=r)return`p:${n}:${r}`}return"p:"+n;case"glyph":return t.pointId?"g:"+t.pointId:"g:"+n;case"rect":return`r:${t.group||""}:${t.datum?.binStart??t.datum?.category??n}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+n:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function je(e,t,n,r,i,o){const s=[];for(const i of e){const e=n(i),o=r(i);Number.isFinite(e)&&Number.isFinite(o)&&s.push({px:t.x(e),py:t.y(o),rawY:o,d:i})}s.sort((e,t)=>e.px-t.px);const a=Array(s.length),c=Array(s.length),l=Array(s.length);for(let e=0;s.length>e;e++){const t=s[e];a[e]=[t.px,t.py],c[e]=t.rawY,l[e]=t.d}return{type:"line",path:a,rawValues:c,style:i,datum:l,group:o}}function Te(e,t,n,r,i,o,s,a){const c=[];for(const o of e){const e=n(o),s=r(o);if(!Number.isFinite(e)||!Number.isFinite(s))continue;const l=t.x(e),u=a?a(o):i;c.push({px:l,topY:t.y(s),botY:t.y(u)})}c.sort((e,t)=>e.px-t.px);const l=Array(c.length),u=Array(c.length);for(let e=0;c.length>e;e++){const t=c[e];l[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:l,bottomPath:u,style:o,datum:e,group:s}}function Ee(e,t,n,r){const i=new Map;if("silhouette"===r)for(const r of e){let e=0;for(const i of t)e+=n(i,r)||0;i.set(r,-e/2)}else if("wiggle"===r){e.length>0&&i.set(e[0],0);for(let r=1;e.length>r;r++){const o=e[r-1],s=e[r];let a=0,c=0,l=0;for(const e of t){const t=n(e,s)||0;a+=(2*l+t)*(t-(n(e,o)||0)),c+=t,l+=t}const u=i.get(o)??0;i.set(s,u-(c>0?a/(2*c):0))}if(e.length>0){let r=0;for(const o of e){let e=0;for(const r of t)e+=n(r,o)||0;r+=(i.get(o)??0)+e/2}const o=r/e.length;for(const t of e)i.set(t,(i.get(t)??0)-o)}}else for(const t of e)i.set(t,0);return i}function De(e,t,n,r,i,o,s){const a=n(e),c=r(e);if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l={type:"point",x:t.x(a),y:t.y(c),r:i,style:o,datum:e};return void 0!==s&&(l.pointId=s),l}function Ne(e,t,n,r,i,o,s,a){const c=n(e),l=r(e);if(!Number.isFinite(c)||!Number.isFinite(l))return null;const u={type:"symbol",x:t.x(c),y:t.y(l),size:i,symbolType:o,style:s,datum:e};return void 0!==a&&(u.pointId=a),u}function Le(e,t,n,r,i,o,s){return{type:"rect",x:e,y:t,w:n,h:r,style:i,datum:o,group:s}}function Ie(e,t,n,r,i,o,s){const a={type:"heatcell",x:e,y:t,w:n,h:r,fill:i,datum:o};return s?.showValues&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function We(e,t,n,r){return"function"==typeof t.style?t.style(r||{},n):t.style&&"object"==typeof t.style?t.style:e.resolveBoundsStyle(n,r)}function $e(e,t,n,r){if(!e.scales)return null;const i=[],o=[];for(const n of t){const t=e.getX(n);if(!Number.isFinite(t))continue;const s=r.getTop(n),a=r.getBottom(n);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const c=e.scales.x(t),l=e.scales.y(s),u=e.scales.y(a);Number.isFinite(c)&&Number.isFinite(l)&&Number.isFinite(u)&&(i.push([c,l]),o.push([c,u]))}return 2>i.length?null:{type:"area",topPath:i,bottomPath:o,style:We(e,r,n,t[0]),datum:t,group:n,interactive:r.interactive}}function ze(e){const t=[],n=[];if(!e)return{perSeries:t,aggregate:n};for(const r of e)r.perSeries?t.push(r):n.push(r);return{perSeries:t,aggregate:n}}function Oe(e,t,n){const r=[];for(const i of n){const n=$e(e,t,"__ribbon_aggregate",i);n&&r.push(n)}return r}function Fe(e,t,n,r){const i=[];for(const o of r){const r=$e(e,t,n,o);r&&i.push(r)}return i}function Be(e,t){if(!e)return{};if(!t||0===t.length)return e;const n=[];for(const r of t){if("band"!==r.kind)continue;const t=r.getTop(e),i=r.getBottom(e);Number.isFinite(i)&&Number.isFinite(t)&&n.push({y0:i,y1:t})}return 0===n.length?e:{...e,band:n[0],bands:n}}function Ye(e,t,n,r){if(!e.config.pointStyle)return;const i=r??e.getY;for(const r of t){const t=e.resolveGroupColor(r.key);for(const o of r.data){let r=e.config.pointStyle(o);!r.fill&&t&&(r={...r,fill:t});const s=r.r??3,a=e.getPointId?e.getPointId(o)+"":void 0,c=De(o,e.scales,e.getX,i,s,r,a);c&&n.push(c)}}}function He(e){return"threshold"===e.type&&"string"==typeof e.color&&"number"==typeof e.value}var Xe={topOpacity:.8,bottomOpacity:.05};function qe(e){if(e)return!0===e?Xe:"colorStops"in e?e:{topOpacity:e.topOpacity??Xe.topOpacity,bottomOpacity:e.bottomOpacity??Xe.bottomOpacity}}var Ge=require("d3-shape"),Ve={circle:Ge.symbolCircle,square:Ge.symbolSquare,triangle:Ge.symbolTriangle,diamond:Ge.symbolDiamond,star:Ge.symbolStar,cross:Ge.symbolCross,wye:Ge.symbolWye},Ue=["circle","triangle","diamond","star","square","chevron","cross","wye"];function Ke(e,t,n){if(n)return n;const r=e??"circle";return"chevron"===r?function(e){const t=1.5*Qe(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}(t):(0,Ge.symbol)(Ve[r]??Ge.symbolCircle,Math.max(1,t))()??""}function Qe(e){return Math.sqrt(Math.max(1,e)/Math.PI)}var Ze=new Map;function Je(e,t,n){if(e.config.heatmapAggregation)return function(e,t,n){const r=Math.max(1,Math.floor(e.config.heatmapXBins??20)),i=Math.max(1,Math.floor(e.config.heatmapYBins??20)),o=e.config.heatmapAggregation??"count",s=O(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[a,c]=e.scales.x.domain(),[l,u]=e.scales.y.domain(),h=(c-a||1)/r,d=(u-l||1)/i,f=r*i;if(f>1e6)return[];const y=new Int32Array(f),p=new Float64Array(f);for(let n=0;t.length>n;n++){const o=t[n],c=e.getX(o),u=e.getY(o);if(!isFinite(c)||!isFinite(u))continue;const f=Math.min(Math.floor((c-a)/h),r-1),g=Math.min(Math.floor((u-l)/d),i-1);if(0>f||0>g)continue;const m=g*r+f;y[m]++;const x=s(o);p[m]+=isFinite(x)?x:0}let g=1/0,m=-1/0;for(let e=0;f>e;e++){if(0===y[e])continue;let t;switch(o){case"sum":t=p[e];break;case"mean":t=p[e]/y[e];break;default:t=y[e]}g>t&&(g=t),t>m&&(m=t)}if(!isFinite(g))return[];const x=m-g||1,v=n.width/r,b=n.height/i,k=e.config.showValues,w=e.config.heatmapValueFormat,A=[];for(let e=0;i>e;e++){const t=e*r;for(let n=0;r>n;n++){const r=t+n;if(0===y[r])continue;let s;switch(o){case"sum":s=p[r];break;case"mean":s=p[r]/y[r];break;default:s=y[r]}const c=(s-g)/x;A.push(Ie(n*v,(i-1-e)*b,v,b,`rgb(${220-(180*c+.5)|0},${220-(100*c+.5)|0},${255-(50*c+.5)|0})`,{xi:n,yi:e,value:s,count:y[r],sum:p[r],xCenter:a+(n+.5)*h,yCenter:l+(e+.5)*d,agg:o},k?{value:s,showValues:!0,valueFormat:w}:void 0))}}return A}(e,t,n);if(0===t.length)return[];const r=O(e.config.valueAccessor,"value"),i=F(e.config.xAccessor,"x"),o=F(e.config.yAccessor,"y"),s=new Map,a=new Map,c=Array(t.length),l=Array(t.length);for(let e=0;t.length>e;e++){const n=t[e],r=i(n),u=o(n);c[e]=r,l[e]=u,s.has(r)||s.set(r,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,h=a.size;if(0===u||0===h)return[];const d=Array.from(s.keys()),f=Array.from(a.keys()),y=d.every(e=>"number"==typeof e&&!isNaN(e)),p=f.every(e=>"number"==typeof e&&!isNaN(e));if(y){d.sort((e,t)=>Number(e)-Number(t)),s.clear();for(let e=0;d.length>e;e++)s.set(d[e],e)}if(p){f.sort((e,t)=>Number(e)-Number(t)),a.clear();for(let e=0;f.length>e;e++)a.set(f[e],e)}const g=new Float64Array(t.length),m=new Float64Array(t.length),x=Array(t.length),v=new Map;let b=0;for(let e=0;t.length>e;e++){const n=t[e],i=s.get(c[e]),o=a.get(l[e]);if(void 0===i||void 0===o)continue;const h=r(n),d=o*u+i,f=v.get(d);let y;void 0!==f?y=f:(y=b++,v.set(d,y)),g[y]=d,m[y]=h,x[y]=n}let k=1/0,w=-1/0;for(let e=0;b>e;e++){const t=m[e];isFinite(t)&&(k>t&&(k=t),t>w&&(w=t))}if(!isFinite(k)||!isFinite(w))return[];const A=function(e){const t=e in le?e:"blues";let n=Ze.get(t);if(n)return n;n=Array(256);const r=(i=t)&&le[i]||Q;var i;for(let e=0;256>e;e++)n[e]=r(e/255);return Ze.set(t,n),n}("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),S=255/(w-k||1),_=n.width/u,M=n.height/h,C=e.config.showValues,P=e.config.heatmapValueFormat,R=[];for(let e=0;b>e;e++){const t=m[e];if(!isFinite(t))continue;const n=g[e],r=n%u;R.push(Ie(r*_,(h-1-(n-r)/u)*M,_,M,A[Math.min((t-k)*S+.5|0,255)],x[e],C?{value:t,showValues:!0,valueFormat:P}:void 0))}return R}function et(e,t,n,r,i){const o=new Map;for(const s of e){const e=t(s),a=n(s);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const c=Math.floor(e/r)*r;let l=o.get(c);if(l||(l={start:c,end:c+r,total:0,categories:new Map},o.set(c,l)),l.total+=a,i){const e=i(s);l.categories.set(e,(l.categories.get(e)||0)+a)}}return o}function tt(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:n,overlays:r,warned:i}=e;nt(r)&&0===n.length&&rt(i,"overlay-only",`[semiotic] ${t} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),n.length>0&&n.every(e=>null==e.datum)&&rt(i,"null-datums",`[semiotic] ${t} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function nt(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(nt))}function rt(e,t,n){e.has(t)||(e.add(t),console.warn(n))}function it(e,t,n,r){const i=function(e){if(e instanceof Error)return{name:e.name||"Error",message:e.message||"Custom layout threw."};if("string"==typeof e)return{name:"Error",message:e};if(null==e)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:e+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(t),o="network"===e?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:e,source:o,message:`Semiotic ${e} ${o} failed: ${i.message}`,error:i,recovery:n?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:n,affectedRevision:r}}function ot(e,t){const n="function"==typeof e?e:n=>n[e||t];return e=>{const t=n(e);return null==t?NaN:+t}}function st(e){const t=[],n=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,r=ot(n&&e.valueAccessor||e.yAccessor,n?"value":"y");if(e.boundsAccessor){const n=O(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{const t=r(e);if(!Number.isFinite(t))return NaN;const i=n(e);return Number.isFinite(i)&&0!==i?t+i:t},getBottom:e=>{const t=r(e);if(!Number.isFinite(t))return NaN;const i=n(e);return Number.isFinite(i)&&0!==i?t-i:t},style:e.boundsStyle,perSeries:!0,interactive:!1})}if(e.band){const n=Array.isArray(e.band)?e.band:[e.band];for(const e of n)t.push({kind:"band",getTop:ot(e.y1Accessor,"y1"),getBottom:ot(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}var at=require("d3-scale");function ct(e,t){return t?[t[0]??e[0],t[1]??e[1]]:e}function lt(e,t,n){if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return(0,at.scaleLog)().domain(e).range(n).clamp(!0)}return"symlog"===e?(0,at.scaleSymlog)().domain(t).range(n):"time"===e?(0,at.scaleTime)().domain([new Date(t[0]),new Date(t[1])]).range(n):(0,at.scaleLinear)().domain(t).range(n)}function ut(e,t,n,r){const i=e.push(t);return n&&n.push(r),i}var ht=new WeakMap;function dt(){return this.updateResults.last}function ft(){return this.updateResults.last}function yt(e){return this.updateResults.subscribe(e)}function pt(e){this.config.layoutSelection=e}function gt(){ht.set(this,!0)}function mt(){const e=!0===ht.get(this);return ht.delete(this),e}function xt(e){Object.assign(e.prototype,{getLastUpdateResult:dt,getUpdateSnapshot:ft,subscribeUpdateResult:yt,setLayoutSelection:pt,markStylePaintPending:gt,consumeStylePaintPending:mt})}var vt={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"};function bt(e,t){const n={...e};for(const e of t)n[vt[e]]++;return n}function kt(e,t,n){const r=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:r,revisions:bt(n,r)}}var wt=class{constructor(){this.revisions={data:0,domain:0,layout:0,sceneGeometry:0,sceneStyle:0,dataPaint:0,interactionPaint:0,overlay:0,accessibility:0,evidence:0},this.latest=kt({kind:"initialize"},[],this.revisions),this.listeners=new Set}get last(){return this.latest}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}record(e,t){const n=kt(e,t,this.revisions);this.revisions=n.revisions,this.latest=n;for(const e of[...this.listeners])e();return n}},At=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],St=["scene-style","data-paint","accessibility","evidence"],_t=(e,t)=>({retainedData:e,invalidations:t}),Mt=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ct=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Pt=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Rt=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],jt=["scene-geometry","data-paint","accessibility","evidence"],Tt=["scene-style","data-paint","accessibility","evidence"],Et=[],Dt={chartType:_t("rebuild",Mt),runtimeMode:_t("rebuild",Mt),xAccessor:_t("rebuild",Mt),yAccessor:_t("rebuild",Mt),timeAccessor:_t("rebuild",Mt),valueAccessor:_t("rebuild",Mt),y0Accessor:_t("rebuild",Mt),boundsAccessor:_t("rebuild",Mt),band:_t("rebuild",Mt),openAccessor:_t("rebuild",Mt),highAccessor:_t("rebuild",Mt),lowAccessor:_t("rebuild",Mt),closeAccessor:_t("rebuild",Mt),candlestickRangeMode:_t("rebuild",Mt),accessorRevision:_t("rebuild",Mt),groupAccessor:_t("rebuild",Ct),categoryAccessor:_t("rebuild",Ct),lineDataAccessor:_t("rebuild",Ct),colorAccessor:_t("rebuild",Tt),sizeAccessor:_t("rebuild",jt),symbolAccessor:_t("rebuild",jt),pointIdAccessor:_t("rebuild",jt),xScaleType:_t("preserve",Pt),yScaleType:_t("preserve",Pt),xExtent:_t("preserve",Pt),yExtent:_t("preserve",Pt),extentPadding:_t("preserve",Pt),scalePadding:_t("preserve",Pt),axisExtent:_t("preserve",Pt),binSize:_t("preserve",Pt),normalize:_t("preserve",Pt),heatmapAggregation:_t("preserve",Pt),heatmapXBins:_t("preserve",Pt),heatmapYBins:_t("preserve",Pt),arrowOfTime:_t("preserve",Rt),baseline:_t("preserve",Rt),stackOrder:_t("preserve",Rt),sizeRange:_t("preserve",Rt),curve:_t("preserve",Rt),areaGroups:_t("preserve",Rt),customLayout:_t("preserve",Rt),layoutConfig:_t("preserve",Rt),layoutMargin:_t("preserve",Rt),symbolMap:_t("preserve",jt),showValues:_t("preserve",jt),heatmapValueFormat:_t("preserve",jt),lineStyle:_t("preserve",Tt),pointStyle:_t("preserve",Tt),areaStyle:_t("preserve",Tt),barStyle:_t("preserve",Tt),swarmStyle:_t("preserve",Tt),waterfallStyle:_t("preserve",Tt),candlestickStyle:_t("preserve",Tt),boundsStyle:_t("preserve",Tt),gradientFill:_t("preserve",Tt),lineGradient:_t("preserve",Tt),colorScheme:_t("preserve",Tt),themeCategorical:_t("preserve",Tt),themeSemantic:_t("preserve",Tt),themeSequential:_t("preserve",Tt),themeDiverging:_t("preserve",Tt),barColors:_t("preserve",Tt),decay:_t("preserve",Tt),pulse:_t("preserve",Tt),staleness:_t("preserve",Tt),layoutSelection:_t("preserve",Tt),annotations:_t("preserve",["overlay","accessibility","evidence"]),windowSize:_t("preserve",Et),windowMode:_t("preserve",Et),maxCapacity:_t("preserve",Et),clock:_t("preserve",Et),transition:_t("preserve",Et),introAnimation:_t("preserve",Et),onLayoutError:_t("preserve",Et)},Nt=_t("preserve",Rt),Lt=class{constructor(){this.tracker=new wt}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}},At)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},St):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const r of e){const e=Dt[r]??Nt;"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)}},It=require("d3-quadtree"),Wt=class{constructor(){this.maxRadius=0,this.tree=null}get quadtree(){return this.tree}get maxPointRadius(){return this.maxRadius}clear(){this.tree=null,this.maxRadius=0}rebuild(e,t){if("scatter"!==e&&"bubble"!==e&&"custom"!==e)return void this.clear();let n=0,r=0;for(const e of t)"point"===e.type&&(n++,e.r>r&&(r=e.r));if(this.maxRadius=r,500>=n)return void(this.tree=null);const i=Array(n);let o=0;for(const e of t)"point"===e.type&&(i[o++]=e);this.tree=(0,It.quadtree)().x(e=>e.x).y(e=>e.y).addAll(i)}},$t=class e{constructor(e){if(this.xExtent=new $,this.yExtent=new $,this.growingCapacityWarned=!1,this.windowSizeWarned=!1,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._datumIndexCache=null,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.updateResults=new Lt,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.xIsDate=!1,this.spatialIndex=new Wt,this._lastBoundedInsertsRef=null,this.applyPulse=(e,t,n)=>!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,n,r,i,o=("undefined"!=typeof performance?performance.now():Date.now())){const s=e.color??"rgba(255,255,255,0.6)",a=e.glowRadius??4;let c=!1;const l=i??(()=>{const e=new Map;for(let t=0;n.length>t;t++)e.set(n[t],t);return e})();for(const n of t){if("line"===n.type)continue;if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[n.datum];let i=0,a=!1;for(const n of t){const t=l.get(n);if(null==t)continue;a=!0;const s=r.get(t);if(null==s)continue;const c=Ce(e,s,o);c>i&&(i=c)}a&&(c=Pe(n,i,s)||c);continue}const t=l.get(n.datum);if(null==t)continue;const i=r.get(t);c=Pe(n,null==i?0:Ce(e,i,o),s,a)||c}return c}(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),n),this.config=e,this.buffer=new W(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=O(e.timeAccessor||e.xAccessor,"time"),this.getY=O(e.valueAccessor||e.yAccessor,"value")):(this.getX=O(e.xAccessor,"x"),this.getY=O(e.yAccessor,"y")),this.getGroup=B(e.groupAccessor),this.getCategory=B(e.categoryAccessor),this.getSize=e.sizeAccessor?O(e.sizeAccessor,"size"):void 0,this.getColor=B(e.colorAccessor),this.getSymbol=B(e.symbolAccessor),this.getY0=e.y0Accessor?O(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=st(e),this.getPointId=B(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,n=null!=e.closeAccessor;this.getOpen=t?O(e.openAccessor,"open"):void 0,this.getHigh=O(e.highAccessor,"high"),this.getLow=O(e.lowAccessor,"low"),this.getClose=n?O(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!n}e.pulse&&(this.timestampBuffer=new W(e.windowSize))}currentTime(){return this.config.clock?.()??me()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=function(e,t){const n=new W(e.capacity);return e.forEach(()=>n.push(t)),n}(this.buffer,this.currentTime())):this.timestampBuffer=null}pushDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(e)),void this.yExtent.push(this.getLow(e));this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e));for(const t of this.resolvedRibbons){const n=t.getTop(e),r=t.getBottom(e);Number.isFinite(n)&&this.yExtent.push(n),Number.isFinite(r)&&this.yExtent.push(r)}}evictDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(e)),void this.yExtent.evict(this.getLow(e));this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e));for(const t of this.resolvedRibbons){const n=t.getTop(e),r=t.getBottom(e);Number.isFinite(n)&&this.yExtent.evict(n),Number.isFinite(r)&&this.yExtent.evict(r)}}rebuildYExtent(){this.yExtent.clear();for(const e of this.buffer)this.pushDatumYExtent(e)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const e of this.buffer)this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e)}ingest(e){if(e.bounded&&this._lastBoundedInsertsRef===e.inserts)return this.updateResults.recordNoop("replace"),!1;const t=this.currentTime();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){this._lastBoundedInsertsRef=e.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const o=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=o?O(this.config.timeAccessor||this.config.xAccessor,"time"):O(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],n=this.config.xAccessor,r="function"==typeof n?n(t):t[n||"x"],i=r instanceof Date,o="string"==typeof r&&Number.isFinite(H(r));if(this.xIsDate=i||o,o){const e="string"==typeof n?n:void 0;this.getX=e?t=>X(t[e]):e=>X(n(e))}}i=this.timestampBuffer,(r=e.totalSize||e.inserts.length)>(n=this.buffer).capacity&&(n.resize(r),i&&r>i.capacity&&i.resize(r));for(const n of e.inserts)ut(this.buffer,n,this.timestampBuffer,t),this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n)}else for(const n of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity??1e5;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap),"production"===process.env.NODE_ENV||this.growingCapacityWarned||5e4>this.growingCap||(this.growingCapacityWarned=!0,console.warn(`[Semiotic] Growing window buffer reached ${this.growingCap} points (cap ${e}). Large canvas scenes are expensive — prefer a sliding window, aggregation, or an explicit maxCapacity if this is intentional.`)))}const e=ut(this.buffer,n,this.timestampBuffer,t);this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n),null!=e&&(this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e))}var n,r,i;return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}computeScene(e){const{config:t,buffer:n}=this,r=this.scales,i=this.lastLayout;if(!this.needsFullRebuild&&!t.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(this.config.scalePadding??0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);this.xExtent.dirty&&this.xExtent.recalculate(n,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const o=this.getBufferArray(),s=this.yExtent.extent;let a=ct(this.xExtent.extent,t.xExtent),c=ct(s,t.yExtent);const l=!(!(u=t.yExtent)||null==u[0]||null==u[1]);var u;const h="exact"===t.axisExtent;if("stackedarea"===t.chartType&&!l&&n.size>0){const e=function(e){const{config:t,groups:n,getX:r,getY:i}=e,o="exact"===t.axisExtent;if(t.normalize){const n=[0,o?1:1+t.extentPadding];return{yDomain:n,stackExtentCache:{key:`${e.bufferSize}:${e.ingestVersion}:norm`,yDomain:n}}}const s=`${e.bufferSize}:${e.ingestVersion}:${t.baseline??"zero"}:${t.stackOrder??"key"}`;if(e.stackExtentCache&&e.stackExtentCache.key===s)return{yDomain:e.stackExtentCache.yDomain,stackExtentCache:e.stackExtentCache};const a=new Map,c=new Set;let l=0;const u=new Map,h=new Map;for(const e of n){const t=new Map;let n=0;for(const o of e.data){const e=r(o),s=i(o);if(!Number.isFinite(e)||!Number.isFinite(s))continue;t.set(e,(t.get(e)||0)+s),c.add(e),n+=s;const a=(u.get(e)||0)+s;u.set(e,a),a>l&&(l=a)}a.set(e.key,t),h.set(e.key,n)}const d=t.stackOrder??"key",f=(e,t)=>t>e?-1:e>t?1:0;let y,p;if("input"===d)y=n.map(e=>e.key);else if("insideOut"===d){const e=[...n].map(e=>e.key).sort((e,t)=>{const n=(h.get(t)??0)-(h.get(e)??0);return 0!==n?n:f(e,t)}),t=[],r=[];let i=0,o=0;for(const n of e)o>i?(t.push(n),i+=h.get(n)??0):(r.push(n),o+=h.get(n)??0);y=[...r.reverse(),...t]}else y="asc"===d?n.map(e=>e.key).sort((e,t)=>{const n=(h.get(e)??0)-(h.get(t)??0);return 0!==n?n:f(e,t)}):"desc"===d?n.map(e=>e.key).sort((e,t)=>{const n=(h.get(t)??0)-(h.get(e)??0);return 0!==n?n:f(e,t)}):n.map(e=>e.key).sort(f);if("wiggle"===t.baseline||"silhouette"===t.baseline){const e=Array.from(c).sort((e,t)=>e-t),n=Ee(e,y,(e,t)=>a.get(e)?.get(t)||0,t.baseline);let r=1/0,i=-1/0;for(const t of e){const e=n.get(t)??0,o=u.get(t)??0;r>e&&(r=e),e+o>i&&(i=e+o)}Number.isFinite(r)&&Number.isFinite(i)||(r=0,i=0);const s=i-r,l=o?0:s>0?s*t.extentPadding:1;p=[r-l,i+l]}else if("diverging"===t.baseline){const e=Array.from(c).sort((e,t)=>e-t),[n,r]=function(e,t,n){let r=0,i=0;for(const o of e){let e=0,s=0;for(const r of t){const t=n(r,o)||0;0>t?s+=t:e+=t}r>s&&(r=s),e>i&&(i=e)}return[r,i]}(e,y,(e,t)=>a.get(e)?.get(t)||0),i=r-n,s=o?0:i>0?i*t.extentPadding:1;p=[n-s,r+s]}else p=[0,l+(o?0:l>0?l*t.extentPadding:1)];return{yDomain:p,stackExtentCache:{key:s,yDomain:p}}}({config:t,groups:this.groupData(o),getX:this.getX,getY:this.getY,bufferSize:n.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});c=e.yDomain,this._stackExtentCache=e.stackExtentCache}else"bar"===t.chartType&&t.binSize&&!l&&n.size>0?c=function(e,t,n,r,i,o,s){const[,a]=function(e,t,n,r,i){const o=et(e,t,n,r,i);if(0===o.size)return[0,0];let s=0;for(const e of o.values())e.total>s&&(s=e.total);return[0,s]}(e,t,n,r,i);return[0,s?a:a+a*o]}(n,this.getX,this.getY,t.binSize,this.getCategory,t.extentPadding,h):"waterfall"===t.chartType&&!l&&n.size>0?c=function(e,t,n,r){const[i,o]=function(e,t){let n=0,r=0,i=0;for(const o of e){const e=t(o);null==e||Number.isNaN(e)||(i+=e,n>i&&(n=i),i>r&&(r=i))}return[n,r]}(e,t),s=o-i,a=r?0:s>0?s*n:1;return[Math.min(0,i-Math.abs(a)),Math.max(0,o+Math.abs(a))]}(n,this.getY,t.extentPadding,h):l||c[0]===1/0||(c=function(e,t,n){if(!n.length)return e;let[r,i]=e;for(const e of t)for(const t of n){const n=t.getTop(e),o=t.getBottom(e);Number.isFinite(n)&&(r>n&&(r=n),n>i&&(i=n)),Number.isFinite(o)&&(r>o&&(r=o),o>i&&(i=o))}return[r,i]}(c,o,this.resolvedRibbons),c=function(e,t){const n=e[1]-e[0],r=t.exactMode?0:n>0?n*t.extentPadding:1,i=[null!=t.userMin?e[0]:e[0]-r,null!=t.userMax?e[1]:e[1]+r];return"log"!==t.yScaleType||i[0]>0||0>=t.dataYDomain[0]||t.exactMode||null==t.userMin&&(i[0]=t.dataYDomain[0]/(1+t.extentPadding)),i}(c,{exactMode:h,extentPadding:t.extentPadding,userMin:t.yExtent?.[0],userMax:t.yExtent?.[1],yScaleType:t.yScaleType,dataYDomain:s}));c=function(e,t,n){if(!t||n)return e;const r=t[0],i=t[1];return null==r&&null==i?e:[null!=r?r:e[0],null!=i?i:e[1]]}(c,t.yExtent,!!l),({xDomain:a,yDomain:c}=function(e,t,n){let r=e,i=t;if(r[0]===1/0||r[1]===-1/0)if("time"===n){const e=Date.now();r=[e-864e5,e]}else r=[0,1];return i[0]!==1/0&&i[1]!==-1/0||(i=[0,1]),{xDomain:r,yDomain:i}}(a,c,t.xScaleType)),this.scales=function(e){const{config:t,layout:n,xDomain:r,yDomain:i}=e,o="streaming"===t.runtimeMode,s=Math.max(0,Math.min(t.scalePadding||0,Math.min(n.width,n.height)/2-1));if(o){if("x"==("up"===(a=t.arrowOfTime)||"down"===a?"y":"x")){const e="right"===t.arrowOfTime?[s,n.width-s]:[n.width-s,s];return{x:(0,at.scaleLinear)().domain(r).range(e),y:lt(t.yScaleType,i,[n.height-s,s])}}const e="down"===t.arrowOfTime?[s,n.height-s]:[n.height-s,s];return{x:lt(t.yScaleType,i,[s,n.width-s]),y:(0,at.scaleLinear)().domain(r).range(e)}}var a;return{x:lt(t.xScaleType,r,[s,n.width-s]),y:lt(t.yScaleType,i,[n.height-s,s])}}({config:t,layout:e,xDomain:a,yDomain:c}),this._customLayoutFailedThisBuild=!1;const d=this.buildSceneNodes(e,o);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=r,this.lastLayout=i):(this.scene=[],this.spatialIndex.rebuild(this.config.chartType,this.scene)),void(this.needsFullRebuild=!0);this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=d,this.config.decay&&this.applyDecay(this.scene,o),this.config.pulse&&this.applyPulse(this.scene,o,this.currentTime()),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.spatialIndex.rebuild(this.config.chartType,this.scene),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(e){const t=e.width/this.lastLayout.width,n=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const r of e.path)r[0]*=t,r[1]*=n;break;case"area":for(const r of e.topPath)r[0]*=t,r[1]*=n;for(const r of e.bottomPath)r[0]*=t,r[1]*=n;e.clipRect&&(e.clipRect={x:e.clipRect.x*t,y:e.clipRect.y*n,width:e.clipRect.width*t,height:e.clipRect.height*n});break;case"point":case"glyph":e.x*=t,e.y*=n;break;case"rect":case"heatcell":e.x*=t,e.y*=n,e.w*=t,e.h*=n;break;case"candlestick":e.x*=t,e.openY*=n,e.closeY*=n,e.highY*=n,e.lowY*=n}const r=this.scales.x.domain(),i=this.scales.y.domain(),o=this.scales.x.range(),s=this.scales.y.range(),a=lt,c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),l=s[1]>s[0];this.scales={x:a(this.config.xScaleType,r,o[0]>o[1]?[e.width-c,c]:[c,e.width-c]),y:a(this.config.yScaleType,i,l?[c,e.height-c]:[e.height-c,c])},this.lastLayout={width:e.width,height:e.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(e,t){const{config:n,scales:r}=this;if(!r)return[];if(n.customLayout){const i={data:t,scales:r,dimensions:{width:e.width,height:e.height,margin:n.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:n.themeSemantic??{},categorical:n.themeCategorical??de},resolveColor:(e,t)=>{const r=this.resolveGroupColor(e);if(r)return r;const i=this.resolveLineStyle(e,t);return i.stroke?i.stroke:"string"==typeof i.fill?i.fill:n.themeSemantic?.primary??"#4e79a7"},config:n.layoutConfig??{},selection:n.layoutSelection??null};let o;try{o=n.customLayout(i)}catch(e){const t=null!==this.lastCustomLayoutResult,r=it("xy",e,t,this.version);this.lastCustomLayoutFailure=r,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",e);try{n.onLayoutError?.(r)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return t?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=o.overlays??null,this.lastCustomLayoutResult=o,this.lastCustomLayoutFailure=null;const s=o.nodes??[];if(this._customRestyle=o.restyle,this.hasCustomRestyle=!!o.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const e of s)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(s,n.layoutSelection??null)}return tt({label:"customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}if(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===t.length)return[];const i={scales:r,config:n,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getSymbol:this.getSymbol,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(e,t)=>this.resolveLineStyle(e,t),resolveAreaStyle:(e,t)=>this.resolveAreaStyle(e,t),resolveBoundsStyle:(e,t)=>this.resolveBoundsStyle(e,t),resolveColorMap:e=>this.resolveColorMap(e),resolveGroupColor:e=>this.resolveGroupColor(e),groupData:e=>this.groupData(e),barCategoryCache:this._barCategoryCache};switch(n.chartType){case"line":return function(e,t){const n=e.groupData(t),r=[],i=e.config.annotations?.filter(He).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){const{perSeries:i,aggregate:o}=ze(e.ribbons);if(o.length>0&&r.push(...Oe(e,t,o)),i.length>0)for(const t of n)r.push(...Fe(e,t.data,t.key,i))}for(const t of n){const n=e.resolveLineStyle(t.key,t.data[0]),o=je(t.data,e.scales,e.getX,e.getY,n,t.key);i&&i.length>0&&(o.colorThresholds=i),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}return Ye(e,n,r),r}(i,t);case"area":return function(e,t){const n=e.groupData(t),r=[];if(e.ribbons&&e.ribbons.length>0){const{perSeries:i,aggregate:o}=ze(e.ribbons);if(o.length>0&&r.push(...Oe(e,t,o)),i.length>0)for(const t of n)r.push(...Fe(e,t.data,t.key,i))}const i=e.scales.y.domain()[0],o=e.getY0?t=>{const n=e.getY0(t);return null==n?i:n}:void 0;for(const t of n){const n=e.resolveAreaStyle(t.key,t.data[0]),s=Te(t.data,e.scales,e.getX,e.getY,i,n,t.key,o),a=qe(e.config.gradientFill);a&&(s.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(s.curve=e.config.curve),e.config.lineGradient&&(s.strokeGradient=e.config.lineGradient),r.push(s)}return Ye(e,n,r),r}(i,t);case"mixed":return function(e,t){const n=e.groupData(t),r=[],i=e.config.areaGroups||new Set;if(e.ribbons&&e.ribbons.length>0){const{perSeries:i,aggregate:o}=ze(e.ribbons);if(o.length>0&&r.push(...Oe(e,t,o)),i.length>0)for(const t of n)r.push(...Fe(e,t.data,t.key,i))}const o=e.scales.y.domain()[0],s=e.getY0?t=>{const n=e.getY0(t);return null==n?o:n}:void 0;for(const t of n)if(i.has(t.key)){const n=e.resolveAreaStyle(t.key,t.data[0]),i=Te(t.data,e.scales,e.getX,e.getY,o,n,t.key,s),a=qe(e.config.gradientFill);a&&(i.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),r.push(i)}else{const n=e.resolveLineStyle(t.key,t.data[0]),i=je(t.data,e.scales,e.getX,e.getY,n,t.key);e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),r.push(i)}return Ye(e,n,r),r}(i,t);case"stackedarea":return function(e,t){const n=e.groupData(t),r=e.config.stackOrder??"key",i=()=>n.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);if("input"===r);else if("key"===r)i();else if("asc"===r||"desc"===r||"insideOut"===r){const t=new Map;for(const r of n){let n=0;for(const t of r.data){const r=e.getX(t),i=e.getY(t);Number.isFinite(r)&&Number.isFinite(i)&&(n+=i)}t.set(r.key,n)}const i=(e,t)=>t>e?-1:e>t?1:0;if("asc"===r)n.sort((e,n)=>{const r=(t.get(e.key)??0)-(t.get(n.key)??0);return 0!==r?r:i(e.key,n.key)});else if("desc"===r)n.sort((e,n)=>{const r=(t.get(n.key)??0)-(t.get(e.key)??0);return 0!==r?r:i(e.key,n.key)});else{const e=[...n].sort((e,n)=>{const r=(t.get(n.key)??0)-(t.get(e.key)??0);return 0!==r?r:i(e.key,n.key)}),r=[],o=[];let s=0,a=0;for(const n of e)a>s?(r.push(n),s+=t.get(n.key)??0):(o.push(n),a+=t.get(n.key)??0);n.length=0,n.push(...o.reverse(),...r)}}else i();const o=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,s=e.config.normalize?"zero":e.config.baseline??"zero",{nodes:a,stackedTops:c}=function(e,t,n,r,i,o,s,a="zero"){const c=new Set;for(const t of e)for(const e of t.data){const t=n(e);Number.isFinite(t)&&c.add(t)}const l=Array.from(c).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const i of t.data){const t=n(i),o=r(i);Number.isFinite(t)&&Number.isFinite(o)&&e.set(t,(e.get(t)||0)+o)}u.set(t.key,e)}let h;if(o){h=new Map;for(const t of l){let n=0;for(const r of e)n+=u.get(r.key)?.get(t)||0;h.set(t,n||1)}}const d=Ee(l,e.map(e=>e.key),(e,t)=>u.get(e)?.get(t)||0,a),f="diverging"===a&&!o,y=[],p=new Map,g=new Map,m=new Map,x=new Map;for(const e of l)g.set(e,d.get(e)??0),m.set(e,0),x.set(e,0);for(const n of e){const e=u.get(n.key),r=new Map;let a=[],c=[];const d=()=>{if(a.length>=2){const e={type:"area",topPath:a,bottomPath:c,style:i(n.key,n.data[0]),datum:n.data,group:n.key};s&&(e.curve=s),y.push(e)}a=[],c=[]};for(const n of l){const i=e.has(n);let s,l,u=i?e.get(n):0;if(o&&i&&(u/=h.get(n)),!i||!Number.isFinite(u)||0===u){d();continue}f?u>0?(s=m.get(n),l=s+u,m.set(n,l)):(s=x.get(n),l=s+u,x.set(n,l)):(s=g.get(n),l=s+u,g.set(n,l));const y=t.x(n);c.push([y,t.y(s)]),a.push([y,t.y(l)]),r.set(n,l)}d(),p.set(n.key,r)}return{nodes:y,stackedTops:p}}(n,e.scales,e.getX,e.getY,(t,n)=>e.resolveAreaStyle(t,n),e.config.normalize,o,s),l=a;if(e.config.pointStyle){const t=new WeakMap;for(const r of n){const n=c.get(r.key);if(n)for(const i of r.data){const r=e.getX(i),o=e.getY(i);null==r||Number.isNaN(r)||null==o||Number.isNaN(o)||!n.has(r)||t.set(i,n.get(r))}}const r=n=>t.get(n)??e.getY(n);Ye(e,n,l,r)}return l}(i,t);case"scatter":case"bubble":return function(e,t){const n=[],r="bubble"===e.config.chartType?10:5,i=e.config.sizeRange||[3,15];let o=null;if(e.getSize&&!e.config.pointStyle){const n=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(n.length>0){let e=1/0,t=-1/0;for(const r of n)e>r&&(e=r),r>t&&(t=r);o=n=>e===t?(i[0]+i[1])/2:i[0]+(n-e)/(t-e)*(i[1]-i[0])}}const s=e.getColor?e.resolveColorMap(t):null,a=e.config.themeSemantic?.primary||"#4e79a7",c=e.getSymbol,l=e.config.symbolMap,u=new Map;let h=0;const d=e=>{const t=l?.[e];if(t)return t;let n=u.get(e);return n||(n=Ue[h%Ue.length],h++,u.set(e,n)),n};for(const i of t){let t=e.config.pointStyle?e.config.pointStyle(i):{fill:a,opacity:.8},l=t.r||r;if(o&&e.getSize){const t=e.getSize(i);null==t||Number.isNaN(t)||(l=o(t))}if(s&&e.getColor&&!t.fill){const n=e.getColor(i);n&&s.has(n)&&(t={...t,fill:s.get(n)})}const u=e.getPointId?e.getPointId(i)+"":void 0;if(c){const r=d(c(i)+""),o=Ne(i,e.scales,e.getX,e.getY,Math.PI*l*l,r,t,u);o&&n.push(o)}else{const r=De(i,e.scales,e.getX,e.getY,l,t,u);r&&n.push(r)}}return n}(i,t);case"heatmap":return Je(i,t,e);case"bar":{const e=function(e,t){if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const n=et(t,e.getX,e.getY,e.config.binSize,e.getCategory);if(0===n.size)return{nodes:[],binBoundaries:[]};let r=null;if(e.getCategory){const t=new Set;for(const e of n.values())for(const n of e.categories.keys())t.add(n);const i=e.config.barColors?Object.keys(e.config.barColors):[],o=new Set(i),s=Array.from(t).filter(e=>!o.has(e)).sort(),a=i.filter(e=>t.has(e)),c=a.join("\0")+""+s.join("\0");e.barCategoryCache&&e.barCategoryCache.key===c?r=e.barCategoryCache.order:(r=[...a,...s],e.barCategoryCache={key:c,order:r})}const i=[],o=e.scales,[s,a]=o.x.domain(),c=e.config.barStyle,l=e.config.themeSemantic?.primary,u=c?.gap,h="number"!=typeof u||0>u?1:u,d={};c?.stroke&&(d.stroke=c.stroke),"number"==typeof c?.strokeWidth&&(d.strokeWidth=c.strokeWidth),"number"==typeof c?.opacity&&(d.opacity=c.opacity);for(const t of n.values()){const n=Math.max(t.start,s),u=Math.min(t.end,a);if(n>=u)continue;const f=o.x(n),y=o.x(u),p=Math.abs(y-f),g=p>h+1?h:0,m=Math.min(f,y)+g/2,x=Math.max(p-g,1);if(x>0)if(r&&t.categories.size>0){let n=0;for(const s of r){const r=t.categories.get(s)||0;if(0===r)continue;const a=o.y(n),u=o.y(n+r);i.push(Le(m,Math.min(a,u),x,Math.abs(a-u),{fill:e.config.barColors?.[s]||c?.fill||l||"#4e79a7",...d},{binStart:t.start,binEnd:t.end,total:t.total,category:s,categoryValue:r},s)),n+=r}}else{const e=o.y(0),n=o.y(t.total);i.push(Le(m,Math.min(e,n),x,Math.abs(e-n),{fill:c?.fill||l||"#007bff",...d},{binStart:t.start,binEnd:t.end,total:t.total}))}}const f=new Set;for(const e of n.values())f.add(e.start),f.add(e.end);return{nodes:i,binBoundaries:Array.from(f).sort((e,t)=>e-t)}}(i,t);return this._barCategoryCache=i.barCategoryCache??null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){const n=[],r=e.config.swarmStyle||{},i=r.radius??3,o=r.fill??e.config.themeSemantic?.primary??"#007bff",s=r.opacity??.7,a=r.stroke,c=r.strokeWidth;for(const r of t){const t=e.getX(r),l=e.getY(r);if(null==l||Number.isNaN(l))continue;const u=e.scales.x(t),h=e.scales.y(l);let d=o;if(e.getCategory){const t=e.getCategory(r);d=e.config.barColors?.[t]||d}const{r:f,...y}=e.config.pointStyle?.(r)??{},p={type:"point",x:u,y:h,r:f??i,style:{fill:d,opacity:s,stroke:a,strokeWidth:c,...y},datum:r};e.getPointId&&(p.pointId=e.getPointId(r)+""),n.push(p)}return n}(i,t);case"waterfall":return function(e,t,n){const r=[],i=e.scales,o=e.config.waterfallStyle,s=t.filter(t=>{const n=e.getY(t),r=e.getX(t);return null!=n&&!Number.isNaN(n)&&null!=r&&isFinite(r)});if(0===s.length)return r;const a=o?.positiveColor??e.config.themeSemantic?.success??"#28a745",c=o?.negativeColor??e.config.themeSemantic?.danger??"#dc3545",l=o?.gap??1,u=o?.stroke,h=o?.strokeWidth,d=o?.opacity;let f=0;for(let t=0;s.length>t;t++){const y=s[t],p=e.getX(y),g=e.getY(y),m=f+g;let x;x=s.length-1>t?e.getX(s[t+1])-p:t>0?p-e.getX(s[t-1]):0;const v=i.x(p),b=0!==x?i.x(p+x):v+n.width/10,k=Math.min(v,b)+l/2,w=Math.max(v,b)-l/2-k;if(0>=w){f=m;continue}const A=i.y(f),S=i.y(m),_=Math.min(A,S),M=Math.abs(A-S),C={fill:0>g?c:a,stroke:u,strokeWidth:h};null!=d&&(C.opacity=d),r.push(Le(k,_,w,M,C,{...y,baseline:f,cumEnd:m,delta:g,_connectorStroke:o?.connectorStroke,_connectorWidth:o?.connectorWidth})),f=m}return r}(i,t,e);case"candlestick":return function(e,t){if(!e.getHigh||!e.getLow||!e.scales)return[];const n=e.config.candlestickRangeMode??!1;if(!(n||e.getOpen&&e.getClose))return[];const r=[],i=e.config.candlestickStyle||{},o=i.rangeColor||"#6366f1",s=n?o:i.upColor||"#28a745",a=n?o:i.downColor||"#dc3545",c=n?o:i.wickColor||"#333",l=i.wickWidth||(n?2:1),u=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let h=i.bodyWidth??0;if(null==i.bodyWidth)if(u.length>1){let t=1/0;for(let n=1;u.length>n;n++){const r=Math.abs(e.scales.x(u[n])-e.scales.x(u[n-1]));r>0&&t>r&&(t=r)}h=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else h=6;for(const i of t){const t=e.getX(i);if(null==t||Number.isNaN(t))continue;const o=e.getHigh(i),u=e.getLow(i);if(null==o||Number.isNaN(o)||null==u||Number.isNaN(u))continue;const d=n?o:e.getOpen(i),f=n?u:e.getClose(i);if(!n&&[d,f].some(e=>null==e||Number.isNaN(e)))continue;const y=f>=d,p={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(d),closeY:e.scales.y(f),highY:e.scales.y(o),lowY:e.scales.y(u),bodyWidth:h,upColor:s,downColor:a,wickColor:c,wickWidth:l,isUp:y,datum:i};n&&(p.isRange=!0),r.push(p)}return r}(i,t);default:return[]}}resolveBoundsStyle(e,t){return function(e,t,n,r){const i=e.boundsStyle;return"function"==typeof i?i(n||{},t):i&&"object"==typeof i?i:{fill:r(t,n).stroke||e.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,stroke:"none"}}(this.config,e,t,(e,t)=>this.resolveLineStyle(e,t))}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?_e(n,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const t=Me(e);return this._datumIndexCache={version:this._ingestVersion,map:t},t}applyDecay(e,t){this.config.decay&&function(e,t,n,r=Me(n)){const i=n.length;if(i>1)for(const n of t){if("line"===n.type){const t=Array.isArray(n.datum)?n.datum:[];if(2>t.length)continue;const o=Array(t.length);let s=!1;for(let n=0;t.length>n;n++){const a=r.get(t[n]);null!=a?(o[n]=_e(e,a,i),1>o[n]&&(s=!0)):o[n]=1}s&&(n._decayOpacities=o);continue}if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[],o=n.topPath?n.topPath.length:t.length;if(2>o)continue;if(t.length===o){const s=Array(o);let a=!1;for(let n=0;t.length>n;n++){const o=r.get(t[n]);null!=o?(s[n]=_e(e,o,i),1>s[n]&&(a=!0)):s[n]=1}a&&(n._decayOpacities=s)}else{let s=1;for(const n of t){const t=r.get(n);if(null!=t){const n=_e(e,t,i);s>n&&(s=n)}}if(1>s){const e=Array(o);e.fill(s),n._decayOpacities=e}}continue}const t=r.get(n.datum);if(null==t)continue;const o=_e(e,t,i);"heatcell"===n.type?n.style={opacity:o}:"candlestick"===n.type?n._decayOpacity=o:n.style={...n.style,opacity:(n.style?.opacity??1)*o}}}(this.config.decay,e,t,this.getDatumIndexMap(t))}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&function(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){if(!t||0===t.size)return!1;const r=e.duration??500,i=t.peek();return null!=i&&r>n-i}(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(e,t,n,r){n.clear(),r.clear();for(let i=0;t.length>i;i++){const o=t[i],s=Re(e,o,i);s&&("point"===o.type?n.set(s,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity}):"glyph"===o.type?n.set(s,{x:o.x,y:o.y,r:o.size,opacity:o.style.opacity,glyph:o.glyph}):"rect"===o.type?n.set(s,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity}):"heatcell"===o.type?n.set(s,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style?.opacity}):"candlestick"===o.type?n.set(s,{x:o.x,y:o.openY,w:o.bodyWidth,openY:o.openY,closeY:o.closeY,highY:o.highY,lowY:o.lowY,opacity:o.style?.opacity}):"line"===o.type?r.set(s,{path:o.path.map(e=>[e[0],e[1]]),opacity:o.style?.opacity}):"area"===o.type&&r.set(s,{topPath:o.topPath.map(e=>[e[0],e[1]]),bottomPath:o.bottomPath.map(e=>[e[0],e[1]]),opacity:o.style?.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();const e=this.scales?.y(0)??0;for(let t=0;this.scene.length>t;t++){const n=this.scene[t],r=Re(this.transitionContext,n,t);r&&("point"===n.type?this.prevPositionMap.set(r,{x:n.x,y:n.y,r:0,opacity:0}):"rect"===n.type?this.prevPositionMap.set(r,{x:n.x,y:e,w:n.w,h:0,opacity:n.style.opacity??1}):"heatcell"===n.type?this.prevPositionMap.set(r,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:0}):"line"===n.type?(n._introClipFraction=0,this.prevPathMap.set(r,{path:n.path.map(e=>[e[0],e[1]]),opacity:n.style.opacity})):"area"===n.type&&(n._introClipFraction=0,this.prevPathMap.set(r,{topPath:n.topPath.map(e=>[e[0],e[1]]),bottomPath:n.bottomPath.map(e=>[e[0],e[1]]),opacity:n.style.opacity})))}}startTransition(){if(!this.config.transition)return;const e=function(e,t,n,r,i,o=me()){if(0===r.size&&0===i.size)return n;const s=t.duration??300;if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}let a=!1;const c=new Set,l=new Set;for(let t=0;n.scene.length>t;t++){const o=n.scene[t],s=Re(e,o,t);if(!s)continue;if(o._transitionKey=s,"line"===o.type||"area"===o.type){const e=i.get(s);if(e){if(l.add(s),"line"===o.type&&e.path&&e.path.length===o.path.length){o._targetPath=o.path.map(e=>[e[0],e[1]]),o._prevPath=e.path;for(let t=0;o.path.length>t;t++)o.path[t]=[e.path[t][0],e.path[t][1]];a=!0}else if("area"===o.type&&e.topPath&&e.bottomPath&&e.topPath.length===o.topPath.length&&e.bottomPath.length===o.bottomPath.length){o._targetTopPath=o.topPath.map(e=>[e[0],e[1]]),o._targetBottomPath=o.bottomPath.map(e=>[e[0],e[1]]),o._prevTopPath=e.topPath,o._prevBottomPath=e.bottomPath;for(let t=0;o.topPath.length>t;t++)o.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;o.bottomPath.length>t;t++)o.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];a=!0}o._targetOpacity=o.style.opacity??1,o._startOpacity=e.opacity??o.style.opacity??1}else o._targetOpacity=o.style.opacity??1,o._startOpacity=0,o.style={...o.style,opacity:0},a=!0;continue}const u=r.get(s);if("point"===o.type)if(u){c.add(s);const e={x:o.x,y:o.y,r:o.r};o._targetOpacity=o.style.opacity??1,u.x===e.x&&u.y===e.y&&u.r===e.r||(o._targetX=e.x,o._targetY=e.y,o._targetR=e.r,o.x=u.x,o.y=u.y,o.r=u.r??o.r,a=!0)}else o._targetOpacity=o.style.opacity??1,o.style={...o.style,opacity:0},a=!0;else if("glyph"===o.type)if(u){c.add(s);const e={x:o.x,y:o.y,size:o.size};o._targetOpacity=o.style.opacity??1,u.x===e.x&&u.y===e.y&&u.r===e.size||(o._targetX=e.x,o._targetY=e.y,o._targetR=e.size,o.x=u.x,o.y=u.y,o.size=u.r??o.size,a=!0)}else o._targetOpacity=o.style.opacity??1,o.style={...o.style,opacity:0},a=!0;else if("rect"===o.type)if(u){c.add(s);const e={x:o.x,y:o.y,w:o.w,h:o.h};o._targetOpacity=o.style.opacity??1,u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(o._targetX=e.x,o._targetY=e.y,o._targetW=e.w,o._targetH=e.h,o.x=u.x,o.y=u.y,o.w=u.w??o.w,o.h=u.h??o.h,a=!0)}else o._targetOpacity=o.style.opacity??1,o.style={...o.style,opacity:0},a=!0;else if("heatcell"===o.type)if(u){c.add(s);const e={x:o.x,y:o.y,w:o.w,h:o.h};o._targetOpacity=o.style?.opacity??1,u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(o._targetX=e.x,o._targetY=e.y,o._targetW=e.w,o._targetH=e.h,o.x=u.x,o.y=u.y,o.w=u.w??o.w,o.h=u.h??o.h,a=!0)}else o._targetOpacity=o.style?.opacity??1,o.style={...o.style||{},opacity:0},a=!0;else if("candlestick"===o.type)if(u&&null!=u.openY){c.add(s);const e={x:o.x,openY:o.openY,closeY:o.closeY,highY:o.highY,lowY:o.lowY};o._targetOpacity=o.style?.opacity??1,(u.x!==e.x||u.openY!==e.openY||u.closeY!==e.closeY||u.highY!==e.highY||u.lowY!==e.lowY)&&(o._targetX=e.x,o._targetOpenY=e.openY,o._targetCloseY=e.closeY,o._targetHighY=e.highY,o._targetLowY=e.lowY,o.x=u.x,o.openY=u.openY,o.closeY=u.closeY??o.closeY,o.highY=u.highY??o.highY,o.lowY=u.lowY??o.lowY,a=!0)}else o._targetOpacity=o.style?.opacity??1,o.style={...o.style||{},opacity:0},a=!0}for(const[e,t]of i)if(!l.has(e))if(e.startsWith("l:")&&t.path){const r={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(r),a=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const r={type:"area",topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),group:e.slice(2),style:{fill:"#999",opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(r),a=!0}for(const[e,t]of r)if(!c.has(e)){if(e.startsWith("p:"))n.exitNodes.push({type:"point",x:t.x,y:t.y,r:t.r??3,style:{opacity:t.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("g:")&&t.glyph)n.exitNodes.push({type:"glyph",x:t.x,y:t.y,size:t.r??12,glyph:t.glyph,color:"#999",accent:"#999",style:{opacity:t.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))n.exitNodes.push({type:"rect",x:t.x,y:t.y,w:t.w??0,h:t.h??0,style:{opacity:t.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("h:"))n.exitNodes.push({type:"heatcell",x:t.x,y:t.y,w:t.w??0,h:t.h??0,fill:"#999",datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e});else if(e.startsWith("c:")){const r=t.openY??t.y;n.exitNodes.push({type:"candlestick",x:t.x,openY:r,closeY:t.closeY??r,highY:t.highY??r,lowY:t.lowY??r,bodyWidth:t.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e})}a=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),a&&(n.activeTransition={startTime:o,duration:s}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap,this.currentTime());this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition}advanceTransition(e){if(!this.activeTransition||!this.config.transition)return!1;const t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(e,t,n,r){if(!n.activeTransition)return!1;const i=pe(e,n.activeTransition),o=ye(i,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of n.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style.opacity=ge(n?n.opacity??1:0,e._targetOpacity,o)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=ge(n.x,e._targetX,o),e.y=ge(n.y,e._targetY,o),void 0!==e._targetR&&void 0!==n.r&&(e.r=ge(n.r,e._targetR,o))}else if("glyph"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style.opacity=ge(n?n.opacity??1:0,e._targetOpacity,o)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=ge(n.x,e._targetX,o),e.y=ge(n.y,e._targetY,o),void 0!==e._targetR&&void 0!==n.r&&(e.size=ge(n.r,e._targetR,o))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style.opacity=ge(n?n.opacity??1:0,e._targetOpacity,o)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=ge(n.x,e._targetX,o),e.y=ge(n.y,e._targetY,o),void 0!==n.w&&(e.w=ge(n.w,e._targetW,o)),void 0!==n.h&&(e.h=ge(n.h,e._targetH,o))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style={...e.style||{},opacity:ge(n?n.opacity??1:0,e._targetOpacity,o)}}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=ge(n.x,e._targetX,o),e.y=ge(n.y,e._targetY,o),void 0!==n.w&&(e.w=ge(n.w,e._targetW,o)),void 0!==n.h&&(e.h=ge(n.h,e._targetH,o))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style={...e.style||{},opacity:ge(n?n.opacity??1:0,e._targetOpacity,o)}}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=ge(n.x,e._targetX,o),void 0!==n.openY&&(e.openY=ge(n.openY,e._targetOpenY,o)),void 0!==n.closeY&&(e.closeY=ge(n.closeY,e._targetCloseY,o)),void 0!==n.highY&&(e.highY=ge(n.highY,e._targetHighY,o)),void 0!==n.lowY&&(e.lowY=ge(n.lowY,e._targetLowY,o))}else if("line"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:ge(e._startOpacity??0,e._targetOpacity,o)}),void 0!==e._introClipFraction&&(e._introClipFraction=o);const t=e._prevPath,n=e._targetPath;if(t&&n&&t.length===e.path.length)for(let r=0;e.path.length>r;r++)e.path[r][0]=ge(t[r][0],n[r][0],o),e.path[r][1]=ge(t[r][1],n[r][1],o)}else if("area"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:ge(e._startOpacity??0,e._targetOpacity,o)}),void 0!==e._introClipFraction&&(e._introClipFraction=o);const t=e._prevTopPath,n=e._prevBottomPath,r=e._targetTopPath,i=e._targetBottomPath;if(t&&r&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=ge(t[n][0],r[n][0],o),e.topPath[n][1]=ge(t[n][1],r[n][1],o);if(n&&i&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=ge(n[t][0],i[t][0],o),e.bottomPath[t][1]=ge(n[t][1],i[t][1],o)}}if(i>=1){for(const e of n.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style="line"===e.type||"area"===e.type?{...e.style,opacity:0===t?0:t}:{...e.style||{},opacity:0===t?0:t},e._targetOpacity=void 0}if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("glyph"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.size=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("candlestick"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,void 0!==e._targetOpenY&&(e.openY=e._targetOpenY),void 0!==e._targetCloseY&&(e.closeY=e._targetCloseY),void 0!==e._targetHighY&&(e.highY=e._targetHighY),void 0!==e._targetLowY&&(e.lowY=e._targetLowY),e._targetX=void 0,e._targetOpenY=void 0,e._targetCloseY=void 0,e._targetHighY=void 0,e._targetLowY=void 0}else if("line"===e.type){const t=e._targetPath;if(t)for(let n=0;e.path.length>n;n++)e.path[n]=t[n];e._prevPath=void 0,e._targetPath=void 0,e._introClipFraction=void 0}else if("area"===e.type){const t=e._targetTopPath,n=e._targetBottomPath;if(t)for(let n=0;e.topPath.length>n;n++)e.topPath[n]=t[n];if(n)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=n[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0,e._introClipFraction=void 0}}if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(e,this.config.transition,t,this.prevPositionMap);return this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition,n}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const e of this.scene)"line"!==e.type&&"area"!==e.type||(e._introClipFraction=void 0)}groupData(e){const{result:t,cache:n}=function(e,t,n,r){if(r&&r.version===n&&r.group===t&&r.data===e)return{result:r.result,cache:r};let i;if(t){const n=new Map;for(const r of e){const e=t(r);n.has(e)||n.set(e,[]),n.get(e).push(r)}i=Array.from(n.entries()).map(([e,t])=>({key:e,data:t}))}else i=[{key:"_default",data:e}];return{result:i,cache:{version:n,group:t,data:e,result:i}}}(e,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=n,t}resolveColorMap(e){const{map:t,cache:n}=function(e,t,n,r,i){if(i&&i.version===r)return{map:i.map,cache:i};const o=new Set;if(t)for(const n of e){const e=t(n);e&&o.add(e)}const s=Array.from(o).sort(),a=s.join("\0");if(i&&i.key===a){const e={...i,version:r};return{map:e.map,cache:e}}const c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical||de,l=new Map;for(let e=0;s.length>e;e++)l.set(s[e],c[e%c.length]);return{map:l,cache:{key:a,map:l,version:r}}}(e,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=n,t}resolveLineStyle(e,t){return function(e,t,n,r){const i=e.lineStyle;if("function"==typeof i){const e=i(n||{},t);if(e&&!e.stroke&&t){const n=r(t);if(n)return{...e,stroke:n}}return e}const o=e.themeSemantic?.primary;return i&&"object"==typeof i?{stroke:i.stroke||o||"#007bff",strokeWidth:i.strokeWidth||2,strokeDasharray:i.strokeDasharray,fill:i.fill,fillOpacity:i.fillOpacity,opacity:i.opacity}:{stroke:r(t)||o||"#007bff",strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveAreaStyle(e,t){return function(e,t,n,r){if(e.areaStyle){const i=e.areaStyle(n||{});if(i&&!i.fill&&t){const e=r(t);if(e)return{...i,fill:e,stroke:i.stroke||e}}return i}const i=e.lineStyle;if("function"==typeof i){const e=i(n||{},t);if(e&&!e.fill&&t){const n=r(t);if(n)return{...e,fill:n,stroke:e.stroke||n}}return e}const o=e.themeSemantic?.primary;if(i&&"object"==typeof i)return{fill:i.fill||i.stroke||o||"#4e79a7",fillOpacity:i.fillOpacity??.7,stroke:i.stroke||o||"#4e79a7",strokeWidth:i.strokeWidth||2};const s=r(t)||o||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveGroupColor(t){const{color:n,groupColorCounter:r}=function(e){const{group:t,colorMapCache:n,groupColorMap:r,groupColorMapCap:i,config:o}=e;let{groupColorCounter:s}=e;if(n){const e=n.map.get(t);if(e)return{color:e,groupColorCounter:s}}const a=r.get(t);if(a)return{color:a,groupColorCounter:s};const c=(Array.isArray(o.colorScheme)&&o.colorScheme.length>0?o.colorScheme:null)||(Array.isArray(o.themeCategorical)&&o.themeCategorical.length>0?o.themeCategorical:null)||de;if(0===c.length)return{color:null,groupColorCounter:s};const l=c[s%c.length];if(s++,r.set(t,l),r.size>i){const e=r.keys().next().value;void 0!==e&&r.delete(e)}return{color:l,groupColorCounter:s}}({group:t,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:e.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=r,n}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(e){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=q(e),n=this.getPointId,r=e=>t.has(n(e));!function(e,t,n){if(!t||0===t.size)return;const r=new Set;if(e.forEach((e,t)=>{n(e)&&r.add(t)}),0===r.size)return;const i=t.toArray();t.clear();for(let e=0;i.length>e;e++)r.has(e)||t.push(i[e])}(this.buffer,this.timestampBuffer,r);const i=this.buffer.remove(r);if(0===i.length)return this.updateResults.recordNoop("remove"),i;for(const e of i)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",i.length),i}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=q(e),r=this.getPointId,i=new Set;this.buffer.forEach((e,t)=>{n.has(r(e))&&i.add(t)});const o=this.buffer.update(e=>n.has(r(e)),t);if(0===o.length)return this.updateResults.recordNoop("update"),o;for(const e of o)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.buffer.forEach((e,t)=>{i.has(t)&&(this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",o.length),o}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this._datumIndexCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.spatialIndex.clear(),this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}applyCustomRestyle(e,t){const n=this._customRestyle;if(n)for(const r of e){const e=this._baseStyles.get(r)??r.style??{},i=n(r,t);r.style=i?{...e,...i}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(e){const t={...this.config},n=Object.keys(e).filter(n=>e[n]!==t[n]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e||"themeCategorical"in e||"colorAccessor"in e)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in e||"colorScheme"in e)&&(this._barCategoryCache=null),("normalize"in e||"extentPadding"in e||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e||"boundsAccessor"in e||"band"in e||"y0Accessor"in e||"openAccessor"in e||"highAccessor"in e||"lowAccessor"in e||"closeAccessor"in e||"groupAccessor"in e||"categoryAccessor"in e||"chartType"in e||"runtimeMode"in e)&&(this._stackExtentCache=null);let r=!1,i=!1;Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();const o="chartType"in e&&e.chartType!==t.chartType||"runtimeMode"in e&&e.runtimeMode!==t.runtimeMode;if(o||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){const e=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,n=e&&this.config.valueAccessor||this.config.yAccessor,s=e&&t.valueAccessor||t.yAccessor,a=o||!z(e&&this.config.timeAccessor||this.config.xAccessor,e&&t.timeAccessor||t.xAccessor),c=o||!z(n,s);(a||c)&&(e?(this.getX=O(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=O(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=O(this.config.xAccessor,"x"),this.getY=O(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=st(this.config)),r=!0,i=!0)}if("groupAccessor"in e&&!z(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?B(this.config.groupAccessor):void 0,r=!0),"categoryAccessor"in e&&!z(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?B(this.config.categoryAccessor):void 0,r=!0),"sizeAccessor"in e&&!z(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?O(this.config.sizeAccessor,"size"):void 0,r=!0),"symbolAccessor"in e&&!z(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?B(this.config.symbolAccessor):void 0,r=!0),"colorAccessor"in e&&!z(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?B(this.config.colorAccessor):void 0,r=!0),"y0Accessor"in e&&!z(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?O(this.config.y0Accessor,"y0"):void 0,r=!0,i=!0),("boundsAccessor"in e&&!z(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=st(this.config),r=!0,i=!0),"pointIdAccessor"in e&&!z(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?B(this.config.pointIdAccessor):void 0,r=!0),"candlestick"===this.config.chartType&&(o||"openAccessor"in e&&!z(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!z(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!z(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!z(e.lowAccessor,t.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?O(this.config.openAccessor,"open"):void 0,this.getHigh=O(this.config.highAccessor,"high"),this.getLow=O(this.config.lowAccessor,"low"),this.getClose=t?O(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,r=!0,i=!0}if("accessorRevision"in e&&e.accessorRevision!==t.accessorRevision&&(r=!0,i=!0),!r){const n=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const i of n)if(e[i]!==t[i]){r=!0;break}}r&&(i&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(n)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};$t.GROUP_COLOR_MAP_CAP=1e3;var zt=$t;xt(zt);var Ot=require("react"),Ft={sceneGeometry:0,layout:0,domain:0};function Bt(e){const{domain:t,layout:n,sceneGeometry:r}=e.revisions;return{domain:t,layout:n,sceneGeometry:r}}function Yt(e,t){return{sceneGeometry:Math.max(e.sceneGeometry,t.sceneGeometry),layout:Math.max(e.layout,t.layout),domain:Math.max(e.domain,t.domain)}}var Ht="production"!==process.env.NODE_ENV,Xt={revisions:Ft,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},qt=class{constructor(e="scene host"){this.hostName=e,this.lastConsumed=Ft,this.lastObserved=Ft,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}observeUpdateResult(e){Ht&&(this.lastObserved=Yt(this.lastObserved,Bt(e)))}beforeCompute(e,t){if(!Ht)return Xt;const n=Yt(Bt(e),this.lastObserved),r=function(e){return`${e.sceneGeometry}|${e.layout}|${e.domain}`}(n),i=!((o=n).sceneGeometry===(s=this.lastConsumed).sceneGeometry&&o.layout===s.layout&&o.domain===s.domain);var o,s;return{revisions:n,signature:r,sawSignals:e.changed.has("scene-geometry")||e.changed.has("layout")||e.changed.has("domain"),wasUnconsumed:i,warnUnconsumed:!t&&i&&this.lastUnconsumedWarning!==r}}afterCompute(e,t,n){if(Ht){if(t&&e.wasUnconsumed&&(this.lastConsumed=e.revisions),e.warnUnconsumed&&!t)return console.warn(`[semiotic] ${this.hostName} observed scene-affecting revisions without a scene rebuild: ${e.signature}.`),void(this.lastUnconsumedWarning=e.signature);t&&e.sawSignals&&!e.wasUnconsumed&&!n&&this.lastDuplicateWarning!==e.signature?(console.warn(`[semiotic] ${this.hostName} performed scene rebuild with unchanged scene revisions: ${e.signature}.`),this.lastDuplicateWarning=e.signature):t&&!e.sawSignals&&(this.lastDuplicateWarning="")}}};function Gt(e){return(0,Ot.useRef)(new qt(e))}var Vt=(0,Ot.memo)(function({store:e,diagnostics:t}){return(0,Ot.useEffect)(()=>{const n=()=>t.observeUpdateResult(e.getUpdateSnapshot());return n(),e.subscribeUpdateResult(n)},[t,e]),null}),Ut=c(require("react"));function Kt(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:Ut.createElement(Ut.Fragment,null,...t)}var Qt=c(require("react")),Zt=require("react/jsx-runtime"),Jt=Qt.createContext(null);function en({value:e,children:t}){return(0,Zt.jsx)(Jt.Provider,{value:e,children:t})}function tn(e,t){return null!=e?(0,Zt.jsx)(en,{value:t,children:e}):e}var nn=require("react");function rn(e,t,n,r){(0,nn.useEffect)(()=>{e.current?.updateConfig(t),n.current=!0,r()},[t,r,e,n])}function on(e,t,n,r){const i=(0,nn.useRef)(null);(0,nn.useEffect)(()=>{const o=e.current;if(!o)return;const s=t??null;i.current!==s&&(i.current=s,o.setLayoutSelection(s),o.hasCustomRestyle?o.restyleScene(s):n.current=!0,r())},[t,r,e,n])}function sn(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function an(e,t=30){return Math.max((e??4)+5,12,t)}function cn(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function ln(e,t){const n=cn(e);if(!n)return!1;const r=cn(t);return!r||n.getFullYear()!==r.getFullYear()||n.getMonth()!==r.getMonth()}function un(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}var hn=[40,40],dn=[.5,.5];function fn(e,t){const[n,r]=e.viewBox??hn,[i,o]=e.anchor??dn,s=r>0?r:1,a=Math.max(0,t)/s,c=(n>0?n:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-i*c,offsetY:-o*l}}function yn(e,t,n,r){if("none"!==e)return"color"===e||null==e?t??r:"accent"===e?n:e}var pn=null;function gn(e){if("undefined"==typeof Path2D)return null;pn||(pn=new Map);const t=pn.get(e);if(t)return t;const n=new Path2D(e);return pn.size>1024&&pn.clear(),pn.set(e,n),n}function mn(e,t,n=0,r="horizontal"){const[i,o]=e.viewBox??hn,s=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,t));return a>s?s>0||1>a?"vertical"===r?{x:0,y:o*(1-a),width:i,height:o*(a-s)}:{x:i*s,y:0,width:i*(a-s),height:o}:null:{x:0,y:0,width:0,height:0}}function xn(e,t){const n=fn(e,t);return{centerDx:n.offsetX+n.width/2,centerDy:n.offsetY+n.height/2,halfWidth:n.width/2,halfHeight:n.height/2,radius:Math.hypot(n.width,n.height)/2}}function vn(e,t,n,r,i,o=e=>e){for(const s of t.parts){const t=gn(s.d);if(!t)continue;const a=s.opacity??1,c=e.globalAlpha;1!==a&&(e.globalAlpha=c*a);const l=i?"none"===s.fill?void 0:i:yn(s.fill,n,r);l&&(e.fillStyle=o(l),e.fill(t));const u=i?s.stroke&&"none"!==s.stroke?i:void 0:yn(s.stroke??"none",n,r);u&&(e.strokeStyle=o(u),e.lineWidth=s.strokeWidth??1,e.lineCap=s.strokeLinecap??"butt",e.lineJoin=s.strokeLinejoin??"miter",e.stroke(t)),1!==a&&(e.globalAlpha=c)}}function bn(e,t,n,r,i,o=e=>e.x,s=e=>e.y,a=e=>e.r){const c=Math.max(r,i+5,12),l=t-c,u=t+c,h=n-c,d=n+c;let f=null,y=1/0;return e.visit((e,i,c,p,g)=>{if(i>u||l>p||c>d||h>g)return!0;if(!e.length){let i=e;do{const e=i.data,c=o(e)-t,l=s(e)-n,u=Math.sqrt(c*c+l*l);an(a(e),r)>=u&&y>u&&(f=e,y=u),i=i.next}while(i)}return!1}),f?{node:f,distance:y}:null}var kn=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,wn=new WeakMap,An=0,Sn=!1,_n=null,Mn=null;function Cn(e,t){if(!t)return t;const n=kn.exec(t);if(!n)return t;const r=e.canvas;if(!r)return n[2]?.trim()||t;!function(){if(Sn)return;if("undefined"==typeof window||"undefined"==typeof document)return;Sn=!0;const e=()=>{An++};if("undefined"!=typeof MutationObserver&&document.documentElement&&new MutationObserver(e).observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]}),"function"==typeof window.matchMedia)try{_n=window.matchMedia("(prefers-color-scheme: dark)"),Mn=e,"function"==typeof _n.addEventListener?_n.addEventListener("change",Mn):"function"==typeof _n.addListener&&_n.addListener(Mn)}catch{}}();let i=wn.get(r);i&&i.version===An||(i={version:An,map:new Map},wn.set(r,i));const o=i.map.get(t);if(void 0!==o)return o;const s=getComputedStyle(r).getPropertyValue(n[1]).trim()||n[2]?.trim()||t;return i.map.set(t,s),s}var Pn=null;var Rn=require("react/jsx-runtime");function jn(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function Tn(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}var En=new Map;function Dn(e,t){const{background:n="transparent",stroke:r="#000",lineWidth:i=1.5,spacing:o=6,angle:s=45,lineOpacity:a=1}=e,c=Math.max(8,Math.ceil(2*o));return(0,Rn.jsxs)("pattern",{id:t,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[n&&"transparent"!==n&&(0,Rn.jsx)("rect",{width:c,height:c,fill:n}),(0,Rn.jsx)("line",{x1:0,y1:0,x2:0,y2:c,stroke:r,strokeWidth:i,strokeOpacity:a}),(0,Rn.jsx)("line",{x1:o,y1:0,x2:o,y2:c,stroke:r,strokeWidth:i,strokeOpacity:a})]},t)}function Nn(e,t,n="#4e79a7"){if(jn(e)){const n=function(e,t){let n=2166136261;const r=Tn(t);for(let e=0;r.length>e;e++)n^=r.charCodeAt(e),n=Math.imul(n,16777619);return`${e}-hatch-${(n>>>0).toString(36)}`}(t,e);return{fill:`url(#${n})`,def:Dn(e,n)}}return e&&"string"==typeof e?{fill:e}:{fill:n}}var Ln=require("d3-shape");function In(e){switch(e){case"monotoneX":return Ln.curveMonotoneX;case"monotoneY":return Ln.curveMonotoneY;case"cardinal":return Ln.curveCardinal;case"catmullRom":return Ln.curveCatmullRom;case"step":return Ln.curveStep;case"stepBefore":return Ln.curveStepBefore;case"stepAfter":return Ln.curveStepAfter;case"basis":return Ln.curveBasis;case"natural":return Ln.curveNatural;default:return null}}function Wn(e,t,n){if(null==t)return n;if(jn(t)){const r=function(e,t){const n="undefined"!=typeof window&&window.devicePixelRatio||1,r=`${Tn(e)}@${n}`,i=En.get(r);if(void 0!==i)return i;const o=function(e={},t){const{background:n="transparent",stroke:r="#000",lineWidth:i=1.5,spacing:o=6,angle:s=45}=e,a=Math.max(8,Math.ceil(2*o));let c;try{c=function(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):(Pn||(Pn=document.createElement("canvas")),Pn.width=e,Pn.height=e,Pn)}(a)}catch{return null}const l=c.getContext("2d");if(!l)return null;n&&"transparent"!==n?(l.fillStyle=n,l.fillRect(0,0,a,a)):l.clearRect(0,0,a,a),l.strokeStyle=r,l.lineWidth=i,l.lineCap="square";const u=s*Math.PI/180;if(45===s||-45===s){const e=s>0?1:-1;for(let t=-a;2*a>=t;t+=o)l.beginPath(),l.moveTo(t,0),l.lineTo(t+e*a,a),l.stroke()}else{l.save(),l.translate(a/2,a/2),l.rotate(u);const e=2*a;for(let t=-e;e>=t;t+=o)l.beginPath(),l.moveTo(-e,t),l.lineTo(e,t),l.stroke();l.restore()}return(t||l).createPattern(c,"repeat")}({background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle},t);return En.set(r,o),o}(t,e);return r||t.background&&Cn(e,t.background)||n}return"string"!=typeof t?t:Cn(e,t)||n}function $n(e,t,n,r,i,o,s){if("colorStops"in t){const n=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>n.length)return null;const a=e.createLinearGradient(r,i,o,s);for(const e of n)a.addColorStop(e.offset,e.color);return a}const{topOpacity:a,bottomOpacity:c}=t;if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l=Math.max(0,Math.min(1,a)),u=Math.max(0,Math.min(1,c)),h=e.createLinearGradient(r,i,o,s),[d,f,y]=function(e,t){const n=e.fillStyle,r="#010203";try{e.fillStyle=r,e.fillStyle=t}catch{return e.fillStyle=n,[78,121,167]}const i=e.fillStyle;if(e.fillStyle=n,"string"!=typeof i)return[78,121,167];if(i.toLowerCase()===r&&t.trim().toLowerCase()!==r)return[78,121,167];if(i.startsWith("#"))return[parseInt(i.slice(1,3),16),parseInt(i.slice(3,5),16),parseInt(i.slice(5,7),16)];const o=i.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return o?[+o[1],+o[2],+o[3]]:[78,121,167]}(e,n);return h.addColorStop(0,`rgba(${d},${f},${y},${l})`),h.addColorStop(1,`rgba(${d},${f},${y},${u})`),h}function zn(e,t,n,r,i,o){const s=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>s.length)return null;const a=e.createLinearGradient(n,r,i,o);for(const e of s)a.addColorStop(e.offset,e.color);return a}var On=require("d3-shape"),Fn=new WeakMap;function Bn(e,t){const n=In(t);if(!n)return e;const r=Fn.get(e);if(r)return r;const i=function(e,t,n=8){if(!t||2>e.length)return e.map(([e,t])=>[e,t]);const r=[];let i=null;const o={moveTo(e,t){i=[e,t],r.push([e,t])},lineTo(e,t){i=[e,t],r.push([e,t])},bezierCurveTo(e,t,o,s,a,c){if(!i)return i=[a,c],void r.push([a,c]);const[l,u]=i;for(let i=1;n>=i;i++){const h=i/n,d=1-h;r.push([d*d*d*l+3*d*d*h*e+3*d*h*h*o+h*h*h*a,d*d*d*u+3*d*d*h*t+3*d*h*h*s+h*h*h*c])}i=[a,c]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(e,t,n,o){i=[n,o],r.push([n,o])}};return(0,On.line)().x(e=>e[0]).y(e=>e[1]).curve(t).context(o)(e),r}(e,n);return Fn.set(e,i),i}function Yn(e,t,n,r=30,i,o=0){let s=null;if(i){const e=bn(i,t,n,r,o);e&&(s={node:e.node,datum:e.node.datum,x:e.node.x,y:e.node.y,distance:e.distance})}for(const o of e){let e=null;switch(o.type){case"point":if(i)break;e=Xn(o,t,n,r);break;case"symbol":e=qn(o,t,n,r);break;case"glyph":e=Gn(o,t,n,r);break;case"line":e=Vn(o,t,n,r);break;case"rect":if(null==o.datum)break;e=Kn(o,t,n);break;case"heatcell":e=Qn(o,t,n);break;case"area":if(!1===o.interactive)break;e=Jn(o,t,n);break;case"candlestick":e=Zn(o,t,n)}e&&r>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}function Hn(e,t,n){if(0===e.length)return null;if(e[0][0]>t||t>e[e.length-1][0])return null;const r=er(e,t);if(0>r)return null;if(Math.abs(e[r][0]-t)>n)return null;let i=r,o=r;r>0&&e[r][0]>=t?(i=r-1,o=r):e.length-1>r&&(i=r,o=r+1);const[s,a]=e[i],[c,l]=e[o];return c===s?a:a+Math.max(0,Math.min(1,(t-s)/(c-s)))*(l-a)}function Xn(e,t,n,r=30){const i=t-e.x,o=n-e.y,s=Math.sqrt(i*i+o*o);return s>an(e.r,r)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function qn(e,t,n,r=30){const i=t-e.x,o=n-e.y,s=Math.sqrt(i*i+o*o);return s>an(Qe(e.size),r)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function Gn(e,t,n,r=30){if(null==e.datum)return null;const i=xn(e.glyph,e.size),o=e.x+i.centerDx,s=e.y+i.centerDy,a=t-o,c=n-s,l=Math.sqrt(a*a+c*c);return l>an(i.radius,r)?null:{node:e,datum:e.datum,x:o,y:s,distance:l}}function Vn(e,t,n,r=30){if(0===e.path.length)return null;const i=er(e.path,t);if(0>i)return null;const[o,s]=e.path[i];let a;if(e.path.length>1){let r=1/0;const o=Math.max(0,i-1),s=Math.min(e.path.length-2,i);for(let i=o;s>=i;i++){const[o,s]=e.path[i],[a,c]=e.path[i+1],l=Un(t,n,o,s,a,c);r>l&&(r=l)}a=r}else{const e=t-o,r=n-s;a=Math.sqrt(e*e+r*r)}const c=e.style;return a>Math.max(5,(c.strokeWidth??c.lineWidth??1)/2+2,r)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[i]?e.datum[i]:e.datum,x:o,y:s,distance:a}}function Un(e,t,n,r,i,o){const s=i-n,a=o-r,c=s*s+a*a;if(0===c)return Math.sqrt((e-n)**2+(t-r)**2);let l=((e-n)*s+(t-r)*a)/c;return l=Math.max(0,Math.min(1,l)),Math.sqrt((e-(n+l*s))**2+(t-(r+l*a))**2)}function Kn(e,t,n){const r=sn(t,n,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function Qn(e,t,n){const r=sn(t,n,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function Zn(e,t,n){const r=e.bodyWidth/2,i=Math.min(e.openY,e.closeY);if(!(e.x-r-3>t||t>e.x+r+3||e.highY-3>n||n>e.lowY+3)){const r=i+Math.max(Math.max(e.openY,e.closeY)-i,1)/2,o=t-e.x,s=n-r;return{node:e,datum:e.datum,x:e.x,y:r,distance:Math.sqrt(o*o+s*s)}}return null}function Jn(e,t,n){if(0===e.topPath.length)return null;const r=er(e.topPath,t);if(0>r)return null;const[i,o]=e.topPath[r],s=t-i,a=n-o,c=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[r]?e.datum[r]:e.datum,x:i,y:o,distance:c}}function er(e,t){if(0===e.length)return-1;let n=0,r=e.length-1;for(;r>n;){const i=n+r>>1;t>e[i][0]?n=i+1:r=i}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}var tr=require("react"),nr={fresh:1,aging:.7,stale:.45,expired:.25},rr={alpha:1,band:"fresh",isStale:!1};function ir(e,t){if(!e||0>=t)return rr;const n=null!=e.threshold&&e.threshold>0?e.threshold:5e3,r=e.graded;if(r){const e="object"==typeof r?r:{},i=ve(t,n,e.thresholds);return{alpha:{...nr,...e.opacities??{}}[i],band:i,isStale:"fresh"!==i}}return t>n?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:rr}function or(e,t,n,r,i,o){const s=(0,tr.useRef)("fresh");(0,tr.useEffect)(()=>{if(!e)return;const a=setInterval(()=>{const a=t.current;if(!a||0===a.lastIngestTime)return;const c="undefined"!=typeof performance?performance.now():Date.now(),l=ir(e,c-a.lastIngestTime);l.band===s.current&&l.isStale===i||(s.current=l.band,l.isStale!==i&&o(l.isStale),n.current=!0,r())},1e3);return()=>clearInterval(a)},[e,i,r,t,o,n])}var sr=require("react/jsx-runtime");function ar({isStale:e,position:t}){return(0,sr.jsx)("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"})}var cr=require("react"),lr=c(require("react")),ur=require("react/jsx-runtime"),hr={fill:(e,t)=>(0,ur.jsx)("rect",{style:e,width:t,height:t}),line:(e,t)=>(0,ur.jsx)("line",{style:e,x1:0,y1:0,x2:t,y2:t})};function dr(e,t,n,r,i){let o;return o="function"==typeof n?n(e):(0,hr[n])(r(e,t),i),o}function fr({swatchSize:e}){return(0,ur.jsx)("path",{d:`M${.25*e},${.55*e} L${.45*e},${.75*e} L${.8*e},${.3*e}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function yr(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}var pr=(e,t,n,r,i,o,s,a,c,l,u)=>{const{type:h="fill",styleFn:d,items:f}=e,y=[];let p=0;const g=!(!t&&!n),m="isolate"===l||void 0===l&&null!=i,{swatchSize:x,labelGap:v,rowHeight:b}=u;return f.forEach((e,l)=>{const u=dr(e,l,h,d,x),k=yr(e,r,i),w=i&&i.size>0&&i.has(e.label);y.push((0,ur.jsxs)("g",{transform:`translate(0,${p})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:g?a===o&&l===s?0:-1:void 0,role:g?"option":void 0,"aria-selected":g&&m?w||!1:void 0,"aria-current":g&&!m&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:g?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(l+("ArrowDown"===n.key?1:-1)+f.length)%f.length;c(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:g?t=>{c(a,l),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:g?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:g?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[g&&(0,ur.jsx)("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:x+v+2+7*e.label.length,height:x+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),u,w&&(0,ur.jsx)(fr,{swatchSize:x}),(0,ur.jsx)("text",{y:x/2,x:x+v,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+l)),p+=b}),y};function gr({config:e,orientation:t="vertical",width:n=100}){const{colorFn:r,domain:i,label:o,format:s}=e,a=s||(e=>Math.round(100*e)/100+""),c="grad-legend-"+lr.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),s=Math.max(0,(n-t)/2),l=[];for(let e=0;64>=e;e++){const t=e/64;l.push((0,ur.jsx)("stop",{offset:100*t+"%",stopColor:r(i[0]+t*(i[1]-i[0]))},e))}return(0,ur.jsxs)("g",{"aria-label":o||"Gradient legend",children:[(0,ur.jsx)("defs",{children:(0,ur.jsx)("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:l})}),o&&(0,ur.jsx)("text",{x:s+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:o}),(0,ur.jsx)("rect",{x:s,y:0,width:t,height:e,fill:`url(#${c})`,rx:2}),(0,ur.jsx)("text",{x:s,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(i[0])}),(0,ur.jsx)("text",{x:s+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(i[1])})]})}const l=[];for(let e=0;64>=e;e++){const t=e/64;l.push((0,ur.jsx)("stop",{offset:100*t+"%",stopColor:r(i[1]-t*(i[1]-i[0]))},e))}return(0,ur.jsxs)("g",{"aria-label":o||"Gradient legend",children:[o&&(0,ur.jsx)("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:o}),(0,ur.jsx)("defs",{children:(0,ur.jsx)("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:l})}),(0,ur.jsx)("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),(0,ur.jsx)("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(i[1])}),(0,ur.jsx)("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(i[0])})]})}function mr(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:o,legendInteraction:s,title:a="Legend",width:c=100,height:l=20,orientation:u="vertical",legendLayout:h}=e,d=function(e){const t=Math.max(1,e?.swatchSize??16),n=Math.max(t,e?.rowHeight??22);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??6),itemGap:Math.max(0,e?.itemGap??10),rowHeight:n,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}(h),[f,y]=lr.useState(0),[p,g]=lr.useState(0),m=lr.useCallback((e,t)=>{y(e),g(t)},[]),x="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:o,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:c,legendInteraction:l,metrics:u})=>{let h=24;const d=[];return e.forEach((e,f)=>{h+=5,d.push((0,ur.jsx)("line",{stroke:"gray",x1:0,y1:h,x2:t,y2:h},"legend-top-line legend-symbol-"+f)),h+=8,e.label&&(h+=16,d.push((0,ur.jsx)("text",{y:h,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+f)),h+=8),d.push((0,ur.jsx)("g",{className:"legend-item",transform:`translate(0,${h})`,children:pr(e,n,r,i,o,s,a,f,c,l,u)},"legend-group-"+f)),h+=e.items.length*u.rowHeight+8}),d})({legendGroups:t||[],width:c,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:o,focusedGroupIndex:f,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:s,metrics:d}):(({legendGroups:e,height:t,width:n,customClickBehavior:r,customHoverBehavior:i,highlightedCategory:o,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:c,onFocusedIndexChange:l,legendInteraction:u,metrics:h})=>{let d=0;const f=[];e.forEach((e,t)=>{let y=0;e.label&&(y+=16);const p=((e,t,n,r,i,o,s,a,c,l,u,h)=>{const{type:d="fill",styleFn:f,items:y}=e,p=[],{swatchSize:g,labelGap:m,itemGap:x,rowHeight:v,align:b}=u,k=!(!t&&!n),w="isolate"===l||void 0===l&&null!=i,A=y.map(e=>g+m+7*e.label.length),S=[];let _=0,M=0;A.forEach((e,t)=>{const n=0===M?e:M+x+e;h&&h>0&&M>0&&n>h?(S.push({start:_,end:t,width:M}),_=t,M=e):M=n}),y.length>0&&S.push({start:_,end:y.length,width:M}),S.forEach((e,l)=>{let u="center"===b?Math.max(0,((h??e.width)-e.width)/2):"end"===b?Math.max(0,(h??e.width)-e.width):0;for(let h=e.start;e.end>h;h++){const e=y[h],b=dr(e,h,d,f,g),S=yr(e,r,i),_=i&&i.size>0&&i.has(e.label);p.push((0,ur.jsxs)("g",{transform:`translate(${u},${l*v})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:k?a===o&&h===s?0:-1:void 0,role:k?"option":void 0,"aria-selected":k&&w?_||!1:void 0,"aria-current":k&&!w&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:k?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(h+("ArrowRight"===n.key?1:-1)+y.length)%y.length;c(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:k?t=>{c(a,h),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:k?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:k?"pointer":"default",opacity:S,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[k&&(0,ur.jsx)("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:g+m+2+7*e.label.length,height:g+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),b,_&&(0,ur.jsx)(fr,{swatchSize:g}),(0,ur.jsx)("text",{y:g/2,x:g+m,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+h)),u+=A[h]+x}});const C=Math.max(0,...S.map(e=>e.width)),P=S.length;return{items:p,offset:C,totalRows:P,totalHeight:P*v}})(e,r,i,o,s,a,c,t,l,u,h,h.maxWidth??n);y+=p.offset+5,f.push({label:e.label,...p,offset:y,totalRows:p.totalRows,totalHeight:p.totalHeight}),d+=y+12});const y=h.maxWidth??n;let p=d>y?0:"center"===h.align?Math.max(0,(y-d)/2):"end"===h.align?Math.max(0,y-d):0;const g=[];return f.forEach((n,r)=>{const i=e[r];i.label&&(g.push((0,ur.jsx)("text",{transform:`translate(${p},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:i.label},"legend-text-"+r)),p+=16),g.push((0,ur.jsx)("g",{className:"legend-item",transform:`translate(${p},0)`,children:n.items},"legend-group-"+r)),p+=n.offset+5,e[r+1]&&g.push((0,ur.jsx)("line",{stroke:"gray",x1:p,y1:-8,x2:p,y2:(n.totalHeight||t)+0+8},"legend-top-line legend-symbol-"+r)),p+=12}),(0,ur.jsx)("g",{children:g})})({legendGroups:t||[],title:a,height:l,width:c,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:o,focusedGroupIndex:f,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:s,metrics:d}),v=!(!n&&!r);return(0,ur.jsxs)("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==s&&(void 0!==s||null==o))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==a&&""!==a&&"vertical"===u&&(0,ur.jsx)("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:a}),x]})}function xr(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}var vr=require("react/jsx-runtime");function br(e){const{legend:t,totalWidth:n,totalHeight:r,margin:i,legendPosition:o="right",legendLayout:s,title:a,legendHoverBehavior:c,legendClickBehavior:l,legendHighlightedCategory:u,legendIsolatedCategories:h,legendInteraction:d}=e;if(!t)return null;const f="top"===o||"bottom"===o,y=!!a,p=Math.max(0,n-i.left-i.right),g=Math.max(1,f?s?.maxWidth??p:100);let m,x;return"left"===o?(m=Math.max(4,i.left-g-10),x=i.top):"top"===o?(m=i.left,x=y?32:8):"bottom"===o?(m=i.left,x=r-i.bottom+38):(m=n-i.right+10,x=i.top),(0,vr.jsx)("g",{transform:`translate(${m}, ${x})`,children:(v=t,"object"==typeof v&&null!==v&&"gradient"in v?(0,vr.jsx)(gr,{config:t.gradient,orientation:f?"horizontal":"vertical",width:g}):xr(t)?(0,vr.jsx)(mr,{legendGroups:t.legendGroups,title:"",width:g,orientation:f?"horizontal":"vertical",legendLayout:s,customHoverBehavior:c,customClickBehavior:l,highlightedCategory:u,isolatedCategories:h,legendInteraction:d}):t)});var v}var kr=require("react"),wr=require("d3-array");function Ar(e){let t=1/0,n=-1/0;for(const r of e)t>r&&(t=r),r>n&&(n=r);return[t,n]}var Sr=require("react/jsx-runtime");function _r(e){return"string"==typeof e?{type:e}:e}function Mr({orient:e,config:t,values:n,scale:r,size:i,length:o}){const s=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,c=(0,kr.useMemo)(()=>{if(0===n.length)return null;const t=r.domain(),c=i-8;if("boxplot"===s.type){const t=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const r=t[Math.floor(.25*n)],i=t[Math.floor(.5*n)],o=t[Math.floor(.75*n)],s=o-r;return{q1:r,median:i,q3:o,whiskerLow:Math.max(t[0],r-1.5*s),whiskerHigh:Math.min(t[n-1],o+1.5*s)}}(n);if(!t)return null;const{q1:i,median:o,q3:l,whiskerLow:u,whiskerHigh:h}=t,d=Math.min(.5*c,20),f=(c-d)/2+4;if(a){const t=r(i),n=r(l),a=r(o),c=r(u),y=r(h),p="top"===e?-1:1,g=0;return(0,Sr.jsxs)("g",{"data-testid":"marginal-boxplot-"+e,children:[(0,Sr.jsx)("line",{x1:c,y1:g+p*(f+d/2),x2:y,y2:g+p*(f+d/2),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,Sr.jsx)("line",{x1:c,y1:g+p*f,x2:c,y2:g+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,Sr.jsx)("line",{x1:y,y1:g+p*f,x2:y,y2:g+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,Sr.jsx)("rect",{x:Math.min(t,n),y:"top"===e?g-f-d:g+f,width:Math.abs(n-t),height:d,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),(0,Sr.jsx)("line",{x1:a,y1:"top"===e?g-f-d:g+f,x2:a,y2:"top"===e?g-f:g+f+d,stroke:s.fill,strokeWidth:2})]})}{const t=r(i),n=r(l),a=r(o),c=r(u),y=r(h),p="left"===e?-1:1,g=0;return(0,Sr.jsxs)("g",{"data-testid":"marginal-boxplot-"+e,children:[(0,Sr.jsx)("line",{x1:g+p*(f+d/2),y1:c,x2:g+p*(f+d/2),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,Sr.jsx)("line",{x1:g+p*f,y1:c,x2:g+p*(f+d),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,Sr.jsx)("line",{x1:g+p*f,y1:y,x2:g+p*(f+d),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,Sr.jsx)("rect",{x:"left"===e?g-f-d:g+f,y:Math.min(t,n),width:d,height:Math.abs(n-t),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),(0,Sr.jsx)("line",{x1:"left"===e?g-f-d:g+f,y1:a,x2:"left"===e?g-f:g+f+d,y2:a,stroke:s.fill,strokeWidth:2})]})}}const l=(0,wr.bin)().domain(t).thresholds(s.bins)(n);if(0===l.length)return null;const u=function(e,t=-1/0){let n=t;for(const t of e)t>n&&(n=t);return n}(l.map(e=>e.length));if(0===u)return null;if("histogram"===s.type)return(0,Sr.jsx)("g",{"data-testid":"marginal-histogram-"+e,children:l.map((t,n)=>{if(null==t.x0||null==t.x1)return null;const i=t.length/u*c;if(a){const o=r(t.x0),a=r(t.x1)-r(t.x0);return(0,Sr.jsx)("rect",{x:o,y:"top"===e?-4-i:4,width:Math.max(a,.5),height:i,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}{const o=r(t.x0),a=r(t.x1)-r(t.x0);return(0,Sr.jsx)("rect",{x:"left"===e?-4-i:4,y:Math.min(o,o+a),width:i,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}})});if("violin"===s.type){const t=c/2+4,n=[];for(const i of l){if(null==i.x0||null==i.x1)continue;const o=i.length/u*(c/2),s=r((i.x0+i.x1)/2);n.push(a?`${s},${"top"===e?-(t-o):t-o}`:`${"left"===e?-(t-o):t-o},${s}`)}for(let i=l.length-1;i>=0;i--){const o=l[i];if(null==o.x0||null==o.x1)continue;const s=o.length/u*(c/2),h=r((o.x0+o.x1)/2);n.push(a?`${h},${"top"===e?-(t+s):t+s}`:`${"left"===e?-(t+s):t+s},${h}`)}return(0,Sr.jsx)("g",{"data-testid":"marginal-violin-"+e,children:(0,Sr.jsx)("polygon",{points:n.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}if("ridgeline"===s.type){const t=[];if(a){const n=0,i=null!=l[0].x0?r(l[0].x0):0;t.push(`M${i},${n}`);for(const n of l){if(null==n.x0||null==n.x1)continue;const i=n.length/u*c,o=r((n.x0+n.x1)/2);t.push(`L${o},${"top"===e?-i-4:i+4}`)}const s=null!=l[l.length-1].x1?r(l[l.length-1].x1):o;t.push(`L${s},${n}`),t.push("Z")}else{const n=0,i=null!=l[0].x0?r(l[0].x0):0;t.push(`M${n},${i}`);for(const n of l){if(null==n.x0||null==n.x1)continue;const i=n.length/u*c,o=r((n.x0+n.x1)/2);t.push(`L${"left"===e?-i-4:i+4},${o}`)}const s=null!=l[l.length-1].x1?r(l[l.length-1].x1):o;t.push(`L${n},${s}`),t.push("Z")}return(0,Sr.jsx)("g",{"data-testid":"marginal-ridgeline-"+e,children:(0,Sr.jsx)("path",{d:t.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}return null},[n,r,s,i,o,e,a,4]);return c?(0,Sr.jsx)("g",{className:"marginal-"+e,"data-testid":"marginal-"+e,children:c}):null}var Cr=c(require("react")),Pr=require("react/jsx-runtime");function Rr(e,t=120,n=8){if(!e)return[];const r=Math.max(1,Math.floor(t/n)),i=e.split(/\s+/),o=[];let s="";for(const e of i)s&&s.length+1+e.length>r?(o.push(s),s=e):s=s?`${s} ${e}`:e;return s&&o.push(s),o}function jr(e,t,n,r){return"curly"===e?r?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:r?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function Tr(e,t,n,r){if(!e)return(0,Pr.jsx)("g",{className:"annotation-note"});const{label:i,title:o,orientation:s,align:a,wrap:c=120,noWrap:l}=e;if(!i&&!o)return(0,Pr.jsx)("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let h=a;h&&"dynamic"!==h||(h="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let d="start";"topBottom"===u?"right"===h?d="end":"middle"===h&&(d="middle"):d=0>t?"end":"start";const f=16,y=o?l?[o]:Rr(o,c):[],p=i?l?[i]:Rr(i,c):[],g="leftRight"===u?"end"===d?-4:4:0;let m=0;const x=[],v=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";e.useHTML||e.html?x.push((0,Pr.jsx)("foreignObject",{className:"annotation-note-html",x:"end"===d?g-c:"middle"===d?g-c/2:g,y:-16,width:c,height:Math.max(f,(y.length+p.length)*f+(o&&i?2:0))+f,style:{overflow:"visible"},children:(0,Pr.jsxs)("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:v,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===d?"right":"middle"===d?"center":"left",whiteSpace:l?"nowrap":"normal",wordBreak:"break-word"},children:[o&&(0,Pr.jsx)("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:o}),i&&(0,Pr.jsx)("div",{className:"annotation-note-label",children:i})]})},"annotation-note-html")):(y.length>0&&(x.push((0,Pr.jsx)("text",{className:"annotation-note-title",fill:v,textAnchor:d,fontWeight:"bold",children:y.map((e,t)=>(0,Pr.jsx)("tspan",{x:g,dy:0===t?0:f,children:e},t))},"annotation-note-title")),m=y.length*f),p.length>0&&x.push((0,Pr.jsx)("text",{className:"annotation-note-label",fill:v,textAnchor:d,y:m,children:p.map((e,t)=>(0,Pr.jsx)("tspan",{x:g,dy:0===t?0:f,children:e},t))},"annotation-note-label")));let b=null;if((o||i)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(c,120);let t=0,n=e;"end"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),b=(0,Pr.jsx)("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(y.length+p.length)*f+(p.length>0?f:0);let t=0,n=e;"bottom"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),b=(0,Pr.jsx)("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const k=Math.max(0,y.length+p.length-1)*f;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===h?-(k+f+(p.length>0&&y.length>0?2:0))/2+8:"bottom"===h||0>n?-(k+2):18),(0,Pr.jsxs)("g",{className:"annotation-note",transform:`translate(${t},${n})`,children:[(0,Pr.jsx)("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0,children:x}),b]})}function Er(e,t,n,r,i){const o=[];switch(e){case"callout-circle":{const e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&o.push((0,Pr.jsx)("circle",{r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=t?.width||0,r=t?.height||0;(e>0||r>0)&&o.push((0,Pr.jsx)("rect",{width:e,height:r,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":t?.custom&&o.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=r||0,s=i||0;if(void 0!==t?.x){const r=(t.x||0)-e;o.push((0,Pr.jsx)("line",{x1:r,y1:(t.y1||0)-s,x2:r,y2:(t.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==t?.y){const r=(t.y||0)-s;o.push((0,Pr.jsx)("line",{x1:(t.x1||0)-e,y1:r,x2:(t.x2||0)-e,y2:r,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==t?.x1||void 0!==t?.x2?o.push((0,Pr.jsx)("line",{x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===t?.y1&&void 0===t?.y2||o.push((0,Pr.jsx)("line",{x1:0,y1:(t.y1||0)-s,x2:0,y2:(t.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=t?.type||"curly",r=t?.width??t?.height;void 0!==r&&o.push((0,Pr.jsx)("path",{d:jr(e,r,t?.depth||30,void 0===t?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return(0,Pr.jsx)("g",{className:"annotation-subject",children:o})}function Dr(e,t,n,r,i,o){const s=[];let a=0,c=0;if("callout-circle"!==i&&"label"!==i||!o?.radius){if("callout-rect"===i&&o){const n=o.width||0,r=o.height||0;if(n>0||r>0){const i=n/2,o=r/2,s=e-i,l=t-o;if(0!==s||0!==l){const e=Math.abs(s),t=Math.abs(l),u=n/2,h=r/2,d=e*h>t*u?u/e:h/t;a=i+s*d,c=o+l*d}}}else if("bracket"===i&&o){const e=o.width,t=o.height,n=o.depth||30;void 0!==e?(a=e/2,c=n):void 0!==t&&(a=n,c=t/2)}}else{const n=(o.radius||0)+(o.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const r=Math.atan2(t,e);a=Math.cos(r)*n,c=Math.sin(r)*n}}const l=Math.sqrt((e-a)**2+(t-c)**2);if(l>.5){const i=r||"var(--semiotic-text-secondary, currentColor)",o="curve"===n?.type;let u=Math.atan2(t-c,e-a);if(o){const r=(a+e)/2,o=(c+t)/2,h=-(t-c)/l,d=(e-a)/l,f=(n?.curve??.25)*l,y=r+h*f,p=o+d*f;s.push((0,Pr.jsx)("path",{className:"connector-curve",d:`M${a},${c}Q${y},${p} ${e},${t}`,fill:"none",stroke:i},"connector-line")),u=Math.atan2(p-c,y-a)}else s.push((0,Pr.jsx)("line",{x1:a,y1:c,x2:e,y2:t,stroke:i},"connector-line"));if("arrow"===n?.end){const e=10,t=16/180*Math.PI;s.push((0,Pr.jsx)("path",{d:`M${a},${c}L${a+e*Math.cos(u+t)},${c+e*Math.sin(u+t)}L${a+e*Math.cos(u-t)},${c+e*Math.sin(u-t)}Z`,fill:i,stroke:"none"},"connector-arrow"))}}return(0,Pr.jsx)("g",{className:"annotation-connector",children:s})}function Nr(e){const{x:t=0,y:n=0,dx:r,dy:i,nx:o,ny:s,note:a,connector:c,subject:l,type:u,color:h,className:d,disable:f,opacity:y,strokeDasharray:p,events:g={},"data-testid":m}=e,x=Array.isArray(t)?t[0]??0:t,v=Array.isArray(n)?n[0]??0:n,b=new Set(Array.isArray(f)?f:[]);let k=r||0,w=i||0;null!=o&&(k=o-x),null!=s&&(w=s-v);const A="string"==typeof u?u:"label";if("bracket"===A&&l&&0===k&&0===w)if(void 0!==l.width){k=l.width/2;const e=l.depth||30;w=e+(0>e?-5:5)}else if(void 0!==l.height){const e=l.depth||30;k=e+(0>e?-5:5),w=l.height/2}return(0,Pr.jsxs)("g",{className:("annotation "+(d||"")).trim(),transform:`translate(${x},${v})`,"data-testid":m,...null!=y&&{opacity:y},...p&&{strokeDasharray:p},...g,children:[!b.has("connector")&&Dr(k,w,c,h,A,l),!b.has("subject")&&Er(A,l,h,x,v),!b.has("note")&&Tr(a,k,w,h)]})}function Lr(e){const{noteData:t}=e,{screenCoordinates:n}=t,r="string"==typeof t.type?t.type:"label",i=t.eventListeners||t.events||{};if(t.coordinates&&n){const e=t.nx||n[0][0]+(t.dx??0),i=t.ny||n[0][1]+(t.dy??0),o=n.map((n,o)=>{const s=Object.assign({},t,{note:0===o?t.note:{label:""},x:n[0],y:n[1],nx:e,ny:i});return(0,Pr.jsx)(Nr,{"data-testid":"semiotic-annotation",...s,type:r},"multi-annotation-"+o)});return(0,Pr.jsx)("g",{children:o})}const o=t.note||{title:"none",label:t.label},s=`${o.label}-${o.title}-${t.i}`;return(0,Pr.jsx)(Nr,{"data-testid":"semiotic-annotation",events:i,...t,type:r},s)}var Ir=require("d3-hierarchy"),Wr=require("d3-shape");function $r(e){return Math.round(100*e)/100}function zr(e,t=2){const n=[],r=[],i=t+1;for(let t=0;i>t;t++){let o=0;for(const[n,r]of e)null!==r&&(o+=n**t*r);n.push(o);const s=[];for(let n=0;i>n;n++){let r=0;for(const[i,o]of e)null!==o&&(r+=i**(t+n));s.push(r)}r.push(s)}r.push(n);const o=function(e,t){const n=e,r=e.length-1,i=[t];for(let e=0;r>e;e++){let t=e;for(let i=e+1;r>i;i++)Math.abs(n[e][i])>Math.abs(n[e][t])&&(t=i);for(let i=e;r+1>i;i++){const r=n[i][e];n[i][e]=n[i][t],n[i][t]=r}for(let t=e+1;r>t;t++)for(let i=r;i>=e;i--)n[i][t]-=n[i][e]*n[e][t]/n[e][e]}for(let e=r-1;e>=0;e--){let t=0;for(let o=e+1;r>o;o++)t+=n[o][e]*i[o];i[e]=(n[r][e]-t)/n[e][e]}return i}(r,i).map($r);return{points:e.map(([e])=>[$r(e),$r(o.reduce((t,n,r)=>t+n*e**r,0))]),equation:[...o].reverse()}}function Or(e,t){const n=t.scales?.x??t.scales?.time;return n?null!=e.x?n(e.x):t.xAccessor&&null!=e[t.xAccessor]?n(e[t.xAccessor]):null:null}function Fr(e,t){const n=t.scales?.y??t.scales?.value;return n?null!=e.y?n(e.y):t.yAccessor&&null!=e[t.yAccessor]?n(e[t.yAccessor]):null:null}function Br(e){return null==e?null:e+""}function Yr(e,t,n){return t.stickyPositionCache?.set(e,n),n}function Hr(e,t,n){const r=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===r){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const i=n.pointNodes[r];if(i.pointId===e.pointId)return Yr(t,n,{x:i.x,y:i.y})}const r=function(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],r=e.scales?.x??e.scales?.time,i=e.scales?.y??e.scales?.value;if(!r||!i)return null;const o=n[e.xAccessor||"x"],s=n[e.yAccessor||"y"];return null==o||null==s?null:{x:r(o),y:i(s)}}(n);return r?Yr(t,n,r):null}if("semantic"===r){const r=function(e,t,n){const r=function(e){return Br(e.provenance?.stableId??e.stableId)}(e);if(!r)return null;const i=n.pointNodes?.find(e=>Br(e.pointId)===r);if(i)return Yr(t,n,{x:i.x,y:i.y});const o=n.data?.find(e=>function(e){return Br(e.stableId??e.id??e.provenance?.stableId)}(e)===r);if(!o)return null;const s=Or(o,n),a=Fr(o,n);return null==s||null==a?null:Yr(t,n,{x:s,y:a})}(e,t,n);if(r)return r}let i=null,o=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(i=t.x,o=t.y)}if(null!=i&&null!=o||(i=Or(e,n),o=Fr(e,n)),null!=i&&null!=o)return Yr(t,n,{x:i,y:o});if("sticky"===r){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function Xr(e,t,n,r=50){return!(-r>e||e>(n.width||0)+r||-r>t||t>(n.height||0)+r)}var qr=require("react/jsx-runtime"),Gr={secondary:0,primary:3},Vr=".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}";function Ur(e){return!0===e?._annotationDeferred}function Kr(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function Qr(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function Zr(e){return Math.max(.72,.95-.06*e)}var Jr=c(require("react")),[ei,ti]=M(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function ni(e){const t=ti(e=>e.pushObservation),n=Jr.useCallback(n=>{e.onObservation?.(n),t?.(n)},[e,t]);return Jr.useMemo(()=>({...e,onObservation:n}),[n,e])}function ri(e,t={}){const n=function(e){const t=e.provenance,n=e.id??e.stableId??t?.stableId;return null==n||""===n?void 0:n+""}(e);return{"data-semiotic-annotation-widget":"",...n?{"data-semiotic-annotation-id":n}:{},onClickCapture(r){const i=function(e){const t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}(r);t.onAnnotationActivate?.({annotation:e,annotationId:n,chartId:t.chartId,inputType:i}),n&&t.onObservation&&t.onObservation({type:"annotation-activate",annotationId:n,inputType:i,timestamp:Date.now(),chartType:t.chartType??"unknown",chartId:t.chartId})}}}function ii(e){return e instanceof Element&&null!=e.closest("[data-semiotic-annotation-widget]")}var oi=require("react/jsx-runtime"),si="var(--semiotic-bg, #ffffff)";function ai(e){const{x:t,y:n,text:r,fill:i,fontSize:o=12,fontWeight:s,fontFamily:a,textAnchor:c="start",dominantBaseline:l,background:u,className:h}=e,d=function(e){return void 0===e||!0===e||"halo"===e?{type:"halo"}:!1===e||"none"===e?null:"box"===e?{type:"box"}:{type:e.type??"halo",...e}}(u),f=e=>(0,oi.jsx)("text",{x:t,y:n,textAnchor:c,dominantBaseline:l,fill:i,fontSize:o,fontWeight:s,fontFamily:a,className:h,...e?{stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:"stroke"}:{},children:r});if(!d)return f();if("halo"===d.type)return f({stroke:d.fill??si,strokeWidth:d.haloWidth??3});const y=d.padding??{x:6,y:3},p="number"==typeof y?y:y.x,g="number"==typeof y?y:y.y,m=function(e,t){return(e+"").length*t*.6}(r,o),x=o+2*g;let v,b;return v="middle"===c?t-m/2-p:"end"===c?t-m-p:t-p,b="middle"===l||"central"===l?n-x/2:"hanging"===l||"text-before-edge"===l?n-g:n-.8*o-g,(0,oi.jsxs)("g",{className:h,children:[(0,oi.jsx)("rect",{x:v,y:b,width:m+2*p,height:x,rx:d.radius??3,ry:d.radius??3,fill:d.fill??si,fillOpacity:d.opacity??.85,stroke:d.stroke,strokeWidth:d.strokeWidth}),f()]})}var ci=require("react/jsx-runtime"),li={linear:Wr.curveLinear,monotoneX:Wr.curveMonotoneX,monotoneY:Wr.curveMonotoneY,step:Wr.curveStep,stepAfter:Wr.curveStepAfter,stepBefore:Wr.curveStepBefore,basis:Wr.curveBasis,cardinal:Wr.curveCardinal,catmullRom:Wr.curveCatmullRom};function ui(e,t,n,r){const i=[];return e.forEach((e,o)=>{let s;if(n){const i=n(e,o,r);s=null!=i?i:t(e,o,r)}else s=t(e,o,r);s&&i.push({node:s,annotation:e})}),function(e){const t=e.map((e,t)=>{return{p:e,i:t,emphasis:(n=e.annotation,"primary"===n?.emphasis||"secondary"===n?.emphasis?n.emphasis:null),confidence:Qr(e.annotation),readingOrder:null,rank:1};var n}),n=t.some(e=>null!=e.emphasis||null!=e.confidence),r=e.some(e=>Ur(e.annotation)),i=e.some(e=>null!=Kr(e.annotation)),o=e.some(e=>"layer"===Kr(e.annotation));if(!n&&!r&&!i)return e.map(e=>e.node);const s=t.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>(t.confidence??0)-(e.confidence??0)||e.i-t.i);s.forEach((e,t)=>{e.readingOrder=t,e.rank=2-t/Math.max(1,s.length)});for(const e of t)e.emphasis&&(e.rank=Gr[e.emphasis]);const a=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{const{p:t,i:n,emphasis:r,readingOrder:i}=e,o=Ur(t.annotation);let s=t.node;if("primary"===r||"secondary"===r||null!=i){const e=null==r&&null!=i;s=(0,qr.jsx)("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r,..."secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},...e?{opacity:Zr(i),"data-annotation-reading-order":i}:{},children:t.node},"annotation-emphasis-"+n)}const a=Kr(t.annotation);return a&&(s=(0,qr.jsx)("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+n)),o&&(s=(0,qr.jsx)("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+n)),s});return r&&a.unshift((0,qr.jsx)("style",{children:Vr},"annotation-disclosure-style")),o&&a.unshift((0,qr.jsx)("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),a}(i)}function hi(e,t={}){return function(e,n,r){switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const t=Hr(e,n,r);if(!t)return null;const{x:i,y:o}=t;if(!Xr(i,o,r))return null;const s="callout"===e.type?"callout-circle":e.type,a="callout-circle"===s?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===s?{width:e.width,height:e.height}:void 0;return(0,ci.jsx)(Lr,{noteData:{x:i,y:o,dx:e.dx??30,dy:e.dy??-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:s,...a?{subject:a}:{},connector:e.connector||{end:"arrow"},color:e.color,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-"+n)}case"x-threshold":{const t=Or(null!=e.value?{...e,x:e.value}:e,r);if(null==t)return null;const i=e.color||"#f97316",o=e.labelPosition||"top";let s;s="bottom"===o?(r.height||0)-4:"center"===o?(r.height||0)/2:16;const a=t>.6*(r.width||0),c=a?t-4:t+4,l=a?"end":"start";return(0,ci.jsxs)("g",{opacity:e.opacity,children:[(0,ci.jsx)("line",{x1:t,y1:0,x2:t,y2:r.height||0,stroke:i,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,ci.jsx)(ai,{x:c,y:s,text:e.label,textAnchor:l,fill:i,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"y-threshold":{const t=Fr(null!=e.value?{...e,y:e.value}:e,r);if(null==t)return null;const i=e.color||"#f97316",o=e.labelPosition||"right";let a,c;"left"===o?(a=4,c="start"):"center"===o?(a=(r.width||0)/2,c="middle"):(a=(r.width||0)-4,c="end");const l=20>(s=t)?Math.min((r.height||0)-4,s+16):s-4;return(0,ci.jsxs)("g",{opacity:e.opacity,children:[(0,ci.jsx)("line",{x1:0,y1:t,x2:r.width||0,y2:t,stroke:i,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,ci.jsx)(ai,{x:a,y:l,text:e.label,textAnchor:c,fill:i,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"enclose":{const t=(e.coordinates||[]).map(e=>({x:Or({...e,type:"point"},r),y:Fr({...e,type:"point"},r),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const i=(0,Ir.packEnclose)(t),o=e.padding||10;return(0,ci.jsxs)("g",{children:[(0,ci.jsx)("circle",{cx:i.x,cy:i.y,r:i.r+o,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&(0,ci.jsx)(ai,{x:i.x,y:i.y-i.r-o-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"rect-enclose":{const t=(e.coordinates||[]).map(e=>({x:Or({...e,type:"point"},r),y:Fr({...e,type:"point"},r)})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const i=e.padding||10,o=t.map(e=>e.x),s=t.map(e=>e.y),[a,c]=Ar(o),[l,u]=Ar(s),h=a-i,d=c+i,f=l-i;return(0,ci.jsxs)("g",{children:[(0,ci.jsx)("rect",{x:h,y:f,width:d-h,height:u+i-f,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&(0,ci.jsx)(ai,{x:(h+d)/2,y:f-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"highlight":{const t=r.data||[],i="function"==typeof e.filter?t.filter(e.filter):e.field&&null!=e.value?t.filter(t=>t[e.field]===e.value):[],o={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return(0,ci.jsx)("g",{children:i.map((t,n)=>{const i=Or(t,r),s=Fr(t,r);if(null==i||null==s)return null;const a="function"==typeof e.r?e.r(t):e.r||6,c="function"==typeof e.style?e.style(t):e.style||o;return(0,ci.jsx)("circle",{cx:i,cy:s,r:a,...c},"hl-"+n)})},"ann-"+n)}case"bracket":{const t=Or(e,r),i=Fr(e,r);return(0,ci.jsx)(Lr,{noteData:{x:t??0,y:i??0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+n)}case"trend":{const t=r.data||[];if(2>t.length)return null;const i=r.xAccessor||"x",o=r.yAccessor||"y",s="ordinal"===r.frameType,a="horizontal"===r.projection,c=s?i:null,l=s?o:null;let u;const h=[],d=new Map;if(s&&c&&l){for(const e of t){const t=e[c];if(null==t)continue;const n=t+"";d.has(n)||(d.set(n,h.length),h.push(n))}u=t.map(e=>{const t=e[c],n=e[l];if(null==t||null==n)return null;const r=d.get(t+"");return null!=r?[r,+n]:null}).filter(e=>null!==e)}else u=t.map(e=>[e[i],e[o]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>u.length)return null;const f=r.scales?.x??r.scales?.time,y=r.scales?.y??r.scales?.value;if(!f||!y)return null;const p=e=>t=>{const n=Math.max(0,Math.floor(t)),r=Math.min(h.length-1,n+1),i=t-n,o=e(h[n]);return o+(e(h[r])-o)*i},g=f,m=y;let x;if(s)if(a){const e=p(m);x=(t,n)=>[g(n),e(t)]}else{const e=p(g);x=(t,n)=>[e(t),m(n)]}else x=(e,t)=>[g(e),m(t)];const v=e.method||"linear";let b;if("loess"===v)b=function(e,t=.3){const n=e.length;if(2>n)return e.slice();const r=e.slice().sort((e,t)=>e[0]-t[0]),i=r.map(e=>e[0]),o=r.map(e=>e[1]),s=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=i[e],r=i.map(e=>Math.abs(e-t)),c=r.slice().sort((e,t)=>e-t)[Math.min(s-1,n-1)]||1,l=[];for(let e=0;n>e;e++){const t=0===c?0:r[e]/c;l[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,h=0,d=0,f=0,y=0;for(let e=0;n>e;e++){const t=l[e];0!==t&&(u+=t,h+=t*i[e],d+=t*o[e],f+=t*i[e]*i[e],y+=t*i[e]*o[e])}if(0===u){a.push([t,o[e]]);continue}const p=u*f-h*h;if(1e-12>Math.abs(p))a.push([t,d/u]);else{const e=(u*y-h*d)/p;a.push([t,(d-e*h)/u+e*t])}}return a}(u,e.bandwidth??.3);else{const t="polynomial"===v?zr(u,e.order||2):function(e){const t=[0,0,0,0];let n=0;for(const[r,i]of e)null!==i&&(n++,t[0]+=r,t[1]+=i,t[2]+=r*r,t[3]+=r*i);const r=n*t[2]-t[0]*t[0],i=0===r?0:$r((n*t[3]-t[0]*t[1])/r),o=$r(t[1]/n-i*t[0]/n);return{points:e.map(([e])=>[$r(e),$r(i*e+o)]),equation:[i,o]}}(u);b=t.points}const k=b.map(([e,t])=>{const[n,r]=x(e,t);return`${n},${r}`}).join(" "),w=e.color||"#6366f1",A=b[b.length-1],[S,_]=x(A[0],A[1]);return(0,ci.jsxs)("g",{children:[(0,ci.jsx)("polyline",{points:k,fill:"none",stroke:w,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,ci.jsx)("text",{x:S+4,y:_-4,fill:w,fontSize:11,children:e.label})]},"ann-"+n)}case"band":{const t=r.scales?.y??r.scales?.value,s=t?.(e.y0)??0,a=t?.(e.y1)??(r.height||0),c=Nn(e.fill,"ann-"+n,"var(--semiotic-primary, #6366f1)");return(0,ci.jsxs)("g",{opacity:e.opacity,children:[c.def&&(0,ci.jsx)("defs",{children:c.def}),(0,ci.jsx)("rect",{x:0,y:Math.min(s,a),width:r.width||0,height:Math.abs(a-s),fill:c.fill,fillOpacity:e.fillOpacity||.1}),e.label&&(0,ci.jsx)(ai,{x:(r.width||0)-4,y:(i=s,o=a,Math.max(Math.min(i,o),0)+16),textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"x-band":{const t=r.scales?.x??r.scales?.time,i=null!=e.x0&&t?t(e.x0):null,o=null!=e.x1&&t?t(e.x1):null;if(null==i||null==o)return null;const s=Nn(e.fill||e.color,"ann-"+n,"var(--semiotic-primary, #6366f1)");return(0,ci.jsxs)("g",{opacity:e.opacity,children:[s.def&&(0,ci.jsx)("defs",{children:s.def}),(0,ci.jsx)("rect",{x:Math.min(i,o),y:0,width:Math.abs(o-i),height:r.height||0,fill:s.fill,fillOpacity:e.fillOpacity??.1}),e.label&&(0,ci.jsx)(ai,{x:Math.min(i,o)+4,y:16,textAnchor:"start",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"envelope":{const t=r.data||[];if(2>t.length)return null;const i=r.xAccessor||"x",o=r.scales?.x??r.scales?.time,s=r.scales?.y??r.scales?.value;if(!o||!s)return null;const a=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",l=e.filter,u=t.filter(e=>null!=e[a]&&null!=e[c]&&!(l&&!l(e))).sort((e,t)=>e[i]-t[i]);if(2>u.length)return null;const h=li[r.curve||"linear"]||Wr.curveLinear,d=(0,Wr.area)().x(e=>o(e[i])).y0(e=>s(e[c])).y1(e=>s(e[a])).curve(h)(u);if(!d)return null;const f=e.fill||"#6366f1";return(0,ci.jsxs)("g",{children:[(0,ci.jsx)("path",{d:d,fill:f,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&u.length>0&&(0,ci.jsx)("text",{x:o(u[u.length-1][i])+4,y:s(u[u.length-1][a])-4,fill:f,fontSize:11,children:e.label})]},"ann-"+n)}case"anomaly-band":{const t=r.data||[];if(2>t.length)return null;const i=r.yAccessor||"y",o=r.scales?.x??r.scales?.time,s=r.scales?.y??r.scales?.value;if(!o||!s)return null;const a=t.map(e=>e[i]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const c=a.reduce((e,t)=>e+t,0)/a.length,l=a.reduce((e,t)=>e+(t-c)**2,0)/a.length,u=Math.sqrt(l),h=e.threshold??2,d=c-h*u,f=!1!==e.showBand,y=e.fill||"#6366f1",p=e.fillOpacity??.1,g=e.anomalyColor||"#ef4444",m=e.anomalyRadius??6,x=s(c+h*u),v=s(d),b=t.filter(e=>{const t=e[i];return null!=t&&Math.abs(t-c)>h*u});return(0,ci.jsxs)("g",{children:[f&&(0,ci.jsx)("rect",{x:0,y:Math.min(x,v),width:r.width||0,height:Math.abs(v-x),fill:y,fillOpacity:p}),b.map((e,t)=>{const n=Or(e,r),i=Fr(e,r);return null==n||null==i?null:(0,ci.jsx)("circle",{cx:n,cy:i,r:m,fill:g,fillOpacity:.7,stroke:g,strokeWidth:1.5},"anomaly-"+t)}),e.label&&(0,ci.jsx)("text",{x:(r.width||0)-4,y:Math.min(x,v)-4,textAnchor:"end",fill:y,fontSize:11,children:e.label})]},"ann-"+n)}case"forecast":{const t=r.data||[];if(3>t.length)return null;const i=r.xAccessor||"x",o=r.yAccessor||"y",s=r.scales?.x??r.scales?.time,a=r.scales?.y??r.scales?.value;if(!s||!a)return null;const c=t.map(e=>[e[i],e[o]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let l;if("polynomial"===(e.method||"linear")){const t=zr(c,e.order||2).equation;l=e=>t.reduce((t,n,r)=>t+n*Math.pow(e,r),0)}else{const e=c.length;let t=0,n=0,r=0,i=0;for(const[e,o]of c)t+=e,n+=o,r+=e*e,i+=e*o;const o=e*r-t*t;if(1e-12>Math.abs(o))return null;const s=(e*i-t*n)/o,a=(n-s*t)/e;l=e=>a+s*e}const u=c.length,h=c.map(([e,t])=>t-l(e)),d=h.reduce((e,t)=>e+t*t,0),f=Math.sqrt(d/Math.max(u-2,1)),y=c.reduce((e,t)=>e+t[0],0)/u,p=c.reduce((e,t)=>e+(t[0]-y)**2,0),g=e.confidence??.95,m=.99>g?.95>g?.9>g?1:1.645:1.96:2.576,x=e.steps??5,v=c[u-1][0],b=(v-c[0][0])/Math.max(u-1,1),k=[];for(let e=1;x>=e;e++)k.push(v+e*b);const w=[];for(const e of k){const t=l(e),n=f*Math.sqrt(1+1/u+(p>0?(e-y)**2/p:0))*m;w.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const A=`M${w.map(e=>`${s(e.x)},${a(e.yUpper)}`).join(" L")} L${w.slice().reverse().map(e=>`${s(e.x)},${a(e.yLower)}`).join(" L")} Z`,S=w.map(e=>`${s(e.x)},${a(e.yCenter)}`).join(" "),_=`${s(v)},${a(l(v))}`,M=e.strokeColor||"#6366f1";return(0,ci.jsxs)("g",{children:[(0,ci.jsx)("path",{d:A,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),(0,ci.jsx)("polyline",{points:`${_} ${S}`,fill:"none",stroke:M,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&w.length>0&&(0,ci.jsx)("text",{x:s(w[w.length-1].x)+4,y:a(w[w.length-1].yCenter)-4,fill:M,fontSize:11,children:e.label})]},"ann-"+n)}case"widget":{let i,o;if(null!=e.px&&null!=e.py)i=e.px,o=e.py;else{const t=Hr(e,n,r);if(!t)return null;i=t.x,o=t.y}if(!Xr(i,o,r))return null;const s=e.dx??0,a=e.dy??0,c=e.width??32,l=e.height??32,u=e.content??(0,ci.jsx)("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return(0,ci.jsx)("foreignObject",{x:i+s-c/2,y:o+a-l/2,width:c,height:l,style:{overflow:"visible",pointerEvents:"auto"},children:(0,ci.jsx)("div",{...ri(e,t),style:{width:c,height:l,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const t=Hr(e,n,r);if(!t)return null;const{x:i,y:o}=t,s=i+(e.dx||0),a=o+(e.dy||0),c=e.color||"var(--semiotic-text, #333)",l=(0,ci.jsx)("text",{x:s,y:a,fill:c,fontSize:e.fontSize||11,opacity:e.opacity,strokeDasharray:e.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label});return!0!==e._redundantConnector?Cr.cloneElement(l,{key:"ann-text-"+n}):(0,ci.jsxs)("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[(0,ci.jsx)("line",{x1:i,y1:o,x2:s,y2:a,stroke:c,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),Cr.cloneElement(l,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+n)}case"category-highlight":{const t=e.category;if(null==t)return null;const i=e=>"function"==typeof e&&"function"==typeof e.bandwidth,o=r.scales?.o,s=r.scales?.x,a=r.scales?.y,c=i(o)?o:i(s)?s:i(a)?a:null;if(!c)return null;const l=c(t+"");if(null==l)return null;const u=c.bandwidth(),h=e.color||"var(--semiotic-primary, #4589ff)",d=e.opacity??.15,f=e.label;return(0,ci.jsxs)("g",(r.projection?"vertical"===r.projection:c===s)?{children:[(0,ci.jsx)("rect",{x:l,y:0,width:u,height:r.height||0,fill:h,fillOpacity:d}),f&&(0,ci.jsx)(ai,{x:l+u/2,y:16,textAnchor:"middle",fill:h,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]}:{children:[(0,ci.jsx)("rect",{x:0,y:l,width:r.width||0,height:u,fill:h,fillOpacity:d}),f&&(0,ci.jsx)(ai,{x:12,y:l+u/2,dominantBaseline:"middle",fill:h,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]},"ann-"+n)}default:return null}var i,o,s}}var di=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function fi(e){return!!e&&"object"==typeof e&&di.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}function yi(e){return"primary"===e?.emphasis||!0===e?.defensive}function pi(e,t,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:2e4))):1/0}function gi(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const r=e?.provenance?.confidence;switch("number"==typeof r&&Number.isFinite(r)&&(t+=15*Math.max(0,Math.min(1,r))),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}new Set(["label","callout","callout-circle","callout-rect"]);var mi=32,xi=6,vi=4,bi=8,ki=72;var wi={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function Ai(e){if(!Si(e))return e;const t=("string"==typeof e.mobileText?e.mobileText:void 0)??("string"==typeof e.shortText?e.shortText:void 0);return!t||"string"!=typeof e.label&&null!=e.label?e:{...e,label:t}}function Si(e){return fi(e)}function _i(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),r=e.split(/\s+/).filter(Boolean),i=[];let o="";for(const e of r)o&&o.length+e.length+1>n?(i.push(o),o=e):o=o?`${o} ${e}`:e;return o&&i.push(o),i}function Mi(e,t,n,r,i){const o=e+n,s=t+r;return Math.abs(n)>Math.abs(r)?{x:0>n?o-i.width-4:o+4,y:0>r?s-i.height:s,width:i.width,height:i.height}:{x:0>n?o-i.width:o,y:0>r?s-i.height-4:s+4,width:i.width,height:i.height}}function Ci(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function Pi(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function Ri(e,t,n,r,i,o,s,a){const c=Ci(e,s);let l=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,r){const i=Math.max(0,r-e.x),o=Math.max(0,r-e.y);return(i+Math.max(0,e.x+e.width-(t-r)))*e.height+(o+Math.max(0,e.y+e.height-(n-r)))*e.width}(c,i,o,a);for(const e of n)l+=12*Pi(c,e);for(const e of r)l+=4*Pi(c,e);return l}function ji(e){const{annotations:t,context:n,defaultOffset:r=mi,notePadding:i=xi,markPadding:o=vi,edgePadding:s=bi,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=ki,density:u,progressiveDisclosure:h=!1,redundantCues:d=!1,responsive:f,mobile:y,cohesion:p,audience:g}=e,m=n.width||0,x=n.height||0,v="object"==typeof y?y:{},b=v.breakpoint??480,k=!!y&&b>=m,w=k&&!1!==v.preferShortText?t.map(Ai):t,A=k&&!u?{maxAnnotations:v.maxAnnotations??("callout-list"===v.strategy?1:2),minVisible:v.minVisible??1}:u,S=h||k&&(!1!==v.progressiveDisclosure||"callout-list"===v.strategy),_=k&&!f?v.responsive??{minWidth:b}:f,M=k&&!p?v.cohesion:p;if(0===w.length||0>=m||0>=x)return w.slice();const C=[],P=function(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}(n,o);let R=!1;const j=w.map((e,t)=>{if(!Si(e))return e;const o=function(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const r=e.pointId??e.nodeId;if(null!=r&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===r);if(e)return{x:e.x,y:e.y}}const i=e.coordinates,o=n.scales?.geoProjection;if(Array.isArray(i)&&i.length>=2&&o){const e=i[0],t=i[1];if("number"==typeof e&&"number"==typeof t){const n=o([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?Hr(e,t,n):{x:e.x,y:e.y}}(e,t,n);if(!o)return e;const u=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="number"==typeof e.wrap?e.wrap:120,n=[..._i("string"==typeof e.title?e.title:void 0,t),..._i("string"==typeof e.label?e.label:void 0,t)],r=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*r)+10),height:Math.max(18,16*n.length+6)}}(e);if(a&&("number"==typeof(h=e).dx||"number"==typeof h.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:30,dy:-30}}(e);return C.push(Ci(Mi(o.x,o.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),i)),e}var h;let d=null,f=1/0;for(const e of function(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}(r)){const t=Ri(Mi(o.x,o.y,e.dx,e.dy,u),e,C,P,m,x,i,s);f>t&&(d=e,f=t)}if(!d)return e;const y=Ci(Mi(o.x,o.y,d.dx,d.dy,u),i);C.push(y);const p=Math.hypot(d.dx,d.dy),g=c&&p>=l&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return R=!0,{...e,dx:d.dx,dy:d.dy,...g?{connector:g}:{}}}),T=R?j:w.slice();let E=T;if(d){let e=!1;const t=T.map(t=>{const n=function(e){return"text"!==e.type||"string"!=typeof e.color||8>Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)?e:{...e,_redundantConnector:!0}}(t);return n!==t&&(e=!0),n});E=e?t:T}{let e=!1;const t=E.map(t=>{if(!0!==t?.defensive)return t;const n=function(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const n="string"==typeof t.source?wi[t.source]??t.source:null,r="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!r)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const i=[n,r].filter(Boolean).join(" · "),o="string"==typeof e.label?e.label:"";return o.includes(`(${i})`)?e:{...e,label:o?`${o} (${i})`:`(${i})`}}(t);return n!==t&&(e=!0),n});E=e?t:E}const D=new Set;if(A){const e="object"==typeof A?A:{},t=function(e){if(!e)return 1;const t=function(e){const t=e?.familiarity;if(!t)return 3;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?3:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(g),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??pi(m,x,e))*t))},{deferred:r}=function(e){const{annotations:t,width:n,height:r}=e,i=Math.max(0,e.minVisible??1),o=pi(n,r,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,fi(n))};var n}),a=s.filter(e=>e.note);if(0===a.length||o>=a.length)return{visible:t.slice(),deferred:[],budget:o};const c=a.filter(e=>yi(e.annotation)),l=a.filter(e=>!yi(e.annotation)).sort((e,t)=>gi(t.annotation)-gi(e.annotation)||e.index-t.index),u=Math.min(l.length,Math.max(Math.max(0,o-c.length),Math.max(0,i-c.length))),h=new Set([...c.map(e=>e.index),...l.slice(0,u).map(e=>e.index)]),d=[],f=[];for(const{annotation:e,index:t,note:n}of s)!n||h.has(t)?d.push(e):f.push(e);return{visible:d,deferred:f,budget:o}}({annotations:E,width:m,height:x,...n});for(const e of r)D.add(e)}if(_&&("object"==typeof _&&"number"==typeof _.minWidth?_.minWidth:480)>=m)for(const e of E)Si(e)&&"secondary"===e.emphasis&&D.add(e);if(D.size>0)for(const e of E)!0===e?.defensive&&D.delete(e);let N;return N=0===D.size?E:S?E.map(e=>D.has(e)?{...e,_annotationDeferred:!0}:e):E.filter(e=>!D.has(e)),M?function(e,t){let n=!1;const r=e.map(e=>Si(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?r:e}(N,M):N}var Ti=require("react"),Ei={positions:new Map},Di=new Set;function Ni(){for(const e of Di)e()}function Li(e,t){const n=Ei.positions.get(e);if(n?.locked)return;if(!n||n.sourceId!==t)return;const r=new Map(Ei.positions);r.delete(e),Ei={positions:r},Ni()}function Ii(e,t){const n=Ei.positions.get(e);if(!n?.locked)return;if(t&&n.sourceId!==t)return;const r=new Map(Ei.positions);r.delete(e),Ei={positions:r},Ni()}function Wi(){return Ei}function $i(e){return Di.add(e),()=>Di.delete(e)}var zi={positions:new Map};function Oi(){return()=>{}}function Fi(){return zi}function Bi(e,t,n){return"exact"===n?function(e,t){const n=e.domain(),r=n[0],i=n[n.length-1],o=r instanceof Date,s=r instanceof Date?r.getTime():r,a=i instanceof Date?i.getTime():i;if(2>t||s===a)return o?[new Date(s),new Date(a)]:[s,a];const c=(a-s)/(t-1),l=Array(t);for(let e=0;t>e;e++){const n=e===t-1?a:s+e*c;l[e]=o?new Date(n):n}return l}(e,t):e.ticks(t)}function Yi(e,t,n){if("edges"===e){if(t)return"start";if(n)return"end"}return"middle"}function Hi(e,t,n){if("edges"===e){if(t)return"hanging";if(n)return"auto"}return"middle"}function Xi(e){if(0===e.length)return{min:null,max:null};let t=1/0,n=-1/0;for(const r of e)t>r.pixel&&(t=r.pixel),r.pixel>n&&(n=r.pixel);return{min:t,max:n}}function qi(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Gi(e,t,n){if("left"===e||"right"===e){const r="left"===e?n:0,i="left"===e?-1:1,o=Math.ceil(t/8);let s="M0,"+r;for(let e=0;o>e;e++){const n=8*(e+1);s+=`L${Math.min(8*e+4,t)},${r+4*i}`,s+=`L${Math.min(n,t)},${r}`}return s}const r="bottom"===e?0:t,i="bottom"===e?1:-1,o=Math.ceil(n/8);let s=`M${r},0`;for(let e=0;o>e;e++){const t=8*(e+1);s+=`L${r+4*i},${Math.min(8*e+4,n)}`,s+=`L${r},${Math.min(t,n)}`}return s}var Vi=require("react/jsx-runtime");function Ui(e){const{width:t,height:n,totalWidth:r,totalHeight:i,margin:o,scales:s,showAxes:a,axes:c,showGrid:l,xFormat:u,yFormat:h,axisExtent:d}=e,f=(0,cr.useMemo)(()=>{if(!s)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||u||Ki,r=Math.max(2,Math.floor(t/70)),i=e?.ticks??5,o="exact"===d?Math.max(2,i):Math.min(i,r),a=e?.tickValues??Bi(s.x,o,d),l=a.map(e=>e.valueOf()),h=a.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,l)})),f=h.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 Qi(h,Math.max(55,f+8))},[s,c,u,t,d]),y=(0,cr.useMemo)(()=>{if(!s)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||h||Ki,r=Math.max(2,Math.floor(n/30)),i=e?.ticks??5,o="exact"===d?Math.max(2,i):Math.min(i,r);return Qi((e?.tickValues??Bi(s.y,o,d)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[s,c,h,n,d]),p=l&&s,g=a&&s;if(!p&&!g)return null;const m=c?.find(e=>"bottom"===e.orient),x=c?.find(e=>"left"===e.orient),v=g&&(!m||!1!==m.baseline),b=g&&(!x||!1!==x.baseline),k=m?.jaggedBase||!1,w=x?.jaggedBase||!1,A="var(--semiotic-border, #ccc)";return(0,Vi.jsx)("svg",{width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:(0,Vi.jsxs)("g",{transform:`translate(${o.left},${o.top})`,children:[p&&(()=>{const e=qi(c?.find(e=>"bottom"===e.orient)?.gridStyle),r=qi(c?.find(e=>"left"===e.orient)?.gridStyle);return(0,Vi.jsxs)("g",{className:"stream-grid",children:[f.map((t,r)=>(0,Vi.jsx)("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+r)),y.map((e,n)=>(0,Vi.jsx)("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),v&&!k&&(0,Vi.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:A,strokeWidth:1}),k&&(0,Vi.jsx)("path",{d:Gi("bottom",t,n),fill:"none",stroke:A,strokeWidth:1}),b&&!w&&(0,Vi.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:A,strokeWidth:1}),w&&(0,Vi.jsx)("path",{d:Gi("left",t,n),fill:"none",stroke:A,strokeWidth:1})]})})}function Ki(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function Qi(e,t){if(2>=e.length)return e;const n=[e[0]];for(let r=1;e.length-1>r;r++)t>Math.abs(e[r].pixel-n[n.length-1].pixel)||n.push(e[r]);const r=e[e.length-1];return t>Math.abs(r.pixel-n[n.length-1].pixel)?n[n.length-1]=r:n.push(r),n}function Zi(e){const{width:t,height:n,totalWidth:r,totalHeight:i,margin:o,scales:s,showAxes:a,axes:c,xLabel:l,yLabel:u,yLabelRight:h,xFormat:d,yFormat:f,axisExtent:y,showGrid:p,title:g,legend:m,legendHoverBehavior:x,legendClickBehavior:v,legendHighlightedCategory:b,legendIsolatedCategories:k,legendPosition:w="right",legendLayout:A,foregroundGraphics:S,marginalGraphics:_,xValues:M,yValues:C,annotations:P,onAnnotationActivate:R,onObservation:j,chartId:T,chartType:E,autoPlaceAnnotations:D,svgAnnotationRules:N,xAccessor:L,yAccessor:I,annotationData:W,pointNodes:$,curve:z,underlayRendered:O,canvasObscuresUnderlay:F=!0,linkedCrosshairName:B,linkedCrosshairSourceId:Y,children:H}=e,X=ni({onAnnotationActivate:R,onObservation:j,chartId:T,chartType:E}),q=(0,cr.useMemo)(()=>{if(!a||!s)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||d||Ki,r=Math.max(2,Math.floor(t/70)),i=e?.ticks??5,o="exact"===y?Math.max(2,i):Math.min(i,r),l=e?.tickValues??Bi(s.x,o,y),u=l.map(e=>e.valueOf()),h=l.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,u)})),f=h.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(f+8,55)):Math.max(55,f+8);let g=Qi(h,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=s.x.domain()[1],t=s.x(e),r=g[g.length-1].pixel;if(Math.abs(t-r)>1){const i=n(e,g.length,u);p>t-r&&g.length>1&&(g=g.slice(0,-1)),g.push({value:e,pixel:t,label:i})}}return g},[a,s,c,d,t,y]),G=(0,cr.useMemo)(()=>{if(!a||!s)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||f||Ki,r=Math.max(2,Math.floor(n/30)),i=e?.ticks??5,o="exact"===y?Math.max(2,i):Math.min(i,r);let l=Qi((e?.tickValues??Bi(s.y,o,y)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22);if(l.length>1&&(l=l.filter((e,t)=>0===t||e.label+""!=l[t-1].label+"")),e?.includeMax&&l.length>0&&"exact"!==y&&!e?.tickValues){const e=s.y.domain()[1],n=s.y(e),r=l[l.length-1].pixel;if(Math.abs(n-r)>1){const i=t(e);22>Math.abs(n-r)&&l.length>1&&(l=l.slice(0,-1)),l.push({value:e,pixel:n,label:i})}}return l},[a,s,c,f,n,y]),V=(0,cr.useMemo)(()=>{if(!a||!s)return[];const e=c?.find(e=>"right"===e.orient);if(!e)return[];const t=e.tickFormat||f||Ki,r=Math.max(2,Math.floor(n/30)),i=e.ticks??5;return Qi((e.tickValues??Bi(s.y,"exact"===y?Math.max(2,i):Math.min(i,r),y)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[a,s,c,f,n,y]),U=(0,cr.useRef)(new Map),K=(0,cr.useRef)(P?.length??0),Q=P?.length??0;K.current!==Q&&(K.current=Q,U.current=new Map);const Z=(0,cr.useMemo)(()=>{if(!P||0===P.length)return null;const e=hi(0,X),r={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:L,yAccessor:I,width:t,height:n,data:W,frameType:"xy",pointNodes:$,curve:z,stickyPositionCache:U.current};return ui(D?ji({annotations:P,context:r,..."object"==typeof D?D:{}}):P,e,N,r)},[P,D,N,t,n,L,I,W,s,$,z,X]),J=function(e){const t=(0,Ti.useSyncExternalStore)(e?$i:Oi,e?Wi:Fi,e?Wi:Fi);return e?t.positions.get(e)??null:null}(B);return(0,cr.useEffect)(()=>{if(!J?.locked||!B)return;const e=e=>{"Escape"===e.key&&Ii(B)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[J?.locked,B]),a||g||m||S||_||Z&&Z.length>0||p||H||J?(0,Vi.jsxs)("svg",{role:"img",width:r,height:i,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[(0,Vi.jsx)("title",{children:"string"==typeof g?g:"XY Chart"}),(0,Vi.jsx)("desc",{children:"string"==typeof g?g+" — XY data visualization":"XY data visualization"}),(0,Vi.jsxs)("g",{transform:`translate(${o.left},${o.top})`,children:[p&&s&&(!O||F)&&(()=>{const e=qi(c?.find(e=>"bottom"===e.orient)?.gridStyle),r=qi(c?.find(e=>"left"===e.orient)?.gridStyle);return(0,Vi.jsxs)("g",{className:"stream-grid",children:[q.map((t,r)=>(0,Vi.jsx)("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+r)),G.map((e,n)=>(0,Vi.jsx)("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),a&&s&&(()=>{const e=c?.find(e=>"left"===e.orient),r=c?.find(e=>"bottom"===e.orient),i=!e||!1!==e.baseline,s=!r||!1!==r.baseline,a=e?.jaggedBase||!1,d=r?.jaggedBase||!1,f=r?.landmarkTicks,y=e?.landmarkTicks,p="var(--semiotic-border, #ccc)",g="var(--semiotic-text-secondary, var(--semiotic-text, #666))",m="var(--semiotic-text, #333)",x=!!r?.autoRotate&&q.length>1&&(()=>{const e=t/Math.max(q.length-1,1);return q.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})(),v=x?12:18,b=n+(x?58:40),k={fontSize:"var(--semiotic-tick-font-size, 12px)"},w={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},A={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},S=r?.tickAnchor,_=e?.tickAnchor,M=Xi(q),C=Xi(G);return(0,Vi.jsxs)("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[(0,Vi.jsxs)("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!O||F)&&s&&!d&&(0,Vi.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:p,strokeWidth:1}),(!O||F)&&d&&(0,Vi.jsx)("path",{d:Gi("bottom",t,n),fill:"none",stroke:p,strokeWidth:1}),q.map((e,t)=>{const r=!!f&&("function"==typeof f?f(e.value,t):ln(e.value,t>0?q[t-1].value:void 0));return(0,Vi.jsxs)("g",{transform:`translate(${e.pixel},${n})`,children:[(0,Vi.jsx)("line",{y2:5,stroke:p,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,Vi.jsx)("text",{y:v,textAnchor:x?"end":Yi(S,e.pixel===M.min,e.pixel===M.max),fontWeight:r?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...r?w:k},transform:x?"rotate(-45)":void 0,children:e.label}):(0,Vi.jsx)("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:(0,Vi.jsx)("div",{style:{textAlign:"center",userSelect:"none",...k},children:e.label})})]},"xtick-"+t)}),l&&(0,Vi.jsx)("text",{x:t/2,y:b,textAnchor:"middle",fill:m,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:l})]}),(0,Vi.jsxs)("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!O||F)&&i&&!a&&(0,Vi.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:p,strokeWidth:1}),(!O||F)&&a&&(0,Vi.jsx)("path",{d:Gi("left",t,n),fill:"none",stroke:p,strokeWidth:1}),G.map((e,t)=>{const n=!!y&&("function"==typeof y?y(e.value,t):ln(e.value,t>0?G[t-1].value:void 0));return(0,Vi.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,Vi.jsx)("line",{x2:-5,stroke:p,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,Vi.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:Hi(_,e.pixel===C.min,e.pixel===C.max),fontWeight:n?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...n?w:k},children:e.label}):(0,Vi.jsx)("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:(0,Vi.jsx)("div",{style:{textAlign:"right",userSelect:"none",...k},children:e.label})})]},"ytick-"+t)}),(()=>{const t=e?.label||u;return t?(0,Vi.jsx)("text",{x:15-o.left,y:n/2,textAnchor:"middle",fill:m,transform:`rotate(-90, ${15-o.left}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:t}):null})()]}),(()=>{const e=c?.find(e=>"right"===e.orient);if(!e||0===V.length)return null;const r=!1!==e.baseline,i=e.landmarkTicks,s=e.label||h,a=e.tickAnchor,l=Xi(V);return(0,Vi.jsxs)("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[r&&(0,Vi.jsx)("line",{x1:t,y1:0,x2:t,y2:n,stroke:p,strokeWidth:1}),V.map((e,n)=>{const r=!!i&&("function"==typeof i?i(e.value,n):ln(e.value,n>0?V[n-1].value:void 0));return(0,Vi.jsxs)("g",{transform:`translate(${t},${e.pixel})`,children:[(0,Vi.jsx)("line",{x2:5,stroke:p,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,Vi.jsx)("text",{x:8,textAnchor:"start",dominantBaseline:Hi(a,e.pixel===l.min,e.pixel===l.max),fontWeight:r?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...r?w:k},children:e.label}):(0,Vi.jsx)("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:(0,Vi.jsx)("div",{style:{textAlign:"left",userSelect:"none",...k},children:e.label})})]},"ytick-r-"+n)}),s&&(0,Vi.jsx)("text",{x:t+o.right-15,y:n/2,textAnchor:"middle",fill:m,transform:`rotate(90, ${t+o.right-15}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:s})]})})()]})})(),Z,_&&s&&M&&C&&(0,Vi.jsxs)(Vi.Fragment,{children:[_.top&&(0,Vi.jsx)("g",{transform:"translate(0, 0)",children:(0,Vi.jsx)(Mr,{orient:"top",config:_r(_.top),values:M,scale:s.x,size:o.top,length:t})}),_.bottom&&(0,Vi.jsx)("g",{transform:`translate(0, ${n})`,children:(0,Vi.jsx)(Mr,{orient:"bottom",config:_r(_.bottom),values:M,scale:s.x,size:o.bottom,length:t})}),_.left&&(0,Vi.jsx)("g",{transform:"translate(0, 0)",children:(0,Vi.jsx)(Mr,{orient:"left",config:_r(_.left),values:C,scale:s.y,size:o.left,length:n})}),_.right&&(0,Vi.jsx)("g",{transform:`translate(${t}, 0)`,children:(0,Vi.jsx)(Mr,{orient:"right",config:_r(_.right),values:C,scale:s.y,size:o.right,length:n})})]}),S,J&&J.sourceId!==Y&&s?.x&&(()=>{const e=s.x(J.xValue);if(null==e||0>e||e>t)return null;const r=J.locked;return(0,Vi.jsx)("line",{x1:e,y1:0,x2:e,y2:n,stroke:r?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:r?1.5:1,strokeDasharray:r?"6,3":"4,4",pointerEvents:"none"})})(),H]}),g&&"string"==typeof g?(0,Vi.jsx)("text",{x:r/2,y:22,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:g}):g?(0,Vi.jsx)("foreignObject",{x:0,y:0,width:r,height:o.top,children:g}):null,br({legend:m,totalWidth:r,totalHeight:i,margin:o,legendPosition:w,title:g,legendLayout:A,legendHoverBehavior:x,legendClickBehavior:v,legendHighlightedCategory:b,legendIsolatedCategories:k})]}):null}var Ji=c(require("react")),eo=require("d3-shape");function to(e){return(e.tl??0)>0||(e.tr??0)>0||(e.br??0)>0||(e.bl??0)>0}var no=require("react/jsx-runtime"),ro={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function io(e,t="#4e79a7"){return jn(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}function oo(e,t,n,r){const i=e.glyph;if(!i?.parts?.length||0>=e.size)return null;const o=fn(i,e.size);if(0>=o.scale)return null;const s=`translate(${t},${n})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${o.offsetX},${o.offsetY}) scale(${o.scale})`,a=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),c=mn(i,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),l=c?function(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}(r+"-clip"):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),h=t=>i.parts.map((n,r)=>{const i=t?"none"===n.fill?void 0:t:yn(n.fill,a,e.accent),o=t?n.stroke&&"none"!==n.stroke?t:void 0:yn(n.stroke??"none",a,e.accent);return i||o?(0,no.jsx)("path",{d:n.d,fill:i??"none",stroke:o,strokeWidth:o?n.strokeWidth??1:void 0,strokeLinecap:n.strokeLinecap,strokeLinejoin:n.strokeLinejoin,opacity:n.opacity},r):null});return(0,no.jsxs)("g",{transform:s,opacity:1===u?void 0:u,children:[c&&l&&(0,no.jsx)("clipPath",{id:l,children:(0,no.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height})}),c&&e.ghostColor?(0,no.jsx)("g",{children:h(e.ghostColor)}):null,c&&l?(0,no.jsx)("g",{clipPath:`url(#${l})`,children:h()}):h()]},r)}var so="undefined"==typeof window||"undefined"==typeof document,ao=require("react"),co="undefined"!=typeof window?ao.useLayoutEffect:ao.useEffect;function lo(){const[e,t]=(0,ao.useState)(!1);return co(()=>{t(!0)},[]),e}var uo=()=>()=>{},ho=()=>!1,fo=()=>!0;function yo(){const e=(0,ao.useSyncExternalStore)(uo,ho,fo);return(0,ao.useRef)(e).current}var po=require("react");function go(e){const t=(0,po.useRef)(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return xo(e,t);if(!vo(e)||!vo(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;const n=e[r],i=t[r];if(!Object.is(n,i))if(Array.isArray(n)&&Array.isArray(i)){if(!xo(n,i))return!1}else{if(!vo(n)||!vo(i))return!1;if(!mo(n,i))return!1}}return!0}(t.current,e)||(t.current=e),t.current}function mo(e,t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;if(!Object.is(e[r],t[r]))return!1}return!0}function xo(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 vo(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 bo(e,t){const{background:n,hasBackgroundGraphics:r=!1,themeBackground:i="",x:o=0,y:s=0,width:a,height:c}=t;if("transparent"===n)return!1;if(r)return!1;const l=n||(i&&"transparent"!==i?i:"")||null;if(!l)return!1;const u=Cn(e,l);return!!u&&(e.fillStyle=u,e.fillRect(o,s,a,c),!0)}var ko={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 wo(e,t){const n=e.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const e=n[1],r=n[2],i=n[3];return`#${e}${e}${r}${r}${i}${i}${t}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${t}`;const r=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return r?`rgba(${r[1]}, ${(parseInt(t,16)/255).toFixed(3)})`:n}var Ao=c(require("react")),So=c(require("react")),_o=(require("react/jsx-runtime"),So.createContext(null));function Mo(){return So.useContext(_o)}var Co=require("react/jsx-runtime"),Po={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Ro({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Data point: "+n}return(0,Co.jsx)("div",{"aria-live":"polite","aria-atomic":"true",style:Po,children:t})}function jo(e){const t={};if(null==e||"object"!=typeof e)return t;for(const[n,r]of Object.entries(e))n.startsWith("_")||null!=r&&""!==r&&("number"==typeof r?Number.isFinite(r)&&(t[n]=r):"string"==typeof r?t[n]=r:"boolean"==typeof r?t[n]=r+"":r instanceof Date&&(t[n]=r.toISOString().slice(0,10)));return t}function To(e){return e&&"object"==typeof e?e:{}}function Eo(e){return To(e.accessibility).tableFields??e.accessibleDatum??e.datum}var Do=require("react/jsx-runtime");function No(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e){if(null===t?.datum)continue;const e=t.type+"";n[e]=(n[e]||0)+1}if(0===Object.keys(n).length)return t+", empty";const r=[],i={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},o=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],s=Object.keys(n).sort((e,t)=>{const n=o.indexOf(e),r=o.indexOf(t);return(-1===n?999:n)-(-1===r?999:r)});for(const e of s)r.push(`${n[e]} ${i[e]||e}`);return`${t}, ${r.join(", ")}`}function Lo(e,t,n){const r=[];return e>0&&r.push(e+" nodes"),t>0&&r.push(t+" edges"),0===r.length?n+", empty":`${n}, ${r.join(", ")}`}var Io=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},Wo="semiotic-accessible-data-table",$o=Wo+" semiotic-accessible-data-table-hidden",zo=Wo+" semiotic-accessible-data-table-visible",Oo=zo+" semiotic-accessible-data-table-network",Fo={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},Bo={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},Yo={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},Ho={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Xo={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},qo={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},Go={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Vo={marginTop:8,padding:"4px 10px",fontSize:12,cursor:"pointer",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",borderRadius:"var(--semiotic-border-radius, 4px)",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",fontFamily:"inherit"};function Uo({scene:e,chartType:t,tableId:n,chartTitle:r}){const[i,o]=Ao.useState(!1),[s,a]=Ao.useState(5),c=Mo(),l=c?.visible??!1,u=i||l,h=Ao.useRef(null),d=r?"Data summary for "+r:n?`Data summary for ${t} ${n}`:"Data summary for "+t;Ao.useEffect(()=>{u||a(5)},[u]);const f=Ao.useCallback(e=>{e.target===e.currentTarget&&(i||l||o(!0))},[i,l]),y=Ao.useCallback(e=>{l||h.current?.contains(e.relatedTarget)||o(!1)},[l]);if(!e||0===e.length)return n?(0,Do.jsx)("span",{id:n,tabIndex:-1,style:Po}):null;if(!u)return(0,Do.jsx)("div",{id:n,className:$o,tabIndex:-1,onFocus:f,style:Po,role:"region","aria-label":d,children:(0,Do.jsxs)("button",{type:"button",onClick:()=>o(!0),children:["View data summary (",e.length," elements)"]})});const p=function(e){const t=[];if(!Array.isArray(e))return t;const n=e.some(e=>e&&("line"===e.type||"area"===e.type));for(const r of e)if(r&&"object"==typeof r&&null!==r.datum)try{switch(r.type){case"point":if(n)break;t.push({label:"Point",values:jo(Eo(r))});break;case"line":case"area":{const e=Eo(r),n=Array.isArray(e)?e:[],i="line"===r.type?"Line point":"Area point";for(const e of n)t.push({label:i,values:jo(e)});break}case"rect":{const e=Eo(r),n=null!=e&&"object"==typeof e?e:{},i=n.category??r.group??"",o=n.value??n.__aggregateValue??n.total,s=jo(n);null==s.category&&""!==i&&(s.category=i+""),null==s.value&&null!=o&&(s.value="number"==typeof o||"string"==typeof o?o:o+""),t.push({label:"Bar",values:s});break}case"heatcell":{const e=jo(Eo(r));null==e.value&&"number"==typeof r.value&&Number.isFinite(r.value)&&(e.value=r.value),t.push({label:"Cell",values:e});break}case"wedge":{const e=Eo(r),n=jo(e);if(null==n.category){const t=To(e),r=t.category??t.label;null!=r&&(n.category=r+"")}t.push({label:"Wedge",values:n});break}case"circle":t.push({label:"Node",values:jo(Eo(r))});break;case"arc":t.push({label:"Arc",values:jo(Eo(r))});break;case"candlestick":t.push({label:"Candlestick",values:jo(Eo(r))});break;case"geoarea":{const e=To(Eo(r)),n=jo(e);if(null==n.name){const t=To(e.properties).name??e.name;null!=t&&(n.name=t+"")}t.push({label:"Region",values:n});break}}}catch{}return t}(e),g=function(e){if(!e||0===e.length)return[];const t=new Set;for(const n of e)if(n&&n.values)for(const e of Object.keys(n.values))t.add(e);const n=[];for(const r of t){const t=[],i=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[r];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&i.add(e+""))}if(t.length>0){let e=t[0],i=t[0],o=0;for(const n of t)e>n&&(e=n),n>i&&(i=n),o+=n;n.push({name:r,count:t.length,numeric:!0,min:e,max:i,mean:o/t.length})}else if(i.size>0){const e=Array.from(i);n.push({name:r,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(p),m=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${Io(e.min)} to ${Io(e.max)}, mean ${Io(e.mean)}.`);else{const t=e.uniqueValues,r=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${r}.`)}return n.join(" ")}(p.length,g),x=Math.min(s,p.length),v=p.slice(0,x),b=p.length-x,k=new Set;for(const e of v)for(const t of Object.keys(e.values))k.add(t);const w=Array.from(k);return(0,Do.jsxs)("div",{ref:h,id:n,className:zo,tabIndex:-1,onBlur:y,style:Fo,role:"region","aria-label":d,children:[(0,Do.jsx)("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{l&&c&&c.setVisible(!1),o(!1)},"aria-label":"Close data summary",style:Yo,children:"×"}),(0,Do.jsx)("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Bo,children:m}),(0,Do.jsxs)("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+t,style:Ho,children:[(0,Do.jsx)("caption",{className:"semiotic-accessible-data-table-caption",style:Go,children:b>0?`First ${x} of ${p.length} data points`:`All ${p.length} data points`}),(0,Do.jsx)("thead",{children:(0,Do.jsxs)("tr",{children:[(0,Do.jsx)("th",{style:Xo,children:"type"}),w.map(e=>(0,Do.jsx)("th",{style:Xo,children:e},e))]})}),(0,Do.jsx)("tbody",{children:v.map((e,t)=>(0,Do.jsxs)("tr",{children:[(0,Do.jsx)("td",{style:qo,children:e.label}),w.map(t=>{return(0,Do.jsx)("td",{style:qo,children:(n=e.values[t],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":Io(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},t);var n})]},t))})]}),b>0&&(0,Do.jsxs)("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>a(e=>e+25),style:Vo,children:["Show ",Math.min(25,b)," more"," ",1===b?"row":"rows"," (",b," remaining)"]})]})}function Ko({nodes:e,edges:t,chartType:n,tableId:r,chartTitle:i}){const[o,s]=Ao.useState(!1),[a,c]=Ao.useState(5),l=Mo(),u=l?.visible??!1,h=o||u,d=i?"Data summary for "+i:r?`Data summary for ${n} ${r}`:"Data summary for "+n,f=Ao.useRef(null);Ao.useEffect(()=>{h||c(5)},[h]);const y=Ao.useCallback(e=>{e.target===e.currentTarget&&(o||u||s(!0))},[o,u]),p=Ao.useCallback(e=>{u||f.current?.contains(e.relatedTarget)||s(!1)},[u]);if(!e||0===e.length)return r?(0,Do.jsx)("span",{id:r,tabIndex:-1,style:Po}):null;if(!h)return(0,Do.jsx)("div",{id:r,className:$o,tabIndex:-1,onFocus:y,style:Po,role:"region","aria-label":d,children:(0,Do.jsxs)("button",{type:"button",onClick:()=>s(!0),children:["View data summary (",e.length," nodes, ",t.length," edges)"]})});const g=Array.isArray(e)?e:[],m=Array.isArray(t)?t:[],x=new Map,v=new Map,b=new Map,k=new Map;for(const e of m){if(!e||"object"!=typeof e)continue;const t=e.datum??{source:e.source,target:e.target},n="object"==typeof t.source?t.source?.id:t.source,r="object"==typeof t.target?t.target?.id:t.target,i="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=n&&""!==n){const e=n+"";v.set(e,(v.get(e)??0)+1),k.set(e,(k.get(e)??0)+i)}if(null!=r&&""!==r){const e=r+"";x.set(e,(x.get(e)??0)+1),b.set(e,(b.get(e)??0)+i)}}const w=[];for(let e=0;g.length>e;e++){const t=g[e];if(!t||"object"!=typeof t)continue;const n=t.datum?.id??t.id,r=null!=n?n+"":"node-"+e,i=x.get(r)??0,o=v.get(r)??0,s=b.get(r)??0,a=k.get(r)??0;w.push({id:r,degree:i+o,inDeg:i,outDeg:o,wDegree:s+a,wInDeg:s,wOutDeg:a})}w.sort((e,t)=>t.degree-e.degree);let A=0,S=0;if(w.length>0){let e=0;for(const t of w)e+=t.degree,t.degree>S&&(S=t.degree);A=e/w.length}const _=m.some(e=>{const t=e?.datum??{source:e?.source,target:e?.target};return"number"==typeof t?.value&&Number.isFinite(t.value)}),M=[`${w.length} nodes, ${m.length} edges.`];w.length>0&&M.push(`Mean degree: ${Io(A)}, max degree: ${S}.`);const C=Math.min(a,w.length),P=w.slice(0,C),R=w.length-C;return(0,Do.jsxs)("div",{ref:f,id:r,className:Oo,tabIndex:-1,onBlur:p,style:Fo,role:"region","aria-label":d,children:[(0,Do.jsx)("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{u&&l&&l.setVisible(!1),s(!1)},"aria-label":"Close data summary",style:Yo,children:"×"}),(0,Do.jsx)("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Bo,children:M.join(" ")}),(0,Do.jsxs)("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+n,style:Ho,children:[(0,Do.jsx)("caption",{className:"semiotic-accessible-data-table-caption",style:Go,children:R>0?`Top ${C} of ${w.length} nodes by degree`:`All ${w.length} nodes by degree`}),(0,Do.jsx)("thead",{children:(0,Do.jsxs)("tr",{children:[(0,Do.jsx)("th",{style:Xo,children:"id"}),(0,Do.jsx)("th",{style:Xo,children:"degree"}),(0,Do.jsx)("th",{style:Xo,children:"in"}),(0,Do.jsx)("th",{style:Xo,children:"out"}),_&&(0,Do.jsx)("th",{style:Xo,children:"w. degree"}),_&&(0,Do.jsx)("th",{style:Xo,children:"w. in"}),_&&(0,Do.jsx)("th",{style:Xo,children:"w. out"})]})}),(0,Do.jsx)("tbody",{children:P.map((e,t)=>(0,Do.jsxs)("tr",{children:[(0,Do.jsx)("td",{style:qo,children:e.id}),(0,Do.jsx)("td",{style:qo,children:e.degree}),(0,Do.jsx)("td",{style:qo,children:e.inDeg}),(0,Do.jsx)("td",{style:qo,children:e.outDeg}),_&&(0,Do.jsx)("td",{style:qo,children:Io(e.wDegree)}),_&&(0,Do.jsx)("td",{style:qo,children:Io(e.wInDeg)}),_&&(0,Do.jsx)("td",{style:qo,children:Io(e.wOutDeg)})]},t))})]}),R>0&&(0,Do.jsxs)("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>c(e=>e+25),style:Vo,children:["Show ",Math.min(25,R)," more"," ",1===R?"node":"nodes"," (",R," remaining)"]})]})}function Qo({summary:e}){return e?(0,Do.jsx)("div",{role:"note",style:Po,children:e}):null}function Zo({tableId:e}){return(0,Do.jsx)("a",{href:"#"+e,style:Po,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,Po)},children:"Skip to data table"})}var Jo=require("react/jsx-runtime"),es="var(--semiotic-focus, #005fcc)";function ts({active:e,hoverPoint:t,margin:n,size:r,shape:i="circle",width:o,height:s,pathData:a}){if(!e||!t)return null;const c=t.x+n.left,l=t.y+n.top;let u;if("geoarea"!==i&&"path"!==i||!a)if("rect"===i&&null!=o&&null!=s){const e=Math.max(o,4),t=Math.max(s,4);u=(0,Jo.jsx)("rect",{x:c-e/2-3,y:l-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:es,strokeWidth:2,strokeDasharray:"4,2"})}else u=(0,Jo.jsx)("circle","wedge"===i?{cx:c,cy:l,r:12,fill:"none",stroke:es,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:c,cy:l,r:8,fill:"none",stroke:es,strokeWidth:2,strokeDasharray:"4,2"});else u=(0,Jo.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:(0,Jo.jsx)("path",{d:a,fill:"none",stroke:es,strokeWidth:2.5,strokeDasharray:"6,3"})});return(0,Jo.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}var ns=c(require("react"));function rs(e,t){return"touch"===t?Math.max(e,24):e}function is(e){return Array.isArray(e)?e[0]:e}function os(e,t,n,r){return{data:is(e),x:t,y:n,__semioticHoverData:!0,...r}}var ss=["name","label","title"],as=["type","kind","category","group","class","status","role","shape"],cs=["value","amount","total","count","weight","score"],ls=new Set(["x","y","z","x0","x1","y0","y1","r","cx","cy","radius","layer","row","rowindex","col","column","depth","index","order","sankeywidth","coincidentpoints","sourcelinks","targetlinks","parent","children","fx","fy","vx","vy"]);function us(e,t){for(const n of t){const t=e.find(e=>e.lower===n);if(t)return t}}function hs(e,t={}){if(!e||"object"!=typeof e)return{entries:[]};const n=t.maxEntries??6,r=!1!==t.skipPositional,i=[];for(const[t,n]of Object.entries(e)){if(t.startsWith("_"))continue;if("data"===t)continue;if(r&&ls.has(t.toLowerCase()))continue;if(null==n)continue;const e=typeof n;("string"===e||"number"===e||"boolean"===e||n instanceof Date)&&i.push({key:t,lower:t.toLowerCase(),value:n})}if(0===i.length)return{entries:[]};let o=i.findIndex(e=>ss.includes(e.lower));const s=o>=0;0>o&&(o=i.findIndex(e=>"id"===e.lower)),0>o&&(o=i.findIndex(e=>"string"==typeof e.value));const a=0>o?void 0:i[o];let c=i.filter((e,t)=>t!==o);s&&(c=c.filter(e=>"id"!==e.lower));const l=us(c,as),u=us(c,cs),h=new Set(as),d=new Set(cs),f=[];l&&f.push({key:l.key,value:l.value}),u&&f.push({key:u.key,value:u.value});for(const e of c){if(f.length>=n)break;e!==l&&e!==u&&(h.has(e.lower)||d.has(e.lower)||f.push({key:e.key,value:e.value}))}return{titleKey:a?.key,title:a?.value,entries:f}}require("react/jsx-runtime");var ds={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"},fs=require("react/jsx-runtime");function ys({x:e,y:t,containerWidth:n,containerHeight:r,margin:i,children:o,className:s="stream-frame-tooltip",zIndex:a=1}){const c=Number.isFinite(e)&&Number.isFinite(t),l=ns.useRef(null),[u,h]=ns.useState(null);ns.useLayoutEffect(()=>{const e=l.current;if(!e)return;const t=()=>{const t=e.getBoundingClientRect();Number.isFinite(t.width)&&Number.isFinite(t.height)&&h(e=>e&&.5>Math.abs(e.width-t.width)&&.5>Math.abs(e.height-t.height)?e:{width:t.width,height:t.height})};if(t(),"undefined"==typeof ResizeObserver)return;const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[s,n,r,c]);let d;d=u?`translate(${u.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>r-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*r>t?"4px":"calc(-100% - 4px)"})`;const f=function(e){if(!ns.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const n=e.props;if(!0===n["data-semiotic-tooltip-chrome"])return!0;if("true"===n["data-semiotic-tooltip-chrome"])return!0;const r=n.style;if(r&&"object"==typeof r){if(null!=r.background&&""!==r.background&&"transparent"!==r.background)return!0;if(null!=r.backgroundColor&&""!==r.backgroundColor&&"transparent"!==r.backgroundColor)return!0}return!1}(o),y=f?null:ds;return c?(0,fs.jsx)("div",{ref:l,className:f?s:(s+" semiotic-tooltip").trim(),style:{...y||{},position:"absolute",left:i.left+e,top:i.top+t,transform:d,pointerEvents:"none",zIndex:a,width:"max-content"},children:o}):null}var ps=c(require("react")),gs=require("react"),ms=require("react");var xs=require("react"),vs=()=>"undefined"!=typeof performance?performance.now():Date.now();function bs(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function ks(e,t){const n=e();return Number.isFinite(n)?n:t}var ws=class{constructor(e={}){this.randomSource=Math.random,this.subscribers=new Set,this.now=()=>this.advance(),this.random=()=>this.randomSource(),this.clock=e.clock??vs,this.lastWallTime=ks(this.clock,0),this.logicalTime=this.lastWallTime,this.pausedValue=!0===e.paused,this.visibleValue=!1!==e.visible,this.setRandomSource(e.random,e.seed)}get isActive(){return!this.pausedValue&&this.visibleValue}get paused(){return this.pausedValue}get seed(){return this.seedValue}get visible(){return this.visibleValue}configure(e){this.setClock(e.clock),this.setRandomSource(e.random,e.seed)}setPaused(e){this.pausedValue!==e&&(this.advance(),this.pausedValue=e,this.emit())}setVisible(e){this.visibleValue!==e&&(this.advance(),this.visibleValue=e,this.emit())}snapshot(){return{now:this.now(),paused:this.pausedValue,seed:this.seedValue,visible:this.visibleValue}}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}advance(){const e=ks(this.clock,this.lastWallTime),t=Math.max(0,e-this.lastWallTime);return this.lastWallTime=e,this.isActive&&(this.logicalTime+=t),this.logicalTime}emit(){for(const e of this.subscribers)e()}setClock(e){const t=e??vs;t!==this.clock&&(this.advance(),this.clock=t,this.lastWallTime=ks(t,this.lastWallTime))}setRandomSource(e,t){const n=function(e){return"number"==typeof e&&Number.isFinite(e)?Math.trunc(e):void 0}(t);e===this.randomInput&&n===this.seedValue||(this.randomInput=e,this.seedValue=n,this.randomSource=e??(void 0===n?Math.random:bs(n)))}},As="undefined"==typeof window?gs.useEffect:gs.useLayoutEffect,Ss={requestAnimationFrame:e=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(e),cancelAnimationFrame:e=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(e)};function _s(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function Ms(e){const t=function(){const[e,t]=(0,ms.useState)(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return(0,ms.useEffect)(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return t(e.matches),function(e,t){if("function"==typeof e.addEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);const n=e;return n.addListener(t),()=>n.removeListener(t)}(e,e=>t(e.matches))},[]),e}(),n=(0,gs.useRef)(t);n.current=t;const[r,i]=function(e,t,n){const r=(0,xs.useRef)(null),[i,o]=(0,xs.useState)(null);return(0,xs.useEffect)(()=>{if(!t&&!n)return;const e=r.current;if(!e)return;const i=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;o(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return i.observe(e),()=>i.disconnect()},[t,n]),[r,[t&&i?i.w:e[0],n&&i?i.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),o=!!e.title,s=!!e.legend&&"top"===e.legendPosition,a=(0,gs.useMemo)(()=>function(e,t,n=!1){const r=n?t?58:34:t?36:0;return r>e.top?{...e,top:r}:e}({...e.marginDefault,...e.userMargin},o,s),[e.marginDefault,e.userMargin,o,s]),c=i[0]-a.left-a.right,l=i[1]-a.top-a.bottom,u=_s(e.foregroundGraphics,i,a),h=_s(e.backgroundGraphics,i,a),d=I(e=>e.theme),{transition:f,introEnabled:y}=function(e,t){if(!1===e)return{transition:void 0,introEnabled:!1};const n="undefined"!=typeof window&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;return{transition:e?!0===e?{duration:300}:{duration:e.duration??300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(n||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),p="semiotic-table-"+ps.useId(),g=(0,gs.useRef)(null);if(!g.current){const t=!e.suspendWhenHidden||"undefined"==typeof document||!document.hidden;g.current=new ws({clock:e.clock,random:e.random,seed:e.seed,paused:e.paused,visible:t})}const m=g.current;m.configure({clock:e.clock,random:e.random,seed:e.seed});const x=(0,gs.useRef)(null),v=(0,gs.useRef)(e.frameScheduler??Ss);v.current=e.frameScheduler??Ss;const b=(0,gs.useRef)(null),k=(0,gs.useRef)(!1),w=(0,gs.useRef)(()=>{}),A=(0,gs.useCallback)(()=>{if(null!==x.current||k.current)return;const e=v.current;let t=!1,n=!1;const r=e.requestAnimationFrame(()=>{t=!0;const e=!n;e&&(k.current=!0),x.current=null,b.current=null;try{w.current()}finally{e&&(k.current=!1)}});n=!0,t||(x.current=r,b.current=e)},[]),S=(0,gs.useCallback)(()=>{null!==x.current&&((b.current??v.current).cancelAnimationFrame(x.current),x.current=null,b.current=null)},[]);As(()=>{m.setPaused(!0===e.paused)},[m,e.paused]),(0,gs.useEffect)(()=>{if(!e.suspendWhenHidden||"undefined"==typeof document)return void m.setVisible(!0);const t=()=>m.setVisible(!document.hidden);return t(),document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[m,e.suspendWhenHidden]),(0,gs.useEffect)(()=>()=>{S()},[S]);const _=(0,gs.useRef)(()=>{}),M=(0,gs.useRef)(()=>{}),C=(0,gs.useRef)(null),P=(0,gs.useRef)(null),R=(0,gs.useRef)(null),j=(0,gs.useCallback)(()=>{const e=C.current;C.current=null,e&&_.current(e)},[]),T=(0,gs.useCallback)(e=>{if(C.current={clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType},null===P.current){const e=v.current;let t=!1;const n=e.requestAnimationFrame(()=>{t=!0,P.current=null,R.current=null,j()});t||(P.current=n,R.current=e)}},[j]),E=(0,gs.useCallback)(()=>{C.current=null,null!==P.current&&((R.current??v.current).cancelAnimationFrame(P.current),P.current=null,R.current=null),M.current()},[]);(0,gs.useEffect)(()=>()=>{C.current=null,null!==P.current&&((R.current??v.current).cancelAnimationFrame(P.current),P.current=null,R.current=null)},[]);const D=e.themeDirtyRef;return As(()=>{D&&(An++,D.current=!0,A())},[d,A,D]),{reducedMotion:t,reducedMotionRef:n,responsiveRef:r,size:i,margin:a,adjustedWidth:c,adjustedHeight:l,resolvedForeground:u,resolvedBackground:h,currentTheme:d,transition:f,introEnabled:y,tableId:p,frameRuntime:m,rafRef:x,renderFnRef:w,scheduleRender:A,cancelRender:S,hoverHandlerRef:_,hoverLeaveRef:M,onPointerMove:T,onPointerLeave:E}}var Cs=require("react"),Ps=require("react/jsx-runtime");function Rs(e,t){return function(e){const{cancelRender:t,dirtyRef:n,frameRuntime:r,manageFrameRuntime:i,scheduleRender:o}=e,s=(0,Cs.useRef)(null),a=(0,Cs.useRef)(null),c=(0,Cs.useRef)(!1);return function(e){const{hydrated:t,wasHydratingFromSSR:n,storeRef:r,dirtyRef:i,renderFnRef:o,cancelRender:s,cleanup:a}=e;co(()=>{t&&n&&r.current?.cancelIntroAnimation?.(),i.current=!0,s?.(),o.current()},[t,n]);const c=(0,ao.useRef)(a);c.current=a,(0,ao.useEffect)(()=>()=>c.current?.(),[])}({hydrated:e.hydrated,wasHydratingFromSSR:e.wasHydratingFromSSR,storeRef:e.storeRef,dirtyRef:e.dirtyRef,renderFnRef:e.renderFnRef,cancelRender:e.cancelRender,cleanup:e.cleanup}),(0,Cs.useEffect)(()=>{if(!1!==i)return r.subscribe(()=>{r.isActive?(n.current=!0,o()):t()})},[t,n,r,i,o]),(0,Cs.useEffect)(()=>{!c.current&&(c.current=!0,e.skipInitialCanvasPaintInvalidation)||(e.dirtyRef.current=!0,e.scheduleRender())},e.canvasPaintDependencies),{canvasRef:s,interactionCanvasRef:a}}({...t,renderFnRef:e.renderFnRef,scheduleRender:e.scheduleRender,cancelRender:e.cancelRender,frameRuntime:e.frameRuntime})}function js({children:e,size:t,margin:n,overflowVisible:r=!1}){return e?(0,Ps.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:t[0],height:t[1],pointerEvents:"none",overflow:r?"visible":void 0},children:(0,Ps.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:e})}):null}function Ts(e,t,n,r){return"function"==typeof e?e({size:t,margin:n,scales:r}):e}function Es(e,t,n,r){const i=e.getContext("2d");if(!i)return null;const o=Math.round(t[0]*r),s=Math.round(t[1]*r),a=o/t[0],c=s/t[1],l=t[0]+"px",u=t[1]+"px";return e.style.width!==l&&(e.style.width=l),e.style.height!==u&&(e.style.height=u),e.width===o&&e.height===s||(e.width=o,e.height=s),i.setTransform(a,0,0,c,0,0),i.translate(n.left,n.top),i}function Ds(){if("undefined"==typeof window)return 1;const e=window.devicePixelRatio||1,t=function(){if("undefined"==typeof window)return!1;const e="function"==typeof window.matchMedia&&window.matchMedia("(pointer: coarse)").matches,t=768>Math.min(window.innerWidth||1/0,window.innerHeight||1/0);return e||t}()?2:3;return Math.max(1,Math.min(e,t))}var Ns=require("react");function Ls(e,t,n,r){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:r,fn:t}:{key:void 0,fn:null}}var Is=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ws=3156e7;function $s(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")}`}:Ws>t?e=>{const t=new Date(e);return`${Is[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*Ws>t?e=>{const t=new Date(e);return`${Is[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}function zs(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:Qe(n.size)});else if("glyph"===n.type){const e=xn(n.glyph,n.size);t.push({pointId:n.pointId,x:n.x+e.centerDx,y:n.y+e.centerDy,r:e.radius})}return t}var Os=require("d3-shape");function Fs(e,t,n){let r=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(r=n.color):e>n.value&&(r=n.color);return r}function Bs(e,t,n,r,i,o){if(2>t.length)return;const s=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],r=t[e][1]-t[e-1][1];s.push(s[e-1]+Math.sqrt(n*n+r*r))}const a=s[s.length-1];if(0===a)return;const c=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=r,e.lineCap=o;for(let n=0;t.length-1>n;n++){const r=(s[n]+s[n+1])/2;let o=i;c>r&&(o*=r/c),c>a-r&&(o*=(a-r)/c),e.globalAlpha=Math.max(0,o),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}var Ys=(e,t,n,r)=>{const i=t.filter(e=>"line"===e.type);for(const t of i){if(2>t.path.length)continue;const n=t._introClipFraction;void 0!==n&&1>n&&(e.save(),e.beginPath(),e.rect(0,0,r.width*n,r.height),e.clip());const i=t.style.stroke||"#007bff",o=Cn(e,i)||i,s=t.style.strokeWidth||2,a=t.colorThresholds,c=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=s,e.lineCap=t.style.strokeLinecap||"butt",t.style._edgeFade){Bs(e,t.path,o,s,t.style.opacity??1,t.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const l=In(t.curve),u=a&&a.length>0&&c&&c.length===t.path.length,h=t._decayOpacities;if(h&&h.length===t.path.length&&!u){e.strokeStyle=o;const n=t.style.opacity??1;for(let r=0;t.path.length-1>r;r++)e.globalAlpha=.5*(h[r]+h[r+1])*n,e.beginPath(),e.moveTo(t.path[r][0],t.path[r][1]),e.lineTo(t.path[r+1][0],t.path[r+1][1]),e.stroke()}else if(u){let n=function(t,n,r){e.beginPath(),e.strokeStyle=t,e.moveTo(n,r),h=!0},r=function(){h&&(e.stroke(),h=!1)},i=null,s=null,l=null,u=null,h=!1;for(let h=0;t.path.length>h;h++){const[d,f]=t.path[h],y=c[h],p=Fs(y,a,o);if(null!==i&&null!==u&&null!==l){if(p===u)e.lineTo(d,f);else{const t=[];for(const e of a){const n=e.value;(l>n||n>y)&&(n>l||y>n)||l===n||y===n||t.push({t:(n-l)/(y-l)})}t.sort((e,t)=>e.t-t.t);for(const c of t){const t=i+(d-i)*c.t,u=s+(f-s)*c.t,h=Fs(l+(y-l)*Math.min(c.t+1e-4,1),a,o);e.lineTo(t,u),r(),n(h,t,u)}e.lineTo(d,f)}i=d,s=f,l=y,u=p}else n(p,d,f),i=d,s=f,l=y,u=p}r()}else{e.beginPath();const n=t.strokeGradient&&t.path.length>=2?zn(e,t.strokeGradient,t.path[0][0],0,t.path[t.path.length-1][0],0):null;if(e.strokeStyle=n||o,l)(0,Os.line)().x(e=>e[0]).y(e=>e[1]).curve(l).context(e)(t.path);else{const[n,r]=t.path[0];e.moveTo(n,r);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=Wn(e,t.style.fill,t.style.fill),l&&!u)(0,Os.line)().x(e=>e[0]).y(e=>e[1]).curve(l).context(e)(t.path);else{const[n,r]=t.path[0];e.moveTo(n,r);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],r.height),e.lineTo(n,r.height),e.closePath(),e.fill()}void 0!==n&&1>n&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function Hs(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Xs(e,t,n=.3){Hs(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 qs(e,t,n=.6){if(!Hs(t))return;const r=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,i=t.cx??t.x??0,o=t.cy??t.y??0;e.beginPath(),e.arc(i,o,r,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 Gs(e,t,n,r=.35){Hs(t)&&(e.globalAlpha=t._pulseIntensity*r,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}var Vs=require("d3-shape");function Us(e,t){const n=In(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 r=(0,Vs.area)().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),r(t.topPath)}}var Ks=(e,t,n,r)=>{const i=t.filter(e=>"area"===e.type);for(const t of i){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 i=t._introClipFraction;void 0!==i&&1>i&&(e.save(),e.beginPath(),e.rect(0,0,r.width*i,r.height),e.clip());const o=Wn(e,t.style.fill,"#4e79a7"),s=t._decayOpacities;if(s&&s.length===t.topPath.length){const n=t.style.fillOpacity??.7;e.fillStyle=o;for(let r=0;t.topPath.length-1>r;r++)e.globalAlpha=.5*(s[r]+s[r+1])*n,e.beginPath(),e.moveTo(t.topPath[r][0],t.topPath[r][1]),e.lineTo(t.topPath[r+1][0],t.topPath[r+1][1]),e.lineTo(t.bottomPath[r+1][0],t.bottomPath[r+1][1]),e.lineTo(t.bottomPath[r][0],t.bottomPath[r][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=Cn(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*(s[n]+s[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(Us(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 r=-1/0;for(const e of t.bottomPath)e[1]>r&&(r=e[1]);const i=$n(e,t.fillGradient,"string"==typeof o?o:"#4e79a7",0,n,0,r);e.fillStyle=i||o,e.globalAlpha=a}else e.globalAlpha=(t.style.fillOpacity??.7)*a,e.fillStyle=o;if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(Us(e,t),Gs(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=a;const n=t.strokeGradient&&t.topPath.length>=2?zn(e,t.strokeGradient,t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0):null;e.strokeStyle=n||Cn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const r=In(t.curve);if(e.beginPath(),r)(0,Vs.line)().x(e=>e[0]).y(e=>e[1]).curve(r).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!==i&&1>i&&e.restore(),n&&e.restore(),e.globalAlpha=1}},Qs=(e,t,n,r)=>{const i=t.filter(e=>"point"===e.type);if(0!==i.length){e.save();try{const t=e.globalAlpha;for(const n of i)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=Wn(e,n.style.fill,"#4e79a7"),e.fill(),n.style.stroke&&(e.strokeStyle=Wn(e,n.style.stroke,n.style.stroke),e.lineWidth=n.style.strokeWidth||1,e.stroke()),qs(e,n)}finally{e.restore()}}},Zs=new Map;function Js(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=Zs.get(t);return n||(n=new Path2D(Ke(e.symbolType,e.size)),Zs.size>256&&Zs.clear(),Zs.set(t,n)),n}catch{return null}}var ea=(e,t)=>{const n=e.globalAlpha;for(const r of t){if("symbol"!==r.type)continue;const t=r;if(0>=t.size)continue;const i=Js(t);if(!i)continue;e.save(),e.translate(t.x,t.y),t.rotation&&e.rotate(t.rotation);const o=(t.style.opacity??1)*(t._decayOpacity??1);t.style.fill&&(e.globalAlpha=n*o*(t.style.fillOpacity??1),e.fillStyle=Wn(e,t.style.fill,"#4e79a7"),e.fill(i)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*o,e.strokeStyle=Wn(e,t.style.stroke,t.style.stroke),e.lineWidth=t.style.strokeWidth??1,e.stroke(i)),e.restore()}e.globalAlpha=n};function ta(e,t,n,r,i){if(0>=t.size)return;const o=t.glyph;if(!o||!o.parts?.length)return;const s=fn(o,t.size);if(0>=s.scale)return;const a=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=a)return;const c=t=>{const n=Wn(e,t,t);return"string"==typeof n?n:t},l=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(n,r),t.rotation&&e.rotate(t.rotation),e.translate(s.offsetX,s.offsetY),e.scale(s.scale,s.scale),e.globalAlpha=i*a*(t.style.fillOpacity??1);const u=mn(o,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&vn(e,o,l,t.accent,t.ghostColor,c),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),vn(e,o,l,t.accent,void 0,c),e.restore()}function na(e,t){const{x:n,y:r,w:i,h:o}=t,{tl:s,tr:a,br:c,bl:l}=function(e){const t=e.cornerRadii;if(!t)return{tl:0,tr:0,br:0,bl:0};const n=Math.min(e.w,e.h)/2,r=e=>Math.max(0,Math.min(e??0,n));return{tl:r(t.tl),tr:r(t.tr),br:r(t.br),bl:r(t.bl)}}(t);e.beginPath(),e.moveTo(n+s,r),e.lineTo(n+i-a,r),a>0&&e.arcTo(n+i,r,n+i,r+a,a),e.lineTo(n+i,r+o-c),c>0&&e.arcTo(n+i,r+o,n+i-c,r+o,c),e.lineTo(n+l,r+o),l>0&&e.arcTo(n,r+o,n,r+o-l,l),e.lineTo(n,r+s),s>0&&e.arcTo(n,r,n+s,r,s),e.closePath()}function ra(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 ia=(e,t,n,r)=>{const i=t.filter(e=>"rect"===e.type);for(const t of i){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)oa(e,t);else if(t.cornerRadii&&to(t.cornerRadii)){const n=Wn(e,t.style.fill,Cn(e,"var(--semiotic-primary, #007bff)")),r=ra(t),i=t.fillGradient&&"string"==typeof n?$n(e,t.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;e.fillStyle=i||n,na(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Cn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else if(t.roundedTop&&t.roundedTop>0){const n=Wn(e,t.style.fill,Cn(e,"var(--semiotic-primary, #007bff)")),r=ra(t),i=t.fillGradient&&"string"==typeof n?$n(e,t.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;e.fillStyle=i||n;const o=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:s,y:a,w:c,h:l}=t;switch(t.roundedEdge){case"right":e.moveTo(s,a),e.lineTo(s+c-o,a),e.arcTo(s+c,a,s+c,a+o,o),e.lineTo(s+c,a+l-o),e.arcTo(s+c,a+l,s+c-o,a+l,o),e.lineTo(s,a+l);break;case"left":e.moveTo(s+c,a),e.lineTo(s+o,a),e.arcTo(s,a,s,a+o,o),e.lineTo(s,a+l-o),e.arcTo(s,a+l,s+o,a+l,o),e.lineTo(s+c,a+l);break;case"bottom":e.moveTo(s,a),e.lineTo(s+c,a),e.lineTo(s+c,a+l-o),e.arcTo(s+c,a+l,s+c-o,a+l,o),e.lineTo(s+o,a+l),e.arcTo(s,a+l,s,a+l-o,o);break;default:e.moveTo(s,a+l),e.lineTo(s,a+o),e.arcTo(s,a,s+o,a,o),e.lineTo(s+c-o,a),e.arcTo(s+c,a,s+c,a+o,o),e.lineTo(s+c,a+l)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Cn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else{const n=Wn(e,t.style.fill,Cn(e,"var(--semiotic-primary, #007bff)")),r=ra(t),i=t.fillGradient&&"string"==typeof n?$n(e,t.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;e.fillStyle=i||n,e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Cn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))}Xs(e,t),e.globalAlpha=1}};function oa(e,t){const n=t.style.icon,r=t.style.iconPadding||2,i=Math.min(t.w,t.h)-r;if(0>=i)return;const o=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),o){const o=i+r,s=t.x+(t.w-i)/2;for(let r=t.y+t.h-i;r>=t.y-i;r-=o)e.drawImage(n,s,r,i,i)}else{const o=i+r,s=t.y+(t.h-i)/2;for(let r=t.x;t.x+t.w>r;r+=o)e.drawImage(n,r,s,i,i)}e.restore()}function sa(e){const[t,n,r]=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*r>128?"#000":"#fff"}function aa(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}var ca=(e,t,n,r)=>{const i=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of i){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=Cn(e,"var(--semiotic-surface, #fff)"),e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),Xs(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):aa(t.value),r=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),i=t.x+t.w/2,o=t.y+t.h/2;e.fillStyle=sa(t.fill),e.font=r+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,i,o)}}}finally{e.restore()}},la=(e,t,n,r)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const i=(t._decayOpacity??1)*(t.style?.opacity??1);1!==i&&(e.globalAlpha=i);const o=Cn(e,t.wickColor)||t.wickColor,s=60>r.height,a=s?Math.max(t.wickWidth,2):t.wickWidth,c=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=o,e.lineWidth=a,e.stroke()};if(s||c(),t.isRange){const n=Math.max(2,Math.min(t.bodyWidth/2,.12*r.height));e.fillStyle=o,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),r=Math.abs(t.openY-t.closeY),i=t.isUp?t.upColor:t.downColor,o=Cn(e,i)||i;e.fillStyle=o,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(r,1)),e.strokeStyle=o,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(r,1))}s&&c(),e.restore()}},ua={line:[Ks,Ys,Qs],area:[Ks,Qs],stackedarea:[Ks,Qs],scatter:[Qs,ea],bubble:[Qs,ea],heatmap:[ca],bar:[ia],swarm:[Qs],waterfall:[(e,t,n,r)=>{ia(e,t);const i=t.filter(e=>"rect"===e.type);if(2>i.length)return;const o=i[0].datum,s=o?._connectorStroke;if(s){e.save(),e.strokeStyle=Cn(e,s)||s,e.lineWidth=o?._connectorWidth??1,e.setLineDash([]);for(let t=0;i.length-1>t;t++){const r=i[t],o=i[t+1],s=r.datum,a=o.datum;if(null==s?.cumEnd||null==a?.baseline)continue;const c=n.y(s.cumEnd),l=r.x+r.w,u=o.x;e.beginPath(),e.moveTo(l,c),e.lineTo(u,c),e.stroke()}e.restore()}}],candlestick:[la],mixed:[Ks,Ys,Qs],custom:[Ks,ia,ca,Ys,Qs,ea,(e,t)=>{const n=e.globalAlpha;for(const r of t)"glyph"===r.type&&ta(e,r,r.x,r.y,n);e.globalAlpha=n},la]},ha=new Set;function da(e,t){const n="function"==typeof e?e(t.datum??null,t):e;return(r=n)&&"object"==typeof r&&"string"==typeof r.id&&"function"==typeof r.cacheKey&&"function"==typeof r.drawCanvas&&"function"==typeof r.renderStaticSVG?n:void 0;var r}function fa(e,t){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const n=`${e}:${t}`;ha.has(n)||(ha.add(n),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}function ya(e){const{context:t,nodes:n,renderMode:r,pixelRatio:i,paintBuiltIn:o}=e;if(!r||"sketchy"===r)return void o(n);let s=[];const a=()=>{s.length&&(o(s),s=[])};for(const e of n){const n=da(r,e);if(!n){s.push(e);continue}let c;a(),t.save();try{c=n.drawCanvas({context:t,node:e,style:e.style??{},pixelRatio:i})}finally{t.restore()}c||(fa(n.id,e.type??"unknown"),o([e]))}a()}function pa(e){const{node:t,index:n,renderMode:r,fallback:i}=e,o=da(r,t);if(!o)return i();const s=o.renderStaticSVG({node:t,style:t.style??{},key:`${o.id}-${n}`});return null!=s?s:(fa(o.id,t.type??"unknown"),i())}require("react/jsx-runtime");var ga=require("react/jsx-runtime");function ma(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function xa({hover:e}){const t=e.data??{},n=t.y??t.value,r=t.x??t.time;if(void 0===n&&void 0===r){const e=hs(t);if(null!=e.title||e.entries.length>0)return(0,ga.jsxs)("div",{className:"semiotic-tooltip",style:ds,children:[null!=e.title&&(0,ga.jsx)("div",{style:{fontWeight:600,marginBottom:e.entries.length?2:0},children:e.title+""}),e.entries.map(e=>(0,ga.jsxs)("div",{style:{opacity:.7,fontSize:11},children:[e.key,":"," ",(0,ga.jsx)("span",{style:{fontWeight:600},children:ma(e.value)})]},e.key))]})}return(0,ga.jsxs)("div",{className:"semiotic-tooltip",style:ds,children:[(0,ga.jsx)("div",{style:{fontWeight:600,marginBottom:2},children:ma(n)}),(0,ga.jsx)("div",{style:{opacity:.7,fontSize:11},children:ma(r)})]})}function va(e){return"touch"===e?"touch":"pointer"}function ba(e){const t=e.target;return t instanceof Element&&t!==e.currentTarget&&null!=t.closest("button, a[href], input, select, textarea, summary, [contenteditable='true'], [role='button'], [role='link'], [role='checkbox'], [role='radio'], [role='switch']")}function ka(e){const{onObservation:t,datum:n,x:r=0,y:i=0,chartType:o,chartId:s,context:a,timestamp:c=Date.now()}=e;t&&(n?(t({type:"hover",datum:n,x:r,y:i,timestamp:c,chartType:o,chartId:s}),"focus"===a?.type&&t({type:"focus",datum:n,inputType:"touch"===a.inputType?"pointer":a.inputType,timestamp:c,chartType:o,chartId:s})):t({type:"hover-end",timestamp:c,chartType:o,chartId:s}))}function wa(e){const{onObservation:t,datum:n,x:r=0,y:i=0,chartType:o,chartId:s,context:a,timestamp:c=Date.now()}=e;t&&(n?(t({type:"click",datum:n,x:r,y:i,timestamp:c,chartType:o,chartId:s}),"activate"===a?.type&&t({type:"activate",datum:n,inputType:a.inputType,timestamp:c,chartType:o,chartId:s})):t({type:"click-end",timestamp:c,chartType:o,chartId:s}))}xa.ownsChrome=!0;var Aa=require("react"),Sa=require("react");function _a(e){const t=new Map;for(const n of e){const e=n.group??"_default";let r=t.get(e);r||(r=[],t.set(e,r)),r.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 r=t.get(e),i=t.get(n);return(r.length>0?r[0].y:0)-(i.length>0?i[0].y:0)}),r=Array.from(t.values()).flat();r.sort((e,t)=>e.x-t.x||e.y-t.y);const i=new Map;for(let e=0;r.length>e;e++){r[e]._flatIndex=e;const t=r[e].datum?.id;null!=t&&i.set(t+"",e)}return{flat:r,groups:n,byGroup:t,idToIdx:i}}function Ma(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)),r=e.flat[n];return{flatIndex:n,group:r.group??"_default",indexInGroup:r._groupIndex??0}}function Ca(e,t,n){const{group:r,indexInGroup:i}=t,o=n.byGroup.get(r);switch(e){case"ArrowRight":return o.length-1>i?o[i+1]._flatIndex:t.flatIndex;case"ArrowLeft":return i>0?o[i-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(r);return n.groups.length-1>e?Pa(n,n.groups[e+1],o[i]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(r);return e>0?Pa(n,n.groups[e-1],o[i]):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 Pa(e,t,n){const r=e.byGroup.get(t);let i=0,o=Math.abs(r[0].x-n.x);for(let e=1;r.length>e;e++){const t=Math.abs(r[e].x-n.x);o>t&&(o=t,i=e)}return r[i]._flatIndex}function Ra(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=xn(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,r=Array.isArray(e.datum)?e.datum:[],i=e.group??"_default";for(let n=0;e.path.length>n&&r.length>n;n++)t.push({x:e.path[n][0],y:e.path[n][1],datum:r[n],shape:"circle",group:i});break}case"area":{const e=n,r=Array.isArray(e.datum)?e.datum:[],i=e.group??"_default";for(let n=0;e.topPath.length>n&&r.length>n;n++)t.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:r[n],shape:"circle",group:i});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 ja(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}var Ta=require("react/jsx-runtime"),Ea={top:20,right:20,bottom:30,left:40},Da=ko;function Na(e){if(e)return"x"===e.dimension?"pan-y":"y"===e.dimension?"pan-x":"none"}var La=(0,h.memo)((0,h.forwardRef)(function(e,t){const{chartType:n,runtimeMode:r,data:i,chunkThreshold:o,chunkSize:s,xAccessor:a,yAccessor:c,accessorRevision:l,colorAccessor:d,sizeAccessor:f,symbolAccessor:y,symbolMap:p,groupAccessor:g,lineDataAccessor:m,curve:x,normalize:v,baseline:k,stackOrder:S,binSize:_,valueAccessor:M,arrowOfTime:C="right",windowMode:R="sliding",windowSize:j=200,timeAccessor:T,xExtent:E,yExtent:D,extentPadding:N=.1,scalePadding:L,sizeRange:I,size:W=[500,300],responsiveWidth:$,responsiveHeight:z,margin:O,className:F,background:B,renderMode:Y,lineStyle:H,pointStyle:X,areaStyle:q,barStyle:G,waterfallStyle:V,swarmStyle:U,barColors:K,colorScheme:Q,boundsAccessor:Z,boundsStyle:J,y0Accessor:ee,band:te,gradientFill:ne,lineGradient:re,areaGroups:ie,openAccessor:oe,highAccessor:se,lowAccessor:ae,closeAccessor:ce,candlestickStyle:le,showAxes:ue=!0,axes:he,xLabel:de,yLabel:fe,yLabelRight:ye,xFormat:pe,yFormat:ge,axisExtent:me,tickFormatTime:xe,tickFormatValue:ve,hoverAnnotation:be,tooltipContent:ke,customHoverBehavior:we,customClickBehavior:Ae,onObservation:Se,annotationObservationCallback:_e,chartId:Me,enableHover:Ce,hoverRadius:Pe=30,tooltipMode:Re,annotations:je,onAnnotationActivate:Te,autoPlaceAnnotations:Ee,svgAnnotationRules:De,showGrid:Ne,legend:Le,legendHoverBehavior:Ie,legendClickBehavior:We,legendHighlightedCategory:$e,legendIsolatedCategories:ze,legendPosition:Oe,legendLayout:Fe,legendCategoryAccessor:Ye,onCategoriesChange:He,backgroundGraphics:Xe,foregroundGraphics:qe,canvasPreRenderers:Ge,svgPreRenderers:Ve,title:Ue,categoryAccessor:Qe,brush:Ze,onBrush:Je,decay:et,pulse:tt,transition:nt,animate:rt,staleness:it,frameScheduler:ot,clock:st,random:at,seed:ct,paused:lt=!1,suspendWhenHidden:ut=!0,heatmapAggregation:ht,heatmapXBins:dt,heatmapYBins:ft,showValues:yt,heatmapValueFormat:pt,marginalGraphics:gt,pointIdAccessor:mt,xScaleType:xt,yScaleType:vt,accessibleTable:bt=!0,description:kt,summary:wt,linkedCrosshairName:At,linkedCrosshairSourceId:St,customLayout:_t,onLayoutError:Mt,layoutConfig:Ct,layoutSelection:Pt}=e,{customHoverBehavior:Rt,customClickBehavior:jt,hasClickBehavior:Tt}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:r,chartType:i}){return{customHoverBehavior:(0,Aa.useCallback)((t,o)=>{e?.(t,o),ka({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:i,chartId:r,context:o})},[r,i,e,n]),customClickBehavior:(0,Aa.useCallback)((e,o)=>{t?.(e,o),wa({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:i,chartId:r,context:o})},[r,i,t,n]),hasClickBehavior:!(!t&&!n)}}({customHoverBehavior:we,customClickBehavior:Ae,onObservation:Se,chartId:Me,chartType:"StreamXYFrame"}),Et=(0,h.useId)().replace(/:/g,""),Dt=(0,h.useRef)(!1),Nt=(0,h.useRef)({w:-1,h:-1}),Lt=(0,h.useRef)(!1),It=Ms({sizeProp:W,responsiveWidth:$,responsiveHeight:z,userMargin:O,marginDefault:Ea,title:Ue,legend:Le,legendPosition:Oe,animate:rt,transitionProp:nt,frameScheduler:ot,clock:st,random:at,seed:ct,paused:lt,suspendWhenHidden:ut,themeDirtyRef:Dt}),Wt=lo(),$t=yo(),{reducedMotionRef:Ot,responsiveRef:Ft,size:Bt,currentTheme:Yt,transition:Ht,introEnabled:Xt,tableId:qt,rafRef:Ut,renderFnRef:Qt,scheduleRender:Zt,frameRuntime:Jt}=It;let en=It.margin;if(gt){const e=60,t={...It.margin};gt.top&&e>t.top&&(t.top=e),gt.bottom&&e>t.bottom&&(t.bottom=e),gt.left&&e>t.left&&(t.left=e),gt.right&&e>t.right&&(t.right=e),en=t}const nn=Bt[0]-en.left-en.right,sn=Bt[1]-en.top-en.bottom,an=(0,h.useMemo)(()=>w(i),[i]),cn=be??Ce,[ln,un]=(0,h.useState)(0),hn=(0,h.useRef)(0),[dn,fn]=(0,h.useState)(null),yn=Ts(qe,Bt,en,dn),pn=Ts(Xe,Bt,en,dn),gn=(0,h.useRef)(null),mn=(0,h.useRef)(null),xn=(0,h.useRef)(void 0),[vn,bn]=(0,h.useState)(null),kn=(0,h.useRef)(Da.primary),wn=(0,h.useRef)(function(){let e=-1,t=ko;return{resolve(n){if(!n)return ko;const r=An;return r===e||(t=function(e){if(!e)return ko;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),r=t.getPropertyValue("--semiotic-text-secondary").trim(),i=t.getPropertyValue("--semiotic-bg").trim(),o=t.getPropertyValue("--semiotic-primary").trim(),s=r||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),c=n||t.getPropertyValue("--surface-3").trim(),l=i||t.getPropertyValue("--surface-0").trim();return s||a||n||o?{axisStroke:c||ko.axisStroke,tickText:s||ko.tickText,crosshair:s?wo(s,"66"):ko.crosshair,hoverFill:l?wo(l,"4D"):ko.hoverFill,hoverStroke:s?wo(s,"99"):ko.hoverStroke,pointRing:l||ko.pointRing,primary:o||ko.primary,background:l||ko.background}:ko}(n),e=r),t},invalidate(){e=-1}}}()),Sn=(0,h.useRef)(!1),_n=Gt("StreamXYFrame"),[Mn,Cn]=(0,h.useState)(!1),[Pn,Rn]=(0,h.useState)([]),[Tn,En]=(0,h.useState)([]),Nn="streaming"===r||["bar","swarm","waterfall"].includes(n),Ln=go((0,h.useMemo)(()=>({chartType:n,runtimeMode:Nn?"streaming":"bounded",windowSize:j,windowMode:R,arrowOfTime:Nn?C:"right",extentPadding:N,scalePadding:L,axisExtent:me,xAccessor:a,yAccessor:c,accessorRevision:l,timeAccessor:Nn?T:void 0,valueAccessor:M,colorAccessor:d,sizeAccessor:f,symbolAccessor:y,symbolMap:p,groupAccessor:g||(m?"_lineGroup":void 0),categoryAccessor:Qe,lineDataAccessor:m,xScaleType:xt,yScaleType:vt,xExtent:E,yExtent:D,sizeRange:I,binSize:_,normalize:v,baseline:k,stackOrder:S,boundsAccessor:Z,boundsStyle:J,y0Accessor:ee,band:te,gradientFill:!0===ne?{topOpacity:.8,bottomOpacity:.05}:!1===ne?void 0:ne,areaGroups:ie?new Set(ie):void 0,lineGradient:re,openAccessor:oe,highAccessor:se,lowAccessor:ae,closeAccessor:ce,candlestickStyle:le,lineStyle:H,pointStyle:X,areaStyle:q,swarmStyle:U,waterfallStyle:V,colorScheme:Q,barColors:K,barStyle:G,annotations:je,decay:et,pulse:tt,transition:Ht,introAnimation:Xt,staleness:it,clock:Jt.now,heatmapAggregation:ht,heatmapXBins:dt,heatmapYBins:ft,showValues:yt,heatmapValueFormat:pt,pointIdAccessor:mt,curve:x,themeCategorical:Yt?.colors?.categorical,themeSemantic:P(Yt),themeSequential:Yt?.colors?.sequential,themeDiverging:Yt?.colors?.diverging,customLayout:_t,onLayoutError:Mt,layoutConfig:Ct,layoutMargin:en}),[n,Nn,j,R,C,N,L,me,a,c,l,T,M,d,f,y,p,g,m,Qe,xt,vt,E,D,I,_,v,k,S,Z,J,ee,te,ne,ie,re,oe,se,ae,ce,le,H,X,q,U,V,Q,K,G,je,et,tt,Ht,Xt,it,Jt.now,ht,dt,ft,yt,pt,mt,x,Yt,_t,Mt,Ct,en])),In=(0,h.useRef)(null);In.current||(In.current=new zt(Ln));const Wn=function(e,t,n,r){const i=(0,Ns.useRef)({accessor:t,onChange:n,readData:r}),o=(0,Ns.useRef)([]);return i.current={accessor:t,onChange:n,readData:r},(0,Ns.useCallback)(()=>{const{accessor:t,onChange:n,readData:r}=i.current;if(!n||!t)return;const s=function(e,t){if(!t)return[];const n=new Set,r=[];for(const i of e){if(!i||"object"!=typeof i)continue;const e="function"==typeof t?t(i):i[t];if(null==e)continue;const o=e+"";n.has(o)||(n.add(o),r.push(o))}return r}(e.current?r(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})(s,o.current)||(o.current=s,n(s))},[e])}(In,Ye,He,e=>e.getData());rn(In,Ln,Dt,Zt),on(In,Pt,Dt,Zt);const $n=(0,h.useRef)(null);$n.current||($n.current=new A(e=>{const t=In.current;t&&t.ingest(e)&&(Dt.current=!0,Zt())},{chunkThreshold:o,chunkSize:s})),(0,h.useEffect)(()=>{$n.current?.updateChunkOptions({chunkThreshold:o,chunkSize:s})},[o,s]);const zn=(0,h.useCallback)(e=>{$n.current?.push(e)},[]),On=(0,h.useCallback)(e=>{$n.current?.pushMany(e)},[]),Fn=(0,h.useCallback)(()=>{$n.current?.clear(),In.current?.clear(),Dt.current=!0,Zt()},[Zt]);(0,h.useImperativeHandle)(t,()=>({push:zn,pushMany:On,remove:e=>{$n.current?.flush();const t=In.current?.remove(e)??[];return t.length>0&&(gn.current&&t.some(e=>e===gn.current?.data)&&(gn.current=null,bn(null)),Dt.current=!0,Zt()),t},update:(e,t)=>{$n.current?.flush();const n=In.current?.update(e,t)??[];return n.length>0&&(Dt.current=!0,Zt()),n},clear:Fn,getData:()=>($n.current?.flush(),In.current?.getData()??[]),getScales:()=>In.current?.scales??null,getExtents:()=>In.current?.getExtents()??null,getCustomLayout:()=>In.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>In.current?.lastCustomLayoutFailure??null}),[zn,On,Fn,Zt]),(0,h.useEffect)(()=>{if(i){if(m&&an.length>0&&"object"==typeof an[0]&&null!==an[0]){const e="string"==typeof m?m:"coordinates";if(Array.isArray(an[0][e])){const t=[];for(const n of an){const r=n[e];if(Array.isArray(r)){const e=n.label||n.id||n.key;if(null!=e)for(const n of r)t.push({...n,_lineGroup:e});else for(const e of r)t.push(e)}}return void $n.current?.setBoundedData(t)}}$n.current?.setBoundedData(an)}},[i,an,m]);const{canvasRef:Xn,interactionCanvasRef:qn}=Rs(It,{storeRef:In,dirtyRef:Dt,hydrated:Wt,wasHydratingFromSSR:$t,cleanup:()=>$n.current?.clear(),canvasPaintDependencies:[n,nn,sn,ue,B,Xe,H,Y,Ge,Zt]}),{hoverHandlerRef:Gn,hoverLeaveRef:Vn,onPointerMove:Un,onPointerLeave:Kn}=It;Gn.current=e=>{if(!cn)return;const t=Xn.current;if(!t)return;const r=t.getBoundingClientRect(),i=e.clientX-r.left-en.left,o=e.clientY-r.top-en.top;if(0>i||i>nn||0>o||o>sn)return void(gn.current&&(gn.current=null,mn.current=null,bn(null),Rt&&(Rt(null),Dt.current=!0),Zt()));const s=In.current;if(!s||0===s.scene.length)return;const c=rs(Pe,e.pointerType),l=Yn(s.scene,i,o,c,s.quadtree,s.maxPointRadius),u="multi"===Re,h=()=>{gn.current&&(gn.current=null,mn.current=null,bn(null),Rt&&Rt(null),Zt())};if(!l&&!u)return void h();const d=u||!l?i:l.x,f=u||!l?o:l.y,y=l?.datum?Be(l.datum,s.resolvedRibbons):{},p=s.scales?.x?.invert,g="function"==typeof p?p(d):void 0;let m=os(y,d,f,null!=g?{xValue:g,xPx:d}:void 0);if(u&&s.scene.length>0&&s.scales){const e=function(e,t,n=30){const r=[];for(const i of e)if("line"===i.type){const e=i;if(2>e.path.length)continue;const o=Hn(Bn(e.path,e.curve),t,n);if(null===o)continue;const s=er(e.path,t);r.push({node:i,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:e.path[s][0],y:o,group:e.group,color:e.style.stroke})}else if("area"===i.type){const e=i;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const o=Bn(e.topPath,e.curve),s=Bn(e.bottomPath,e.curve),a=Hn(o,t,n);if(null===a)continue;const c=Hn(s,t,n),l=er(e.topPath,t);r.push({node:i,datum:Array.isArray(e.datum)&&e.datum[l]?e.datum[l]:e.datum,x:e.topPath[l][0],y:a,y0:c??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 r}(s.scene,d,Math.max(c,nn));if(e.length>0){const t=s.scales.y.invert,r=kn.current,i=p?p(d):d;if(l)m.xValue=i,m.xPx=d;else{const e={xValue:i};"string"==typeof a&&(e[a]=i),m=os(e,d,f,{xValue:i,xPx:d})}m.allSeries=e.map(e=>{const i=t?t(e.y):e.y,o=null!=e.y0?t?t(e.y0):e.y0:void 0;return{group:e.group||"",value:"stackedarea"===n&&null!=o?i-o:i,valuePx:e.y,color:e.color||r,datum:Be(e.datum,s.resolvedRibbons)}})}}l||m.allSeries?.length?(gn.current=m,mn.current=l?.node??null,bn(m),Rt&&(Rt(m),Dt.current=!0),Zt()):h()},Vn.current=()=>{gn.current&&(gn.current=null,mn.current=null,bn(null),Rt&&(Rt(null),Dt.current=!0),Zt())};const Qn=(0,h.useRef)(()=>{});Qn.current=e=>{if(ii(e.target))return;if(!jt)return;const t=Xn.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-en.left,i=e.clientY-n.top-en.top;if(0>r||r>nn||0>i||i>sn)return void jt(null);const o=In.current;if(!o||0===o.scene.length)return void jt(null);const s=rs(Pe,xn.current),a=Yn(o.scene,r,i,s,o.quadtree,o.maxPointRadius);if(!a)return void jt(null);const c=a.datum||{},l=o.scales?.x?.invert,u="function"==typeof l?l(a.x):void 0;jt(os(c,a.x,a.y,null!=u?{xValue:u,xPx:a.x}:void 0),{type:"activate",inputType:va(xn.current)})};const Zn=(0,h.useCallback)(e=>Qn.current(e),[]),{kbFocusIndexRef:Jn,focusedNavPointRef:tr,onKeyDown:nr}=(lr={storeRef:In,hoverRef:gn,hoveredNodeRef:mn,setHoverPoint:bn,customHoverBehavior:Rt,customClickBehavior:jt,scheduleRender:Zt},function({storeRef:e,hoverRef:t,hoveredNodeRef:n,setHoverPoint:r,customHoverBehavior:i,customClickBehavior:o,scheduleRender:s,extractPoints:a,toHover:c}){const l=(0,Sa.useRef)(-1),u=(0,Sa.useRef)(null),h=(0,Sa.useRef)(null),d=(0,Sa.useCallback)(d=>{if(ba(d))return;const f=e.current;if(!f)return;const y=()=>{l.current=-1,u.current=null,t.current=null,n&&(n.current=null),r(null),i(null),s()};if(0===f.scene.length)return void(0>l.current||y());let p;if(h.current?.version===f.version)p=h.current.graph;else{const e=a(f.scene);if(0===e.length)return void(0>l.current||y());p=_a(e),h.current={version:f.version,graph:p}}let g=l.current;if(p.flat.length>g||(y(),g=-1),("Enter"===d.key||" "===d.key)&&g>=0)return d.preventDefault(),void o(c(p.flat[g],f),{type:"activate",inputType:"keyboard"});if(0>g){if("Escape"===d.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(d.key))return;d.preventDefault(),l.current=0;const e=p.flat[0];u.current=e;const n=c(e,f);return t.current=n,r(n),i(n,{type:"focus",inputType:"keyboard"}),void s()}const m=Ca(d.key,Ma(p,g),p);if(null===m)return;if(d.preventDefault(),0>m)return void y();l.current=m;const x=p.flat[m];u.current=x;const v=c(x,f);t.current=v,r(v),i(v,{type:"focus",inputType:"keyboard"}),s()},[o,i,a,t,n,s,r,e,c]);return{kbFocusIndexRef:l,focusedNavPointRef:u,onKeyDown:d}}({...lr,extractPoints:Ra,toHover:(e,t)=>function(e){return{data:e.datum||{},x:e.x,y:e.y,__semioticHoverData:!0}}({...e,datum:Be(e.datum,t.resolvedRibbons)})})),rr=(0,h.useCallback)(e=>{xn.current=e.pointerType,Jn.current=-1,tr.current=null,Un(e)},[tr,Jn,Un]),sr=(0,h.useCallback)(e=>{xn.current="mouse",Jn.current=-1,tr.current=null,Un({clientX:e.clientX,clientY:e.clientY,pointerType:"mouse"})},[tr,Jn,Un]),cr=(0,h.useCallback)(e=>{xn.current=e.pointerType},[]);var lr;Qt.current=()=>{if(Ut.current=null,!Jt.isActive)return;const e=Xn.current,t=qn.current;if(!e||!t)return;const r=In.current;if(!r)return;const i=Jt.now(),o=r.advanceTransition(Ot.current?i+1e6:i),s=!Ot.current&&o,l=Nt.current.w!==nn||Nt.current.h!==sn,u=Dt.current||o||l,h=r.consumeStylePaintPending();let d=!1;const f=r.getLastUpdateResult(),y=_n.current.beforeCompute(f,s);!u||s&&!l||(r.computeScene({width:nn,height:sn}),Nt.current={w:nn,h:sn},d=!0,Wn()),_n.current.afterCompute(y,d,l);const p=function(e,t,n,r){const i=r.current,o=!0===e.lastCustomLayoutFailure?.preservedLastGoodScene,s=!o&&e.hasActivePulsesAt(t),a=!(n||o||!s&&!i)&&e.refreshPulse(t);return r.current=s,{changed:a,pending:s}}(r,i,d,Lt),g=Ds(),m=wn.current.resolve(e);kn.current=m.primary;const x=ir(it,r.lastIngestTime>0?i-r.lastIngestTime:0),v=it&&x.isStale;if(u||h||p.changed){const t=Es(e,Bt,en,g);if(t){if(t.clearRect(-en.left,-en.top,Bt[0],Bt[1]),it&&1>x.alpha&&(t.globalAlpha=x.alpha),bo(t,{background:B,hasBackgroundGraphics:!!Xe,themeBackground:m.background,x:-en.left,y:-en.top,width:Bt[0],height:Bt[1]}),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,nn,sn),t.clip()),Ge&&r.scales)for(const e of Ge)t.save(),e(t,r.scene,r.scales,{width:nn,height:sn}),t.restore();const e=_t?ua.custom:ua[n];ya({context:t,nodes:r.scene,renderMode:Y,pixelRatio:g,paintBuiltIn:n=>{if(e&&r.scales)for(const i of e)i(t,n,r.scales,{width:nn,height:sn})}}),t.restore(),it&&1>x.alpha&&(t.globalAlpha=1)}}const b=!!(cn&&gn.current&&r.scales),k=!!(mn.current&&Array.isArray(be)&&be.some(e=>e&&"object"==typeof e&&"highlight"===e.type)),w=b||k;if(w||Sn.current){const e=Es(t,Bt,en,g);if(e&&(e.clearRect(-en.left,-en.top,Bt[0],Bt[1]),b&&gn.current&&function(e,t,n,r,i,o,s){if(!1===i.crosshair)return;const a=t.allSeries,c=a&&a.length>0,l=t.xPx??t.x;e.save();const u="object"==typeof i.crosshair?i.crosshair:{};if(e.strokeStyle=u.stroke||s.crosshair,e.lineWidth=u.strokeWidth||1,e.setLineDash(u.strokeDasharray?u.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(c?l:t.x,0),e.lineTo(c?l:t.x,r),e.stroke(),c||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),c){e.lineWidth=2,e.strokeStyle=s.pointRing;for(const t of a)null!=t.valuePx&&(e.beginPath(),e.arc(l,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||s.primary,e.fill(),e.stroke())}else{const n=i.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}(o)||s.primary;e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=n,e.fill(),e.strokeStyle=s.pointRing,e.lineWidth=2,e.stroke()}}(e,gn.current,nn,sn,"object"==typeof cn?cn:{},mn.current,m),k&&mn.current&&Array.isArray(be))){const t=be.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,r,i){if(!n)return;const o="group"in n?n.group:void 0;if(void 0!==o)for(const n of t){if("line"!==n.type)continue;if(n.group!==o)continue;if(2>n.path.length)continue;const t="function"==typeof r.style?n.datum?r.style(n.datum):{}:r.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||i.primary,e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=t.opacity??1,e.stroke(),e.restore()}}(e,r.scene,mn.current,t,m)}Sn.current=w}u&&e&&e.setAttribute("aria-label",No(r.scene,n+" chart"));const A=Dt.current;if(Dt.current=A&&s&&!d,A&&r.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!dn||e(dn.x.domain()[0])!==e(r.scales.x.domain()[0])||e(dn.x.domain()[1])!==e(r.scales.x.domain()[1])||e(dn.y.domain()[0])!==e(r.scales.y.domain()[0])||e(dn.y.domain()[1])!==e(r.scales.y.domain()[1])||dn.x.range()[0]!==r.scales.x.range()[0]||dn.x.range()[1]!==r.scales.x.range()[1]||dn.y.range()[0]!==r.scales.y.range()[0]||dn.y.range()[1]!==r.scales.y.range()[1])&&fn(r.scales),gt){const e=r.getData(),t="function"==typeof a?a:e=>e[a||"x"],n="function"==typeof c?c:e=>e[c||"y"];Rn(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),En(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}!((je&&je.length>0||_t)&&(d||s))||!d&&33>i-hn.current||(un(e=>e+1),hn.current=i),it?.showBadge&&Cn(!!v),(s||null!=r.activeTransition||p.pending)&&Zt()},or(it,In,Dt,Zt,Mn,Cn);const ur=(0,h.useMemo)(()=>{if(pe||xe)return;const e=In.current;return e?.xIsDate&&dn?$s(dn.x.domain()):void 0},[pe,xe,dn]),hr=pe||xe||ur,dr=cn&&vn?ke?ke(vn):(0,Ta.jsx)(xa,{hover:vn}):null,fr=dr?(0,Ta.jsx)(ys,{x:vn.x,y:vn.y,containerWidth:nn,containerHeight:sn,margin:en,className:"stream-frame-tooltip",children:dr}):null,yr=tr.current,pr=(0,Ta.jsx)(ts,{active:Jn.current>=0,hoverPoint:vn,margin:en,size:Bt,shape:yr?.shape,width:yr?.w,height:yr?.h}),gr=Ls(a,T,"__semiotic_resolvedX","__semiotic_resolvedTime"),mr=Ls(c,M,"__semiotic_resolvedY","__semiotic_resolvedValue"),xr=gr.key,vr=mr.key,br=function(e,t,n){return r=>{if(!r||!n||!e.fn&&!t.fn)return r;let i=!1;const o=r.map(n=>{const r=e.fn&&e.key&&!(e.key in n),o=t.fn&&t.key&&!(t.key in n);if(!r&&!o)return n;i=!0;const s={...n};return r&&(s[e.key]=e.fn(n)),o&&(s[t.key]=t.fn(n)),s});return i?o:r}}(gr,mr,je&&je.length>0||!1);if(so||!Wt&&$t){const e=In.current;e&&i&&(e.ingest({inserts:an,bounded:!0}),e.computeScene({width:nn,height:sn}));const t=e?.scene??[],n=e?.scales??null,r=Ts(qe,Bt,en,n),o=Ts(Xe,Bt,en,n),s=hr||(()=>{if(e?.xIsDate&&n)return $s(n.x.domain())})();return(0,Ta.jsxs)("div",{ref:Ft,className:"stream-xy-frame"+(F?" "+F:""),role:"img","aria-label":kt||("string"==typeof Ue?Ue:"XY chart"),style:{position:"relative",width:$?"100%":Bt[0],height:z?"100%":Bt[1]},children:[(0,Ta.jsx)(Qo,{summary:wt}),(0,Ta.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:Bt[0],height:Bt[1],style:{position:"absolute",left:0,top:0},children:[(0,Ta.jsx)("g",{transform:`translate(${en.left},${en.top})`,children:o}),(0,Ta.jsxs)("g",{transform:`translate(${en.left},${en.top})`,children:[B&&(0,Ta.jsx)("rect",{x:0,y:0,width:nn,height:sn,fill:B}),Ve&&n&&Ve.map((e,r)=>(0,Ta.jsx)(u.Fragment,{children:e(t,n,{width:nn,height:sn})},"svgpre-"+r)),t.map((e,t)=>pa({node:e,index:t,renderMode:Y,fallback:()=>function(e,t,n){switch(e.type){case"line":{const n=e;if(0===n.path.length)return null;const r="M"+n.path.map(([e,t])=>`${e},${t}`).join("L");return(0,no.jsx)("path",{d:r,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity},"line-"+t)}case"area":{const r=e;if(0===r.topPath.length)return null;const i=`M${r.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...r.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`,o=`${n?n+"-":""}area-${t}-hatch`,s=jn(r.style.fill)?Dn(r.style.fill,o):void 0,a=s?`url(#${o})`:io(r.style.fill);if(r.clipRect){const e=`${n?n+"-":""}area-clip-${t}`;return(0,no.jsxs)("g",{children:[(0,no.jsxs)("defs",{children:[s,(0,no.jsx)("clipPath",{id:e,children:(0,no.jsx)("rect",{x:r.clipRect.x,y:r.clipRect.y,width:r.clipRect.width,height:r.clipRect.height})})]}),(0,no.jsx)("path",{d:i,fill:a,fillOpacity:r.style.fillOpacity??r.style.opacity??.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,clipPath:`url(#${e})`})]},"area-"+t)}return(0,no.jsxs)(Ji.Fragment,{children:[s&&(0,no.jsx)("defs",{children:s}),(0,no.jsx)("path",{d:i,fill:a,fillOpacity:r.style.fillOpacity??r.style.opacity??.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},"area-"+t)}case"point":{const r=e,i=`${n?n+"-":""}point-${t}-hatch`,o=jn(r.style.fill)?Dn(r.style.fill,i):void 0;return(0,no.jsxs)(Ji.Fragment,{children:[o&&(0,no.jsx)("defs",{children:o}),(0,no.jsx)("circle",{cx:r.x,cy:r.y,r:r.r,fill:o?`url(#${i})`:io(r.style.fill),opacity:r.style.opacity??.8,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},"point-"+t)}case"symbol":return function(e,t){const n=Ke(e.symbolType,e.size,e.path);return(0,no.jsx)("path",{d:n,transform:e.rotation?`translate(${e.x},${e.y}) rotate(${180*e.rotation/Math.PI})`:`translate(${e.x},${e.y})`,fill:e.style.fill?io(e.style.fill):"none",opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"symbol-"+t)}(e,t);case"glyph":return oo(e,e.x,e.y,`${n??""}glyph-${e.pointId??t}`);case"rect":{const r=e,i=`${n?n+"-":""}xyrect-${t}-hatch`,o=jn(r.style.fill)?Dn(r.style.fill,i):void 0;return(0,no.jsxs)(Ji.Fragment,{children:[o&&(0,no.jsx)("defs",{children:o}),(0,no.jsx)("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:o?`url(#${i})`:io(r.style.fill),opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},"rect-"+t)}case"heatcell":{const n=e;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const e=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[r,i,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]}(n.fill),s=.299*r+.587*i+.114*o>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return(0,no.jsxs)("g",{children:[(0,no.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),(0,no.jsx)("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px",children:e})]},"heatcell-"+t)}return(0,no.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill},"heatcell-"+t)}case"candlestick":{const n=e,r=Math.min(n.openY,n.closeY),i=Math.max(Math.abs(n.openY-n.closeY),1),o=n.isUp?n.upColor:n.downColor;return(0,no.jsxs)("g",{children:[(0,no.jsx)("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),(0,no.jsx)("rect",{x:n.x-n.bodyWidth/2,y:r,width:n.bodyWidth,height:i,fill:o,stroke:o,strokeWidth:1})]},"candle-"+t)}default:return null}}(e,t,Et)})).filter(Boolean)]})]}),(0,Ta.jsx)(Zi,{width:nn,height:sn,totalWidth:Bt[0],totalHeight:Bt[1],margin:en,scales:n,showAxes:ue,axes:he,xLabel:de,yLabel:fe,yLabelRight:ye,xFormat:s,yFormat:ge||ve,axisExtent:me,showGrid:Ne,title:Ue,legend:Le,legendHoverBehavior:Ie,legendClickBehavior:We,legendHighlightedCategory:$e,legendIsolatedCategories:ze,legendPosition:Oe,legendLayout:Fe,foregroundGraphics:Kt(r,tn(In.current?.customLayoutOverlays,Pt??null)),marginalGraphics:gt,xValues:[],yValues:[],annotations:je,onAnnotationActivate:Te,onObservation:_e??Se,chartId:Me,chartType:"StreamXYFrame",autoPlaceAnnotations:Ee,svgAnnotationRules:De,annotationFrame:0,xAccessor:xr,yAccessor:vr,annotationData:br(In.current?.getData()),pointNodes:zs(In.current?.scene),curve:"string"==typeof x?x:void 0,linkedCrosshairName:At,linkedCrosshairSourceId:St})]})}return(0,Ta.jsxs)("div",{ref:Ft,className:"stream-xy-frame"+(F?" "+F:""),role:"group","aria-label":kt||("string"==typeof Ue?Ue:"XY chart"),tabIndex:0,style:{position:"relative",width:$?"100%":Bt[0],height:z?"100%":Bt[1],overflow:"visible",touchAction:Na(Ze)},onKeyDown:nr,children:["production"!==process.env.NODE_ENV&&In.current&&(0,Ta.jsx)(Vt,{store:In.current,diagnostics:_n.current}),bt&&(0,Ta.jsx)(Zo,{tableId:qt}),bt&&(0,Ta.jsx)(Uo,{scene:In.current?.scene??[],chartType:n+" chart",tableId:qt,chartTitle:"string"==typeof Ue?Ue:void 0}),(0,Ta.jsx)(Qo,{summary:wt}),(0,Ta.jsx)(Ro,{hoverPoint:vn}),(0,Ta.jsxs)("div",{role:"img","aria-label":kt||("string"==typeof Ue?Ue:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:cn?rr:void 0,onMouseMove:cn?sr:void 0,onPointerLeave:cn?Kn:void 0,onMouseLeave:cn?Kn:void 0,onPointerDown:cn||Tt?cr:void 0,onClick:Tt?Zn:void 0,children:[(0,Ta.jsx)(js,{size:Bt,margin:en,children:pn}),(0,Ta.jsx)(Ui,{width:nn,height:sn,totalWidth:Bt[0],totalHeight:Bt[1],margin:en,scales:dn,showAxes:ue,axes:he,showGrid:Ne,xFormat:hr,yFormat:ge||ve,axisExtent:me}),(0,Ta.jsx)("canvas",{ref:Xn,"aria-label":No(In.current?.scene??[],n+" chart"),style:{position:"absolute",left:0,top:0}}),(0,Ta.jsx)("canvas",{ref:qn,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),(0,Ta.jsx)(Zi,{width:nn,height:sn,totalWidth:Bt[0],totalHeight:Bt[1],margin:en,scales:dn,showAxes:ue,axes:he,xLabel:de,yLabel:fe,yLabelRight:ye,xFormat:hr,yFormat:ge||ve,axisExtent:me,showGrid:Ne,title:Ue,legend:Le,legendHoverBehavior:Ie,legendClickBehavior:We,legendHighlightedCategory:$e,legendIsolatedCategories:ze,legendPosition:Oe,legendLayout:Fe,foregroundGraphics:Kt(yn,tn(In.current?.customLayoutOverlays,Pt??null)),marginalGraphics:gt,xValues:Pn,yValues:Tn,annotations:je,onAnnotationActivate:Te,onObservation:_e??Se,chartId:Me,chartType:"StreamXYFrame",autoPlaceAnnotations:Ee,svgAnnotationRules:De,annotationFrame:ln,xAccessor:xr,yAccessor:vr,annotationData:br(In.current?.getData()),pointNodes:zs(In.current?.scene),curve:"string"==typeof x?x:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==B&&!Xe,linkedCrosshairName:At,linkedCrosshairSourceId:St}),(Ze||Je)&&(0,Ta.jsx)(b,{width:nn,height:sn,totalWidth:Bt[0],totalHeight:Bt[1],margin:en,dimension:Ze?.dimension??"xy",scales:dn,onBrush:Je??(()=>{}),binSize:_,snap:Ze?.snap,binBoundaries:Ze?.binBoundaries??("bar"===n?In.current?.getBinBoundaries():void 0),snapDuring:Ze?.snapDuring,streaming:"streaming"===r}),it?.showBadge&&(0,Ta.jsx)(ar,{isStale:Mn,position:it.badgePosition}),pr,fr]})]})}));La.displayName="StreamXYFrame";var Ia=La,Wa=require("react"),$a={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},za={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1},Oa=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 r=this.particles[n];return r.active=!0,r.t=0,r.offset=t()-.5,r.edgeIndex=e,r.x=0,r.y=0,r}step(e,t,n,r){for(let i=0;this.capacity>i;i++){const o=this.particles[i];if(!o.active)continue;const s=n[o.edgeIndex];s&&s.bezier?(o.t+=e*t*(r?r[o.edgeIndex]??1:1)*(s.bezier.circular?.3:1),1>o.t?Fa(s.bezier,o.t,o.offset,o):(o.active=!1,this._freeIndices.push(i))):(o.active=!1,this._freeIndices.push(i))}}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 Fa(e,t,n,r){if(e.circular&&e.segments)return void function(e,t,n,r,i){const o=e.length,s=t*o,a=Math.min(Math.floor(s),o-1),c=s-a,[l,u,h,d]=e[a];Ba(l,u,h,d,c,i);const f=d.x-l.x,y=d.y-l.y,p=Math.sqrt(f*f+y*y);if(p>.001){const e=f/p;i.x+=-y/p*n*r*2,i.y+=e*n*r*2}}(e.segments,t,n,e.halfWidth,r);if(!e.points)return r.x=0,void(r.y=0);const[i,o,s,a]=e.points;Ba(i,o,s,a,t,r);const c=a.x-i.x,l=a.y-i.y,u=Math.sqrt(c*c+l*l);if(u>.001){const t=c/u;r.x+=-l/u*n*e.halfWidth*2,r.y+=t*n*e.halfWidth*2}}function Ba(e,t,n,r,i,o){const s=1-i,a=s*s,c=a*s,l=i*i,u=l*i;o.x=c*e.x+3*a*i*t.x+3*s*l*n.x+u*r.x,o.y=c*e.y+3*a*i*t.y+3*s*l*n.y+u*r.y}function Ya(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function Ha(e,t){var n,r=[],i=[],o=[],s={},a=[];function c(e){o[e]=!1,s.hasOwnProperty(e)&&Object.keys(s[e]).forEach(function(t){delete s[e][t],o[t]&&c(t)})}function l(e){var t,r,h=!1;for(i.push(e),o[e]=!0,t=0;a[e].length>t;t++)(r=a[e][t])===n?(u(n,i),h=!0):o[r]||(h=l(r));if(h)c(e);else for(t=0;a[e].length>t;t++){var d=s[r=a[e][t]];d||(s[r]=d={}),d[r]=!0}return i.pop(),h}function u(e,n){var i=[].concat(n).concat(e);t?t(i):r.push(i)}function h(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,r=function(e){for(var t=e.length,n=Array(t),r=Array(t),i=Array(t),o=Array(t),s=Array(t),a=Array(t),c=0;t>c;++c)n[c]=-1,r[c]=0,i[c]=!1,o[c]=0,s[c]=-1,a[c]=[];var l,u=0,h=[],d=[];function f(t){var c=[t],l=[t];for(n[t]=r[t]=u,i[t]=!0,u+=1;l.length>0;){var f=e[t=l[l.length-1]];if(f.length>o[t]){for(var y=o[t];f.length>y;++y){var p=f[y];if(0>n[p]){n[p]=r[p]=u,i[p]=!0,u+=1,c.push(p),l.push(p);break}i[p]&&(r[t]=0|Math.min(r[t],r[p])),0>s[p]||a[t].push(s[p])}o[t]=y}else{if(r[t]===n[t]){var g=[],m=[],x=0;for(y=c.length-1;y>=0;--y){var v=c[y];if(i[v]=!1,g.push(v),m.push(a[v]),x+=a[v].length,s[v]=h.length,v===t){c.length=y;break}}h.push(g);var b=Array(x);for(y=0;m.length>y;y++)for(var k=0;m[y].length>k;k++)b[--x]=m[y][k];d.push(b)}l.pop()}}}for(c=0;t>c;++c)0>n[c]&&f(c);for(c=0;d.length>c;c++){var y=d[c];if(0!==y.length){y.sort(function(e,t){return e-t}),l=[y[0]];for(var p=1;y.length>p;p++)y[p]!==y[p-1]&&l.push(y[p]);d[c]=l}}return{components:h,adjacencyList:d}}(e),i=r.components.filter(function(e){return e.length>1}),o=1/0,s=0;i.length>s;s++)for(var a=0;i[s].length>a;a++)o>i[s][a]&&(o=i[s][a],n=s);var c=i[n];return!!c&&{leastVertex:o,adjList:e.map(function(e,t){return-1===c.indexOf(t)?[]:e.filter(function(e){return-1!==c.indexOf(e)})})}}n=0;for(var d=e.length;d>n;){var f=h(n);if(n=f.leastVertex,a=f.adjList){for(var y=0;a.length>y;y++)for(var p=0;a[y].length>p;p++){var g=a[y][p];o[+g]=!1,s[g]={}}l(n),n+=1}else n=d}return t?void 0:r}function Xa(e){return e.y0-e.y1>0?"up":"down"}function qa(e,t){return t(e.source)==t(e.target)}function Ga(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function Va(e){return e.target.x0-e.source.x1}function Ua(e,t){var n=Qa(e),r=Va(t)/Math.tan(n);return"up"==Xa(e)?e.y1-r:e.y1+r}function Ka(e,t){var n=Qa(e),r=Va(t)/Math.tan(n);return"up"==Xa(e)?e.y1+r:e.y1-r}function Qa(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function Za(e,t){return t(e)}function Ja(e){return tc(e.source)}function ec(e){return tc(e.target)}function tc(e){return(e.y0+e.y1)/2}function nc(e){return e.virtual?0:e.value}function rc(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!qa(e,t)?n+1:n});var r=0;return e.targetLinks.forEach(function(e){r=e.circular&&!qa(e,t)?r+1:r}),n+r}function ic(e){return e.target.depth}function oc(e,t){return e.sourceLinks.length?e.depth:t-1}function sc(e,t){return e.y0-t.y0}function ac(e,t){return t.y0-e.y0}function cc(e,t){return e.y1-t.y1}function lc(e,t){return t.y1-e.y1}function uc(e,t){return dc(e.source,t.source)||e.index-t.index}function hc(e,t){return dc(e.target,t.target)||e.index-t.index}function dc(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function fc(e,t){return yc(e)==yc(t)?"bottom"==e.circularLinkType?ac(e,t):sc(e,t):yc(t)-yc(e)}function yc(e){return e.target.column-e.source.column}function pc(e,t){return gc(e)==gc(t)}function gc(e){return e.y0-e.y1>0?"up":"down"}var mc=require("d3-array");function xc(e,t,n,r,i){let o=e;var s=Math.max(8,.15*(o.y1-o.y0));o.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var a=(0,mc.min)(o.links,function(e){return e.source.y0});o.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=o.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),vc(o.links.filter(function(e){return"top"==e.circularLinkType}),t,n),vc(o.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),o.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+r,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,qa(e,t)&&Ga(e))e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var s=e.source.column,c=e.circularLinkType,l=o.links.filter(function(e){return e.source.column==s&&e.circularLinkType==c});l.sort("bottom"==e.circularLinkType?ac:sc);var u=0;l.forEach(function(t,i){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2+i*n+u),u+=t._circularWidth||t.width}),s=e.target.column,(l=o.links.filter(function(e){return e.target.column==s&&e.circularLinkType==c})).sort("bottom"==e.circularLinkType?lc:cc),u=0,l.forEach(function(t,i){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2+i*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(o.y1,e.source.y1,e.target.y1)+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=a-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,n=e.y0,r=e.target.x0,i=e.y1,o=(t+r)/2;return"M"+t+","+n+"C"+o+","+n+" "+o+","+i+" "+r+","+i}(e)}),o}function vc(e,t,n){e.sort(fc);var r=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,i){var o=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(qa(e,t)&&Ga(e))e.circularPathData.verticalBuffer=o+e._circularWidth/2;else{for(var s=0;r.length>s;s++){var a=r[s];if(a!==e&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&bc(e,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;o=c>o?c:o}}e.circularPathData.verticalBuffer=o+e._circularWidth/2}}),e}function bc(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}var kc=require("d3-array");function wc(e){return function(){return e}}function Ac(e){return e.index}function Sc(e){return e.nodes}function _c(e){return e.links}function Mc(e,t,n){var r=(0,kc.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});r.forEach(function(i,o){var s=i.length;if(t)i.sort(t);else if(o>0){var a=new Map;i.forEach(function(e,t){var n,r,i,o=(r=0,i=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;i+=tc(e.source)*t,r+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;i+=tc(e.target)*t,r+=t}}),r>0?i/r:NaN);a.set(e,{bc:o,idx:t})}),i.sort(function(e,t){var n=a.get(e),r=a.get(t),i=n.bc,o=r.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(i)||isNaN(o)?isNaN(i)?isNaN(o)?n.idx-r.idx:1:-1:i-o})}else i.sort(function(e,t){return e.circularLinkType==t.circularLinkType?rc(t,n)-rc(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});i.forEach(function(t,i){t.depth==r.length-1&&1==s||0==t.depth&&1==s?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==rc(t,n)?(t.y0=e.y1/2+i,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+i,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-i,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/s*i,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-s/2+i,t.y1=t.y0+t.value*e.ky)})})}function Cc(e,t,n,r,i,o){var s=(0,kc.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var a=1,c=o;c>0;--c)l(a*=.99,n),u();function l(t,n){var r=s.length;s.forEach(function(i){var o=i.length,s=i[0].depth;i.forEach(function(i){var a;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&rc(i,n)>0){var c=(0,kc.mean)(i.sourceLinks,ec),l=(0,kc.mean)(i.targetLinks,Ja),u=c&&l?(c+l)/2:c||l;if(u){var h=(u-tc(i))*t*.3;i.y0+=h,i.y1+=h}}else if(0==s&&1==o)i.y0=e.y1/2-(a=i.y1-i.y0)/2,i.y1=e.y1/2+a/2;else if(s==r-1&&1==o)i.y0=e.y1/2-(a=i.y1-i.y0)/2,i.y1=e.y1/2+a/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)a=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+a;else{var d=(0,kc.mean)(i.sourceLinks,ec),f=(0,kc.mean)(i.targetLinks,Ja),y=((d&&f?(d+f)/2:d||f)-tc(i))*t;i.y0+=y,i.y1+=y}})})}function u(){s.forEach(function(n){var o,s,a,c=e.y0,l=n.length;for(n.sort(t||dc),a=0;l>a;++a)(s=c-(o=n[a]).y0)>0&&(o.y0+=s,o.y1+=s),c=o.y1+r;if((s=c-r-e.y1)>0)for(c=o.y0-=s,o.y1-=s,a=l-2;a>=0;--a)(s=(o=n[a]).y1+i-c)>0&&(o.y0-=s,o.y1-=s),c=o.y0})}}function Pc(e){e.nodes.forEach(function(e){e.sourceLinks.sort(hc),e.targetLinks.sort(uc)}),e.nodes.forEach(function(e){var t=e.y0,n=t,r=e.y1,i=r;e.sourceLinks.forEach(function(e){e.circular?(e.y0=r-e.width/2,r-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=i-e.width/2,i-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function Rc(){var e=0,t=0,n=1,r=1,i=24,o=8,s=null,a=Ac,c=oc,l=void 0,u=32,h=2,d=Sc,f=_c;function y(){var y={nodes:d.apply(null,arguments),links:f.apply(null,arguments)};return function(d){d.x0=e,d.y0=t,d.x1=n,d.y1=r,d.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return(0,kc.group)(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,i=e.target;"object"!=typeof r&&(r=e.source=Ya(n,r)),"object"!=typeof i&&(i=e.target=Ya(n,i)),r.sourceLinks.push(e),i.targetLinks.push(e)})}(d,a),function(e,t){var n=0;if(null==t){for(var r=[],i=0;e.links.length>i;i++){var o=e.links[i],s=o.source.index,a=o.target.index;r[s]||(r[s]=[]),r[a]||(r[a]=[]),-1===r[s].indexOf(a)&&r[s].push(a)}var c=Ha(r);c.sort(function(e,t){return e.length-t.length});var l={};for(i=0;c.length>i;i++){var u=c[i].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,r=e.source.index;t===r||l[r]&&l[r][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(d,l),function(e,t){var n=0,r=0;e.links.forEach(function(i){i.circular&&(i.circularLinkType=i.source.circularLinkType||i.target.circularLinkType?i.source.circularLinkType?i.source.circularLinkType:i.target.circularLinkType:r>n?"top":"bottom","top"==i.circularLinkType?n++:r++,e.nodes.forEach(function(e){Za(e,t)!=Za(i.source,t)&&Za(e,t)!=Za(i.target,t)||(e.circularLinkType=i.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),qa(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(d,a),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max((0,kc.sum)(e.sourceLinks,nc),(0,kc.sum)(e.targetLinks,nc)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(d),function(e,t,n){var r,i,o;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var s=0,a=t(e.nodes[0]);e.nodes.forEach(function(e){s=t(e)==a?s:s+1,a=t(e)==a?a:t(e),e.column=s})}for(r=e.nodes,i=[],o=0;r.length;++o,r=i,i=[])r.forEach(function(e){e.depth=o,e.sourceLinks.forEach(function(e){0>i.indexOf(e.target)&&!e.circular&&i.push(e.target)})});for(r=e.nodes,i=[],o=0;r.length;++o,r=i,i=[])r.forEach(function(e){e.height=o,e.targetLinks.forEach(function(e){0>i.indexOf(e.source)&&!e.circular&&i.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,o):e.column})}(d,l,c);var f=o;if(null!==s){var y=(0,kc.groups)(d.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),p=(0,kc.max)(y,function(e){return e.length});p>1&&(f=Math.max(1,(r-t)*s/(p-1)))}(function(e,t,n){var r=(0,kc.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var i=(0,kc.min)(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/(0,kc.sum)(t,function(e){return e.value})});e.ky=i,e.links.forEach(function(t){t.width=t.value*e.ky});var o=(0,kc.max)(e.nodes,function(e){return e.column});e.nodes.forEach(o>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/o),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(d,f,i),Mc(d,l,a),Cc(d,l,a,f,f,u),Pc(d),xc(d,a,h,10,8),Mc(d,l,a),Cc(d,l,a,f,f,u),Pc(d),xc(d,a,h,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var r=n.links.filter(function(n){return Za(n.source,t)==Za(e,t)}),i=r.length;i>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!pc(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=Ua(t,e);return e.y1-n}if(t.target.column>e.target.column)return Ua(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var o=e.y0;r.forEach(function(e){e.y0=o+e.width/2,o+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var o=n+1,s=0;i>o;o++)s+=r[o].width;t.y0=e.y1-s-t.width/2}})})}(d,a),function(e,t){let n=e;n.nodes.forEach(function(e){var r=n.links.filter(function(n){return Za(n.target,t)==Za(e,t)}),i=r.length;i>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!pc(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=Ka(t,e);return e.y0-n}if(t.source.column>e.source.column)return Ka(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var o=e.y0;r.forEach(function(e){e.y1=o+e.width/2,o+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var o=n+1,s=0;i>o;o++)s+=r[o].width;t.y1=e.y1-s-t.width/2}})})}(d,a),function(e){var t=e.nodes,n=e.links,r=!1,i=!1;if(n.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(i=!0)}),0==r||0==i){let r=function(t){return(t-o)/(s-o)*(e.y1-e.y0)+e.y0};var o=(0,kc.min)(t,function(e){return e.y0}),s=(0,kc.max)(t,function(e){return e.y1}),a=(e.y1-e.y0)/(s-o);1>a?(t.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1)}),n.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1),e.width=e.width*a})):t.forEach(function(e){var t=e.y1-e.y0,n=r(e.y0)-e.y0;e.y0=r(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(d),xc(d,a,h,10,8)}(y),y}return y.update=function(e){return Pc(e),xc(e,a,h,10,8),e},y.nodeWidth=function(e){return arguments.length?(i=+e,y):i},y.nodePadding=function(e){return arguments.length?(o=+e,y):o},y.nodePaddingRatio=function(e){return arguments.length?(s=+e,y):s},y.nodes=function(e){return arguments.length?(d="function"==typeof e?e:wc(e),y):d},y.links=function(e){return arguments.length?(f="function"==typeof e?e:wc(e),y):f},y.nodeId=function(e){return arguments.length?(a="function"==typeof e?e:wc(e),y):a},y.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:wc(e),y):c},y.nodeSort=function(e){return arguments.length?(l=e,y):l},y.iterations=function(e){return arguments.length?(u=+e,y):u},y.circularLinkGap=function(e){return arguments.length?(h=+e,y):h},y.extent=function(i){return arguments.length?(e=+i[0][0],t=+i[0][1],n=+i[1][0],r=+i[1][1],y):[[e,t],[n,r]]},y.size=function(i){return arguments.length?(e=t=0,n=+i[0],r=+i[1],y):[n-e,r-t]},y}var jc=require("d3-interpolate");require("d3-shape");var Tc=e=>{let t,n,r,i,o,s,a,c,l;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,r=e.y1+e.sankeyWidth/2,i=e.y0+e.sankeyWidth/2,o=e.source.x1,s=e.target.x0,a=(0,jc.interpolateNumber)(o,s),c=a(.5),l=a(.5),`M${t},${o}C${t},${c} ${n},${l} ${n},${s}L${r},${s}C${r},${l} ${i},${c} ${i},${o}Z`;const u=e.sankeyWidth/2,h=(0,jc.interpolateNumber)(e.source.x1,e.target.x0),{pathD:d}=function(e){const{sx:t,sTop:n,sBot:r,tx:i,tTop:o,tBot:s,cp1X:a,cp2X:c}=e,l=(n+r)/2,u=(o+s)/2;return{pathD:[`M${t},${n}`,`C${a},${n} ${c},${o} ${i},${o}`,`L${i},${s}`,`C${c},${s} ${a},${r} ${t},${r}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:l},{x:a,y:l},{x:c,y:u},{x:i,y:u}],halfWidth:(r-n)/2}}}({sx:e.source.x1,sTop:e.y0-u,sBot:e.y0+u,tx:e.target.x0,tTop:e.y1-u,tBot:e.y1+u,cp1X:h(.5),cp2X:h(.5)});return d};function Ec(e){const t=e.sankeyWidth/2,n=(e._circularWidth??e.sankeyWidth)/2,r=e.circularPathData;if(!r)return null;if("down"===e.direction)return null;if(e._circularStub){const n=r.sourceX,i=r.sourceY,o=r.targetX,s=r.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const a=Math.max(15,Math.min(40,.33*(r.rightFullExtent-n))),c=Math.max(15,Math.min(40,.33*(o-r.leftFullExtent)));return`M${n},${i-t}L${n+a},${i-t}L${n+a},${i+t}L${n},${i+t}ZM${o},${s-t}L${o-c},${s-t}L${o-c},${s+t}L${o},${s+t}Z`}const i=r.sourceX,o=r.sourceY,s=r.targetX,a=r.targetY,c=r.rightFullExtent,l=r.leftFullExtent,u=r.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,d=Math.max(4,Math.min(n,15));return`M${i},${o-h*t}L${c},${o-h*t}L${c+n},${o-h*t+h*d}L${c+n},${u+h*n-h*d}L${c+n-d},${u+h*n}L${l-n+d},${u+h*n}L${l-n},${u+h*n-h*d}L${l-n},${a-h*t+h*d}L${l-n+d},${a-h*t}L${s},${a-h*t}L${s},${a+h*t}L${l+n},${a+h*t}L${l+n},${u-h*n}L${c-n},${u-h*n}L${c-n},${o+h*t}L${i},${o+h*t}Z`}var Dc=new Set,Nc=new WeakMap;function Lc(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=Nc.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,Nc.set(e,n);const r=new Proxy(e,{get(e,n,r){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;Dc.has(e)||(Dc.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,n,r)}});return n.set(t,r),r}var Ic={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(ic))-1:0},justify:oc};function Wc(e){return"string"==typeof e?e:e.id}var $c={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const i="vertical"===n.orientation?"down":"right",o=n.nodeAlign||"justify",s=n.nodeWidth??15,a=n.nodePaddingRatio??.05,c=n.iterations??100,l=e.map(e=>({...e})),u=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let h;h="down"===i?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const d=Rc().extent(h).links(u).nodes(l).nodeAlign(Ic[o]||oc).nodeId(e=>e.id).nodeWidth(s).iterations(c);d.nodePaddingRatio&&d.nodePaddingRatio(a),d();{let e=1/0,t=-1/0,n=1/0,i=-1/0;for(const r of l)e>r.x0&&(e=r.x0),r.x1>t&&(t=r.x1),n>r.y0&&(n=r.y0),r.y1>i&&(i=r.y1);for(const r of u){if(!r.circular||!r.circularPathData)continue;const o=r.circularPathData,s=(r._circularWidth??r.width??0)/2;e>o.leftFullExtent-s&&(e=o.leftFullExtent-s),o.rightFullExtent+s>t&&(t=o.rightFullExtent+s),n>o.verticalFullExtent-s&&(n=o.verticalFullExtent-s),o.verticalFullExtent+s>i&&(i=o.verticalFullExtent+s)}const o=t-e,s=i-n,a=r[0],c=r[1];if(o>0&&s>0&&(0>e||0>n||t>a||i>c)){const t=Math.min(a/o,c/s),r=-e*t+(a-o*t)/2,i=-n*t+(c-s*t)/2;for(const e of l)e.x0=e.x0*t+r,e.x1=e.x1*t+r,e.y0=e.y0*t+i,e.y1=e.y1*t+i;for(const e of u)if(e.y0=e.y0*t+i,e.y1=e.y1*t+i,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+r,n.targetX=n.targetX*t+r,n.sourceY=n.sourceY*t+i,n.targetY=n.targetY*t+i,n.rightFullExtent=n.rightFullExtent*t+r,n.leftFullExtent=n.leftFullExtent*t+r,n.verticalFullExtent=n.verticalFullExtent*t+i,n.rightInnerExtent=n.rightInnerExtent*t+r,n.leftInnerExtent=n.leftInnerExtent*t+r,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+i,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+i,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const f=new Map;for(const t of e)f.set(t.id,t);for(const e of l){const t=f.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const y=new Map;for(const e of t)y.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of u){const t=Wc(e.source),n=Wc(e.target),r=y.get(e._edgeKey?e._edgeKey:`${t}\0${n}`);if(r){r.y0=e.y0,r.y1=e.y1,r.sankeyWidth=e.width??0,r.circular=!!e.circular,r.circularPathData=e.circularPathData,r._circularWidth=e._circularWidth,r._circularStub=e._circularStub,r.path=e.path,r.circularLinkType=e.circularLinkType,r.direction=i;const o=f.get(t),s=f.get(n);o&&(r.source=o),s&&(r.target=s)}}},buildScene(e,t,n,r){const i="vertical"===n.orientation?"down":"right",o=n.nodeStyle,s=n.edgeStyle,a=n.edgeOpacity??.5,c=n.edgeColorBy||"source",l=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:K,u=new Map;e.forEach((e,t)=>{u.set(e.id,l[t%l.length])});const h=[],d=[],f=[],y=new Map;for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const r=o?o(Lc(t,"nodeStyle")):{},s={fill:r.fill||u.get(t.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};y.set(t.id,("string"==typeof s.fill?s.fill:null)||u.get(t.id)||"#4d430c"),h.push("down"===i?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:s,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:s,datum:t,id:t.id,label:t.id})}const p=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of p){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let i=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";i="function"==typeof c?c(e)||i:"target"===c?y.get(r.id)||u.get(r.id)||i:y.get(t.id)||u.get(t.id)||i;const o=s?s(Lc(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,r=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),s=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=o.fill||i;d.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+r},${t.sourceY-n}L${t.sourceX+r},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:c,fillOpacity:o.fillOpacity??a,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+r}}),d.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-s},${t.targetY-n}L${t.targetX-s},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:c,fillOpacity:o.fillOpacity??a,stroke:"none",opacity:o.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-s,x1:t.targetX}});continue}let l;(l=e.circular&&e.circularPathData?Ec(e):Tc(e),l)&&d.push({type:"bezier",pathD:l,bezierCache:e.bezier,style:{fill:o.fill||i,fillOpacity:o.fillOpacity??a,stroke:o.stroke||"none",strokeWidth:o.strokeWidth,opacity:o.opacity},datum:e})}if(!1!==n.showLabels){const t=(g=n.nodeLabel)?"function"==typeof g?g:e=>e[g]||e.id:null;for(const n of e){const e=n.x1-n.x0,o=n.y1-n.y0;if(0>=e||0>=o)continue;const s=t?t(n):n.id;if(!s)continue;let a,c,l;"down"===i?(a=n.y0+(n.y1-n.y0)/2,c=n.x1+14,l="start"):(r[0]/2>n.x0+e/2?(a=n.x0-6,l="end"):(a=n.x1+6,l="start"),c=n.y0+o/2),f.push({x:a,y:c,text:s+"",anchor:"down"===i?"middle":l,baseline:"middle",fontSize:11})}}var g;return{sceneNodes:h,sceneEdges:d,labels:f}}},zc=require("d3-force"),Oc=require("d3-scale"),Fc={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const i=n.forceStrength??.1,o=r[0]/2,s=r[1]/2,a=n.__previousPositions;let c=0;const l=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=a?.get(t.id);e?c++:n?(t.x=n.x,t.y=n.y,c++):l.push(t)}const u=c>0&&.3>=(e.length>0?l.length/e.length:1);if(u){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of l){const r=Bc(e.id,t,n);if(r.length>0){let t=0,n=0;for(const e of r)t+=e.x,n+=e.y;const i=Yc(e.id),o=i%360*(Math.PI/180),s=10+i%20;e.x=t/r.length+s*Math.cos(o),e.y=n/r.length+s*Math.sin(o)}else{const t=Yc(e.id),n=t%360*(Math.PI/180),r=15+t%30;e.x=o+r*Math.cos(n),e.y=s+r*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const r=e[n];if(null==r.x||null==r.y||0===r.x&&0===r.y){const e=10*Math.sqrt(n+.5),i=n*t;r.x=o+e*Math.cos(i),r.y=s+e*Math.sin(i)}}}const h=n.__skipForceSimulation||0===n.iterations?0:u?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),d=Hc(n.nodeSize,n.nodeSizeRange,e),f=e=>d(e);if(h>0){const r=new Map,a=new Map;for(const t of e)r.set(t.id,0),a.set(t.id,t);for(const e of t){const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id;r.set(t,(r.get(t)??0)+1),r.set(n,(r.get(n)??0)+1)}const c=(0,zc.forceLink)().strength(e=>{const t=e.weight,n="string"==typeof e.target?e.target:e.target.id,o=Math.max(1,Math.min(r.get("string"==typeof e.source?e.source:e.source.id)??1,r.get(n)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*i/(.1*o))}).distance(e=>{const t="string"==typeof e.source?a.get(e.source):e.source,n="string"==typeof e.target?a.get(e.target):e.target,r=(t?f(t):0)+(n?f(n):0)+12;return Math.max(40,r)}).id(e=>e.id),l=(0,zc.forceSimulation)();if(void 0===n.random&&void 0===n.seed||l.randomSource(n.random??bs(n.seed)),l.force("charge",(0,zc.forceManyBody)().strength(e=>{const t=r.get(e.id)??0;return-15*f(e)*Math.sqrt(t+1)})).force("collide",(0,zc.forceCollide)(e=>f(e)+3).strength(.9).iterations(2)).force("center",(0,zc.forceCenter)(o,s).strength(.8)).force("x",(0,zc.forceX)(o).strength(.06)).force("y",(0,zc.forceY)(s).strength(.06)),l.nodes(e),t.length>0){const e=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));c.links(e),l.force("link",c)}u?l.alpha(.3):.1>l.alpha()&&l.alpha(1),l.stop();for(let e=0;h>e;++e)l.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=f(t);t.x=Math.max(e,Math.min(r[0]-e,t.x)),t.y=Math.max(e,Math.min(r[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const y=new Map;for(const t of e)y.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=y.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=y.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,r){const i=n.nodeStyle,o=n.edgeStyle,s=Hc(n.nodeSize,n.nodeSizeRange,e),a=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:K,c=new Map;e.forEach((e,t)=>{c.set(e.id,a[t%a.length])});const l=[],u=[],h=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=s(Lc(t,"nodeSize")),r=i?i(Lc(t,"nodeStyle")):{},o={fill:r.fill||c.get(t.id)||n.themeSemantic?.primary||"#007bff",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??2,opacity:r.opacity};l.push({type:"circle",cx:t.x,cy:t.y,r:e,style:o,datum:t,id:t.id,label:t.id})}const d=new Map;for(const t of e)d.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:d.get(e.source),r="object"==typeof e.target?e.target:d.get(e.target);if(!t||!r)continue;if(null==t.x||null==t.y)continue;if(null==r.x||null==r.y)continue;const i=o?o(Lc(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:i.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:i.strokeWidth??1,opacity:i.opacity??.6},datum:e})}if(!1!==n.showLabels){const t=(f=n.nodeLabel)?"function"==typeof f?f:e=>e[f]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const r=s(Lc(n,"nodeSize"));h.push({x:n.x,y:n.y-r-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var f;return{sceneNodes:l,sceneEdges:u,labels:h}}};function Bc(e,t,n){const r=[];for(const i of t){const t="string"==typeof i.source?i.source:i.source.id,o="string"==typeof i.target?i.target:i.target.id;let s=null;if(t===e?s=o:o===e&&(s=t),s){const e=n.get(s);!e||0===e.x&&0===e.y||r.push({x:e.x,y:e.y})}}return r}function Yc(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function Hc(e,t,n){if(n.some(e=>null!=e.__forceRadius))return e=>e.__forceRadius??8;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const r=t||[5,20],i=[];for(const t of n){const n=t.data?.[e];"number"==typeof n&&i.push(n)}if(0===i.length)return()=>r[0];const[o,s]=Ar(i);if(o===s)return()=>(r[0]+r[1])/2;const a=(0,Oc.scaleLinear)().domain([o,s]).range(r).clamp(!0);return t=>{const n=t.data?.[e];return null==n||"number"!=typeof n?r[0]:a(n)}}var Xc=require("d3-chord"),qc=require("d3-shape"),Gc=K,Vc={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const{padAngle:i=.01,groupWidth:o=20,sortGroups:s}=n,a=Math.min(r[0],r[1])/2,c=a-o,l=r[0]/2,u=r[1]/2,h=(d=n.valueAccessor)?"function"==typeof d?d:e=>e[d]??1:e=>e.value??1;var d;const f=new Map;for(let t=0;e.length>t;t++)f.set(e[t].id,t);const y=e.length,p=Array.from({length:y},()=>Array.from({length:y},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=f.get("string"==typeof e.source?e.source:e.source.id),r=f.get(t);if(void 0===n||void 0===r)continue;const i=h(e);p[n][r]=i}const g=(0,Xc.chord)().padAngle(i);s&&g.sortGroups(s);const m=g(p),x=m.groups,v=(0,qc.arc)().innerRadius(c).outerRadius(a);for(const t of x){const n=e[t.index],r=v.centroid({innerRadius:c,outerRadius:a,startAngle:t.startAngle,endAngle:t.endAngle});n.x=r[0]+l,n.y=r[1]+u,n.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const b=new Map;for(const t of e)b.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=b.get("string"==typeof e.source?e.source:e.source.id),r=b.get(t);n&&(e.source=n),r&&(e.target=r)}const k=new Map;for(const e of t)k.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of m){const n=e[t.source.index].id,r=e[t.target.index].id,i=k.get(`${n}\0${r}`)||k.get(`${r}\0${n}`);i&&(i.__chordData=t)}},buildScene(e,t,n,r){const{groupWidth:i=20,edgeOpacity:o=.5}=n,s=Math.min(r[0],r[1])/2,a=s-i,c=r[0]/2,l=r[1]/2,u=n.nodeStyle,h=n.edgeStyle,d=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Gc,y=new Map;e.forEach((e,t)=>{y.set(e.id,f[t%f.length])});const p=(0,Xc.ribbon)().radius(a),g=[],m=[],x=[];for(let t=0;e.length>t;t++){const n=e[t],r=n.__arcData;if(!r)continue;let i;i=u?u(Lc(n,"nodeStyle")).fill||y.get(n.id)||f[t%f.length]:y.get(n.id)||f[t%f.length];const o=u?u(Lc(n,"nodeStyle")):{};g.push({type:"arc",cx:c,cy:l,innerR:a,outerR:s,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:{fill:i,stroke:o.stroke||"black",strokeWidth:o.strokeWidth??1,opacity:o.opacity},datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const r=p(t);if(!r)continue;const i=Uc(r,c,l);let s=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(h)s=h(Lc(e,"edgeStyle")).fill||s;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===d&&n?s=y.get(n.id)||s:t&&(s=y.get(t.id)||s)}const a=h?h(Lc(e,"edgeStyle")):{};m.push({type:"ribbon",pathD:i,style:{fill:s,fillOpacity:a.fillOpacity??o,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity},datum:e})}if(!1!==n.showLabels){const t=(v=n.nodeLabel)?"function"==typeof v?v:e=>e[v]||e.id:null,r=s+12;for(const n of e){const e=n.__arcData;if(!e)continue;const i=t?t(n):n.id;if(!i)continue;const o=(e.startAngle+e.endAngle)/2,s=o-Math.PI/2;x.push({x:c+Math.cos(s)*r,y:l+Math.sin(s)*r,text:i+"",anchor:o>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var v;return{sceneNodes:g,sceneEdges:m,labels:x}}};function Uc(e,t,n){const r=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return e;const i=[];let o=0;for(;r.length>o;){const e=r[o];if("M"===e||"L"===e)for(i.push(e),o++;r.length>o&&!isNaN(Number(r[o]));)i.push(Number(r[o])+t+""),o++,r.length>o&&!isNaN(Number(r[o]))&&(i.push(Number(r[o])+n+""),o++);else if("C"===e)for(i.push(e),o++;r.length>o&&!isNaN(Number(r[o]));)for(let e=0;3>e&&r.length>o&&!isNaN(Number(r[o]));e++)i.push(Number(r[o])+t+""),o++,r.length>o&&!isNaN(Number(r[o]))&&(i.push(Number(r[o])+n+""),o++);else if("Q"===e)for(i.push(e),o++;r.length>o&&!isNaN(Number(r[o]));)for(let e=0;2>e&&r.length>o&&!isNaN(Number(r[o]));e++)i.push(Number(r[o])+t+""),o++,r.length>o&&!isNaN(Number(r[o]))&&(i.push(Number(r[o])+n+""),o++);else if("A"===e)for(i.push(e),o++;r.length>o&&!isNaN(Number(r[o]));)i.push(r[o++]),r.length>o&&i.push(r[o++]),r.length>o&&i.push(r[o++]),r.length>o&&i.push(r[o++]),r.length>o&&i.push(r[o++]),r.length>o&&(i.push(Number(r[o])+t+""),o++),r.length>o&&(i.push(Number(r[o])+n+""),o++);else"Z"===e||"z"===e?(i.push(e),o++):(i.push(r[o]),o++)}return i.join(" ")}var Kc=require("d3-hierarchy"),Qc=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Zc(e){const[t,n,r]=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*r>150?"#222":"#fff"}function Jc(e,t,n){const r=t.nodeIDAccessor;return"function"==typeof r?r(e.data)+"":"string"==typeof r&&void 0!==e.data[r]?e.data[r]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function el(e){if(!e)return null;if("function"==typeof e){const t=e;return e=>t(e.data??e)}return t=>t.data?.[e]||t[e]||t.id}function tl(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:Qc}function nl(e){return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:e.themeSemantic?.primary?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function rl(e,t,n,r,i){if("horizontal"===i){const i=(e+n)/2;return`M ${e},${t} C ${i},${t} ${i},${r} ${n},${r}`}if("radial"===i){const i=(e+n)/2;return`M ${e},${t} Q ${i},${t} ${i},${(t+r)/2} T ${n},${r}`}{const i=(t+r)/2;return`M ${e},${t} C ${e},${i} ${n},${i} ${n},${r}`}}var il={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,r){const i=n.__hierarchyRoot;if(!i)return;const o=n.chartType,s=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),a=n.hierarchySum,c="function"==typeof a?a:"string"==typeof a?e=>Number(e[a])||0:e=>Number(e.value)||0,l=(0,Kc.hierarchy)(i,s);l.sum(c),l.sort((e,t)=>(t.value??0)-(e.value??0));const[u,h]=r;switch(o){case"tree":!function(e,t,n,r){const i=t.treeOrientation||"vertical",o=(0,Kc.tree)();o.size("horizontal"===i?[r,n]:"radial"===i?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),o(e)}(l,n,u,h);break;case"cluster":!function(e,t,n,r){const i=t.treeOrientation||"vertical",o=(0,Kc.cluster)();o.size("horizontal"===i?[r,n]:"radial"===i?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),o(e)}(l,n,u,h);break;case"treemap":!function(e,t,n,r){const i=t.padding??4,o=t.paddingTop??0,s=(0,Kc.treemap)().size([n,r]).tile(Kc.treemapBinary).padding(i);o>0&&s.paddingTop(o),s(e)}(l,n,u,h);break;case"circlepack":!function(e,t,n,r){const i=t.padding??4;(0,Kc.pack)().size([n,r]).padding(i)(e)}(l,n,u,h);break;case"partition":!function(e,t,n,r){(0,Kc.partition)().size([n,r]).padding(t.padding??1)(e)}(l,n,u,h)}const d=l.descendants();e.length=0,t.length=0;const f=new Map;for(let t=0;d.length>t;t++){const r=d[t],i={id:Jc(r,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:r.value??0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===o||"cluster"===o?ol(i,r,n):"treemap"===o||"partition"===o?sl(i,r):"circlepack"===o&&al(i,r),i.__hierarchyNode=r,e.push(i),f.set(r,i)}if("tree"===o||"cluster"===o)for(const e of d)if(e.parent){const n=f.get(e.parent),r=f.get(e);n&&r&&t.push({source:n,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,r){const i=n.nodeStyle||(()=>({})),o=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,r,i,o){const s=[],a=[],c=[],l=n.treeOrientation||"vertical",u="radial"===l,h=r[0]/2,d=r[1]/2,f="number"==typeof(y=n.nodeSize)?y:5;var y;for(const t of e){let e=t.x,r=t.y;u&&(e+=h,r+=d);const o=i(Lc(t,"nodeStyle"));let a=o.fill||nl(n);if(n.colorByDepth&&void 0!==t.depth){const e=tl(n);a=e[t.depth%e.length]}s.push({type:"circle",cx:e,cy:r,r:f,style:{fill:a,stroke:o.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??1,opacity:o.opacity},datum:t,id:t.id,label:t.id,depth:t.depth})}const p=n.edgeOpacity??.5;for(const e of t){const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let i=t.x,s=t.y,c=r.x,f=r.y;u&&(i+=h,s+=d,c+=h,f+=d);const y=rl(i,s,c,f,l),g=o(Lc(e,"edgeStyle"));a.push({type:"curved",pathD:y,style:{fill:"none",stroke:g.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??p},datum:e})}if(!1!==n.showLabels){const t=el(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let r,i,o,s=n.x,a=n.y;if(u&&(s+=h,a+=d),u){const e=s-h,t=a-d,n=Math.sqrt(e*e+t*t);n>0?(r=s+e/n*10,i=a+t/n*10,o=0>e?"end":"start"):(r=s,i=a-12,o="middle")}else"horizontal"===l?(n.data?.children&&0!==n.data.children.length?(r=s-f-6,o="end"):(r=s+f+6,o="start"),i=a):(r=s,i=a+f+14,o="middle");c.push({x:r,y:i,text:e+"",anchor:o,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:c}}(e,t,n,r,i,o);case"treemap":case"partition":return function(e,t,n,r){const i=[],o=[];for(const n of e){const e=n.x1-n.x0,o=n.y1-n.y0;if(0>=e||0>=o)continue;const s=r(Lc(n,"nodeStyle"));let a=s.fill||nl(t);if(t.colorByDepth&&void 0!==n.depth){const e=tl(t);a=e[n.depth%e.length]}i.push({type:"rect",x:n.x0,y:n.y0,w:e,h:o,style:{fill:a,stroke:s.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:s.strokeWidth??1,opacity:s.opacity},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=el(t.nodeLabel),i=t.labelMode||"leaf",s="partition"===t.chartType;for(const a of e){const e=a.x1-a.x0,c=a.y1-a.y0;if(0>=e||0>=c)continue;const l=!(a.data?.children&&a.data.children.length>0);if(!s){if("leaf"===i&&!l)continue;if("parent"===i&&l)continue}const u=n?n(a):a.id;if(!u)continue;if((l?30:40)>e||(l?16:14)>c)continue;let h=r(Lc(a,"nodeStyle")).fill||nl(t);if(t.colorByDepth&&void 0!==a.depth){const e=tl(t);h=e[a.depth%e.length]}const d="string"==typeof h?Zc(h):t.themeSemantic?.text??"#000";o.push(l?{x:a.x0+e/2,y:a.y0+c/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,c)/6)),fill:d}:{x:a.x0+4,y:a.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:d})}}return{sceneNodes:i,sceneEdges:[],labels:o}}(e,n,0,i);case"circlepack":return function(e,t,n,r){const i=[],o=[];for(const n of e){const e=n.__radius??5;if(0>=e)continue;const o=r(Lc(n,"nodeStyle"));let s=o.fill||nl(t);if(t.colorByDepth&&void 0!==n.depth){const e=tl(t);s=e[n.depth%e.length]}i.push({type:"circle",cx:n.x,cy:n.y,r:e,style:{fill:s,stroke:o.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.7},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=el(t.nodeLabel);for(const i of e){const e=i.__radius??5,s=n?n(i):i.id;if(!s)continue;if(15>e)continue;const a=!(i.data?.children&&i.data.children.length>0);let c=r(Lc(i,"nodeStyle")).fill||nl(t);if(t.colorByDepth&&void 0!==i.depth){const e=tl(t);c=e[i.depth%e.length]}if(a){const n="string"==typeof c?Zc(c):t.themeSemantic?.text??"#000";o.push({x:i.x,y:i.y,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:n})}else o.push({x:i.x,y:i.y-e+14,text:s+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:t.themeSemantic?.text||"#000",stroke:t.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:i,sceneEdges:[],labels:o}}(e,n,0,i);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function ol(e,t,n){const r=n.treeOrientation||"vertical";if("radial"===r){const n=t.x,r=t.y;e.x=r*Math.cos(n-Math.PI/2),e.y=r*Math.sin(n-Math.PI/2)}else"horizontal"===r?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function sl(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function al(e,t){const n=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}var cl=require("d3-shape");function ll(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var ul={sankey:$c,force:Fc,chord:Vc,tree:il,cluster:il,treemap:il,circlepack:il,partition:il,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,r){const i=n.__hierarchyRoot;i&&function(e,t,n,r,i){const o=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),s=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}(n.nodeIDAccessor),a=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),c=n.orbitSize??2.95,l=n.orbitEccentricity??1,u="number"==typeof c?()=>c:c,h="number"==typeof l?()=>l:l,d=ll(n);d.metaMap.clear(),r.length=0,i.length=0;const f=new Map;function y(e){const t=f.get(e)??0;return f.set(e,t+1),0===t?e:`${e}__${t}`}const p=t[0]/2,g=t[1]/2,m=Math.min(t[0],t[1])/2*.85,x=y(s(e));r.push({id:x,x:p,y:g,x0:p,x1:p,y0:g,y1:g,width:0,height:0,value:0,depth:0,data:e}),d.metaMap.set(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,c,l,f,p,g){const m=o(t);if(!m?.length)return;const x=m.length;let v=0,b=0,k=0;for(;x>b;)b+=a[Math.min(k,a.length-1)],k++,v++;let w=0;for(let x=0;v>x;x++){const b=a[Math.min(x,a.length-1)],k=m.slice(w,w+b);if(!k.length)break;const A=(x+1)/v,S={id:n,depth:p,data:t,parentId:n},_=g?f/u(S)*A:f*A,M=(0,cl.pie)().value(e=>{const t=o(e)?.length;return t?4:1}).sort(null)(k),C=h(S);for(let t=0;k.length>t;t++){const o=(M[t].startAngle+M[t].endAngle)/2,a=k[t],u=y(s(a)),h=c+_*Math.sin(o),f=l+_*Math.cos(o)*C;r.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:p,data:a}),d.metaMap.set(u,{ring:_,angle:o,depth:p,parentId:n,eccentricity:C}),i.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(a,u,h,f,_,p+1,!0)}w+=b}}(e,x,p,g,m,1,!1)}(i,r,n,e,t)},buildScene(e,t,n,r){const i=n.nodeStyle,o=n.nodeSize,s="number"==typeof o?()=>o:"function"==typeof o?o:()=>6,a=[],c=[],l=[];if(!1!==n.orbitShowRings){const t=ll(n),r=new Map;for(const t of e)r.set(t.id,t);const i=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=r.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;i.has(n)||i.set(n,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const o=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:n,ecc:r}]of i)for(let i=0;o>i;i++){const a=i/o*Math.PI*2,l=(i+1)/o*Math.PI*2;c.push({type:"line",x1:e+n*Math.sin(a),y1:t+n*Math.cos(a)*r,x2:e+n*Math.sin(l),y2:t+n*Math.cos(l)*r,style:s,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=s(Lc(t,"nodeSize")),r=i?i(Lc(t,"nodeStyle")):{};a.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:r.fill||n.themeSemantic?.primary||"#6366f1",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??(0===(t.depth??0)?1:.85)},datum:t,id:t.id,label:t.id,depth:t.depth})}const u=new Map;for(const t of e)u.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:u.get(e.source),n="object"==typeof e.target?e.target:u.get(e.target);t&&n&&(null!=t.x&&null!=n.x&&c.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=s(Lc(n,"nodeSize"));if(4>=e)continue;const r="function"==typeof t?t(n):t?n.data?.[t]??n.id:n.id;l.push({x:n.x,y:n.y+e+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:a,sceneEdges:c,labels:l}},tick:(e,t,n,r,i)=>!1!==n.orbitAnimated&&(function(e,t){const n=ll(t),r=t.orbitSpeed??.25,i=t.orbitRevolution??function(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{const t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}(t.orbitRevolutionStyle),o=(("undefined"!=typeof performance?performance.now():Date.now())-n.startTime)/1e3,s=r*(Math.PI/6),a=new Map;for(const t of e)a.set(t.id,t);for(const t of e){const e=n.metaMap.get(t.id);if(!e||!e.parentId)continue;const r=a.get(e.parentId);if(!r)continue;const c=e.angle+o*s*i({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=r.x+e.ring*Math.sin(c),t.y=r.y+e.ring*Math.cos(c)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)}};function hl(e){return ul[e]}var dl=require("d3-quadtree");function fl(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 yl(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(!pl(e))return!1;return!0}return pl(t.points)}function pl(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}var gl=require("d3-interpolate");var ml="rgba(34, 197, 94, 0.7)",xl=2e3,vl=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],bl=["scene-style","data-paint","accessibility","evidence"],kl=(e,t)=>({retainedData:e,invalidations:t}),wl=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Al=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Sl=["scene-geometry","data-paint","overlay","accessibility","evidence"],_l=["scene-style","data-paint","accessibility","evidence"],Ml=["scene-geometry","data-paint","overlay","accessibility","evidence"],Cl=[],Pl={chartType:kl("rebuild",wl),nodeIDAccessor:kl("rebuild",wl),sourceAccessor:kl("rebuild",wl),targetAccessor:kl("rebuild",wl),valueAccessor:kl("rebuild",wl),edgeIdAccessor:kl("rebuild",wl),childrenAccessor:kl("rebuild",wl),hierarchySum:kl("rebuild",wl),orientation:kl("preserve",Al),nodeAlign:kl("preserve",Al),nodePaddingRatio:kl("preserve",Al),nodeWidth:kl("preserve",Al),edgeSort:kl("preserve",Al),iterations:kl("preserve",Al),forceStrength:kl("preserve",Al),padAngle:kl("preserve",Al),groupWidth:kl("preserve",Al),sortGroups:kl("preserve",Al),treeOrientation:kl("preserve",Al),edgeType:kl("preserve",Al),padding:kl("preserve",Al),paddingTop:kl("preserve",Al),orbitMode:kl("preserve",Al),orbitSize:kl("preserve",Al),orbitSpeed:kl("preserve",Al),orbitRevolution:kl("preserve",Al),orbitRevolutionStyle:kl("preserve",Al),orbitEccentricity:kl("preserve",Al),orbitShowRings:kl("preserve",Al),orbitAnimated:kl("preserve",Al),customNetworkLayout:kl("preserve",Al),layoutConfig:kl("preserve",Al),nodeSize:kl("preserve",Sl),nodeSizeRange:kl("preserve",Sl),colorByDepth:kl("preserve",Sl),nodeLabel:kl("preserve",Ml),showLabels:kl("preserve",Ml),labelMode:kl("preserve",Ml),nodeStyle:kl("preserve",_l),edgeStyle:kl("preserve",_l),colorBy:kl("preserve",_l),colorScheme:kl("preserve",_l),themeCategorical:kl("preserve",_l),themeSemantic:kl("preserve",_l),edgeColorBy:kl("preserve",_l),edgeOpacity:kl("preserve",_l),showParticles:kl("preserve",_l),particleStyle:kl("preserve",_l),decay:kl("preserve",_l),pulse:kl("preserve",_l),thresholds:kl("preserve",_l),staleness:kl("preserve",_l),layoutSelection:kl("preserve",_l),clock:kl("preserve",Cl),random:kl("preserve",Cl),seed:kl("preserve",Cl),tensionConfig:kl("preserve",Cl),transition:kl("preserve",Cl),introAnimation:kl("preserve",Cl),onLayoutError:kl("preserve",Cl),__skipForceSimulation:kl("preserve",Cl),__hierarchyRoot:kl("preserve",Cl),__orbitState:kl("preserve",Cl),__previousPositions:kl("preserve",Cl)},Rl=kl("preserve",Al),jl=class{constructor(){this.tracker=new wt}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}},vl)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},bl):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const r of e){const e=Pl[r]??Rl;"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)}};function Tl(e,t){const n=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>n&&fe(n,e)||"#4e79a7":t=>{if(n){const e=fe(n,t);if(e)return e}let r=0;for(let e=0;t.length>e;e++)r=31*r+t.charCodeAt(e)|0;return e[Math.abs(r)%e.length]??"#4e79a7"}}var El=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 jl,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={...$a,...e.tensionConfig},e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new Oa(2e3))}currentTime(){return this.config.clock?.()??me()}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 r=[...new Set([...Object.keys(t),...Object.keys(n)])].filter(e=>t[e]!==n[e]);this.config=n,this.tensionConfig={...$a,...n.tensionConfig},!n.showParticles||"sankey"!==n.chartType&&!n.customNetworkLayout||this.particlePool||(this.particlePool=new Oa(2e3)),this.updateResults.recordConfig(r)}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,r){const{nodeIDAccessor:i="id",sourceAccessor:o="source",targetAccessor:s="target",valueAccessor:a="value"}=this.config,c="function"==typeof i?i:e=>e[i],l="function"==typeof o?o:e=>e[o],u="function"==typeof s?s:e=>e[s],h="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=c(t)+"";this.nodes.set(e,{...fl(e),data:t})}for(let e=0;t.length>e;e++){const n=t[e],r=l(n)+"",i=u(n)+"",o=h(n),s=null==o?NaN:Number(o),a=Number.isFinite(s)?s:1;this.nodes.has(r)||this.nodes.set(r,{...fl(r),data:n}),this.nodes.has(i)||this.nodes.set(i,{...fl(i),data:n});const c=`${r}\0${i}\0${e}`,d={source:r,target:i,value:a,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:c};n&&"object"==typeof n&&yl(n.bezier)&&(d.bezier=n.bezier),this.edges.set(c,d)}r?.deferLayout||this.runLayout(n),this.updateResults.recordData("replace",e.length+t.length)}ingestBoundedWithResult(e,t,n,r){return this.ingestBounded(e,t,n,r),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:r}=e,i=0===this.nodes.size;let o=!1;const s=this.currentTime();this.lastIngestTime=s,this._decaySortedNodes=null,this._networkDecayCache=null,this.nodes.has(t)||(this.nodes.set(t,fl(t)),this.nodeTimestamps.set(t,s),this.tension+=this.tensionConfig.newNode,o=!0),this.nodes.has(n)||(this.nodes.set(n,fl(n)),this.nodeTimestamps.set(n,s),this.tension+=this.tensionConfig.newNode,o=!0);const a=this.edgeKey(t,n),c=this.edges.get(a);let l=!1;c?(c.value+=r,this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.weightChange,l=!0):(this.edges.set(a,{source:t,target:n,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.newEdge,o=!0);const u=i||o||l||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=hl(this.config.chartType);if(!t)return;let n=Array.from(this.nodes.values());const r=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,r,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;r.length>e;e++){const t=r[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 i=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||i.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=i,this.saveTargetPositions();const o=n.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),s=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&&s>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:s}}else o&&s>0&&(this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:s});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:r,baseStyles:i,selection:o}){const s=!(!n&&!r);if(n)for(const t of e){const e=i.get(t)??t.style,r=n(t,o);t.style=r?{...e,...r}:e}if(r)for(const e of t){const t=i.get(e)??e.style,n=r(e,o);e.style=n?{...t,...n}:t}return s}({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:r,edges:i,previousResult:o,revision:s}){const a=function(e,t,n){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=Object.values(e).filter(e=>"string"==typeof e&&e.length>0);if(t.length>0)return t}if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=ue[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}(e.colorScheme,e.themeCategorical,K),c={nodes:r,edges:i,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:Tl(a,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};try{return{kind:"success",result:t(c)}}catch(t){const n=null!==o,r=it("network",t,n,s);"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",t);try{e.onLayoutError?.(r)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:r,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 tt({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=hl(this.config.chartType);if(!t)return void this._sceneNodesRevision++;const n=t.hierarchical?Array.from(this.nodes.values()):this.nodesArray,r=t.hierarchical?Array.from(this.edges.values()):this.edgesArray,{sceneNodes:i,sceneEdges:o,labels:s}=t.buildScene(n,r,this.config,e);this.sceneNodes=i,this.sceneEdges=o,this.labels=s,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 r=Array(t);let i=0;for(const e of this.sceneNodes)"circle"===e.type&&(r[i++]=e);this._nodeQuadtree=(0,dl.quadtree)().x(e=>e.cx).y(e=>e.cy).addAll(r)}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=hl(this.config.chartType);return!!e?.supportsAnimation&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=hl(this.config.chartType);if(!n?.tick)return!1;const r=n.hierarchical?Array.from(this.nodes.values()):this.nodesArray,i=n.hierarchical?Array.from(this.edges.values()):this.edgesArray;return n.tick(r,i,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=ye(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=ge(e._prevX0,e._targetX0,n),e.x1=ge(e._prevX1,e._targetX1,n),e.y0=ge(e._prevY0,e._targetY0,n),e.y1=ge(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=ge(e._prevY0,e._targetY0,n),e.y1=ge(e._prevY1,e._targetY1,n),e.sankeyWidth=ge(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 r="string"==typeof e.source?t.get(e.source):e.source,i="string"==typeof e.target?t.get(e.target):e.target;!r||!i||(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))),r=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-r,y:n.targetY},{x:n.targetX-.66*r,y:n.targetY},{x:n.targetX-.33*r,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let r;r="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 i=[];for(let e=0;r.length-1>e;e++){const t=r[e],n=r[e+1],o=n.x-t.x,s=n.y-t.y;i.push([t,{x:t.x+o/3,y:t.y+s/3},{x:t.x+2*o/3,y:t.y+2*s/3},n])}return{circular:!0,segments:i,halfWidth:t}}(e):function(e,t,n,r=.5){const i=(e.sankeyWidth||1)/2;if("down"===e.direction){const o=t.x1,s=n.x0,a=(0,gl.interpolateNumber)(o,s);return{circular:!1,points:[{x:e.y0,y:o},{x:e.y0,y:a(r)},{x:e.y1,y:a(1-r)},{x:e.y1,y:s}],halfWidth:i}}const o=t.x1,s=n.x0,a=(0,gl.interpolateNumber)(o,s);return{circular:!1,points:[{x:o,y:e.y0},{x:a(r),y:e.y0},{x:a(1-r),y:e.y1},{x:s,y:e.y1}],halfWidth:i}}(e,r,i,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,r=t.color??"rgba(255,255,255,0.6)",i=t.glowRadius??4,{now:o}=e;for(const t of e.sceneNodes){const s=t.id;if(!s)continue;const a=e.nodeTimestamps.get(s);if(!a)continue;const c=o-a;n>c&&(t._pulseIntensity=1-c/n,t._pulseColor=r,t._pulseGlowRadius=i)}for(const t of e.sceneEdges){const i=t.datum;if(!i)continue;const s="object"==typeof i.source?i.source?.id:i.source,a="object"==typeof i.target?i.target?.id:i.target;if(!s||!a)continue;const c=e.edgeTimestamps.get(`${s}\0${a}`);if(!c)continue;const l=o-c;n>l&&(t._pulseIntensity=1-l/n,t._pulseColor=r)}}({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 r=e.cache.ageMap;for(const i of e.sceneNodes){const e=i.id;if(!e)continue;const o=r.get(e);if(void 0===o)continue;const s=_e(t,o,n);i.style={...i.style,opacity:(i.style?.opacity??1)*s}}}({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===ml&&(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>=xl)return;const n=1-t/xl;for(const t of e.sceneNodes){const r=t.id;r&&e.addedNodes.has(r)&&(t._pulseIntensity=Math.max(t._pulseIntensity??0,n),t._pulseColor=ml,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&&xl>n-t}(this.addedNodes,this.lastTopologyChangeTime)}applyThresholds(e){!function(e){const t=e.thresholds;if(!t)return;const n=t.warningColor??"#f59e0b",r=t.criticalColor??"#ef4444",i=!1!==t.pulse;for(const o of e.sceneNodes){const s=o.id;if(!s)continue;const a=e.nodes.get(s);if(!a)continue;const c=t.metric(a);let l=null;void 0===t.critical||t.critical>c?void 0===t.warning||t.warning>c||(l=n):l=r,l&&(o.style={...o.style,fill:l},i&&(o._pulseIntensity=.6+.4*Math.sin(e.now/300),o._pulseColor=l,o._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 r=n.data?{...n.data}:{};return n.data=t(n.data??{}),this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",1),r}updateEdge(e,t,n){const r=this.config.valueAccessor,i="function"==typeof r?r:r?e=>e[r]:e=>e.value,o=[];for(const[,r]of this.edges)if(("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t){o.push(r.data?{...r.data}:{}),r.data=n(r.data??{});const e=i(r.data);null!=e&&(r.value=Number(e))}return o.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",o.length)):this.updateResults.recordNoop("update"),o}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 r="function"==typeof t?t:e=>e?.[t];for(const[t,i]of this.edges)i.data&&r(i.data)===e&&n.push(t)}else for(const[r,i]of this.edges)("string"==typeof i.source?i.source:i.source.id)===e&&("string"==typeof i.target?i.target:i.target.id)===t&&n.push(r);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")}};El.QUADTREE_THRESHOLD=500;var Dl=El;xt(Dl);var Nl=c(require("react")),Ll=require("react/jsx-runtime");function Il(e){const{width:t,height:n,totalWidth:r,totalHeight:i,margin:o,labels:s,title:a,legend:c,legendHoverBehavior:l,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d,legendPosition:f="right",legendLayout:y,foregroundGraphics:p,sceneNodes:g,annotations:m,onAnnotationActivate:x,onObservation:v,chartId:b,chartType:k,autoPlaceAnnotations:w,svgAnnotationRules:A}=e,S=ni({onAnnotationActivate:x,onObservation:v,chartId:b,chartType:k}),_=Nl.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 r=xn(e.glyph,e.size);return{x:t+r.centerDx,y:n+r.centerDy,r:Math.max(1,r.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,Qe(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]),M=Nl.useMemo(()=>m&&w?ji({annotations:m,context:_,..."object"==typeof w?w:{}}):m,[m,w,_]),C=Nl.useMemo(()=>hi(),[]),P=M?ui(M.filter(e=>"widget"!==e.type),C,A,_):null,R=!0===M?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return(0,Ll.jsxs)(Ll.Fragment,{children:[R&&(0,Ll.jsx)("style",{children:Vr},"annotation-widget-disclosure-style"),(0,Ll.jsxs)("svg",{role:"img",width:r,height:i,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[(0,Ll.jsx)("title",{children:"string"==typeof a?a:"Network Chart"}),(0,Ll.jsx)("desc",{children:"string"==typeof a?a+" — network data visualization":"Network data visualization"}),(0,Ll.jsxs)("g",{transform:`translate(${o.left},${o.top})`,children:[s.map((e,t)=>(0,Ll.jsx)("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)),P,p]}),a&&"string"==typeof a?(0,Ll.jsx)("text",{x:r/2,y:22,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:a}):a?(0,Ll.jsx)("foreignObject",{x:0,y:0,width:r,height:o.top,children:a}):null,br({legend:c,totalWidth:r,totalHeight:i,margin:o,legendPosition:f,title:a,legendLayout:y,legendHoverBehavior:l,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d})]}),M?.filter(e=>"widget"===e.type&&e.nodeId&&g).map((e,t)=>{const n=!0===e._annotationDeferred,r=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(!r)return null;const i=o.left+(r.cx??(null!=r.x&&null!=r.w?r.x+r.w/2:r.x??0)),s=o.top+(r.cy??(null!=r.y&&null!=r.h?r.y+r.h/2:r.y??0)),a=e.dx??0,c=e.dy??-16,l=e.width??32,u=e.height??32,h=e.content??(0,Ll.jsx)("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return(0,Ll.jsx)("div",{...ri(e,S),className:n?"annotation-deferred":void 0,"data-annotation-disclosure":n?"deferred":void 0,style:{position:"absolute",left:i+a-l/2,top:s+c-u/2,width:l,height:u,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:h},"widget-"+t)})]})}Il.displayName="NetworkSVGOverlay";var Wl=c(require("react")),$l=require("react/jsx-runtime"),zl={position:"absolute",top:0,left:0,pointerEvents:"none"};function Ol({marks:e,margin:t,selection:n=null,overscan:r=400}){const i=Wl.useRef(null),o=function(e,t,n){const[r,i]=Wl.useState(null);return Wl.useLayoutEffect(()=>{const e=t.current,n=function(e){let t=e?.parentElement??null;for(;t;){const{overflow:e,overflowX:n,overflowY:r}=window.getComputedStyle(t);if(/(auto|scroll|overlay)/.test(`${e} ${r} ${n}`))return t;t=t.parentElement}return null}(e);if(!e||!n)return void i(null);let r=0;const o=()=>{r=0;const t=n.getBoundingClientRect(),o=e.getBoundingClientRect();i(0!==t.width&&0!==t.height?{scroll:{left:t.left,top:t.top,right:t.right,bottom:t.bottom},originX:o.left,originY:o.top}:null)},s=()=>{0===r&&(r=window.requestAnimationFrame(o))};o(),n.addEventListener("scroll",s,{passive:!0});const a=new ResizeObserver(s);return a.observe(n),()=>{0!==r&&window.cancelAnimationFrame(r),n.removeEventListener("scroll",s),a.disconnect()}},[t,e,n]),Wl.useMemo(()=>{if(!e||!r)return e;const{scroll:t,originX:i,originY:o}=r,s=t.left-n,a=t.right+n,c=t.top-n,l=t.bottom+n;return e.filter(e=>{const t=i+e.x,n=o+e.y;return!(s>t+e.width||t>a||c>n+e.height||n>l)})},[e,r,n])}(e,i,r);if(!e||0===e.length)return null;const s=(0,$l.jsx)("div",{className:"semiotic-network-html-marks",ref:i,style:{...zl,transform:`translate(${t.left}px, ${t.top}px)`},children:(o??e).map(e=>(0,$l.jsx)("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?(0,$l.jsx)(en,{value:n,children:s}):s}var Fl=require("react/jsx-runtime");function Bl({props:e,store:t,responsiveRef:n,size:r,margin:i,adjustedWidth:o,adjustedHeight:s,resolvedBackground:a,resolvedForeground:c}){const{chartType:l,nodes:u,edges:h,data:d,className:f,description:y,title:p,responsiveWidth:g,responsiveHeight:m,summary:x,background:v,renderMode:b,legend:k,legendPosition:A,legendLayout:S,legendHoverBehavior:_,legendClickBehavior:M,legendHighlightedCategory:C,legendIsolatedCategories:P,layoutSelection:R,annotations:j,onAnnotationActivate:T,annotationObservationCallback:E,onObservation:D,chartId:N,autoPlaceAnnotations:L,svgAnnotationRules:I}=e;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(l),n=e?d||(Array.isArray(h)?void 0:h):void 0;if(e&&n)t.ingestHierarchy(n,[o,s]),t.buildScene([o,s]);else{const e=w(u),n=Array.isArray(h)?w(h):[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[o,s]),t.buildScene([o,s]))}}const W=t?.sceneNodes??[],$=t?.sceneEdges??[],z=t?.labels??[];return(0,Fl.jsxs)("div",{ref:n,className:"stream-network-frame"+(f?" "+f:""),role:"img","aria-label":y||("string"==typeof p?p:"Network chart"),style:{position:"relative",width:g?"100%":r[0],height:m?"100%":r[1]},children:[(0,Fl.jsx)(Qo,{summary:x}),(0,Fl.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:r[0],height:r[1],style:{position:"absolute",left:0,top:0},children:[a&&(0,Fl.jsx)("g",{transform:`translate(${i.left},${i.top})`,children:a}),(0,Fl.jsxs)("g",{transform:`translate(${i.left},${i.top})`,children:[v&&(0,Fl.jsx)("rect",{x:0,y:0,width:o,height:s,fill:v}),$.map((e,t)=>pa({node:e,index:t,renderMode:b,fallback:()=>function(e,t){switch(e.type){case"line":return(0,no.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+t);case"bezier":{const n=e;return(0,no.jsx)("path",{d:n.pathD,fill:io(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"ribbon":{const n=e;return(0,no.jsx)("path",{d:n.pathD,fill:io(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"curved":{const n=e;return(0,no.jsx)("path",{d:n.pathD,fill:io(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+t)}default:return null}}(e,t)})).filter(Boolean),W.map((e,t)=>pa({node:e,index:t,renderMode:b,fallback:()=>function(e,t){switch(e.type){case"circle":{const n=e,r=jn(n.style.fill)?Dn(n.style.fill,`net-circle-${t}-hatch`):void 0;return(0,no.jsxs)(Ji.Fragment,{children:[r&&(0,no.jsx)("defs",{children:r}),(0,no.jsx)("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:r?`url(#net-circle-${t}-hatch)`:io(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-circle-"+t)}case"rect":{const n=e,r=jn(n.style.fill)?Dn(n.style.fill,`net-rect-${t}-hatch`):void 0;return(0,no.jsxs)(Ji.Fragment,{children:[r&&(0,no.jsx)("defs",{children:r}),(0,no.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:r?`url(#net-rect-${t}-hatch)`:io(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-rect-"+t)}case"arc":{const n=e,r=(0,eo.arc)().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(ro)||"",i=jn(n.style.fill)?Dn(n.style.fill,`net-arc-${t}-hatch`):void 0;return(0,no.jsxs)(Ji.Fragment,{children:[i&&(0,no.jsx)("defs",{children:i}),(0,no.jsx)("path",{d:r,transform:`translate(${n.cx},${n.cy})`,fill:i?`url(#net-arc-${t}-hatch)`:io(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-arc-"+t)}case"symbol":{const n=e,r=Ke(n.symbolType,n.size,n.path);return(0,no.jsx)("path",{d:r,transform:n.rotation?`translate(${n.cx},${n.cy}) rotate(${180*n.rotation/Math.PI})`:`translate(${n.cx},${n.cy})`,fill:n.style.fill?io(n.style.fill):"none",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-symbol-"+t)}case"glyph":return oo(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}(e,t)})).filter(Boolean),z.map((e,t)=>function(e,t){return(0,no.jsx)("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+t)}(e,t)).filter(Boolean)]})]}),(0,Fl.jsx)(Il,{width:o,height:s,totalWidth:r[0],totalHeight:r[1],margin:i,labels:z,sceneNodes:W,title:p,legend:k,legendPosition:A,legendLayout:S,legendHoverBehavior:_,legendClickBehavior:M,legendHighlightedCategory:C,legendIsolatedCategories:P,foregroundGraphics:Kt(c,tn(t?.customLayoutOverlays,R??null)),annotations:j,onAnnotationActivate:T,onObservation:E??D,chartId:N,chartType:"StreamNetworkFrame",autoPlaceAnnotations:L,svgAnnotationRules:I,annotationFrame:0}),(0,Fl.jsx)(Ol,{marks:t?.customLayoutHtmlMarks,margin:i,selection:R??null})]})}var Yl=require("react/jsx-runtime"),Hl=("undefined"!=typeof process&&process,{display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #666)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"}),Xl={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function ql(e,t,n,r){return!1===r||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?(0,Yl.jsx)("div",{style:{...Hl,width:t,height:n},children:r||"No data available"}):null}function Gl(e,t,n,r){if(!e)return null;if(!1===r)return null;if(null!=r)return(0,Yl.jsx)("div",{style:{width:t,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:r});const i=Math.min(5,Math.floor(n/40)),o=Math.max(8,Math.floor(n/(3*i))),s=Math.max(6,Math.floor(n/(2.5*i))),a=Math.floor((n-(i*(o+s)-s))/2);return(0,Yl.jsx)("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:i},(e,n)=>(0,Yl.jsx)("div",{className:"semiotic-loading-bar",style:{...Xl,position:"absolute",top:a+n*(o+s),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:o,opacity:.5+n%2*.2}},n))})}var Vl={};function Ul(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function Kl(){if("undefined"!=typeof DOMException)return new DOMException("Force layout aborted","AbortError");const e=Error("Force layout aborted");return e.name="AbortError",e}var Ql=class{constructor(e=function(){const e="string"==typeof Vl.url&&Vl.url?new URL("./forceLayoutWorker.js",Vl.url):function(e){if("undefined"!=typeof __filename){const t=__filename.replace(/\\/g,"/"),n=t.startsWith("/")?t:"/"+t;return new URL("./"+e,"file:"+n)}throw Error("Cannot resolve module worker asset: "+e)}("forceLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-force-layout"})}()){this.nextRequestId=1,this.pending=new Map,this.dead=!1,this.worker=e,this.worker.onmessage=e=>{const t=e.data,n=t.requestId,r=null!=n?this.pending.get(n):this.pending.values().next().value;if(r){if(null!=n?this.pending.delete(n):this.pending.clear(),r.cleanup(),t.error){const e=Error(t.error.message);return e.name=t.error.name??"Error",t.error.stack&&(e.stack=t.error.stack),void r.reject(e)}r.resolve({positions:t.positions??{}})}},this.worker.onerror=e=>{this.rejectAll(Error(e.message||"Force layout worker failed")),this.terminate()}}get isDead(){return this.dead}request(e,t){if(this.dead)return Promise.reject(Error("Force layout worker session is closed"));if(t?.aborted)return Promise.reject(Kl());const n=this.nextRequestId;this.nextRequestId+=1;const r={requestId:n,request:e};return new Promise((e,i)=>{const o=()=>{this.pending.delete(n),t?.removeEventListener("abort",o),i(Kl())},s=()=>t?.removeEventListener("abort",o);this.pending.set(n,{cleanup:s,reject:i,resolve:e}),t?.addEventListener("abort",o,{once:!0});try{this.worker.postMessage(r)}catch(e){this.pending.delete(n),s(),i(e instanceof Error?e:Error(e+""))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(Error("Force layout worker terminated")),this.worker.terminate())}rejectAll(e){for(const t of this.pending.values())t.cleanup(),t.reject(e);this.pending.clear()}},Zl=null;var Jl=require("react/jsx-runtime"),eu=/^(value|amount|total|count|weight|score)$/i;function tu({data:e}){if("edge"===e.nodeOrEdge){const t=e.data;return t?(0,Jl.jsxs)("div",{className:"semiotic-tooltip",style:ds,children:[(0,Jl.jsxs)("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&&(0,Jl.jsxs)("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 r=n;for(;r;){const n=r.data?.name??r.data?.id??t.id;null!=n&&e.unshift(n+""),r=r.parent}e.length>1&&e.shift();const i=e.length-1;return(0,Jl.jsxs)("div",{className:"semiotic-tooltip",style:ds,children:[(0,Jl.jsx)("div",{children:e.map((e,t)=>(0,Jl.jsxs)("span",{children:[t>0&&(0,Jl.jsx)("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),t===i?(0,Jl.jsx)("strong",{children:e}):(0,Jl.jsx)("span",{style:{opacity:.7},children:e})]},t))}),null!=t.value&&t.value>0&&(0,Jl.jsx)("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof t.value?t.value.toLocaleString():t.value+""})]})}const r=(t.sourceLinks?.length||0)+(t.targetLinks?.length||0),i=(t.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(t.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0),o=hs(t.data??t),s=null!=o.title?o.title+"":t.id,a=o.entries.some(e=>eu.test(e.key));return(0,Jl.jsxs)("div",{className:"semiotic-tooltip",style:ds,children:[(0,Jl.jsx)("div",{style:{fontWeight:600},children:s}),o.entries.map(e=>{return(0,Jl.jsxs)("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&&(0,Jl.jsxs)("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]}),r>0&&(0,Jl.jsxs)("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",r,i!==r&&` (weighted: ${i.toLocaleString()})`]})]})}function nu(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function ru(e,t){if(!t.pathD)return;e.save();const n=nu(t);if(t.style.fill&&"none"!==t.style.fill){const r=t._gradient;if(r){const n=e.createLinearGradient(r.x0,0,r.x1,0),i=t.style.fillOpacity??t.style.opacity??.5,o="string"==typeof t.style.fill?t.style.fill:"#999",s=Cn(e,o)||o;n.addColorStop(0,1===r.from?s:"transparent"),n.addColorStop(1,1===r.to?s:"transparent"),e.fillStyle=n,e.globalAlpha=i}else e.fillStyle=Wn(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=Cn(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 iu(e,t){e.save();const n=t.style.stroke||"#999";e.strokeStyle=Cn(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 ou(e,t){if(!t.pathD)return;e.save();const n=nu(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=Wn(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=Cn(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 su(e,t){if(!t.pathD)return;e.save();const n=nu(t),r=t.style.stroke||"#999";e.strokeStyle=Cn(e,r)||r,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=Wn(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??.1,e.fill(n)),e.restore()}tu.ownsChrome=!0;var au=new Map;function cu(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=au.get(t);return n||(n=new Path2D(Ke(e.symbolType,e.size)),au.size>256&&au.clear(),au.set(t,n)),n}catch{return null}}function lu(e){const{sceneNodes:t,nodes:n,nodeColorMap:r,colorScheme:i}=e;for(const e of t)e.id&&"string"==typeof e.style?.fill&&r.set(e.id,e.style.fill);const o=Array.isArray(i)?i:he,s=Array.from(n);for(let e=0;s.length>e;e++){const t=s[e];r.has(t.id)||r.set(t.id,o[e%o.length])}return s.length}function uu(e,t,n,r=30){switch(e.type){case"circle":return function(e,t,n,r=30){const i=t-e.cx,o=n-e.cy,s=Math.sqrt(i*i+o*o);return s>an(e.r,r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:s}}(e,t,n,r);case"rect":return function(e,t,n){const r=sn(t,n,e);return r.hit?{type:"node",datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}(e,t,n);case"arc":return function(e,t,n){const r=t-e.cx,i=n-e.cy,o=Math.sqrt(r*r+i*i);if(e.innerR-2>o||o>e.outerR+2)return null;const s=un(Math.atan2(i,r)),a=un(e.startAngle),c=un(e.endAngle);if(a>c?s>=a||c>=s:s>=a&&c>=s){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}(e,t,n);case"symbol":return function(e,t,n,r=30){const i=t-e.cx,o=n-e.cy,s=Math.sqrt(i*i+o*o);return s>an(Qe(e.size),r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:s}}(e,t,n,r);case"glyph":return function(e,t,n,r=30){if(null==e.datum)return null;const i=xn(e.glyph,e.size),o=e.cx+i.centerDx,s=e.cy+i.centerDy,a=t-o,c=n-s,l=Math.sqrt(a*a+c*c);return l>an(i.radius,r)?null:{type:"node",datum:e.datum,x:o,y:s,distance:l}}(e,t,n,r);default:return null}}var hu=null,du=null;function fu(){return du||((hu=document.createElement("canvas")).width=1,hu.height=1,du=hu.getContext("2d")),du}function yu(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 pu(e,t,n){switch(e.type){case"bezier":return function(e,t,n){if(!e.pathD)return null;const r=yu(e),i=fu();if(!r||!i)return null;try{if(i.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const o=i.lineWidth;i.lineWidth=10;const s=i.isPointInStroke(r,t,n);if(i.lineWidth=o,s)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 r=e.x2-e.x1,i=e.y2-e.y1,o=r*r+i*i;if(0===o)return null;let s=((t-e.x1)*r+(n-e.y1)*i)/o;s=Math.max(0,Math.min(1,s));const a=e.x1+s*r,c=e.y1+s*i,l=Math.sqrt((t-a)**2+(n-c)**2);return l>5?null:{type:"edge",datum:e.datum,x:a,y:c,distance:l}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;const r=yu(e),i=fu();if(!r||!i)return null;try{if(i.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const o=i.lineWidth;i.lineWidth=10;const s=i.isPointInStroke(r,t,n);if(i.lineWidth=o,s)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);default:return null}}function gu(e){const{clientX:t,clientY:n,canvasRect:r,margin:i,adjustedWidth:o,adjustedHeight:s,sceneNodes:a,sceneEdges:c,nodeQuadtree:l,maxNodeRadius:u,hitRadius:h=30}=e,d=t-r.left-i.left,f=n-r.top-i.top;if(0>d||d>o||0>f||f>s)return{kind:"miss-outside"};const y=function(e,t,n,r,i=30,o,s=0){let a=null,c=i,l=1/0;if(o){const e=bn(o,n,r,i,s,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},c=e.distance)}for(const t of e){if(o&&"circle"===t.type)continue;const e=uu(t,n,r,i);if(e)if("rect"===t.type){const n=t.w*t.h;l>n&&(a=e,l=n)}else c>e.distance&&(a=e,c=e.distance)}if(a)return a;for(const e of t){if(!1===e.interactive)continue;const t=pu(e,n,r);t&&c>t.distance&&(a=t,c=t.distance)}return a}(a,c,d,f,h,l,u);return y?{kind:"hit",hover:os(y.datum||{},y.x,y.y,{nodeOrEdge:y.type})}:{kind:"miss"}}var mu=require("react"),xu="StreamNetworkFrame",vu=require("react/jsx-runtime"),bu={top:20,right:80,bottom:20,left:80},ku={top:40,right:40,bottom:40,left:40},wu=new Set(["chord","force","circlepack","orbit"]),Au=[800,600],Su=(0,Wa.memo)((0,Wa.forwardRef)(function(e,t){const{chartType:n,nodes:r,edges:i,data:o,initialEdges:s,nodeIDAccessor:a="id",sourceAccessor:c="source",targetAccessor:l="target",valueAccessor:u="value",edgeIdAccessor:h,childrenAccessor:d,hierarchySum:f,orientation:y="horizontal",nodeAlign:p="justify",nodePaddingRatio:g=.05,nodeWidth:m=15,iterations:x=300,forceStrength:v=.1,layoutExecution:b="auto",layoutLoadingContent:k,onLayoutStateChange:A,padAngle:S=.01,groupWidth:_=20,sortGroups:M,edgeSort:C,treeOrientation:R="vertical",edgeType:j="curve",padding:T,paddingTop:E,tensionConfig:D,showParticles:N=!1,particleStyle:L,renderMode:I,nodeStyle:W,edgeStyle:$,colorBy:z,colorScheme:O="category10",edgeColorBy:F="source",edgeOpacity:B=.5,colorByDepth:Y=!1,nodeSize:H=8,nodeSizeRange:X=[5,20],nodeLabel:q,showLabels:G=!0,labelMode:V,size:U=Au,responsiveWidth:K,responsiveHeight:Q,margin:Z,className:J,background:ee,enableHover:te=!0,tooltipContent:ne,customHoverBehavior:re,customClickBehavior:ie,onObservation:oe,annotationObservationCallback:se,chartId:ae,onTopologyChange:ce,annotations:le,onAnnotationActivate:ue,autoPlaceAnnotations:de,svgAnnotationRules:fe,legend:ye,legendPosition:pe,legendLayout:ge,legendHoverBehavior:me,legendClickBehavior:xe,legendHighlightedCategory:ve,legendIsolatedCategories:be,title:ke,foregroundGraphics:we,backgroundGraphics:Ae,decay:Se,pulse:_e,transition:Me,animate:Ce,staleness:Pe,frameScheduler:Re,clock:je,random:Te,seed:Ee,paused:De=!1,suspendWhenHidden:Ne=!0,thresholds:Le,accessibleTable:Ie=!0,description:We,summary:$e,orbitMode:ze,orbitSize:Oe,orbitSpeed:Fe,orbitRevolution:Be,orbitRevolutionStyle:Ye,orbitEccentricity:He,orbitShowRings:Xe,orbitAnimated:qe,customNetworkLayout:Ge,onLayoutError:Ve,layoutConfig:Ue,layoutSelection:Ke}=e,Qe=wu.has(n)?ku:bu,Ze=(0,Wa.useRef)(!0),Je=Ms({sizeProp:U,responsiveWidth:K,responsiveHeight:Q,userMargin:Z,marginDefault:Qe,title:ke,legend:ye,legendPosition:pe,foregroundGraphics:we,backgroundGraphics:Ae,animate:Ce,transitionProp:Me,frameScheduler:Re,clock:je,random:Te,seed:Ee,paused:De,suspendWhenHidden:Ne,themeDirtyRef:Ze}),{reducedMotionRef:et,responsiveRef:tt,size:nt,margin:rt,adjustedWidth:it,adjustedHeight:ot,resolvedForeground:st,resolvedBackground:at,transition:ct,introEnabled:lt,tableId:ut,rafRef:ht,renderFnRef:dt,scheduleRender:ft,frameRuntime:yt,currentTheme:pt}=Je,gt=lo(),mt=yo(),xt=(0,Wa.useMemo)(()=>w(r),[r]),vt=(0,Wa.useMemo)(()=>Array.isArray(i)?w(i):i,[i]),bt=(0,Wa.useMemo)(()=>({...$a,...D}),[D]),kt=(0,Wa.useMemo)(()=>({...za,...L}),[L]),wt=(0,Wa.useMemo)(()=>{return{chartType:(e={chartType:n,clock:yt.now,random:Te,seed:Ee,nodeIDAccessor:a,sourceAccessor:c,targetAccessor:l,valueAccessor:u,edgeIdAccessor:h,childrenAccessor:d,hierarchySum:f,orientation:y,nodeAlign:p,nodePaddingRatio:g,nodeWidth:m,iterations:x,forceStrength:v,padAngle:S,groupWidth:_,sortGroups:M,edgeSort:C,treeOrientation:R,edgeType:j,padding:T,paddingTop:E,tensionConfig:bt,showParticles:N,particleStyle:kt,nodeStyle:W,edgeStyle:$,nodeLabel:q,showLabels:G,labelMode:V,colorBy:z,colorScheme:O,edgeColorBy:F,edgeOpacity:B,colorByDepth:Y,nodeSize:H,nodeSizeRange:X,decay:Se,pulse:_e,transition:ct,introAnimation:lt,staleness:Pe,thresholds:Le,orbitMode:ze,orbitSize:Oe,orbitSpeed:Fe,orbitRevolution:Be,orbitRevolutionStyle:Ye,orbitEccentricity:He,orbitShowRings:Xe,orbitAnimated:qe,customNetworkLayout:Ge,onLayoutError:Ve,layoutConfig:Ue,currentTheme:pt}).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:P(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,yt.now,Te,Ee,a,c,l,u,h,d,f,y,p,g,m,x,v,S,_,M,C,R,j,T,E,bt,N,kt,W,$,q,G,V,z,O,F,B,Y,H,X,Se,_e,ct,lt,Pe,Le,ze,Oe,Fe,Be,Ye,He,Xe,qe,Ge,Ve,Ue,pt]),At=go(wt),St=go({chartType:(_t={chartType:n,nodeIDAccessor:a,sourceAccessor:c,targetAccessor:l,valueAccessor:u,edgeIdAccessor:h,childrenAccessor:d,hierarchySum:f,orientation:y,nodeAlign:p,nodePaddingRatio:g,nodeWidth:m,iterations:x,forceStrength:v,padAngle:S,groupWidth:_,sortGroups:M,edgeSort:C,treeOrientation:R,edgeType:j,padding:T,paddingTop:E,random:Te,seed:Ee,tensionConfig:bt,customNetworkLayout:Ge,orbitMode:ze,orbitSize:Oe,orbitEccentricity:He}).chartType,nodeIDAccessor:_t.nodeIDAccessor,sourceAccessor:_t.sourceAccessor,targetAccessor:_t.targetAccessor,valueAccessor:_t.valueAccessor,edgeIdAccessor:_t.edgeIdAccessor,childrenAccessor:_t.childrenAccessor,hierarchySum:_t.hierarchySum,orientation:_t.orientation,nodeAlign:_t.nodeAlign,nodePaddingRatio:_t.nodePaddingRatio,nodeWidth:_t.nodeWidth,iterations:_t.iterations,forceStrength:_t.forceStrength,padAngle:_t.padAngle,groupWidth:_t.groupWidth,sortGroups:_t.sortGroups,edgeSort:_t.edgeSort,treeOrientation:_t.treeOrientation,edgeType:_t.edgeType,padding:_t.padding,paddingTop:_t.paddingTop,random:_t.random,seed:_t.seed,tensionConfig:_t.tensionConfig,customNetworkLayout:_t.customNetworkLayout,orbitMode:_t.orbitMode,orbitSize:_t.orbitSize,orbitEccentricity:_t.orbitEccentricity});var _t;const Mt=(0,Wa.useRef)(0),Ct=(0,Wa.useRef)(0),Pt=(0,Wa.useRef)(!1),Rt=(0,Wa.useRef)(null);Rt.current||(Rt.current=new Dl(At));const jt=Gt("StreamNetworkFrame"),Tt=(0,Wa.useCallback)((e,t,n=!1)=>function(e,t,n,r=!1,i=!1){const o=e.beforeCompute(t.getLastUpdateResult(),r);n(),e.afterCompute(o,!0,i)}(jt.current,e,()=>e.buildScene(t),n),[jt]),[Et,Dt]=(0,Wa.useState)(null),[Nt,Lt]=(0,Wa.useState)(0),[It,Wt]=(0,Wa.useState)(0),[$t,zt]=(0,Wa.useState)(!1),[Ot,Ft]=(0,Wa.useState)(!1),Bt=(0,Wa.useRef)(0),Yt=(0,Wa.useRef)(null),Ht=(0,Wa.useRef)(!1),Xt=(0,Wa.useRef)(A);Xt.current=A;const qt=(0,Wa.useRef)(At);qt.current=At;const Ut=(0,Wa.useRef)(null),Qt=(0,Wa.useRef)(new Map),Zt=(0,Wa.useRef)(0),Jt=(0,Wa.useCallback)(e=>function(e){const{node:t,colorBy:n,colorScheme:r,nodeColorMap:i,colorIndexRef:o}=e;if("function"==typeof n)return n(t)+"";if("string"==typeof n&&t.data){const e=t.data[n];if(void 0!==e){if(!i.has(e+"")){const t=Array.isArray(r)?r:he;i.set(e+"",t[o.current++%t.length])}return i.get(e+"")}}if(i.has(t.id))return i.get(t.id);const s=Array.isArray(r)?r:he,a=n?s[o.current++%s.length]:s[0];return i.set(t.id,a),a}({node:e,colorBy:z,colorScheme:O,nodeColorMap:Qt.current,colorIndexRef:Zt}),[z,O]),en=(nn=pt,nn?.colors?.border||nn?.colors?.secondary||nn?.colors?.primary||"#999");var nn;const sn=(0,Wa.useCallback)(e=>function(e,t){return e?"object"==typeof e?e:t?.get(e)??null:null}(e,Rt.current?.nodes),[]),an=(0,Wa.useCallback)(e=>function(e){const{edge:t,edgeColorBy:n,getNodeColor:r,resolveEndpoint:i,fallback:o}=e;if("function"==typeof n)return n(t);const s=i(t.source),a=i(t.target);return"target"===n&&a?r(a):s?r(s):o}({edge:e,edgeColorBy:F,getNodeColor:Jt,resolveEndpoint:sn,fallback:en}),[F,Jt,en,sn]),cn=(0,Wa.useCallback)(e=>function(e){const{edge:t,particleStyleColor:n,particleColorBy:r,hasExplicitParticleColorBy:i,getEdgeColor:o,getNodeColor:s,resolveEndpoint:a,fallback:c}=e;if("function"==typeof n){const e=a(t.source);return e?n(t,e):c}if(!i)return o(t);const l=r,u=a(t.source),h=a(t.target);return"target"===l&&h?s(h):u?s(u):c}({edge:e,particleStyleColor:kt.color,particleColorBy:kt.colorBy,hasExplicitParticleColorBy:!!L?.colorBy,getEdgeColor:an,getNodeColor:Jt,resolveEndpoint:sn,fallback:en}),[L?.colorBy,kt.color,kt.colorBy,Jt,an,en,sn]),ln=function(e,t,n,r,i){return("sankey"===e||t)&&n||r||i}(n,!!Ge,N,!!_e,Rt.current?.isAnimating??!1);rn(Rt,At,Ze,ft),on(Rt,Ke,Ze,ft),(0,Wa.useEffect)(()=>{const e=Rt.current;e&&(Tt(e,[it,ot]),Zt.current=lu({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Qt.current,colorScheme:O}),Ze.current=!0,ft())},[pt,it,ot,Tt,ft,O]);const un=(0,Wa.useCallback)(()=>{const e=Rt.current;if(e&&(e.runLayout([it,ot]),Tt(e,[it,ot]),Ze.current=!0,Zt.current=lu({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Qt.current,colorScheme:O}),Lt(e.layoutVersion),ce)){const{nodes:t,edges:n}=e.getLayoutData();ce(t,n)}},[it,ot,Tt,ce,O]),hn=(0,Wa.useCallback)(e=>{if(null==e||"object"!=typeof e)return;const t=Rt.current;t&&(t.ingestEdge(e)&&un(),ft())},[un,ft]),dn=(0,Wa.useCallback)(e=>{const t=Rt.current;if(!t)return;let n=!1;for(const r of e)null!=r&&"object"==typeof r&&t.ingestEdge(r)&&(n=!0);n&&un(),ft()},[un,ft]),fn=(0,Wa.useCallback)(()=>{Rt.current?.clear(),Qt.current.clear(),Zt.current=0,Lt(Rt.current?.layoutVersion??0),Dt(null),Ut.current=null,Ze.current=!0,ft()},[ft]),yn=(0,Wa.useCallback)(()=>{const e=Rt.current;e&&(e.tension+=999,un(),ft())},[un,ft]);(0,Wa.useImperativeHandle)(t,()=>({push:hn,pushMany:dn,removeNode:e=>{const t=Rt.current?.removeNode(e)??!1;if(t){const t=Ut.current?.data?"function"==typeof a?a(Ut.current.data):Ut.current.data[a]:void 0;Ut.current&&"node"===Ut.current.nodeOrEdge&&t===e&&(Ut.current=null,Dt(null)),Qt.current.delete(e),un(),Ze.current=!0,ft()}return t},removeEdge:(e,t)=>{const n=Rt.current?.removeEdge(e,t)??!1;if(n){if(Ut.current&&"edge"===Ut.current.nodeOrEdge){const n=Ut.current.data;let r;r=void 0!==t?("object"==typeof n?.source?n.source.id:n?.source)===e&&("object"==typeof n?.target?n.target.id:n?.target)===t:!h||!n||("function"==typeof h?h:e=>e?.[h])(n)===e,r&&(Ut.current=null,Dt(null))}un(),Ze.current=!0,ft()}return n},updateNode:(e,t)=>{const n=Rt.current?.updateNode(e,t)??null;return n&&(Ze.current=!0,ft()),n},updateEdge:(e,t,n)=>{const r=Rt.current?.updateEdge(e,t,n)??[];return r.length>0&&(un(),Ze.current=!0,ft()),r},clear:fn,getTopology:()=>Rt.current?.getLayoutData()??{nodes:[],edges:[]},getCustomLayout:()=>Rt.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Rt.current?.lastCustomLayoutFailure??null,getTopologyDiff:()=>{const e=Rt.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:yn,getTension:()=>Rt.current?.tension??0}),[hn,dn,fn,yn,a,un,ft,h]);const pn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(n),gn=pn?o||(Array.isArray(i)?void 0:i):void 0;(0,Wa.useEffect)(()=>{const e=Rt.current;if(!e)return;const t=++Bt.current;if(Yt.current?.abort(),Yt.current=null,pn&&gn)e.ingestHierarchy(gn,[it,ot]),Tt(e,[it,ot]),Ft(!1),Xt.current?.("ready"),Ze.current=!0,ft();else{const o=xt,s=Array.isArray(vt)?vt:[];if(0===o.length&&0===s.length)return null==r&&null==i||0>=e.nodes.size&&0>=e.edges.size||fn(),Ft(!1),void Xt.current?.("ready");const a=[it,ot],c="force"===n&&!Ge&&Ul()&&!Te&&function(e,t,n,r,i=4e4){return"sync"!==e&&("worker"===e||r*(t+n)>=i)}(b,o.length,s.length,x);if(c&&mt&&!Ht.current&&e.sceneNodes.length>0)return Ht.current=!0,Ft(!1),Xt.current?.("ready"),Ze.current=!0,void ft();if(c){const n=new AbortController;Yt.current=n;const r=e._lastPositionSnapshot;e.ingestBounded(o,s,a,{deferLayout:!0});const i=e.getLayoutData(),c=function(e,t,n,r,i){const o=Hc(n.nodeSize,n.nodeSizeRange,e);return{kind:"frame",nodes:e.map(e=>{const t=i?.get(e.id);return{id:e.id,x:0!==e.x||0!==e.y?e.x:t?.x??0,y:0!==e.x||0!==e.y?e.y:t?.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:e.value,__forceRadius:o(e)}}),edges:t.map(e=>{const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id,r=e.data?.weight,i="number"==typeof r&&Number.isFinite(r)?r:e.value;return{source:t,target:n,value:e.value,y0:0,y1:0,sankeyWidth:0,weight:i}}),config:{chartType:"force",iterations:n.iterations,forceStrength:n.forceStrength,seed:n.seed},size:r}}(i.nodes,i.edges,qt.current,a,r);return Ft(!0),Xt.current?.("pending"),function(e,t){return Ul()?t?.aborted?Promise.reject(Kl()):(Zl&&!Zl.isDead||(Zl=new Ql),Zl).request(e,t):Promise.reject(Error("Web Workers are unavailable"))}(c,n.signal).then(({positions:n})=>{t===Bt.current&&(e.applyForceLayoutPositions(n,a),Tt(e,a),Zt.current=lu({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Qt.current,colorScheme:O}),Ft(!1),Xt.current?.("ready"),Lt(e.layoutVersion),Ze.current=!0,ft())}).catch(n=>{"AbortError"!==n.name&&t===Bt.current&&(e.runLayout(a),Tt(e,a),Zt.current=lu({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Qt.current,colorScheme:O}),Ft(!1),Xt.current?.("error"),Lt(e.layoutVersion),Ze.current=!0,ft())}),()=>n.abort()}e.ingestBounded(o,s,a),Tt(e,a),Ft(!1),Xt.current?.("ready"),Zt.current=lu({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Qt.current,colorScheme:O}),Ze.current=!0,ft()}},[xt,vt,r,i,o,gn,pn,it,ot,St,b,x,mt,n,Ge,Te,ft,fn,O,Tt]),(0,Wa.useEffect)(()=>{s&&s.length>0&&dn(s)},[s,dn]);const{customHoverBehavior:mn,customClickBehavior:vn}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:r}){return{customHoverBehavior:(0,mu.useCallback)((t,i)=>{e?.(t,i),ka({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:xu,chartId:r,context:i})},[e,n,r]),customClickBehavior:(0,mu.useCallback)((e,i)=>{t?.(e,i),wa({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:xu,chartId:r,context:i})},[t,n,r])}}({customHoverBehavior:re,customClickBehavior:ie,onObservation:oe,chartId:ae}),{hoverHandlerRef:bn,hoverLeaveRef:kn,onPointerMove:wn,onPointerLeave:An}=Je,Sn=()=>!Ge||(Rt.current?.hasCustomRestyle??!1);bn.current=e=>{if(!te)return;const t=Sn(),n=Dn.current;if(!n)return;const r=Rt.current;if(!r)return;const i=gu({clientX:e.clientX,clientY:e.clientY,canvasRect:n.getBoundingClientRect(),margin:rt,adjustedWidth:it,adjustedHeight:ot,sceneNodes:r.sceneNodes,sceneEdges:r.sceneEdges,nodeQuadtree:r.nodeQuadtree,maxNodeRadius:r.maxNodeRadius});"hit"===i.kind?(Ut.current=i.hover,Dt(i.hover),mn&&(mn(i.hover),t&&(Ze.current=!0)),t&&ft()):Ut.current&&(Ut.current=null,Dt(null),mn&&(mn(null),t&&(Ze.current=!0)),t&&ft())},kn.current=()=>{if(Ut.current){const e=Sn();Ut.current=null,Dt(null),mn&&(mn(null),e&&(Ze.current=!0)),e&&ft()}};const _n=(0,Wa.useRef)(()=>{});_n.current=e=>{if(ii(e.target))return;if(!ie&&!oe)return;const t=Dn.current;if(!t)return;const n=Rt.current;if(!n)return;const r=gu({clientX:e.clientX,clientY:e.clientY,canvasRect:t.getBoundingClientRect(),margin:rt,adjustedWidth:it,adjustedHeight:ot,sceneNodes:n.sceneNodes,sceneEdges:n.sceneEdges,nodeQuadtree:n.nodeQuadtree,maxNodeRadius:n.maxNodeRadius});"hit"===r.kind?vn(r.hover,{type:"activate",inputType:va(e.nativeEvent.pointerType)}):"miss"===r.kind&&vn(null)};const Mn=(0,Wa.useCallback)(e=>_n.current(e),[]),Pn=(0,Wa.useRef)(-1),Rn=(0,Wa.useRef)(null),jn=(0,Wa.useRef)(-1),Tn=(0,Wa.useCallback)(e=>{if(ba(e))return;const t=Rt.current;if(!t)return;const n=()=>{Pn.current=-1,Rn.current=null,jn.current=-1,Ut.current=null,Dt(null),mn&&(mn(null),Ze.current=!0),ft()},r=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=xn(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===r.length)return void(0>Pn.current||n());const i=_a(r);let o=Pn.current;if(i.flat.length>o||(n(),o=-1)," "===e.key&&o>=0){e.preventDefault();const t=i.flat[o];return void vn(os(t.datum||{},t.x,t.y,{nodeOrEdge:"node"}),{type:"activate",inputType:"keyboard"})}if(0>o){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),Pn.current=0,jn.current=-1;const t=i.flat[0];Rn.current={shape:t.shape,w:t.w,h:t.h};const n=os(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Ut.current=n,Dt(n),mn&&(mn(n,{type:"focus",inputType:"keyboard"}),Ze.current=!0),void ft()}const s=Ma(i,o),a=function(e,t,n,r,i){const o=n.flat[t.flatIndex];if(!o)return Ca(e,t,n);const s=o.datum?.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const r=function(e,t,n){let r=null,i=1/0;for(let o=0;e.flat.length>o;o++){const s=e.flat[o];if(s===t)continue;const a=s.x-t.x,c=s.y-t.y;let l=!1;switch(n){case"right":l=a>0&&Math.abs(a)>=Math.abs(c);break;case"left":l=0>a&&Math.abs(a)>=Math.abs(c);break;case"down":l=c>0&&Math.abs(c)>=Math.abs(a);break;case"up":l=0>c&&Math.abs(c)>=Math.abs(a)}if(!l)continue;const u=a*a+c*c;i>u&&(i=u,r=o)}return r}(n,o,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up")??t.flatIndex;return r!==t.flatIndex&&(i.current=-1),r}case"Enter":{if(null==s)return t.flatIndex;const e=function(e,t){const n=e+"",r=[];for(const e of t){const t=e.datum??e,i=ja(t.source),o=ja(t.target),s=null!=i,a=null!=o;s&&i+""===n&&a?r.push(o+""):a&&o+""===n&&s&&r.push(i+"")}return r}(s,r);if(0===e.length)return t.flatIndex;const o=n.idToIdx.get(e[(i.current+1)%e.length])??-1;return 0>o?t.flatIndex:(i.current=-1,o)}default:{const r=Ca(e,t,n);return null!==r&&r!==t.flatIndex&&(i.current=-1),r}}}(e.key,s,i,t.sceneEdges??[],jn);if(null===a)return;if(e.preventDefault(),0>a)return void n();Pn.current=a;const c=i.flat[a];Rn.current={shape:c.shape,w:c.w,h:c.h};const l={data:c.datum||{},x:c.x,y:c.y,__semioticHoverData:!0,nodeOrEdge:"node"};Ut.current=l,Dt(l),mn&&(mn(l,{type:"focus",inputType:"keyboard"}),Ze.current=!0),ft()},[vn,mn,ft]),En=(0,Wa.useCallback)(e=>{Pn.current=-1,Rn.current=null,wn(e)},[wn]);dt.current=()=>{if(ht.current=null,!yt.isActive)return;const e=Dn.current;if(!e)return;const t=Rt.current;t&&function(e){const{canvas:t,store:n,sceneRevisionDiagnostics:r,size:i,margin:o,adjustedWidth:s,adjustedHeight:a,background:c,renderMode:l,hasBackgroundGraphics:u=!1,dirtyRef:h,lastFrameTimeRef:d,now:f,random:y,reducedMotion:p,showParticles:g,isContinuous:m,animate:x,decay:v,pulse:b,thresholds:k,staleness:w,particleStyle:A,getParticleColor:S,pendingAnnotationFrameRef:_,lastAnnotationFrameTimeRef:M,setAnnotationFrame:C,scheduleNextFrame:P}=e,R=t.getContext("2d");if(!R)return;const j=d.current?Math.min((f-d.current)/1e3,.1):.016;d.current=f;const T=n.advanceTransition(p?f+1e6:f),E=!p&&T,D=!p&&n.tickAnimation([s,a],j),N=h.current,L=r?.beforeCompute(n.getLastUpdateResult(),E),I=T||N||D;I&&n.buildScene([s,a]),L&&r?.afterCompute(L,I,!1);const W=g&&!p&&!!n.particlePool,$=!!((z={dirtyOrRebuilt:N,transitioning:E,animationTicked:D,continuous:W||m,liveEncoding:!!v||!!b||!!k||!1!==x&&n.hasActiveTopologyDiff||n.hasActivePulses||n.hasActiveThresholds,forced:n.consumeStylePaintPending()}).dirtyOrRebuilt||z.transitioning||z.animationTicked||z.continuous||z.liveEncoding||z.forced);var z;const O=!!w&&n.lastIngestTime>0&&f-n.lastIngestTime>(w?.threshold??5e3);if($){const e=Ds();if(!Es(t,i,o,e))return;if(R.clearRect(-o.left,-o.top,i[0],i[1]),bo(R,{background:c,hasBackgroundGraphics:u,width:s,height:a}),v&&n.applyDecay(),b&&n.applyPulse(f),k&&n.applyThresholds(f),!1!==x&&n.applyTopologyDiff(f),O&&(R.globalAlpha=w?.dimOpacity??.5),ya({context:R,nodes:n.sceneEdges,renderMode:l,pixelRatio:e,paintBuiltIn:e=>function(e,t){for(const n of t)switch(n.type){case"bezier":ru(e,n);break;case"line":iu(e,n);break;case"ribbon":ou(e,n);break;case"curved":su(e,n)}}(R,e)}),ya({context:R,nodes:n.sceneNodes,renderMode:l,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=Wn(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=Cn(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)),Xs(e,t),e.restore())}}(R,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=Wn(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=Cn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),qs(e,t),e.restore())}}(R,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=Wn(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=Cn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),e.restore()}}(R,t),function(e,t){const n=e.globalAlpha;for(const r of t){if("symbol"!==r.type)continue;const t=r;if(0>=t.size)continue;const i=cu(t);if(!i)continue;e.save(),e.translate(t.cx,t.cy),t.rotation&&e.rotate(t.rotation);const o=t.style.opacity??1;t.style.fill&&(e.globalAlpha=n*o*(t.style.fillOpacity??1),e.fillStyle=Wn(e,t.style.fill,"#007bff"),e.fill(i)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*o,e.strokeStyle=Cn(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.stroke(i)),e.restore()}}(R,t),function(e,t){const n=e.globalAlpha;for(const r of t)"glyph"===r.type&&ta(e,r,r.cx,r.cy,n);e.globalAlpha=n}(R,t)}}),W&&!O){const e=n.edgesArray;if(e.length>0){!function(e,t,n,r,i=Math.random){const o=r.spawnRate??.1,s=r.maxPerEdge??50;for(let r=0;t.length>r;r++){const a=t[r];if(!a.bezier)continue;if(e.countForEdge(r)>=s)continue;const c=a.value*o*n*(a.bezier.circular?.3:1),l=Math.floor(c),u=c-l;let h=l;i()<u&&h++;for(let t=0;h>t&&e.countForEdge(r)<s;t++)e.spawn(r,i)}}(n.particlePool,e,j,A,y);const t=.5*(A.speedMultiplier??1);let r;if(A.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);r=e.map(e=>.3+(e.value||1)/t*1.7)}n.particlePool.step(j,t,e,r),function(e,t,n,r,i){const o=r.radius??3;e.globalAlpha=r.opacity??.7;for(let s=0;t.particles.length>s;s++){const a=t.particles[s];if(!a.active)continue;const c=n[a.edgeIndex];if(!c)continue;let l;l="string"==typeof r.color&&"inherit"!==r.color?r.color:i(c),e.fillStyle=Cn(e,l)||l,e.beginPath(),e.arc(a.x,a.y,o,0,2*Math.PI),e.fill()}e.globalAlpha=1}(R,n.particlePool,e,A,S)}}O&&(R.globalAlpha=1)}h.current=!1,(N||E||D)&&t.setAttribute("aria-label",Lo(n.sceneNodes?.length??0,n.sceneEdges?.length??0,"Network chart"));const F=N||E||D||_.current;F&&f-M.current>=33?(C(e=>e+1),M.current=f,_.current=!1):_.current=!!F,(m||E||null!=n.transition||D||n.hasActivePulses||n.hasActiveThresholds||!1!==x&&n.hasActiveTopologyDiff||_.current)&&P()}({canvas:e,store:t,sceneRevisionDiagnostics:jt.current,size:nt,margin:rt,adjustedWidth:it,adjustedHeight:ot,background:ee,renderMode:I,hasBackgroundGraphics:!!Ae,dirtyRef:Ze,lastFrameTimeRef:Mt,now:yt.now(),random:yt.random,reducedMotion:!!et.current,showParticles:N,isContinuous:ln,animate:Ce,decay:Se,pulse:_e,thresholds:Le,staleness:Pe,particleStyle:kt,getParticleColor:cn,pendingAnnotationFrameRef:Pt,lastAnnotationFrameTimeRef:Ct,setAnnotationFrame:Wt,scheduleNextFrame:()=>{ft()}})};const{canvasRef:Dn}=Rs(Je,{hydrated:gt,wasHydratingFromSSR:mt,storeRef:Rt,dirtyRef:Ze,canvasPaintDependencies:[n,it,ot,ee,Ae,I,ft]});or(Pe,Rt,Ze,ft,$t,zt);const Nn=te&&Et?(0,vu.jsx)(ys,{x:Et.x,y:Et.y,containerWidth:it,containerHeight:ot,margin:rt,className:"stream-network-tooltip",zIndex:2,children:ne?ne(Et):(0,vu.jsx)(tu,{data:Et})}):null;if(so||!gt&&mt)return(0,vu.jsx)(Bl,{props:e,store:Rt.current,responsiveRef:tt,size:nt,margin:rt,adjustedWidth:it,adjustedHeight:ot,resolvedBackground:at,resolvedForeground:st});const Ln=Rt.current;return(0,vu.jsxs)("div",{ref:tt,className:"stream-network-frame"+(J?" "+J:""),role:"group","aria-label":We||("string"==typeof ke?ke:"Network chart"),tabIndex:0,"aria-busy":Ot||void 0,style:{position:"relative",width:K?"100%":nt[0],height:Q?"100%":nt[1],overflow:"visible"},onKeyDown:Tn,children:["production"!==process.env.NODE_ENV&&Rt.current&&(0,vu.jsx)(Vt,{store:Rt.current,diagnostics:jt.current}),Ie&&(0,vu.jsx)(Zo,{tableId:ut}),Ie&&(0,vu.jsx)(Ko,{nodes:Ln?.sceneNodes??[],edges:Ln?.sceneEdges??[],chartType:"Network chart",tableId:ut,chartTitle:"string"==typeof ke?ke:void 0}),(0,vu.jsx)(Qo,{summary:$e}),(0,vu.jsx)(Ro,{hoverPoint:Et}),(0,vu.jsxs)("div",{role:"img","aria-label":We||("string"==typeof ke?ke:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:te?En:void 0,onMouseLeave:te?An:void 0,onClick:ie||oe?Mn:void 0,children:[Ot&&!1!==k&&(0,vu.jsx)("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:Gl(!0,nt[0],nt[1],k)}),(0,vu.jsx)(js,{size:nt,margin:rt,overflowVisible:!0,children:at}),(0,vu.jsx)("canvas",{ref:Dn,"aria-label":Lo(Ln?.sceneNodes?.length??0,Ln?.sceneEdges?.length??0,"Network chart"),style:{position:"absolute",top:0,left:0}}),(0,vu.jsx)(Il,{width:it,height:ot,totalWidth:nt[0],totalHeight:nt[1],margin:rt,labels:Ln?.labels||[],sceneNodes:Ln?.sceneNodes,title:ke,legend:ye,legendPosition:pe,legendLayout:ge,legendHoverBehavior:me,legendClickBehavior:xe,legendHighlightedCategory:ve,legendIsolatedCategories:be,foregroundGraphics:Kt(st,tn(Rt.current?.customLayoutOverlays,Ke??null)),annotations:le,onAnnotationActivate:ue,onObservation:se??oe,chartId:ae,chartType:"StreamNetworkFrame",autoPlaceAnnotations:de,svgAnnotationRules:fe,annotationFrame:It}),(0,vu.jsx)(Ol,{marks:Ln?.customLayoutHtmlMarks,margin:rt,selection:Ke??null}),(0,vu.jsx)(ts,{active:Pn.current>=0,hoverPoint:Et,margin:rt,size:nt,shape:Rn.current?.shape,width:Rn.current?.w,height:Rn.current?.h}),Nn,Pe?.showBadge&&(0,vu.jsx)(ar,{isStale:$t,position:Pe.badgePosition})]})]})}));Su.displayName="StreamNetworkFrame";var _u=Su,Mu=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}},Cu=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,r=Math.floor(e/n);for(let i=Math.floor((e-this.size)/n)+1;r>=i;i++)this.bump(i*n,t)}bump(e,t){let n=this.windows.get(e);n||(n=new Mu,this.windows.set(e,n)),n.push(t)}pushSession(e,t){const n=this.gap,r=new Mu;r.push(t);let i=e,o=e;const s=[],a={start:i,end:o,stats:r};for(const t of this.sessions)e-n>t.end||t.start>e+n?s.push(t):(a.stats.merge(t.stats),i>t.start&&(i=t.start),t.end>o&&(o=t.end));a.start=i,a.end=o,s.push(a),s.sort((e,t)=>e.start-t.start),this.sessions=s}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 r=t+this.size;e.push(this.row(t,r,n,r>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,r){return{start:e,end:t,count:n.count,mean:n.mean,sum:n.sum,min:n.min,max:n.max,stddev:n.stddev,partial:r}}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 Pu(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 Ru(e,t,n,r=1){if("none"===t)return null;if("minmax"===t)return[e.min,e.max];const i=Pu(e,n),o=e.stddev*r;return[i-o,i+o]}var ju={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},Tu=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g;function Eu(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;Tu.lastIndex=0;let n,r=0,i=0;for(;null!==(n=Tu.exec(t));){const e=parseFloat(n[1]),t=ju[n[2]];if(null==t||!Number.isFinite(e))return null;r+=e*t,i+=n[0].length}return i!==t.length?null:r>0?r:null}var Du=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 r of this.held)this.getTime(r)>e?n.push(r):t.push(r);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}},Nu=require("react"),Lu=require("react");function Iu(e){const t=[];for(const[n,r]of Object.entries(e.fields))if("point"===r.type)t.push(e=>r.values.has(e[n]));else{const[e,i]=r.range;t.push(t=>{const r=t[n];return r>=e&&i>=r})}return e=>t.every(t=>t(e))}function Wu(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}function $u(e,t){if(e.type!==t.type)return!1;if("interval"===e.type&&"interval"===t.type)return e.range[0]===t.range[0]&&e.range[1]===t.range[1];if("point"===e.type&&"point"===t.type){if(e.values.size!==t.values.size)return!1;for(const n of e.values)if(!t.values.has(n))return!1;return!0}return!1}var[zu,Ou]=M(e=>({selections:new Map,setClause(t,n){e(e=>{const r=e.selections.get(t),i=r?.clauses.get(n.clientId);if(i&&function(e,t){if(e.clientId!==t.clientId||e.type!==t.type)return!1;const n=Object.entries(e.fields);if(n.length!==function(e){let t=0;for(const n in e)t++;return t}(t.fields))return!1;for(const[e,r]of n){const n=t.fields[e];if(!n||!$u(r,n))return!1}return!0}(i,n))return{};const o=new Map(e.selections),s=Wu(o,t),a=new Map(s.clauses);return a.set(n.clientId,n),o.set(t,{...s,clauses:a}),{selections:o}})},clearClause(t,n){e(e=>{const r=e.selections.get(t);if(!r||!r.clauses.has(n))return{};const i=new Map(e.selections),o=new Map(r.clauses);return o.delete(n),i.set(t,{...r,clauses:o}),{selections:i}})},setResolution(t,n){e(e=>{const r=e.selections.get(t);if(r?.resolution===n)return{};const i=new Map(e.selections),o=Wu(i,t);return i.set(t,{...o,resolution:n}),{selections:i}})},clearSelection(t){e(e=>{const n=e.selections.get(t);if(!n||0===n.clauses.size)return{};const r=new Map(e.selections);return r.set(t,{...n,clauses:new Map}),{selections:r}})}})),Fu=require("react");function Bu(e){const t=(0,Fu.useId)(),n=e.clientId||t,{name:r}=e,i=Ou(e=>e.selections.get(r)),o=Ou(e=>e.setClause),s=Ou(e=>e.clearClause),a=(0,Fu.useMemo)(()=>!!i&&i.clauses.size>0,[i]);return{predicate:(0,Fu.useMemo)(()=>i&&0!==i.clauses.size?function(e,t){const n=[];for(const[r,i]of e.clauses)"crossfilter"===e.resolution&&r===t||n.push(Iu(i));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(i,n):()=>!0,[i,n]),isActive:a,selectPoints:(0,Fu.useCallback)(e=>{const t={};let i=!1;for(const[n,r]of Object.entries(e))t[n]={type:"point",values:new Set(r)},i=!0;i&&o(r,{clientId:n,type:"point",fields:t})},[n,r,o]),selectInterval:(0,Fu.useCallback)(e=>{const t={};let i=!1;for(const[n,r]of Object.entries(e))t[n]={type:"interval",range:r},i=!0;i&&o(r,{clientId:n,type:"interval",fields:t})},[n,r,o]),clear:(0,Fu.useCallback)(()=>{s(r,n)},[s,r,n]),clientId:n}}function Yu(e){return 2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]}function Hu(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function Xu(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function qu(e,t,n){const r=e.xValue??t?.[n];if(null==r)return null;const i=Number(r);return Number.isFinite(i)?i:null}function Gu(e){let t=e.data||e.datum||e;return Array.isArray(t)&&(t=t[0]),null!=e.xValue&&t&&"object"==typeof t&&!Array.isArray(t)&&null==t.xValue?{...t,xValue:e.xValue}:t||{}}var Vu=[],Uu={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function Ku(e,t={}){const n=t.mobileSemantics?.interaction,r="number"==typeof n?.targetSize?n.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,i="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,o=!!n||void 0!==r,s=e&&"object"==typeof e?e:void 0;if(!1===e||!1===s?.enabled||void 0===e&&!i&&!o)return Uu;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??r??44,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??44,standardControls:a.standardControls??!1}}function Qu({selection:e,linkedHover:t,fallbackFields:n=Vu,unwrapData:r=!1,onObservation:i,chartType:o,chartId:s,onClick:a,hoverHighlight:c,colorByField:l,mobileInteraction:u}){const h=(0,Lu.useId)(),d=(0,Lu.useMemo)(()=>function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField,seriesField:e.seriesField}:null}(t,n),[t,n]),f=(0,Lu.useMemo)(()=>"series"===d?.mode?[d.seriesField||l||n[0]].filter(e=>!!e):d?.fields||n,[d,l,n]),y=Bu({name:e?.name||"__unused__",fields:f}),p=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:r,isActive:i,selectPoints:o,clear:s}=Bu({name:t,fields:n});return{onHover:(0,Fu.useCallback)(e=>{if(!e)return void s();const t={};for(const r of n){const n=e[r];void 0!==n&&(t[r]=[n])}Hu(t)&&o(t)},[n,o,s]),predicate:r,isActive:i}}({name:d?.name||"hover",fields:f}),g=ti(e=>e.pushObservation),m=(0,Lu.useCallback)(e=>{i?.(e),g?.(e)},[i,g]),x=e?{isActive:y.isActive,predicate:y.predicate}:null,[v,b]=(0,Lu.useState)(null),k=(0,Lu.useRef)(!1),w=l||n[0],A=(0,Lu.useMemo)(()=>{if(!c||null==v||!w)return null;const e=v,t=w;return{isActive:!0,predicate:n=>("string"==typeof n[t]?n[t]:(n[t]??"")+"")===e}},[c,v,w]),S=(0,Lu.useCallback)((e,n)=>{const r=!e&&k.current&&!!u?.enabled&&u.tapToLockTooltip;if(t)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===d?.mode&&d.xField){const n=qu(e,t,d.xField);null!=n&&function(e,t,n){const r=Ei.positions.get(e);r?.locked||r&&r.xValue===t&&r.sourceId===n||(Ei={positions:new Map(Ei.positions).set(e,{xValue:t,sourceId:n})},Ni())}(d.name||"hover",n,h)}"x-position"!==d?.mode&&p.onHover(t)}else"x-position"!==d?.mode||r||Li(d.name||"hover",h),"x-position"===d?.mode||r||p.onHover(null);if(c&&w)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=t?.[w];b(null!=n?n+"":null)}else r||b(null);(i||g)&&ka({onObservation:m,datum:e?Gu(e):null,x:e?.x,y:e?.y,chartType:o||"unknown",chartId:s,context:n})},[t,p,d,h,i,o,s,g,m,c,w,u]),_=(0,Lu.useCallback)((n=!0)=>{k.current=!1,t&&"x-position"!==d?.mode&&p.onHover(null),e&&u?.tapToSelect&&y.clear(),n&&c&&b(null),"x-position"===d?.mode&&(Ii(d.name||"hover",h),Li(d.name||"hover",h))},[t,d,p,e,u,y,c,h]),M=(0,Lu.useCallback)((n,r)=>{const l=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),x=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===d?.mode&&d.xField&&n){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]);const t=qu(n,e,d.xField);null!=t&&function(e,t,n){const r=Ei.positions.get(e);if(r?.locked){const t=new Map(Ei.positions);return t.delete(e),Ei={positions:t},Ni(),!1}Ei={positions:new Map(Ei.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Ni()}(d.name||"hover",t,h)}if(l)if(n){k.current=!0;const r=Gu(n);if(t&&"x-position"!==d?.mode&&p.onHover(r),e&&u?.tapToSelect&&f.length>0){const e={};for(const t of f){const n=r[t];void 0!==n&&(e[t]=[n])}(function(e){if(!e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1})(e)&&y.selectPoints(e)}if(c&&w){const e=r?.[w];b(null!=e?e+"":null)}}else x&&_();if(n||x){if(n&&a){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]),a(e,{x:n.x??0,y:n.y??0})}(i||g)&&wa({onObservation:m,datum:n?Gu(n):null,x:n?.x,y:n?.y,chartType:o||"unknown",chartId:s,context:r})}},[a,i,g,m,o,s,d,h,u,t,p,e,y,f,c,w,_]);return(0,Lu.useEffect)(()=>{if(!u?.enabled||"undefined"==typeof document)return;const e=e=>{"Escape"===e.key&&k.current&&_()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u?.enabled,_]),(0,Lu.useEffect)(()=>()=>{k.current&&_(!1)},[_]),(0,Lu.useEffect)(()=>{if("x-position"!==d?.mode)return;const e=d.name||"hover";return()=>{Ii(e,h),Li(e,h)}},[d?.mode,d?.name,h]),{activeSelectionHook:x,hoverSelectionHook:A,customHoverBehavior:S,customClickBehavior:M,crosshairSourceId:h}}var Zu={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}},mobile:{width:390,height:300,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:!1,showLabels:!0,marginDefaults:{top:28,bottom:42,left:44,right:16}}};function Ju(e,t,n){const r=Zu[e||"primary"],i=e&&"primary"!==e||!n?.width?r.width:n.width,o=e&&"primary"!==e||!n?.height?r.height:n.height,s=function(e,t,n=e.responsiveRules){if(!Array.isArray(n)||0===n.length)return{props:e,matches:[]};const r=n.map((e,t)=>({rule:e,index:t})).filter(e=>function(e,t){const{when:n}=e,r=t.width,i=t.height,o=function(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}(t),s=function(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}(t);return!("number"==typeof n.minWidth&&n.minWidth>r||"number"==typeof n.maxWidth&&r>n.maxWidth||"number"==typeof n.minHeight&&("number"!=typeof i||n.minHeight>i)||"number"==typeof n.maxHeight&&("number"!=typeof i||i>n.maxHeight)||"number"==typeof n.minAspectRatio&&("number"!=typeof o||n.minAspectRatio>o)||"number"==typeof n.maxAspectRatio&&("number"!=typeof o||o>n.maxAspectRatio)||n.orientation&&s!==n.orientation)}(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:r.reduce((e,t)=>function(e,t){const n={...e,...t};for(const r of["margin","frameProps","mobileSemantics","style"])Xu(e[r])&&Xu(t[r])&&(n[r]={...e[r],...t[r]});return"string"==typeof e.className&&"string"==typeof t.className&&(n.className=`${e.className} ${t.className}`),n}(e,t.rule.transform),e),matches:r}}({...t,mode:e},{width:t.width??i,height:t.height??o}).props,a=s.mode||e,c=Zu[a||"primary"],l="context"===a||"sparkline"===a,u=a&&"primary"!==a||!n?.width?c.width:n.width;return{width:s.width??u,height:s.height??(a&&"primary"!==a||!n?.height?c.height:n.height),showAxes:s.showAxes??c.showAxes,showGrid:s.showGrid??c.showGrid,enableHover:s.enableHover??(!!s.linkedHover||c.enableHover),showLegend:s.showLegend??c.showLegend,showLabels:s.showLabels??c.showLabels,title:l?void 0:s.title,description:s.description,summary:s.summary,accessibleTable:s.accessibleTable,xLabel:l?void 0:s.xLabel,yLabel:l?void 0:s.yLabel,categoryLabel:l?void 0:s.categoryLabel,valueLabel:l?void 0:s.valueLabel,marginDefaults:eh(c.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:l,mobileInteraction:Ku(s.mobileInteraction,{mode:a,width:s.width??u,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}function eh(e,t,n){if(!1!==t)return e;const r={...e};return"horizontal"===n?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}var th=require("react/jsx-runtime"),nh={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"},rh={opacity:.7,marginRight:4};function ih(e,t,n){if(null!=e)return"function"==typeof t?t(e):e["string"==typeof t?t:n]}function oh(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function sh(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:r="x",yLabel:i="y"}=e;return e=>{const o=e?.data??null,s=ih(o,t,"time"),a=ih(o,n,"value");return(0,th.jsxs)("div",{className:"semiotic-tooltip",style:nh,children:[(0,th.jsxs)("div",{children:[(0,th.jsxs)("span",{style:rh,children:[r,":"]}),oh(s)]}),(0,th.jsxs)("div",{children:[(0,th.jsxs)("span",{style:rh,children:[i,":"]}),oh(a)]})]})}}function ah(e,t){return null!=e?e:Math.max(t?.length??0,200)}var ch="time",lh="value",uh="__aggLower",hh="__aggUpper",dh="__aggPartial",fh="count",yh="__aggStart",ph="__aggEnd";function gh(e,t){const n=t.stat??"mean",r=t.band??"none",i=t.sigma??1;return e.emit().map(e=>{const t={[ch]:(e.start+e.end)/2,[lh]:Pu(e,n),[fh]:e.count,[dh]:e.partial,[yh]:e.start,[ph]:e.end},o=Ru(e,r,n,i);return o&&(t[uh]=o[0],t[hh]=o[1]),t})}function mh(e){const{linkedHover:t,selection:n,onObservation:r,onClick:i,hoverRadius:o,hoverHighlight:s,forceHoverBehavior:a,forceClickBehavior:c,mobileInteraction:l,customHoverBehavior:u,customClickBehavior:h,linkedHoverInClickPredicate:d=!0}=e,f={};r&&(f.annotationObservationCallback=r);const y=l?.enabled?Math.max(o??30,Math.ceil((l.targetSize||44)/2),24):o;return(a||t||r||i||s)&&(f.customHoverBehavior=u),h&&(c||(d?r||i||t:r||i)||l?.enabled&&(l.tapToSelect||l.tapToLockTooltip)&&(t||s||n))&&(f.customClickBehavior=h),null!=y&&(f.hoverRadius=y),f}var xh=require("react/jsx-runtime");function vh(e,t,n){const r="function"==typeof t?t(e):e[t??n];if(null==r)return null;if(r instanceof Date)return r.getTime();const i=Number(r);return Number.isFinite(i)?i:null}var bh=(0,Nu.forwardRef)(function(e,t){const n=Ju(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:r,margin:i,className:o,arrowOfTime:s="right",windowMode:a="sliding",windowSize:c,data:l,timeAccessor:u,valueAccessor:h,timeExtent:d,valueExtent:f,extentPadding:y,stroke:p="#007bff",strokeWidth:g=2,strokeDasharray:m,opacity:x,background:v,tooltipContent:b,tooltip:k,onHover:w,annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:C,decay:P,pulse:R,staleness:j,transition:T,linkedHover:E,selection:D,onObservation:N,chartId:L,loading:I,loadingContent:W,emptyContent:$,emphasis:z,legendPosition:O,aggregate:F,eventTime:B}=e,Y=n.showAxes,H=n.enableHover,X=i??n.marginDefaults,q=r??[n.width,n.height],G=b??k??sh({timeAccessor:u,valueAccessor:h}),V=(0,Nu.useRef)(null),{customHoverBehavior:U}=Qu({selection:D,linkedHover:E,unwrapData:!0,onObservation:N,chartType:"RealtimeLineChart",chartId:L}),K=(0,Nu.useCallback)(e=>{w&&w(e),U(e)},[w,U]),Q=null!=F,[Z,J]=(0,Nu.useState)([]),ee=(0,Nu.useRef)(null),te=(0,Nu.useRef)(F);te.current=F;const ne=(0,Nu.useRef)(Q);ne.current=Q;const re=(0,Nu.useRef)(Z);re.current=Z;const ie=(0,Nu.useRef)({timeAccessor:u,valueAccessor:h});ie.current={timeAccessor:u,valueAccessor:h},(0,Nu.useEffect)(()=>{if(!Q)return void(ee.current=null);const e=te.current,t=function(e){const t=e.window??"tumbling",n=Eu("session"===t?e.gap??e.size:e.size);if(null==n)return null;const r=null!=e.hop?Eu(e.hop):void 0,i=null!=e.gap?Eu(e.gap):void 0;return new Cu({window:t,size:n,hop:r??void 0,gap:i??void 0,retain:e.retain})}(e);if(ee.current=t,t&&l){const{timeAccessor:e,valueAccessor:n}=ie.current;for(const r of l){const i=vh(r,e,"time"),o=vh(r,n,"value");null!=i&&null!=o&&t.push(i,o)}}J(t?gh(t,e):[])},[Q?[F.window??"tumbling",F.size,F.hop??"",F.gap??"",F.retain??""].join("|"):"",Q,l]),(0,Nu.useEffect)(()=>{Q&&ee.current&&J(gh(ee.current,te.current))},[F?.stat,F?.band,F?.sigma]);const oe=(0,Nu.useCallback)(e=>{const t=ee.current,n=te.current;if(!t||!n)return;const{timeAccessor:r,valueAccessor:i}=ie.current;for(const n of e){const e=vh(n,r,"time"),o=vh(n,i,"value");null!=e&&null!=o&&t.push(e,o)}J(gh(t,n))},[]),se=null!=B,ae=(0,Nu.useRef)(null),ce=(0,Nu.useRef)(B);ce.current=B;const le=(0,Nu.useRef)(se);le.current=se;const ue=(0,Nu.useRef)(N);ue.current=N;const he=(0,Nu.useRef)(L);he.current=L,(0,Nu.useEffect)(()=>{ae.current=se?function(e){const t=Eu(e.lateness);return null==t?null:new Du({lateness:t,getTime:e=>vh(e,ie.current.timeAccessor,"time")??NaN,latePolicy:e.latePolicy??"drop"})}(ce.current):null},[se?`${B.lateness}|${B.latePolicy??"drop"}`:"",se]);const de=(0,Nu.useCallback)(e=>{0!==e.length&&(ne.current?oe(e):V.current?.pushMany(e))},[oe]),fe=(0,Nu.useCallback)(e=>{const t=ae.current;if(!le.current||!t)return void de(e);const n=[];for(const r of e){const e=t.push(r);if(e.released.length&&n.push(...e.released),e.late.length){const n=ue.current;if(n){const{timeAccessor:r}=ie.current,i=ce.current?.latePolicy??"drop";for(const o of e.late)n({type:"late-data",datum:o,eventTime:vh(o,r,"time")??NaN,watermark:t.watermark,policy:i,lateCount:t.lateCount,timestamp:Date.now(),chartType:"RealtimeLineChart",chartId:he.current})}}}de(n)},[de]);(0,Nu.useImperativeHandle)(t,()=>({push:e=>fe([e]),pushMany:e=>fe(e),remove:e=>ne.current?[]:V.current?.remove(e)??[],update:(e,t)=>ne.current?[]:V.current?.update(e,t)??[],clear:()=>{ae.current?.clear(),ne.current?(ee.current?.clear(),J([])):V.current?.clear()},getData:()=>ne.current?re.current:V.current?.getData()??[],getScales:()=>V.current?.getScales()??null}),[fe]);const ye=Gl(I,q[0],q[1],W),pe=ye?null:ql(Q?void 0:l,q[0],q[1],$),ge={stroke:p,strokeWidth:g,strokeDasharray:m};null!=x&&(ge.opacity=x);const me=ah(c,l),xe=Q?Z:l,ve=Q?ch:u,be=Q?lh:h,ke=Q&&F&&"none"!==(F.band??"none")?{y0Accessor:uh,y1Accessor:hh,perSeries:!1}:void 0;return ye||pe||(0,xh.jsx)(Ia,{ref:V,chartType:"line",runtimeMode:"streaming",size:q,margin:X,className:z?`${o||""} semiotic-emphasis-${z}`.trim():o,arrowOfTime:s,windowMode:Q?"growing":a,windowSize:Q?Math.max(1,F?.retain??Math.max(Z.length,600)):me,data:xe,timeAccessor:ve,valueAccessor:be,xExtent:d,yExtent:f,extentPadding:y,band:ke,lineStyle:ge,showAxes:Y,background:v,hoverAnnotation:H,tooltipContent:G,...mh({linkedHover:E,selection:D,onObservation:N,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:K}),annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:C,decay:P,pulse:R,staleness:j,transition:T,pointIdAccessor:e.pointIdAccessor,legendPosition:O})});bh.displayName="RealtimeLineChart";var kh=require("react"),wh=require("react/jsx-runtime");function Ah(e,t,n){const r="function"==typeof t?t(e):e[t??n];if(null==r)return null;if(r instanceof Date)return r.getTime();if("string"==typeof r&&""===r.trim())return null;const i=Number(r);return Number.isFinite(i)?i:null}var Sh=(0,kh.forwardRef)(function(e,t){const n=Ju(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:r,size:i,margin:o,className:s,arrowOfTime:a="right",windowMode:c="sliding",windowSize:l,data:u,timeAccessor:h,valueAccessor:d,direction:f="up",timeExtent:y,valueExtent:p,extentPadding:g,categoryAccessor:m,colors:x,fill:v,stroke:b,strokeWidth:k,opacity:w,gap:A,background:S,tooltipContent:_,tooltip:M,onHover:C,annotations:P,autoPlaceAnnotations:R,svgAnnotationRules:j,tickFormatTime:T,tickFormatValue:E,linkedHover:D,selection:N,decay:L,pulse:I,staleness:W,transition:$,onObservation:z,chartId:O,loading:F,loadingContent:B,emptyContent:Y,emphasis:H,legendPosition:X,brush:q,onBrush:G,linkedBrush:V}=e,U=n.showAxes,K=n.enableHover,Q=o??n.marginDefaults,Z=i??[n.width,n.height],J=_??M??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const r=e?.data??null;if(null==r?.binStart||null==r?.binEnd){const e=ih(r,t,"time"),i=ih(r,n,"value");return(0,th.jsxs)("div",{className:"semiotic-tooltip",style:nh,children:[(0,th.jsxs)("div",{children:[(0,th.jsx)("span",{style:rh,children:"x:"}),oh(e)]}),(0,th.jsxs)("div",{children:[(0,th.jsx)("span",{style:rh,children:"y:"}),oh(i)]})]})}return(0,th.jsxs)("div",{className:"semiotic-tooltip",style:nh,children:[(0,th.jsxs)("div",{children:[(0,th.jsx)("span",{style:rh,children:"range:"}),oh(r.binStart),"–",oh(r.binEnd)]}),null!=r.total&&(0,th.jsxs)("div",{children:[(0,th.jsx)("span",{style:rh,children:"count:"}),oh(r.total)]}),null!=r.category&&(0,th.jsxs)("div",{children:[(0,th.jsx)("span",{style:rh,children:"category:"}),oh(r.category)]})]})}}({timeAccessor:h,valueAccessor:d}),ee=(0,kh.useRef)(null),{customHoverBehavior:te}=Qu({selection:N,linkedHover:D,unwrapData:!0,onObservation:z,chartType:"RealtimeHistogram",chartId:O}),ne=(0,kh.useCallback)(e=>{C&&C(e),te(e)},[C,te]),re=!0===q?{dimension:"x",snap:"bin"}:"x"===q?{dimension:"x"}:"object"==typeof q?q:void 0,ie=(oe=V)?"string"==typeof oe?{name:oe}:oe:null;var oe;const se="string"==typeof h?h:"time",ae=function(e){const{name:t,xField:n,yField:r}=e,{predicate:i,isActive:o,selectInterval:s,clear:a}=Bu({name:t,fields:[n,r].filter(Boolean)}),c=n&&r?"xyBrush":n?"xBrush":"yBrush",l=(0,Fu.useCallback)(e=>{if(!e)return void a();const t={};"xyBrush"===c&&function(e){return 2===e.length&&Array.isArray(e[0])&&2===e[0].length&&Array.isArray(e[1])&&2===e[1].length}(e)?(n&&(t[n]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),r&&(t[r]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Yu(e)?n&&(t[n]=[Math.min(e[0],e[1]),Math.max(e[0],e[1])]):"yBrush"===c&&Yu(e)&&r&&(t[r]=[Math.min(e[0],e[1]),Math.max(e[0],e[1])]),Hu(t)&&s(t)},[c,n,r,s,a]);return{brushInteraction:(0,Fu.useMemo)(()=>({brush:c,during:l,end:l}),[c,l]),predicate:i,isActive:o,clear:a}}({name:ie?.name||"__unused_hist_brush__",xField:ie?.xField||se,...ie?.yField?{yField:ie.yField}:{}}),ce=(0,kh.useRef)(ae.brushInteraction);ce.current=ae.brushInteraction;const le=(0,kh.useCallback)(e=>{if(G&&G(e),z&&z(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:O}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:O}),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)}},[G,z,O,ie]);(0,kh.useImperativeHandle)(t,()=>({push:e=>ee.current?.push(e),pushMany:e=>ee.current?.pushMany(e),remove:e=>ee.current?.remove(e)??[],update:(e,t)=>ee.current?.update(e,t)??[],clear:()=>ee.current?.clear(),getData:()=>ee.current?.getData()??[],getScales:()=>ee.current?.getScales()??null}),[]);const ue=Gl(F,Z[0],Z[1],B),he=ue?null:ql(u,Z[0],Z[1],Y),de={};null!=v&&(de.fill=v),null!=b&&(de.stroke=b),null!=k&&(de.strokeWidth=k),null!=w&&(de.opacity=w),null!=A&&(de.gap=A);const fe=H?`${s||""} semiotic-emphasis-${H}`.trim():s,ye=ah(l,u),pe=(0,kh.useMemo)(()=>"down"!==f?p:function({data:e,valueAccessor:t,timeAccessor:n,binSize:r,valueExtent:i,extentPadding:o}){if(i)return[i[1],i[0]];if(!e||0===e.length)return;const s=new Map;for(const i of e){const e=Ah(i,n,"time"),o=Ah(i,t,"value");if(null==e||null==o)continue;const a=Math.floor(e/r)*r;s.set(a,(s.get(a)??0)+o)}let a=0;for(const e of s.values())e>a&&(a=e);return[a>0?a+a*(o??.1):1,0]}({data:u,valueAccessor:d,timeAccessor:h,binSize:r,valueExtent:p,extentPadding:g}),[f,u,d,h,r,p,g]);return ue||he||(0,wh.jsx)(Ia,{ref:ee,chartType:"bar",runtimeMode:"streaming",size:Z,margin:Q,className:fe,arrowOfTime:a,windowMode:c,windowSize:ye,data:u,timeAccessor:h,valueAccessor:d,xExtent:y,yExtent:pe,extentPadding:g,binSize:r,categoryAccessor:m,barColors:x,barStyle:de,showAxes:U,background:S,hoverAnnotation:K,tooltipContent:J,...mh({linkedHover:D,selection:N,onObservation:z,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:ne}),annotations:P,autoPlaceAnnotations:R,svgAnnotationRules:j,tickFormatTime:T,tickFormatValue:E,decay:L,pulse:I,staleness:W,transition:$,pointIdAccessor:e.pointIdAccessor,legendPosition:X,brush:re||(V?{dimension:"x"}:void 0),onBrush:re||V?le:void 0})});function _h(e){return(0,wh.jsx)(Sh,{...e,windowMode:"growing"})}Sh.displayName="RealtimeHistogram",_h.displayName="TemporalHistogram";var Mh=require("react"),Ch=require("react/jsx-runtime"),Ph=(0,Mh.forwardRef)(function(e,t){const n=Ju(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:r,margin:i,className:o,arrowOfTime:s="right",windowMode:a="sliding",windowSize:c,data:l,timeAccessor:u,valueAccessor:h,timeExtent:d,valueExtent:f,yScaleType:y,extentPadding:p,categoryAccessor:g,colors:m,radius:x,fill:v,opacity:b,stroke:k,strokeWidth:w,pointStyle:A,background:S,tooltipContent:_,tooltip:M,onHover:C,annotations:P,autoPlaceAnnotations:R,svgAnnotationRules:j,tickFormatTime:T,tickFormatValue:E,linkedHover:D,selection:N,onObservation:L,chartId:I,loading:W,loadingContent:$,emptyContent:z,emphasis:O,legendPosition:F}=e,B=n.showAxes,Y=n.enableHover,H=i??n.marginDefaults,X=r??[n.width,n.height],q=_??M??sh({timeAccessor:u,valueAccessor:h}),G=(0,Mh.useRef)(null),{customHoverBehavior:V}=Qu({selection:N,linkedHover:D,unwrapData:!0,onObservation:L,chartType:"RealtimeSwarmChart",chartId:I}),U=(0,Mh.useCallback)(e=>{C&&C(e),V(e)},[C,V]);(0,Mh.useImperativeHandle)(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 K=Gl(W,X[0],X[1],$),Q=K?null:ql(l,X[0],X[1],z),Z={};null!=x&&(Z.radius=x),null!=v&&(Z.fill=v),null!=b&&(Z.opacity=b),null!=k&&(Z.stroke=k),null!=w&&(Z.strokeWidth=w);const J=A,ee=O?`${o||""} semiotic-emphasis-${O}`.trim():o,te=ah(c,l);return K||Q||(0,Ch.jsx)(Ia,{ref:G,chartType:"swarm",runtimeMode:"streaming",size:X,margin:H,className:ee,arrowOfTime:s,windowMode:a,windowSize:te,data:l,timeAccessor:u,valueAccessor:h,xExtent:d,yExtent:f,yScaleType:y,extentPadding:p,categoryAccessor:g,barColors:m,swarmStyle:Z,pointStyle:J,showAxes:B,background:S,hoverAnnotation:Y,tooltipContent:q,...mh({linkedHover:D,selection:N,onObservation:L,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:U}),annotations:P,autoPlaceAnnotations:R,svgAnnotationRules:j,tickFormatTime:T,tickFormatValue:E,legendPosition:F,pointIdAccessor:e.pointIdAccessor})});Ph.displayName="RealtimeSwarmChart";var Rh=require("react"),jh=require("react/jsx-runtime"),Th=(0,Rh.forwardRef)(function(e,t){const n=Ju(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:r,margin:i,className:o,arrowOfTime:s="right",windowMode:a="sliding",windowSize:c,data:l,timeAccessor:u,valueAccessor:h,timeExtent:d,valueExtent:f,extentPadding:y,positiveColor:p,negativeColor:g,connectorStroke:m,connectorWidth:x,gap:v,stroke:b,strokeWidth:k,opacity:w,background:A,tooltipContent:S,tooltip:_,onHover:M,annotations:C,autoPlaceAnnotations:P,svgAnnotationRules:R,tickFormatTime:j,tickFormatValue:T,linkedHover:E,selection:D,onObservation:N,chartId:L,loading:I,loadingContent:W,emptyContent:$,emphasis:z,legendPosition:O}=e,F=n.showAxes,B=n.enableHover,Y=i??n.marginDefaults,H=r??[n.width,n.height],X=S??_??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const r=e?.data??null,i=ih(r,t,"time"),o=r?.delta??ih(r,n,"value"),s=r?.cumEnd,a="number"==typeof o?0>o?oh(o):"+"+oh(o):oh(o);return(0,th.jsxs)("div",{className:"semiotic-tooltip",style:nh,children:[(0,th.jsxs)("div",{children:[(0,th.jsx)("span",{style:rh,children:"x:"}),oh(i)]}),(0,th.jsxs)("div",{children:[(0,th.jsx)("span",{style:rh,children:"Δ:"}),a]}),null!=s&&(0,th.jsxs)("div",{children:[(0,th.jsx)("span",{style:rh,children:"total:"}),oh(s)]})]})}}({timeAccessor:u,valueAccessor:h}),q=(0,Rh.useRef)(null),{customHoverBehavior:G}=Qu({selection:D,linkedHover:E,unwrapData:!0,onObservation:N,chartType:"RealtimeWaterfallChart",chartId:L}),V=(0,Rh.useCallback)(e=>{M&&M(e),G(e)},[M,G]);(0,Rh.useImperativeHandle)(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 U=Gl(I,H[0],H[1],W),K=U?null:ql(l,H[0],H[1],$),Q={};null!=p&&(Q.positiveColor=p),null!=g&&(Q.negativeColor=g),null!=m&&(Q.connectorStroke=m),null!=x&&(Q.connectorWidth=x),null!=v&&(Q.gap=v),null!=b&&(Q.stroke=b),null!=k&&(Q.strokeWidth=k),null!=w&&(Q.opacity=w);const Z=z?`${o||""} semiotic-emphasis-${z}`.trim():o,J=ah(c,l);return U||K||(0,jh.jsx)(Ia,{ref:q,chartType:"waterfall",runtimeMode:"streaming",size:H,margin:Y,className:Z,arrowOfTime:s,windowMode:a,windowSize:J,data:l,timeAccessor:u,valueAccessor:h,xExtent:d,yExtent:f,extentPadding:y,waterfallStyle:Q,showAxes:F,background:A,hoverAnnotation:B,tooltipContent:X,...mh({linkedHover:E,selection:D,onObservation:N,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:V}),annotations:C,autoPlaceAnnotations:P,svgAnnotationRules:R,tickFormatTime:j,tickFormatValue:T,legendPosition:O,pointIdAccessor:e.pointIdAccessor})});Th.displayName="RealtimeWaterfallChart";var Eh=require("react"),Dh=require("react/jsx-runtime"),Nh=(0,Eh.forwardRef)(function(e,t){const n=Ju(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:r,margin:i,className:o,arrowOfTime:s="right",windowMode:a="sliding",windowSize:c,data:l,timeAccessor:u,valueAccessor:h,categoryAccessor:d,timeExtent:f,valueExtent:y,extentPadding:p,heatmapXBins:g=20,heatmapYBins:m=20,aggregation:x="count",background:v,tooltipContent:b,tooltip:k,onHover:w,annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:C,decay:P,pulse:R,staleness:j,linkedHover:T,selection:E,onObservation:D,chartId:N,loading:L,loadingContent:I,emptyContent:W,emphasis:$,legendPosition:z}=e,O=n.showAxes,F=n.enableHover,B=i??n.marginDefaults,Y=r??[n.width,n.height],H=b??k??function(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:r="x",yLabel:i="y"}=e;return e=>{const o=e?.data??null,s=o?.xCenter??ih(o,t,"time"),a=o?.yCenter??ih(o,n,"value"),c=o?.count,l=o?.sum,u=o?.value,h=o?.agg??"count";return(0,th.jsxs)("div",{className:"semiotic-tooltip",style:nh,children:[(0,th.jsxs)("div",{children:[(0,th.jsxs)("span",{style:rh,children:[r,":"]}),oh(s)]}),(0,th.jsxs)("div",{children:[(0,th.jsxs)("span",{style:rh,children:[i,":"]}),oh(a)]}),null!=c&&(0,th.jsxs)("div",{children:[(0,th.jsx)("span",{style:rh,children:"count:"}),oh(c)]}),"sum"===h&&null!=l&&(0,th.jsxs)("div",{children:[(0,th.jsx)("span",{style:rh,children:"sum:"}),oh(l)]}),"mean"===h&&null!=u&&(0,th.jsxs)("div",{children:[(0,th.jsx)("span",{style:rh,children:"mean:"}),oh(u)]})]})}}({timeAccessor:u,valueAccessor:h}),X=(0,Eh.useRef)(null),{customHoverBehavior:q}=Qu({selection:E,linkedHover:T,unwrapData:!0,onObservation:D,chartType:"RealtimeHeatmap",chartId:N}),G=(0,Eh.useCallback)(e=>{w&&w(e),q(e)},[w,q]);(0,Eh.useImperativeHandle)(t,()=>({push:e=>X.current?.push(e),pushMany:e=>X.current?.pushMany(e),remove:e=>X.current?.remove(e)??[],update:(e,t)=>X.current?.update(e,t)??[],clear:()=>X.current?.clear(),getData:()=>X.current?.getData()??[],getScales:()=>X.current?.getScales()??null}),[]);const V=Gl(L,Y[0],Y[1],I),U=V?null:ql(l,Y[0],Y[1],W),K=$?`${o||""} semiotic-emphasis-${$}`.trim():o,Q=ah(c,l);return V||U||(0,Dh.jsx)(Ia,{ref:X,chartType:"heatmap",runtimeMode:"streaming",size:Y,margin:B,className:K,arrowOfTime:s,windowMode:a,windowSize:Q,data:l,timeAccessor:u,valueAccessor:h,categoryAccessor:d,xExtent:f,yExtent:y,extentPadding:p,heatmapXBins:g,heatmapYBins:m,heatmapAggregation:x,showAxes:O,background:v,hoverAnnotation:F,tooltipContent:H,...mh({linkedHover:T,selection:E,onObservation:D,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:G}),annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:C,decay:P,pulse:R,staleness:j,legendPosition:z,pointIdAccessor:e.pointIdAccessor})});Nh.displayName="RealtimeHeatmap";var Lh=require("react"),Ih=Symbol("semiotic.useStreamStatus.wrapped");function Wh(e={}){const{staleThresholdMs:t=5e3,pollIntervalMs:n=1e3}=e,r=(0,Lh.useRef)(null),[i,o]=(0,Lh.useState)("idle"),[s,a]=(0,Lh.useState)(null),c=(0,Lh.useCallback)(()=>{const e="undefined"!=typeof performance?performance.now():Date.now();r.current=e,a(e),o(e=>"active"===e?e:"active")},[]),l=(0,Lh.useMemo)(()=>{const e={_frame:null,_origPush:null,_origPushMany:null};return{get current(){return e._frame},set current(t){const n=e._frame;if(n&&n!==t&&e._origPush&&e._origPushMany&&(n.push=e._origPush,n.pushMany=e._origPushMany,delete n[Ih]),e._frame=t,!t)return e._origPush=null,void(e._origPushMany=null);if(t[Ih])return;t[Ih]=!0;const r=t.push,i=t.pushMany,o=r.bind(t),s=i.bind(t);e._origPush=r,e._origPushMany=i,t.push=e=>(c(),o(e)),t.pushMany=e=>(e&&e.length>0&&c(),s(e))}}},[c]);return(0,Lh.useEffect)(()=>{const e=setInterval(()=>{const e=r.current;if(null==e)return;const n=("undefined"!=typeof performance?performance.now():Date.now())-e>t;o(e=>{const t=n?"stale":"active";return e===t?e:t})},n);return()=>clearInterval(e)},[t,n]),{ref:l,status:i,lastPushTime:s}}var $h=require("react");function zh(e,t,n,r){const i=new Map;n.forEach((e,t)=>{i.set(r?r(e,t):t+"",e)});const o=[];t.forEach((e,t)=>{i.has(t)||o.push(t)}),o.length>0&&e.remove?.(o);const s=[];if(i.forEach((n,r)=>{const i=t.get(r);void 0===i?s.push(n):i!==n&&(e.update?e.update(r,()=>n):(e.remove?.(r),s.push(n)))}),s.length>0)if(e.pushMany)e.pushMany(s);else if(e.push)for(const t of s)e.push(t);return i}function Oh(e,t,n={}){const{id:r,resetKey:i}=n,o=(0,$h.useMemo)(()=>function(e){return null==e?null:"function"==typeof e?(t,n)=>{const r=e(t,n);return null==r?n+"":r+""}:(t,n)=>{const r=t[e];return null==r?n+"":r+""}}(r),[r]),s=(0,$h.useRef)({map:new Map,handle:null,resetKey:void 0});(0,$h.useEffect)(()=>{const n=e.current;if(!n)return;const r=s.current;r.handle===n&&r.resetKey===i||(n.clear?.(),r.map=new Map,r.handle=n,r.resetKey=i),r.map=zh(n,r.map,t,o)},[e,t,o,i])}
2
+ var e,t,n,r,o,i,s=Object.create,a=Object.defineProperty,l=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,u=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty,d=(e,t,n)=>function(){if(n)throw n[0];try{return e&&(t=(0,e[c(e)[0]])(e=0)),t}catch(e){throw n=[e],e}},f=(e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})},y=(e,t,n,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let o of c(t))h.call(e,o)||o===n||a(e,o,{get:()=>t[o],enumerable:!(r=l(t,o))||r.enumerable});return e},p=(e,t,n)=>(n=null!=e?s(u(e)):{},y(!t&&e&&e.__esModule?n:a(n,"default",{value:e,enumerable:!0}),e)),g=d({"src/components/stream/brushAccessibility.ts"(){e=p(require("react")),t="Use arrow keys to move the selected range, Shift plus an arrow key to resize it, and Escape to clear it."}}),m={};function x(e,t,n,r){const[o,i]=[Math.min(...t),Math.max(...t)],s=(i-o)/20;let[a,l]=e;if(r)0>n?a=Math.max(o,a-s):l=Math.min(i,l+s);else{const e=l-a;a=Math.max(o,Math.min(i-e,a+n*s)),l=a+e}return[a,l]}function v(e,t){let n=0,r=t.length-1;for(;r>n;){const o=n+r+1>>1;t[o]>e?r=o-1:n=o}return t[n]}function b(e,t){let n=0,r=t.length-1;for(;r>n;){const o=n+r>>1;e>t[o]?n=o+1:r=o}return t[n]}function k({width:s,height:a,totalWidth:l,totalHeight:c,margin:u,dimension:h,scales:d,onBrush:f,binSize:y,snap:p,binBoundaries:g,snapDuring:m,streaming:k}){const w=(0,n.useRef)(null),A=(0,n.useRef)(null),S=(0,n.useRef)(f);S.current=f;const M=(0,n.useRef)(d);M.current=d;const _=(0,n.useMemo)(()=>g?[...g].sort((e,t)=>e-t):void 0,[g]),C=(0,n.useRef)(_);C.current=_;const P=(0,n.useRef)(!1),R=(0,n.useRef)(null),j=function({label:n="Data range brush",description:r=t,onAction:o}={}){const i=e.useId().replace(/:/g,""),s=e.useRef(o);return s.current=o,{description:r,descriptionId:"semiotic-brush-description-"+i,svgProps:{role:"region",tabIndex:0,"aria-label":n,"aria-describedby":"semiotic-brush-description-"+i,onKeyDown:e.useCallback(e=>{const t=function(e){return"Escape"===e.key?{type:"clear"}:"ArrowLeft"===e.key?{type:"nudge",direction:"left",resize:e.shiftKey}:"ArrowRight"===e.key?{type:"nudge",direction:"right",resize:e.shiftKey}:"ArrowUp"===e.key?{type:"nudge",direction:"up",resize:e.shiftKey}:"ArrowDown"===e.key?{type:"nudge",direction:"down",resize:e.shiftKey}:null}(e);t&&(e.preventDefault(),s.current?.(t))},[])}}}({label:"xy"===h?"Two-dimensional data range brush":h.toUpperCase()+" data range brush",onAction:e=>{const t=M.current,n=A.current;if(!t||!n||!w.current)return;const o=(0,r.select)(w.current).select(".brush-g");if("clear"===e.type)return P.current=!0,o.call(n.move,null),P.current=!1,R.current=null,void S.current(null);const i=t.x.domain(),s=t.y.domain(),a=R.current;let l=a?.x??[i[0]+.4*(i[1]-i[0]),i[0]+.6*(i[1]-i[0])],c=a?.y??[s[0]+.4*(s[1]-s[0]),s[0]+.6*(s[1]-s[0])];const u="left"===e.direction||"right"===e.direction,d="left"===e.direction||"down"===e.direction?-1:1;if(u&&"y"!==h&&(l=x(l,i,d,e.resize)),u||"x"===h||(c=x(c,s,d,e.resize)),u&&"y"===h||!u&&"x"===h)return;const f={x:l,y:c};P.current=!0,o.call(n.move,"x"===h?[t.x(l[0]),t.x(l[1])]:"y"===h?[t.y(c[1]),t.y(c[0])]:[[t.x(l[0]),t.y(c[1])],[t.x(l[1]),t.y(c[0])]]),P.current=!1,R.current=f,S.current(f)}});return(0,n.useEffect)(()=>{if(!w.current)return;const e=(0,r.select)(w.current).select(".brush-g"),t="x"===h?(0,o.brushX)():"y"===h?(0,o.brushY)():(0,o.brush)();return t.extent([[0,0],[s,a]]),t.on("brush end",n=>{if(P.current)return;const r=M.current;if(!r)return;if(!n.selection)return R.current=null,void S.current(null);let o,i;if("x"===h){const[e,t]=n.selection;o=[r.x.invert(e),r.x.invert(t)],i=[r.y.invert(a),r.y.invert(0)]}else if("y"===h){const[e,t]=n.selection;o=[r.x.invert(0),r.x.invert(s)],i=[r.y.invert(t),r.y.invert(e)]}else{const[[e,t],[s,a]]=n.selection;o=[r.x.invert(e),r.x.invert(s)],i=[r.y.invert(a),r.y.invert(t)]}if("bin"===p&&"y"!==h&&("end"===n.type||"brush"===n.type&&m)){const i=C.current;i&&i.length>0?o=function(e,t){return 0===t.length?e:[v(e[0],t),b(e[1],t)]}(o,i):y&&y>0&&(o=[Math.floor(o[0]/y)*y,Math.ceil(o[1]/y)*y]);const s=r.x(o[0]),a=r.x(o[1]);if(P.current=!0,"x"===h)e.call(t.move,[s,a]);else if("xy"===h){const r=n.selection;e.call(t.move,[[s,r[0][1]],[a,r[1][1]]])}P.current=!1}const l={x:o,y:i};R.current=l,S.current(l)}),e.call(t),A.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null),A.current=null}},[s,a,h,p,y,m]),(0,n.useEffect)(()=>{if(!(k&&d&&A.current&&R.current))return;if(!w.current)return;if("y"===h)return;const e=R.current,t=d.x.domain()[0],n=(0,r.select)(w.current).select(".brush-g");if(t>=e.x[1])return P.current=!0,n.call(A.current.move,null),P.current=!1,R.current=null,void S.current(null);let o=e.x[0],i=!1;if(t>e.x[0]){if(o=t,"bin"===p){const e=C.current;e&&e.length>0?o=b(t,e):y&&y>0&&(o=Math.ceil(t/y)*y)}if(o>=e.x[1])return P.current=!0,n.call(A.current.move,null),P.current=!1,R.current=null,void S.current(null);i=!0}const s=d.x(o),a=d.x(e.x[1]);if(P.current=!0,"x"===h)n.call(A.current.move,[s,a]);else{const t=d.y(e.y[1]),r=d.y(e.y[0]);n.call(A.current.move,[[s,t],[a,r]])}if(P.current=!1,i){const t={x:[o,e.x[1]],y:e.y};R.current=t,S.current(t)}},[d,k,h,p,y]),(0,i.jsxs)("svg",{ref:w,width:l,height:c,...j.svgProps,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:[(0,i.jsx)("title",{children:j.svgProps["aria-label"]}),(0,i.jsx)("desc",{id:j.descriptionId,children:j.description}),(0,i.jsx)("g",{className:"brush-g",transform:`translate(${u.left},${u.top})`})]})}f(m,{XYBrushOverlay:()=>k});var w,A=d({"src/components/stream/XYBrushOverlay.tsx"(){n=require("react"),r=require("d3-selection"),o=require("d3-brush"),g(),i=require("react/jsx-runtime")}}),S={};f(S,{DEFAULT_LIFECYCLE_THRESHOLDS:()=>Te,IncrementalExtent:()=>U,RealtimeHeatmap:()=>sd,RealtimeHistogram:()=>Kh,RealtimeLineChart:()=>qh,RealtimeSwarmChart:()=>ed,RealtimeWaterfallChart:()=>rd,ReorderBuffer:()=>eh,RingBuffer:()=>V,RunningStats:()=>Gu,StreamNetworkFrame:()=>qu,StreamXYFrame:()=>rl,TemporalHistogram:()=>Qh,WindowAccumulator:()=>Vu,bandBounds:()=>Ku,bandFromAge:()=>Ee,compileMotionEncoding:()=>Ne,deriveMotionVector:()=>$e,opacityFromAge:()=>De,parseWindowDuration:()=>Ju,resolveMotionAccessor:()=>Le,resolveMotionVector:()=>Ie,statValue:()=>Uu,syncPushBuffer:()=>hd,useStreamStatus:()=>cd,useSyncedPushData:()=>dd}),module.exports=(w=S,y(a({},"__esModule",{value:!0}),w));var M=p(require("react")),_=require("react"),C=p(require("react")),P=require("react/jsx-runtime"),R=null,j=null;function T(e){const[t,n]=C.useState(()=>R);return C.useEffect(()=>{if(t)return;let e=!1;return(R?Promise.resolve(R):(j||(j=Promise.resolve().then(()=>(A(),m)).then(e=>R=e.XYBrushOverlay)),j)).then(t=>{e||n(()=>t)}),()=>{e=!0}},[t]),t?(0,P.jsx)(t,{...e}):null}var E=Object.freeze([]);function L(e){if(!e)return E;let t=!1;for(let n=0;e.length>n;n++){const r=e[n];if(null==r||"object"!=typeof r){t=!0;break}}if(!t)return e;const n=[];for(const t of e)null!=t&&"object"==typeof t&&n.push(t);return n}var N=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=L(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 r=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,r),bounded:!1}),t=r,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(e){if(e=L(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 r=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,r),bounded:!1}),t=r,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 r=e[n];null!=r&&"object"==typeof r&&(this.pushBuffer.push(r),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}},D=require("react"),I=require("react/jsx-runtime");function $(e){let t=null;const n=()=>(t||(t=(0,D.createContext)(null)),t),r=W(e);return[function({children:t,initialState:r}){const o=(0,D.useRef)(r),i=(0,D.useMemo)(()=>W(e,o.current),[]),s=n();return(0,I.jsx)(s.Provider,{value:i,children:t})},(e,t)=>{const o=n(),i=(0,D.useContext)(o)??r,s=(0,D.useRef)(e);s.current=e;const a=(0,D.useRef)({hasValue:!1,value:void 0}),l=(0,D.useCallback)(()=>{const e=s.current(i.getState()),n=a.current;return n.hasValue&&t&&t(n.value,e)?n.value:(a.current={hasValue:!0,value:e},e)},[i,t]),c=(0,D.useCallback)(()=>s.current(i.getState()),[i]);return(0,D.useSyncExternalStore)(i.subscribe,l,c)}]}function W(e,t){const n=new Set;let r={...e(function(e){const t=e(r);if(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}(t)){r={...r,...t};for(const e of n)e()}}),...t??{}};return{getState:()=>r,subscribe:function(e){return n.add(e),()=>{n.delete(e)}}}}function z(e){if(!e?.colors)return;const t=e.colors;return{primary:t.primary,secondary:t.secondary||t.primary,surface:t.surface||t.background,success:t.success,danger:t.danger,warning:t.warning,error:t.error,info:t.info,text:t.text,textSecondary:t.textSecondary,border:t.border,grid:t.grid}}function O(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:F}}),e.accessibility.highContrast){const e="dark"===t.mode;t={...t,colors:{...t.colors,text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"}}}return t}var F=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],B={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},Y={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},H={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:F,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function X(e,t){if("light"===t)return B;if("dark"===t)return Y;if("high-contrast"===t)return H;if("string"==typeof t)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${t}". Keeping current theme.`),e;if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?Y:B;return O({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}return O({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}var[q,G]=$(e=>({theme:B,setTheme(t){e(e=>({theme:X(e.theme,t)}))}})),V=class{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;return{next:()=>this._size>e?{done:!1,value:this.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray();let n=0,r=[];t.length>e&&(n=t.length-e,r=t.slice(0,n)),this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(let e=n;t.length>e;e++)this.push(t[e]);return r}update(e,t){const n=[],r=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const i=(r+o)%this._capacity,s=this.buffer[i];if(e(s)){let e;e="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:{...s},n.push(e),this.buffer[i]=t(s)}}return n}remove(e){const t=[],n=[];if(this.forEach(r=>{e(r)?n.push(r):t.push(r)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}},U=class{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}};function K(e,t){return e===t}function Q(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function Z(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function J(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}var ee=/^\d{4}-\d{1,2}$/;function te(e){const t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;const n=ee.test(t)?t+"-01":t;if(n===t&&10>t.length)return NaN;const r=Date.parse(n);return Number.isFinite(r)?r:NaN}function ne(e){return e instanceof Date?e.getTime():"string"==typeof e?te(e):+e}function re(e){return new Set(Array.isArray(e)?e:[e])}function oe(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function ie(e,t,n){const r=e=>e.toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function se(e){const t=e.map(oe),n=t.length-1;return e=>{if(0>=e){const[e,n,r]=t[0];return ie(e,n,r)}if(e>=1){const[e,r,o]=t[n];return ie(e,r,o)}const r=e*n,o=Math.floor(r),i=r-o,[s,a,l]=t[o],[c,u,h]=t[o+1];return ie(Math.round(s+(c-s)*i),Math.round(a+(u-a)*i),Math.round(l+(h-l)*i))}}require("d3-scale");var ae=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],le=se(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),ce=se(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),ue=se(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),he=se(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),de=se(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),fe=se(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),ye=se(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),pe=se(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),ge=se(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),me=se(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),xe=se(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),ve=se(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),be={blues:le,reds:ce,greens:ue,viridis:ye,oranges:he,purples:de,greys:fe,plasma:pe,inferno:ge,magma:me,cividis:xe,turbo:ve};se(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),se(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),se(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),se(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),se(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),se(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),se(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);var ke={category10:ae,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...be},we=ae,Ae=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],Se=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function Me(e,t,n){if("function"==typeof t){const r=t(e);return n&&r&&"string"==typeof r&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||Se.has(t)}(r)?n(r):r}const r=e?.[t]+"";return n?n(r):we[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(r))%we.length]}function _e(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;const n=e[t];return"string"==typeof n&&n.length>0?n:void 0}function Ce(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function Pe(e,t){return Math.min((e-t.startTime)/t.duration,1)}function Re(e,t,n){return e+(t-e)*n}function je(){return"undefined"!=typeof performance?performance.now():Date.now()}var Te={fresh:1,aging:1.5,stale:3};function Ee(e,t,n={}){return Number.isFinite(t)&&t>0?Number.isNaN(e)?"fresh":e===1/0?"expired":0>e||t*(n.fresh??Te.fresh)>e?"fresh":t*(n.aging??Te.aging)>e?"aging":t*(n.stale??Te.stale)>e?"stale":"expired":"fresh"}function Le(e,t,n){if(null!=e)return"function"==typeof e?e(t,n):"object"==typeof e&&null!==e&&"constant"in e?e.constant:t[e]}function Ne(e){const{data:t,encoding:n}=e,r=[],o=new Map;return t.forEach((e,t)=>{const i=Le(n.id,e,t);if(null==i||""===i)throw Error(`[semiotic] Motion encoding row ${t} resolved an empty id.`);const s=i+"";if(o.has(s))throw Error(`[semiotic] Duplicate motion encoding id "${s}".`);const a=Le(n.process?.group,e,t),l=Le(n.process?.stage,e,t),c=Le(n.accessible?.group,e,t)??(null!=a?a+"":null!=l?l+"":void 0),u={};for(const r of Object.keys(n.evidence??{}))u[r]=Le(n.evidence?.[r],e,t);const h={id:s,datum:e,time:{arrival:Le(n.time?.arrival,e,t),basis:n.time?.basis,unit:n.time?.unit},placement:{x:Le(n.placement?.x,e,t),y:Le(n.placement?.y,e,t),lane:Le(n.placement?.lane,e,t),space:n.placement?.space},kinematics:{velocityX:Le(n.kinematics?.velocityX,e,t),velocityY:Le(n.kinematics?.velocityY,e,t),space:n.kinematics?.space},process:{group:a,stage:l,target:Le(n.process?.target,e,t),work:Le(n.process?.work,e,t)},evidence:u,accessible:{description:Le(n.accessible?.description,e,t),group:c,label:Le(n.accessible?.label,e,t)??s}};r.push(h),o.set(s,h)}),{rows:r,byId:o}}function De(e){const t=Math.max(0,Math.min(1,e.minOpacity??.1));if(Number.isNaN(e.age))return 1;if(e.age===1/0)return t;if(!Number.isFinite(e.extent)||0>=e.extent)return 1;const n=Math.max(0,e.age);if("step"===e.type)return(e.threshold??.5*e.extent)>n?1:t;if("exponential"===e.type){const r=e.halfLife??e.extent/2;return t+Math.pow(.5,n/(r>0?r:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-n/e.extent))*(1-t)}function Ie(e,t){const n=Number.isFinite(e)?e:0,r=Number.isFinite(t)?t:0;return{velocityX:n,velocityY:r,speed:Math.hypot(n,r),direction:Math.atan2(r,n)}}function $e(e,t,n){return Number.isFinite(n)&&n>0?Ie((t.x-e.x)/n,(t.y-e.y)/n):Ie(0,0)}function We(e,t,n){if(1>=n)return 1;const r=n-1;return De({age:r-t,extent:r,type:e.type,halfLife:e.halfLife??n/2,threshold:e.stepThreshold??.5*n,minOpacity:e.minOpacity??.1})}function ze(e){const t=new Map;for(let n=0;e.length>n;n++)t.set(e[n],n);return t}function Oe(e,t,n){const r=e.duration??500,o=n-t;return r>o?1-o/r:0}function Fe(e,t,n,r){let o=!1;return t>0?(e._pulseIntensity!==t&&(e._pulseIntensity=t,o=!0),e._pulseColor!==n&&(e._pulseColor=n,o=!0),e._pulseGlowRadius!==r&&(e._pulseGlowRadius=r,o=!0),o):(0!==e._pulseIntensity&&(e._pulseIntensity=0,o=!0),void 0!==e._pulseColor&&(e._pulseColor=void 0,o=!0),void 0!==e._pulseGlowRadius&&(e._pulseGlowRadius=void 0,o=!0),o)}function Be(e,t,n){if(t._transitionKey)return t._transitionKey;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){const n=e.getX(t.datum),r=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${n}:${r}`;if(null!=n&&null!=r)return`p:${n}:${r}`}return"p:"+n;case"glyph":return t.pointId?"g:"+t.pointId:"g:"+n;case"rect":return`r:${t.group||""}:${t.datum?.binStart??t.datum?.category??n}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+n:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function Ye(e,t,n,r,o,i){const s=[];for(const o of e){const e=n(o),i=r(o);Number.isFinite(e)&&Number.isFinite(i)&&s.push({px:t.x(e),py:t.y(i),rawY:i,d:o})}s.sort((e,t)=>e.px-t.px);const a=Array(s.length),l=Array(s.length),c=Array(s.length);for(let e=0;s.length>e;e++){const t=s[e];a[e]=[t.px,t.py],l[e]=t.rawY,c[e]=t.d}return{type:"line",path:a,rawValues:l,style:o,datum:c,group:i}}function He(e,t,n,r,o,i,s,a){const l=[];for(const i of e){const e=n(i),s=r(i);if(!Number.isFinite(e)||!Number.isFinite(s))continue;const c=t.x(e),u=a?a(i):o;l.push({px:c,topY:t.y(s),botY:t.y(u)})}l.sort((e,t)=>e.px-t.px);const c=Array(l.length),u=Array(l.length);for(let e=0;l.length>e;e++){const t=l[e];c[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:c,bottomPath:u,style:i,datum:e,group:s}}function Xe(e,t,n,r){const o=new Map;if("silhouette"===r)for(const r of e){let e=0;for(const o of t)e+=n(o,r)||0;o.set(r,-e/2)}else if("wiggle"===r){e.length>0&&o.set(e[0],0);for(let r=1;e.length>r;r++){const i=e[r-1],s=e[r];let a=0,l=0,c=0;for(const e of t){const t=n(e,s)||0;a+=(2*c+t)*(t-(n(e,i)||0)),l+=t,c+=t}const u=o.get(i)??0;o.set(s,u-(l>0?a/(2*l):0))}if(e.length>0){let r=0;for(const i of e){let e=0;for(const r of t)e+=n(r,i)||0;r+=(o.get(i)??0)+e/2}const i=r/e.length;for(const t of e)o.set(t,(o.get(t)??0)-i)}}else for(const t of e)o.set(t,0);return o}function qe(e,t,n,r,o,i,s){const a=n(e),l=r(e);if(!Number.isFinite(a)||!Number.isFinite(l))return null;const c={type:"point",x:t.x(a),y:t.y(l),r:o,style:i,datum:e};return void 0!==s&&(c.pointId=s),c}function Ge(e,t,n,r,o,i,s,a){const l=n(e),c=r(e);if(!Number.isFinite(l)||!Number.isFinite(c))return null;const u={type:"symbol",x:t.x(l),y:t.y(c),size:o,symbolType:i,style:s,datum:e};return void 0!==a&&(u.pointId=a),u}function Ve(e,t,n,r,o,i,s){return{type:"rect",x:e,y:t,w:n,h:r,style:o,datum:i,group:s}}function Ue(e,t,n,r,o,i,s){const a={type:"heatcell",x:e,y:t,w:n,h:r,fill:o,datum:i};return s?.showValues&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function Ke(e,t,n,r){return"function"==typeof t.style?t.style(r||{},n):t.style&&"object"==typeof t.style?t.style:e.resolveBoundsStyle(n,r)}function Qe(e,t,n,r){if(!e.scales)return null;const o=[],i=[];for(const n of t){const t=e.getX(n);if(!Number.isFinite(t))continue;const s=r.getTop(n),a=r.getBottom(n);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const l=e.scales.x(t),c=e.scales.y(s),u=e.scales.y(a);Number.isFinite(l)&&Number.isFinite(c)&&Number.isFinite(u)&&(o.push([l,c]),i.push([l,u]))}return 2>o.length?null:{type:"area",topPath:o,bottomPath:i,style:Ke(e,r,n,t[0]),datum:t,group:n,interactive:r.interactive}}function Ze(e){const t=[],n=[];if(!e)return{perSeries:t,aggregate:n};for(const r of e)r.perSeries?t.push(r):n.push(r);return{perSeries:t,aggregate:n}}function Je(e,t,n){const r=[];for(const o of n){const n=Qe(e,t,"__ribbon_aggregate",o);n&&r.push(n)}return r}function et(e,t,n,r){const o=[];for(const i of r){const r=Qe(e,t,n,i);r&&o.push(r)}return o}function tt(e,t){if(!e)return{};if(!t||0===t.length)return e;const n=[];for(const r of t){if("band"!==r.kind)continue;const t=r.getTop(e),o=r.getBottom(e);Number.isFinite(o)&&Number.isFinite(t)&&n.push({y0:o,y1:t})}return 0===n.length?e:{...e,band:n[0],bands:n}}function nt(e,t,n,r){if(!e.config.pointStyle)return;const o=r??e.getY;for(const r of t){const t=e.resolveGroupColor(r.key);for(const i of r.data){let r=e.config.pointStyle(i);!r.fill&&t&&(r={...r,fill:t});const s=r.r??3,a=e.getPointId?e.getPointId(i)+"":void 0,l=qe(i,e.scales,e.getX,o,s,r,a);l&&n.push(l)}}}function rt(e){return"threshold"===e.type&&"string"==typeof e.color&&"number"==typeof e.value}var ot={topOpacity:.8,bottomOpacity:.05};function it(e){if(e)return!0===e?ot:"colorStops"in e?e:{topOpacity:e.topOpacity??ot.topOpacity,bottomOpacity:e.bottomOpacity??ot.bottomOpacity}}var st=require("d3-shape"),at={circle:st.symbolCircle,square:st.symbolSquare,triangle:st.symbolTriangle,diamond:st.symbolDiamond,star:st.symbolStar,cross:st.symbolCross,wye:st.symbolWye},lt=["circle","triangle","diamond","star","square","chevron","cross","wye"];function ct(e,t,n){if(n)return n;const r=e??"circle";return"chevron"===r?function(e){const t=1.5*ut(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}(t):(0,st.symbol)(at[r]??st.symbolCircle,Math.max(1,t))()??""}function ut(e){return Math.sqrt(Math.max(1,e)/Math.PI)}var ht=new Map;function dt(e,t,n){if(e.config.heatmapAggregation)return function(e,t,n){const r=Math.max(1,Math.floor(e.config.heatmapXBins??20)),o=Math.max(1,Math.floor(e.config.heatmapYBins??20)),i=e.config.heatmapAggregation??"count",s=Q(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[a,l]=e.scales.x.domain(),[c,u]=e.scales.y.domain(),h=(l-a||1)/r,d=(u-c||1)/o,f=r*o;if(f>1e6)return[];const y=new Int32Array(f),p=new Float64Array(f);for(let n=0;t.length>n;n++){const i=t[n],l=e.getX(i),u=e.getY(i);if(!isFinite(l)||!isFinite(u))continue;const f=Math.min(Math.floor((l-a)/h),r-1),g=Math.min(Math.floor((u-c)/d),o-1);if(0>f||0>g)continue;const m=g*r+f;y[m]++;const x=s(i);p[m]+=isFinite(x)?x:0}let g=1/0,m=-1/0;for(let e=0;f>e;e++){if(0===y[e])continue;let t;switch(i){case"sum":t=p[e];break;case"mean":t=p[e]/y[e];break;default:t=y[e]}g>t&&(g=t),t>m&&(m=t)}if(!isFinite(g))return[];const x=m-g||1,v=n.width/r,b=n.height/o,k=e.config.showValues,w=e.config.heatmapValueFormat,A=[];for(let e=0;o>e;e++){const t=e*r;for(let n=0;r>n;n++){const r=t+n;if(0===y[r])continue;let s;switch(i){case"sum":s=p[r];break;case"mean":s=p[r]/y[r];break;default:s=y[r]}const l=(s-g)/x;A.push(Ue(n*v,(o-1-e)*b,v,b,`rgb(${220-(180*l+.5)|0},${220-(100*l+.5)|0},${255-(50*l+.5)|0})`,{xi:n,yi:e,value:s,count:y[r],sum:p[r],xCenter:a+(n+.5)*h,yCenter:c+(e+.5)*d,agg:i},k?{value:s,showValues:!0,valueFormat:w}:void 0))}}return A}(e,t,n);if(0===t.length)return[];const r=Q(e.config.valueAccessor,"value"),o=Z(e.config.xAccessor,"x"),i=Z(e.config.yAccessor,"y"),s=new Map,a=new Map,l=Array(t.length),c=Array(t.length);for(let e=0;t.length>e;e++){const n=t[e],r=o(n),u=i(n);l[e]=r,c[e]=u,s.has(r)||s.set(r,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,h=a.size;if(0===u||0===h)return[];const d=Array.from(s.keys()),f=Array.from(a.keys()),y=d.every(e=>"number"==typeof e&&!isNaN(e)),p=f.every(e=>"number"==typeof e&&!isNaN(e));if(y){d.sort((e,t)=>Number(e)-Number(t)),s.clear();for(let e=0;d.length>e;e++)s.set(d[e],e)}if(p){f.sort((e,t)=>Number(e)-Number(t)),a.clear();for(let e=0;f.length>e;e++)a.set(f[e],e)}const g=new Float64Array(t.length),m=new Float64Array(t.length),x=Array(t.length),v=new Map;let b=0;for(let e=0;t.length>e;e++){const n=t[e],o=s.get(l[e]),i=a.get(c[e]);if(void 0===o||void 0===i)continue;const h=r(n),d=i*u+o,f=v.get(d);let y;void 0!==f?y=f:(y=b++,v.set(d,y)),g[y]=d,m[y]=h,x[y]=n}let k=1/0,w=-1/0;for(let e=0;b>e;e++){const t=m[e];isFinite(t)&&(k>t&&(k=t),t>w&&(w=t))}if(!isFinite(k)||!isFinite(w))return[];const A=function(e){const t=e in be?e:"blues";let n=ht.get(t);if(n)return n;n=Array(256);const r=(o=t)&&be[o]||le;var o;for(let e=0;256>e;e++)n[e]=r(e/255);return ht.set(t,n),n}("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),S=255/(w-k||1),M=n.width/u,_=n.height/h,C=e.config.showValues,P=e.config.heatmapValueFormat,R=[];for(let e=0;b>e;e++){const t=m[e];if(!isFinite(t))continue;const n=g[e],r=n%u;R.push(Ue(r*M,(h-1-(n-r)/u)*_,M,_,A[Math.min((t-k)*S+.5|0,255)],x[e],C?{value:t,showValues:!0,valueFormat:P}:void 0))}return R}function ft(e,t,n,r,o){const i=new Map;for(const s of e){const e=t(s),a=n(s);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const l=Math.floor(e/r)*r;let c=i.get(l);if(c||(c={start:l,end:l+r,total:0,categories:new Map},i.set(l,c)),c.total+=a,o){const e=o(s);c.categories.set(e,(c.categories.get(e)||0)+a)}}return i}function yt(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:n,overlays:r,warned:o}=e;pt(r)&&0===n.length&&gt(o,"overlay-only",`[semiotic] ${t} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),n.length>0&&n.every(e=>null==e.datum)&&gt(o,"null-datums",`[semiotic] ${t} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function pt(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(pt))}function gt(e,t,n){e.has(t)||(e.add(t),console.warn(n))}function mt(e,t,n,r){const o=function(e){if(e instanceof Error)return{name:e.name||"Error",message:e.message||"Custom layout threw."};if("string"==typeof e)return{name:"Error",message:e};if(null==e)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:e+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(t),i="network"===e?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:e,source:i,message:`Semiotic ${e} ${i} failed: ${o.message}`,error:o,recovery:n?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:n,affectedRevision:r}}function xt(e,t){const n="function"==typeof e?e:n=>n[e||t];return e=>{const t=n(e);return null==t?NaN:+t}}function vt(e){const t=[],n=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,r=xt(n&&e.valueAccessor||e.yAccessor,n?"value":"y");if(e.boundsAccessor){const n=Q(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{const t=r(e);if(!Number.isFinite(t))return NaN;const o=n(e);return Number.isFinite(o)&&0!==o?t+o:t},getBottom:e=>{const t=r(e);if(!Number.isFinite(t))return NaN;const o=n(e);return Number.isFinite(o)&&0!==o?t-o:t},style:e.boundsStyle,perSeries:!0,interactive:!1})}if(e.band){const n=Array.isArray(e.band)?e.band:[e.band];for(const e of n)t.push({kind:"band",getTop:xt(e.y1Accessor,"y1"),getBottom:xt(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}var bt=require("d3-scale");function kt(e,t){return t?[t[0]??e[0],t[1]??e[1]]:e}function wt(e,t,n){if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return(0,bt.scaleLog)().domain(e).range(n).clamp(!0)}return"symlog"===e?(0,bt.scaleSymlog)().domain(t).range(n):"time"===e?(0,bt.scaleTime)().domain([new Date(t[0]),new Date(t[1])]).range(n):(0,bt.scaleLinear)().domain(t).range(n)}function At(e,t,n,r){const o=e.push(t);return n&&n.push(r),o}var St=new WeakMap;function Mt(){return this.updateResults.last}function _t(){return this.updateResults.last}function Ct(e){return this.updateResults.subscribe(e)}function Pt(e){this.config.layoutSelection=e}function Rt(){St.set(this,!0)}function jt(){const e=!0===St.get(this);return St.delete(this),e}function Tt(e){Object.assign(e.prototype,{getLastUpdateResult:Mt,getUpdateSnapshot:_t,subscribeUpdateResult:Ct,setLayoutSelection:Pt,markStylePaintPending:Rt,consumeStylePaintPending:jt})}var Et={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"};function Lt(e,t){const n={...e};for(const e of t)n[Et[e]]++;return n}function Nt(e,t,n){const r=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:r,revisions:Lt(n,r)}}var Dt=class{constructor(){this.revisions={data:0,domain:0,layout:0,sceneGeometry:0,sceneStyle:0,dataPaint:0,interactionPaint:0,overlay:0,accessibility:0,evidence:0},this.latest=Nt({kind:"initialize"},[],this.revisions),this.listeners=new Set}get last(){return this.latest}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}record(e,t){const n=Nt(e,t,this.revisions);this.revisions=n.revisions,this.latest=n;for(const e of[...this.listeners])e();return n}},It=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],$t=["scene-style","data-paint","accessibility","evidence"],Wt=(e,t)=>({retainedData:e,invalidations:t}),zt=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ot=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ft=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Bt=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Yt=["scene-geometry","data-paint","accessibility","evidence"],Ht=["scene-style","data-paint","accessibility","evidence"],Xt=[],qt={chartType:Wt("rebuild",zt),runtimeMode:Wt("rebuild",zt),xAccessor:Wt("rebuild",zt),yAccessor:Wt("rebuild",zt),timeAccessor:Wt("rebuild",zt),valueAccessor:Wt("rebuild",zt),y0Accessor:Wt("rebuild",zt),boundsAccessor:Wt("rebuild",zt),band:Wt("rebuild",zt),openAccessor:Wt("rebuild",zt),highAccessor:Wt("rebuild",zt),lowAccessor:Wt("rebuild",zt),closeAccessor:Wt("rebuild",zt),candlestickRangeMode:Wt("rebuild",zt),accessorRevision:Wt("rebuild",zt),groupAccessor:Wt("rebuild",Ot),categoryAccessor:Wt("rebuild",Ot),lineDataAccessor:Wt("rebuild",Ot),colorAccessor:Wt("rebuild",Ht),sizeAccessor:Wt("rebuild",Yt),symbolAccessor:Wt("rebuild",Yt),pointIdAccessor:Wt("rebuild",Yt),xScaleType:Wt("preserve",Ft),yScaleType:Wt("preserve",Ft),xExtent:Wt("preserve",Ft),yExtent:Wt("preserve",Ft),extentPadding:Wt("preserve",Ft),scalePadding:Wt("preserve",Ft),axisExtent:Wt("preserve",Ft),binSize:Wt("preserve",Ft),normalize:Wt("preserve",Ft),heatmapAggregation:Wt("preserve",Ft),heatmapXBins:Wt("preserve",Ft),heatmapYBins:Wt("preserve",Ft),arrowOfTime:Wt("preserve",Bt),baseline:Wt("preserve",Bt),stackOrder:Wt("preserve",Bt),sizeRange:Wt("preserve",Bt),curve:Wt("preserve",Bt),areaGroups:Wt("preserve",Bt),customLayout:Wt("preserve",Bt),layoutConfig:Wt("preserve",Bt),layoutMargin:Wt("preserve",Bt),symbolMap:Wt("preserve",Yt),showValues:Wt("preserve",Yt),heatmapValueFormat:Wt("preserve",Yt),lineStyle:Wt("preserve",Ht),pointStyle:Wt("preserve",Ht),areaStyle:Wt("preserve",Ht),barStyle:Wt("preserve",Ht),swarmStyle:Wt("preserve",Ht),waterfallStyle:Wt("preserve",Ht),candlestickStyle:Wt("preserve",Ht),boundsStyle:Wt("preserve",Ht),gradientFill:Wt("preserve",Ht),lineGradient:Wt("preserve",Ht),colorScheme:Wt("preserve",Ht),themeCategorical:Wt("preserve",Ht),themeSemantic:Wt("preserve",Ht),themeSequential:Wt("preserve",Ht),themeDiverging:Wt("preserve",Ht),barColors:Wt("preserve",Ht),decay:Wt("preserve",Ht),pulse:Wt("preserve",Ht),staleness:Wt("preserve",Ht),layoutSelection:Wt("preserve",Ht),annotations:Wt("preserve",["overlay","accessibility","evidence"]),windowSize:Wt("preserve",Xt),windowMode:Wt("preserve",Xt),maxCapacity:Wt("preserve",Xt),clock:Wt("preserve",Xt),transition:Wt("preserve",Xt),introAnimation:Wt("preserve",Xt),onLayoutError:Wt("preserve",Xt)},Gt=Wt("preserve",Bt),Vt=class{constructor(){this.tracker=new Dt}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}},It)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},$t):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const r of e){const e=qt[r]??Gt;"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)}},Ut=require("d3-quadtree"),Kt=class{constructor(){this.maxRadius=0,this.tree=null}get quadtree(){return this.tree}get maxPointRadius(){return this.maxRadius}clear(){this.tree=null,this.maxRadius=0}rebuild(e,t){if("scatter"!==e&&"bubble"!==e&&"custom"!==e)return void this.clear();let n=0,r=0;for(const e of t)"point"===e.type&&(n++,e.r>r&&(r=e.r));if(this.maxRadius=r,500>=n)return void(this.tree=null);const o=Array(n);let i=0;for(const e of t)"point"===e.type&&(o[i++]=e);this.tree=(0,Ut.quadtree)().x(e=>e.x).y(e=>e.y).addAll(o)}},Qt=class e{constructor(e){if(this.xExtent=new U,this.yExtent=new U,this.growingCapacityWarned=!1,this.windowSizeWarned=!1,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._datumIndexCache=null,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.updateResults=new Vt,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.xIsDate=!1,this.spatialIndex=new Kt,this._lastBoundedInsertsRef=null,this.applyPulse=(e,t,n)=>!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,n,r,o,i=("undefined"!=typeof performance?performance.now():Date.now())){const s=e.color??"rgba(255,255,255,0.6)",a=e.glowRadius??4;let l=!1;const c=o??(()=>{const e=new Map;for(let t=0;n.length>t;t++)e.set(n[t],t);return e})();for(const n of t){if("line"===n.type)continue;if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[n.datum];let o=0,a=!1;for(const n of t){const t=c.get(n);if(null==t)continue;a=!0;const s=r.get(t);if(null==s)continue;const l=Oe(e,s,i);l>o&&(o=l)}a&&(l=Fe(n,o,s)||l);continue}const t=c.get(n.datum);if(null==t)continue;const o=r.get(t);l=Fe(n,null==o?0:Oe(e,o,i),s,a)||l}return l}(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),n),this.config=e,this.buffer=new V(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=Q(e.timeAccessor||e.xAccessor,"time"),this.getY=Q(e.valueAccessor||e.yAccessor,"value")):(this.getX=Q(e.xAccessor,"x"),this.getY=Q(e.yAccessor,"y")),this.getGroup=J(e.groupAccessor),this.getCategory=J(e.categoryAccessor),this.getSize=e.sizeAccessor?Q(e.sizeAccessor,"size"):void 0,this.getColor=J(e.colorAccessor),this.getSymbol=J(e.symbolAccessor),this.getY0=e.y0Accessor?Q(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=vt(e),this.getPointId=J(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,n=null!=e.closeAccessor;this.getOpen=t?Q(e.openAccessor,"open"):void 0,this.getHigh=Q(e.highAccessor,"high"),this.getLow=Q(e.lowAccessor,"low"),this.getClose=n?Q(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!n}e.pulse&&(this.timestampBuffer=new V(e.windowSize))}currentTime(){return this.config.clock?.()??je()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=function(e,t){const n=new V(e.capacity);return e.forEach(()=>n.push(t)),n}(this.buffer,this.currentTime())):this.timestampBuffer=null}pushDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(e)),void this.yExtent.push(this.getLow(e));this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e));for(const t of this.resolvedRibbons){const n=t.getTop(e),r=t.getBottom(e);Number.isFinite(n)&&this.yExtent.push(n),Number.isFinite(r)&&this.yExtent.push(r)}}evictDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(e)),void this.yExtent.evict(this.getLow(e));this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e));for(const t of this.resolvedRibbons){const n=t.getTop(e),r=t.getBottom(e);Number.isFinite(n)&&this.yExtent.evict(n),Number.isFinite(r)&&this.yExtent.evict(r)}}rebuildYExtent(){this.yExtent.clear();for(const e of this.buffer)this.pushDatumYExtent(e)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const e of this.buffer)this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e)}ingest(e){if(e.bounded&&this._lastBoundedInsertsRef===e.inserts)return this.updateResults.recordNoop("replace"),!1;const t=this.currentTime();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){this._lastBoundedInsertsRef=e.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=i?Q(this.config.timeAccessor||this.config.xAccessor,"time"):Q(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],n=this.config.xAccessor,r="function"==typeof n?n(t):t[n||"x"],o=r instanceof Date,i="string"==typeof r&&Number.isFinite(te(r));if(this.xIsDate=o||i,i){const e="string"==typeof n?n:void 0;this.getX=e?t=>ne(t[e]):e=>ne(n(e))}}o=this.timestampBuffer,(r=e.totalSize||e.inserts.length)>(n=this.buffer).capacity&&(n.resize(r),o&&r>o.capacity&&o.resize(r));for(const n of e.inserts)At(this.buffer,n,this.timestampBuffer,t),this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n)}else for(const n of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity??1e5;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap),"production"===process.env.NODE_ENV||this.growingCapacityWarned||5e4>this.growingCap||(this.growingCapacityWarned=!0,console.warn(`[Semiotic] Growing window buffer reached ${this.growingCap} points (cap ${e}). Large canvas scenes are expensive — prefer a sliding window, aggregation, or an explicit maxCapacity if this is intentional.`)))}const e=At(this.buffer,n,this.timestampBuffer,t);this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n),null!=e&&(this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e))}var n,r,o;return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}computeScene(e){const{config:t,buffer:n}=this,r=this.scales,o=this.lastLayout;if(!this.needsFullRebuild&&!t.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(this.config.scalePadding??0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);this.xExtent.dirty&&this.xExtent.recalculate(n,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const i=this.getBufferArray(),s=this.yExtent.extent;let a=kt(this.xExtent.extent,t.xExtent),l=kt(s,t.yExtent);const c=!(!(u=t.yExtent)||null==u[0]||null==u[1]);var u;const h="exact"===t.axisExtent;if("stackedarea"===t.chartType&&!c&&n.size>0){const e=function(e){const{config:t,groups:n,getX:r,getY:o}=e,i="exact"===t.axisExtent;if(t.normalize){const n=[0,i?1:1+t.extentPadding];return{yDomain:n,stackExtentCache:{key:`${e.bufferSize}:${e.ingestVersion}:norm`,yDomain:n}}}const s=`${e.bufferSize}:${e.ingestVersion}:${t.baseline??"zero"}:${t.stackOrder??"key"}`;if(e.stackExtentCache&&e.stackExtentCache.key===s)return{yDomain:e.stackExtentCache.yDomain,stackExtentCache:e.stackExtentCache};const a=new Map,l=new Set;let c=0;const u=new Map,h=new Map;for(const e of n){const t=new Map;let n=0;for(const i of e.data){const e=r(i),s=o(i);if(!Number.isFinite(e)||!Number.isFinite(s))continue;t.set(e,(t.get(e)||0)+s),l.add(e),n+=s;const a=(u.get(e)||0)+s;u.set(e,a),a>c&&(c=a)}a.set(e.key,t),h.set(e.key,n)}const d=t.stackOrder??"key",f=(e,t)=>t>e?-1:e>t?1:0;let y,p;if("input"===d)y=n.map(e=>e.key);else if("insideOut"===d){const e=[...n].map(e=>e.key).sort((e,t)=>{const n=(h.get(t)??0)-(h.get(e)??0);return 0!==n?n:f(e,t)}),t=[],r=[];let o=0,i=0;for(const n of e)i>o?(t.push(n),o+=h.get(n)??0):(r.push(n),i+=h.get(n)??0);y=[...r.reverse(),...t]}else y="asc"===d?n.map(e=>e.key).sort((e,t)=>{const n=(h.get(e)??0)-(h.get(t)??0);return 0!==n?n:f(e,t)}):"desc"===d?n.map(e=>e.key).sort((e,t)=>{const n=(h.get(t)??0)-(h.get(e)??0);return 0!==n?n:f(e,t)}):n.map(e=>e.key).sort(f);if("wiggle"===t.baseline||"silhouette"===t.baseline){const e=Array.from(l).sort((e,t)=>e-t),n=Xe(e,y,(e,t)=>a.get(e)?.get(t)||0,t.baseline);let r=1/0,o=-1/0;for(const t of e){const e=n.get(t)??0,i=u.get(t)??0;r>e&&(r=e),e+i>o&&(o=e+i)}Number.isFinite(r)&&Number.isFinite(o)||(r=0,o=0);const s=o-r,c=i?0:s>0?s*t.extentPadding:1;p=[r-c,o+c]}else if("diverging"===t.baseline){const e=Array.from(l).sort((e,t)=>e-t),[n,r]=function(e,t,n){let r=0,o=0;for(const i of e){let e=0,s=0;for(const r of t){const t=n(r,i)||0;0>t?s+=t:e+=t}r>s&&(r=s),e>o&&(o=e)}return[r,o]}(e,y,(e,t)=>a.get(e)?.get(t)||0),o=r-n,s=i?0:o>0?o*t.extentPadding:1;p=[n-s,r+s]}else p=[0,c+(i?0:c>0?c*t.extentPadding:1)];return{yDomain:p,stackExtentCache:{key:s,yDomain:p}}}({config:t,groups:this.groupData(i),getX:this.getX,getY:this.getY,bufferSize:n.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});l=e.yDomain,this._stackExtentCache=e.stackExtentCache}else"bar"===t.chartType&&t.binSize&&!c&&n.size>0?l=function(e,t,n,r,o,i,s){const[,a]=function(e,t,n,r,o){const i=ft(e,t,n,r,o);if(0===i.size)return[0,0];let s=0;for(const e of i.values())e.total>s&&(s=e.total);return[0,s]}(e,t,n,r,o);return[0,s?a:a+a*i]}(n,this.getX,this.getY,t.binSize,this.getCategory,t.extentPadding,h):"waterfall"===t.chartType&&!c&&n.size>0?l=function(e,t,n,r){const[o,i]=function(e,t){let n=0,r=0,o=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(o+=e,n>o&&(n=o),o>r&&(r=o))}return[n,r]}(e,t),s=i-o,a=r?0:s>0?s*n:1;return[Math.min(0,o-Math.abs(a)),Math.max(0,i+Math.abs(a))]}(n,this.getY,t.extentPadding,h):c||l[0]===1/0||(l=function(e,t,n){if(!n.length)return e;let[r,o]=e;for(const e of t)for(const t of n){const n=t.getTop(e),i=t.getBottom(e);Number.isFinite(n)&&(r>n&&(r=n),n>o&&(o=n)),Number.isFinite(i)&&(r>i&&(r=i),i>o&&(o=i))}return[r,o]}(l,i,this.resolvedRibbons),l=function(e,t){const n=e[1]-e[0],r=t.exactMode?0:n>0?n*t.extentPadding:1,o=[null!=t.userMin?e[0]:e[0]-r,null!=t.userMax?e[1]:e[1]+r];return"log"!==t.yScaleType||o[0]>0||0>=t.dataYDomain[0]||t.exactMode||null==t.userMin&&(o[0]=t.dataYDomain[0]/(1+t.extentPadding)),o}(l,{exactMode:h,extentPadding:t.extentPadding,userMin:t.yExtent?.[0],userMax:t.yExtent?.[1],yScaleType:t.yScaleType,dataYDomain:s}));l=function(e,t,n){if(!t||n)return e;const r=t[0],o=t[1];return null==r&&null==o?e:[null!=r?r:e[0],null!=o?o:e[1]]}(l,t.yExtent,!!c),({xDomain:a,yDomain:l}=function(e,t,n){let r=e,o=t;if(r[0]===1/0||r[1]===-1/0)if("time"===n){const e=Date.now();r=[e-864e5,e]}else r=[0,1];return o[0]!==1/0&&o[1]!==-1/0||(o=[0,1]),{xDomain:r,yDomain:o}}(a,l,t.xScaleType)),this.scales=function(e){const{config:t,layout:n,xDomain:r,yDomain:o}=e,i="streaming"===t.runtimeMode,s=Math.max(0,Math.min(t.scalePadding||0,Math.min(n.width,n.height)/2-1));if(i){if("x"==("up"===(a=t.arrowOfTime)||"down"===a?"y":"x")){const e="right"===t.arrowOfTime?[s,n.width-s]:[n.width-s,s];return{x:(0,bt.scaleLinear)().domain(r).range(e),y:wt(t.yScaleType,o,[n.height-s,s])}}const e="down"===t.arrowOfTime?[s,n.height-s]:[n.height-s,s];return{x:wt(t.yScaleType,o,[s,n.width-s]),y:(0,bt.scaleLinear)().domain(r).range(e)}}var a;return{x:wt(t.xScaleType,r,[s,n.width-s]),y:wt(t.yScaleType,o,[n.height-s,s])}}({config:t,layout:e,xDomain:a,yDomain:l}),this._customLayoutFailedThisBuild=!1;const d=this.buildSceneNodes(e,i);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=r,this.lastLayout=o):(this.scene=[],this.spatialIndex.rebuild(this.config.chartType,this.scene)),void(this.needsFullRebuild=!0);this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=d,this.config.decay&&this.applyDecay(this.scene,i),this.config.pulse&&this.applyPulse(this.scene,i,this.currentTime()),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.spatialIndex.rebuild(this.config.chartType,this.scene),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(e){const t=e.width/this.lastLayout.width,n=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const r of e.path)r[0]*=t,r[1]*=n;break;case"area":for(const r of e.topPath)r[0]*=t,r[1]*=n;for(const r of e.bottomPath)r[0]*=t,r[1]*=n;e.clipRect&&(e.clipRect={x:e.clipRect.x*t,y:e.clipRect.y*n,width:e.clipRect.width*t,height:e.clipRect.height*n});break;case"point":case"glyph":e.x*=t,e.y*=n;break;case"rect":case"heatcell":e.x*=t,e.y*=n,e.w*=t,e.h*=n;break;case"candlestick":e.x*=t,e.openY*=n,e.closeY*=n,e.highY*=n,e.lowY*=n}const r=this.scales.x.domain(),o=this.scales.y.domain(),i=this.scales.x.range(),s=this.scales.y.range(),a=wt,l=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),c=s[1]>s[0];this.scales={x:a(this.config.xScaleType,r,i[0]>i[1]?[e.width-l,l]:[l,e.width-l]),y:a(this.config.yScaleType,o,c?[l,e.height-l]:[e.height-l,l])},this.lastLayout={width:e.width,height:e.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(e,t){const{config:n,scales:r}=this;if(!r)return[];if(n.customLayout){const o={data:t,scales:r,dimensions:{width:e.width,height:e.height,margin:n.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:n.themeSemantic??{},categorical:n.themeCategorical??Ae},resolveColor:(e,t)=>{const r=this.resolveGroupColor(e);if(r)return r;const o=this.resolveLineStyle(e,t);return o.stroke?o.stroke:"string"==typeof o.fill?o.fill:n.themeSemantic?.primary??"#4e79a7"},config:n.layoutConfig??{},selection:n.layoutSelection??null};let i;try{i=n.customLayout(o)}catch(e){const t=null!==this.lastCustomLayoutResult,r=mt("xy",e,t,this.version);this.lastCustomLayoutFailure=r,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",e);try{n.onLayoutError?.(r)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return t?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=i.overlays??null,this.lastCustomLayoutResult=i,this.lastCustomLayoutFailure=null;const s=i.nodes??[];if(this._customRestyle=i.restyle,this.hasCustomRestyle=!!i.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const e of s)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(s,n.layoutSelection??null)}return yt({label:"customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}if(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===t.length)return[];const o={scales:r,config:n,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getSymbol:this.getSymbol,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(e,t)=>this.resolveLineStyle(e,t),resolveAreaStyle:(e,t)=>this.resolveAreaStyle(e,t),resolveBoundsStyle:(e,t)=>this.resolveBoundsStyle(e,t),resolveColorMap:e=>this.resolveColorMap(e),resolveGroupColor:e=>this.resolveGroupColor(e),groupData:e=>this.groupData(e),barCategoryCache:this._barCategoryCache};switch(n.chartType){case"line":return function(e,t){const n=e.groupData(t),r=[],o=e.config.annotations?.filter(rt).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:i}=Ze(e.ribbons);if(i.length>0&&r.push(...Je(e,t,i)),o.length>0)for(const t of n)r.push(...et(e,t.data,t.key,o))}for(const t of n){const n=e.resolveLineStyle(t.key,t.data[0]),i=Ye(t.data,e.scales,e.getX,e.getY,n,t.key);o&&o.length>0&&(i.colorThresholds=o),e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),r.push(i)}return nt(e,n,r),r}(o,t);case"area":return function(e,t){const n=e.groupData(t),r=[];if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:i}=Ze(e.ribbons);if(i.length>0&&r.push(...Je(e,t,i)),o.length>0)for(const t of n)r.push(...et(e,t.data,t.key,o))}const o=e.scales.y.domain()[0],i=e.getY0?t=>{const n=e.getY0(t);return null==n?o:n}:void 0;for(const t of n){const n=e.resolveAreaStyle(t.key,t.data[0]),s=He(t.data,e.scales,e.getX,e.getY,o,n,t.key,i),a=it(e.config.gradientFill);a&&(s.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(s.curve=e.config.curve),e.config.lineGradient&&(s.strokeGradient=e.config.lineGradient),r.push(s)}return nt(e,n,r),r}(o,t);case"mixed":return function(e,t){const n=e.groupData(t),r=[],o=e.config.areaGroups||new Set;if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:i}=Ze(e.ribbons);if(i.length>0&&r.push(...Je(e,t,i)),o.length>0)for(const t of n)r.push(...et(e,t.data,t.key,o))}const i=e.scales.y.domain()[0],s=e.getY0?t=>{const n=e.getY0(t);return null==n?i:n}:void 0;for(const t of n)if(o.has(t.key)){const n=e.resolveAreaStyle(t.key,t.data[0]),o=He(t.data,e.scales,e.getX,e.getY,i,n,t.key,s),a=it(e.config.gradientFill);a&&(o.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}else{const n=e.resolveLineStyle(t.key,t.data[0]),o=Ye(t.data,e.scales,e.getX,e.getY,n,t.key);e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}return nt(e,n,r),r}(o,t);case"stackedarea":return function(e,t){const n=e.groupData(t),r=e.config.stackOrder??"key",o=()=>n.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);if("input"===r);else if("key"===r)o();else if("asc"===r||"desc"===r||"insideOut"===r){const t=new Map;for(const r of n){let n=0;for(const t of r.data){const r=e.getX(t),o=e.getY(t);Number.isFinite(r)&&Number.isFinite(o)&&(n+=o)}t.set(r.key,n)}const o=(e,t)=>t>e?-1:e>t?1:0;if("asc"===r)n.sort((e,n)=>{const r=(t.get(e.key)??0)-(t.get(n.key)??0);return 0!==r?r:o(e.key,n.key)});else if("desc"===r)n.sort((e,n)=>{const r=(t.get(n.key)??0)-(t.get(e.key)??0);return 0!==r?r:o(e.key,n.key)});else{const e=[...n].sort((e,n)=>{const r=(t.get(n.key)??0)-(t.get(e.key)??0);return 0!==r?r:o(e.key,n.key)}),r=[],i=[];let s=0,a=0;for(const n of e)a>s?(r.push(n),s+=t.get(n.key)??0):(i.push(n),a+=t.get(n.key)??0);n.length=0,n.push(...i.reverse(),...r)}}else o();const i=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,s=e.config.normalize?"zero":e.config.baseline??"zero",{nodes:a,stackedTops:l}=function(e,t,n,r,o,i,s,a="zero"){const l=new Set;for(const t of e)for(const e of t.data){const t=n(e);Number.isFinite(t)&&l.add(t)}const c=Array.from(l).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const o of t.data){const t=n(o),i=r(o);Number.isFinite(t)&&Number.isFinite(i)&&e.set(t,(e.get(t)||0)+i)}u.set(t.key,e)}let h;if(i){h=new Map;for(const t of c){let n=0;for(const r of e)n+=u.get(r.key)?.get(t)||0;h.set(t,n||1)}}const d=Xe(c,e.map(e=>e.key),(e,t)=>u.get(e)?.get(t)||0,a),f="diverging"===a&&!i,y=[],p=new Map,g=new Map,m=new Map,x=new Map;for(const e of c)g.set(e,d.get(e)??0),m.set(e,0),x.set(e,0);for(const n of e){const e=u.get(n.key),r=new Map;let a=[],l=[];const d=()=>{if(a.length>=2){const e={type:"area",topPath:a,bottomPath:l,style:o(n.key,n.data[0]),datum:n.data,group:n.key};s&&(e.curve=s),y.push(e)}a=[],l=[]};for(const n of c){const o=e.has(n);let s,c,u=o?e.get(n):0;if(i&&o&&(u/=h.get(n)),!o||!Number.isFinite(u)||0===u){d();continue}f?u>0?(s=m.get(n),c=s+u,m.set(n,c)):(s=x.get(n),c=s+u,x.set(n,c)):(s=g.get(n),c=s+u,g.set(n,c));const y=t.x(n);l.push([y,t.y(s)]),a.push([y,t.y(c)]),r.set(n,c)}d(),p.set(n.key,r)}return{nodes:y,stackedTops:p}}(n,e.scales,e.getX,e.getY,(t,n)=>e.resolveAreaStyle(t,n),e.config.normalize,i,s),c=a;if(e.config.pointStyle){const t=new WeakMap;for(const r of n){const n=l.get(r.key);if(n)for(const o of r.data){const r=e.getX(o),i=e.getY(o);null==r||Number.isNaN(r)||null==i||Number.isNaN(i)||!n.has(r)||t.set(o,n.get(r))}}const r=n=>t.get(n)??e.getY(n);nt(e,n,c,r)}return c}(o,t);case"scatter":case"bubble":return function(e,t){const n=[],r="bubble"===e.config.chartType?10:5,o=e.config.sizeRange||[3,15];let i=null;if(e.getSize&&!e.config.pointStyle){const n=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(n.length>0){let e=1/0,t=-1/0;for(const r of n)e>r&&(e=r),r>t&&(t=r);i=n=>e===t?(o[0]+o[1])/2:o[0]+(n-e)/(t-e)*(o[1]-o[0])}}const s=e.getColor?e.resolveColorMap(t):null,a=e.config.themeSemantic?.primary||"#4e79a7",l=e.getSymbol,c=e.config.symbolMap,u=new Map;let h=0;const d=e=>{const t=c?.[e];if(t)return t;let n=u.get(e);return n||(n=lt[h%lt.length],h++,u.set(e,n)),n};for(const o of t){let t=e.config.pointStyle?e.config.pointStyle(o):{fill:a,opacity:.8},c=t.r||r;if(i&&e.getSize){const t=e.getSize(o);null==t||Number.isNaN(t)||(c=i(t))}if(s&&e.getColor&&!t.fill){const n=e.getColor(o);n&&s.has(n)&&(t={...t,fill:s.get(n)})}const u=e.getPointId?e.getPointId(o)+"":void 0;if(l){const r=d(l(o)+""),i=Ge(o,e.scales,e.getX,e.getY,Math.PI*c*c,r,t,u);i&&n.push(i)}else{const r=qe(o,e.scales,e.getX,e.getY,c,t,u);r&&n.push(r)}}return n}(o,t);case"heatmap":return dt(o,t,e);case"bar":{const e=function(e,t){if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const n=ft(t,e.getX,e.getY,e.config.binSize,e.getCategory);if(0===n.size)return{nodes:[],binBoundaries:[]};let r=null;if(e.getCategory){const t=new Set;for(const e of n.values())for(const n of e.categories.keys())t.add(n);const o=e.config.barColors?Object.keys(e.config.barColors):[],i=new Set(o),s=Array.from(t).filter(e=>!i.has(e)).sort(),a=o.filter(e=>t.has(e)),l=a.join("\0")+""+s.join("\0");e.barCategoryCache&&e.barCategoryCache.key===l?r=e.barCategoryCache.order:(r=[...a,...s],e.barCategoryCache={key:l,order:r})}const o=[],i=e.scales,[s,a]=i.x.domain(),l=e.config.barStyle,c=e.config.themeSemantic?.primary,u=l?.gap,h="number"!=typeof u||0>u?1:u,d={};l?.stroke&&(d.stroke=l.stroke),"number"==typeof l?.strokeWidth&&(d.strokeWidth=l.strokeWidth),"number"==typeof l?.opacity&&(d.opacity=l.opacity);for(const t of n.values()){const n=Math.max(t.start,s),u=Math.min(t.end,a);if(n>=u)continue;const f=i.x(n),y=i.x(u),p=Math.abs(y-f),g=p>h+1?h:0,m=Math.min(f,y)+g/2,x=Math.max(p-g,1);if(x>0)if(r&&t.categories.size>0){let n=0;for(const s of r){const r=t.categories.get(s)||0;if(0===r)continue;const a=i.y(n),u=i.y(n+r);o.push(Ve(m,Math.min(a,u),x,Math.abs(a-u),{fill:e.config.barColors?.[s]||l?.fill||c||"#4e79a7",...d},{binStart:t.start,binEnd:t.end,total:t.total,category:s,categoryValue:r},s)),n+=r}}else{const e=i.y(0),n=i.y(t.total);o.push(Ve(m,Math.min(e,n),x,Math.abs(e-n),{fill:l?.fill||c||"#007bff",...d},{binStart:t.start,binEnd:t.end,total:t.total}))}}const f=new Set;for(const e of n.values())f.add(e.start),f.add(e.end);return{nodes:o,binBoundaries:Array.from(f).sort((e,t)=>e-t)}}(o,t);return this._barCategoryCache=o.barCategoryCache??null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){const n=[],r=e.config.swarmStyle||{},o=r.radius??3,i=r.fill??e.config.themeSemantic?.primary??"#007bff",s=r.opacity??.7,a=r.stroke,l=r.strokeWidth;for(const r of t){const t=e.getX(r),c=e.getY(r);if(null==c||Number.isNaN(c))continue;const u=e.scales.x(t),h=e.scales.y(c);let d=i;if(e.getCategory){const t=e.getCategory(r);d=e.config.barColors?.[t]||d}const{r:f,...y}=e.config.pointStyle?.(r)??{},p={type:"point",x:u,y:h,r:f??o,style:{fill:d,opacity:s,stroke:a,strokeWidth:l,...y},datum:r};e.getPointId&&(p.pointId=e.getPointId(r)+""),n.push(p)}return n}(o,t);case"waterfall":return function(e,t,n){const r=[],o=e.scales,i=e.config.waterfallStyle,s=t.filter(t=>{const n=e.getY(t),r=e.getX(t);return null!=n&&!Number.isNaN(n)&&null!=r&&isFinite(r)});if(0===s.length)return r;const a=i?.positiveColor??e.config.themeSemantic?.success??"#28a745",l=i?.negativeColor??e.config.themeSemantic?.danger??"#dc3545",c=i?.gap??1,u=i?.stroke,h=i?.strokeWidth,d=i?.opacity;let f=0;for(let t=0;s.length>t;t++){const y=s[t],p=e.getX(y),g=e.getY(y),m=f+g;let x;x=s.length-1>t?e.getX(s[t+1])-p:t>0?p-e.getX(s[t-1]):0;const v=o.x(p),b=0!==x?o.x(p+x):v+n.width/10,k=Math.min(v,b)+c/2,w=Math.max(v,b)-c/2-k;if(0>=w){f=m;continue}const A=o.y(f),S=o.y(m),M=Math.min(A,S),_=Math.abs(A-S),C={fill:0>g?l:a,stroke:u,strokeWidth:h};null!=d&&(C.opacity=d),r.push(Ve(k,M,w,_,C,{...y,baseline:f,cumEnd:m,delta:g,_connectorStroke:i?.connectorStroke,_connectorWidth:i?.connectorWidth})),f=m}return r}(o,t,e);case"candlestick":return function(e,t){if(!e.getHigh||!e.getLow||!e.scales)return[];const n=e.config.candlestickRangeMode??!1;if(!(n||e.getOpen&&e.getClose))return[];const r=[],o=e.config.candlestickStyle||{},i=o.rangeColor||"#6366f1",s=n?i:o.upColor||"#28a745",a=n?i:o.downColor||"#dc3545",l=n?i:o.wickColor||"#333",c=o.wickWidth||(n?2:1),u=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let h=o.bodyWidth??0;if(null==o.bodyWidth)if(u.length>1){let t=1/0;for(let n=1;u.length>n;n++){const r=Math.abs(e.scales.x(u[n])-e.scales.x(u[n-1]));r>0&&t>r&&(t=r)}h=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else h=6;for(const o of t){const t=e.getX(o);if(null==t||Number.isNaN(t))continue;const i=e.getHigh(o),u=e.getLow(o);if(null==i||Number.isNaN(i)||null==u||Number.isNaN(u))continue;const d=n?i:e.getOpen(o),f=n?u:e.getClose(o);if(!n&&[d,f].some(e=>null==e||Number.isNaN(e)))continue;const y=f>=d,p={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(d),closeY:e.scales.y(f),highY:e.scales.y(i),lowY:e.scales.y(u),bodyWidth:h,upColor:s,downColor:a,wickColor:l,wickWidth:c,isUp:y,datum:o};n&&(p.isRange=!0),r.push(p)}return r}(o,t);default:return[]}}resolveBoundsStyle(e,t){return function(e,t,n,r){const o=e.boundsStyle;return"function"==typeof o?o(n||{},t):o&&"object"==typeof o?o:{fill:r(t,n).stroke||e.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,stroke:"none"}}(this.config,e,t,(e,t)=>this.resolveLineStyle(e,t))}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?We(n,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const t=ze(e);return this._datumIndexCache={version:this._ingestVersion,map:t},t}applyDecay(e,t){this.config.decay&&function(e,t,n,r=ze(n)){const o=n.length;if(o>1)for(const n of t){if("line"===n.type){const t=Array.isArray(n.datum)?n.datum:[];if(2>t.length)continue;const i=Array(t.length);let s=!1;for(let n=0;t.length>n;n++){const a=r.get(t[n]);null!=a?(i[n]=We(e,a,o),1>i[n]&&(s=!0)):i[n]=1}s&&(n._decayOpacities=i);continue}if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[],i=n.topPath?n.topPath.length:t.length;if(2>i)continue;if(t.length===i){const s=Array(i);let a=!1;for(let n=0;t.length>n;n++){const i=r.get(t[n]);null!=i?(s[n]=We(e,i,o),1>s[n]&&(a=!0)):s[n]=1}a&&(n._decayOpacities=s)}else{let s=1;for(const n of t){const t=r.get(n);if(null!=t){const n=We(e,t,o);s>n&&(s=n)}}if(1>s){const e=Array(i);e.fill(s),n._decayOpacities=e}}continue}const t=r.get(n.datum);if(null==t)continue;const i=We(e,t,o);"heatcell"===n.type?n.style={opacity:i}:"candlestick"===n.type?n._decayOpacity=i:n.style={...n.style,opacity:(n.style?.opacity??1)*i}}}(this.config.decay,e,t,this.getDatumIndexMap(t))}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&function(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){if(!t||0===t.size)return!1;const r=e.duration??500,o=t.peek();return null!=o&&r>n-o}(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(e,t,n,r){n.clear(),r.clear();for(let o=0;t.length>o;o++){const i=t[o],s=Be(e,i,o);s&&("point"===i.type?n.set(s,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity}):"glyph"===i.type?n.set(s,{x:i.x,y:i.y,r:i.size,opacity:i.style.opacity,glyph:i.glyph}):"rect"===i.type?n.set(s,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity}):"heatcell"===i.type?n.set(s,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style?.opacity}):"candlestick"===i.type?n.set(s,{x:i.x,y:i.openY,w:i.bodyWidth,openY:i.openY,closeY:i.closeY,highY:i.highY,lowY:i.lowY,opacity:i.style?.opacity}):"line"===i.type?r.set(s,{path:i.path.map(e=>[e[0],e[1]]),opacity:i.style?.opacity}):"area"===i.type&&r.set(s,{topPath:i.topPath.map(e=>[e[0],e[1]]),bottomPath:i.bottomPath.map(e=>[e[0],e[1]]),opacity:i.style?.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();const e=this.scales?.y(0)??0;for(let t=0;this.scene.length>t;t++){const n=this.scene[t],r=Be(this.transitionContext,n,t);r&&("point"===n.type?this.prevPositionMap.set(r,{x:n.x,y:n.y,r:0,opacity:0}):"rect"===n.type?this.prevPositionMap.set(r,{x:n.x,y:e,w:n.w,h:0,opacity:n.style.opacity??1}):"heatcell"===n.type?this.prevPositionMap.set(r,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:0}):"line"===n.type?(n._introClipFraction=0,this.prevPathMap.set(r,{path:n.path.map(e=>[e[0],e[1]]),opacity:n.style.opacity})):"area"===n.type&&(n._introClipFraction=0,this.prevPathMap.set(r,{topPath:n.topPath.map(e=>[e[0],e[1]]),bottomPath:n.bottomPath.map(e=>[e[0],e[1]]),opacity:n.style.opacity})))}}startTransition(){if(!this.config.transition)return;const e=function(e,t,n,r,o,i=je()){if(0===r.size&&0===o.size)return n;const s=t.duration??300;if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}let a=!1;const l=new Set,c=new Set;for(let t=0;n.scene.length>t;t++){const i=n.scene[t],s=Be(e,i,t);if(!s)continue;if(i._transitionKey=s,"line"===i.type||"area"===i.type){const e=o.get(s);if(e){if(c.add(s),"line"===i.type&&e.path&&e.path.length===i.path.length){i._targetPath=i.path.map(e=>[e[0],e[1]]),i._prevPath=e.path;for(let t=0;i.path.length>t;t++)i.path[t]=[e.path[t][0],e.path[t][1]];a=!0}else if("area"===i.type&&e.topPath&&e.bottomPath&&e.topPath.length===i.topPath.length&&e.bottomPath.length===i.bottomPath.length){i._targetTopPath=i.topPath.map(e=>[e[0],e[1]]),i._targetBottomPath=i.bottomPath.map(e=>[e[0],e[1]]),i._prevTopPath=e.topPath,i._prevBottomPath=e.bottomPath;for(let t=0;i.topPath.length>t;t++)i.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;i.bottomPath.length>t;t++)i.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];a=!0}i._targetOpacity=i.style.opacity??1,i._startOpacity=e.opacity??i.style.opacity??1}else i._targetOpacity=i.style.opacity??1,i._startOpacity=0,i.style={...i.style,opacity:0},a=!0;continue}const u=r.get(s);if("point"===i.type)if(u){l.add(s);const e={x:i.x,y:i.y,r:i.r};i._targetOpacity=i.style.opacity??1,u.x===e.x&&u.y===e.y&&u.r===e.r||(i._targetX=e.x,i._targetY=e.y,i._targetR=e.r,i.x=u.x,i.y=u.y,i.r=u.r??i.r,a=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},a=!0;else if("glyph"===i.type)if(u){l.add(s);const e={x:i.x,y:i.y,size:i.size};i._targetOpacity=i.style.opacity??1,u.x===e.x&&u.y===e.y&&u.r===e.size||(i._targetX=e.x,i._targetY=e.y,i._targetR=e.size,i.x=u.x,i.y=u.y,i.size=u.r??i.size,a=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},a=!0;else if("rect"===i.type)if(u){l.add(s);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=i.style.opacity??1,u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=u.x,i.y=u.y,i.w=u.w??i.w,i.h=u.h??i.h,a=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},a=!0;else if("heatcell"===i.type)if(u){l.add(s);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=i.style?.opacity??1,u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=u.x,i.y=u.y,i.w=u.w??i.w,i.h=u.h??i.h,a=!0)}else i._targetOpacity=i.style?.opacity??1,i.style={...i.style||{},opacity:0},a=!0;else if("candlestick"===i.type)if(u&&null!=u.openY){l.add(s);const e={x:i.x,openY:i.openY,closeY:i.closeY,highY:i.highY,lowY:i.lowY};i._targetOpacity=i.style?.opacity??1,(u.x!==e.x||u.openY!==e.openY||u.closeY!==e.closeY||u.highY!==e.highY||u.lowY!==e.lowY)&&(i._targetX=e.x,i._targetOpenY=e.openY,i._targetCloseY=e.closeY,i._targetHighY=e.highY,i._targetLowY=e.lowY,i.x=u.x,i.openY=u.openY,i.closeY=u.closeY??i.closeY,i.highY=u.highY??i.highY,i.lowY=u.lowY??i.lowY,a=!0)}else i._targetOpacity=i.style?.opacity??1,i.style={...i.style||{},opacity:0},a=!0}for(const[e,t]of o)if(!c.has(e))if(e.startsWith("l:")&&t.path){const r={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(r),a=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const r={type:"area",topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),group:e.slice(2),style:{fill:"#999",opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(r),a=!0}for(const[e,t]of r)if(!l.has(e)){if(e.startsWith("p:"))n.exitNodes.push({type:"point",x:t.x,y:t.y,r:t.r??3,style:{opacity:t.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("g:")&&t.glyph)n.exitNodes.push({type:"glyph",x:t.x,y:t.y,size:t.r??12,glyph:t.glyph,color:"#999",accent:"#999",style:{opacity:t.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))n.exitNodes.push({type:"rect",x:t.x,y:t.y,w:t.w??0,h:t.h??0,style:{opacity:t.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("h:"))n.exitNodes.push({type:"heatcell",x:t.x,y:t.y,w:t.w??0,h:t.h??0,fill:"#999",datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e});else if(e.startsWith("c:")){const r=t.openY??t.y;n.exitNodes.push({type:"candlestick",x:t.x,openY:r,closeY:t.closeY??r,highY:t.highY??r,lowY:t.lowY??r,bodyWidth:t.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e})}a=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),a&&(n.activeTransition={startTime:i,duration:s}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap,this.currentTime());this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition}advanceTransition(e){if(!this.activeTransition||!this.config.transition)return!1;const t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(e,t,n,r){if(!n.activeTransition)return!1;const o=Pe(e,n.activeTransition),i=Ce(o,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of n.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style.opacity=Re(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=Re(n.x,e._targetX,i),e.y=Re(n.y,e._targetY,i),void 0!==e._targetR&&void 0!==n.r&&(e.r=Re(n.r,e._targetR,i))}else if("glyph"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style.opacity=Re(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=Re(n.x,e._targetX,i),e.y=Re(n.y,e._targetY,i),void 0!==e._targetR&&void 0!==n.r&&(e.size=Re(n.r,e._targetR,i))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style.opacity=Re(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=Re(n.x,e._targetX,i),e.y=Re(n.y,e._targetY,i),void 0!==n.w&&(e.w=Re(n.w,e._targetW,i)),void 0!==n.h&&(e.h=Re(n.h,e._targetH,i))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style={...e.style||{},opacity:Re(n?n.opacity??1:0,e._targetOpacity,i)}}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=Re(n.x,e._targetX,i),e.y=Re(n.y,e._targetY,i),void 0!==n.w&&(e.w=Re(n.w,e._targetW,i)),void 0!==n.h&&(e.h=Re(n.h,e._targetH,i))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style={...e.style||{},opacity:Re(n?n.opacity??1:0,e._targetOpacity,i)}}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=Re(n.x,e._targetX,i),void 0!==n.openY&&(e.openY=Re(n.openY,e._targetOpenY,i)),void 0!==n.closeY&&(e.closeY=Re(n.closeY,e._targetCloseY,i)),void 0!==n.highY&&(e.highY=Re(n.highY,e._targetHighY,i)),void 0!==n.lowY&&(e.lowY=Re(n.lowY,e._targetLowY,i))}else if("line"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:Re(e._startOpacity??0,e._targetOpacity,i)}),void 0!==e._introClipFraction&&(e._introClipFraction=i);const t=e._prevPath,n=e._targetPath;if(t&&n&&t.length===e.path.length)for(let r=0;e.path.length>r;r++)e.path[r][0]=Re(t[r][0],n[r][0],i),e.path[r][1]=Re(t[r][1],n[r][1],i)}else if("area"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:Re(e._startOpacity??0,e._targetOpacity,i)}),void 0!==e._introClipFraction&&(e._introClipFraction=i);const t=e._prevTopPath,n=e._prevBottomPath,r=e._targetTopPath,o=e._targetBottomPath;if(t&&r&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=Re(t[n][0],r[n][0],i),e.topPath[n][1]=Re(t[n][1],r[n][1],i);if(n&&o&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=Re(n[t][0],o[t][0],i),e.bottomPath[t][1]=Re(n[t][1],o[t][1],i)}}if(o>=1){for(const e of n.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style="line"===e.type||"area"===e.type?{...e.style,opacity:0===t?0:t}:{...e.style||{},opacity:0===t?0:t},e._targetOpacity=void 0}if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("glyph"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.size=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("candlestick"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,void 0!==e._targetOpenY&&(e.openY=e._targetOpenY),void 0!==e._targetCloseY&&(e.closeY=e._targetCloseY),void 0!==e._targetHighY&&(e.highY=e._targetHighY),void 0!==e._targetLowY&&(e.lowY=e._targetLowY),e._targetX=void 0,e._targetOpenY=void 0,e._targetCloseY=void 0,e._targetHighY=void 0,e._targetLowY=void 0}else if("line"===e.type){const t=e._targetPath;if(t)for(let n=0;e.path.length>n;n++)e.path[n]=t[n];e._prevPath=void 0,e._targetPath=void 0,e._introClipFraction=void 0}else if("area"===e.type){const t=e._targetTopPath,n=e._targetBottomPath;if(t)for(let n=0;e.topPath.length>n;n++)e.topPath[n]=t[n];if(n)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=n[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0,e._introClipFraction=void 0}}if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(e,this.config.transition,t,this.prevPositionMap);return this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition,n}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const e of this.scene)"line"!==e.type&&"area"!==e.type||(e._introClipFraction=void 0)}groupData(e){const{result:t,cache:n}=function(e,t,n,r){if(r&&r.version===n&&r.group===t&&r.data===e)return{result:r.result,cache:r};let o;if(t){const n=new Map;for(const r of e){const e=t(r);n.has(e)||n.set(e,[]),n.get(e).push(r)}o=Array.from(n.entries()).map(([e,t])=>({key:e,data:t}))}else o=[{key:"_default",data:e}];return{result:o,cache:{version:n,group:t,data:e,result:o}}}(e,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=n,t}resolveColorMap(e){const{map:t,cache:n}=function(e,t,n,r,o){if(o&&o.version===r)return{map:o.map,cache:o};const i=new Set;if(t)for(const n of e){const e=t(n);e&&i.add(e)}const s=Array.from(i).sort(),a=s.join("\0");if(o&&o.key===a){const e={...o,version:r};return{map:e.map,cache:e}}const l=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical||Ae,c=new Map;for(let e=0;s.length>e;e++)c.set(s[e],l[e%l.length]);return{map:c,cache:{key:a,map:c,version:r}}}(e,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=n,t}resolveLineStyle(e,t){return function(e,t,n,r){const o=e.lineStyle;if("function"==typeof o){const e=o(n||{},t);if(e&&!e.stroke&&t){const n=r(t);if(n)return{...e,stroke:n}}return e}const i=e.themeSemantic?.primary;return o&&"object"==typeof o?{stroke:o.stroke||i||"#007bff",strokeWidth:o.strokeWidth||2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity}:{stroke:r(t)||i||"#007bff",strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveAreaStyle(e,t){return function(e,t,n,r){if(e.areaStyle){const o=e.areaStyle(n||{});if(o&&!o.fill&&t){const e=r(t);if(e)return{...o,fill:e,stroke:o.stroke||e}}return o}const o=e.lineStyle;if("function"==typeof o){const e=o(n||{},t);if(e&&!e.fill&&t){const n=r(t);if(n)return{...e,fill:n,stroke:e.stroke||n}}return e}const i=e.themeSemantic?.primary;if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||i||"#4e79a7",fillOpacity:o.fillOpacity??.7,stroke:o.stroke||i||"#4e79a7",strokeWidth:o.strokeWidth||2};const s=r(t)||i||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveGroupColor(t){const{color:n,groupColorCounter:r}=function(e){const{group:t,colorMapCache:n,groupColorMap:r,groupColorMapCap:o,config:i}=e;let{groupColorCounter:s}=e;if(n){const e=n.map.get(t);if(e)return{color:e,groupColorCounter:s}}const a=r.get(t);if(a)return{color:a,groupColorCounter:s};const l=(Array.isArray(i.colorScheme)&&i.colorScheme.length>0?i.colorScheme:null)||(Array.isArray(i.themeCategorical)&&i.themeCategorical.length>0?i.themeCategorical:null)||Ae;if(0===l.length)return{color:null,groupColorCounter:s};const c=l[s%l.length];if(s++,r.set(t,c),r.size>o){const e=r.keys().next().value;void 0!==e&&r.delete(e)}return{color:c,groupColorCounter:s}}({group:t,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:e.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=r,n}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(e){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=re(e),n=this.getPointId,r=e=>t.has(n(e));!function(e,t,n){if(!t||0===t.size)return;const r=new Set;if(e.forEach((e,t)=>{n(e)&&r.add(t)}),0===r.size)return;const o=t.toArray();t.clear();for(let e=0;o.length>e;e++)r.has(e)||t.push(o[e])}(this.buffer,this.timestampBuffer,r);const o=this.buffer.remove(r);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(const e of o)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",o.length),o}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=re(e),r=this.getPointId,o=new Set;this.buffer.forEach((e,t)=>{n.has(r(e))&&o.add(t)});const i=this.buffer.update(e=>n.has(r(e)),t);if(0===i.length)return this.updateResults.recordNoop("update"),i;for(const e of i)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.buffer.forEach((e,t)=>{o.has(t)&&(this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",i.length),i}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this._datumIndexCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.spatialIndex.clear(),this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}applyCustomRestyle(e,t){const n=this._customRestyle;if(n)for(const r of e){const e=this._baseStyles.get(r)??r.style??{},o=n(r,t);r.style=o?{...e,...o}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(e){const t={...this.config},n=Object.keys(e).filter(n=>e[n]!==t[n]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e||"themeCategorical"in e||"colorAccessor"in e)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in e||"colorScheme"in e)&&(this._barCategoryCache=null),("normalize"in e||"extentPadding"in e||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e||"boundsAccessor"in e||"band"in e||"y0Accessor"in e||"openAccessor"in e||"highAccessor"in e||"lowAccessor"in e||"closeAccessor"in e||"groupAccessor"in e||"categoryAccessor"in e||"chartType"in e||"runtimeMode"in e)&&(this._stackExtentCache=null);let r=!1,o=!1;Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();const i="chartType"in e&&e.chartType!==t.chartType||"runtimeMode"in e&&e.runtimeMode!==t.runtimeMode;if(i||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){const e=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,n=e&&this.config.valueAccessor||this.config.yAccessor,s=e&&t.valueAccessor||t.yAccessor,a=i||!K(e&&this.config.timeAccessor||this.config.xAccessor,e&&t.timeAccessor||t.xAccessor),l=i||!K(n,s);(a||l)&&(e?(this.getX=Q(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=Q(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=Q(this.config.xAccessor,"x"),this.getY=Q(this.config.yAccessor,"y")),l&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=vt(this.config)),r=!0,o=!0)}if("groupAccessor"in e&&!K(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?J(this.config.groupAccessor):void 0,r=!0),"categoryAccessor"in e&&!K(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?J(this.config.categoryAccessor):void 0,r=!0),"sizeAccessor"in e&&!K(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?Q(this.config.sizeAccessor,"size"):void 0,r=!0),"symbolAccessor"in e&&!K(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?J(this.config.symbolAccessor):void 0,r=!0),"colorAccessor"in e&&!K(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?J(this.config.colorAccessor):void 0,r=!0),"y0Accessor"in e&&!K(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?Q(this.config.y0Accessor,"y0"):void 0,r=!0,o=!0),("boundsAccessor"in e&&!K(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=vt(this.config),r=!0,o=!0),"pointIdAccessor"in e&&!K(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?J(this.config.pointIdAccessor):void 0,r=!0),"candlestick"===this.config.chartType&&(i||"openAccessor"in e&&!K(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!K(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!K(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!K(e.lowAccessor,t.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?Q(this.config.openAccessor,"open"):void 0,this.getHigh=Q(this.config.highAccessor,"high"),this.getLow=Q(this.config.lowAccessor,"low"),this.getClose=t?Q(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,r=!0,o=!0}if("accessorRevision"in e&&e.accessorRevision!==t.accessorRevision&&(r=!0,o=!0),!r){const n=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const o of n)if(e[o]!==t[o]){r=!0;break}}r&&(o&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(n)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};Qt.GROUP_COLOR_MAP_CAP=1e3;var Zt=Qt;Tt(Zt);var Jt=require("react"),en={sceneGeometry:0,layout:0,domain:0};function tn(e){const{domain:t,layout:n,sceneGeometry:r}=e.revisions;return{domain:t,layout:n,sceneGeometry:r}}function nn(e,t){return{sceneGeometry:Math.max(e.sceneGeometry,t.sceneGeometry),layout:Math.max(e.layout,t.layout),domain:Math.max(e.domain,t.domain)}}var rn="production"!==process.env.NODE_ENV,on={revisions:en,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},sn=class{constructor(e="scene host"){this.hostName=e,this.lastConsumed=en,this.lastObserved=en,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}observeUpdateResult(e){rn&&(this.lastObserved=nn(this.lastObserved,tn(e)))}beforeCompute(e,t){if(!rn)return on;const n=nn(tn(e),this.lastObserved),r=function(e){return`${e.sceneGeometry}|${e.layout}|${e.domain}`}(n),o=!((i=n).sceneGeometry===(s=this.lastConsumed).sceneGeometry&&i.layout===s.layout&&i.domain===s.domain);var i,s;return{revisions:n,signature:r,sawSignals:e.changed.has("scene-geometry")||e.changed.has("layout")||e.changed.has("domain"),wasUnconsumed:o,warnUnconsumed:!t&&o&&this.lastUnconsumedWarning!==r}}afterCompute(e,t,n){if(rn){if(t&&e.wasUnconsumed&&(this.lastConsumed=e.revisions),e.warnUnconsumed&&!t)return console.warn(`[semiotic] ${this.hostName} observed scene-affecting revisions without a scene rebuild: ${e.signature}.`),void(this.lastUnconsumedWarning=e.signature);t&&e.sawSignals&&!e.wasUnconsumed&&!n&&this.lastDuplicateWarning!==e.signature?(console.warn(`[semiotic] ${this.hostName} performed scene rebuild with unchanged scene revisions: ${e.signature}.`),this.lastDuplicateWarning=e.signature):t&&!e.sawSignals&&(this.lastDuplicateWarning="")}}};function an(e){return(0,Jt.useRef)(new sn(e))}var ln=(0,Jt.memo)(function({store:e,diagnostics:t}){return(0,Jt.useEffect)(()=>{const n=()=>t.observeUpdateResult(e.getUpdateSnapshot());return n(),e.subscribeUpdateResult(n)},[t,e]),null}),cn=p(require("react"));function un(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:cn.createElement(cn.Fragment,null,...t)}var hn=p(require("react")),dn=require("react/jsx-runtime"),fn=hn.createContext(null);function yn({value:e,children:t}){return(0,dn.jsx)(fn.Provider,{value:e,children:t})}function pn(e,t){return null!=e?(0,dn.jsx)(yn,{value:t,children:e}):e}var gn=require("react");function mn(e,t,n,r){(0,gn.useEffect)(()=>{e.current?.updateConfig(t),n.current=!0,r()},[t,r,e,n])}function xn(e,t,n,r){const o=(0,gn.useRef)(null);(0,gn.useEffect)(()=>{const i=e.current;if(!i)return;const s=t??null;o.current!==s&&(o.current=s,i.setLayoutSelection(s),i.hasCustomRestyle?i.restyleScene(s):n.current=!0,r())},[t,r,e,n])}function vn(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function bn(e,t=30){return Math.max((e??4)+5,12,t)}function kn(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function wn(e,t){const n=kn(e);if(!n)return!1;const r=kn(t);return!r||n.getFullYear()!==r.getFullYear()||n.getMonth()!==r.getMonth()}function An(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}var Sn=[40,40],Mn=[.5,.5];function _n(e,t){const[n,r]=e.viewBox??Sn,[o,i]=e.anchor??Mn,s=r>0?r:1,a=Math.max(0,t)/s,l=(n>0?n:s)*a,c=s*a;return{width:l,height:c,scale:a,offsetX:-o*l,offsetY:-i*c}}function Cn(e,t,n,r){if("none"!==e)return"color"===e||null==e?t??r:"accent"===e?n:e}var Pn=null;function Rn(e){if("undefined"==typeof Path2D)return null;Pn||(Pn=new Map);const t=Pn.get(e);if(t)return t;const n=new Path2D(e);return Pn.size>1024&&Pn.clear(),Pn.set(e,n),n}function jn(e,t,n=0,r="horizontal"){const[o,i]=e.viewBox??Sn,s=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,t));return a>s?s>0||1>a?"vertical"===r?{x:0,y:i*(1-a),width:o,height:i*(a-s)}:{x:o*s,y:0,width:o*(a-s),height:i}:null:{x:0,y:0,width:0,height:0}}function Tn(e,t){const n=_n(e,t);return{centerDx:n.offsetX+n.width/2,centerDy:n.offsetY+n.height/2,halfWidth:n.width/2,halfHeight:n.height/2,radius:Math.hypot(n.width,n.height)/2}}function En(e,t,n,r,o,i=e=>e){for(const s of t.parts){const t=Rn(s.d);if(!t)continue;const a=s.opacity??1,l=e.globalAlpha;1!==a&&(e.globalAlpha=l*a);const c=o?"none"===s.fill?void 0:o:Cn(s.fill,n,r);c&&(e.fillStyle=i(c),e.fill(t));const u=o?s.stroke&&"none"!==s.stroke?o:void 0:Cn(s.stroke??"none",n,r);u&&(e.strokeStyle=i(u),e.lineWidth=s.strokeWidth??1,e.lineCap=s.strokeLinecap??"butt",e.lineJoin=s.strokeLinejoin??"miter",e.stroke(t)),1!==a&&(e.globalAlpha=l)}}function Ln(e,t,n,r,o,i=e=>e.x,s=e=>e.y,a=e=>e.r){const l=Math.max(r,o+5,12),c=t-l,u=t+l,h=n-l,d=n+l;let f=null,y=1/0;return e.visit((e,o,l,p,g)=>{if(o>u||c>p||l>d||h>g)return!0;if(!e.length){let o=e;do{const e=o.data,l=i(e)-t,c=s(e)-n,u=Math.sqrt(l*l+c*c);bn(a(e),r)>=u&&y>u&&(f=e,y=u),o=o.next}while(o)}return!1}),f?{node:f,distance:y}:null}var Nn=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Dn=new WeakMap,In=0,$n=!1,Wn=null,zn=null;function On(e,t){if(!t)return t;const n=Nn.exec(t);if(!n)return t;const r=e.canvas;if(!r)return n[2]?.trim()||t;!function(){if($n)return;if("undefined"==typeof window||"undefined"==typeof document)return;$n=!0;const e=()=>{In++};if("undefined"!=typeof MutationObserver&&document.documentElement&&new MutationObserver(e).observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]}),"function"==typeof window.matchMedia)try{Wn=window.matchMedia("(prefers-color-scheme: dark)"),zn=e,"function"==typeof Wn.addEventListener?Wn.addEventListener("change",zn):"function"==typeof Wn.addListener&&Wn.addListener(zn)}catch{}}();let o=Dn.get(r);o&&o.version===In||(o={version:In,map:new Map},Dn.set(r,o));const i=o.map.get(t);if(void 0!==i)return i;const s=getComputedStyle(r).getPropertyValue(n[1]).trim()||n[2]?.trim()||t;return o.map.set(t,s),s}var Fn=null;var Bn=require("react/jsx-runtime");function Yn(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function Hn(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}var Xn=new Map;function qn(e,t){const{background:n="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:i=6,angle:s=45,lineOpacity:a=1}=e,l=Math.max(8,Math.ceil(2*i));return(0,Bn.jsxs)("pattern",{id:t,width:l,height:l,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[n&&"transparent"!==n&&(0,Bn.jsx)("rect",{width:l,height:l,fill:n}),(0,Bn.jsx)("line",{x1:0,y1:0,x2:0,y2:l,stroke:r,strokeWidth:o,strokeOpacity:a}),(0,Bn.jsx)("line",{x1:i,y1:0,x2:i,y2:l,stroke:r,strokeWidth:o,strokeOpacity:a})]},t)}function Gn(e,t,n="#4e79a7"){if(Yn(e)){const n=function(e,t){let n=2166136261;const r=Hn(t);for(let e=0;r.length>e;e++)n^=r.charCodeAt(e),n=Math.imul(n,16777619);return`${e}-hatch-${(n>>>0).toString(36)}`}(t,e);return{fill:`url(#${n})`,def:qn(e,n)}}return e&&"string"==typeof e?{fill:e}:{fill:n}}var Vn=require("d3-shape");function Un(e){switch(e){case"monotoneX":return Vn.curveMonotoneX;case"monotoneY":return Vn.curveMonotoneY;case"cardinal":return Vn.curveCardinal;case"catmullRom":return Vn.curveCatmullRom;case"step":return Vn.curveStep;case"stepBefore":return Vn.curveStepBefore;case"stepAfter":return Vn.curveStepAfter;case"basis":return Vn.curveBasis;case"natural":return Vn.curveNatural;default:return null}}function Kn(e,t,n){if(null==t)return n;if(Yn(t)){const r=function(e,t){const n="undefined"!=typeof window&&window.devicePixelRatio||1,r=`${Hn(e)}@${n}`,o=Xn.get(r);if(void 0!==o)return o;const i=function(e={},t){const{background:n="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:i=6,angle:s=45}=e,a=Math.max(8,Math.ceil(2*i));let l;try{l=function(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):(Fn||(Fn=document.createElement("canvas")),Fn.width=e,Fn.height=e,Fn)}(a)}catch{return null}const c=l.getContext("2d");if(!c)return null;n&&"transparent"!==n?(c.fillStyle=n,c.fillRect(0,0,a,a)):c.clearRect(0,0,a,a),c.strokeStyle=r,c.lineWidth=o,c.lineCap="square";const u=s*Math.PI/180;if(45===s||-45===s){const e=s>0?1:-1;for(let t=-a;2*a>=t;t+=i)c.beginPath(),c.moveTo(t,0),c.lineTo(t+e*a,a),c.stroke()}else{c.save(),c.translate(a/2,a/2),c.rotate(u);const e=2*a;for(let t=-e;e>=t;t+=i)c.beginPath(),c.moveTo(-e,t),c.lineTo(e,t),c.stroke();c.restore()}return(t||c).createPattern(l,"repeat")}({background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle},t);return Xn.set(r,i),i}(t,e);return r||t.background&&On(e,t.background)||n}return"string"!=typeof t?t:On(e,t)||n}function Qn(e,t,n,r,o,i,s){if("colorStops"in t){const n=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>n.length)return null;const a=e.createLinearGradient(r,o,i,s);for(const e of n)a.addColorStop(e.offset,e.color);return a}const{topOpacity:a,bottomOpacity:l}=t;if(!Number.isFinite(a)||!Number.isFinite(l))return null;const c=Math.max(0,Math.min(1,a)),u=Math.max(0,Math.min(1,l)),h=e.createLinearGradient(r,o,i,s),[d,f,y]=function(e,t){const n=e.fillStyle,r="#010203";try{e.fillStyle=r,e.fillStyle=t}catch{return e.fillStyle=n,[78,121,167]}const o=e.fillStyle;if(e.fillStyle=n,"string"!=typeof o)return[78,121,167];if(o.toLowerCase()===r&&t.trim().toLowerCase()!==r)return[78,121,167];if(o.startsWith("#"))return[parseInt(o.slice(1,3),16),parseInt(o.slice(3,5),16),parseInt(o.slice(5,7),16)];const i=o.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return i?[+i[1],+i[2],+i[3]]:[78,121,167]}(e,n);return h.addColorStop(0,`rgba(${d},${f},${y},${c})`),h.addColorStop(1,`rgba(${d},${f},${y},${u})`),h}function Zn(e,t,n,r,o,i){const s=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>s.length)return null;const a=e.createLinearGradient(n,r,o,i);for(const e of s)a.addColorStop(e.offset,e.color);return a}var Jn=require("d3-shape"),er=new WeakMap;function tr(e,t){const n=Un(t);if(!n)return e;const r=er.get(e);if(r)return r;const o=function(e,t,n=8){if(!t||2>e.length)return e.map(([e,t])=>[e,t]);const r=[];let o=null;const i={moveTo(e,t){o=[e,t],r.push([e,t])},lineTo(e,t){o=[e,t],r.push([e,t])},bezierCurveTo(e,t,i,s,a,l){if(!o)return o=[a,l],void r.push([a,l]);const[c,u]=o;for(let o=1;n>=o;o++){const h=o/n,d=1-h;r.push([d*d*d*c+3*d*d*h*e+3*d*h*h*i+h*h*h*a,d*d*d*u+3*d*d*h*t+3*d*h*h*s+h*h*h*l])}o=[a,l]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(e,t,n,i){o=[n,i],r.push([n,i])}};return(0,Jn.line)().x(e=>e[0]).y(e=>e[1]).curve(t).context(i)(e),r}(e,n);return er.set(e,o),o}function nr(e,t,n,r=30,o,i=0){let s=null;if(o){const e=Ln(o,t,n,r,i);e&&(s={node:e.node,datum:e.node.datum,x:e.node.x,y:e.node.y,distance:e.distance})}for(const i of e){let e=null;switch(i.type){case"point":if(o)break;e=or(i,t,n,r);break;case"symbol":e=ir(i,t,n,r);break;case"glyph":e=sr(i,t,n,r);break;case"line":e=ar(i,t,n,r);break;case"rect":if(null==i.datum)break;e=cr(i,t,n);break;case"heatcell":e=ur(i,t,n);break;case"area":if(!1===i.interactive)break;e=dr(i,t,n);break;case"candlestick":e=hr(i,t,n)}e&&r>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}function rr(e,t,n){if(0===e.length)return null;if(e[0][0]>t||t>e[e.length-1][0])return null;const r=fr(e,t);if(0>r)return null;if(Math.abs(e[r][0]-t)>n)return null;let o=r,i=r;r>0&&e[r][0]>=t?(o=r-1,i=r):e.length-1>r&&(o=r,i=r+1);const[s,a]=e[o],[l,c]=e[i];return l===s?a:a+Math.max(0,Math.min(1,(t-s)/(l-s)))*(c-a)}function or(e,t,n,r=30){const o=t-e.x,i=n-e.y,s=Math.sqrt(o*o+i*i);return s>bn(e.r,r)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function ir(e,t,n,r=30){const o=t-e.x,i=n-e.y,s=Math.sqrt(o*o+i*i);return s>bn(ut(e.size),r)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function sr(e,t,n,r=30){if(null==e.datum)return null;const o=Tn(e.glyph,e.size),i=e.x+o.centerDx,s=e.y+o.centerDy,a=t-i,l=n-s,c=Math.sqrt(a*a+l*l);return c>bn(o.radius,r)?null:{node:e,datum:e.datum,x:i,y:s,distance:c}}function ar(e,t,n,r=30){if(0===e.path.length)return null;const o=fr(e.path,t);if(0>o)return null;const[i,s]=e.path[o];let a;if(e.path.length>1){let r=1/0;const i=Math.max(0,o-1),s=Math.min(e.path.length-2,o);for(let o=i;s>=o;o++){const[i,s]=e.path[o],[a,l]=e.path[o+1],c=lr(t,n,i,s,a,l);r>c&&(r=c)}a=r}else{const e=t-i,r=n-s;a=Math.sqrt(e*e+r*r)}const l=e.style;return a>Math.max(5,(l.strokeWidth??l.lineWidth??1)/2+2,r)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:i,y:s,distance:a}}function lr(e,t,n,r,o,i){const s=o-n,a=i-r,l=s*s+a*a;if(0===l)return Math.sqrt((e-n)**2+(t-r)**2);let c=((e-n)*s+(t-r)*a)/l;return c=Math.max(0,Math.min(1,c)),Math.sqrt((e-(n+c*s))**2+(t-(r+c*a))**2)}function cr(e,t,n){const r=vn(t,n,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function ur(e,t,n){const r=vn(t,n,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function hr(e,t,n){const r=e.bodyWidth/2,o=Math.min(e.openY,e.closeY);if(!(e.x-r-3>t||t>e.x+r+3||e.highY-3>n||n>e.lowY+3)){const r=o+Math.max(Math.max(e.openY,e.closeY)-o,1)/2,i=t-e.x,s=n-r;return{node:e,datum:e.datum,x:e.x,y:r,distance:Math.sqrt(i*i+s*s)}}return null}function dr(e,t,n){if(0===e.topPath.length)return null;const r=fr(e.topPath,t);if(0>r)return null;const[o,i]=e.topPath[r],s=t-o,a=n-i,l=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[r]?e.datum[r]:e.datum,x:o,y:i,distance:l}}function fr(e,t){if(0===e.length)return-1;let n=0,r=e.length-1;for(;r>n;){const o=n+r>>1;t>e[o][0]?n=o+1:r=o}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}var yr=require("react"),pr={fresh:1,aging:.7,stale:.45,expired:.25},gr={alpha:1,band:"fresh",isStale:!1};function mr(e,t){if(!e||0>=t)return gr;const n=null!=e.threshold&&e.threshold>0?e.threshold:5e3,r=e.graded;if(r){const e="object"==typeof r?r:{},o=Ee(t,n,e.thresholds);return{alpha:{...pr,...e.opacities??{}}[o],band:o,isStale:"fresh"!==o}}return t>n?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:gr}function xr(e,t,n,r,o,i){const s=(0,yr.useRef)("fresh");(0,yr.useEffect)(()=>{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=mr(e,l-a.lastIngestTime);c.band===s.current&&c.isStale===o||(s.current=c.band,c.isStale!==o&&i(c.isStale),n.current=!0,r())},1e3);return()=>clearInterval(a)},[e,o,r,t,i,n])}var vr=require("react/jsx-runtime");function br({isStale:e,position:t}){return(0,vr.jsx)("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"})}var kr=require("react"),wr=p(require("react")),Ar=require("react/jsx-runtime"),Sr={fill:(e,t)=>(0,Ar.jsx)("rect",{style:e,width:t,height:t}),line:(e,t)=>(0,Ar.jsx)("line",{style:e,x1:0,y1:0,x2:t,y2:t})};function Mr(e,t,n,r,o){let i;return i="function"==typeof n?n(e):(0,Sr[n])(r(e,t),o),i}function _r({swatchSize:e}){return(0,Ar.jsx)("path",{d:`M${.25*e},${.55*e} L${.45*e},${.75*e} L${.8*e},${.3*e}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Cr(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}var Pr=(e,t,n,r,o,i,s,a,l,c,u)=>{const{type:h="fill",styleFn:d,items:f}=e,y=[];let p=0;const g=!(!t&&!n),m="isolate"===c||void 0===c&&null!=o,{swatchSize:x,labelGap:v,rowHeight:b}=u;return f.forEach((e,c)=>{const u=Mr(e,c,h,d,x),k=Cr(e,r,o),w=o&&o.size>0&&o.has(e.label);y.push((0,Ar.jsxs)("g",{transform:`translate(0,${p})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:g?a===i&&c===s?0:-1:void 0,role:g?"option":void 0,"aria-selected":g&&m?w||!1:void 0,"aria-current":g&&!m&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:g?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(c+("ArrowDown"===n.key?1:-1)+f.length)%f.length;l(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:g?t=>{l(a,c),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:g?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:g?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[g&&(0,Ar.jsx)("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:x+v+2+7*e.label.length,height:x+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),u,w&&(0,Ar.jsx)(_r,{swatchSize:x}),(0,Ar.jsx)("text",{y:x/2,x:x+v,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+c)),p+=b}),y};function Rr({config:e,orientation:t="vertical",width:n=100}){const{colorFn:r,domain:o,label:i,format:s}=e,a=s||(e=>Math.round(100*e)/100+""),l="grad-legend-"+wr.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),s=Math.max(0,(n-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.push((0,Ar.jsx)("stop",{offset:100*t+"%",stopColor:r(o[0]+t*(o[1]-o[0]))},e))}return(0,Ar.jsxs)("g",{"aria-label":i||"Gradient legend",children:[(0,Ar.jsx)("defs",{children:(0,Ar.jsx)("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),i&&(0,Ar.jsx)("text",{x:s+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),(0,Ar.jsx)("rect",{x:s,y:0,width:t,height:e,fill:`url(#${l})`,rx:2}),(0,Ar.jsx)("text",{x:s,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[0])}),(0,Ar.jsx)("text",{x:s+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[1])})]})}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.push((0,Ar.jsx)("stop",{offset:100*t+"%",stopColor:r(o[1]-t*(o[1]-o[0]))},e))}return(0,Ar.jsxs)("g",{"aria-label":i||"Gradient legend",children:[i&&(0,Ar.jsx)("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),(0,Ar.jsx)("defs",{children:(0,Ar.jsx)("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:c})}),(0,Ar.jsx)("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),(0,Ar.jsx)("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[1])}),(0,Ar.jsx)("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[0])})]})}function jr(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,legendInteraction:s,title:a="Legend",width:l=100,height:c=20,orientation:u="vertical",legendLayout:h}=e,d=function(e){const t=Math.max(1,e?.swatchSize??16),n=Math.max(t,e?.rowHeight??22);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??6),itemGap:Math.max(0,e?.itemGap??10),rowHeight:n,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}(h),[f,y]=wr.useState(0),[p,g]=wr.useState(0),m=wr.useCallback((e,t)=>{y(e),g(t)},[]),x="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:l,legendInteraction:c,metrics:u})=>{const h=[],d=function(e,t){let n=24;return e.map(({hasLabel:e,itemCount:r})=>{n+=5;const o=n;let i;n+=8,e&&(n+=16,i=n,n+=8);const s=n;return n+=r*t+8,{lineY:o,labelY:i,itemsY:s,endY:n}})}(e.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),u.rowHeight);return e.forEach((e,f)=>{const y=d[f];h.push((0,Ar.jsx)("line",{stroke:"gray",x1:0,y1:y.lineY,x2:t,y2:y.lineY},"legend-top-line legend-symbol-"+f)),e.label&&null!=y.labelY&&h.push((0,Ar.jsx)("text",{y:y.labelY,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+f)),h.push((0,Ar.jsx)("g",{className:"legend-item",transform:`translate(0,${y.itemsY})`,children:Pr(e,n,r,o,i,s,a,f,l,c,u)},"legend-group-"+f))}),h})({legendGroups:t||[],width:l,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:s,metrics:d}):(({legendGroups:e,height:t,width:n,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u,metrics:h})=>{let d=0;const f=[];e.forEach((e,t)=>{let y=0;e.label&&(y+=16);const p=((e,t,n,r,o,i,s,a,l,c,u,h)=>{const{type:d="fill",styleFn:f,items:y}=e,p=[],{swatchSize:g,labelGap:m,itemGap:x,rowHeight:v,align:b}=u,k=!(!t&&!n),w="isolate"===c||void 0===c&&null!=o,A=y.map(e=>g+m+7*e.label.length),S=[];let M=0,_=0;A.forEach((e,t)=>{const n=0===_?e:_+x+e;h&&h>0&&_>0&&n>h?(S.push({start:M,end:t,width:_}),M=t,_=e):_=n}),y.length>0&&S.push({start:M,end:y.length,width:_}),S.forEach((e,c)=>{let u="center"===b?Math.max(0,((h??e.width)-e.width)/2):"end"===b?Math.max(0,(h??e.width)-e.width):0;for(let h=e.start;e.end>h;h++){const e=y[h],b=Mr(e,h,d,f,g),S=Cr(e,r,o),M=o&&o.size>0&&o.has(e.label);p.push((0,Ar.jsxs)("g",{transform:`translate(${u},${c*v})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:k?a===i&&h===s?0:-1:void 0,role:k?"option":void 0,"aria-selected":k&&w?M||!1:void 0,"aria-current":k&&!w&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:k?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(h+("ArrowRight"===n.key?1:-1)+y.length)%y.length;l(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:k?t=>{l(a,h),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:k?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:k?"pointer":"default",opacity:S,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[k&&(0,Ar.jsx)("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:g+m+2+7*e.label.length,height:g+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),b,M&&(0,Ar.jsx)(_r,{swatchSize:g}),(0,Ar.jsx)("text",{y:g/2,x:g+m,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+h)),u+=A[h]+x}});const C=Math.max(0,...S.map(e=>e.width)),P=S.length;return{items:p,offset:C,totalRows:P,totalHeight:P*v}})(e,r,o,i,s,a,l,t,c,u,h,h.maxWidth??n);y+=p.offset+5,f.push({label:e.label,...p,offset:y,totalRows:p.totalRows,totalHeight:p.totalHeight}),d+=y+12});const y=h.maxWidth??n;let p=d>y?0:"center"===h.align?Math.max(0,(y-d)/2):"end"===h.align?Math.max(0,y-d):0;const g=[];return f.forEach((n,r)=>{const o=e[r];o.label&&(g.push((0,Ar.jsx)("text",{transform:`translate(${p},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:o.label},"legend-text-"+r)),p+=16),g.push((0,Ar.jsx)("g",{className:"legend-item",transform:`translate(${p},0)`,children:n.items},"legend-group-"+r)),p+=n.offset+5,e[r+1]&&g.push((0,Ar.jsx)("line",{stroke:"gray",x1:p,y1:-8,x2:p,y2:(n.totalHeight||t)+0+8},"legend-top-line legend-symbol-"+r)),p+=12}),(0,Ar.jsx)("g",{children:g})})({legendGroups:t||[],title:a,height:c,width:l,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:s,metrics:d}),v=!(!n&&!r);return(0,Ar.jsxs)("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==s&&(void 0!==s||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==a&&""!==a&&"vertical"===u&&(0,Ar.jsx)("text",{className:"legend-title",y:16,x:l/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:a}),x]})}function Tr(e){return"object"==typeof e&&null!==e&&"legendGroups"in e&&Array.isArray(e.legendGroups)}var Er=require("react/jsx-runtime");function Lr(e){const{legend:t,totalWidth:n,totalHeight:r,margin:o,legendPosition:i="right",legendLayout:s,title:a,legendHoverBehavior:l,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:h,legendInteraction:d}=e;if(!t)return null;const f="top"===i||"bottom"===i,y=!!a,p=Math.max(0,n-o.left-o.right),g=Math.max(1,f?s?.maxWidth??p:100);let m,x;return"left"===i?(m=Math.max(4,o.left-g-10),x=o.top):"top"===i?(m=o.left,x=y?32:8):"bottom"===i?(m=o.left,x=r-o.bottom+38):(m=n-o.right+10,x=o.top),(0,Er.jsx)("g",{transform:`translate(${m}, ${x})`,children:(v=t,"object"==typeof v&&null!==v&&"gradient"in v?(0,Er.jsx)(Rr,{config:t.gradient,orientation:f?"horizontal":"vertical",width:g}):Tr(t)?(0,Er.jsx)(jr,{legendGroups:t.legendGroups,title:"",width:g,orientation:f?"horizontal":"vertical",legendLayout:s,customHoverBehavior:l,customClickBehavior:c,highlightedCategory:u,isolatedCategories:h,legendInteraction:d}):t)});var v}var Nr=require("react"),Dr=require("d3-array");function Ir(e){let t=1/0,n=-1/0;for(const r of e)t>r&&(t=r),r>n&&(n=r);return[t,n]}var $r=require("react/jsx-runtime");function Wr(e){return"string"==typeof e?{type:e}:e}function zr({orient:e,config:t,values:n,scale:r,size:o,length:i}){const s=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=(0,Nr.useMemo)(()=>{if(0===n.length)return null;const t=r.domain(),l=o-8;if("boxplot"===s.type){const t=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const r=t[Math.floor(.25*n)],o=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],s=i-r;return{q1:r,median:o,q3:i,whiskerLow:Math.max(t[0],r-1.5*s),whiskerHigh:Math.min(t[n-1],i+1.5*s)}}(n);if(!t)return null;const{q1:o,median:i,q3:c,whiskerLow:u,whiskerHigh:h}=t,d=Math.min(.5*l,20),f=(l-d)/2+4;if(a){const t=r(o),n=r(c),a=r(i),l=r(u),y=r(h),p="top"===e?-1:1,g=0;return(0,$r.jsxs)("g",{"data-testid":"marginal-boxplot-"+e,children:[(0,$r.jsx)("line",{x1:l,y1:g+p*(f+d/2),x2:y,y2:g+p*(f+d/2),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,$r.jsx)("line",{x1:l,y1:g+p*f,x2:l,y2:g+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,$r.jsx)("line",{x1:y,y1:g+p*f,x2:y,y2:g+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,$r.jsx)("rect",{x:Math.min(t,n),y:"top"===e?g-f-d:g+f,width:Math.abs(n-t),height:d,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),(0,$r.jsx)("line",{x1:a,y1:"top"===e?g-f-d:g+f,x2:a,y2:"top"===e?g-f:g+f+d,stroke:s.fill,strokeWidth:2})]})}{const t=r(o),n=r(c),a=r(i),l=r(u),y=r(h),p="left"===e?-1:1,g=0;return(0,$r.jsxs)("g",{"data-testid":"marginal-boxplot-"+e,children:[(0,$r.jsx)("line",{x1:g+p*(f+d/2),y1:l,x2:g+p*(f+d/2),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,$r.jsx)("line",{x1:g+p*f,y1:l,x2:g+p*(f+d),y2:l,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,$r.jsx)("line",{x1:g+p*f,y1:y,x2:g+p*(f+d),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,$r.jsx)("rect",{x:"left"===e?g-f-d:g+f,y:Math.min(t,n),width:d,height:Math.abs(n-t),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),(0,$r.jsx)("line",{x1:"left"===e?g-f-d:g+f,y1:a,x2:"left"===e?g-f:g+f+d,y2:a,stroke:s.fill,strokeWidth:2})]})}}const c=(0,Dr.bin)().domain(t).thresholds(s.bins)(n);if(0===c.length)return null;const u=function(e,t=-1/0){let n=t;for(const t of e)t>n&&(n=t);return n}(c.map(e=>e.length));if(0===u)return null;if("histogram"===s.type)return(0,$r.jsx)("g",{"data-testid":"marginal-histogram-"+e,children:c.map((t,n)=>{if(null==t.x0||null==t.x1)return null;const o=t.length/u*l;if(a){const i=r(t.x0),a=r(t.x1)-r(t.x0);return(0,$r.jsx)("rect",{x:i,y:"top"===e?-4-o:4,width:Math.max(a,.5),height:o,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}{const i=r(t.x0),a=r(t.x1)-r(t.x0);return(0,$r.jsx)("rect",{x:"left"===e?-4-o:4,y:Math.min(i,i+a),width:o,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}})});if("violin"===s.type){const t=l/2+4,n=[];for(const o of c){if(null==o.x0||null==o.x1)continue;const i=o.length/u*(l/2),s=r((o.x0+o.x1)/2);n.push(a?`${s},${"top"===e?-(t-i):t-i}`:`${"left"===e?-(t-i):t-i},${s}`)}for(let o=c.length-1;o>=0;o--){const i=c[o];if(null==i.x0||null==i.x1)continue;const s=i.length/u*(l/2),h=r((i.x0+i.x1)/2);n.push(a?`${h},${"top"===e?-(t+s):t+s}`:`${"left"===e?-(t+s):t+s},${h}`)}return(0,$r.jsx)("g",{"data-testid":"marginal-violin-"+e,children:(0,$r.jsx)("polygon",{points:n.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}if("ridgeline"===s.type){const t=[];if(a){const n=0,o=null!=c[0].x0?r(c[0].x0):0;t.push(`M${o},${n}`);for(const n of c){if(null==n.x0||null==n.x1)continue;const o=n.length/u*l,i=r((n.x0+n.x1)/2);t.push(`L${i},${"top"===e?-o-4:o+4}`)}const s=null!=c[c.length-1].x1?r(c[c.length-1].x1):i;t.push(`L${s},${n}`),t.push("Z")}else{const n=0,o=null!=c[0].x0?r(c[0].x0):0;t.push(`M${n},${o}`);for(const n of c){if(null==n.x0||null==n.x1)continue;const o=n.length/u*l,i=r((n.x0+n.x1)/2);t.push(`L${"left"===e?-o-4:o+4},${i}`)}const s=null!=c[c.length-1].x1?r(c[c.length-1].x1):i;t.push(`L${n},${s}`),t.push("Z")}return(0,$r.jsx)("g",{"data-testid":"marginal-ridgeline-"+e,children:(0,$r.jsx)("path",{d:t.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}return null},[n,r,s,o,i,e,a,4]);return l?(0,$r.jsx)("g",{className:"marginal-"+e,"data-testid":"marginal-"+e,children:l}):null}var Or=p(require("react")),Fr=require("react/jsx-runtime");function Br(e,t=120,n=8){if(!e)return[];const r=Math.max(1,Math.floor(t/n)),o=e.split(/\s+/),i=[];let s="";for(const e of o)s&&s.length+1+e.length>r?(i.push(s),s=e):s=s?`${s} ${e}`:e;return s&&i.push(s),i}function Yr(e,t,n,r){return"curly"===e?r?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:r?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function Hr(e,t,n,r){if(!e)return(0,Fr.jsx)("g",{className:"annotation-note"});const{label:o,title:i,orientation:s,align:a,wrap:l=120,noWrap:c}=e;if(!o&&!i)return(0,Fr.jsx)("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let h=a;h&&"dynamic"!==h||(h="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let d="start";"topBottom"===u?"right"===h?d="end":"middle"===h&&(d="middle"):d=0>t?"end":"start";const f=16,y=i?c?[i]:Br(i,l):[],p=o?c?[o]:Br(o,l):[],g="leftRight"===u?"end"===d?-4:4:0;let m=0;const x=[],v=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";e.useHTML||e.html?x.push((0,Fr.jsx)("foreignObject",{className:"annotation-note-html",x:"end"===d?g-l:"middle"===d?g-l/2:g,y:-16,width:l,height:Math.max(f,(y.length+p.length)*f+(i&&o?2:0))+f,style:{overflow:"visible"},children:(0,Fr.jsxs)("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:v,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===d?"right":"middle"===d?"center":"left",whiteSpace:c?"nowrap":"normal",wordBreak:"break-word"},children:[i&&(0,Fr.jsx)("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:i}),o&&(0,Fr.jsx)("div",{className:"annotation-note-label",children:o})]})},"annotation-note-html")):(y.length>0&&(x.push((0,Fr.jsx)("text",{className:"annotation-note-title",fill:v,textAnchor:d,fontWeight:"bold",children:y.map((e,t)=>(0,Fr.jsx)("tspan",{x:g,dy:0===t?0:f,children:e},t))},"annotation-note-title")),m=y.length*f),p.length>0&&x.push((0,Fr.jsx)("text",{className:"annotation-note-label",fill:v,textAnchor:d,y:m,children:p.map((e,t)=>(0,Fr.jsx)("tspan",{x:g,dy:0===t?0:f,children:e},t))},"annotation-note-label")));let b=null;if((i||o)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(l,120);let t=0,n=e;"end"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),b=(0,Fr.jsx)("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(y.length+p.length)*f+(p.length>0?f:0);let t=0,n=e;"bottom"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),b=(0,Fr.jsx)("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const k=Math.max(0,y.length+p.length-1)*f;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===h?-(k+f+(p.length>0&&y.length>0?2:0))/2+8:"bottom"===h||0>n?-(k+2):18),(0,Fr.jsxs)("g",{className:"annotation-note",transform:`translate(${t},${n})`,children:[(0,Fr.jsx)("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0,children:x}),b]})}function Xr(e,t,n,r,o){const i=[];switch(e){case"callout-circle":{const e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&i.push((0,Fr.jsx)("circle",{r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=t?.width||0,r=t?.height||0;(e>0||r>0)&&i.push((0,Fr.jsx)("rect",{width:e,height:r,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":t?.custom&&i.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=r||0,s=o||0;if(void 0!==t?.x){const r=(t.x||0)-e;i.push((0,Fr.jsx)("line",{x1:r,y1:(t.y1||0)-s,x2:r,y2:(t.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==t?.y){const r=(t.y||0)-s;i.push((0,Fr.jsx)("line",{x1:(t.x1||0)-e,y1:r,x2:(t.x2||0)-e,y2:r,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==t?.x1||void 0!==t?.x2?i.push((0,Fr.jsx)("line",{x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===t?.y1&&void 0===t?.y2||i.push((0,Fr.jsx)("line",{x1:0,y1:(t.y1||0)-s,x2:0,y2:(t.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=t?.type||"curly",r=t?.width??t?.height;void 0!==r&&i.push((0,Fr.jsx)("path",{d:Yr(e,r,t?.depth||30,void 0===t?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return(0,Fr.jsx)("g",{className:"annotation-subject",children:i})}function qr(e,t,n,r,o,i){const s=[];let a=0,l=0;if("callout-circle"!==o&&"label"!==o||!i?.radius){if("callout-rect"===o&&i){const n=i.width||0,r=i.height||0;if(n>0||r>0){const o=n/2,i=r/2,s=e-o,c=t-i;if(0!==s||0!==c){const e=Math.abs(s),t=Math.abs(c),u=n/2,h=r/2,d=e*h>t*u?u/e:h/t;a=o+s*d,l=i+c*d}}}else if("bracket"===o&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(a=e/2,l=n):void 0!==t&&(a=n,l=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const r=Math.atan2(t,e);a=Math.cos(r)*n,l=Math.sin(r)*n}}const c=Math.sqrt((e-a)**2+(t-l)**2);if(c>.5){const o=r||"var(--semiotic-text-secondary, currentColor)",i="curve"===n?.type;let u=Math.atan2(t-l,e-a);if(i){const r=(a+e)/2,i=(l+t)/2,h=-(t-l)/c,d=(e-a)/c,f=(n?.curve??.25)*c,y=r+h*f,p=i+d*f;s.push((0,Fr.jsx)("path",{className:"connector-curve",d:`M${a},${l}Q${y},${p} ${e},${t}`,fill:"none",stroke:o},"connector-line")),u=Math.atan2(p-l,y-a)}else s.push((0,Fr.jsx)("line",{x1:a,y1:l,x2:e,y2:t,stroke:o},"connector-line"));if("arrow"===n?.end){const e=10,t=16/180*Math.PI;s.push((0,Fr.jsx)("path",{d:`M${a},${l}L${a+e*Math.cos(u+t)},${l+e*Math.sin(u+t)}L${a+e*Math.cos(u-t)},${l+e*Math.sin(u-t)}Z`,fill:o,stroke:"none"},"connector-arrow"))}}return(0,Fr.jsx)("g",{className:"annotation-connector",children:s})}function Gr(e){const{x:t=0,y:n=0,dx:r,dy:o,nx:i,ny:s,note:a,connector:l,subject:c,type:u,color:h,className:d,disable:f,opacity:y,strokeDasharray:p,events:g={},"data-testid":m}=e,x=Array.isArray(t)?t[0]??0:t,v=Array.isArray(n)?n[0]??0:n,b=new Set(Array.isArray(f)?f:[]);let k=r||0,w=o||0;null!=i&&(k=i-x),null!=s&&(w=s-v);const A="string"==typeof u?u:"label";if("bracket"===A&&c&&0===k&&0===w)if(void 0!==c.width){k=c.width/2;const e=c.depth||30;w=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;k=e+(0>e?-5:5),w=c.height/2}return(0,Fr.jsxs)("g",{className:("annotation "+(d||"")).trim(),transform:`translate(${x},${v})`,"data-testid":m,...null!=y&&{opacity:y},...p&&{strokeDasharray:p},...g,children:[!b.has("connector")&&qr(k,w,l,h,A,c),!b.has("subject")&&Xr(A,c,h,x,v),!b.has("note")&&Hr(a,k,w,h)]})}function Vr(e){const{noteData:t}=e,{screenCoordinates:n}=t,r="string"==typeof t.type?t.type:"label",o=t.eventListeners||t.events||{};if(t.coordinates&&n){const e=t.nx||n[0][0]+(t.dx??0),o=t.ny||n[0][1]+(t.dy??0),i=n.map((n,i)=>{const s=Object.assign({},t,{note:0===i?t.note:{label:""},x:n[0],y:n[1],nx:e,ny:o});return(0,Fr.jsx)(Gr,{"data-testid":"semiotic-annotation",...s,type:r},"multi-annotation-"+i)});return(0,Fr.jsx)("g",{children:i})}const i=t.note||{title:"none",label:t.label},s=`${i.label}-${i.title}-${t.i}`;return(0,Fr.jsx)(Gr,{"data-testid":"semiotic-annotation",events:o,...t,type:r},s)}var Ur=require("d3-hierarchy"),Kr=require("d3-shape");function Qr(e){return Math.round(100*e)/100}function Zr(e,t=2){const n=[],r=[],o=t+1;for(let t=0;o>t;t++){let i=0;for(const[n,r]of e)null!==r&&(i+=n**t*r);n.push(i);const s=[];for(let n=0;o>n;n++){let r=0;for(const[o,i]of e)null!==i&&(r+=o**(t+n));s.push(r)}r.push(s)}r.push(n);const i=function(e,t){const n=e,r=e.length-1,o=[t];for(let e=0;r>e;e++){let t=e;for(let o=e+1;r>o;o++)Math.abs(n[e][o])>Math.abs(n[e][t])&&(t=o);for(let o=e;r+1>o;o++){const r=n[o][e];n[o][e]=n[o][t],n[o][t]=r}for(let t=e+1;r>t;t++)for(let o=r;o>=e;o--)n[o][t]-=n[o][e]*n[e][t]/n[e][e]}for(let e=r-1;e>=0;e--){let t=0;for(let i=e+1;r>i;i++)t+=n[i][e]*o[i];o[e]=(n[r][e]-t)/n[e][e]}return o}(r,o).map(Qr);return{points:e.map(([e])=>[Qr(e),Qr(i.reduce((t,n,r)=>t+n*e**r,0))]),equation:[...i].reverse()}}function Jr(e,t){const n=t.scales?.x??t.scales?.time;return n?null!=e.x?n(e.x):t.xAccessor&&null!=e[t.xAccessor]?n(e[t.xAccessor]):null:null}function eo(e,t){const n=t.scales?.y??t.scales?.value;return n?null!=e.y?n(e.y):t.yAccessor&&null!=e[t.yAccessor]?n(e[t.yAccessor]):null:null}function to(e){return null==e?null:e+""}function no(e,t,n){return t.stickyPositionCache?.set(e,n),n}function ro(e,t,n){const r=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===r){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const o=n.pointNodes[r];if(o.pointId===e.pointId)return no(t,n,{x:o.x,y:o.y})}const r=function(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],r=e.scales?.x??e.scales?.time,o=e.scales?.y??e.scales?.value;if(!r||!o)return null;const i=n[e.xAccessor||"x"],s=n[e.yAccessor||"y"];return null==i||null==s?null:{x:r(i),y:o(s)}}(n);return r?no(t,n,r):null}if("semantic"===r){const r=function(e,t,n){const r=function(e){return to(e.provenance?.stableId??e.stableId)}(e);if(!r)return null;const o=n.pointNodes?.find(e=>to(e.pointId)===r);if(o)return no(t,n,{x:o.x,y:o.y});const i=n.data?.find(e=>function(e){return to(e.stableId??e.id??e.provenance?.stableId)}(e)===r);if(!i)return null;const s=Jr(i,n),a=eo(i,n);return null==s||null==a?null:no(t,n,{x:s,y:a})}(e,t,n);if(r)return r}let o=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(o=t.x,i=t.y)}if(null!=o&&null!=i||(o=Jr(e,n),i=eo(e,n)),null!=o&&null!=i)return no(t,n,{x:o,y:i});if("sticky"===r){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function oo(e,t,n,r=50){return!(-r>e||e>(n.width||0)+r||-r>t||t>(n.height||0)+r)}var io=require("react/jsx-runtime"),so={secondary:0,primary:3},ao=".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}";function lo(e){return!0===e?._annotationDeferred}function co(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function uo(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function ho(e){return Math.max(.72,.95-.06*e)}var fo=p(require("react")),[yo,po]=$(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function go(e){const t=po(e=>e.pushObservation),n=fo.useCallback(n=>{e.onObservation?.(n),t?.(n)},[e,t]);return fo.useMemo(()=>({...e,onObservation:n}),[n,e])}function mo(e,t={}){const n=function(e){const t=e.provenance,n=e.id??e.stableId??t?.stableId;return null==n||""===n?void 0:n+""}(e);return{"data-semiotic-annotation-widget":"",...n?{"data-semiotic-annotation-id":n}:{},onClickCapture(r){const o=function(e){const t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}(r);t.onAnnotationActivate?.({annotation:e,annotationId:n,chartId:t.chartId,inputType:o}),n&&t.onObservation&&t.onObservation({type:"annotation-activate",annotationId:n,inputType:o,timestamp:Date.now(),chartType:t.chartType??"unknown",chartId:t.chartId})}}}function xo(e){return e instanceof Element&&null!=e.closest("[data-semiotic-annotation-widget]")}var vo=require("react/jsx-runtime"),bo="var(--semiotic-bg, #ffffff)";function ko(e){const{x:t,y:n,text:r,fill:o,fontSize:i=12,fontWeight:s,fontFamily:a,textAnchor:l="start",dominantBaseline:c,background:u,className:h}=e,d=function(e){return void 0===e||!0===e||"halo"===e?{type:"halo"}:!1===e||"none"===e?null:"box"===e?{type:"box"}:{type:e.type??"halo",...e}}(u),f=e=>(0,vo.jsx)("text",{x:t,y:n,textAnchor:l,dominantBaseline:c,fill:o,fontSize:i,fontWeight:s,fontFamily:a,className:h,...e?{stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:"stroke"}:{},children:r});if(!d)return f();if("halo"===d.type)return f({stroke:d.fill??bo,strokeWidth:d.haloWidth??3});const y=d.padding??{x:6,y:3},p="number"==typeof y?y:y.x,g="number"==typeof y?y:y.y,m=function(e,t){return(e+"").length*t*.6}(r,i),x=i+2*g;let v,b;return v="middle"===l?t-m/2-p:"end"===l?t-m-p:t-p,b="middle"===c||"central"===c?n-x/2:"hanging"===c||"text-before-edge"===c?n-g:n-.8*i-g,(0,vo.jsxs)("g",{className:h,children:[(0,vo.jsx)("rect",{x:v,y:b,width:m+2*p,height:x,rx:d.radius??3,ry:d.radius??3,fill:d.fill??bo,fillOpacity:d.opacity??.85,stroke:d.stroke,strokeWidth:d.strokeWidth}),f()]})}var wo=require("react/jsx-runtime"),Ao={linear:Kr.curveLinear,monotoneX:Kr.curveMonotoneX,monotoneY:Kr.curveMonotoneY,step:Kr.curveStep,stepAfter:Kr.curveStepAfter,stepBefore:Kr.curveStepBefore,basis:Kr.curveBasis,cardinal:Kr.curveCardinal,catmullRom:Kr.curveCatmullRom};function So(e,t,n,r){const o=[];return e.forEach((e,i)=>{let s;if(n){const o=n(e,i,r);s=null!=o?o:t(e,i,r)}else s=t(e,i,r);s&&o.push({node:s,annotation:e})}),function(e){const t=e.map((e,t)=>{return{p:e,i:t,emphasis:(n=e.annotation,"primary"===n?.emphasis||"secondary"===n?.emphasis?n.emphasis:null),confidence:uo(e.annotation),readingOrder:null,rank:1};var n}),n=t.some(e=>null!=e.emphasis||null!=e.confidence),r=e.some(e=>lo(e.annotation)),o=e.some(e=>null!=co(e.annotation)),i=e.some(e=>"layer"===co(e.annotation));if(!n&&!r&&!o)return e.map(e=>e.node);const s=t.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>(t.confidence??0)-(e.confidence??0)||e.i-t.i);s.forEach((e,t)=>{e.readingOrder=t,e.rank=2-t/Math.max(1,s.length)});for(const e of t)e.emphasis&&(e.rank=so[e.emphasis]);const a=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{const{p:t,i:n,emphasis:r,readingOrder:o}=e,i=lo(t.annotation);let s=t.node;if("primary"===r||"secondary"===r||null!=o){const e=null==r&&null!=o;s=(0,io.jsx)("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r,..."secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},...e?{opacity:ho(o),"data-annotation-reading-order":o}:{},children:t.node},"annotation-emphasis-"+n)}const a=co(t.annotation);return a&&(s=(0,io.jsx)("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+n)),i&&(s=(0,io.jsx)("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+n)),s});return r&&a.unshift((0,io.jsx)("style",{children:ao},"annotation-disclosure-style")),i&&a.unshift((0,io.jsx)("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),a}(o)}function Mo(e,t={}){return function(e,n,r){switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const t=ro(e,n,r);if(!t)return null;const{x:o,y:i}=t;if(!oo(o,i,r))return null;const s="callout"===e.type?"callout-circle":e.type,a="callout-circle"===s?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===s?{width:e.width,height:e.height}:void 0;return(0,wo.jsx)(Vr,{noteData:{x:o,y:i,dx:e.dx??30,dy:e.dy??-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:s,...a?{subject:a}:{},connector:e.connector||{end:"arrow"},color:e.color,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-"+n)}case"x-threshold":{const t=Jr(null!=e.value?{...e,x:e.value}:e,r);if(null==t)return null;const o=e.color||"#f97316",i=e.labelPosition||"top";let s;s="bottom"===i?(r.height||0)-4:"center"===i?(r.height||0)/2:16;const a=t>.6*(r.width||0),l=a?t-4:t+4,c=a?"end":"start";return(0,wo.jsxs)("g",{opacity:e.opacity,children:[(0,wo.jsx)("line",{x1:t,y1:0,x2:t,y2:r.height||0,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,wo.jsx)(ko,{x:l,y:s,text:e.label,textAnchor:c,fill:o,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"y-threshold":{const t=eo(null!=e.value?{...e,y:e.value}:e,r);if(null==t)return null;const o=e.color||"#f97316",i=e.labelPosition||"right";let a,l;"left"===i?(a=4,l="start"):"center"===i?(a=(r.width||0)/2,l="middle"):(a=(r.width||0)-4,l="end");const c=20>(s=t)?Math.min((r.height||0)-4,s+16):s-4;return(0,wo.jsxs)("g",{opacity:e.opacity,children:[(0,wo.jsx)("line",{x1:0,y1:t,x2:r.width||0,y2:t,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,wo.jsx)(ko,{x:a,y:c,text:e.label,textAnchor:l,fill:o,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"enclose":{const t=(e.coordinates||[]).map(e=>({x:Jr({...e,type:"point"},r),y:eo({...e,type:"point"},r),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const o=(0,Ur.packEnclose)(t),i=e.padding||10;return(0,wo.jsxs)("g",{children:[(0,wo.jsx)("circle",{cx:o.x,cy:o.y,r:o.r+i,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&(0,wo.jsx)(ko,{x:o.x,y:o.y-o.r-i-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"rect-enclose":{const t=(e.coordinates||[]).map(e=>({x:Jr({...e,type:"point"},r),y:eo({...e,type:"point"},r)})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const o=e.padding||10,i=t.map(e=>e.x),s=t.map(e=>e.y),[a,l]=Ir(i),[c,u]=Ir(s),h=a-o,d=l+o,f=c-o;return(0,wo.jsxs)("g",{children:[(0,wo.jsx)("rect",{x:h,y:f,width:d-h,height:u+o-f,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&(0,wo.jsx)(ko,{x:(h+d)/2,y:f-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"highlight":{const t=r.data||[],o="function"==typeof e.filter?t.filter(e.filter):e.field&&null!=e.value?t.filter(t=>t[e.field]===e.value):[],i={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return(0,wo.jsx)("g",{children:o.map((t,n)=>{const o=Jr(t,r),s=eo(t,r);if(null==o||null==s)return null;const a="function"==typeof e.r?e.r(t):e.r||6,l="function"==typeof e.style?e.style(t):e.style||i;return(0,wo.jsx)("circle",{cx:o,cy:s,r:a,...l},"hl-"+n)})},"ann-"+n)}case"bracket":{const t=Jr(e,r),o=eo(e,r);return(0,wo.jsx)(Vr,{noteData:{x:t??0,y:o??0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+n)}case"trend":{const t=r.data||[];if(2>t.length)return null;const o=r.xAccessor||"x",i=r.yAccessor||"y",s="ordinal"===r.frameType,a="horizontal"===r.projection,l=s?o:null,c=s?i:null;let u;const h=[],d=new Map;if(s&&l&&c){for(const e of t){const t=e[l];if(null==t)continue;const n=t+"";d.has(n)||(d.set(n,h.length),h.push(n))}u=t.map(e=>{const t=e[l],n=e[c];if(null==t||null==n)return null;const r=d.get(t+"");return null!=r?[r,+n]:null}).filter(e=>null!==e)}else u=t.map(e=>[e[o],e[i]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>u.length)return null;const f=r.scales?.x??r.scales?.time,y=r.scales?.y??r.scales?.value;if(!f||!y)return null;const p=e=>t=>{const n=Math.max(0,Math.floor(t)),r=Math.min(h.length-1,n+1),o=t-n,i=e(h[n]);return i+(e(h[r])-i)*o},g=f,m=y;let x;if(s)if(a){const e=p(m);x=(t,n)=>[g(n),e(t)]}else{const e=p(g);x=(t,n)=>[e(t),m(n)]}else x=(e,t)=>[g(e),m(t)];const v=e.method||"linear";let b;if("loess"===v)b=function(e,t=.3){const n=e.length;if(2>n)return e.slice();const r=e.slice().sort((e,t)=>e[0]-t[0]),o=r.map(e=>e[0]),i=r.map(e=>e[1]),s=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=o[e],r=o.map(e=>Math.abs(e-t)),l=r.slice().sort((e,t)=>e-t)[Math.min(s-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:r[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,h=0,d=0,f=0,y=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,h+=t*o[e],d+=t*i[e],f+=t*o[e]*o[e],y+=t*o[e]*i[e])}if(0===u){a.push([t,i[e]]);continue}const p=u*f-h*h;if(1e-12>Math.abs(p))a.push([t,d/u]);else{const e=(u*y-h*d)/p;a.push([t,(d-e*h)/u+e*t])}}return a}(u,e.bandwidth??.3);else{const t="polynomial"===v?Zr(u,e.order||2):function(e){const t=[0,0,0,0];let n=0;for(const[r,o]of e)null!==o&&(n++,t[0]+=r,t[1]+=o,t[2]+=r*r,t[3]+=r*o);const r=n*t[2]-t[0]*t[0],o=0===r?0:Qr((n*t[3]-t[0]*t[1])/r),i=Qr(t[1]/n-o*t[0]/n);return{points:e.map(([e])=>[Qr(e),Qr(o*e+i)]),equation:[o,i]}}(u);b=t.points}const k=b.map(([e,t])=>{const[n,r]=x(e,t);return`${n},${r}`}).join(" "),w=e.color||"#6366f1",A=b[b.length-1],[S,M]=x(A[0],A[1]);return(0,wo.jsxs)("g",{children:[(0,wo.jsx)("polyline",{points:k,fill:"none",stroke:w,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,wo.jsx)("text",{x:S+4,y:M-4,fill:w,fontSize:11,children:e.label})]},"ann-"+n)}case"band":{const t=r.scales?.y??r.scales?.value,s=t?.(e.y0)??0,a=t?.(e.y1)??(r.height||0),l=Gn(e.fill,"ann-"+n,"var(--semiotic-primary, #6366f1)");return(0,wo.jsxs)("g",{opacity:e.opacity,children:[l.def&&(0,wo.jsx)("defs",{children:l.def}),(0,wo.jsx)("rect",{x:0,y:Math.min(s,a),width:r.width||0,height:Math.abs(a-s),fill:l.fill,fillOpacity:e.fillOpacity||.1}),e.label&&(0,wo.jsx)(ko,{x:(r.width||0)-4,y:(o=s,i=a,Math.max(Math.min(o,i),0)+16),textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"x-band":{const t=r.scales?.x??r.scales?.time,o=null!=e.x0&&t?t(e.x0):null,i=null!=e.x1&&t?t(e.x1):null;if(null==o||null==i)return null;const s=Gn(e.fill||e.color,"ann-"+n,"var(--semiotic-primary, #6366f1)");return(0,wo.jsxs)("g",{opacity:e.opacity,children:[s.def&&(0,wo.jsx)("defs",{children:s.def}),(0,wo.jsx)("rect",{x:Math.min(o,i),y:0,width:Math.abs(i-o),height:r.height||0,fill:s.fill,fillOpacity:e.fillOpacity??.1}),e.label&&(0,wo.jsx)(ko,{x:Math.min(o,i)+4,y:16,textAnchor:"start",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"envelope":{const t=r.data||[];if(2>t.length)return null;const o=r.xAccessor||"x",i=r.scales?.x??r.scales?.time,s=r.scales?.y??r.scales?.value;if(!i||!s)return null;const a=e.upperAccessor||"upperBounds",l=e.lowerAccessor||"lowerBounds",c=e.filter,u=t.filter(e=>null!=e[a]&&null!=e[l]&&!(c&&!c(e))).sort((e,t)=>e[o]-t[o]);if(2>u.length)return null;const h=Ao[r.curve||"linear"]||Kr.curveLinear,d=(0,Kr.area)().x(e=>i(e[o])).y0(e=>s(e[l])).y1(e=>s(e[a])).curve(h)(u);if(!d)return null;const f=e.fill||"#6366f1";return(0,wo.jsxs)("g",{children:[(0,wo.jsx)("path",{d:d,fill:f,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&u.length>0&&(0,wo.jsx)("text",{x:i(u[u.length-1][o])+4,y:s(u[u.length-1][a])-4,fill:f,fontSize:11,children:e.label})]},"ann-"+n)}case"anomaly-band":{const t=r.data||[];if(2>t.length)return null;const o=r.yAccessor||"y",i=r.scales?.x??r.scales?.time,s=r.scales?.y??r.scales?.value;if(!i||!s)return null;const a=t.map(e=>e[o]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const l=a.reduce((e,t)=>e+t,0)/a.length,c=a.reduce((e,t)=>e+(t-l)**2,0)/a.length,u=Math.sqrt(c),h=e.threshold??2,d=l-h*u,f=!1!==e.showBand,y=e.fill||"#6366f1",p=e.fillOpacity??.1,g=e.anomalyColor||"#ef4444",m=e.anomalyRadius??6,x=s(l+h*u),v=s(d),b=t.filter(e=>{const t=e[o];return null!=t&&Math.abs(t-l)>h*u});return(0,wo.jsxs)("g",{children:[f&&(0,wo.jsx)("rect",{x:0,y:Math.min(x,v),width:r.width||0,height:Math.abs(v-x),fill:y,fillOpacity:p}),b.map((e,t)=>{const n=Jr(e,r),o=eo(e,r);return null==n||null==o?null:(0,wo.jsx)("circle",{cx:n,cy:o,r:m,fill:g,fillOpacity:.7,stroke:g,strokeWidth:1.5},"anomaly-"+t)}),e.label&&(0,wo.jsx)("text",{x:(r.width||0)-4,y:Math.min(x,v)-4,textAnchor:"end",fill:y,fontSize:11,children:e.label})]},"ann-"+n)}case"forecast":{const t=r.data||[];if(3>t.length)return null;const o=r.xAccessor||"x",i=r.yAccessor||"y",s=r.scales?.x??r.scales?.time,a=r.scales?.y??r.scales?.value;if(!s||!a)return null;const l=t.map(e=>[e[o],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>l.length)return null;let c;if("polynomial"===(e.method||"linear")){const t=Zr(l,e.order||2).equation;c=e=>t.reduce((t,n,r)=>t+n*Math.pow(e,r),0)}else{const e=l.length;let t=0,n=0,r=0,o=0;for(const[e,i]of l)t+=e,n+=i,r+=e*e,o+=e*i;const i=e*r-t*t;if(1e-12>Math.abs(i))return null;const s=(e*o-t*n)/i,a=(n-s*t)/e;c=e=>a+s*e}const u=l.length,h=l.map(([e,t])=>t-c(e)),d=h.reduce((e,t)=>e+t*t,0),f=Math.sqrt(d/Math.max(u-2,1)),y=l.reduce((e,t)=>e+t[0],0)/u,p=l.reduce((e,t)=>e+(t[0]-y)**2,0),g=e.confidence??.95,m=.99>g?.95>g?.9>g?1:1.645:1.96:2.576,x=e.steps??5,v=l[u-1][0],b=(v-l[0][0])/Math.max(u-1,1),k=[];for(let e=1;x>=e;e++)k.push(v+e*b);const w=[];for(const e of k){const t=c(e),n=f*Math.sqrt(1+1/u+(p>0?(e-y)**2/p:0))*m;w.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const A=`M${w.map(e=>`${s(e.x)},${a(e.yUpper)}`).join(" L")} L${w.slice().reverse().map(e=>`${s(e.x)},${a(e.yLower)}`).join(" L")} Z`,S=w.map(e=>`${s(e.x)},${a(e.yCenter)}`).join(" "),M=`${s(v)},${a(c(v))}`,_=e.strokeColor||"#6366f1";return(0,wo.jsxs)("g",{children:[(0,wo.jsx)("path",{d:A,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),(0,wo.jsx)("polyline",{points:`${M} ${S}`,fill:"none",stroke:_,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&w.length>0&&(0,wo.jsx)("text",{x:s(w[w.length-1].x)+4,y:a(w[w.length-1].yCenter)-4,fill:_,fontSize:11,children:e.label})]},"ann-"+n)}case"widget":{let o,i;if(null!=e.px&&null!=e.py)o=e.px,i=e.py;else{const t=ro(e,n,r);if(!t)return null;o=t.x,i=t.y}if(!oo(o,i,r))return null;const s=e.dx??0,a=e.dy??0,l=e.width??32,c=e.height??32,u=e.content??(0,wo.jsx)("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return(0,wo.jsx)("foreignObject",{x:o+s-l/2,y:i+a-c/2,width:l,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:(0,wo.jsx)("div",{...mo(e,t),style:{width:l,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const t=ro(e,n,r);if(!t)return null;const{x:o,y:i}=t,s=o+(e.dx||0),a=i+(e.dy||0),l=e.color||"var(--semiotic-text, #333)",c=(0,wo.jsx)("text",{x:s,y:a,fill:l,fontSize:e.fontSize||11,opacity:e.opacity,strokeDasharray:e.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label});return!0!==e._redundantConnector?Or.cloneElement(c,{key:"ann-text-"+n}):(0,wo.jsxs)("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[(0,wo.jsx)("line",{x1:o,y1:i,x2:s,y2:a,stroke:l,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),Or.cloneElement(c,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+n)}case"category-highlight":{const t=e.category;if(null==t)return null;const o=e=>"function"==typeof e&&"function"==typeof e.bandwidth,i=r.scales?.o,s=r.scales?.x,a=r.scales?.y,l=o(i)?i:o(s)?s:o(a)?a:null;if(!l)return null;const c=l(t+"");if(null==c)return null;const u=l.bandwidth(),h=e.color||"var(--semiotic-primary, #4589ff)",d=e.opacity??.15,f=e.label;return(0,wo.jsxs)("g",(r.projection?"vertical"===r.projection:l===s)?{children:[(0,wo.jsx)("rect",{x:c,y:0,width:u,height:r.height||0,fill:h,fillOpacity:d}),f&&(0,wo.jsx)(ko,{x:c+u/2,y:16,textAnchor:"middle",fill:h,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]}:{children:[(0,wo.jsx)("rect",{x:0,y:c,width:r.width||0,height:u,fill:h,fillOpacity:d}),f&&(0,wo.jsx)(ko,{x:12,y:c+u/2,dominantBaseline:"middle",fill:h,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]},"ann-"+n)}default:return null}var o,i,s}}var _o=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function Co(e){return!!e&&"object"==typeof e&&_o.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}function Po(e){return"primary"===e?.emphasis||!0===e?.defensive}function Ro(e,t,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:2e4))):1/0}function jo(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const r=e?.provenance?.confidence;switch("number"==typeof r&&Number.isFinite(r)&&(t+=15*Math.max(0,Math.min(1,r))),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}new Set(["label","callout","callout-circle","callout-rect"]);var To=32,Eo=6,Lo=4,No=8,Do=72;var Io={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function $o(e){if(!Wo(e))return e;const t=("string"==typeof e.mobileText?e.mobileText:void 0)??("string"==typeof e.shortText?e.shortText:void 0);return!t||"string"!=typeof e.label&&null!=e.label?e:{...e,label:t}}function Wo(e){return Co(e)}function zo(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),r=e.split(/\s+/).filter(Boolean),o=[];let i="";for(const e of r)i&&i.length+e.length+1>n?(o.push(i),i=e):i=i?`${i} ${e}`:e;return i&&o.push(i),o}function Oo(e,t,n,r,o){const i=e+n,s=t+r;return Math.abs(n)>Math.abs(r)?{x:0>n?i-o.width-4:i+4,y:0>r?s-o.height:s,width:o.width,height:o.height}:{x:0>n?i-o.width:i,y:0>r?s-o.height-4:s+4,width:o.width,height:o.height}}function Fo(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function Bo(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function Yo(e,t,n,r,o,i,s,a){const l=Fo(e,s);let c=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,r){const o=Math.max(0,r-e.x),i=Math.max(0,r-e.y);return(o+Math.max(0,e.x+e.width-(t-r)))*e.height+(i+Math.max(0,e.y+e.height-(n-r)))*e.width}(l,o,i,a);for(const e of n)c+=12*Bo(l,e);for(const e of r)c+=4*Bo(l,e);return c}function Ho(e){const{annotations:t,context:n,defaultOffset:r=To,notePadding:o=Eo,markPadding:i=Lo,edgePadding:s=No,preserveManualOffsets:a=!0,routeLongConnectors:l=!0,connectorThreshold:c=Do,density:u,progressiveDisclosure:h=!1,redundantCues:d=!1,responsive:f,mobile:y,cohesion:p,audience:g}=e,m=n.width||0,x=n.height||0,v="object"==typeof y?y:{},b=v.breakpoint??480,k=!!y&&b>=m,w=k&&!1!==v.preferShortText?t.map($o):t,A=k&&!u?{maxAnnotations:v.maxAnnotations??("callout-list"===v.strategy?1:2),minVisible:v.minVisible??1}:u,S=h||k&&(!1!==v.progressiveDisclosure||"callout-list"===v.strategy),M=k&&!f?v.responsive??{minWidth:b}:f,_=k&&!p?v.cohesion:p;if(0===w.length||0>=m||0>=x)return w.slice();const C=[],P=function(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}(n,i);let R=!1;const j=w.map((e,t)=>{if(!Wo(e))return e;const i=function(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const r=e.pointId??e.nodeId;if(null!=r&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===r);if(e)return{x:e.x,y:e.y}}const o=e.coordinates,i=n.scales?.geoProjection;if(Array.isArray(o)&&o.length>=2&&i){const e=o[0],t=o[1];if("number"==typeof e&&"number"==typeof t){const n=i([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?ro(e,t,n):{x:e.x,y:e.y}}(e,t,n);if(!i)return e;const u=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="number"==typeof e.wrap?e.wrap:120,n=[...zo("string"==typeof e.title?e.title:void 0,t),...zo("string"==typeof e.label?e.label:void 0,t)],r=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*r)+10),height:Math.max(18,16*n.length+6)}}(e);if(a&&("number"==typeof(h=e).dx||"number"==typeof h.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:30,dy:-30}}(e);return C.push(Fo(Oo(i.x,i.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),o)),e}var h;let d=null,f=1/0;for(const e of function(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}(r)){const t=Yo(Oo(i.x,i.y,e.dx,e.dy,u),e,C,P,m,x,o,s);f>t&&(d=e,f=t)}if(!d)return e;const y=Fo(Oo(i.x,i.y,d.dx,d.dy,u),o);C.push(y);const p=Math.hypot(d.dx,d.dy),g=l&&p>=c&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return R=!0,{...e,dx:d.dx,dy:d.dy,...g?{connector:g}:{}}}),T=R?j:w.slice();let E=T;if(d){let e=!1;const t=T.map(t=>{const n=function(e){return"text"!==e.type||"string"!=typeof e.color||8>Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)?e:{...e,_redundantConnector:!0}}(t);return n!==t&&(e=!0),n});E=e?t:T}{let e=!1;const t=E.map(t=>{if(!0!==t?.defensive)return t;const n=function(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const n="string"==typeof t.source?Io[t.source]??t.source:null,r="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!r)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const o=[n,r].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${o})`)?e:{...e,label:i?`${i} (${o})`:`(${o})`}}(t);return n!==t&&(e=!0),n});E=e?t:E}const L=new Set;if(A){const e="object"==typeof A?A:{},t=function(e){if(!e)return 1;const t=function(e){const t=e?.familiarity;if(!t)return 3;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?3:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(g),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??Ro(m,x,e))*t))},{deferred:r}=function(e){const{annotations:t,width:n,height:r}=e,o=Math.max(0,e.minVisible??1),i=Ro(n,r,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,Co(n))};var n}),a=s.filter(e=>e.note);if(0===a.length||i>=a.length)return{visible:t.slice(),deferred:[],budget:i};const l=a.filter(e=>Po(e.annotation)),c=a.filter(e=>!Po(e.annotation)).sort((e,t)=>jo(t.annotation)-jo(e.annotation)||e.index-t.index),u=Math.min(c.length,Math.max(Math.max(0,i-l.length),Math.max(0,o-l.length))),h=new Set([...l.map(e=>e.index),...c.slice(0,u).map(e=>e.index)]),d=[],f=[];for(const{annotation:e,index:t,note:n}of s)!n||h.has(t)?d.push(e):f.push(e);return{visible:d,deferred:f,budget:i}}({annotations:E,width:m,height:x,...n});for(const e of r)L.add(e)}if(M&&("object"==typeof M&&"number"==typeof M.minWidth?M.minWidth:480)>=m)for(const e of E)Wo(e)&&"secondary"===e.emphasis&&L.add(e);if(L.size>0)for(const e of E)!0===e?.defensive&&L.delete(e);let N;return N=0===L.size?E:S?E.map(e=>L.has(e)?{...e,_annotationDeferred:!0}:e):E.filter(e=>!L.has(e)),_?function(e,t){let n=!1;const r=e.map(e=>Wo(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?r:e}(N,_):N}var Xo=require("react"),qo={positions:new Map},Go=new Set;function Vo(){for(const e of Go)e()}function Uo(e,t){const n=qo.positions.get(e);if(n?.locked)return;if(!n||n.sourceId!==t)return;const r=new Map(qo.positions);r.delete(e),qo={positions:r},Vo()}function Ko(e,t){const n=qo.positions.get(e);if(!n?.locked)return;if(t&&n.sourceId!==t)return;const r=new Map(qo.positions);r.delete(e),qo={positions:r},Vo()}function Qo(){return qo}function Zo(e){return Go.add(e),()=>Go.delete(e)}var Jo={positions:new Map};function ei(){return()=>{}}function ti(){return Jo}function ni(e,t,n){return"exact"===n?function(e,t){const n=e.domain(),r=n[0],o=n[n.length-1],i=r instanceof Date,s=r instanceof Date?r.getTime():r,a=o instanceof Date?o.getTime():o;if(2>t||s===a)return i?[new Date(s),new Date(a)]:[s,a];const l=(a-s)/(t-1),c=Array(t);for(let e=0;t>e;e++){const n=e===t-1?a:s+e*l;c[e]=i?new Date(n):n}return c}(e,t):e.ticks(t)}function ri(e,t,n){if("edges"===e){if(t)return"start";if(n)return"end"}return"middle"}function oi(e,t,n){if("edges"===e){if(t)return"hanging";if(n)return"auto"}return"middle"}function ii(e){if(0===e.length)return{min:null,max:null};let t=1/0,n=-1/0;for(const r of e)t>r.pixel&&(t=r.pixel),r.pixel>n&&(n=r.pixel);return{min:t,max:n}}function si(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function ai(e,t,n){if("left"===e||"right"===e){const r="left"===e?n:0,o="left"===e?-1:1,i=Math.ceil(t/8);let s="M0,"+r;for(let e=0;i>e;e++){const n=8*(e+1);s+=`L${Math.min(8*e+4,t)},${r+4*o}`,s+=`L${Math.min(n,t)},${r}`}return s}const r="bottom"===e?0:t,o="bottom"===e?1:-1,i=Math.ceil(n/8);let s=`M${r},0`;for(let e=0;i>e;e++){const t=8*(e+1);s+=`L${r+4*o},${Math.min(8*e+4,n)}`,s+=`L${r},${Math.min(t,n)}`}return s}var li=require("react/jsx-runtime");function ci(e){const{width:t,height:n,totalWidth:r,totalHeight:o,margin:i,scales:s,showAxes:a,axes:l,showGrid:c,xFormat:u,yFormat:h,axisExtent:d}=e,f=(0,kr.useMemo)(()=>{if(!s)return[];const e=l?.find(e=>"bottom"===e.orient),n=e?.tickFormat||u||ui,r=Math.max(2,Math.floor(t/70)),o=e?.ticks??5,i="exact"===d?Math.max(2,o):Math.min(o,r),a=e?.tickValues??ni(s.x,i,d),c=a.map(e=>e.valueOf()),h=a.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,c)})),f=h.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 hi(h,Math.max(55,f+8))},[s,l,u,t,d]),y=(0,kr.useMemo)(()=>{if(!s)return[];const e=l?.find(e=>"left"===e.orient),t=e?.tickFormat||h||ui,r=Math.max(2,Math.floor(n/30)),o=e?.ticks??5,i="exact"===d?Math.max(2,o):Math.min(o,r);return hi((e?.tickValues??ni(s.y,i,d)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[s,l,h,n,d]),p=c&&s,g=a&&s;if(!p&&!g)return null;const m=l?.find(e=>"bottom"===e.orient),x=l?.find(e=>"left"===e.orient),v=g&&(!m||!1!==m.baseline),b=g&&(!x||!1!==x.baseline),k=m?.jaggedBase||!1,w=x?.jaggedBase||!1,A="var(--semiotic-border, #ccc)";return(0,li.jsx)("svg",{width:r,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:(0,li.jsxs)("g",{transform:`translate(${i.left},${i.top})`,children:[p&&(()=>{const e=si(l?.find(e=>"bottom"===e.orient)?.gridStyle),r=si(l?.find(e=>"left"===e.orient)?.gridStyle);return(0,li.jsxs)("g",{className:"stream-grid",children:[f.map((t,r)=>(0,li.jsx)("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+r)),y.map((e,n)=>(0,li.jsx)("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),v&&!k&&(0,li.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:A,strokeWidth:1}),k&&(0,li.jsx)("path",{d:ai("bottom",t,n),fill:"none",stroke:A,strokeWidth:1}),b&&!w&&(0,li.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:A,strokeWidth:1}),w&&(0,li.jsx)("path",{d:ai("left",t,n),fill:"none",stroke:A,strokeWidth:1})]})})}function ui(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function hi(e,t){if(2>=e.length)return e;const n=[e[0]];for(let r=1;e.length-1>r;r++)t>Math.abs(e[r].pixel-n[n.length-1].pixel)||n.push(e[r]);const r=e[e.length-1];return t>Math.abs(r.pixel-n[n.length-1].pixel)?n[n.length-1]=r:n.push(r),n}function di(e){const{width:t,height:n,totalWidth:r,totalHeight:o,margin:i,scales:s,showAxes:a,axes:l,xLabel:c,yLabel:u,yLabelRight:h,xFormat:d,yFormat:f,axisExtent:y,showGrid:p,title:g,legend:m,legendHoverBehavior:x,legendClickBehavior:v,legendHighlightedCategory:b,legendIsolatedCategories:k,legendPosition:w="right",legendLayout:A,foregroundGraphics:S,marginalGraphics:M,xValues:_,yValues:C,annotations:P,onAnnotationActivate:R,onObservation:j,chartId:T,chartType:E,autoPlaceAnnotations:L,svgAnnotationRules:N,xAccessor:D,yAccessor:I,annotationData:$,pointNodes:W,curve:z,underlayRendered:O,canvasObscuresUnderlay:F=!0,linkedCrosshairName:B,linkedCrosshairSourceId:Y,children:H}=e,X=go({onAnnotationActivate:R,onObservation:j,chartId:T,chartType:E}),q=(0,kr.useMemo)(()=>{if(!a||!s)return[];const e=l?.find(e=>"bottom"===e.orient),n=e?.tickFormat||d||ui,r=Math.max(2,Math.floor(t/70)),o=e?.ticks??5,i="exact"===y?Math.max(2,o):Math.min(o,r),c=e?.tickValues??ni(s.x,i,y),u=c.map(e=>e.valueOf()),h=c.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,u)})),f=h.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(f+8,55)):Math.max(55,f+8);let g=hi(h,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=s.x.domain()[1],t=s.x(e),r=g[g.length-1].pixel;if(Math.abs(t-r)>1){const o=n(e,g.length,u);p>t-r&&g.length>1&&(g=g.slice(0,-1)),g.push({value:e,pixel:t,label:o})}}return g},[a,s,l,d,t,y]),G=(0,kr.useMemo)(()=>{if(!a||!s)return[];const e=l?.find(e=>"left"===e.orient),t=e?.tickFormat||f||ui,r=Math.max(2,Math.floor(n/30)),o=e?.ticks??5,i="exact"===y?Math.max(2,o):Math.min(o,r);let c=hi((e?.tickValues??ni(s.y,i,y)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22);if(c.length>1&&(c=c.filter((e,t)=>0===t||e.label+""!=c[t-1].label+"")),e?.includeMax&&c.length>0&&"exact"!==y&&!e?.tickValues){const e=s.y.domain()[1],n=s.y(e),r=c[c.length-1].pixel;if(Math.abs(n-r)>1){const o=t(e);22>Math.abs(n-r)&&c.length>1&&(c=c.slice(0,-1)),c.push({value:e,pixel:n,label:o})}}return c},[a,s,l,f,n,y]),V=(0,kr.useMemo)(()=>{if(!a||!s)return[];const e=l?.find(e=>"right"===e.orient);if(!e)return[];const t=e.tickFormat||f||ui,r=Math.max(2,Math.floor(n/30)),o=e.ticks??5;return hi((e.tickValues??ni(s.y,"exact"===y?Math.max(2,o):Math.min(o,r),y)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[a,s,l,f,n,y]),U=(0,kr.useRef)(new Map),K=(0,kr.useRef)(P?.length??0),Q=P?.length??0;K.current!==Q&&(K.current=Q,U.current=new Map);const Z=(0,kr.useMemo)(()=>{if(!P||0===P.length)return null;const e=Mo(0,X),r={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:D,yAccessor:I,width:t,height:n,data:$,frameType:"xy",pointNodes:W,curve:z,stickyPositionCache:U.current};return So(L?Ho({annotations:P,context:r,..."object"==typeof L?L:{}}):P,e,N,r)},[P,L,N,t,n,D,I,$,s,W,z,X]),J=function(e){const t=(0,Xo.useSyncExternalStore)(e?Zo:ei,e?Qo:ti,e?Qo:ti);return e?t.positions.get(e)??null:null}(B);return(0,kr.useEffect)(()=>{if(!J?.locked||!B)return;const e=e=>{"Escape"===e.key&&Ko(B)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[J?.locked,B]),a||g||m||S||M||Z&&Z.length>0||p||H||J?(0,li.jsxs)("svg",{role:"img",width:r,height:o,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[(0,li.jsx)("title",{children:"string"==typeof g?g:"XY Chart"}),(0,li.jsx)("desc",{children:"string"==typeof g?g+" (XY data visualization)":"XY data visualization"}),(0,li.jsxs)("g",{transform:`translate(${i.left},${i.top})`,children:[p&&s&&(!O||F)&&(()=>{const e=si(l?.find(e=>"bottom"===e.orient)?.gridStyle),r=si(l?.find(e=>"left"===e.orient)?.gridStyle);return(0,li.jsxs)("g",{className:"stream-grid",children:[q.map((t,r)=>(0,li.jsx)("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+r)),G.map((e,n)=>(0,li.jsx)("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),a&&s&&(()=>{const e=l?.find(e=>"left"===e.orient),r=l?.find(e=>"bottom"===e.orient),o=!e||!1!==e.baseline,s=!r||!1!==r.baseline,a=e?.jaggedBase||!1,d=r?.jaggedBase||!1,f=r?.landmarkTicks,y=e?.landmarkTicks,p="var(--semiotic-border, #ccc)",g="var(--semiotic-text-secondary, var(--semiotic-text, #666))",m="var(--semiotic-text, #333)",x=!!r?.autoRotate&&q.length>1&&(()=>{const e=t/Math.max(q.length-1,1);return q.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})(),v=x?12:18,b=n+(x?58:40),k={fontSize:"var(--semiotic-tick-font-size, 12px)"},w={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},A={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},S=r?.tickAnchor,M=e?.tickAnchor,_=ii(q),C=ii(G);return(0,li.jsxs)("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[(0,li.jsxs)("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!O||F)&&s&&!d&&(0,li.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:p,strokeWidth:1}),(!O||F)&&d&&(0,li.jsx)("path",{d:ai("bottom",t,n),fill:"none",stroke:p,strokeWidth:1}),q.map((e,t)=>{const r=!!f&&("function"==typeof f?f(e.value,t):wn(e.value,t>0?q[t-1].value:void 0));return(0,li.jsxs)("g",{transform:`translate(${e.pixel},${n})`,children:[(0,li.jsx)("line",{y2:5,stroke:p,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,li.jsx)("text",{y:v,textAnchor:x?"end":ri(S,e.pixel===_.min,e.pixel===_.max),fontWeight:r?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...r?w:k},transform:x?"rotate(-45)":void 0,children:e.label}):(0,li.jsx)("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:(0,li.jsx)("div",{style:{textAlign:"center",userSelect:"none",...k},children:e.label})})]},"xtick-"+t)}),c&&(0,li.jsx)("text",{x:t/2,y:b,textAnchor:"middle",fill:m,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:c})]}),(0,li.jsxs)("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!O||F)&&o&&!a&&(0,li.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:p,strokeWidth:1}),(!O||F)&&a&&(0,li.jsx)("path",{d:ai("left",t,n),fill:"none",stroke:p,strokeWidth:1}),G.map((e,t)=>{const n=!!y&&("function"==typeof y?y(e.value,t):wn(e.value,t>0?G[t-1].value:void 0));return(0,li.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,li.jsx)("line",{x2:-5,stroke:p,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,li.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:oi(M,e.pixel===C.min,e.pixel===C.max),fontWeight:n?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...n?w:k},children:e.label}):(0,li.jsx)("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:(0,li.jsx)("div",{style:{textAlign:"right",userSelect:"none",...k},children:e.label})})]},"ytick-"+t)}),(()=>{const t=e?.label||u;return t?(0,li.jsx)("text",{x:15-i.left,y:n/2,textAnchor:"middle",fill:m,transform:`rotate(-90, ${15-i.left}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:t}):null})()]}),(()=>{const e=l?.find(e=>"right"===e.orient);if(!e||0===V.length)return null;const r=!1!==e.baseline,o=e.landmarkTicks,s=e.label||h,a=e.tickAnchor,c=ii(V);return(0,li.jsxs)("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[r&&(0,li.jsx)("line",{x1:t,y1:0,x2:t,y2:n,stroke:p,strokeWidth:1}),V.map((e,n)=>{const r=!!o&&("function"==typeof o?o(e.value,n):wn(e.value,n>0?V[n-1].value:void 0));return(0,li.jsxs)("g",{transform:`translate(${t},${e.pixel})`,children:[(0,li.jsx)("line",{x2:5,stroke:p,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,li.jsx)("text",{x:8,textAnchor:"start",dominantBaseline:oi(a,e.pixel===c.min,e.pixel===c.max),fontWeight:r?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...r?w:k},children:e.label}):(0,li.jsx)("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:(0,li.jsx)("div",{style:{textAlign:"left",userSelect:"none",...k},children:e.label})})]},"ytick-r-"+n)}),s&&(0,li.jsx)("text",{x:t+i.right-15,y:n/2,textAnchor:"middle",fill:m,transform:`rotate(90, ${t+i.right-15}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:s})]})})()]})})(),Z,M&&s&&_&&C&&(0,li.jsxs)(li.Fragment,{children:[M.top&&(0,li.jsx)("g",{transform:"translate(0, 0)",children:(0,li.jsx)(zr,{orient:"top",config:Wr(M.top),values:_,scale:s.x,size:i.top,length:t})}),M.bottom&&(0,li.jsx)("g",{transform:`translate(0, ${n})`,children:(0,li.jsx)(zr,{orient:"bottom",config:Wr(M.bottom),values:_,scale:s.x,size:i.bottom,length:t})}),M.left&&(0,li.jsx)("g",{transform:"translate(0, 0)",children:(0,li.jsx)(zr,{orient:"left",config:Wr(M.left),values:C,scale:s.y,size:i.left,length:n})}),M.right&&(0,li.jsx)("g",{transform:`translate(${t}, 0)`,children:(0,li.jsx)(zr,{orient:"right",config:Wr(M.right),values:C,scale:s.y,size:i.right,length:n})})]}),S,J&&J.sourceId!==Y&&s?.x&&(()=>{const e=s.x(J.xValue);if(null==e||0>e||e>t)return null;const r=J.locked;return(0,li.jsx)("line",{x1:e,y1:0,x2:e,y2:n,stroke:r?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:r?1.5:1,strokeDasharray:r?"6,3":"4,4",pointerEvents:"none"})})(),H]}),g&&"string"==typeof g?(0,li.jsx)("text",{x:r/2,y:22,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:g}):g?(0,li.jsx)("foreignObject",{x:0,y:0,width:r,height:i.top,children:g}):null,Lr({legend:m,totalWidth:r,totalHeight:o,margin:i,legendPosition:w,title:g,legendLayout:A,legendHoverBehavior:x,legendClickBehavior:v,legendHighlightedCategory:b,legendIsolatedCategories:k})]}):null}var fi=p(require("react")),yi=require("d3-shape");function pi(e){return(e.tl??0)>0||(e.tr??0)>0||(e.br??0)>0||(e.bl??0)>0}var gi=require("react/jsx-runtime"),mi={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function xi(e,t="#4e79a7"){return Yn(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}function vi(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}function bi(e,t,n,r){const o=e.glyph;if(!o?.parts?.length||0>=e.size)return null;const i=_n(o,e.size);if(0>=i.scale)return null;const s=`translate(${t},${n})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${i.offsetX},${i.offsetY}) scale(${i.scale})`,a=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),l=jn(o,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),c=l?vi(r+"-clip"):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),h=t=>o.parts.map((n,r)=>{const o=t?"none"===n.fill?void 0:t:Cn(n.fill,a,e.accent),i=t?n.stroke&&"none"!==n.stroke?t:void 0:Cn(n.stroke??"none",a,e.accent);return o||i?(0,gi.jsx)("path",{d:n.d,fill:o??"none",stroke:i,strokeWidth:i?n.strokeWidth??1:void 0,strokeLinecap:n.strokeLinecap,strokeLinejoin:n.strokeLinejoin,opacity:n.opacity},r):null});return(0,gi.jsxs)("g",{transform:s,opacity:1===u?void 0:u,children:[l&&c&&(0,gi.jsx)("clipPath",{id:c,children:(0,gi.jsx)("rect",{x:l.x,y:l.y,width:l.width,height:l.height})}),l&&e.ghostColor?(0,gi.jsx)("g",{children:h(e.ghostColor)}):null,l&&c?(0,gi.jsx)("g",{clipPath:`url(#${c})`,children:h()}):h()]},r)}var ki=p(require("react")),wi=require("d3-shape"),Ai=require("react/jsx-runtime"),Si=require("react/jsx-runtime");function Mi(e){const t=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));return 2>t.length?null:t.map((e,t)=>(0,Si.jsx)("stop",{offset:e.offset,stopColor:e.color},t))}function _i(e,t,n){if(!e||2>t.length)return null;const r=Mi(e.colorStops);return r?(0,Si.jsx)("linearGradient",{id:n,gradientUnits:"userSpaceOnUse",x1:t[0][0],y1:0,x2:t[t.length-1][0],y2:0,children:r}):null}var Ci="undefined"==typeof window||"undefined"==typeof document,Pi=require("react"),Ri="undefined"!=typeof window?Pi.useLayoutEffect:Pi.useEffect;function ji(){const[e,t]=(0,Pi.useState)(!1);return Ri(()=>{t(!0)},[]),e}var Ti=()=>()=>{},Ei=()=>!1,Li=()=>!0;function Ni(){const e=(0,Pi.useSyncExternalStore)(Ti,Ei,Li);return(0,Pi.useRef)(e).current}var Di=require("react");function Ii(e){const t=(0,Di.useRef)(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return Wi(e,t);if(!zi(e)||!zi(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;const n=e[r],o=t[r];if(!Object.is(n,o))if(Array.isArray(n)&&Array.isArray(o)){if(!Wi(n,o))return!1}else{if(!zi(n)||!zi(o))return!1;if(!$i(n,o))return!1}}return!0}(t.current,e)||(t.current=e),t.current}function $i(e,t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;if(!Object.is(e[r],t[r]))return!1}return!0}function Wi(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 zi(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 Oi(e){const{background:t,hasBackgroundGraphics:n=!1,themeBackground:r=""}=e;return"transparent"===t||n?null:t||(r&&"transparent"!==r?r:"")||null}function Fi(e,t){const{background:n,hasBackgroundGraphics:r=!1,themeBackground:o="",x:i=0,y:s=0,width:a,height:l}=t,c=Oi({background:n,hasBackgroundGraphics:r,themeBackground:o});if(!c)return!1;const u=On(e,c);return!!u&&(e.fillStyle=u,e.fillRect(i,s,a,l),!0)}var Bi={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 Yi(e,t){const n=e.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const e=n[1],r=n[2],o=n[3];return`#${e}${e}${r}${r}${o}${o}${t}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${t}`;const r=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return r?`rgba(${r[1]}, ${(parseInt(t,16)/255).toFixed(3)})`:n}var Hi=p(require("react")),Xi=p(require("react")),qi=(require("react/jsx-runtime"),Xi.createContext(null));function Gi(){return Xi.useContext(qi)}var Vi=require("react/jsx-runtime"),Ui={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Ki({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Data point: "+n}return(0,Vi.jsx)("div",{"aria-live":"polite","aria-atomic":"true",style:Ui,children:t})}function Qi(e){const t={};if(null==e||"object"!=typeof e)return t;for(const[n,r]of Object.entries(e))n.startsWith("_")||null!=r&&""!==r&&("number"==typeof r?Number.isFinite(r)&&(t[n]=r):"string"==typeof r?t[n]=r:"boolean"==typeof r?t[n]=r+"":r instanceof Date&&(t[n]=r.toISOString().slice(0,10)));return t}function Zi(e){return e&&"object"==typeof e?e:{}}function Ji(e){return Zi(e.accessibility).tableFields??e.accessibleDatum??e.datum}var es=require("react/jsx-runtime");function ts(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e){if(null===t?.datum)continue;const e=t.type+"";n[e]=(n[e]||0)+1}if(0===Object.keys(n).length)return t+", empty";const r=[],o={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},i=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],s=Object.keys(n).sort((e,t)=>{const n=i.indexOf(e),r=i.indexOf(t);return(-1===n?999:n)-(-1===r?999:r)});for(const e of s)r.push(`${n[e]} ${o[e]||e}`);return`${t}, ${r.join(", ")}`}function ns(e,t,n){const r=[];return e>0&&r.push(e+" nodes"),t>0&&r.push(t+" edges"),0===r.length?n+", empty":`${n}, ${r.join(", ")}`}var rs=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},os="semiotic-accessible-data-table",is=os+" semiotic-accessible-data-table-hidden",ss=os+" semiotic-accessible-data-table-visible",as=ss+" semiotic-accessible-data-table-network",ls={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},cs={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},us={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},hs={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},ds={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},fs={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},ys={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},ps={marginTop:8,padding:"4px 10px",fontSize:12,cursor:"pointer",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",borderRadius:"var(--semiotic-border-radius, 4px)",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",fontFamily:"inherit"};function gs({scene:e,chartType:t,tableId:n,chartTitle:r}){const[o,i]=Hi.useState(!1),[s,a]=Hi.useState(5),l=Gi(),c=l?.visible??!1,u=o||c,h=Hi.useRef(null),d=r?"Data summary for "+r:n?`Data summary for ${t} ${n}`:"Data summary for "+t;Hi.useEffect(()=>{u||a(5)},[u]);const f=Hi.useCallback(e=>{e.target===e.currentTarget&&(o||c||i(!0))},[o,c]),y=Hi.useCallback(e=>{c||h.current?.contains(e.relatedTarget)||i(!1)},[c]);if(!e||0===e.length)return n?(0,es.jsx)("span",{id:n,tabIndex:-1,style:Ui}):null;if(!u)return(0,es.jsx)("div",{id:n,className:is,tabIndex:-1,onFocus:f,style:Ui,role:"region","aria-label":d,children:(0,es.jsxs)("button",{type:"button",onClick:()=>i(!0),children:["View data summary (",e.length," elements)"]})});const p=function(e){const t=[];if(!Array.isArray(e))return t;const n=e.some(e=>e&&("line"===e.type||"area"===e.type));for(const r of e)if(r&&"object"==typeof r&&null!==r.datum)try{switch(r.type){case"point":if(n)break;t.push({label:"Point",values:Qi(Ji(r))});break;case"line":case"area":{const e=Ji(r),n=Array.isArray(e)?e:[],o="line"===r.type?"Line point":"Area point";for(const e of n)t.push({label:o,values:Qi(e)});break}case"rect":{const e=Ji(r),n=null!=e&&"object"==typeof e?e:{},o=n.category??r.group??"",i=n.value??n.__aggregateValue??n.total,s=Qi(n);null==s.category&&""!==o&&(s.category=o+""),null==s.value&&null!=i&&(s.value="number"==typeof i||"string"==typeof i?i:i+""),t.push({label:"Bar",values:s});break}case"heatcell":{const e=Qi(Ji(r));null==e.value&&"number"==typeof r.value&&Number.isFinite(r.value)&&(e.value=r.value),t.push({label:"Cell",values:e});break}case"wedge":{const e=Ji(r),n=Qi(e);if(null==n.category){const t=Zi(e),r=t.category??t.label;null!=r&&(n.category=r+"")}t.push({label:"Wedge",values:n});break}case"circle":t.push({label:"Node",values:Qi(Ji(r))});break;case"arc":t.push({label:"Arc",values:Qi(Ji(r))});break;case"candlestick":t.push({label:"Candlestick",values:Qi(Ji(r))});break;case"geoarea":{const e=Zi(Ji(r)),n=Qi(e);if(null==n.name){const t=Zi(e.properties).name??e.name;null!=t&&(n.name=t+"")}t.push({label:"Region",values:n});break}}}catch{}return t}(e),g=function(e){if(!e||0===e.length)return[];const t=new Set;for(const n of e)if(n&&n.values)for(const e of Object.keys(n.values))t.add(e);const n=[];for(const r of t){const t=[],o=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[r];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&o.add(e+""))}if(t.length>0){let e=t[0],o=t[0],i=0;for(const n of t)e>n&&(e=n),n>o&&(o=n),i+=n;n.push({name:r,count:t.length,numeric:!0,min:e,max:o,mean:i/t.length})}else if(o.size>0){const e=Array.from(o);n.push({name:r,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(p),m=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${rs(e.min)} to ${rs(e.max)}, mean ${rs(e.mean)}.`);else{const t=e.uniqueValues,r=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${r}.`)}return n.join(" ")}(p.length,g),x=Math.min(s,p.length),v=p.slice(0,x),b=p.length-x,k=new Set;for(const e of v)for(const t of Object.keys(e.values))k.add(t);const w=Array.from(k);return(0,es.jsxs)("div",{ref:h,id:n,className:ss,tabIndex:-1,onBlur:y,style:ls,role:"region","aria-label":d,children:[(0,es.jsx)("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{c&&l&&l.setVisible(!1),i(!1)},"aria-label":"Close data summary",style:us,children:"×"}),(0,es.jsx)("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:cs,children:m}),(0,es.jsxs)("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+t,style:hs,children:[(0,es.jsx)("caption",{className:"semiotic-accessible-data-table-caption",style:ys,children:b>0?`First ${x} of ${p.length} data points`:`All ${p.length} data points`}),(0,es.jsx)("thead",{children:(0,es.jsxs)("tr",{children:[(0,es.jsx)("th",{style:ds,children:"type"}),w.map(e=>(0,es.jsx)("th",{style:ds,children:e},e))]})}),(0,es.jsx)("tbody",{children:v.map((e,t)=>(0,es.jsxs)("tr",{children:[(0,es.jsx)("td",{style:fs,children:e.label}),w.map(t=>{return(0,es.jsx)("td",{style:fs,children:(n=e.values[t],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":rs(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},t);var n})]},t))})]}),b>0&&(0,es.jsxs)("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>a(e=>e+25),style:ps,children:["Show ",Math.min(25,b)," more"," ",1===b?"row":"rows"," (",b," remaining)"]})]})}function ms({nodes:e,edges:t,chartType:n,tableId:r,chartTitle:o}){const[i,s]=Hi.useState(!1),[a,l]=Hi.useState(5),c=Gi(),u=c?.visible??!1,h=i||u,d=o?"Data summary for "+o:r?`Data summary for ${n} ${r}`:"Data summary for "+n,f=Hi.useRef(null);Hi.useEffect(()=>{h||l(5)},[h]);const y=Hi.useCallback(e=>{e.target===e.currentTarget&&(i||u||s(!0))},[i,u]),p=Hi.useCallback(e=>{u||f.current?.contains(e.relatedTarget)||s(!1)},[u]);if(!e||0===e.length)return r?(0,es.jsx)("span",{id:r,tabIndex:-1,style:Ui}):null;if(!h)return(0,es.jsx)("div",{id:r,className:is,tabIndex:-1,onFocus:y,style:Ui,role:"region","aria-label":d,children:(0,es.jsxs)("button",{type:"button",onClick:()=>s(!0),children:["View data summary (",e.length," nodes, ",t.length," edges)"]})});const g=Array.isArray(e)?e:[],m=Array.isArray(t)?t:[],x=new Map,v=new Map,b=new Map,k=new Map;for(const e of m){if(!e||"object"!=typeof e)continue;const t=e.datum??{source:e.source,target:e.target},n="object"==typeof t.source?t.source?.id:t.source,r="object"==typeof t.target?t.target?.id:t.target,o="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=n&&""!==n){const e=n+"";v.set(e,(v.get(e)??0)+1),k.set(e,(k.get(e)??0)+o)}if(null!=r&&""!==r){const e=r+"";x.set(e,(x.get(e)??0)+1),b.set(e,(b.get(e)??0)+o)}}const w=[];for(let e=0;g.length>e;e++){const t=g[e];if(!t||"object"!=typeof t)continue;const n=t.datum?.id??t.id,r=null!=n?n+"":"node-"+e,o=x.get(r)??0,i=v.get(r)??0,s=b.get(r)??0,a=k.get(r)??0;w.push({id:r,degree:o+i,inDeg:o,outDeg:i,wDegree:s+a,wInDeg:s,wOutDeg:a})}w.sort((e,t)=>t.degree-e.degree);let A=0,S=0;if(w.length>0){let e=0;for(const t of w)e+=t.degree,t.degree>S&&(S=t.degree);A=e/w.length}const M=m.some(e=>{const t=e?.datum??{source:e?.source,target:e?.target};return"number"==typeof t?.value&&Number.isFinite(t.value)}),_=[`${w.length} nodes, ${m.length} edges.`];w.length>0&&_.push(`Mean degree: ${rs(A)}, max degree: ${S}.`);const C=Math.min(a,w.length),P=w.slice(0,C),R=w.length-C;return(0,es.jsxs)("div",{ref:f,id:r,className:as,tabIndex:-1,onBlur:p,style:ls,role:"region","aria-label":d,children:[(0,es.jsx)("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{u&&c&&c.setVisible(!1),s(!1)},"aria-label":"Close data summary",style:us,children:"×"}),(0,es.jsx)("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:cs,children:_.join(" ")}),(0,es.jsxs)("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+n,style:hs,children:[(0,es.jsx)("caption",{className:"semiotic-accessible-data-table-caption",style:ys,children:R>0?`Top ${C} of ${w.length} nodes by degree`:`All ${w.length} nodes by degree`}),(0,es.jsx)("thead",{children:(0,es.jsxs)("tr",{children:[(0,es.jsx)("th",{style:ds,children:"id"}),(0,es.jsx)("th",{style:ds,children:"degree"}),(0,es.jsx)("th",{style:ds,children:"in"}),(0,es.jsx)("th",{style:ds,children:"out"}),M&&(0,es.jsx)("th",{style:ds,children:"w. degree"}),M&&(0,es.jsx)("th",{style:ds,children:"w. in"}),M&&(0,es.jsx)("th",{style:ds,children:"w. out"})]})}),(0,es.jsx)("tbody",{children:P.map((e,t)=>(0,es.jsxs)("tr",{children:[(0,es.jsx)("td",{style:fs,children:e.id}),(0,es.jsx)("td",{style:fs,children:e.degree}),(0,es.jsx)("td",{style:fs,children:e.inDeg}),(0,es.jsx)("td",{style:fs,children:e.outDeg}),M&&(0,es.jsx)("td",{style:fs,children:rs(e.wDegree)}),M&&(0,es.jsx)("td",{style:fs,children:rs(e.wInDeg)}),M&&(0,es.jsx)("td",{style:fs,children:rs(e.wOutDeg)})]},t))})]}),R>0&&(0,es.jsxs)("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>l(e=>e+25),style:ps,children:["Show ",Math.min(25,R)," more"," ",1===R?"node":"nodes"," (",R," remaining)"]})]})}function xs({summary:e}){return e?(0,es.jsx)("div",{role:"note",style:Ui,children:e}):null}function vs({tableId:e}){return(0,es.jsx)("a",{href:"#"+e,style:Ui,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,Ui)},children:"Skip to data table"})}var bs=require("react/jsx-runtime"),ks="var(--semiotic-focus, #005fcc)";function ws({active:e,hoverPoint:t,margin:n,size:r,shape:o="circle",width:i,height:s,pathData:a}){if(!e||!t)return null;const l=t.x+n.left,c=t.y+n.top;let u;if("geoarea"!==o&&"path"!==o||!a)if("rect"===o&&null!=i&&null!=s){const e=Math.max(i,4),t=Math.max(s,4);u=(0,bs.jsx)("rect",{x:l-e/2-3,y:c-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:ks,strokeWidth:2,strokeDasharray:"4,2"})}else u=(0,bs.jsx)("circle","wedge"===o?{cx:l,cy:c,r:12,fill:"none",stroke:ks,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:ks,strokeWidth:2,strokeDasharray:"4,2"});else u=(0,bs.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:(0,bs.jsx)("path",{d:a,fill:"none",stroke:ks,strokeWidth:2.5,strokeDasharray:"6,3"})});return(0,bs.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}var As=p(require("react"));function Ss(e,t){return"touch"===t?Math.max(e,24):e}function Ms(e){return Array.isArray(e)?e[0]:e}function _s(e,t,n,r){return{data:Ms(e),x:t,y:n,__semioticHoverData:!0,...r}}var Cs=["name","label","title"],Ps=["type","kind","category","group","class","status","role","shape"],Rs=["value","amount","total","count","weight","score"],js=new Set(["x","y","z","x0","x1","y0","y1","r","cx","cy","radius","layer","row","rowindex","col","column","depth","index","order","sankeywidth","coincidentpoints","sourcelinks","targetlinks","parent","children","fx","fy","vx","vy"]);function Ts(e,t){for(const n of t){const t=e.find(e=>e.lower===n);if(t)return t}}function Es(e,t={}){if(!e||"object"!=typeof e)return{entries:[]};const n=t.maxEntries??6,r=!1!==t.skipPositional,o=[];for(const[t,n]of Object.entries(e)){if(t.startsWith("_"))continue;if("data"===t)continue;if(r&&js.has(t.toLowerCase()))continue;if(null==n)continue;const e=typeof n;("string"===e||"number"===e||"boolean"===e||n instanceof Date)&&o.push({key:t,lower:t.toLowerCase(),value:n})}if(0===o.length)return{entries:[]};let i=o.findIndex(e=>Cs.includes(e.lower));const s=i>=0;0>i&&(i=o.findIndex(e=>"id"===e.lower)),0>i&&(i=o.findIndex(e=>"string"==typeof e.value));const a=0>i?void 0:o[i];let l=o.filter((e,t)=>t!==i);s&&(l=l.filter(e=>"id"!==e.lower));const c=Ts(l,Ps),u=Ts(l,Rs),h=new Set(Ps),d=new Set(Rs),f=[];c&&f.push({key:c.key,value:c.value}),u&&f.push({key:u.key,value:u.value});for(const e of l){if(f.length>=n)break;e!==c&&e!==u&&(h.has(e.lower)||d.has(e.lower)||f.push({key:e.key,value:e.value}))}return{titleKey:a?.key,title:a?.value,entries:f}}require("react/jsx-runtime");var Ls={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"},Ns=require("react/jsx-runtime");function Ds({x:e,y:t,containerWidth:n,containerHeight:r,margin:o,children:i,className:s="stream-frame-tooltip",zIndex:a=1}){const l=Number.isFinite(e)&&Number.isFinite(t),c=As.useRef(null),[u,h]=As.useState(null);As.useLayoutEffect(()=>{const e=c.current;if(!e)return;const t=()=>{const t=e.getBoundingClientRect();Number.isFinite(t.width)&&Number.isFinite(t.height)&&h(e=>e&&.5>Math.abs(e.width-t.width)&&.5>Math.abs(e.height-t.height)?e:{width:t.width,height:t.height})};if(t(),"undefined"==typeof ResizeObserver)return;const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[s,n,r,l]);let d;d=u?`translate(${u.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>r-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*r>t?"4px":"calc(-100% - 4px)"})`;const f=function(e){if(!As.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const n=e.props;if(!0===n["data-semiotic-tooltip-chrome"])return!0;if("true"===n["data-semiotic-tooltip-chrome"])return!0;const r=n.style;if(r&&"object"==typeof r){if(null!=r.background&&""!==r.background&&"transparent"!==r.background)return!0;if(null!=r.backgroundColor&&""!==r.backgroundColor&&"transparent"!==r.backgroundColor)return!0}return!1}(i),y=f?null:Ls;return l?(0,Ns.jsx)("div",{ref:c,className:f?s:(s+" semiotic-tooltip").trim(),style:{...y||{},position:"absolute",left:o.left+e,top:o.top+t,transform:d,pointerEvents:"none",zIndex:a,width:"max-content"},children:i}):null}var Is=p(require("react")),$s=require("react"),Ws=require("react");var zs=require("react"),Os=()=>"undefined"!=typeof performance?performance.now():Date.now();function Fs(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function Bs(e,t){const n=e();return Number.isFinite(n)?n:t}var Ys=class{constructor(e={}){this.randomSource=Math.random,this.subscribers=new Set,this.now=()=>this.advance(),this.random=()=>this.randomSource(),this.clock=e.clock??Os,this.lastWallTime=Bs(this.clock,0),this.logicalTime=this.lastWallTime,this.pausedValue=!0===e.paused,this.visibleValue=!1!==e.visible,this.setRandomSource(e.random,e.seed)}get isActive(){return!this.pausedValue&&this.visibleValue}get paused(){return this.pausedValue}get seed(){return this.seedValue}get visible(){return this.visibleValue}configure(e){this.setClock(e.clock),this.setRandomSource(e.random,e.seed)}setPaused(e){this.pausedValue!==e&&(this.advance(),this.pausedValue=e,this.emit())}setVisible(e){this.visibleValue!==e&&(this.advance(),this.visibleValue=e,this.emit())}snapshot(){return{now:this.now(),paused:this.pausedValue,seed:this.seedValue,visible:this.visibleValue}}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}advance(){const e=Bs(this.clock,this.lastWallTime),t=Math.max(0,e-this.lastWallTime);return this.lastWallTime=e,this.isActive&&(this.logicalTime+=t),this.logicalTime}emit(){for(const e of this.subscribers)e()}setClock(e){const t=e??Os;t!==this.clock&&(this.advance(),this.clock=t,this.lastWallTime=Bs(t,this.lastWallTime))}setRandomSource(e,t){const n=function(e){return"number"==typeof e&&Number.isFinite(e)?Math.trunc(e):void 0}(t);e===this.randomInput&&n===this.seedValue||(this.randomInput=e,this.seedValue=n,this.randomSource=e??(void 0===n?Math.random:Fs(n)))}},Hs="undefined"==typeof window?$s.useEffect:$s.useLayoutEffect,Xs={requestAnimationFrame:e=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(e),cancelAnimationFrame:e=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(e)};function qs(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function Gs(e){const t=function(){const[e,t]=(0,Ws.useState)(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return(0,Ws.useEffect)(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return t(e.matches),function(e,t){if("function"==typeof e.addEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);const n=e;return n.addListener(t),()=>n.removeListener(t)}(e,e=>t(e.matches))},[]),e}(),n=(0,$s.useRef)(t);n.current=t;const[r,o]=function(e,t,n){const r=(0,zs.useRef)(null),[o,i]=(0,zs.useState)(null);return(0,zs.useEffect)(()=>{if(!t&&!n)return;const e=r.current;if(!e)return;const o=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;i(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return o.observe(e),()=>o.disconnect()},[t,n]),[r,[t&&o?o.w:e[0],n&&o?o.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),i=!!e.title,s=!!e.legend&&"top"===e.legendPosition,a=(0,$s.useMemo)(()=>function(e,t,n=!1){const r=n?t?58:34:t?36:0;return r>e.top?{...e,top:r}:e}({...e.marginDefault,...e.userMargin},i,s),[e.marginDefault,e.userMargin,i,s]),l=o[0]-a.left-a.right,c=o[1]-a.top-a.bottom,u=qs(e.foregroundGraphics,o,a),h=qs(e.backgroundGraphics,o,a),d=G(e=>e.theme),{transition:f,introEnabled:y}=function(e,t){if(!1===e)return{transition:void 0,introEnabled:!1};const n="undefined"!=typeof window&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;return{transition:e?!0===e?{duration:300}:{duration:e.duration??300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(n||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),p="semiotic-table-"+Is.useId(),g=(0,$s.useRef)(null);if(!g.current){const t=!e.suspendWhenHidden||"undefined"==typeof document||!document.hidden;g.current=new Ys({clock:e.clock,random:e.random,seed:e.seed,paused:e.paused,visible:t})}const m=g.current;m.configure({clock:e.clock,random:e.random,seed:e.seed});const x=(0,$s.useRef)(null),v=(0,$s.useRef)(e.frameScheduler??Xs);v.current=e.frameScheduler??Xs;const b=(0,$s.useRef)(null),k=(0,$s.useRef)(!1),w=(0,$s.useRef)(()=>{}),A=(0,$s.useCallback)(()=>{if(null!==x.current||k.current)return;const e=v.current;let t=!1,n=!1;const r=e.requestAnimationFrame(()=>{t=!0;const e=!n;e&&(k.current=!0),x.current=null,b.current=null;try{w.current()}finally{e&&(k.current=!1)}});n=!0,t||(x.current=r,b.current=e)},[]),S=(0,$s.useCallback)(()=>{null!==x.current&&((b.current??v.current).cancelAnimationFrame(x.current),x.current=null,b.current=null)},[]);Hs(()=>{m.setPaused(!0===e.paused)},[m,e.paused]),(0,$s.useEffect)(()=>{if(!e.suspendWhenHidden||"undefined"==typeof document)return void m.setVisible(!0);const t=()=>m.setVisible(!document.hidden);return t(),document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[m,e.suspendWhenHidden]),(0,$s.useEffect)(()=>()=>{S()},[S]);const M=(0,$s.useRef)(()=>{}),_=(0,$s.useRef)(()=>{}),C=(0,$s.useRef)(null),P=(0,$s.useRef)(null),R=(0,$s.useRef)(null),j=(0,$s.useCallback)(()=>{const e=C.current;C.current=null,e&&M.current(e)},[]),T=(0,$s.useCallback)(e=>{if(C.current={clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType},null===P.current){const e=v.current;let t=!1;const n=e.requestAnimationFrame(()=>{t=!0,P.current=null,R.current=null,j()});t||(P.current=n,R.current=e)}},[j]),E=(0,$s.useCallback)(()=>{C.current=null,null!==P.current&&((R.current??v.current).cancelAnimationFrame(P.current),P.current=null,R.current=null),_.current()},[]);(0,$s.useEffect)(()=>()=>{C.current=null,null!==P.current&&((R.current??v.current).cancelAnimationFrame(P.current),P.current=null,R.current=null)},[]);const L=e.themeDirtyRef;return Hs(()=>{L&&(In++,L.current=!0,A())},[d,A,L]),{reducedMotion:t,reducedMotionRef:n,responsiveRef:r,size:o,margin:a,adjustedWidth:l,adjustedHeight:c,resolvedForeground:u,resolvedBackground:h,currentTheme:d,transition:f,introEnabled:y,tableId:p,frameRuntime:m,rafRef:x,renderFnRef:w,scheduleRender:A,cancelRender:S,hoverHandlerRef:M,hoverLeaveRef:_,onPointerMove:T,onPointerLeave:E}}var Vs=require("react"),Us=require("react/jsx-runtime");function Ks(e,t){return function(e){const{cancelRender:t,dirtyRef:n,frameRuntime:r,manageFrameRuntime:o,scheduleRender:i}=e,s=(0,Vs.useRef)(null),a=(0,Vs.useRef)(null),l=(0,Vs.useRef)(!1);return function(e){const{hydrated:t,wasHydratingFromSSR:n,storeRef:r,dirtyRef:o,renderFnRef:i,cancelRender:s,cleanup:a}=e;Ri(()=>{t&&n&&r.current?.cancelIntroAnimation?.(),o.current=!0,s?.(),i.current()},[t,n]);const l=(0,Pi.useRef)(a);l.current=a,(0,Pi.useEffect)(()=>()=>l.current?.(),[])}({hydrated:e.hydrated,wasHydratingFromSSR:e.wasHydratingFromSSR,storeRef:e.storeRef,dirtyRef:e.dirtyRef,renderFnRef:e.renderFnRef,cancelRender:e.cancelRender,cleanup:e.cleanup}),(0,Vs.useEffect)(()=>{if(!1!==o)return r.subscribe(()=>{r.isActive?(n.current=!0,i()):t()})},[t,n,r,o,i]),(0,Vs.useEffect)(()=>{!l.current&&(l.current=!0,e.skipInitialCanvasPaintInvalidation)||(e.dirtyRef.current=!0,e.scheduleRender())},e.canvasPaintDependencies),{canvasRef:s,interactionCanvasRef:a}}({...t,renderFnRef:e.renderFnRef,scheduleRender:e.scheduleRender,cancelRender:e.cancelRender,frameRuntime:e.frameRuntime})}function Qs({children:e,size:t,margin:n,overflowVisible:r=!1}){return e?(0,Us.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:t[0],height:t[1],pointerEvents:"none",overflow:r?"visible":void 0},children:(0,Us.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:e})}):null}function Zs(e,t,n,r){return"function"==typeof e?e({size:t,margin:n,scales:r}):e}function Js(e,t,n,r){const o=e.getContext("2d");if(!o)return null;const i=Math.round(t[0]*r),s=Math.round(t[1]*r),a=i/t[0],l=s/t[1],c=t[0]+"px",u=t[1]+"px";return e.style.width!==c&&(e.style.width=c),e.style.height!==u&&(e.style.height=u),e.width===i&&e.height===s||(e.width=i,e.height=s),o.setTransform(a,0,0,l,0,0),o.translate(n.left,n.top),o}function ea(){if("undefined"==typeof window)return 1;const e=window.devicePixelRatio||1,t=function(){if("undefined"==typeof window)return!1;const e="function"==typeof window.matchMedia&&window.matchMedia("(pointer: coarse)").matches,t=768>Math.min(window.innerWidth||1/0,window.innerHeight||1/0);return e||t}()?2:3;return Math.max(1,Math.min(e,t))}var ta=require("react");function na(e,t,n,r){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:r,fn:t}:{key:void 0,fn:null}}var ra=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],oa=3156e7;function ia(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")}`}:oa>t?e=>{const t=new Date(e);return`${ra[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*oa>t?e=>{const t=new Date(e);return`${ra[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}function sa(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:ut(n.size)});else if("glyph"===n.type){const e=Tn(n.glyph,n.size);t.push({pointId:n.pointId,x:n.x+e.centerDx,y:n.y+e.centerDy,r:e.radius})}return t}var aa=require("d3-shape");function la(e,t,n){let r=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(r=n.color):e>n.value&&(r=n.color);return r}function ca(e,t,n,r,o,i){if(2>t.length)return;const s=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],r=t[e][1]-t[e-1][1];s.push(s[e-1]+Math.sqrt(n*n+r*r))}const a=s[s.length-1];if(0===a)return;const l=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=r,e.lineCap=i;for(let n=0;t.length-1>n;n++){const r=(s[n]+s[n+1])/2;let i=o;l>r&&(i*=r/l),l>a-r&&(i*=(a-r)/l),e.globalAlpha=Math.max(0,i),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}var ua=(e,t,n,r)=>{const o=t.filter(e=>"line"===e.type);for(const t of o){if(2>t.path.length)continue;const n=t._introClipFraction;void 0!==n&&1>n&&(e.save(),e.beginPath(),e.rect(0,0,r.width*n,r.height),e.clip());const o=t.style.stroke||"#007bff",i=On(e,o)||o,s=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=s,e.lineCap=t.style.strokeLinecap||"butt",t.style._edgeFade){ca(e,t.path,i,s,t.style.opacity??1,t.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const c=Un(t.curve),u=a&&a.length>0&&l&&l.length===t.path.length,h=t._decayOpacities;if(h&&h.length===t.path.length&&!u){e.strokeStyle=i;const n=t.style.opacity??1;for(let r=0;t.path.length-1>r;r++)e.globalAlpha=.5*(h[r]+h[r+1])*n,e.beginPath(),e.moveTo(t.path[r][0],t.path[r][1]),e.lineTo(t.path[r+1][0],t.path[r+1][1]),e.stroke()}else if(u){let n=function(t,n,r){e.beginPath(),e.strokeStyle=t,e.moveTo(n,r),h=!0},r=function(){h&&(e.stroke(),h=!1)},o=null,s=null,c=null,u=null,h=!1;for(let h=0;t.path.length>h;h++){const[d,f]=t.path[h],y=l[h],p=la(y,a,i);if(null!==o&&null!==u&&null!==c){if(p===u)e.lineTo(d,f);else{const t=[];for(const e of a){const n=e.value;(c>n||n>y)&&(n>c||y>n)||c===n||y===n||t.push({t:(n-c)/(y-c)})}t.sort((e,t)=>e.t-t.t);for(const l of t){const t=o+(d-o)*l.t,u=s+(f-s)*l.t,h=la(c+(y-c)*Math.min(l.t+1e-4,1),a,i);e.lineTo(t,u),r(),n(h,t,u)}e.lineTo(d,f)}o=d,s=f,c=y,u=p}else n(p,d,f),o=d,s=f,c=y,u=p}r()}else{e.beginPath();const n=t.strokeGradient&&t.path.length>=2?Zn(e,t.strokeGradient,t.path[0][0],0,t.path[t.path.length-1][0],0):null;if(e.strokeStyle=n||i,c)(0,aa.line)().x(e=>e[0]).y(e=>e[1]).curve(c).context(e)(t.path);else{const[n,r]=t.path[0];e.moveTo(n,r);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=Kn(e,t.style.fill,t.style.fill),c&&!u)(0,aa.line)().x(e=>e[0]).y(e=>e[1]).curve(c).context(e)(t.path);else{const[n,r]=t.path[0];e.moveTo(n,r);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],r.height),e.lineTo(n,r.height),e.closePath(),e.fill()}void 0!==n&&1>n&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function ha(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function da(e,t,n=.3){ha(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 fa(e,t,n=.6){if(!ha(t))return;const r=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,o=t.cx??t.x??0,i=t.cy??t.y??0;e.beginPath(),e.arc(o,i,r,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 ya(e,t,n,r=.35){ha(t)&&(e.globalAlpha=t._pulseIntensity*r,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}var pa=require("d3-shape");function ga(e,t){const n=Un(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 r=(0,pa.area)().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),r(t.topPath)}}var ma=(e,t,n,r)=>{const o=t.filter(e=>"area"===e.type);for(const t of o){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 o=t._introClipFraction;void 0!==o&&1>o&&(e.save(),e.beginPath(),e.rect(0,0,r.width*o,r.height),e.clip());const i=Kn(e,t.style.fill,"#4e79a7"),s=t._decayOpacities;if(s&&s.length===t.topPath.length){const n=t.style.fillOpacity??.7;e.fillStyle=i;for(let r=0;t.topPath.length-1>r;r++)e.globalAlpha=.5*(s[r]+s[r+1])*n,e.beginPath(),e.moveTo(t.topPath[r][0],t.topPath[r][1]),e.lineTo(t.topPath[r+1][0],t.topPath[r+1][1]),e.lineTo(t.bottomPath[r+1][0],t.bottomPath[r+1][1]),e.lineTo(t.bottomPath[r][0],t.bottomPath[r][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=On(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*(s[n]+s[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(ga(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 r=-1/0;for(const e of t.bottomPath)e[1]>r&&(r=e[1]);const o=Qn(e,t.fillGradient,"string"==typeof i?i:"#4e79a7",0,n,0,r);e.fillStyle=o||i,e.globalAlpha=a}else e.globalAlpha=(t.style.fillOpacity??.7)*a,e.fillStyle=i;if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(ga(e,t),ya(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=a;const n=t.strokeGradient&&t.topPath.length>=2?Zn(e,t.strokeGradient,t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0):null;e.strokeStyle=n||On(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const r=Un(t.curve);if(e.beginPath(),r)(0,pa.line)().x(e=>e[0]).y(e=>e[1]).curve(r).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!==o&&1>o&&e.restore(),n&&e.restore(),e.globalAlpha=1}},xa=(e,t,n,r)=>{const o=t.filter(e=>"point"===e.type);if(0!==o.length){e.save();try{const t=e.globalAlpha;for(const n of o)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=Kn(e,n.style.fill,"#4e79a7"),e.fill(),n.style.stroke&&(e.strokeStyle=Kn(e,n.style.stroke,n.style.stroke),e.lineWidth=n.style.strokeWidth||1,e.stroke()),fa(e,n)}finally{e.restore()}}},va=new Map;function ba(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=va.get(t);return n||(n=new Path2D(ct(e.symbolType,e.size)),va.size>256&&va.clear(),va.set(t,n)),n}catch{return null}}var ka=(e,t)=>{const n=e.globalAlpha;for(const r of t){if("symbol"!==r.type)continue;const t=r;if(0>=t.size)continue;const o=ba(t);if(!o)continue;e.save(),e.translate(t.x,t.y),t.rotation&&e.rotate(t.rotation);const i=(t.style.opacity??1)*(t._decayOpacity??1);t.style.fill&&(e.globalAlpha=n*i*(t.style.fillOpacity??1),e.fillStyle=Kn(e,t.style.fill,"#4e79a7"),e.fill(o)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*i,e.strokeStyle=Kn(e,t.style.stroke,t.style.stroke),e.lineWidth=t.style.strokeWidth??1,e.stroke(o)),e.restore()}e.globalAlpha=n};function wa(e,t,n,r,o){if(0>=t.size)return;const i=t.glyph;if(!i||!i.parts?.length)return;const s=_n(i,t.size);if(0>=s.scale)return;const a=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=a)return;const l=t=>{const n=Kn(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,r),t.rotation&&e.rotate(t.rotation),e.translate(s.offsetX,s.offsetY),e.scale(s.scale,s.scale),e.globalAlpha=o*a*(t.style.fillOpacity??1);const u=jn(i,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&En(e,i,c,t.accent,t.ghostColor,l),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),En(e,i,c,t.accent,void 0,l),e.restore()}function Aa(e,t){const{x:n,y:r,w:o,h:i}=t,{tl:s,tr:a,br:l,bl:c}=function(e){const t=e.cornerRadii;if(!t)return{tl:0,tr:0,br:0,bl:0};const n=Math.min(e.w,e.h)/2,r=e=>Math.max(0,Math.min(e??0,n));return{tl:r(t.tl),tr:r(t.tr),br:r(t.br),bl:r(t.bl)}}(t);e.beginPath(),e.moveTo(n+s,r),e.lineTo(n+o-a,r),a>0&&e.arcTo(n+o,r,n+o,r+a,a),e.lineTo(n+o,r+i-l),l>0&&e.arcTo(n+o,r+i,n+o-l,r+i,l),e.lineTo(n+c,r+i),c>0&&e.arcTo(n,r+i,n,r+i-c,c),e.lineTo(n,r+s),s>0&&e.arcTo(n,r,n+s,r,s),e.closePath()}function Sa(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 Ma=(e,t,n,r)=>{const o=t.filter(e=>"rect"===e.type);for(const t of o){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)_a(e,t);else if(t.cornerRadii&&pi(t.cornerRadii)){const n=Kn(e,t.style.fill,On(e,"var(--semiotic-primary, #007bff)")),r=Sa(t),o=t.fillGradient&&"string"==typeof n?Qn(e,t.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;e.fillStyle=o||n,Aa(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=On(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else if(t.roundedTop&&t.roundedTop>0){const n=Kn(e,t.style.fill,On(e,"var(--semiotic-primary, #007bff)")),r=Sa(t),o=t.fillGradient&&"string"==typeof n?Qn(e,t.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;e.fillStyle=o||n;const i=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:s,y:a,w:l,h:c}=t;switch(t.roundedEdge){case"right":e.moveTo(s,a),e.lineTo(s+l-i,a),e.arcTo(s+l,a,s+l,a+i,i),e.lineTo(s+l,a+c-i),e.arcTo(s+l,a+c,s+l-i,a+c,i),e.lineTo(s,a+c);break;case"left":e.moveTo(s+l,a),e.lineTo(s+i,a),e.arcTo(s,a,s,a+i,i),e.lineTo(s,a+c-i),e.arcTo(s,a+c,s+i,a+c,i),e.lineTo(s+l,a+c);break;case"bottom":e.moveTo(s,a),e.lineTo(s+l,a),e.lineTo(s+l,a+c-i),e.arcTo(s+l,a+c,s+l-i,a+c,i),e.lineTo(s+i,a+c),e.arcTo(s,a+c,s,a+c-i,i);break;default:e.moveTo(s,a+c),e.lineTo(s,a+i),e.arcTo(s,a,s+i,a,i),e.lineTo(s+l-i,a),e.arcTo(s+l,a,s+l,a+i,i),e.lineTo(s+l,a+c)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=On(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else{const n=Kn(e,t.style.fill,On(e,"var(--semiotic-primary, #007bff)")),r=Sa(t),o=t.fillGradient&&"string"==typeof n?Qn(e,t.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;e.fillStyle=o||n,e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=On(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))}da(e,t),e.globalAlpha=1}};function _a(e,t){const n=t.style.icon,r=t.style.iconPadding||2,o=Math.min(t.w,t.h)-r;if(0>=o)return;const i=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),i){const i=o+r,s=t.x+(t.w-o)/2;for(let r=t.y+t.h-o;r>=t.y-o;r-=i)e.drawImage(n,s,r,o,o)}else{const i=o+r,s=t.y+(t.h-o)/2;for(let r=t.x;t.x+t.w>r;r+=i)e.drawImage(n,r,s,o,o)}e.restore()}function Ca(e){const[t,n,r]=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*r>128?"#000":"#fff"}function Pa(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}var Ra=(e,t,n,r)=>{const o=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of o){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=On(e,"var(--semiotic-surface, #fff)"),e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),da(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):Pa(t.value),r=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),o=t.x+t.w/2,i=t.y+t.h/2;e.fillStyle=Ca(t.fill),e.font=r+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,o,i)}}}finally{e.restore()}},ja=(e,t,n,r)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const o=(t._decayOpacity??1)*(t.style?.opacity??1);1!==o&&(e.globalAlpha=o);const i=On(e,t.wickColor)||t.wickColor,s=60>r.height,a=s?Math.max(t.wickWidth,2):t.wickWidth,l=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=i,e.lineWidth=a,e.stroke()};if(s||l(),t.isRange){const n=Math.max(2,Math.min(t.bodyWidth/2,.12*r.height));e.fillStyle=i,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),r=Math.abs(t.openY-t.closeY),o=t.isUp?t.upColor:t.downColor,i=On(e,o)||o;e.fillStyle=i,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(r,1)),e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(r,1))}s&&l(),e.restore()}},Ta={line:[ma,ua,xa],area:[ma,xa],stackedarea:[ma,xa],scatter:[xa,ka],bubble:[xa,ka],heatmap:[Ra],bar:[Ma],swarm:[xa],waterfall:[(e,t,n,r)=>{Ma(e,t);const o=t.filter(e=>"rect"===e.type);if(2>o.length)return;const i=o[0].datum,s=i?._connectorStroke;if(s){e.save(),e.strokeStyle=On(e,s)||s,e.lineWidth=i?._connectorWidth??1,e.setLineDash([]);for(let t=0;o.length-1>t;t++){const r=o[t],i=o[t+1],s=r.datum,a=i.datum;if(null==s?.cumEnd||null==a?.baseline)continue;const l=n.y(s.cumEnd),c=r.x+r.w,u=i.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[ja],mixed:[ma,ua,xa],custom:[ma,Ma,Ra,ua,xa,ka,(e,t)=>{const n=e.globalAlpha;for(const r of t)"glyph"===r.type&&wa(e,r,r.x,r.y,n);e.globalAlpha=n},ja]},Ea=new Set;function La(e,t){const n="function"==typeof e?e(t.datum??null,t):e;return(r=n)&&"object"==typeof r&&"string"==typeof r.id&&"function"==typeof r.cacheKey&&"function"==typeof r.drawCanvas&&"function"==typeof r.renderStaticSVG?n:void 0;var r}function Na(e,t){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const n=`${e}:${t}`;Ea.has(n)||(Ea.add(n),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}function Da(e){const{context:t,nodes:n,renderMode:r,pixelRatio:o,paintBuiltIn:i}=e;if(!r||"sketchy"===r)return void i(n);let s=[];const a=()=>{s.length&&(i(s),s=[])};for(const e of n){const n=La(r,e);if(!n){s.push(e);continue}let l;a(),t.save();try{l=n.drawCanvas({context:t,node:e,style:e.style??{},pixelRatio:o})}finally{t.restore()}l||(Na(n.id,e.type??"unknown"),i([e]))}a()}function Ia(e){const{node:t,index:n,renderMode:r,fallback:o}=e,i=La(r,t);if(!i)return o();const s=i.renderStaticSVG({node:t,style:t.style??{},key:`${i.id}-${n}`});return null!=s?s:(Na(i.id,t.type??"unknown"),o())}require("react/jsx-runtime");var $a=require("react/jsx-runtime");function Wa(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function za({hover:e}){const t=e.data??{},n=t.y??t.value,r=t.x??t.time;if(void 0===n&&void 0===r){const e=Es(t);if(null!=e.title||e.entries.length>0)return(0,$a.jsxs)("div",{className:"semiotic-tooltip",style:Ls,children:[null!=e.title&&(0,$a.jsx)("div",{style:{fontWeight:600,marginBottom:e.entries.length?2:0},children:e.title+""}),e.entries.map(e=>(0,$a.jsxs)("div",{style:{opacity:.7,fontSize:11},children:[e.key,":"," ",(0,$a.jsx)("span",{style:{fontWeight:600},children:Wa(e.value)})]},e.key))]})}return(0,$a.jsxs)("div",{className:"semiotic-tooltip",style:Ls,children:[(0,$a.jsx)("div",{style:{fontWeight:600,marginBottom:2},children:Wa(n)}),(0,$a.jsx)("div",{style:{opacity:.7,fontSize:11},children:Wa(r)})]})}function Oa(e){return"touch"===e?"touch":"pointer"}function Fa(e){const t=e.target;return t instanceof Element&&t!==e.currentTarget&&null!=t.closest("button, a[href], input, select, textarea, summary, [contenteditable='true'], [role='button'], [role='link'], [role='checkbox'], [role='radio'], [role='switch']")}function Ba(e){const{onObservation:t,datum:n,x:r=0,y:o=0,chartType:i,chartId:s,context:a,timestamp:l=Date.now()}=e;t&&(n?(t({type:"hover",datum:n,x:r,y:o,timestamp:l,chartType:i,chartId:s}),"focus"===a?.type&&t({type:"focus",datum:n,inputType:"touch"===a.inputType?"pointer":a.inputType,timestamp:l,chartType:i,chartId:s})):t({type:"hover-end",timestamp:l,chartType:i,chartId:s}))}function Ya(e){const{onObservation:t,datum:n,x:r=0,y:o=0,chartType:i,chartId:s,context:a,timestamp:l=Date.now()}=e;t&&(n?(t({type:"click",datum:n,x:r,y:o,timestamp:l,chartType:i,chartId:s}),"activate"===a?.type&&t({type:"activate",datum:n,inputType:a.inputType,timestamp:l,chartType:i,chartId:s})):t({type:"click-end",timestamp:l,chartType:i,chartId:s}))}za.ownsChrome=!0;var Ha=require("react"),Xa=require("react");function qa(e){const t=new Map;for(const n of e){const e=n.group??"_default";let r=t.get(e);r||(r=[],t.set(e,r)),r.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 r=t.get(e),o=t.get(n);return(r.length>0?r[0].y:0)-(o.length>0?o[0].y:0)}),r=Array.from(t.values()).flat();r.sort((e,t)=>e.x-t.x||e.y-t.y);const o=new Map;for(let e=0;r.length>e;e++){r[e]._flatIndex=e;const t=r[e].datum?.id;null!=t&&o.set(t+"",e)}return{flat:r,groups:n,byGroup:t,idToIdx:o}}function Ga(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)),r=e.flat[n];return{flatIndex:n,group:r.group??"_default",indexInGroup:r._groupIndex??0}}function Va(e,t,n){const{group:r,indexInGroup:o}=t,i=n.byGroup.get(r);switch(e){case"ArrowRight":return i.length-1>o?i[o+1]._flatIndex:t.flatIndex;case"ArrowLeft":return o>0?i[o-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(r);return n.groups.length-1>e?Ua(n,n.groups[e+1],i[o]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(r);return e>0?Ua(n,n.groups[e-1],i[o]):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 Ua(e,t,n){const r=e.byGroup.get(t);let o=0,i=Math.abs(r[0].x-n.x);for(let e=1;r.length>e;e++){const t=Math.abs(r[e].x-n.x);i>t&&(i=t,o=e)}return r[o]._flatIndex}function Ka(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=Tn(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,r=Array.isArray(e.datum)?e.datum:[],o=e.group??"_default";for(let n=0;e.path.length>n&&r.length>n;n++)t.push({x:e.path[n][0],y:e.path[n][1],datum:r[n],shape:"circle",group:o});break}case"area":{const e=n,r=Array.isArray(e.datum)?e.datum:[],o=e.group??"_default";for(let n=0;e.topPath.length>n&&r.length>n;n++)t.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:r[n],shape:"circle",group:o});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 Qa(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}var Za=require("react/jsx-runtime"),Ja={top:20,right:20,bottom:30,left:40},el=Bi;function tl(e){if(e)return"x"===e.dimension?"pan-y":"y"===e.dimension?"pan-x":"none"}var nl=(0,_.memo)((0,_.forwardRef)(function(e,t){const{chartType:n,runtimeMode:r,data:o,chunkThreshold:i,chunkSize:s,xAccessor:a,yAccessor:l,accessorRevision:c,colorAccessor:u,sizeAccessor:h,symbolAccessor:d,symbolMap:f,groupAccessor:y,lineDataAccessor:p,curve:g,normalize:m,baseline:x,stackOrder:v,binSize:b,valueAccessor:k,arrowOfTime:w="right",windowMode:A="sliding",windowSize:S=200,timeAccessor:C,xExtent:P,yExtent:R,extentPadding:j=.1,scalePadding:E,sizeRange:D,size:I=[500,300],responsiveWidth:$,responsiveHeight:W,margin:O,className:F,background:B,renderMode:Y,lineStyle:H,pointStyle:X,areaStyle:q,barStyle:G,waterfallStyle:V,swarmStyle:U,barColors:K,colorScheme:Q,boundsAccessor:Z,boundsStyle:J,y0Accessor:ee,band:te,gradientFill:ne,lineGradient:re,areaGroups:oe,openAccessor:ie,highAccessor:se,lowAccessor:ae,closeAccessor:le,candlestickStyle:ce,showAxes:ue=!0,axes:he,xLabel:de,yLabel:fe,yLabelRight:ye,xFormat:pe,yFormat:ge,axisExtent:me,tickFormatTime:xe,tickFormatValue:ve,hoverAnnotation:be,tooltipContent:ke,customHoverBehavior:we,customClickBehavior:Ae,onObservation:Se,annotationObservationCallback:Me,chartId:_e,enableHover:Ce,hoverRadius:Pe=30,tooltipMode:Re,annotations:je,onAnnotationActivate:Te,autoPlaceAnnotations:Ee,svgAnnotationRules:Le,showGrid:Ne,legend:De,legendHoverBehavior:Ie,legendClickBehavior:$e,legendHighlightedCategory:We,legendIsolatedCategories:ze,legendPosition:Oe,legendLayout:Fe,legendCategoryAccessor:Be,onCategoriesChange:Ye,backgroundGraphics:He,foregroundGraphics:Xe,canvasPreRenderers:qe,svgPreRenderers:Ge,title:Ve,categoryAccessor:Ue,brush:Ke,onBrush:Qe,decay:Ze,pulse:Je,transition:et,animate:nt,staleness:rt,frameScheduler:ot,clock:it,random:st,seed:at,paused:lt=!1,suspendWhenHidden:ut=!0,heatmapAggregation:ht,heatmapXBins:dt,heatmapYBins:ft,showValues:yt,heatmapValueFormat:pt,marginalGraphics:gt,pointIdAccessor:mt,xScaleType:xt,yScaleType:vt,accessibleTable:bt=!0,description:kt,summary:wt,linkedCrosshairName:At,linkedCrosshairSourceId:St,customLayout:Mt,onLayoutError:_t,layoutConfig:Ct,layoutSelection:Pt}=e,{customHoverBehavior:Rt,customClickBehavior:jt,hasClickBehavior:Tt}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:r,chartType:o}){return{customHoverBehavior:(0,Ha.useCallback)((t,i)=>{e?.(t,i),Ba({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:o,chartId:r,context:i})},[r,o,e,n]),customClickBehavior:(0,Ha.useCallback)((e,i)=>{t?.(e,i),Ya({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:o,chartId:r,context:i})},[r,o,t,n]),hasClickBehavior:!(!t&&!n)}}({customHoverBehavior:we,customClickBehavior:Ae,onObservation:Se,chartId:_e,chartType:"StreamXYFrame"}),Et=(0,_.useId)().replace(/:/g,""),Lt=(0,_.useRef)(!1),Nt=(0,_.useRef)({w:-1,h:-1}),Dt=(0,_.useRef)(!1),It=Gs({sizeProp:I,responsiveWidth:$,responsiveHeight:W,userMargin:O,marginDefault:Ja,title:Ve,legend:De,legendPosition:Oe,animate:nt,transitionProp:et,frameScheduler:ot,clock:it,random:st,seed:at,paused:lt,suspendWhenHidden:ut,themeDirtyRef:Lt}),$t=ji(),Wt=Ni(),{reducedMotionRef:zt,responsiveRef:Ot,size:Ft,currentTheme:Bt,transition:Yt,introEnabled:Ht,tableId:Xt,rafRef:qt,renderFnRef:Gt,scheduleRender:Vt,frameRuntime:Ut}=It;let Kt=It.margin;if(gt){const e=60,t={...It.margin};gt.top&&e>t.top&&(t.top=e),gt.bottom&&e>t.bottom&&(t.bottom=e),gt.left&&e>t.left&&(t.left=e),gt.right&&e>t.right&&(t.right=e),Kt=t}const Qt=Ft[0]-Kt.left-Kt.right,Jt=Ft[1]-Kt.top-Kt.bottom,en=(0,_.useMemo)(()=>L(o),[o]),tn=be??Ce,[nn,rn]=(0,_.useState)(0),on=(0,_.useRef)(0),[sn,cn]=(0,_.useState)(null),hn=Zs(Xe,Ft,Kt,sn),dn=Zs(He,Ft,Kt,sn),fn=(0,_.useRef)(null),yn=(0,_.useRef)(null),gn=(0,_.useRef)(void 0),[vn,bn]=(0,_.useState)(null),kn=(0,_.useRef)(el.primary),wn=(0,_.useRef)(function(){let e=-1,t=Bi;return{resolve(n){if(!n)return Bi;const r=In;return r===e||(t=function(e){if(!e)return Bi;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),r=t.getPropertyValue("--semiotic-text-secondary").trim(),o=t.getPropertyValue("--semiotic-bg").trim(),i=t.getPropertyValue("--semiotic-primary").trim(),s=r||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),l=n||t.getPropertyValue("--surface-3").trim(),c=o||t.getPropertyValue("--surface-0").trim();return s||a||n||i?{axisStroke:l||Bi.axisStroke,tickText:s||Bi.tickText,crosshair:s?Yi(s,"66"):Bi.crosshair,hoverFill:c?Yi(c,"4D"):Bi.hoverFill,hoverStroke:s?Yi(s,"99"):Bi.hoverStroke,pointRing:c||Bi.pointRing,primary:i||Bi.primary,background:c||Bi.background}:Bi}(n),e=r),t},invalidate(){e=-1}}}()),An=(0,_.useRef)(!1),Sn=an("StreamXYFrame"),[Mn,_n]=(0,_.useState)(!1),[Cn,Pn]=(0,_.useState)([]),[Rn,jn]=(0,_.useState)([]),Tn="streaming"===r||["bar","swarm","waterfall"].includes(n),En=Ii((0,_.useMemo)(()=>({chartType:n,runtimeMode:Tn?"streaming":"bounded",windowSize:S,windowMode:A,arrowOfTime:Tn?w:"right",extentPadding:j,scalePadding:E,axisExtent:me,xAccessor:a,yAccessor:l,accessorRevision:c,timeAccessor:Tn?C:void 0,valueAccessor:k,colorAccessor:u,sizeAccessor:h,symbolAccessor:d,symbolMap:f,groupAccessor:y||(p?"_lineGroup":void 0),categoryAccessor:Ue,lineDataAccessor:p,xScaleType:xt,yScaleType:vt,xExtent:P,yExtent:R,sizeRange:D,binSize:b,normalize:m,baseline:x,stackOrder:v,boundsAccessor:Z,boundsStyle:J,y0Accessor:ee,band:te,gradientFill:!0===ne?{topOpacity:.8,bottomOpacity:.05}:!1===ne?void 0:ne,areaGroups:oe?new Set(oe):void 0,lineGradient:re,openAccessor:ie,highAccessor:se,lowAccessor:ae,closeAccessor:le,candlestickStyle:ce,lineStyle:H,pointStyle:X,areaStyle:q,swarmStyle:U,waterfallStyle:V,colorScheme:Q,barColors:K,barStyle:G,annotations:je,decay:Ze,pulse:Je,transition:Yt,introAnimation:Ht,staleness:rt,clock:Ut.now,heatmapAggregation:ht,heatmapXBins:dt,heatmapYBins:ft,showValues:yt,heatmapValueFormat:pt,pointIdAccessor:mt,curve:g,themeCategorical:Bt?.colors?.categorical,themeSemantic:z(Bt),themeSequential:Bt?.colors?.sequential,themeDiverging:Bt?.colors?.diverging,customLayout:Mt,onLayoutError:_t,layoutConfig:Ct,layoutMargin:Kt}),[n,Tn,S,A,w,j,E,me,a,l,c,C,k,u,h,d,f,y,p,Ue,xt,vt,P,R,D,b,m,x,v,Z,J,ee,te,ne,oe,re,ie,se,ae,le,ce,H,X,q,U,V,Q,K,G,je,Ze,Je,Yt,Ht,rt,Ut.now,ht,dt,ft,yt,pt,mt,g,Bt,Mt,_t,Ct,Kt])),Ln=(0,_.useRef)(null);Ln.current||(Ln.current=new Zt(En));const Nn=function(e,t,n,r){const o=(0,ta.useRef)({accessor:t,onChange:n,readData:r}),i=(0,ta.useRef)([]);return o.current={accessor:t,onChange:n,readData:r},(0,ta.useCallback)(()=>{const{accessor:t,onChange:n,readData:r}=o.current;if(!n||!t)return;const s=function(e,t){if(!t)return[];const n=new Set,r=[];for(const o of e){if(!o||"object"!=typeof o)continue;const e="function"==typeof t?t(o):o[t];if(null==e)continue;const i=e+"";n.has(i)||(n.add(i),r.push(i))}return r}(e.current?r(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})(s,i.current)||(i.current=s,n(s))},[e])}(Ln,Be,Ye,e=>e.getData());mn(Ln,En,Lt,Vt),xn(Ln,Pt,Lt,Vt);const Dn=(0,_.useRef)(null);Dn.current||(Dn.current=new N(e=>{const t=Ln.current;t&&t.ingest(e)&&(Lt.current=!0,Vt())},{chunkThreshold:i,chunkSize:s})),(0,_.useEffect)(()=>{Dn.current?.updateChunkOptions({chunkThreshold:i,chunkSize:s})},[i,s]);const $n=(0,_.useCallback)(e=>{Dn.current?.push(e)},[]),Wn=(0,_.useCallback)(e=>{Dn.current?.pushMany(e)},[]),zn=(0,_.useCallback)(()=>{Dn.current?.clear(),Ln.current?.clear(),Lt.current=!0,Vt()},[Vt]);(0,_.useImperativeHandle)(t,()=>({push:$n,pushMany:Wn,remove:e=>{Dn.current?.flush();const t=Ln.current?.remove(e)??[];return t.length>0&&(fn.current&&t.some(e=>e===fn.current?.data)&&(fn.current=null,bn(null)),Lt.current=!0,Vt()),t},update:(e,t)=>{Dn.current?.flush();const n=Ln.current?.update(e,t)??[];return n.length>0&&(Lt.current=!0,Vt()),n},clear:zn,getData:()=>(Dn.current?.flush(),Ln.current?.getData()??[]),getScales:()=>Ln.current?.scales??null,getExtents:()=>Ln.current?.getExtents()??null,getCustomLayout:()=>Ln.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Ln.current?.lastCustomLayoutFailure??null}),[$n,Wn,zn,Vt]),(0,_.useEffect)(()=>{if(o){if(p&&en.length>0&&"object"==typeof en[0]&&null!==en[0]){const e="string"==typeof p?p:"coordinates";if(Array.isArray(en[0][e])){const t=[];for(const n of en){const r=n[e];if(Array.isArray(r)){const e=n.label||n.id||n.key;if(null!=e)for(const n of r)t.push({...n,_lineGroup:e});else for(const e of r)t.push(e)}}return void Dn.current?.setBoundedData(t)}}Dn.current?.setBoundedData(en)}},[o,en,p]);const{canvasRef:On,interactionCanvasRef:Fn}=Ks(It,{storeRef:Ln,dirtyRef:Lt,hydrated:$t,wasHydratingFromSSR:Wt,cleanup:()=>Dn.current?.clear(),canvasPaintDependencies:[n,Qt,Jt,ue,B,He,H,Y,qe,Vt]}),{hoverHandlerRef:Bn,hoverLeaveRef:Hn,onPointerMove:Xn,onPointerLeave:Gn}=It;Bn.current=e=>{if(!tn)return;const t=On.current;if(!t)return;const r=t.getBoundingClientRect(),o=e.clientX-r.left-Kt.left,i=e.clientY-r.top-Kt.top;if(0>o||o>Qt||0>i||i>Jt)return void(fn.current&&(fn.current=null,yn.current=null,bn(null),Rt&&(Rt(null),Lt.current=!0),Vt()));const s=Ln.current;if(!s||0===s.scene.length)return;const l=Ss(Pe,e.pointerType),c=nr(s.scene,o,i,l,s.quadtree,s.maxPointRadius),u="multi"===Re,h=()=>{fn.current&&(fn.current=null,yn.current=null,bn(null),Rt&&Rt(null),Vt())};if(!c&&!u)return void h();const d=u||!c?o:c.x,f=u||!c?i:c.y,y=c?.datum?tt(c.datum,s.resolvedRibbons):{},p=s.scales?.x?.invert,g="function"==typeof p?p(d):void 0;let m=_s(y,d,f,null!=g?{xValue:g,xPx:d}:void 0);if(u&&s.scene.length>0&&s.scales){const e=function(e,t,n=30){const r=[];for(const o of e)if("line"===o.type){const e=o;if(2>e.path.length)continue;const i=rr(tr(e.path,e.curve),t,n);if(null===i)continue;const s=fr(e.path,t);r.push({node:o,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:e.path[s][0],y:i,group:e.group,color:e.style.stroke})}else if("area"===o.type){const e=o;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const i=tr(e.topPath,e.curve),s=tr(e.bottomPath,e.curve),a=rr(i,t,n);if(null===a)continue;const l=rr(s,t,n),c=fr(e.topPath,t);r.push({node:o,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 r}(s.scene,d,Math.max(l,Qt));if(e.length>0){const t=s.scales.y.invert,r=kn.current,o=p?p(d):d;if(c)m.xValue=o,m.xPx=d;else{const e={xValue:o};"string"==typeof a&&(e[a]=o),m=_s(e,d,f,{xValue:o,xPx:d})}m.allSeries=e.map(e=>{const o=t?t(e.y):e.y,i=null!=e.y0?t?t(e.y0):e.y0:void 0;return{group:e.group||"",value:"stackedarea"===n&&null!=i?o-i:o,valuePx:e.y,color:e.color||r,datum:tt(e.datum,s.resolvedRibbons)}})}}c||m.allSeries?.length?(fn.current=m,yn.current=c?.node??null,bn(m),Rt&&(Rt(m),Lt.current=!0),Vt()):h()},Hn.current=()=>{fn.current&&(fn.current=null,yn.current=null,bn(null),Rt&&(Rt(null),Lt.current=!0),Vt())};const Vn=(0,_.useRef)(()=>{});Vn.current=e=>{if(xo(e.target))return;if(!jt)return;const t=On.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-Kt.left,o=e.clientY-n.top-Kt.top;if(0>r||r>Qt||0>o||o>Jt)return void jt(null);const i=Ln.current;if(!i||0===i.scene.length)return void jt(null);const s=Ss(Pe,gn.current),a=nr(i.scene,r,o,s,i.quadtree,i.maxPointRadius);if(!a)return void jt(null);const l=a.datum||{},c=i.scales?.x?.invert,u="function"==typeof c?c(a.x):void 0;jt(_s(l,a.x,a.y,null!=u?{xValue:u,xPx:a.x}:void 0),{type:"activate",inputType:Oa(gn.current)})};const Kn=(0,_.useCallback)(e=>Vn.current(e),[]),{kbFocusIndexRef:Qn,focusedNavPointRef:Zn,onKeyDown:Jn}=(sr={storeRef:Ln,hoverRef:fn,hoveredNodeRef:yn,setHoverPoint:bn,customHoverBehavior:Rt,customClickBehavior:jt,scheduleRender:Vt},function({storeRef:e,hoverRef:t,hoveredNodeRef:n,setHoverPoint:r,customHoverBehavior:o,customClickBehavior:i,scheduleRender:s,extractPoints:a,toHover:l}){const c=(0,Xa.useRef)(-1),u=(0,Xa.useRef)(null),h=(0,Xa.useRef)(null),d=(0,Xa.useCallback)(d=>{if(Fa(d))return;const f=e.current;if(!f)return;const y=()=>{c.current=-1,u.current=null,t.current=null,n&&(n.current=null),r(null),o(null),s()};if(0===f.scene.length)return void(0>c.current||y());let p;if(h.current?.version===f.version)p=h.current.graph;else{const e=a(f.scene);if(0===e.length)return void(0>c.current||y());p=qa(e),h.current={version:f.version,graph:p}}let g=c.current;if(p.flat.length>g||(y(),g=-1),("Enter"===d.key||" "===d.key)&&g>=0)return d.preventDefault(),void i(l(p.flat[g],f),{type:"activate",inputType:"keyboard"});if(0>g){if("Escape"===d.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(d.key))return;d.preventDefault(),c.current=0;const e=p.flat[0];u.current=e;const n=l(e,f);return t.current=n,r(n),o(n,{type:"focus",inputType:"keyboard"}),void s()}const m=Va(d.key,Ga(p,g),p);if(null===m)return;if(d.preventDefault(),0>m)return void y();c.current=m;const x=p.flat[m];u.current=x;const v=l(x,f);t.current=v,r(v),o(v,{type:"focus",inputType:"keyboard"}),s()},[i,o,a,t,n,s,r,e,l]);return{kbFocusIndexRef:c,focusedNavPointRef:u,onKeyDown:d}}({...sr,extractPoints:Ka,toHover:(e,t)=>function(e){return{data:e.datum||{},x:e.x,y:e.y,__semioticHoverData:!0}}({...e,datum:tt(e.datum,t.resolvedRibbons)})})),er=(0,_.useCallback)(e=>{gn.current=e.pointerType,Qn.current=-1,Zn.current=null,Xn(e)},[Zn,Qn,Xn]),or=(0,_.useCallback)(e=>{gn.current="mouse",Qn.current=-1,Zn.current=null,Xn({clientX:e.clientX,clientY:e.clientY,pointerType:"mouse"})},[Zn,Qn,Xn]),ir=(0,_.useCallback)(e=>{gn.current=e.pointerType},[]);var sr;Gt.current=()=>{if(qt.current=null,!Ut.isActive)return;const e=On.current,t=Fn.current;if(!e||!t)return;const r=Ln.current;if(!r)return;const o=Ut.now(),i=r.advanceTransition(zt.current?o+1e6:o),s=!zt.current&&i,c=Nt.current.w!==Qt||Nt.current.h!==Jt,u=Lt.current||i||c,h=r.consumeStylePaintPending();let d=!1;const f=r.getLastUpdateResult(),y=Sn.current.beforeCompute(f,s);!u||s&&!c||(r.computeScene({width:Qt,height:Jt}),Nt.current={w:Qt,h:Jt},d=!0,Nn()),Sn.current.afterCompute(y,d,c);const p=function(e,t,n,r){const o=r.current,i=!0===e.lastCustomLayoutFailure?.preservedLastGoodScene,s=!i&&e.hasActivePulsesAt(t),a=!(n||i||!s&&!o)&&e.refreshPulse(t);return r.current=s,{changed:a,pending:s}}(r,o,d,Dt),g=ea(),m=wn.current.resolve(e);kn.current=m.primary;const x=mr(rt,r.lastIngestTime>0?o-r.lastIngestTime:0),v=rt&&x.isStale;if(u||h||p.changed){const t=Js(e,Ft,Kt,g);if(t){if(t.clearRect(-Kt.left,-Kt.top,Ft[0],Ft[1]),rt&&1>x.alpha&&(t.globalAlpha=x.alpha),Fi(t,{background:B,hasBackgroundGraphics:!!He,themeBackground:m.background,x:-Kt.left,y:-Kt.top,width:Ft[0],height:Ft[1]}),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,Qt,Jt),t.clip()),qe&&r.scales)for(const e of qe)t.save(),e(t,r.scene,r.scales,{width:Qt,height:Jt}),t.restore();const e=Mt?Ta.custom:Ta[n];Da({context:t,nodes:r.scene,renderMode:Y,pixelRatio:g,paintBuiltIn:n=>{if(e&&r.scales)for(const o of e)o(t,n,r.scales,{width:Qt,height:Jt})}}),t.restore(),rt&&1>x.alpha&&(t.globalAlpha=1)}}const b=!!(tn&&fn.current&&r.scales),k=!!(yn.current&&Array.isArray(be)&&be.some(e=>e&&"object"==typeof e&&"highlight"===e.type)),w=b||k;if(w||An.current){const e=Js(t,Ft,Kt,g);if(e&&(e.clearRect(-Kt.left,-Kt.top,Ft[0],Ft[1]),b&&fn.current&&function(e,t,n,r,o,i,s){if(!1===o.crosshair)return;const a=t.allSeries,l=a&&a.length>0,c=t.xPx??t.x;e.save();const u="object"==typeof o.crosshair?o.crosshair:{};if(e.strokeStyle=u.stroke||s.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,r),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=s.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||s.primary,e.fill(),e.stroke())}else{const n=o.pointColor||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const n="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||n||null:n||t.stroke||null}(i)||s.primary;e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=n,e.fill(),e.strokeStyle=s.pointRing,e.lineWidth=2,e.stroke()}}(e,fn.current,Qt,Jt,"object"==typeof tn?tn:{},yn.current,m),k&&yn.current&&Array.isArray(be))){const t=be.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,r,o){if(!n)return;const i="group"in n?n.group:void 0;if(void 0!==i)for(const n of t){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const t="function"==typeof r.style?n.datum?r.style(n.datum):{}:r.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||o.primary,e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=t.opacity??1,e.stroke(),e.restore()}}(e,r.scene,yn.current,t,m)}An.current=w}u&&e&&e.setAttribute("aria-label",ts(r.scene,n+" chart"));const A=Lt.current;if(Lt.current=A&&s&&!d,A&&r.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!sn||e(sn.x.domain()[0])!==e(r.scales.x.domain()[0])||e(sn.x.domain()[1])!==e(r.scales.x.domain()[1])||e(sn.y.domain()[0])!==e(r.scales.y.domain()[0])||e(sn.y.domain()[1])!==e(r.scales.y.domain()[1])||sn.x.range()[0]!==r.scales.x.range()[0]||sn.x.range()[1]!==r.scales.x.range()[1]||sn.y.range()[0]!==r.scales.y.range()[0]||sn.y.range()[1]!==r.scales.y.range()[1])&&cn(r.scales),gt){const e=r.getData(),t="function"==typeof a?a:e=>e[a||"x"],n="function"==typeof l?l:e=>e[l||"y"];Pn(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),jn(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}!((je&&je.length>0||Mt)&&(d||s))||!d&&33>o-on.current||(rn(e=>e+1),on.current=o),rt?.showBadge&&_n(!!v),(s||null!=r.activeTransition||p.pending)&&Vt()},xr(rt,Ln,Lt,Vt,Mn,_n);const ar=(0,_.useMemo)(()=>{if(pe||xe)return;const e=Ln.current;return e?.xIsDate&&sn?ia(sn.x.domain()):void 0},[pe,xe,sn]),lr=pe||xe||ar,cr=tn&&vn?ke?ke(vn):(0,Za.jsx)(za,{hover:vn}):null,ur=cr?(0,Za.jsx)(Ds,{x:vn.x,y:vn.y,containerWidth:Qt,containerHeight:Jt,margin:Kt,className:"stream-frame-tooltip",children:cr}):null,hr=Zn.current,dr=(0,Za.jsx)(ws,{active:Qn.current>=0,hoverPoint:vn,margin:Kt,size:Ft,shape:hr?.shape,width:hr?.w,height:hr?.h}),yr=na(a,C,"__semiotic_resolvedX","__semiotic_resolvedTime"),pr=na(l,k,"__semiotic_resolvedY","__semiotic_resolvedValue"),gr=yr.key,vr=pr.key,kr=function(e,t,n){return r=>{if(!r||!n||!e.fn&&!t.fn)return r;let o=!1;const i=r.map(n=>{const r=e.fn&&e.key&&!(e.key in n),i=t.fn&&t.key&&!(t.key in n);if(!r&&!i)return n;o=!0;const s={...n};return r&&(s[e.key]=e.fn(n)),i&&(s[t.key]=t.fn(n)),s});return o?i:r}}(yr,pr,je&&je.length>0||!1);if(Ci||!$t&&Wt){const e=Ln.current;e&&o&&(e.ingest({inserts:en,bounded:!0}),e.computeScene({width:Qt,height:Jt}));const t=e?.scene??[],n=e?.scales??null,r=Zs(Xe,Ft,Kt,n),i=Zs(He,Ft,Kt,n),s=lr||(()=>{if(e?.xIsDate&&n)return ia(n.x.domain())})();return(0,Za.jsxs)("div",{ref:Ot,className:"stream-xy-frame"+(F?" "+F:""),role:"img","aria-label":kt||("string"==typeof Ve?Ve:"XY chart"),style:{position:"relative",width:$?"100%":Ft[0],height:W?"100%":Ft[1]},children:[(0,Za.jsx)(xs,{summary:wt}),(0,Za.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:Ft[0],height:Ft[1],style:{position:"absolute",left:0,top:0},children:[(0,Za.jsx)("g",{transform:`translate(${Kt.left},${Kt.top})`,children:i}),(0,Za.jsxs)("g",{transform:`translate(${Kt.left},${Kt.top})`,children:[B&&(0,Za.jsx)("rect",{x:0,y:0,width:Qt,height:Jt,fill:B}),Ge&&n&&Ge.map((e,r)=>(0,Za.jsx)(M.Fragment,{children:e(t,n,{width:Qt,height:Jt})},"svgpre-"+r)),t.map((e,t)=>Ia({node:e,index:t,renderMode:Y,fallback:()=>function(e,t,n){switch(e.type){case"line":{const r=e;if(0===r.path.length)return null;const o=Un(r.curve),i=o?(0,yi.line)().x(([e])=>e).y(([,e])=>e).curve(o)(r.path)??"":"M"+r.path.map(([e,t])=>`${e},${t}`).join("L"),s=vi(`${n?n+"-":""}line-${t}-stroke-gradient`),a=_i(r.strokeGradient,r.path,s);return(0,Si.jsxs)(fi.Fragment,{children:[a&&(0,Si.jsx)("defs",{children:a}),(0,Si.jsx)("path",{d:i,fill:"none",stroke:a?`url(#${s})`:r.style.stroke||"#4e79a7",strokeWidth:r.style.strokeWidth||2,strokeDasharray:r.style.strokeDasharray,opacity:r.style.opacity})]},"line-"+t)}case"area":{const r=e;if(0===r.topPath.length)return null;const o=Un(r.curve),i=!o||2>r.topPath.length||2>r.bottomPath.length?`M${r.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...r.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`:(0,yi.area)().x(([e])=>e).y0((e,t)=>r.bottomPath[t][1]).y1(([,e])=>e).curve(o)(r.topPath)??"",s=`${n?n+"-":""}area-${t}-hatch`,a=Yn(r.style.fill)?qn(r.style.fill,s):void 0,l=vi(`${n?n+"-":""}area-${t}-gradient`),c=function(e,t){const n=e.fillGradient;if(!n||"object"!=typeof n)return null;let r=1/0;for(const[,t]of e.topPath)r=Math.min(r,t);let o=-1/0;for(const[,t]of e.bottomPath)o=Math.max(o,t);if(!Number.isFinite(r)||!Number.isFinite(o))return null;const i=[];if("colorStops"in n){const e=Mi(n.colorStops);if(!e)return null;i.push(...e)}else{if(!Number.isFinite(n.topOpacity)||!Number.isFinite(n.bottomOpacity))return null;i.push((0,Si.jsx)("stop",{offset:0,stopColor:xi(e.style.fill),stopOpacity:Math.max(0,Math.min(1,n.topOpacity))},"0")),i.push((0,Si.jsx)("stop",{offset:1,stopColor:xi(e.style.fill),stopOpacity:Math.max(0,Math.min(1,n.bottomOpacity))},"1"))}return(0,Si.jsx)("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:0,y1:r,x2:0,y2:o,children:i})}(r,l),u=c?`url(#${l})`:a?`url(#${s})`:xi(r.style.fill),h=c?void 0:r.style.fillOpacity??r.style.opacity??.7,d=o?(0,yi.line)().x(([e])=>e).y(([,e])=>e).curve(o)(r.topPath)??"":"M"+r.topPath.map(([e,t])=>`${e},${t}`).join("L"),f=vi(`${n?n+"-":""}area-${t}-stroke-gradient`),y=_i(r.strokeGradient,r.topPath,f),p=r.style.stroke&&"none"!==r.style.stroke?(0,Si.jsx)("path",{d:d,fill:"none",stroke:y?`url(#${f})`:xi(r.style.stroke),strokeWidth:r.style.strokeWidth||2,opacity:r.style.opacity}):null;if(r.clipRect){const e=`${n?n+"-":""}area-clip-${t}`;return(0,Si.jsxs)("g",{children:[(0,Si.jsxs)("defs",{children:[c,!c&&a,y,(0,Si.jsx)("clipPath",{id:e,children:(0,Si.jsx)("rect",{x:r.clipRect.x,y:r.clipRect.y,width:r.clipRect.width,height:r.clipRect.height})})]}),(0,Si.jsxs)("g",{clipPath:`url(#${e})`,children:[(0,Si.jsx)("path",{d:i,fill:u,fillOpacity:h,opacity:c?r.style.opacity:void 0,stroke:"none"}),p]})]},"area-"+t)}return(0,Si.jsxs)(fi.Fragment,{children:[(c||a||y)&&(0,Si.jsxs)("defs",{children:[c,!c&&a,y]}),(0,Si.jsx)("path",{d:i,fill:u,fillOpacity:h,opacity:c?r.style.opacity:void 0,stroke:"none"}),p]},"area-"+t)}case"point":{const r=e,o=`${n?n+"-":""}point-${t}-hatch`,i=Yn(r.style.fill)?qn(r.style.fill,o):void 0;return(0,Si.jsxs)(fi.Fragment,{children:[i&&(0,Si.jsx)("defs",{children:i}),(0,Si.jsx)("circle",{cx:r.x,cy:r.y,r:r.r,fill:i?`url(#${o})`:xi(r.style.fill),opacity:r.style.opacity??r.style.fillOpacity??.8,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},"point-"+t)}case"symbol":return function(e,t){const n=ct(e.symbolType,e.size,e.path);return(0,Si.jsx)("path",{d:n,transform:e.rotation?`translate(${e.x},${e.y}) rotate(${180*e.rotation/Math.PI})`:`translate(${e.x},${e.y})`,fill:e.style.fill?xi(e.style.fill):"none",fillOpacity:e.style.fillOpacity,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"symbol-"+t)}(e,t);case"glyph":return bi(e,e.x,e.y,`${n??""}glyph-${e.pointId??t}`);case"rect":{const r=e,o=`${n?n+"-":""}xyrect-${t}-hatch`,i=Yn(r.style.fill)?qn(r.style.fill,o):void 0;return(0,Si.jsxs)(fi.Fragment,{children:[i&&(0,Si.jsx)("defs",{children:i}),(0,Si.jsx)("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:i?`url(#${o})`:xi(r.style.fill),opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},"rect-"+t)}case"heatcell":{const n=e;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const e=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[r,o,i]=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]}(n.fill),s=.299*r+.587*o+.114*i>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return(0,Si.jsxs)("g",{children:[(0,Si.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),(0,Si.jsx)("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px",children:e})]},"heatcell-"+t)}return(0,Si.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill},"heatcell-"+t)}case"candlestick":{const n=e,r=Math.min(n.openY,n.closeY),o=Math.max(Math.abs(n.openY-n.closeY),1),i=n.isUp?n.upColor:n.downColor;return(0,Si.jsxs)("g",{children:[(0,Si.jsx)("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),(0,Si.jsx)("rect",{x:n.x-n.bodyWidth/2,y:r,width:n.bodyWidth,height:o,fill:i,stroke:i,strokeWidth:1})]},"candle-"+t)}default:return null}}(e,t,Et)})).filter(Boolean)]})]}),(0,Za.jsx)(di,{width:Qt,height:Jt,totalWidth:Ft[0],totalHeight:Ft[1],margin:Kt,scales:n,showAxes:ue,axes:he,xLabel:de,yLabel:fe,yLabelRight:ye,xFormat:s,yFormat:ge||ve,axisExtent:me,showGrid:Ne,title:Ve,legend:De,legendHoverBehavior:Ie,legendClickBehavior:$e,legendHighlightedCategory:We,legendIsolatedCategories:ze,legendPosition:Oe,legendLayout:Fe,foregroundGraphics:un(r,pn(Ln.current?.customLayoutOverlays,Pt??null)),marginalGraphics:gt,xValues:[],yValues:[],annotations:je,onAnnotationActivate:Te,onObservation:Me??Se,chartId:_e,chartType:"StreamXYFrame",autoPlaceAnnotations:Ee,svgAnnotationRules:Le,annotationFrame:0,xAccessor:gr,yAccessor:vr,annotationData:kr(Ln.current?.getData()),pointNodes:sa(Ln.current?.scene),curve:"string"==typeof g?g:void 0,linkedCrosshairName:At,linkedCrosshairSourceId:St})]})}return(0,Za.jsxs)("div",{ref:Ot,className:"stream-xy-frame"+(F?" "+F:""),role:"group","aria-label":kt||("string"==typeof Ve?Ve:"XY chart"),tabIndex:0,style:{position:"relative",width:$?"100%":Ft[0],height:W?"100%":Ft[1],overflow:"visible",touchAction:tl(Ke)},onKeyDown:Jn,children:["production"!==process.env.NODE_ENV&&Ln.current&&(0,Za.jsx)(ln,{store:Ln.current,diagnostics:Sn.current}),bt&&(0,Za.jsx)(vs,{tableId:Xt}),bt&&(0,Za.jsx)(gs,{scene:Ln.current?.scene??[],chartType:n+" chart",tableId:Xt,chartTitle:"string"==typeof Ve?Ve:void 0}),(0,Za.jsx)(xs,{summary:wt}),(0,Za.jsx)(Ki,{hoverPoint:vn}),(0,Za.jsxs)("div",{role:"img","aria-label":kt||("string"==typeof Ve?Ve:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:tn?er:void 0,onMouseMove:tn?or:void 0,onPointerLeave:tn?Gn:void 0,onMouseLeave:tn?Gn:void 0,onPointerDown:tn||Tt?ir:void 0,onClick:Tt?Kn:void 0,children:[(0,Za.jsx)(Qs,{size:Ft,margin:Kt,children:dn}),(0,Za.jsx)(ci,{width:Qt,height:Jt,totalWidth:Ft[0],totalHeight:Ft[1],margin:Kt,scales:sn,showAxes:ue,axes:he,showGrid:Ne,xFormat:lr,yFormat:ge||ve,axisExtent:me}),(0,Za.jsx)("canvas",{ref:On,"aria-label":ts(Ln.current?.scene??[],n+" chart"),style:{position:"absolute",left:0,top:0}}),(0,Za.jsx)("canvas",{ref:Fn,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),(0,Za.jsx)(di,{width:Qt,height:Jt,totalWidth:Ft[0],totalHeight:Ft[1],margin:Kt,scales:sn,showAxes:ue,axes:he,xLabel:de,yLabel:fe,yLabelRight:ye,xFormat:lr,yFormat:ge||ve,axisExtent:me,showGrid:Ne,title:Ve,legend:De,legendHoverBehavior:Ie,legendClickBehavior:$e,legendHighlightedCategory:We,legendIsolatedCategories:ze,legendPosition:Oe,legendLayout:Fe,foregroundGraphics:un(hn,pn(Ln.current?.customLayoutOverlays,Pt??null)),marginalGraphics:gt,xValues:Cn,yValues:Rn,annotations:je,onAnnotationActivate:Te,onObservation:Me??Se,chartId:_e,chartType:"StreamXYFrame",autoPlaceAnnotations:Ee,svgAnnotationRules:Le,annotationFrame:nn,xAccessor:gr,yAccessor:vr,annotationData:kr(Ln.current?.getData()),pointNodes:sa(Ln.current?.scene),curve:"string"==typeof g?g:void 0,underlayRendered:!0,canvasObscuresUnderlay:!!Oi({background:B,hasBackgroundGraphics:!!He,themeBackground:Bt?.colors.background}),linkedCrosshairName:At,linkedCrosshairSourceId:St}),(Ke||Qe)&&(0,Za.jsx)(T,{width:Qt,height:Jt,totalWidth:Ft[0],totalHeight:Ft[1],margin:Kt,dimension:Ke?.dimension??"xy",scales:sn,onBrush:Qe??(()=>{}),binSize:b,snap:Ke?.snap,binBoundaries:Ke?.binBoundaries??("bar"===n?Ln.current?.getBinBoundaries():void 0),snapDuring:Ke?.snapDuring,streaming:"streaming"===r}),rt?.showBadge&&(0,Za.jsx)(br,{isStale:Mn,position:rt.badgePosition}),dr,ur]})]})}));nl.displayName="StreamXYFrame";var rl=nl,ol=require("react"),il={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},sl={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1},al=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 r=this.particles[n];return r.active=!0,r.t=0,r.offset=t()-.5,r.edgeIndex=e,r.x=0,r.y=0,r}step(e,t,n,r){for(let o=0;this.capacity>o;o++){const i=this.particles[o];if(!i.active)continue;const s=n[i.edgeIndex];s&&s.bezier?(i.t+=e*t*(r?r[i.edgeIndex]??1:1)*(s.bezier.circular?.3:1),1>i.t?ll(s.bezier,i.t,i.offset,i):(i.active=!1,this._freeIndices.push(o))):(i.active=!1,this._freeIndices.push(o))}}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 ll(e,t,n,r){if(e.circular&&e.segments)return void function(e,t,n,r,o){const i=e.length,s=t*i,a=Math.min(Math.floor(s),i-1),l=s-a,[c,u,h,d]=e[a];cl(c,u,h,d,l,o);const f=d.x-c.x,y=d.y-c.y,p=Math.sqrt(f*f+y*y);if(p>.001){const e=f/p;o.x+=-y/p*n*r*2,o.y+=e*n*r*2}}(e.segments,t,n,e.halfWidth,r);if(!e.points)return r.x=0,void(r.y=0);const[o,i,s,a]=e.points;cl(o,i,s,a,t,r);const l=a.x-o.x,c=a.y-o.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;r.x+=-c/u*n*e.halfWidth*2,r.y+=t*n*e.halfWidth*2}}function cl(e,t,n,r,o,i){const s=1-o,a=s*s,l=a*s,c=o*o,u=c*o;i.x=l*e.x+3*a*o*t.x+3*s*c*n.x+u*r.x,i.y=l*e.y+3*a*o*t.y+3*s*c*n.y+u*r.y}function ul(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function hl(e,t){var n,r=[],o=[],i=[],s={},a=[];function l(e){i[e]=!1,s.hasOwnProperty(e)&&Object.keys(s[e]).forEach(function(t){delete s[e][t],i[t]&&l(t)})}function c(e){var t,r,h=!1;for(o.push(e),i[e]=!0,t=0;a[e].length>t;t++)(r=a[e][t])===n?(u(n,o),h=!0):i[r]||(h=c(r));if(h)l(e);else for(t=0;a[e].length>t;t++){var d=s[r=a[e][t]];d||(s[r]=d={}),d[r]=!0}return o.pop(),h}function u(e,n){var o=[].concat(n).concat(e);t?t(o):r.push(o)}function h(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,r=function(e){for(var t=e.length,n=Array(t),r=Array(t),o=Array(t),i=Array(t),s=Array(t),a=Array(t),l=0;t>l;++l)n[l]=-1,r[l]=0,o[l]=!1,i[l]=0,s[l]=-1,a[l]=[];var c,u=0,h=[],d=[];function f(t){var l=[t],c=[t];for(n[t]=r[t]=u,o[t]=!0,u+=1;c.length>0;){var f=e[t=c[c.length-1]];if(f.length>i[t]){for(var y=i[t];f.length>y;++y){var p=f[y];if(0>n[p]){n[p]=r[p]=u,o[p]=!0,u+=1,l.push(p),c.push(p);break}o[p]&&(r[t]=0|Math.min(r[t],r[p])),0>s[p]||a[t].push(s[p])}i[t]=y}else{if(r[t]===n[t]){var g=[],m=[],x=0;for(y=l.length-1;y>=0;--y){var v=l[y];if(o[v]=!1,g.push(v),m.push(a[v]),x+=a[v].length,s[v]=h.length,v===t){l.length=y;break}}h.push(g);var b=Array(x);for(y=0;m.length>y;y++)for(var k=0;m[y].length>k;k++)b[--x]=m[y][k];d.push(b)}c.pop()}}}for(l=0;t>l;++l)0>n[l]&&f(l);for(l=0;d.length>l;l++){var y=d[l];if(0!==y.length){y.sort(function(e,t){return e-t}),c=[y[0]];for(var p=1;y.length>p;p++)y[p]!==y[p-1]&&c.push(y[p]);d[l]=c}}return{components:h,adjacencyList:d}}(e),o=r.components.filter(function(e){return e.length>1}),i=1/0,s=0;o.length>s;s++)for(var a=0;o[s].length>a;a++)i>o[s][a]&&(i=o[s][a],n=s);var l=o[n];return!!l&&{leastVertex:i,adjList:e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.indexOf(e)})})}}n=0;for(var d=e.length;d>n;){var f=h(n);if(n=f.leastVertex,a=f.adjList){for(var y=0;a.length>y;y++)for(var p=0;a[y].length>p;p++){var g=a[y][p];i[+g]=!1,s[g]={}}c(n),n+=1}else n=d}return t?void 0:r}function dl(e){return e.y0-e.y1>0?"up":"down"}function fl(e,t){return t(e.source)==t(e.target)}function yl(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function pl(e){return e.target.x0-e.source.x1}function gl(e,t){var n=xl(e),r=pl(t)/Math.tan(n);return"up"==dl(e)?e.y1-r:e.y1+r}function ml(e,t){var n=xl(e),r=pl(t)/Math.tan(n);return"up"==dl(e)?e.y1+r:e.y1-r}function xl(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function vl(e,t){return t(e)}function bl(e){return wl(e.source)}function kl(e){return wl(e.target)}function wl(e){return(e.y0+e.y1)/2}function Al(e){return e.virtual?0:e.value}function Sl(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!fl(e,t)?n+1:n});var r=0;return e.targetLinks.forEach(function(e){r=e.circular&&!fl(e,t)?r+1:r}),n+r}function Ml(e){return e.target.depth}function _l(e,t){return e.sourceLinks.length?e.depth:t-1}function Cl(e,t){return e.y0-t.y0}function Pl(e,t){return t.y0-e.y0}function Rl(e,t){return e.y1-t.y1}function jl(e,t){return t.y1-e.y1}function Tl(e,t){return Ll(e.source,t.source)||e.index-t.index}function El(e,t){return Ll(e.target,t.target)||e.index-t.index}function Ll(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function Nl(e,t){return Dl(e)==Dl(t)?"bottom"==e.circularLinkType?Pl(e,t):Cl(e,t):Dl(t)-Dl(e)}function Dl(e){return e.target.column-e.source.column}function Il(e,t){return $l(e)==$l(t)}function $l(e){return e.y0-e.y1>0?"up":"down"}var Wl=require("d3-array");function zl(e,t,n,r,o){let i=e;var s=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var a=(0,Wl.min)(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var l=i.links.filter(function(e){return e.circular});return l.sort(function(e,t){return t.value-e.value}),l.forEach(function(e,t){e._circularStub=t>=4}),Ol(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),Ol(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+r,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,fl(e,t)&&yl(e))e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var s=e.source.column,l=e.circularLinkType,c=i.links.filter(function(e){return e.source.column==s&&e.circularLinkType==l});c.sort("bottom"==e.circularLinkType?Pl:Cl);var u=0;c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2+o*n+u),u+=t._circularWidth||t.width}),s=e.target.column,(c=i.links.filter(function(e){return e.target.column==s&&e.circularLinkType==l})).sort("bottom"==e.circularLinkType?jl:Rl),u=0,c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2+o*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=a-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,n=e.y0,r=e.target.x0,o=e.y1,i=(t+r)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+o+" "+r+","+o}(e)}),i}function Ol(e,t,n){e.sort(Nl);var r=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(fl(e,t)&&yl(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var s=0;r.length>s;s++){var a=r[s];if(a!==e&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&Fl(e,a)){var l=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;i=l>i?l:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function Fl(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}var Bl=require("d3-array");function Yl(e){return function(){return e}}function Hl(e){return e.index}function Xl(e){return e.nodes}function ql(e){return e.links}function Gl(e,t,n){var r=(0,Bl.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});r.forEach(function(o,i){var s=o.length;if(t)o.sort(t);else if(i>0){var a=new Map;o.forEach(function(e,t){var n,r,o,i=(r=0,o=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=wl(e.source)*t,r+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=wl(e.target)*t,r+=t}}),r>0?o/r:NaN);a.set(e,{bc:i,idx:t})}),o.sort(function(e,t){var n=a.get(e),r=a.get(t),o=n.bc,i=r.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(o)||isNaN(i)?isNaN(o)?isNaN(i)?n.idx-r.idx:1:-1:o-i})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?Sl(t,n)-Sl(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});o.forEach(function(t,o){t.depth==r.length-1&&1==s||0==t.depth&&1==s?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==Sl(t,n)?(t.y0=e.y1/2+o,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+o,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-o,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/s*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-s/2+o,t.y1=t.y0+t.value*e.ky)})})}function Vl(e,t,n,r,o,i){var s=(0,Bl.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var a=1,l=i;l>0;--l)c(a*=.99,n),u();function c(t,n){var r=s.length;s.forEach(function(o){var i=o.length,s=o[0].depth;o.forEach(function(o){var a;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&Sl(o,n)>0){var l=(0,Bl.mean)(o.sourceLinks,kl),c=(0,Bl.mean)(o.targetLinks,bl),u=l&&c?(l+c)/2:l||c;if(u){var h=(u-wl(o))*t*.3;o.y0+=h,o.y1+=h}}else if(0==s&&1==i)o.y0=e.y1/2-(a=o.y1-o.y0)/2,o.y1=e.y1/2+a/2;else if(s==r-1&&1==i)o.y0=e.y1/2-(a=o.y1-o.y0)/2,o.y1=e.y1/2+a/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)a=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+a;else{var d=(0,Bl.mean)(o.sourceLinks,kl),f=(0,Bl.mean)(o.targetLinks,bl),y=((d&&f?(d+f)/2:d||f)-wl(o))*t;o.y0+=y,o.y1+=y}})})}function u(){s.forEach(function(n){var i,s,a,l=e.y0,c=n.length;for(n.sort(t||Ll),a=0;c>a;++a)(s=l-(i=n[a]).y0)>0&&(i.y0+=s,i.y1+=s),l=i.y1+r;if((s=l-r-e.y1)>0)for(l=i.y0-=s,i.y1-=s,a=c-2;a>=0;--a)(s=(i=n[a]).y1+o-l)>0&&(i.y0-=s,i.y1-=s),l=i.y0})}}function Ul(e){e.nodes.forEach(function(e){e.sourceLinks.sort(El),e.targetLinks.sort(Tl)}),e.nodes.forEach(function(e){var t=e.y0,n=t,r=e.y1,o=r;e.sourceLinks.forEach(function(e){e.circular?(e.y0=r-e.width/2,r-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=o-e.width/2,o-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function Kl(){var e=0,t=0,n=1,r=1,o=24,i=8,s=null,a=Hl,l=_l,c=void 0,u=32,h=2,d=Xl,f=ql;function y(){var y={nodes:d.apply(null,arguments),links:f.apply(null,arguments)};return function(d){d.x0=e,d.y0=t,d.x1=n,d.y1=r,d.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return(0,Bl.group)(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,o=e.target;"object"!=typeof r&&(r=e.source=ul(n,r)),"object"!=typeof o&&(o=e.target=ul(n,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}(d,a),function(e,t){var n=0;if(null==t){for(var r=[],o=0;e.links.length>o;o++){var i=e.links[o],s=i.source.index,a=i.target.index;r[s]||(r[s]=[]),r[a]||(r[a]=[]),-1===r[s].indexOf(a)&&r[s].push(a)}var l=hl(r);l.sort(function(e,t){return e.length-t.length});var c={};for(o=0;l.length>o;o++){var u=l[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,r=e.source.index;t===r||c[r]&&c[r][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(d,c),function(e,t){var n=0,r=0;e.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:r>n?"top":"bottom","top"==o.circularLinkType?n++:r++,e.nodes.forEach(function(e){vl(e,t)!=vl(o.source,t)&&vl(e,t)!=vl(o.target,t)||(e.circularLinkType=o.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),fl(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(d,a),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max((0,Bl.sum)(e.sourceLinks,Al),(0,Bl.sum)(e.targetLinks,Al)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(d),function(e,t,n){var r,o,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var s=0,a=t(e.nodes[0]);e.nodes.forEach(function(e){s=t(e)==a?s:s+1,a=t(e)==a?a:t(e),e.column=s})}for(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>o.indexOf(e.source)&&!e.circular&&o.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,i):e.column})}(d,c,l);var f=i;if(null!==s){var y=(0,Bl.groups)(d.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),p=(0,Bl.max)(y,function(e){return e.length});p>1&&(f=Math.max(1,(r-t)*s/(p-1)))}(function(e,t,n){var r=(0,Bl.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var o=(0,Bl.min)(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/(0,Bl.sum)(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var i=(0,Bl.max)(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/i),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(d,f,o),Gl(d,c,a),Vl(d,c,a,f,f,u),Ul(d),zl(d,a,h,10,8),Gl(d,c,a),Vl(d,c,a,f,f,u),Ul(d),zl(d,a,h,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var r=n.links.filter(function(n){return vl(n.source,t)==vl(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Il(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=gl(t,e);return e.y1-n}if(t.target.column>e.target.column)return gl(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;r.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,s=0;o>i;i++)s+=r[i].width;t.y0=e.y1-s-t.width/2}})})}(d,a),function(e,t){let n=e;n.nodes.forEach(function(e){var r=n.links.filter(function(n){return vl(n.target,t)==vl(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Il(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=ml(t,e);return e.y0-n}if(t.source.column>e.source.column)return ml(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;r.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,s=0;o>i;i++)s+=r[i].width;t.y1=e.y1-s-t.width/2}})})}(d,a),function(e){var t=e.nodes,n=e.links,r=!1,o=!1;if(n.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==r||0==o){let r=function(t){return(t-i)/(s-i)*(e.y1-e.y0)+e.y0};var i=(0,Bl.min)(t,function(e){return e.y0}),s=(0,Bl.max)(t,function(e){return e.y1}),a=(e.y1-e.y0)/(s-i);1>a?(t.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1)}),n.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1),e.width=e.width*a})):t.forEach(function(e){var t=e.y1-e.y0,n=r(e.y0)-e.y0;e.y0=r(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(d),zl(d,a,h,10,8)}(y),y}return y.update=function(e){return Ul(e),zl(e,a,h,10,8),e},y.nodeWidth=function(e){return arguments.length?(o=+e,y):o},y.nodePadding=function(e){return arguments.length?(i=+e,y):i},y.nodePaddingRatio=function(e){return arguments.length?(s=+e,y):s},y.nodes=function(e){return arguments.length?(d="function"==typeof e?e:Yl(e),y):d},y.links=function(e){return arguments.length?(f="function"==typeof e?e:Yl(e),y):f},y.nodeId=function(e){return arguments.length?(a="function"==typeof e?e:Yl(e),y):a},y.nodeAlign=function(e){return arguments.length?(l="function"==typeof e?e:Yl(e),y):l},y.nodeSort=function(e){return arguments.length?(c=e,y):c},y.iterations=function(e){return arguments.length?(u=+e,y):u},y.circularLinkGap=function(e){return arguments.length?(h=+e,y):h},y.extent=function(o){return arguments.length?(e=+o[0][0],t=+o[0][1],n=+o[1][0],r=+o[1][1],y):[[e,t],[n,r]]},y.size=function(o){return arguments.length?(e=t=0,n=+o[0],r=+o[1],y):[n-e,r-t]},y}var Ql=require("d3-interpolate");require("d3-shape");var Zl=e=>{let t,n,r,o,i,s,a,l,c;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,r=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,i=e.source.x1,s=e.target.x0,a=(0,Ql.interpolateNumber)(i,s),l=a(.5),c=a(.5),`M${t},${i}C${t},${l} ${n},${c} ${n},${s}L${r},${s}C${r},${c} ${o},${l} ${o},${i}Z`;const u=e.sankeyWidth/2,h=(0,Ql.interpolateNumber)(e.source.x1,e.target.x0),{pathD:d}=function(e){const{sx:t,sTop:n,sBot:r,tx:o,tTop:i,tBot:s,cp1X:a,cp2X:l}=e,c=(n+r)/2,u=(i+s)/2;return{pathD:[`M${t},${n}`,`C${a},${n} ${l},${i} ${o},${i}`,`L${o},${s}`,`C${l},${s} ${a},${r} ${t},${r}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:c},{x:a,y:c},{x:l,y:u},{x:o,y:u}],halfWidth:(r-n)/2}}}({sx:e.source.x1,sTop:e.y0-u,sBot:e.y0+u,tx:e.target.x0,tTop:e.y1-u,tBot:e.y1+u,cp1X:h(.5),cp2X:h(.5)});return d};function Jl(e){const t=e.sankeyWidth/2,n=(e._circularWidth??e.sankeyWidth)/2,r=e.circularPathData;if(!r)return null;if("down"===e.direction)return null;if(e._circularStub){const n=r.sourceX,o=r.sourceY,i=r.targetX,s=r.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const a=Math.max(15,Math.min(40,.33*(r.rightFullExtent-n))),l=Math.max(15,Math.min(40,.33*(i-r.leftFullExtent)));return`M${n},${o-t}L${n+a},${o-t}L${n+a},${o+t}L${n},${o+t}ZM${i},${s-t}L${i-l},${s-t}L${i-l},${s+t}L${i},${s+t}Z`}const o=r.sourceX,i=r.sourceY,s=r.targetX,a=r.targetY,l=r.rightFullExtent,c=r.leftFullExtent,u=r.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,d=Math.max(4,Math.min(n,15));return`M${o},${i-h*t}L${l},${i-h*t}L${l+n},${i-h*t+h*d}L${l+n},${u+h*n-h*d}L${l+n-d},${u+h*n}L${c-n+d},${u+h*n}L${c-n},${u+h*n-h*d}L${c-n},${a-h*t+h*d}L${c-n+d},${a-h*t}L${s},${a-h*t}L${s},${a+h*t}L${c+n},${a+h*t}L${c+n},${u-h*n}L${l-n},${u-h*n}L${l-n},${i+h*t}L${o},${i+h*t}Z`}var ec=new Set,tc=new WeakMap;function nc(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=tc.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,tc.set(e,n);const r=new Proxy(e,{get(e,n,r){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;ec.has(e)||(ec.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,n,r)}});return n.set(t,r),r}var rc={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(Ml))-1:0},justify:_l};function oc(e){return"string"==typeof e?e:e.id}var ic={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const o="vertical"===n.orientation?"down":"right",i=n.nodeAlign||"justify",s=n.nodeWidth??15,a=n.nodePaddingRatio??.05,l=n.iterations??100,c=e.map(e=>({...e})),u=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let h;h="down"===o?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const d=Kl().extent(h).links(u).nodes(c).nodeAlign(rc[i]||_l).nodeId(e=>e.id).nodeWidth(s).iterations(l);d.nodePaddingRatio&&d.nodePaddingRatio(a),d();{let e=1/0,t=-1/0,n=1/0,o=-1/0;for(const r of c)e>r.x0&&(e=r.x0),r.x1>t&&(t=r.x1),n>r.y0&&(n=r.y0),r.y1>o&&(o=r.y1);for(const r of u){if(!r.circular||!r.circularPathData)continue;const i=r.circularPathData,s=(r._circularWidth??r.width??0)/2;e>i.leftFullExtent-s&&(e=i.leftFullExtent-s),i.rightFullExtent+s>t&&(t=i.rightFullExtent+s),n>i.verticalFullExtent-s&&(n=i.verticalFullExtent-s),i.verticalFullExtent+s>o&&(o=i.verticalFullExtent+s)}const i=t-e,s=o-n,a=r[0],l=r[1];if(i>0&&s>0&&(0>e||0>n||t>a||o>l)){const t=Math.min(a/i,l/s),r=-e*t+(a-i*t)/2,o=-n*t+(l-s*t)/2;for(const e of c)e.x0=e.x0*t+r,e.x1=e.x1*t+r,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of u)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+r,n.targetX=n.targetX*t+r,n.sourceY=n.sourceY*t+o,n.targetY=n.targetY*t+o,n.rightFullExtent=n.rightFullExtent*t+r,n.leftFullExtent=n.leftFullExtent*t+r,n.verticalFullExtent=n.verticalFullExtent*t+o,n.rightInnerExtent=n.rightInnerExtent*t+r,n.leftInnerExtent=n.leftInnerExtent*t+r,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+o,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const f=new Map;for(const t of e)f.set(t.id,t);for(const e of c){const t=f.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const y=new Map;for(const e of t)y.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of u){const t=oc(e.source),n=oc(e.target),r=y.get(e._edgeKey?e._edgeKey:`${t}\0${n}`);if(r){r.y0=e.y0,r.y1=e.y1,r.sankeyWidth=e.width??0,r.circular=!!e.circular,r.circularPathData=e.circularPathData,r._circularWidth=e._circularWidth,r._circularStub=e._circularStub,r.path=e.path,r.circularLinkType=e.circularLinkType,r.direction=o;const i=f.get(t),s=f.get(n);i&&(r.source=i),s&&(r.target=s)}}},buildScene(e,t,n,r){const o="vertical"===n.orientation?"down":"right",i=n.nodeStyle,s=n.edgeStyle,a=n.edgeOpacity??.5,l=n.edgeColorBy||"source",c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:ae,u=new Map;e.forEach((e,t)=>{u.set(e.id,c[t%c.length])});const h=[],d=[],f=[],y=new Map;for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const r=i?i(nc(t,"nodeStyle")):{},s={fill:r.fill||u.get(t.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};y.set(t.id,("string"==typeof s.fill?s.fill:null)||u.get(t.id)||"#4d430c"),h.push("down"===o?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:s,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:s,datum:t,id:t.id,label:t.id})}const p=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of p){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";o="function"==typeof l?l(e)||o:"target"===l?y.get(r.id)||u.get(r.id)||o:y.get(t.id)||u.get(t.id)||o;const i=s?s(nc(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,r=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),s=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),l=i.fill||o;d.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+r},${t.sourceY-n}L${t.sourceX+r},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:l,fillOpacity:i.fillOpacity??a,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+r}}),d.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-s},${t.targetY-n}L${t.targetX-s},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:l,fillOpacity:i.fillOpacity??a,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-s,x1:t.targetX}});continue}let c;(c=e.circular&&e.circularPathData?Jl(e):Zl(e),c)&&d.push({type:"bezier",pathD:c,bezierCache:e.bezier,style:{fill:i.fill||o,fillOpacity:i.fillOpacity??a,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity},datum:e})}if(!1!==n.showLabels){const t=(g=n.nodeLabel)?"function"==typeof g?g:e=>e[g]||e.id:null;for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const s=t?t(n):n.id;if(!s)continue;let a,l,c;"down"===o?(a=n.y0+(n.y1-n.y0)/2,l=n.x1+14,c="start"):(r[0]/2>n.x0+e/2?(a=n.x0-6,c="end"):(a=n.x1+6,c="start"),l=n.y0+i/2),f.push({x:a,y:l,text:s+"",anchor:"down"===o?"middle":c,baseline:"middle",fontSize:11})}}var g;return{sceneNodes:h,sceneEdges:d,labels:f}}},sc=require("d3-force"),ac=require("d3-scale"),lc={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const o=n.forceStrength??.1,i=r[0]/2,s=r[1]/2,a=n.__previousPositions;let l=0;const c=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=a?.get(t.id);e?l++:n?(t.x=n.x,t.y=n.y,l++):c.push(t)}const u=l>0&&.3>=(e.length>0?c.length/e.length:1);if(u){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of c){const r=cc(e.id,t,n);if(r.length>0){let t=0,n=0;for(const e of r)t+=e.x,n+=e.y;const o=uc(e.id),i=o%360*(Math.PI/180),s=10+o%20;e.x=t/r.length+s*Math.cos(i),e.y=n/r.length+s*Math.sin(i)}else{const t=uc(e.id),n=t%360*(Math.PI/180),r=15+t%30;e.x=i+r*Math.cos(n),e.y=s+r*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const r=e[n];if(null==r.x||null==r.y||0===r.x&&0===r.y){const e=10*Math.sqrt(n+.5),o=n*t;r.x=i+e*Math.cos(o),r.y=s+e*Math.sin(o)}}}const h=n.__skipForceSimulation||0===n.iterations?0:u?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),d=hc(n.nodeSize,n.nodeSizeRange,e),f=e=>d(e);if(h>0){const r=new Map,a=new Map;for(const t of e)r.set(t.id,0),a.set(t.id,t);for(const e of t){const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id;r.set(t,(r.get(t)??0)+1),r.set(n,(r.get(n)??0)+1)}const l=(0,sc.forceLink)().strength(e=>{const t=e.weight,n="string"==typeof e.target?e.target:e.target.id,i=Math.max(1,Math.min(r.get("string"==typeof e.source?e.source:e.source.id)??1,r.get(n)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*o/(.1*i))}).distance(e=>{const t="string"==typeof e.source?a.get(e.source):e.source,n="string"==typeof e.target?a.get(e.target):e.target,r=(t?f(t):0)+(n?f(n):0)+12;return Math.max(40,r)}).id(e=>e.id),c=(0,sc.forceSimulation)();if(void 0===n.random&&void 0===n.seed||c.randomSource(n.random??Fs(n.seed)),c.force("charge",(0,sc.forceManyBody)().strength(e=>{const t=r.get(e.id)??0;return-15*f(e)*Math.sqrt(t+1)})).force("collide",(0,sc.forceCollide)(e=>f(e)+3).strength(.9).iterations(2)).force("center",(0,sc.forceCenter)(i,s).strength(.8)).force("x",(0,sc.forceX)(i).strength(.06)).force("y",(0,sc.forceY)(s).strength(.06)),c.nodes(e),t.length>0){const e=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));l.links(e),c.force("link",l)}u?c.alpha(.3):.1>c.alpha()&&c.alpha(1),c.stop();for(let e=0;h>e;++e)c.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=f(t);t.x=Math.max(e,Math.min(r[0]-e,t.x)),t.y=Math.max(e,Math.min(r[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const y=new Map;for(const t of e)y.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=y.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=y.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,r){const o=n.nodeStyle,i=n.edgeStyle,s=hc(n.nodeSize,n.nodeSizeRange,e),a=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:ae,l=new Map;e.forEach((e,t)=>{l.set(e.id,a[t%a.length])});const c=[],u=[],h=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=s(nc(t,"nodeSize")),r=o?o(nc(t,"nodeStyle")):{},i={fill:r.fill||l.get(t.id)||n.themeSemantic?.primary||"#007bff",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??2,opacity:r.opacity};c.push({type:"circle",cx:t.x,cy:t.y,r:e,style:i,datum:t,id:t.id,label:t.id})}const d=new Map;for(const t of e)d.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:d.get(e.source),r="object"==typeof e.target?e.target:d.get(e.target);if(!t||!r)continue;if(null==t.x||null==t.y)continue;if(null==r.x||null==r.y)continue;const o=i?i(nc(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:o.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.6},datum:e})}if(!1!==n.showLabels){const t=(f=n.nodeLabel)?"function"==typeof f?f:e=>e[f]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const r=s(nc(n,"nodeSize"));h.push({x:n.x,y:n.y-r-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var f;return{sceneNodes:c,sceneEdges:u,labels:h}}};function cc(e,t,n){const r=[];for(const o of t){const t="string"==typeof o.source?o.source:o.source.id,i="string"==typeof o.target?o.target:o.target.id;let s=null;if(t===e?s=i:i===e&&(s=t),s){const e=n.get(s);!e||0===e.x&&0===e.y||r.push({x:e.x,y:e.y})}}return r}function uc(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function hc(e,t,n){if(n.some(e=>null!=e.__forceRadius))return e=>e.__forceRadius??8;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const r=t||[5,20],o=[];for(const t of n){const n=t.data?.[e];"number"==typeof n&&o.push(n)}if(0===o.length)return()=>r[0];const[i,s]=Ir(o);if(i===s)return()=>(r[0]+r[1])/2;const a=(0,ac.scaleLinear)().domain([i,s]).range(r).clamp(!0);return t=>{const n=t.data?.[e];return null==n||"number"!=typeof n?r[0]:a(n)}}var dc=require("d3-chord"),fc=require("d3-shape"),yc=ae,pc={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:s}=n,a=Math.min(r[0],r[1])/2,l=a-i,c=r[0]/2,u=r[1]/2,h=(d=n.valueAccessor)?"function"==typeof d?d:e=>e[d]??1:e=>e.value??1;var d;const f=new Map;for(let t=0;e.length>t;t++)f.set(e[t].id,t);const y=e.length,p=Array.from({length:y},()=>Array.from({length:y},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=f.get("string"==typeof e.source?e.source:e.source.id),r=f.get(t);if(void 0===n||void 0===r)continue;const o=h(e);p[n][r]=o}const g=(0,dc.chord)().padAngle(o);s&&g.sortGroups(s);const m=g(p),x=m.groups,v=(0,fc.arc)().innerRadius(l).outerRadius(a);for(const t of x){const n=e[t.index],r=v.centroid({innerRadius:l,outerRadius:a,startAngle:t.startAngle,endAngle:t.endAngle});n.x=r[0]+c,n.y=r[1]+u,n.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const b=new Map;for(const t of e)b.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=b.get("string"==typeof e.source?e.source:e.source.id),r=b.get(t);n&&(e.source=n),r&&(e.target=r)}const k=new Map;for(const e of t)k.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of m){const n=e[t.source.index].id,r=e[t.target.index].id,o=k.get(`${n}\0${r}`)||k.get(`${r}\0${n}`);o&&(o.__chordData=t)}},buildScene(e,t,n,r){const{groupWidth:o=20,edgeOpacity:i=.5}=n,s=Math.min(r[0],r[1])/2,a=s-o,l=r[0]/2,c=r[1]/2,u=n.nodeStyle,h=n.edgeStyle,d=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:yc,y=new Map;e.forEach((e,t)=>{y.set(e.id,f[t%f.length])});const p=(0,dc.ribbon)().radius(a),g=[],m=[],x=[];for(let t=0;e.length>t;t++){const n=e[t],r=n.__arcData;if(!r)continue;let o;o=u?u(nc(n,"nodeStyle")).fill||y.get(n.id)||f[t%f.length]:y.get(n.id)||f[t%f.length];const i=u?u(nc(n,"nodeStyle")):{};g.push({type:"arc",cx:l,cy:c,innerR:a,outerR:s,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:{fill:o,stroke:i.stroke||"black",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const r=p(t);if(!r)continue;const o=gc(r,l,c);let s=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(h)s=h(nc(e,"edgeStyle")).fill||s;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===d&&n?s=y.get(n.id)||s:t&&(s=y.get(t.id)||s)}const a=h?h(nc(e,"edgeStyle")):{};m.push({type:"ribbon",pathD:o,style:{fill:s,fillOpacity:a.fillOpacity??i,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity},datum:e})}if(!1!==n.showLabels){const t=(v=n.nodeLabel)?"function"==typeof v?v:e=>e[v]||e.id:null,r=s+12;for(const n of e){const e=n.__arcData;if(!e)continue;const o=t?t(n):n.id;if(!o)continue;const i=(e.startAngle+e.endAngle)/2,s=i-Math.PI/2;x.push({x:l+Math.cos(s)*r,y:c+Math.sin(s)*r,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var v;return{sceneNodes:g,sceneEdges:m,labels:x}}};function gc(e,t,n){const r=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return e;const o=[];let i=0;for(;r.length>i;){const e=r[i];if("M"===e||"L"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("C"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;3>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("Q"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;2>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("A"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&(o.push(Number(r[i])+t+""),i++),r.length>i&&(o.push(Number(r[i])+n+""),i++);else"Z"===e||"z"===e?(o.push(e),i++):(o.push(r[i]),i++)}return o.join(" ")}var mc=require("d3-hierarchy"),xc=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function vc(e){const[t,n,r]=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*r>150?"#222":"#fff"}function bc(e,t,n){const r=t.nodeIDAccessor;return"function"==typeof r?r(e.data)+"":"string"==typeof r&&void 0!==e.data[r]?e.data[r]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function kc(e){if(!e)return null;if("function"==typeof e){const t=e;return e=>t(e.data??e)}return t=>t.data?.[e]||t[e]||t.id}function wc(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:xc}function Ac(e){return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:e.themeSemantic?.primary?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function Sc(e,t,n,r,o){if("horizontal"===o){const o=(e+n)/2;return`M ${e},${t} C ${o},${t} ${o},${r} ${n},${r}`}if("radial"===o){const o=(e+n)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+r)/2} T ${n},${r}`}{const o=(t+r)/2;return`M ${e},${t} C ${e},${o} ${n},${o} ${n},${r}`}}var Mc={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,r){const o=n.__hierarchyRoot;if(!o)return;const i=n.chartType,s=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),a=n.hierarchySum,l="function"==typeof a?a:"string"==typeof a?e=>Number(e[a])||0:e=>Number(e.value)||0,c=(0,mc.hierarchy)(o,s);c.sum(l),c.sort((e,t)=>(t.value??0)-(e.value??0));const[u,h]=r;switch(i){case"tree":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=(0,mc.tree)();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(c,n,u,h);break;case"cluster":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=(0,mc.cluster)();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(c,n,u,h);break;case"treemap":!function(e,t,n,r){const o=t.padding??4,i=t.paddingTop??0,s=(0,mc.treemap)().size([n,r]).tile(mc.treemapBinary).padding(o);i>0&&s.paddingTop(i),s(e)}(c,n,u,h);break;case"circlepack":!function(e,t,n,r){const o=t.padding??4;(0,mc.pack)().size([n,r]).padding(o)(e)}(c,n,u,h);break;case"partition":!function(e,t,n,r){(0,mc.partition)().size([n,r]).padding(t.padding??1)(e)}(c,n,u,h)}const d=c.descendants();e.length=0,t.length=0;const f=new Map;for(let t=0;d.length>t;t++){const r=d[t],o={id:bc(r,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:r.value??0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===i||"cluster"===i?_c(o,r,n):"treemap"===i||"partition"===i?Cc(o,r):"circlepack"===i&&Pc(o,r),o.__hierarchyNode=r,e.push(o),f.set(r,o)}if("tree"===i||"cluster"===i)for(const e of d)if(e.parent){const n=f.get(e.parent),r=f.get(e);n&&r&&t.push({source:n,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,r){const o=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,r,o,i){const s=[],a=[],l=[],c=n.treeOrientation||"vertical",u="radial"===c,h=r[0]/2,d=r[1]/2,f="number"==typeof(y=n.nodeSize)?y:5;var y;for(const t of e){let e=t.x,r=t.y;u&&(e+=h,r+=d);const i=o(nc(t,"nodeStyle"));let a=i.fill||Ac(n);if(n.colorByDepth&&void 0!==t.depth){const e=wc(n);a=e[t.depth%e.length]}s.push({type:"circle",cx:e,cy:r,r:f,style:{fill:a,stroke:i.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:t,id:t.id,label:t.id,depth:t.depth})}const p=n.edgeOpacity??.5;for(const e of t){const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=t.x,s=t.y,l=r.x,f=r.y;u&&(o+=h,s+=d,l+=h,f+=d);const y=Sc(o,s,l,f,c),g=i(nc(e,"edgeStyle"));a.push({type:"curved",pathD:y,style:{fill:"none",stroke:g.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??p},datum:e})}if(!1!==n.showLabels){const t=kc(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let r,o,i,s=n.x,a=n.y;if(u&&(s+=h,a+=d),u){const e=s-h,t=a-d,n=Math.sqrt(e*e+t*t);n>0?(r=s+e/n*10,o=a+t/n*10,i=0>e?"end":"start"):(r=s,o=a-12,i="middle")}else"horizontal"===c?(n.data?.children&&0!==n.data.children.length?(r=s-f-6,i="end"):(r=s+f+6,i="start"),o=a):(r=s,o=a+f+14,i="middle");l.push({x:r,y:o,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:l}}(e,t,n,r,o,i);case"treemap":case"partition":return function(e,t,n,r){const o=[],i=[];for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const s=r(nc(n,"nodeStyle"));let a=s.fill||Ac(t);if(t.colorByDepth&&void 0!==n.depth){const e=wc(t);a=e[n.depth%e.length]}o.push({type:"rect",x:n.x0,y:n.y0,w:e,h:i,style:{fill:a,stroke:s.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:s.strokeWidth??1,opacity:s.opacity},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=kc(t.nodeLabel),o=t.labelMode||"leaf",s="partition"===t.chartType;for(const a of e){const e=a.x1-a.x0,l=a.y1-a.y0;if(0>=e||0>=l)continue;const c=!(a.data?.children&&a.data.children.length>0);if(!s){if("leaf"===o&&!c)continue;if("parent"===o&&c)continue}const u=n?n(a):a.id;if(!u)continue;if((c?30:40)>e||(c?16:14)>l)continue;let h=r(nc(a,"nodeStyle")).fill||Ac(t);if(t.colorByDepth&&void 0!==a.depth){const e=wc(t);h=e[a.depth%e.length]}const d="string"==typeof h?vc(h):t.themeSemantic?.text??"#000";i.push(c?{x:a.x0+e/2,y:a.y0+l/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,l)/6)),fill:d}:{x:a.x0+4,y:a.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:d})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(e,n,0,o);case"circlepack":return function(e,t,n,r){const o=[],i=[];for(const n of e){const e=n.__radius??5;if(0>=e)continue;const i=r(nc(n,"nodeStyle"));let s=i.fill||Ac(t);if(t.colorByDepth&&void 0!==n.depth){const e=wc(t);s=e[n.depth%e.length]}o.push({type:"circle",cx:n.x,cy:n.y,r:e,style:{fill:s,stroke:i.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??.7},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=kc(t.nodeLabel);for(const o of e){const e=o.__radius??5,s=n?n(o):o.id;if(!s)continue;if(15>e)continue;const a=!(o.data?.children&&o.data.children.length>0);let l=r(nc(o,"nodeStyle")).fill||Ac(t);if(t.colorByDepth&&void 0!==o.depth){const e=wc(t);l=e[o.depth%e.length]}if(a){const n="string"==typeof l?vc(l):t.themeSemantic?.text??"#000";i.push({x:o.x,y:o.y,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:n})}else i.push({x:o.x,y:o.y-e+14,text:s+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:t.themeSemantic?.text||"#000",stroke:t.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(e,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function _c(e,t,n){const r=n.treeOrientation||"vertical";if("radial"===r){const n=t.x,r=t.y;e.x=r*Math.cos(n-Math.PI/2),e.y=r*Math.sin(n-Math.PI/2)}else"horizontal"===r?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function Cc(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function Pc(e,t){const n=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}var Rc=require("d3-shape");function jc(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var Tc={sankey:ic,force:lc,chord:pc,tree:Mc,cluster:Mc,treemap:Mc,circlepack:Mc,partition:Mc,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,r){const o=n.__hierarchyRoot;o&&function(e,t,n,r,o){const i=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),s=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}(n.nodeIDAccessor),a=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),l=n.orbitSize??2.95,c=n.orbitEccentricity??1,u="number"==typeof l?()=>l:l,h="number"==typeof c?()=>c:c,d=jc(n);d.metaMap.clear(),r.length=0,o.length=0;const f=new Map;function y(e){const t=f.get(e)??0;return f.set(e,t+1),0===t?e:`${e}__${t}`}const p=t[0]/2,g=t[1]/2,m=Math.min(t[0],t[1])/2*.85,x=y(s(e));r.push({id:x,x:p,y:g,x0:p,x1:p,y0:g,y1:g,width:0,height:0,value:0,depth:0,data:e}),d.metaMap.set(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,l,c,f,p,g){const m=i(t);if(!m?.length)return;const x=m.length;let v=0,b=0,k=0;for(;x>b;)b+=a[Math.min(k,a.length-1)],k++,v++;let w=0;for(let x=0;v>x;x++){const b=a[Math.min(x,a.length-1)],k=m.slice(w,w+b);if(!k.length)break;const A=(x+1)/v,S={id:n,depth:p,data:t,parentId:n},M=g?f/u(S)*A:f*A,_=(0,Rc.pie)().value(e=>{const t=i(e)?.length;return t?4:1}).sort(null)(k),C=h(S);for(let t=0;k.length>t;t++){const i=(_[t].startAngle+_[t].endAngle)/2,a=k[t],u=y(s(a)),h=l+M*Math.sin(i),f=c+M*Math.cos(i)*C;r.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:p,data:a}),d.metaMap.set(u,{ring:M,angle:i,depth:p,parentId:n,eccentricity:C}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(a,u,h,f,M,p+1,!0)}w+=b}}(e,x,p,g,m,1,!1)}(o,r,n,e,t)},buildScene(e,t,n,r){const o=n.nodeStyle,i=n.nodeSize,s="number"==typeof i?()=>i:"function"==typeof i?i:()=>6,a=[],l=[],c=[];if(!1!==n.orbitShowRings){const t=jc(n),r=new Map;for(const t of e)r.set(t.id,t);const o=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=r.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;o.has(n)||o.set(n,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:n,ecc:r}]of o)for(let o=0;i>o;o++){const a=o/i*Math.PI*2,c=(o+1)/i*Math.PI*2;l.push({type:"line",x1:e+n*Math.sin(a),y1:t+n*Math.cos(a)*r,x2:e+n*Math.sin(c),y2:t+n*Math.cos(c)*r,style:s,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=s(nc(t,"nodeSize")),r=o?o(nc(t,"nodeStyle")):{};a.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:r.fill||n.themeSemantic?.primary||"#6366f1",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??(0===(t.depth??0)?1:.85)},datum:t,id:t.id,label:t.id,depth:t.depth})}const u=new Map;for(const t of e)u.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:u.get(e.source),n="object"==typeof e.target?e.target:u.get(e.target);t&&n&&(null!=t.x&&null!=n.x&&l.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=s(nc(n,"nodeSize"));if(4>=e)continue;const r="function"==typeof t?t(n):t?n.data?.[t]??n.id:n.id;c.push({x:n.x,y:n.y+e+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:a,sceneEdges:l,labels:c}},tick:(e,t,n,r,o)=>!1!==n.orbitAnimated&&(function(e,t){const n=jc(t),r=t.orbitSpeed??.25,o=t.orbitRevolution??function(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{const t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}(t.orbitRevolutionStyle),i=(("undefined"!=typeof performance?performance.now():Date.now())-n.startTime)/1e3,s=r*(Math.PI/6),a=new Map;for(const t of e)a.set(t.id,t);for(const t of e){const e=n.metaMap.get(t.id);if(!e||!e.parentId)continue;const r=a.get(e.parentId);if(!r)continue;const l=e.angle+i*s*o({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=r.x+e.ring*Math.sin(l),t.y=r.y+e.ring*Math.cos(l)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)}};function Ec(e){return Tc[e]}var Lc=require("d3-quadtree");function Nc(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 Dc(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(!Ic(e))return!1;return!0}return Ic(t.points)}function Ic(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}var $c=require("d3-interpolate");var Wc="rgba(34, 197, 94, 0.7)",zc=2e3,Oc=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Fc=["scene-style","data-paint","accessibility","evidence"],Bc=(e,t)=>({retainedData:e,invalidations:t}),Yc=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Hc=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Xc=["scene-geometry","data-paint","overlay","accessibility","evidence"],qc=["scene-style","data-paint","accessibility","evidence"],Gc=["scene-geometry","data-paint","overlay","accessibility","evidence"],Vc=[],Uc={chartType:Bc("rebuild",Yc),nodeIDAccessor:Bc("rebuild",Yc),sourceAccessor:Bc("rebuild",Yc),targetAccessor:Bc("rebuild",Yc),valueAccessor:Bc("rebuild",Yc),edgeIdAccessor:Bc("rebuild",Yc),childrenAccessor:Bc("rebuild",Yc),hierarchySum:Bc("rebuild",Yc),orientation:Bc("preserve",Hc),nodeAlign:Bc("preserve",Hc),nodePaddingRatio:Bc("preserve",Hc),nodeWidth:Bc("preserve",Hc),edgeSort:Bc("preserve",Hc),iterations:Bc("preserve",Hc),forceStrength:Bc("preserve",Hc),padAngle:Bc("preserve",Hc),groupWidth:Bc("preserve",Hc),sortGroups:Bc("preserve",Hc),treeOrientation:Bc("preserve",Hc),edgeType:Bc("preserve",Hc),padding:Bc("preserve",Hc),paddingTop:Bc("preserve",Hc),orbitMode:Bc("preserve",Hc),orbitSize:Bc("preserve",Hc),orbitSpeed:Bc("preserve",Hc),orbitRevolution:Bc("preserve",Hc),orbitRevolutionStyle:Bc("preserve",Hc),orbitEccentricity:Bc("preserve",Hc),orbitShowRings:Bc("preserve",Hc),orbitAnimated:Bc("preserve",Hc),customNetworkLayout:Bc("preserve",Hc),layoutConfig:Bc("preserve",Hc),nodeSize:Bc("preserve",Xc),nodeSizeRange:Bc("preserve",Xc),colorByDepth:Bc("preserve",Xc),nodeLabel:Bc("preserve",Gc),showLabels:Bc("preserve",Gc),labelMode:Bc("preserve",Gc),nodeStyle:Bc("preserve",qc),edgeStyle:Bc("preserve",qc),colorBy:Bc("preserve",qc),colorScheme:Bc("preserve",qc),themeCategorical:Bc("preserve",qc),themeSemantic:Bc("preserve",qc),edgeColorBy:Bc("preserve",qc),edgeOpacity:Bc("preserve",qc),showParticles:Bc("preserve",qc),particleStyle:Bc("preserve",qc),decay:Bc("preserve",qc),pulse:Bc("preserve",qc),thresholds:Bc("preserve",qc),staleness:Bc("preserve",qc),layoutSelection:Bc("preserve",qc),clock:Bc("preserve",Vc),random:Bc("preserve",Vc),seed:Bc("preserve",Vc),tensionConfig:Bc("preserve",Vc),transition:Bc("preserve",Vc),introAnimation:Bc("preserve",Vc),onLayoutError:Bc("preserve",Vc),__skipForceSimulation:Bc("preserve",Vc),__hierarchyRoot:Bc("preserve",Vc),__orbitState:Bc("preserve",Vc),__previousPositions:Bc("preserve",Vc)},Kc=Bc("preserve",Hc),Qc=class{constructor(){this.tracker=new Dt}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}},Oc)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Fc):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const r of e){const e=Uc[r]??Kc;"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)}};function Zc(e,t){const n=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>n&&_e(n,e)||"#4e79a7":t=>{if(n){const e=_e(n,t);if(e)return e}let r=0;for(let e=0;t.length>e;e++)r=31*r+t.charCodeAt(e)|0;return e[Math.abs(r)%e.length]??"#4e79a7"}}var Jc=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 Qc,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={...il,...e.tensionConfig},e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new al(2e3))}currentTime(){return this.config.clock?.()??je()}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 r=[...new Set([...Object.keys(t),...Object.keys(n)])].filter(e=>t[e]!==n[e]);this.config=n,this.tensionConfig={...il,...n.tensionConfig},!n.showParticles||"sankey"!==n.chartType&&!n.customNetworkLayout||this.particlePool||(this.particlePool=new al(2e3)),this.updateResults.recordConfig(r)}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,r){const{nodeIDAccessor:o="id",sourceAccessor:i="source",targetAccessor:s="target",valueAccessor:a="value"}=this.config,l="function"==typeof o?o:e=>e[o],c="function"==typeof i?i:e=>e[i],u="function"==typeof s?s:e=>e[s],h="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,{...Nc(e),data:t})}for(let e=0;t.length>e;e++){const n=t[e],r=c(n)+"",o=u(n)+"",i=h(n),s=null==i?NaN:Number(i),a=Number.isFinite(s)?s:1;this.nodes.has(r)||this.nodes.set(r,{...Nc(r),data:n}),this.nodes.has(o)||this.nodes.set(o,{...Nc(o),data:n});const l=`${r}\0${o}\0${e}`,d={source:r,target:o,value:a,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:l};n&&"object"==typeof n&&Dc(n.bezier)&&(d.bezier=n.bezier),this.edges.set(l,d)}r?.deferLayout||this.runLayout(n),this.updateResults.recordData("replace",e.length+t.length)}ingestBoundedWithResult(e,t,n,r){return this.ingestBounded(e,t,n,r),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:r}=e,o=0===this.nodes.size;let i=!1;const s=this.currentTime();this.lastIngestTime=s,this._decaySortedNodes=null,this._networkDecayCache=null,this.nodes.has(t)||(this.nodes.set(t,Nc(t)),this.nodeTimestamps.set(t,s),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,Nc(n)),this.nodeTimestamps.set(n,s),this.tension+=this.tensionConfig.newNode,i=!0);const a=this.edgeKey(t,n),l=this.edges.get(a);let c=!1;l?(l.value+=r,this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(a,{source:t,target:n,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.newEdge,i=!0);const u=o||i||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=Ec(this.config.chartType);if(!t)return;let n=Array.from(this.nodes.values());const r=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,r,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;r.length>e;e++){const t=r[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 o=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||o.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=o,this.saveTargetPositions();const i=n.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),s=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&&s>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:s}}else i&&s>0&&(this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:s});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:r,baseStyles:o,selection:i}){const s=!(!n&&!r);if(n)for(const t of e){const e=o.get(t)??t.style,r=n(t,i);t.style=r?{...e,...r}:e}if(r)for(const e of t){const t=o.get(e)??e.style,n=r(e,i);e.style=n?{...t,...n}:t}return s}({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:r,edges:o,previousResult:i,revision:s}){const a=function(e,t,n=we){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=Object.values(e).filter(e=>"string"==typeof e&&e.length>0);if(t.length>0)return t}if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=ke[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}(e.colorScheme,e.themeCategorical,ae),l={nodes:r,edges:o,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:Zc(a,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};try{return{kind:"success",result:t(l)}}catch(t){const n=null!==i,r=mt("network",t,n,s);"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",t);try{e.onLayoutError?.(r)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:r,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 yt({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=Ec(this.config.chartType);if(!t)return void this._sceneNodesRevision++;const n=t.hierarchical?Array.from(this.nodes.values()):this.nodesArray,r=t.hierarchical?Array.from(this.edges.values()):this.edgesArray,{sceneNodes:o,sceneEdges:i,labels:s}=t.buildScene(n,r,this.config,e);this.sceneNodes=o,this.sceneEdges=i,this.labels=s,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 r=Array(t);let o=0;for(const e of this.sceneNodes)"circle"===e.type&&(r[o++]=e);this._nodeQuadtree=(0,Lc.quadtree)().x(e=>e.cx).y(e=>e.cy).addAll(r)}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=Ec(this.config.chartType);return!!e?.supportsAnimation&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=Ec(this.config.chartType);if(!n?.tick)return!1;const r=n.hierarchical?Array.from(this.nodes.values()):this.nodesArray,o=n.hierarchical?Array.from(this.edges.values()):this.edgesArray;return n.tick(r,o,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=Ce(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=Re(e._prevX0,e._targetX0,n),e.x1=Re(e._prevX1,e._targetX1,n),e.y0=Re(e._prevY0,e._targetY0,n),e.y1=Re(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=Re(e._prevY0,e._targetY0,n),e.y1=Re(e._prevY1,e._targetY1,n),e.sankeyWidth=Re(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 r="string"==typeof e.source?t.get(e.source):e.source,o="string"==typeof e.target?t.get(e.target):e.target;!r||!o||(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))),r=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-r,y:n.targetY},{x:n.targetX-.66*r,y:n.targetY},{x:n.targetX-.33*r,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let r;r="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 o=[];for(let e=0;r.length-1>e;e++){const t=r[e],n=r[e+1],i=n.x-t.x,s=n.y-t.y;o.push([t,{x:t.x+i/3,y:t.y+s/3},{x:t.x+2*i/3,y:t.y+2*s/3},n])}return{circular:!0,segments:o,halfWidth:t}}(e):function(e,t,n,r=.5){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,s=n.x0,a=(0,$c.interpolateNumber)(i,s);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:a(r)},{x:e.y1,y:a(1-r)},{x:e.y1,y:s}],halfWidth:o}}const i=t.x1,s=n.x0,a=(0,$c.interpolateNumber)(i,s);return{circular:!1,points:[{x:i,y:e.y0},{x:a(r),y:e.y0},{x:a(1-r),y:e.y1},{x:s,y:e.y1}],halfWidth:o}}(e,r,o,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,r=t.color??"rgba(255,255,255,0.6)",o=t.glowRadius??4,{now:i}=e;for(const t of e.sceneNodes){const s=t.id;if(!s)continue;const a=e.nodeTimestamps.get(s);if(!a)continue;const l=i-a;n>l&&(t._pulseIntensity=1-l/n,t._pulseColor=r,t._pulseGlowRadius=o)}for(const t of e.sceneEdges){const o=t.datum;if(!o)continue;const s="object"==typeof o.source?o.source?.id:o.source,a="object"==typeof o.target?o.target?.id:o.target;if(!s||!a)continue;const l=e.edgeTimestamps.get(`${s}\0${a}`);if(!l)continue;const c=i-l;n>c&&(t._pulseIntensity=1-c/n,t._pulseColor=r)}}({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 r=e.cache.ageMap;for(const o of e.sceneNodes){const e=o.id;if(!e)continue;const i=r.get(e);if(void 0===i)continue;const s=We(t,i,n);o.style={...o.style,opacity:(o.style?.opacity??1)*s}}}({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===Wc&&(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>=zc)return;const n=1-t/zc;for(const t of e.sceneNodes){const r=t.id;r&&e.addedNodes.has(r)&&(t._pulseIntensity=Math.max(t._pulseIntensity??0,n),t._pulseColor=Wc,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&&zc>n-t}(this.addedNodes,this.lastTopologyChangeTime)}applyThresholds(e){!function(e){const t=e.thresholds;if(!t)return;const n=t.warningColor??"#f59e0b",r=t.criticalColor??"#ef4444",o=!1!==t.pulse;for(const i of e.sceneNodes){const s=i.id;if(!s)continue;const a=e.nodes.get(s);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=r,c&&(i.style={...i.style,fill:c},o&&(i._pulseIntensity=.6+.4*Math.sin(e.now/300),i._pulseColor=c,i._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 r=n.data?{...n.data}:{};return n.data=t(n.data??{}),this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",1),r}updateEdge(e,t,n){const r=this.config.valueAccessor,o="function"==typeof r?r:r?e=>e[r]:e=>e.value,i=[];for(const[,r]of this.edges)if(("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t){i.push(r.data?{...r.data}:{}),r.data=n(r.data??{});const e=o(r.data);null!=e&&(r.value=Number(e))}return i.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",i.length)):this.updateResults.recordNoop("update"),i}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 r="function"==typeof t?t:e=>e?.[t];for(const[t,o]of this.edges)o.data&&r(o.data)===e&&n.push(t)}else for(const[r,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t&&n.push(r);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")}};Jc.QUADTREE_THRESHOLD=500;var eu=Jc;Tt(eu);var tu=p(require("react")),nu=require("react/jsx-runtime");function ru(e){const{width:t,height:n,totalWidth:r,totalHeight:o,margin:i,labels:s,title:a,legend:l,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d,legendPosition:f="right",legendLayout:y,foregroundGraphics:p,sceneNodes:g,annotations:m,onAnnotationActivate:x,onObservation:v,chartId:b,chartType:k,autoPlaceAnnotations:w,svgAnnotationRules:A}=e,S=go({onAnnotationActivate:x,onObservation:v,chartId:b,chartType:k}),M=tu.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 r=Tn(e.glyph,e.size);return{x:t+r.centerDx,y:n+r.centerDy,r:Math.max(1,r.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,ut(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]),_=tu.useMemo(()=>m&&w?Ho({annotations:m,context:M,..."object"==typeof w?w:{}}):m,[m,w,M]),C=tu.useMemo(()=>Mo(),[]),P=_?So(_.filter(e=>"widget"!==e.type),C,A,M):null,R=!0===_?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return(0,nu.jsxs)(nu.Fragment,{children:[R&&(0,nu.jsx)("style",{children:ao},"annotation-widget-disclosure-style"),(0,nu.jsxs)("svg",{role:"img",width:r,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[(0,nu.jsx)("title",{children:"string"==typeof a?a:"Network Chart"}),(0,nu.jsx)("desc",{children:"string"==typeof a?a+" (network data visualization)":"Network data visualization"}),(0,nu.jsxs)("g",{transform:`translate(${i.left},${i.top})`,children:[s.map((e,t)=>(0,nu.jsx)("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)),P,p]}),a&&"string"==typeof a?(0,nu.jsx)("text",{x:r/2,y:22,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:a}):a?(0,nu.jsx)("foreignObject",{x:0,y:0,width:r,height:i.top,children:a}):null,Lr({legend:l,totalWidth:r,totalHeight:o,margin:i,legendPosition:f,title:a,legendLayout:y,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d})]}),_?.filter(e=>"widget"===e.type&&e.nodeId&&g).map((e,t)=>{const n=!0===e._annotationDeferred,r=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(!r)return null;const o=i.left+(r.cx??(null!=r.x&&null!=r.w?r.x+r.w/2:r.x??0)),s=i.top+(r.cy??(null!=r.y&&null!=r.h?r.y+r.h/2:r.y??0)),a=e.dx??0,l=e.dy??-16,c=e.width??32,u=e.height??32,h=e.content??(0,nu.jsx)("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return(0,nu.jsx)("div",{...mo(e,S),className:n?"annotation-deferred":void 0,"data-annotation-disclosure":n?"deferred":void 0,style:{position:"absolute",left:o+a-c/2,top:s+l-u/2,width:c,height:u,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:h},"widget-"+t)})]})}ru.displayName="NetworkSVGOverlay";var ou=p(require("react")),iu=require("react/jsx-runtime"),su={position:"absolute",top:0,left:0,pointerEvents:"none"};function au({marks:e,margin:t,selection:n=null,overscan:r=400}){const o=ou.useRef(null),i=function(e,t,n){const[r,o]=ou.useState(null);return ou.useLayoutEffect(()=>{const e=t.current,n=function(e){let t=e?.parentElement??null;for(;t;){const{overflow:e,overflowX:n,overflowY:r}=window.getComputedStyle(t);if(/(auto|scroll|overlay)/.test(`${e} ${r} ${n}`))return t;t=t.parentElement}return null}(e);if(!e||!n)return void o(null);let r=0;const i=()=>{r=0;const t=n.getBoundingClientRect(),i=e.getBoundingClientRect();o(0!==t.width&&0!==t.height?{scroll:{left:t.left,top:t.top,right:t.right,bottom:t.bottom},originX:i.left,originY:i.top}:null)},s=()=>{0===r&&(r=window.requestAnimationFrame(i))};i(),n.addEventListener("scroll",s,{passive:!0});const a=new ResizeObserver(s);return a.observe(n),()=>{0!==r&&window.cancelAnimationFrame(r),n.removeEventListener("scroll",s),a.disconnect()}},[t,e,n]),ou.useMemo(()=>{if(!e||!r)return e;const{scroll:t,originX:o,originY:i}=r,s=t.left-n,a=t.right+n,l=t.top-n,c=t.bottom+n;return e.filter(e=>{const t=o+e.x,n=i+e.y;return!(s>t+e.width||t>a||l>n+e.height||n>c)})},[e,r,n])}(e,o,r);if(!e||0===e.length)return null;const s=(0,iu.jsx)("div",{className:"semiotic-network-html-marks",ref:o,style:{...su,transform:`translate(${t.left}px, ${t.top}px)`},children:(i??e).map(e=>(0,iu.jsx)("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?(0,iu.jsx)(yn,{value:n,children:s}):s}var lu=require("react/jsx-runtime");function cu({props:e,store:t,responsiveRef:n,size:r,margin:o,adjustedWidth:i,adjustedHeight:s,resolvedBackground:a,resolvedForeground:l}){const{chartType:c,nodes:u,edges:h,data:d,className:f,description:y,title:p,responsiveWidth:g,responsiveHeight:m,summary:x,background:v,renderMode:b,legend:k,legendPosition:w,legendLayout:A,legendHoverBehavior:S,legendClickBehavior:M,legendHighlightedCategory:_,legendIsolatedCategories:C,layoutSelection:P,annotations:R,onAnnotationActivate:j,annotationObservationCallback:T,onObservation:E,chartId:N,autoPlaceAnnotations:D,svgAnnotationRules:I}=e;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(c),n=e?d||(Array.isArray(h)?void 0:h):void 0;if(e&&n)t.ingestHierarchy(n,[i,s]),t.buildScene([i,s]);else{const e=L(u),n=Array.isArray(h)?L(h):[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[i,s]),t.buildScene([i,s]))}}const $=t?.sceneNodes??[],W=t?.sceneEdges??[],z=t?.labels??[];return(0,lu.jsxs)("div",{ref:n,className:"stream-network-frame"+(f?" "+f:""),role:"img","aria-label":y||("string"==typeof p?p:"Network chart"),style:{position:"relative",width:g?"100%":r[0],height:m?"100%":r[1]},children:[(0,lu.jsx)(xs,{summary:x}),(0,lu.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:r[0],height:r[1],style:{position:"absolute",left:0,top:0},children:[a&&(0,lu.jsx)("g",{transform:`translate(${o.left},${o.top})`,children:a}),(0,lu.jsxs)("g",{transform:`translate(${o.left},${o.top})`,children:[v&&(0,lu.jsx)("rect",{x:0,y:0,width:i,height:s,fill:v}),W.map((e,t)=>Ia({node:e,index:t,renderMode:b,fallback:()=>function(e,t){switch(e.type){case"line":return(0,Ai.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+t);case"bezier":{const n=e;return(0,Ai.jsx)("path",{d:n.pathD,fill:xi(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"ribbon":{const n=e;return(0,Ai.jsx)("path",{d:n.pathD,fill:xi(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"curved":{const n=e;return(0,Ai.jsx)("path",{d:n.pathD,fill:xi(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+t)}default:return null}}(e,t)})).filter(Boolean),$.map((e,t)=>Ia({node:e,index:t,renderMode:b,fallback:()=>function(e,t){switch(e.type){case"circle":{const n=e,r=Yn(n.style.fill)?qn(n.style.fill,`net-circle-${t}-hatch`):void 0;return(0,Ai.jsxs)(ki.Fragment,{children:[r&&(0,Ai.jsx)("defs",{children:r}),(0,Ai.jsx)("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:r?`url(#net-circle-${t}-hatch)`:xi(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-circle-"+t)}case"rect":{const n=e,r=Yn(n.style.fill)?qn(n.style.fill,`net-rect-${t}-hatch`):void 0;return(0,Ai.jsxs)(ki.Fragment,{children:[r&&(0,Ai.jsx)("defs",{children:r}),(0,Ai.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:r?`url(#net-rect-${t}-hatch)`:xi(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-rect-"+t)}case"arc":{const n=e,r=(0,wi.arc)().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(mi)||"",o=Yn(n.style.fill)?qn(n.style.fill,`net-arc-${t}-hatch`):void 0;return(0,Ai.jsxs)(ki.Fragment,{children:[o&&(0,Ai.jsx)("defs",{children:o}),(0,Ai.jsx)("path",{d:r,transform:`translate(${n.cx},${n.cy})`,fill:o?`url(#net-arc-${t}-hatch)`:xi(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-arc-"+t)}case"symbol":{const n=e,r=ct(n.symbolType,n.size,n.path);return(0,Ai.jsx)("path",{d:r,transform:n.rotation?`translate(${n.cx},${n.cy}) rotate(${180*n.rotation/Math.PI})`:`translate(${n.cx},${n.cy})`,fill:n.style.fill?xi(n.style.fill):"none",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-symbol-"+t)}case"glyph":return bi(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}(e,t)})).filter(Boolean),z.map((e,t)=>function(e,t){return(0,Ai.jsx)("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+t)}(e,t)).filter(Boolean)]})]}),(0,lu.jsx)(ru,{width:i,height:s,totalWidth:r[0],totalHeight:r[1],margin:o,labels:z,sceneNodes:$,title:p,legend:k,legendPosition:w,legendLayout:A,legendHoverBehavior:S,legendClickBehavior:M,legendHighlightedCategory:_,legendIsolatedCategories:C,foregroundGraphics:un(l,pn(t?.customLayoutOverlays,P??null)),annotations:R,onAnnotationActivate:j,onObservation:T??E,chartId:N,chartType:"StreamNetworkFrame",autoPlaceAnnotations:D,svgAnnotationRules:I,annotationFrame:0}),(0,lu.jsx)(au,{marks:t?.customLayoutHtmlMarks,margin:o,selection:P??null})]})}var uu=require("react/jsx-runtime"),hu=("undefined"!=typeof process&&process,{display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #666)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"}),du={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function fu(e,t,n,r){return!1===r||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?(0,uu.jsx)("div",{style:{...hu,width:t,height:n},children:r||"No data available"}):null}function yu(e,t,n,r){if(!e)return null;if(!1===r)return null;if(null!=r)return(0,uu.jsx)("div",{style:{width:t,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:r});const o=Math.min(5,Math.floor(n/40)),i=Math.max(8,Math.floor(n/(3*o))),s=Math.max(6,Math.floor(n/(2.5*o))),a=Math.floor((n-(o*(i+s)-s))/2);return(0,uu.jsx)("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:o},(e,n)=>(0,uu.jsx)("div",{className:"semiotic-loading-bar",style:{...du,position:"absolute",top:a+n*(i+s),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:i,opacity:.5+n%2*.2}},n))})}var pu={};function gu(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function mu(){if("undefined"!=typeof DOMException)return new DOMException("Force layout aborted","AbortError");const e=Error("Force layout aborted");return e.name="AbortError",e}var xu=class{constructor(e=function(){const e="string"==typeof pu.url&&pu.url?new URL("./forceLayoutWorker.js",pu.url):function(e){if("undefined"!=typeof __filename){const t=__filename.replace(/\\/g,"/"),n=t.startsWith("/")?t:"/"+t;return new URL("./"+e,"file:"+n)}throw Error("Cannot resolve module worker asset: "+e)}("forceLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-force-layout"})}()){this.nextRequestId=1,this.pending=new Map,this.dead=!1,this.worker=e,this.worker.onmessage=e=>{const t=e.data,n=t.requestId,r=null!=n?this.pending.get(n):this.pending.values().next().value;if(r){if(null!=n?this.pending.delete(n):this.pending.clear(),r.cleanup(),t.error){const e=Error(t.error.message);return e.name=t.error.name??"Error",t.error.stack&&(e.stack=t.error.stack),void r.reject(e)}r.resolve({positions:t.positions??{}})}},this.worker.onerror=e=>{this.rejectAll(Error(e.message||"Force layout worker failed")),this.terminate()}}get isDead(){return this.dead}request(e,t){if(this.dead)return Promise.reject(Error("Force layout worker session is closed"));if(t?.aborted)return Promise.reject(mu());const n=this.nextRequestId;this.nextRequestId+=1;const r={requestId:n,request:e};return new Promise((e,o)=>{const i=()=>{this.pending.delete(n),t?.removeEventListener("abort",i),o(mu())},s=()=>t?.removeEventListener("abort",i);this.pending.set(n,{cleanup:s,reject:o,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(r)}catch(e){this.pending.delete(n),s(),o(e instanceof Error?e:Error(e+""))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(Error("Force layout worker terminated")),this.worker.terminate())}rejectAll(e){for(const t of this.pending.values())t.cleanup(),t.reject(e);this.pending.clear()}},vu=null;var bu=require("react/jsx-runtime"),ku=/^(value|amount|total|count|weight|score)$/i;function wu({data:e}){if("edge"===e.nodeOrEdge){const t=e.data;return t?(0,bu.jsxs)("div",{className:"semiotic-tooltip",style:Ls,children:[(0,bu.jsxs)("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&&(0,bu.jsxs)("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 r=n;for(;r;){const n=r.data?.name??r.data?.id??t.id;null!=n&&e.unshift(n+""),r=r.parent}e.length>1&&e.shift();const o=e.length-1;return(0,bu.jsxs)("div",{className:"semiotic-tooltip",style:Ls,children:[(0,bu.jsx)("div",{children:e.map((e,t)=>(0,bu.jsxs)("span",{children:[t>0&&(0,bu.jsx)("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),t===o?(0,bu.jsx)("strong",{children:e}):(0,bu.jsx)("span",{style:{opacity:.7},children:e})]},t))}),null!=t.value&&t.value>0&&(0,bu.jsx)("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof t.value?t.value.toLocaleString():t.value+""})]})}const r=(t.sourceLinks?.length||0)+(t.targetLinks?.length||0),o=(t.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(t.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0),i=Es(t.data??t),s=null!=i.title?i.title+"":t.id,a=i.entries.some(e=>ku.test(e.key));return(0,bu.jsxs)("div",{className:"semiotic-tooltip",style:Ls,children:[(0,bu.jsx)("div",{style:{fontWeight:600},children:s}),i.entries.map(e=>{return(0,bu.jsxs)("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&&(0,bu.jsxs)("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]}),r>0&&(0,bu.jsxs)("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",r,o!==r&&` (weighted: ${o.toLocaleString()})`]})]})}function Au(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function Su(e,t){if(!t.pathD)return;e.save();const n=Au(t);if(t.style.fill&&"none"!==t.style.fill){const r=t._gradient;if(r){const n=e.createLinearGradient(r.x0,0,r.x1,0),o=t.style.fillOpacity??t.style.opacity??.5,i="string"==typeof t.style.fill?t.style.fill:"#999",s=On(e,i)||i;n.addColorStop(0,1===r.from?s:"transparent"),n.addColorStop(1,1===r.to?s:"transparent"),e.fillStyle=n,e.globalAlpha=o}else e.fillStyle=Kn(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=On(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 Mu(e,t){e.save();const n=t.style.stroke||"#999";e.strokeStyle=On(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 _u(e,t){if(!t.pathD)return;e.save();const n=Au(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=Kn(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=On(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 Cu(e,t){if(!t.pathD)return;e.save();const n=Au(t),r=t.style.stroke||"#999";e.strokeStyle=On(e,r)||r,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=Kn(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??.1,e.fill(n)),e.restore()}wu.ownsChrome=!0;var Pu=new Map;function Ru(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=Pu.get(t);return n||(n=new Path2D(ct(e.symbolType,e.size)),Pu.size>256&&Pu.clear(),Pu.set(t,n)),n}catch{return null}}function ju(e){const{sceneNodes:t,nodes:n,nodeColorMap:r,colorScheme:o}=e;for(const e of t)e.id&&"string"==typeof e.style?.fill&&r.set(e.id,e.style.fill);const i=Array.isArray(o)?o:we,s=Array.from(n);for(let e=0;s.length>e;e++){const t=s[e];r.has(t.id)||r.set(t.id,i[e%i.length])}return s.length}function Tu(e,t,n,r=30){switch(e.type){case"circle":return function(e,t,n,r=30){const o=t-e.cx,i=n-e.cy,s=Math.sqrt(o*o+i*i);return s>bn(e.r,r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:s}}(e,t,n,r);case"rect":return function(e,t,n){const r=vn(t,n,e);return r.hit?{type:"node",datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}(e,t,n);case"arc":return function(e,t,n){const r=t-e.cx,o=n-e.cy,i=Math.sqrt(r*r+o*o);if(e.innerR-2>i||i>e.outerR+2)return null;const s=An(Math.atan2(o,r)),a=An(e.startAngle),l=An(e.endAngle);if(a>l?s>=a||l>=s:s>=a&&l>=s){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}(e,t,n);case"symbol":return function(e,t,n,r=30){const o=t-e.cx,i=n-e.cy,s=Math.sqrt(o*o+i*i);return s>bn(ut(e.size),r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:s}}(e,t,n,r);case"glyph":return function(e,t,n,r=30){if(null==e.datum)return null;const o=Tn(e.glyph,e.size),i=e.cx+o.centerDx,s=e.cy+o.centerDy,a=t-i,l=n-s,c=Math.sqrt(a*a+l*l);return c>bn(o.radius,r)?null:{type:"node",datum:e.datum,x:i,y:s,distance:c}}(e,t,n,r);default:return null}}var Eu=null,Lu=null;function Nu(){return Lu||((Eu=document.createElement("canvas")).width=1,Eu.height=1,Lu=Eu.getContext("2d")),Lu}function Du(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 Iu(e,t,n){switch(e.type){case"bezier":return function(e,t,n){if(!e.pathD)return null;const r=Du(e),o=Nu();if(!r||!o)return null;try{if(o.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const s=o.isPointInStroke(r,t,n);if(o.lineWidth=i,s)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 r=e.x2-e.x1,o=e.y2-e.y1,i=r*r+o*o;if(0===i)return null;let s=((t-e.x1)*r+(n-e.y1)*o)/i;s=Math.max(0,Math.min(1,s));const a=e.x1+s*r,l=e.y1+s*o,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 r=Du(e),o=Nu();if(!r||!o)return null;try{if(o.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const s=o.isPointInStroke(r,t,n);if(o.lineWidth=i,s)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);default:return null}}function $u(e){const{clientX:t,clientY:n,canvasRect:r,margin:o,adjustedWidth:i,adjustedHeight:s,sceneNodes:a,sceneEdges:l,nodeQuadtree:c,maxNodeRadius:u,hitRadius:h=30}=e,d=t-r.left-o.left,f=n-r.top-o.top;if(0>d||d>i||0>f||f>s)return{kind:"miss-outside"};const y=function(e,t,n,r,o=30,i,s=0){let a=null,l=o,c=1/0;if(i){const e=Ln(i,n,r,o,s,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(i&&"circle"===t.type)continue;const e=Tu(t,n,r,o);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=Iu(e,n,r);t&&l>t.distance&&(a=t,l=t.distance)}return a}(a,l,d,f,h,c,u);return y?{kind:"hit",hover:_s(y.datum||{},y.x,y.y,{nodeOrEdge:y.type})}:{kind:"miss"}}var Wu=require("react"),zu="StreamNetworkFrame",Ou=require("react/jsx-runtime"),Fu={top:20,right:80,bottom:20,left:80},Bu={top:40,right:40,bottom:40,left:40},Yu=new Set(["chord","force","circlepack","orbit"]),Hu=[800,600],Xu=(0,ol.memo)((0,ol.forwardRef)(function(e,t){const{chartType:n,nodes:r,edges:o,data:i,initialEdges:s,nodeIDAccessor:a="id",sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:u="value",edgeIdAccessor:h,childrenAccessor:d,hierarchySum:f,orientation:y="horizontal",nodeAlign:p="justify",nodePaddingRatio:g=.05,nodeWidth:m=15,iterations:x=300,forceStrength:v=.1,layoutExecution:b="auto",layoutLoadingContent:k,onLayoutStateChange:w,padAngle:A=.01,groupWidth:S=20,sortGroups:M,edgeSort:_,treeOrientation:C="vertical",edgeType:P="curve",padding:R,paddingTop:j,tensionConfig:T,showParticles:E=!1,particleStyle:N,renderMode:D,nodeStyle:I,edgeStyle:$,colorBy:W,colorScheme:O="category10",edgeColorBy:F="source",edgeOpacity:B=.5,colorByDepth:Y=!1,nodeSize:H=8,nodeSizeRange:X=[5,20],nodeLabel:q,showLabels:G=!0,labelMode:V,size:U=Hu,responsiveWidth:K,responsiveHeight:Q,margin:Z,className:J,background:ee,enableHover:te=!0,tooltipContent:ne,customHoverBehavior:re,customClickBehavior:oe,onObservation:ie,annotationObservationCallback:se,chartId:ae,onTopologyChange:le,annotations:ce,onAnnotationActivate:ue,autoPlaceAnnotations:he,svgAnnotationRules:de,legend:fe,legendPosition:ye,legendLayout:pe,legendHoverBehavior:ge,legendClickBehavior:me,legendHighlightedCategory:xe,legendIsolatedCategories:ve,title:be,foregroundGraphics:ke,backgroundGraphics:Ae,decay:Se,pulse:Me,transition:_e,animate:Ce,staleness:Pe,frameScheduler:Re,clock:je,random:Te,seed:Ee,paused:Le=!1,suspendWhenHidden:Ne=!0,thresholds:De,accessibleTable:Ie=!0,description:$e,summary:We,orbitMode:ze,orbitSize:Oe,orbitSpeed:Fe,orbitRevolution:Be,orbitRevolutionStyle:Ye,orbitEccentricity:He,orbitShowRings:Xe,orbitAnimated:qe,customNetworkLayout:Ge,onLayoutError:Ve,layoutConfig:Ue,layoutSelection:Ke}=e,Qe=Yu.has(n)?Bu:Fu,Ze=(0,ol.useRef)(!0),Je=Gs({sizeProp:U,responsiveWidth:K,responsiveHeight:Q,userMargin:Z,marginDefault:Qe,title:be,legend:fe,legendPosition:ye,foregroundGraphics:ke,backgroundGraphics:Ae,animate:Ce,transitionProp:_e,frameScheduler:Re,clock:je,random:Te,seed:Ee,paused:Le,suspendWhenHidden:Ne,themeDirtyRef:Ze}),{reducedMotionRef:et,responsiveRef:tt,size:nt,margin:rt,adjustedWidth:ot,adjustedHeight:it,resolvedForeground:st,resolvedBackground:at,transition:lt,introEnabled:ct,tableId:ut,rafRef:ht,renderFnRef:dt,scheduleRender:ft,frameRuntime:yt,currentTheme:pt}=Je,gt=ji(),mt=Ni(),xt=(0,ol.useMemo)(()=>L(r),[r]),vt=(0,ol.useMemo)(()=>Array.isArray(o)?L(o):o,[o]),bt=(0,ol.useMemo)(()=>({...il,...T}),[T]),kt=(0,ol.useMemo)(()=>({...sl,...N}),[N]),wt=(0,ol.useMemo)(()=>{return{chartType:(e={chartType:n,clock:yt.now,random:Te,seed:Ee,nodeIDAccessor:a,sourceAccessor:l,targetAccessor:c,valueAccessor:u,edgeIdAccessor:h,childrenAccessor:d,hierarchySum:f,orientation:y,nodeAlign:p,nodePaddingRatio:g,nodeWidth:m,iterations:x,forceStrength:v,padAngle:A,groupWidth:S,sortGroups:M,edgeSort:_,treeOrientation:C,edgeType:P,padding:R,paddingTop:j,tensionConfig:bt,showParticles:E,particleStyle:kt,nodeStyle:I,edgeStyle:$,nodeLabel:q,showLabels:G,labelMode:V,colorBy:W,colorScheme:O,edgeColorBy:F,edgeOpacity:B,colorByDepth:Y,nodeSize:H,nodeSizeRange:X,decay:Se,pulse:Me,transition:lt,introAnimation:ct,staleness:Pe,thresholds:De,orbitMode:ze,orbitSize:Oe,orbitSpeed:Fe,orbitRevolution:Be,orbitRevolutionStyle:Ye,orbitEccentricity:He,orbitShowRings:Xe,orbitAnimated:qe,customNetworkLayout:Ge,onLayoutError:Ve,layoutConfig:Ue,currentTheme:pt}).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:z(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,yt.now,Te,Ee,a,l,c,u,h,d,f,y,p,g,m,x,v,A,S,M,_,C,P,R,j,bt,E,kt,I,$,q,G,V,W,O,F,B,Y,H,X,Se,Me,lt,ct,Pe,De,ze,Oe,Fe,Be,Ye,He,Xe,qe,Ge,Ve,Ue,pt]),At=Ii(wt),St=Ii({chartType:(Mt={chartType:n,nodeIDAccessor:a,sourceAccessor:l,targetAccessor:c,valueAccessor:u,edgeIdAccessor:h,childrenAccessor:d,hierarchySum:f,orientation:y,nodeAlign:p,nodePaddingRatio:g,nodeWidth:m,iterations:x,forceStrength:v,padAngle:A,groupWidth:S,sortGroups:M,edgeSort:_,treeOrientation:C,edgeType:P,padding:R,paddingTop:j,random:Te,seed:Ee,tensionConfig:bt,customNetworkLayout:Ge,orbitMode:ze,orbitSize:Oe,orbitEccentricity:He}).chartType,nodeIDAccessor:Mt.nodeIDAccessor,sourceAccessor:Mt.sourceAccessor,targetAccessor:Mt.targetAccessor,valueAccessor:Mt.valueAccessor,edgeIdAccessor:Mt.edgeIdAccessor,childrenAccessor:Mt.childrenAccessor,hierarchySum:Mt.hierarchySum,orientation:Mt.orientation,nodeAlign:Mt.nodeAlign,nodePaddingRatio:Mt.nodePaddingRatio,nodeWidth:Mt.nodeWidth,iterations:Mt.iterations,forceStrength:Mt.forceStrength,padAngle:Mt.padAngle,groupWidth:Mt.groupWidth,sortGroups:Mt.sortGroups,edgeSort:Mt.edgeSort,treeOrientation:Mt.treeOrientation,edgeType:Mt.edgeType,padding:Mt.padding,paddingTop:Mt.paddingTop,random:Mt.random,seed:Mt.seed,tensionConfig:Mt.tensionConfig,customNetworkLayout:Mt.customNetworkLayout,orbitMode:Mt.orbitMode,orbitSize:Mt.orbitSize,orbitEccentricity:Mt.orbitEccentricity});var Mt;const _t=(0,ol.useRef)(0),Ct=(0,ol.useRef)(0),Pt=(0,ol.useRef)(!1),Rt=(0,ol.useRef)(null);Rt.current||(Rt.current=new eu(At));const jt=an("StreamNetworkFrame"),Tt=(0,ol.useCallback)((e,t,n=!1)=>function(e,t,n,r=!1,o=!1){const i=e.beforeCompute(t.getLastUpdateResult(),r);n(),e.afterCompute(i,!0,o)}(jt.current,e,()=>e.buildScene(t),n),[jt]),[Et,Lt]=(0,ol.useState)(null),[Nt,Dt]=(0,ol.useState)(0),[It,$t]=(0,ol.useState)(0),[Wt,zt]=(0,ol.useState)(!1),[Ot,Ft]=(0,ol.useState)(!1),Bt=(0,ol.useRef)(0),Yt=(0,ol.useRef)(null),Ht=(0,ol.useRef)(!1),Xt=(0,ol.useRef)(w);Xt.current=w;const qt=(0,ol.useRef)(At);qt.current=At;const Gt=(0,ol.useRef)(null),Vt=(0,ol.useRef)(new Map),Ut=(0,ol.useRef)(0),Kt=(0,ol.useCallback)(e=>function(e){const{node:t,colorBy:n,colorScheme:r,nodeColorMap:o,colorIndexRef:i}=e;if("function"==typeof n)return n(t)+"";if("string"==typeof n&&t.data){const e=t.data[n];if(void 0!==e){if(!o.has(e+"")){const t=Array.isArray(r)?r:we;o.set(e+"",t[i.current++%t.length])}return o.get(e+"")}}if(o.has(t.id))return o.get(t.id);const s=Array.isArray(r)?r:we,a=n?s[i.current++%s.length]:s[0];return o.set(t.id,a),a}({node:e,colorBy:W,colorScheme:O,nodeColorMap:Vt.current,colorIndexRef:Ut}),[W,O]),Qt=(Zt=pt,Zt?.colors?.border||Zt?.colors?.secondary||Zt?.colors?.primary||"#999");var Zt;const Jt=(0,ol.useCallback)(e=>function(e,t){return e?"object"==typeof e?e:t?.get(e)??null:null}(e,Rt.current?.nodes),[]),en=(0,ol.useCallback)(e=>function(e){const{edge:t,edgeColorBy:n,getNodeColor:r,resolveEndpoint:o,fallback:i}=e;if("function"==typeof n)return n(t);const s=o(t.source),a=o(t.target);return"target"===n&&a?r(a):s?r(s):i}({edge:e,edgeColorBy:F,getNodeColor:Kt,resolveEndpoint:Jt,fallback:Qt}),[F,Kt,Qt,Jt]),tn=(0,ol.useCallback)(e=>function(e){const{edge:t,particleStyleColor:n,particleColorBy:r,hasExplicitParticleColorBy:o,getEdgeColor:i,getNodeColor:s,resolveEndpoint:a,fallback:l}=e;if("function"==typeof n){const e=a(t.source);return e?n(t,e):l}if(!o)return i(t);const c=r,u=a(t.source),h=a(t.target);return"target"===c&&h?s(h):u?s(u):l}({edge:e,particleStyleColor:kt.color,particleColorBy:kt.colorBy,hasExplicitParticleColorBy:!!N?.colorBy,getEdgeColor:en,getNodeColor:Kt,resolveEndpoint:Jt,fallback:Qt}),[N?.colorBy,kt.color,kt.colorBy,Kt,en,Qt,Jt]),nn=function(e,t,n,r,o){return("sankey"===e||t)&&n||r||o}(n,!!Ge,E,!!Me,Rt.current?.isAnimating??!1);mn(Rt,At,Ze,ft),xn(Rt,Ke,Ze,ft),(0,ol.useEffect)(()=>{const e=Rt.current;e&&(Tt(e,[ot,it]),Ut.current=ju({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Vt.current,colorScheme:O}),Ze.current=!0,ft())},[pt,ot,it,Tt,ft,O]);const rn=(0,ol.useCallback)(()=>{const e=Rt.current;if(e&&(e.runLayout([ot,it]),Tt(e,[ot,it]),Ze.current=!0,Ut.current=ju({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Vt.current,colorScheme:O}),Dt(e.layoutVersion),le)){const{nodes:t,edges:n}=e.getLayoutData();le(t,n)}},[ot,it,Tt,le,O]),on=(0,ol.useCallback)(e=>{if(null==e||"object"!=typeof e)return;const t=Rt.current;t&&(t.ingestEdge(e)&&rn(),ft())},[rn,ft]),sn=(0,ol.useCallback)(e=>{const t=Rt.current;if(!t)return;let n=!1;for(const r of e)null!=r&&"object"==typeof r&&t.ingestEdge(r)&&(n=!0);n&&rn(),ft()},[rn,ft]),cn=(0,ol.useCallback)(()=>{Rt.current?.clear(),Vt.current.clear(),Ut.current=0,Dt(Rt.current?.layoutVersion??0),Lt(null),Gt.current=null,Ze.current=!0,ft()},[ft]),hn=(0,ol.useCallback)(()=>{const e=Rt.current;e&&(e.tension+=999,rn(),ft())},[rn,ft]);(0,ol.useImperativeHandle)(t,()=>({push:on,pushMany:sn,removeNode:e=>{const t=Rt.current?.removeNode(e)??!1;if(t){const t=Gt.current?.data?"function"==typeof a?a(Gt.current.data):Gt.current.data[a]:void 0;Gt.current&&"node"===Gt.current.nodeOrEdge&&t===e&&(Gt.current=null,Lt(null)),Vt.current.delete(e),rn(),Ze.current=!0,ft()}return t},removeEdge:(e,t)=>{const n=Rt.current?.removeEdge(e,t)??!1;if(n){if(Gt.current&&"edge"===Gt.current.nodeOrEdge){const n=Gt.current.data;let r;r=void 0!==t?("object"==typeof n?.source?n.source.id:n?.source)===e&&("object"==typeof n?.target?n.target.id:n?.target)===t:!h||!n||("function"==typeof h?h:e=>e?.[h])(n)===e,r&&(Gt.current=null,Lt(null))}rn(),Ze.current=!0,ft()}return n},updateNode:(e,t)=>{const n=Rt.current?.updateNode(e,t)??null;return n&&(Ze.current=!0,ft()),n},updateEdge:(e,t,n)=>{const r=Rt.current?.updateEdge(e,t,n)??[];return r.length>0&&(rn(),Ze.current=!0,ft()),r},clear:cn,getTopology:()=>Rt.current?.getLayoutData()??{nodes:[],edges:[]},getCustomLayout:()=>Rt.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Rt.current?.lastCustomLayoutFailure??null,getTopologyDiff:()=>{const e=Rt.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:hn,getTension:()=>Rt.current?.tension??0}),[on,sn,cn,hn,a,rn,ft,h]);const dn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(n),fn=dn?i||(Array.isArray(o)?void 0:o):void 0;(0,ol.useEffect)(()=>{const e=Rt.current;if(!e)return;const t=++Bt.current;if(Yt.current?.abort(),Yt.current=null,dn&&fn)e.ingestHierarchy(fn,[ot,it]),Tt(e,[ot,it]),Ft(!1),Xt.current?.("ready"),Ze.current=!0,ft();else{const i=xt,s=Array.isArray(vt)?vt:[];if(0===i.length&&0===s.length)return null==r&&null==o||0>=e.nodes.size&&0>=e.edges.size||cn(),Ft(!1),void Xt.current?.("ready");const a=[ot,it],l="force"===n&&!Ge&&gu()&&!Te&&function(e,t,n,r,o=4e4){return"sync"!==e&&("worker"===e||r*(t+n)>=o)}(b,i.length,s.length,x);if(l&&mt&&!Ht.current&&e.sceneNodes.length>0)return Ht.current=!0,Ft(!1),Xt.current?.("ready"),Ze.current=!0,void ft();if(l){const n=new AbortController;Yt.current=n;const r=e._lastPositionSnapshot;e.ingestBounded(i,s,a,{deferLayout:!0});const o=e.getLayoutData(),l=function(e,t,n,r,o){const i=hc(n.nodeSize,n.nodeSizeRange,e);return{kind:"frame",nodes:e.map(e=>{const t=o?.get(e.id);return{id:e.id,x:0!==e.x||0!==e.y?e.x:t?.x??0,y:0!==e.x||0!==e.y?e.y:t?.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:e.value,__forceRadius:i(e)}}),edges:t.map(e=>{const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id,r=e.data?.weight,o="number"==typeof r&&Number.isFinite(r)?r:e.value;return{source:t,target:n,value:e.value,y0:0,y1:0,sankeyWidth:0,weight:o}}),config:{chartType:"force",iterations:n.iterations,forceStrength:n.forceStrength,seed:n.seed},size:r}}(o.nodes,o.edges,qt.current,a,r);return Ft(!0),Xt.current?.("pending"),function(e,t){return gu()?t?.aborted?Promise.reject(mu()):(vu&&!vu.isDead||(vu=new xu),vu).request(e,t):Promise.reject(Error("Web Workers are unavailable"))}(l,n.signal).then(({positions:n})=>{t===Bt.current&&(e.applyForceLayoutPositions(n,a),Tt(e,a),Ut.current=ju({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Vt.current,colorScheme:O}),Ft(!1),Xt.current?.("ready"),Dt(e.layoutVersion),Ze.current=!0,ft())}).catch(n=>{"AbortError"!==n.name&&t===Bt.current&&(e.runLayout(a),Tt(e,a),Ut.current=ju({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Vt.current,colorScheme:O}),Ft(!1),Xt.current?.("error"),Dt(e.layoutVersion),Ze.current=!0,ft())}),()=>n.abort()}e.ingestBounded(i,s,a),Tt(e,a),Ft(!1),Xt.current?.("ready"),Ut.current=ju({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Vt.current,colorScheme:O}),Ze.current=!0,ft()}},[xt,vt,r,o,i,fn,dn,ot,it,St,b,x,mt,n,Ge,Te,ft,cn,O,Tt]),(0,ol.useEffect)(()=>{s&&s.length>0&&sn(s)},[s,sn]);const{customHoverBehavior:yn,customClickBehavior:gn}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:r}){return{customHoverBehavior:(0,Wu.useCallback)((t,o)=>{e?.(t,o),Ba({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:zu,chartId:r,context:o})},[e,n,r]),customClickBehavior:(0,Wu.useCallback)((e,o)=>{t?.(e,o),Ya({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:zu,chartId:r,context:o})},[t,n,r])}}({customHoverBehavior:re,customClickBehavior:oe,onObservation:ie,chartId:ae}),{hoverHandlerRef:vn,hoverLeaveRef:bn,onPointerMove:kn,onPointerLeave:wn}=Je,An=()=>!Ge||(Rt.current?.hasCustomRestyle??!1);vn.current=e=>{if(!te)return;const t=An(),n=En.current;if(!n)return;const r=Rt.current;if(!r)return;const o=$u({clientX:e.clientX,clientY:e.clientY,canvasRect:n.getBoundingClientRect(),margin:rt,adjustedWidth:ot,adjustedHeight:it,sceneNodes:r.sceneNodes,sceneEdges:r.sceneEdges,nodeQuadtree:r.nodeQuadtree,maxNodeRadius:r.maxNodeRadius});"hit"===o.kind?(Gt.current=o.hover,Lt(o.hover),yn&&(yn(o.hover),t&&(Ze.current=!0)),t&&ft()):Gt.current&&(Gt.current=null,Lt(null),yn&&(yn(null),t&&(Ze.current=!0)),t&&ft())},bn.current=()=>{if(Gt.current){const e=An();Gt.current=null,Lt(null),yn&&(yn(null),e&&(Ze.current=!0)),e&&ft()}};const Sn=(0,ol.useRef)(()=>{});Sn.current=e=>{if(xo(e.target))return;if(!oe&&!ie)return;const t=En.current;if(!t)return;const n=Rt.current;if(!n)return;const r=$u({clientX:e.clientX,clientY:e.clientY,canvasRect:t.getBoundingClientRect(),margin:rt,adjustedWidth:ot,adjustedHeight:it,sceneNodes:n.sceneNodes,sceneEdges:n.sceneEdges,nodeQuadtree:n.nodeQuadtree,maxNodeRadius:n.maxNodeRadius});"hit"===r.kind?gn(r.hover,{type:"activate",inputType:Oa(e.nativeEvent.pointerType)}):"miss"===r.kind&&gn(null)};const Mn=(0,ol.useCallback)(e=>Sn.current(e),[]),_n=(0,ol.useRef)(-1),Cn=(0,ol.useRef)(null),Pn=(0,ol.useRef)(-1),Rn=(0,ol.useCallback)(e=>{if(Fa(e))return;const t=Rt.current;if(!t)return;const n=()=>{_n.current=-1,Cn.current=null,Pn.current=-1,Gt.current=null,Lt(null),yn&&(yn(null),Ze.current=!0),ft()},r=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=Tn(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===r.length)return void(0>_n.current||n());const o=qa(r);let i=_n.current;if(o.flat.length>i||(n(),i=-1)," "===e.key&&i>=0){e.preventDefault();const t=o.flat[i];return void gn(_s(t.datum||{},t.x,t.y,{nodeOrEdge:"node"}),{type:"activate",inputType:"keyboard"})}if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),_n.current=0,Pn.current=-1;const t=o.flat[0];Cn.current={shape:t.shape,w:t.w,h:t.h};const n=_s(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Gt.current=n,Lt(n),yn&&(yn(n,{type:"focus",inputType:"keyboard"}),Ze.current=!0),void ft()}const s=Ga(o,i),a=function(e,t,n,r,o){const i=n.flat[t.flatIndex];if(!i)return Va(e,t,n);const s=i.datum?.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const r=function(e,t,n){let r=null,o=1/0;for(let i=0;e.flat.length>i;i++){const s=e.flat[i];if(s===t)continue;const a=s.x-t.x,l=s.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;o>u&&(o=u,r=i)}return r}(n,i,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up")??t.flatIndex;return r!==t.flatIndex&&(o.current=-1),r}case"Enter":{if(null==s)return t.flatIndex;const e=function(e,t){const n=e+"",r=[];for(const e of t){const t=e.datum??e,o=Qa(t.source),i=Qa(t.target),s=null!=o,a=null!=i;s&&o+""===n&&a?r.push(i+""):a&&i+""===n&&s&&r.push(o+"")}return r}(s,r);if(0===e.length)return t.flatIndex;const i=n.idToIdx.get(e[(o.current+1)%e.length])??-1;return 0>i?t.flatIndex:(o.current=-1,i)}default:{const r=Va(e,t,n);return null!==r&&r!==t.flatIndex&&(o.current=-1),r}}}(e.key,s,o,t.sceneEdges??[],Pn);if(null===a)return;if(e.preventDefault(),0>a)return void n();_n.current=a;const l=o.flat[a];Cn.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"};Gt.current=c,Lt(c),yn&&(yn(c,{type:"focus",inputType:"keyboard"}),Ze.current=!0),ft()},[gn,yn,ft]),jn=(0,ol.useCallback)(e=>{_n.current=-1,Cn.current=null,kn(e)},[kn]);dt.current=()=>{if(ht.current=null,!yt.isActive)return;const e=En.current;if(!e)return;const t=Rt.current;t&&function(e){const{canvas:t,store:n,sceneRevisionDiagnostics:r,size:o,margin:i,adjustedWidth:s,adjustedHeight:a,background:l,renderMode:c,hasBackgroundGraphics:u=!1,dirtyRef:h,lastFrameTimeRef:d,now:f,random:y,reducedMotion:p,showParticles:g,isContinuous:m,animate:x,decay:v,pulse:b,thresholds:k,staleness:w,particleStyle:A,getParticleColor:S,pendingAnnotationFrameRef:M,lastAnnotationFrameTimeRef:_,setAnnotationFrame:C,scheduleNextFrame:P}=e,R=t.getContext("2d");if(!R)return;const j=d.current?Math.min((f-d.current)/1e3,.1):.016;d.current=f;const T=n.advanceTransition(p?f+1e6:f),E=!p&&T,L=!p&&n.tickAnimation([s,a],j),N=h.current,D=r?.beforeCompute(n.getLastUpdateResult(),E),I=T||N||L;I&&n.buildScene([s,a]),D&&r?.afterCompute(D,I,!1);const $=g&&!p&&!!n.particlePool,W=!!((z={dirtyOrRebuilt:N,transitioning:E,animationTicked:L,continuous:$||m,liveEncoding:!!v||!!b||!!k||!1!==x&&n.hasActiveTopologyDiff||n.hasActivePulses||n.hasActiveThresholds,forced:n.consumeStylePaintPending()}).dirtyOrRebuilt||z.transitioning||z.animationTicked||z.continuous||z.liveEncoding||z.forced);var z;const O=!!w&&n.lastIngestTime>0&&f-n.lastIngestTime>(w?.threshold??5e3);if(W){const e=ea();if(!Js(t,o,i,e))return;if(R.clearRect(-i.left,-i.top,o[0],o[1]),Fi(R,{background:l,hasBackgroundGraphics:u,width:s,height:a}),v&&n.applyDecay(),b&&n.applyPulse(f),k&&n.applyThresholds(f),!1!==x&&n.applyTopologyDiff(f),O&&(R.globalAlpha=w?.dimOpacity??.5),Da({context:R,nodes:n.sceneEdges,renderMode:c,pixelRatio:e,paintBuiltIn:e=>function(e,t){for(const n of t)switch(n.type){case"bezier":Su(e,n);break;case"line":Mu(e,n);break;case"ribbon":_u(e,n);break;case"curved":Cu(e,n)}}(R,e)}),Da({context:R,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=Kn(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=On(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)),da(e,t),e.restore())}}(R,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=Kn(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=On(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),fa(e,t),e.restore())}}(R,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=Kn(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=On(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),e.restore()}}(R,t),function(e,t){const n=e.globalAlpha;for(const r of t){if("symbol"!==r.type)continue;const t=r;if(0>=t.size)continue;const o=Ru(t);if(!o)continue;e.save(),e.translate(t.cx,t.cy),t.rotation&&e.rotate(t.rotation);const i=t.style.opacity??1;t.style.fill&&(e.globalAlpha=n*i*(t.style.fillOpacity??1),e.fillStyle=Kn(e,t.style.fill,"#007bff"),e.fill(o)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*i,e.strokeStyle=On(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.stroke(o)),e.restore()}}(R,t),function(e,t){const n=e.globalAlpha;for(const r of t)"glyph"===r.type&&wa(e,r,r.cx,r.cy,n);e.globalAlpha=n}(R,t)}}),$&&!O){const e=n.edgesArray;if(e.length>0){!function(e,t,n,r,o=Math.random){const i=r.spawnRate??.1,s=r.maxPerEdge??50;for(let r=0;t.length>r;r++){const a=t[r];if(!a.bezier)continue;if(e.countForEdge(r)>=s)continue;const l=a.value*i*n*(a.bezier.circular?.3:1),c=Math.floor(l),u=l-c;let h=c;o()<u&&h++;for(let t=0;h>t&&e.countForEdge(r)<s;t++)e.spawn(r,o)}}(n.particlePool,e,j,A,y);const t=.5*(A.speedMultiplier??1);let r;if(A.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);r=e.map(e=>.3+(e.value||1)/t*1.7)}n.particlePool.step(j,t,e,r),function(e,t,n,r,o){const i=r.radius??3;e.globalAlpha=r.opacity??.7;for(let s=0;t.particles.length>s;s++){const a=t.particles[s];if(!a.active)continue;const l=n[a.edgeIndex];if(!l)continue;let c;c="string"==typeof r.color&&"inherit"!==r.color?r.color:o(l),e.fillStyle=On(e,c)||c,e.beginPath(),e.arc(a.x,a.y,i,0,2*Math.PI),e.fill()}e.globalAlpha=1}(R,n.particlePool,e,A,S)}}O&&(R.globalAlpha=1)}h.current=!1,(N||E||L)&&t.setAttribute("aria-label",ns(n.sceneNodes?.length??0,n.sceneEdges?.length??0,"Network chart"));const F=N||E||L||M.current;F&&f-_.current>=33?(C(e=>e+1),_.current=f,M.current=!1):M.current=!!F,(m||E||null!=n.transition||L||n.hasActivePulses||n.hasActiveThresholds||!1!==x&&n.hasActiveTopologyDiff||M.current)&&P()}({canvas:e,store:t,sceneRevisionDiagnostics:jt.current,size:nt,margin:rt,adjustedWidth:ot,adjustedHeight:it,background:ee,renderMode:D,hasBackgroundGraphics:!!Ae,dirtyRef:Ze,lastFrameTimeRef:_t,now:yt.now(),random:yt.random,reducedMotion:!!et.current,showParticles:E,isContinuous:nn,animate:Ce,decay:Se,pulse:Me,thresholds:De,staleness:Pe,particleStyle:kt,getParticleColor:tn,pendingAnnotationFrameRef:Pt,lastAnnotationFrameTimeRef:Ct,setAnnotationFrame:$t,scheduleNextFrame:()=>{ft()}})};const{canvasRef:En}=Ks(Je,{hydrated:gt,wasHydratingFromSSR:mt,storeRef:Rt,dirtyRef:Ze,canvasPaintDependencies:[n,ot,it,ee,Ae,D,ft]});xr(Pe,Rt,Ze,ft,Wt,zt);const Ln=te&&Et?(0,Ou.jsx)(Ds,{x:Et.x,y:Et.y,containerWidth:ot,containerHeight:it,margin:rt,className:"stream-network-tooltip",zIndex:2,children:ne?ne(Et):(0,Ou.jsx)(wu,{data:Et})}):null;if(Ci||!gt&&mt)return(0,Ou.jsx)(cu,{props:e,store:Rt.current,responsiveRef:tt,size:nt,margin:rt,adjustedWidth:ot,adjustedHeight:it,resolvedBackground:at,resolvedForeground:st});const Nn=Rt.current;return(0,Ou.jsxs)("div",{ref:tt,className:"stream-network-frame"+(J?" "+J:""),role:"group","aria-label":$e||("string"==typeof be?be:"Network chart"),tabIndex:0,"aria-busy":Ot||void 0,style:{position:"relative",width:K?"100%":nt[0],height:Q?"100%":nt[1],overflow:"visible"},onKeyDown:Rn,children:["production"!==process.env.NODE_ENV&&Rt.current&&(0,Ou.jsx)(ln,{store:Rt.current,diagnostics:jt.current}),Ie&&(0,Ou.jsx)(vs,{tableId:ut}),Ie&&(0,Ou.jsx)(ms,{nodes:Nn?.sceneNodes??[],edges:Nn?.sceneEdges??[],chartType:"Network chart",tableId:ut,chartTitle:"string"==typeof be?be:void 0}),(0,Ou.jsx)(xs,{summary:We}),(0,Ou.jsx)(Ki,{hoverPoint:Et}),(0,Ou.jsxs)("div",{role:"img","aria-label":$e||("string"==typeof be?be:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:te?jn:void 0,onMouseLeave:te?wn:void 0,onClick:oe||ie?Mn:void 0,children:[Ot&&!1!==k&&(0,Ou.jsx)("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:yu(!0,nt[0],nt[1],k)}),(0,Ou.jsx)(Qs,{size:nt,margin:rt,overflowVisible:!0,children:at}),(0,Ou.jsx)("canvas",{ref:En,"aria-label":ns(Nn?.sceneNodes?.length??0,Nn?.sceneEdges?.length??0,"Network chart"),style:{position:"absolute",top:0,left:0}}),(0,Ou.jsx)(ru,{width:ot,height:it,totalWidth:nt[0],totalHeight:nt[1],margin:rt,labels:Nn?.labels||[],sceneNodes:Nn?.sceneNodes,title:be,legend:fe,legendPosition:ye,legendLayout:pe,legendHoverBehavior:ge,legendClickBehavior:me,legendHighlightedCategory:xe,legendIsolatedCategories:ve,foregroundGraphics:un(st,pn(Rt.current?.customLayoutOverlays,Ke??null)),annotations:ce,onAnnotationActivate:ue,onObservation:se??ie,chartId:ae,chartType:"StreamNetworkFrame",autoPlaceAnnotations:he,svgAnnotationRules:de,annotationFrame:It}),(0,Ou.jsx)(au,{marks:Nn?.customLayoutHtmlMarks,margin:rt,selection:Ke??null}),(0,Ou.jsx)(ws,{active:_n.current>=0,hoverPoint:Et,margin:rt,size:nt,shape:Cn.current?.shape,width:Cn.current?.w,height:Cn.current?.h}),Ln,Pe?.showBadge&&(0,Ou.jsx)(br,{isStale:Wt,position:Pe.badgePosition})]})]})}));Xu.displayName="StreamNetworkFrame";var qu=Xu,Gu=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}},Vu=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,r=Math.floor(e/n);for(let o=Math.floor((e-this.size)/n)+1;r>=o;o++)this.bump(o*n,t)}bump(e,t){let n=this.windows.get(e);n||(n=new Gu,this.windows.set(e,n)),n.push(t)}pushSession(e,t){const n=this.gap,r=new Gu;r.push(t);let o=e,i=e;const s=[],a={start:o,end:i,stats:r};for(const t of this.sessions)e-n>t.end||t.start>e+n?s.push(t):(a.stats.merge(t.stats),o>t.start&&(o=t.start),t.end>i&&(i=t.end));a.start=o,a.end=i,s.push(a),s.sort((e,t)=>e.start-t.start),this.sessions=s}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 r=t+this.size;e.push(this.row(t,r,n,r>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,r){return{start:e,end:t,count:n.count,mean:n.mean,sum:n.sum,min:n.min,max:n.max,stddev:n.stddev,partial:r}}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 Uu(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 Ku(e,t,n,r=1){if("none"===t)return null;if("minmax"===t)return[e.min,e.max];const o=Uu(e,n),i=e.stddev*r;return[o-i,o+i]}var Qu={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},Zu=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g;function Ju(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;Zu.lastIndex=0;let n,r=0,o=0;for(;null!==(n=Zu.exec(t));){const e=parseFloat(n[1]),t=Qu[n[2]];if(null==t||!Number.isFinite(e))return null;r+=e*t,o+=n[0].length}return o!==t.length?null:r>0?r:null}var eh=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 r of this.held)this.getTime(r)>e?n.push(r):t.push(r);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}},th=require("react"),nh=require("react"),rh=require("react");function oh(e){const t=[];for(const[n,r]of Object.entries(e.fields))if("point"===r.type)t.push(e=>r.values.has(e[n]));else{const[e,o]=r.range;t.push(t=>{const r=t[n];return r>=e&&o>=r})}return e=>t.every(t=>t(e))}function ih(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}function sh(e,t){if(e.type!==t.type)return!1;if("interval"===e.type&&"interval"===t.type)return e.range[0]===t.range[0]&&e.range[1]===t.range[1];if("point"===e.type&&"point"===t.type){if(e.values.size!==t.values.size)return!1;for(const n of e.values)if(!t.values.has(n))return!1;return!0}return!1}var[ah,lh]=$(e=>({selections:new Map,setClause(t,n){e(e=>{const r=e.selections.get(t),o=r?.clauses.get(n.clientId);if(o&&function(e,t){if(e.clientId!==t.clientId||e.type!==t.type)return!1;const n=Object.entries(e.fields);if(n.length!==function(e){let t=0;for(const n in e)t++;return t}(t.fields))return!1;for(const[e,r]of n){const n=t.fields[e];if(!n||!sh(r,n))return!1}return!0}(o,n))return{};const i=new Map(e.selections),s=ih(i,t),a=new Map(s.clauses);return a.set(n.clientId,n),i.set(t,{...s,clauses:a}),{selections:i}})},clearClause(t,n){e(e=>{const r=e.selections.get(t);if(!r||!r.clauses.has(n))return{};const o=new Map(e.selections),i=new Map(r.clauses);return i.delete(n),o.set(t,{...r,clauses:i}),{selections:o}})},setResolution(t,n){e(e=>{const r=e.selections.get(t);if(r?.resolution===n)return{};const o=new Map(e.selections),i=ih(o,t);return o.set(t,{...i,resolution:n}),{selections:o}})},clearSelection(t){e(e=>{const n=e.selections.get(t);if(!n||0===n.clauses.size)return{};const r=new Map(e.selections);return r.set(t,{...n,clauses:new Map}),{selections:r}})}})),ch=require("react");function uh(e){const t=(0,ch.useId)(),n=e.clientId||t,{name:r}=e,o=lh(e=>e.selections.get(r)),i=lh(e=>e.setClause),s=lh(e=>e.clearClause),a=(0,ch.useMemo)(()=>!!o&&o.clauses.size>0,[o]);return{predicate:(0,ch.useMemo)(()=>o&&0!==o.clauses.size?function(e,t){const n=[];for(const[r,o]of e.clauses)"crossfilter"===e.resolution&&r===t||n.push(oh(o));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(o,n):()=>!0,[o,n]),isActive:a,selectPoints:(0,ch.useCallback)(e=>{const t={};let o=!1;for(const[n,r]of Object.entries(e))t[n]={type:"point",values:new Set(r)},o=!0;o&&i(r,{clientId:n,type:"point",fields:t})},[n,r,i]),selectInterval:(0,ch.useCallback)(e=>{const t={};let o=!1;for(const[n,r]of Object.entries(e))t[n]={type:"interval",range:r},o=!0;o&&i(r,{clientId:n,type:"interval",fields:t})},[n,r,i]),clear:(0,ch.useCallback)(()=>{s(r,n)},[s,r,n]),clientId:n}}function hh(e){return 2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]}function dh(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}require("react/jsx-runtime");var fh=(0,rh.createContext)(!1);(0,rh.createContext)(!1);var yh=(0,rh.createContext)(null),ph="undefined"==typeof window?rh.useEffect:rh.useLayoutEffect;function gh(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}var mh={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function xh(e,t={}){const n=t.mobileSemantics?.interaction,r="number"==typeof n?.targetSize?n.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,o="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,i=!!n||void 0!==r,s=e&&"object"==typeof e?e:void 0;if(!1===e||!1===s?.enabled||void 0===e&&!o&&!i)return mh;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??r??44,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??44,standardControls:a.standardControls??!1}}var vh={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}},mobile:{width:390,height:300,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:!1,showLabels:!0,marginDefaults:{top:28,bottom:42,left:44,right:16}}};function bh(e,t,n){if(!1!==t)return e;const r={...e};return"horizontal"===n?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}function kh(e,t,n){const r=e.xValue??t?.[n];if(null==r)return null;const o=Number(r);return Number.isFinite(o)?o:null}function wh(e){let t=e.data||e.datum||e;return Array.isArray(t)&&(t=t[0]),null!=e.xValue&&t&&"object"==typeof t&&!Array.isArray(t)&&null==t.xValue?{...t,xValue:e.xValue}:t||{}}var Ah=[];function Sh({selection:e,linkedHover:t,fallbackFields:n=Ah,unwrapData:r=!1,onObservation:o,chartType:i,chartId:s,onClick:a,hoverHighlight:l,colorByField:c,mobileInteraction:u}){const h=(0,nh.useId)(),d=(0,nh.useMemo)(()=>function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField,seriesField:e.seriesField}:null}(t,n),[t,n]),f=(0,nh.useMemo)(()=>"series"===d?.mode?[d.seriesField||c||n[0]].filter(e=>!!e):d?.fields||n,[d,c,n]),y=uh({name:e?.name||"__unused__",fields:f}),p=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:r,isActive:o,selectPoints:i,clear:s}=uh({name:t,fields:n});return{onHover:(0,ch.useCallback)(e=>{if(!e)return void s();const t={};for(const r of n){const n=e[r];void 0!==n&&(t[r]=[n])}dh(t)&&i(t)},[n,i,s]),predicate:r,isActive:o}}({name:d?.name||"hover",fields:f}),g=po(e=>e.pushObservation),m=(0,nh.useCallback)(e=>{o?.(e),g?.(e)},[o,g]),x=e?{isActive:y.isActive,predicate:y.predicate}:null,[v,b]=(0,nh.useState)(null),k=(0,nh.useRef)(!1),w=c||n[0],A=(0,nh.useMemo)(()=>{if(!l||null==v||!w)return null;const e=v,t=w;return{isActive:!0,predicate:n=>("string"==typeof n[t]?n[t]:(n[t]??"")+"")===e}},[l,v,w]),S=(0,nh.useCallback)((e,n)=>{const r=!e&&k.current&&!!u?.enabled&&u.tapToLockTooltip;if(t)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===d?.mode&&d.xField){const n=kh(e,t,d.xField);null!=n&&function(e,t,n){const r=qo.positions.get(e);r?.locked||r&&r.xValue===t&&r.sourceId===n||(qo={positions:new Map(qo.positions).set(e,{xValue:t,sourceId:n})},Vo())}(d.name||"hover",n,h)}"x-position"!==d?.mode&&p.onHover(t)}else"x-position"!==d?.mode||r||Uo(d.name||"hover",h),"x-position"===d?.mode||r||p.onHover(null);if(l&&w)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=t?.[w];b(null!=n?n+"":null)}else r||b(null);(o||g)&&Ba({onObservation:m,datum:e?wh(e):null,x:e?.x,y:e?.y,chartType:i||"unknown",chartId:s,context:n})},[t,p,d,h,o,i,s,g,m,l,w,u]),M=(0,nh.useCallback)((n=!0)=>{k.current=!1,t&&"x-position"!==d?.mode&&p.onHover(null),e&&u?.tapToSelect&&y.clear(),n&&l&&b(null),"x-position"===d?.mode&&(Ko(d.name||"hover",h),Uo(d.name||"hover",h))},[t,d,p,e,u,y,l,h]),_=(0,nh.useCallback)((n,r)=>{const c=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),x=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===d?.mode&&d.xField&&n){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]);const t=kh(n,e,d.xField);null!=t&&function(e,t,n){const r=qo.positions.get(e);if(r?.locked){const t=new Map(qo.positions);return t.delete(e),qo={positions:t},Vo(),!1}qo={positions:new Map(qo.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Vo()}(d.name||"hover",t,h)}if(c)if(n){k.current=!0;const r=wh(n);if(t&&"x-position"!==d?.mode&&p.onHover(r),e&&u?.tapToSelect&&f.length>0){const e={};for(const t of f){const n=r[t];void 0!==n&&(e[t]=[n])}(function(e){if(!e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1})(e)&&y.selectPoints(e)}if(l&&w){const e=r?.[w];b(null!=e?e+"":null)}}else x&&M();if(n||x){if(n&&a){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]),a(e,{x:n.x??0,y:n.y??0})}(o||g)&&Ya({onObservation:m,datum:n?wh(n):null,x:n?.x,y:n?.y,chartType:i||"unknown",chartId:s,context:r})}},[a,o,g,m,i,s,d,h,u,t,p,e,y,f,l,w,M]);return(0,nh.useEffect)(()=>{if(!u?.enabled||"undefined"==typeof document)return;const e=e=>{"Escape"===e.key&&k.current&&M()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u?.enabled,M]),(0,nh.useEffect)(()=>()=>{k.current&&M(!1)},[M]),(0,nh.useEffect)(()=>{if("x-position"!==d?.mode)return;const e=d.name||"hover";return()=>{Ko(e,h),Uo(e,h)}},[d?.mode,d?.name,h]),{activeSelectionHook:x,hoverSelectionHook:A,customHoverBehavior:S,customClickBehavior:_,crosshairSourceId:h}}function Mh({data:e,colorBy:t,colorScale:n,showLegend:r,legendPosition:o="right",userMargin:i,defaults:s={top:50,bottom:60,left:70,right:40},categories:a,additionalLegend:l}){const c=(0,rh.useContext)(fh),u=null!==(0,rh.useContext)(yh),h=void 0!==r?r:!c&&!!t,d=!!t&&(h||u),f=(0,nh.useMemo)(()=>{if(!d)return[];if(void 0!==a)return a;const n=new Set;for(const r of e){const e="function"==typeof t?t(r):r[t];null!=e&&n.add(e+"")}return Array.from(n)},[a,t,e,d]);!function(e){const t=(0,rh.useContext)(yh),n=(0,rh.useId)(),r=function(e){const t=new Set,n=[];for(const r of e)t.has(r)||(t.add(r),n.push(r));return n}(e),o=(0,rh.useRef)([]);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(o.current,r)||(o.current=r);const i=o.current;ph(()=>{if(t)return()=>t.unregisterCategories(n)},[t,n]),ph(()=>{t&&t.registerCategories(n,i)},[t,n,i])}(u&&t?f:[]);const y=(0,nh.useMemo)(()=>{if(!h||!t)return;const r=function({data:e,colorBy:t,colorScale:n,getColor:r,strokeColor:o,strokeWidth:i,categories:s}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==o&&(n.stroke=o),void 0!==i&&(n.strokeWidth=i),n},type:"fill",items:(s&&s.length>0?s:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((o,i)=>{const s=e.find("function"==typeof t?e=>t(e)===o:e=>e[t]===o),a=s?r(s,t,n):n?n(o):Ae[i%Ae.length];return{label:o+"",color:a}}),label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:Me,categories:f});return 0!==r.legendGroups.reduce((e,t)=>e+t.items.length,0)?r:void 0},[h,t,e,n,f]),p=(0,nh.useMemo)(()=>function(...e){let t;for(const n of e)n&&(t=Tr(t)&&Tr(n)?{legendGroups:[...t.legendGroups,...n.legendGroups]}:n);return t}(y,l),[y,l]),g=(0,nh.useMemo)(()=>{const e="number"==typeof i?{top:i,bottom:i,left:i,right:i}:i??{},t=t=>{const n=e[t];return"number"==typeof n?n:s[t]},n={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")},r=t=>"number"==typeof e[t];return p&&("right"===o&&!r("right")&&110>n.right?n.right=110:"left"===o&&!r("left")&&110>n.left?n.left=110:"top"===o&&!r("top")&&50>n.top?n.top=50:"bottom"===o&&!r("bottom")&&80>n.bottom&&(n.bottom=80)),n},[s,i,p,o]);return{legend:p,margin:g,legendPosition:o}}function _h(e,t,n){return function(e,t,n){const r=vh[e||"primary"],o=e&&"primary"!==e||!n?.width?r.width:n.width,i=e&&"primary"!==e||!n?.height?r.height:n.height,s=function(e,t,n=e.responsiveRules){if(!Array.isArray(n)||0===n.length)return{props:e,matches:[]};const r=n.map((e,t)=>({rule:e,index:t})).filter(e=>function(e,t){const{when:n}=e,r=t.width,o=t.height,i=function(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}(t),s=function(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}(t);return!("number"==typeof n.minWidth&&n.minWidth>r||"number"==typeof n.maxWidth&&r>n.maxWidth||"number"==typeof n.minHeight&&("number"!=typeof o||n.minHeight>o)||"number"==typeof n.maxHeight&&("number"!=typeof o||o>n.maxHeight)||"number"==typeof n.minAspectRatio&&("number"!=typeof i||n.minAspectRatio>i)||"number"==typeof n.maxAspectRatio&&("number"!=typeof i||i>n.maxAspectRatio)||n.orientation&&s!==n.orientation)}(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:r.reduce((e,t)=>function(e,t){const n={...e,...t};for(const r of["margin","frameProps","mobileSemantics","style"])gh(e[r])&&gh(t[r])&&(n[r]={...e[r],...t[r]});return"string"==typeof e.className&&"string"==typeof t.className&&(n.className=`${e.className} ${t.className}`),n}(e,t.rule.transform),e),matches:r}}({...t,mode:e},{width:t.width??o,height:t.height??i}).props,a=s.mode||e,l=vh[a||"primary"],c="context"===a||"sparkline"===a,u=a&&"primary"!==a||!n?.width?l.width:n.width;return{width:s.width??u,height:s.height??(a&&"primary"!==a||!n?.height?l.height:n.height),showAxes:s.showAxes??l.showAxes,showGrid:s.showGrid??l.showGrid,enableHover:s.enableHover??(!!s.linkedHover||l.enableHover),showLegend:s.showLegend??l.showLegend,showLabels:s.showLabels??l.showLabels,title:c?void 0:s.title,description:s.description,summary:s.summary,accessibleTable:s.accessibleTable,xLabel:c?void 0:s.xLabel,yLabel:c?void 0:s.yLabel,categoryLabel:c?void 0:s.categoryLabel,valueLabel:c?void 0:s.valueLabel,marginDefaults:bh(l.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:c,mobileInteraction:xh(s.mobileInteraction,{mode:a,width:s.width??u,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}(e,t,n)}var Ch=require("react/jsx-runtime"),Ph={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"},Rh={opacity:.7,marginRight:4};function jh(e,t,n){if(null!=e)return"function"==typeof t?t(e):e["string"==typeof t?t:n]}function Th(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function Eh(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:r="x",yLabel:o="y"}=e;return e=>{const i=e?.data??null,s=jh(i,t,"time"),a=jh(i,n,"value");return(0,Ch.jsxs)("div",{className:"semiotic-tooltip",style:Ph,children:[(0,Ch.jsxs)("div",{children:[(0,Ch.jsxs)("span",{style:Rh,children:[r,":"]}),Th(s)]}),(0,Ch.jsxs)("div",{children:[(0,Ch.jsxs)("span",{style:Rh,children:[o,":"]}),Th(a)]})]})}}function Lh(e,t){return null!=e?e:Math.max(t?.length??0,200)}var Nh="time",Dh="value",Ih="__aggLower",$h="__aggUpper",Wh="__aggPartial",zh="count",Oh="__aggStart",Fh="__aggEnd";function Bh(e,t){const n=t.stat??"mean",r=t.band??"none",o=t.sigma??1;return e.emit().map(e=>{const t={[Nh]:(e.start+e.end)/2,[Dh]:Uu(e,n),[zh]:e.count,[Wh]:e.partial,[Oh]:e.start,[Fh]:e.end},i=Ku(e,r,n,o);return i&&(t[Ih]=i[0],t[$h]=i[1]),t})}function Yh(e){const{linkedHover:t,selection:n,onObservation:r,onClick:o,hoverRadius:i,hoverHighlight:s,forceHoverBehavior:a,forceClickBehavior:l,mobileInteraction:c,customHoverBehavior:u,customClickBehavior:h,linkedHoverInClickPredicate:d=!0}=e,f={};r&&(f.annotationObservationCallback=r);const y=c?.enabled?Math.max(i??30,Math.ceil((c.targetSize||44)/2),24):i;return(a||t||r||o||s)&&(f.customHoverBehavior=u),h&&(l||(d?r||o||t:r||o)||c?.enabled&&(c.tapToSelect||c.tapToLockTooltip)&&(t||s||n))&&(f.customClickBehavior=h),null!=y&&(f.hoverRadius=y),f}var Hh=require("react/jsx-runtime");function Xh(e,t,n){const r="function"==typeof t?t(e):e[t??n];if(null==r)return null;if(r instanceof Date)return r.getTime();const o=Number(r);return Number.isFinite(o)?o:null}var qh=(0,th.forwardRef)(function(e,t){const n=_h(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:r,margin:o,className:i,arrowOfTime:s="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:h,timeExtent:d,valueExtent:f,extentPadding:y,stroke:p="#007bff",strokeWidth:g=2,strokeDasharray:m,opacity:x,background:v,tooltipContent:b,tooltip:k,onHover:w,annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:M,tickFormatTime:_,tickFormatValue:C,decay:P,pulse:R,staleness:j,transition:T,linkedHover:E,selection:L,onObservation:N,chartId:D,loading:I,loadingContent:$,emptyContent:W,emphasis:z,legendPosition:O,aggregate:F,eventTime:B}=e,Y=n.showAxes,H=n.enableHover,X=o??n.marginDefaults,q=r??[n.width,n.height],G=b??k??Eh({timeAccessor:u,valueAccessor:h}),V=(0,th.useRef)(null),{customHoverBehavior:U}=Sh({selection:L,linkedHover:E,unwrapData:!0,onObservation:N,chartType:"RealtimeLineChart",chartId:D}),K=(0,th.useCallback)(e=>{w&&w(e),U(e)},[w,U]),Q=null!=F,[Z,J]=(0,th.useState)([]),ee=(0,th.useRef)(null),te=(0,th.useRef)(F);te.current=F;const ne=(0,th.useRef)(Q);ne.current=Q;const re=(0,th.useRef)(Z);re.current=Z;const oe=(0,th.useRef)({timeAccessor:u,valueAccessor:h});oe.current={timeAccessor:u,valueAccessor:h},(0,th.useEffect)(()=>{if(!Q)return void(ee.current=null);const e=te.current,t=function(e){const t=e.window??"tumbling",n=Ju("session"===t?e.gap??e.size:e.size);if(null==n)return null;const r=null!=e.hop?Ju(e.hop):void 0,o=null!=e.gap?Ju(e.gap):void 0;return new Vu({window:t,size:n,hop:r??void 0,gap:o??void 0,retain:e.retain})}(e);if(ee.current=t,t&&c){const{timeAccessor:e,valueAccessor:n}=oe.current;for(const r of c){const o=Xh(r,e,"time"),i=Xh(r,n,"value");null!=o&&null!=i&&t.push(o,i)}}J(t?Bh(t,e):[])},[Q?[F.window??"tumbling",F.size,F.hop??"",F.gap??"",F.retain??""].join("|"):"",Q,c]),(0,th.useEffect)(()=>{Q&&ee.current&&J(Bh(ee.current,te.current))},[F?.stat,F?.band,F?.sigma]);const ie=(0,th.useCallback)(e=>{const t=ee.current,n=te.current;if(!t||!n)return;const{timeAccessor:r,valueAccessor:o}=oe.current;for(const n of e){const e=Xh(n,r,"time"),i=Xh(n,o,"value");null!=e&&null!=i&&t.push(e,i)}J(Bh(t,n))},[]),se=null!=B,ae=(0,th.useRef)(null),le=(0,th.useRef)(B);le.current=B;const ce=(0,th.useRef)(se);ce.current=se;const ue=(0,th.useRef)(N);ue.current=N;const he=(0,th.useRef)(D);he.current=D,(0,th.useEffect)(()=>{ae.current=se?function(e){const t=Ju(e.lateness);return null==t?null:new eh({lateness:t,getTime:e=>Xh(e,oe.current.timeAccessor,"time")??NaN,latePolicy:e.latePolicy??"drop"})}(le.current):null},[se?`${B.lateness}|${B.latePolicy??"drop"}`:"",se]);const de=(0,th.useCallback)(e=>{0!==e.length&&(ne.current?ie(e):V.current?.pushMany(e))},[ie]),fe=(0,th.useCallback)(e=>{const t=ae.current;if(!ce.current||!t)return void de(e);const n=[];for(const r of e){const e=t.push(r);if(e.released.length&&n.push(...e.released),e.late.length){const n=ue.current;if(n){const{timeAccessor:r}=oe.current,o=le.current?.latePolicy??"drop";for(const i of e.late)n({type:"late-data",datum:i,eventTime:Xh(i,r,"time")??NaN,watermark:t.watermark,policy:o,lateCount:t.lateCount,timestamp:Date.now(),chartType:"RealtimeLineChart",chartId:he.current})}}}de(n)},[de]);(0,th.useImperativeHandle)(t,()=>({push:e=>fe([e]),pushMany:e=>fe(e),remove:e=>ne.current?[]:V.current?.remove(e)??[],update:(e,t)=>ne.current?[]:V.current?.update(e,t)??[],clear:()=>{ae.current?.clear(),ne.current?(ee.current?.clear(),J([])):V.current?.clear()},getData:()=>ne.current?re.current:V.current?.getData()??[],getScales:()=>V.current?.getScales()??null}),[fe]);const ye=yu(I,q[0],q[1],$),pe=ye?null:fu(Q?void 0:c,q[0],q[1],W),ge={stroke:p,strokeWidth:g,strokeDasharray:m};null!=x&&(ge.opacity=x);const me=Lh(l,c),xe=Q?Z:c,ve=Q?Nh:u,be=Q?Dh:h,ke=Q&&F&&"none"!==(F.band??"none")?{y0Accessor:Ih,y1Accessor:$h,perSeries:!1}:void 0;return ye||pe||(0,Hh.jsx)(rl,{ref:V,chartType:"line",runtimeMode:"streaming",size:q,margin:X,className:z?`${i||""} semiotic-emphasis-${z}`.trim():i,arrowOfTime:s,windowMode:Q?"growing":a,windowSize:Q?Math.max(1,F?.retain??Math.max(Z.length,600)):me,data:xe,timeAccessor:ve,valueAccessor:be,xExtent:d,yExtent:f,extentPadding:y,band:ke,lineStyle:ge,showAxes:Y,background:v,hoverAnnotation:H,tooltipContent:G,...Yh({linkedHover:E,selection:L,onObservation:N,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:K}),annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:M,tickFormatTime:_,tickFormatValue:C,decay:P,pulse:R,staleness:j,transition:T,pointIdAccessor:e.pointIdAccessor,legendPosition:O})});qh.displayName="RealtimeLineChart";var Gh=require("react");function Vh(e,t,n){const r="function"==typeof t?t(e):e[t??n];if(null==r)return null;if(r instanceof Date)return r.getTime();if("string"==typeof r&&""===r.trim())return null;const o=Number(r);return Number.isFinite(o)?o:null}var Uh=require("react/jsx-runtime"),Kh=(0,Gh.forwardRef)(function(e,t){const n=_h(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:r,size:o,margin:i,className:s,arrowOfTime:a="right",windowMode:l="sliding",windowSize:c,data:u,timeAccessor:h,valueAccessor:d,direction:f="up",timeExtent:y,valueExtent:p,extentPadding:g,categoryAccessor:m,colors:x,fill:v,stroke:b,strokeWidth:k,opacity:w,gap:A,background:S,tooltipContent:M,tooltip:_,onHover:C,annotations:P,autoPlaceAnnotations:R,svgAnnotationRules:j,tickFormatTime:T,tickFormatValue:E,linkedHover:L,selection:N,decay:D,pulse:I,staleness:$,transition:W,onObservation:z,chartId:O,loading:F,loadingContent:B,emptyContent:Y,emphasis:H,legendPosition:X,legend:q,brush:G,onBrush:V,linkedBrush:U}=e,K=n.showAxes,Q=n.enableHover,Z=o??[n.width,n.height],J=(0,Gh.useMemo)(()=>x?e=>x[e]??v??"#999":void 0,[x,v]),{legend:ee,margin:te,legendPosition:ne}=Mh({data:u??[],colorBy:m,colorScale:J,showLegend:n.showLegend,legendPosition:X,userMargin:i,defaults:n.marginDefaults,additionalLegend:q}),re=M??_??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const r=e?.data??null;if(null==r?.binStart||null==r?.binEnd){const e=jh(r,t,"time"),o=jh(r,n,"value");return(0,Ch.jsxs)("div",{className:"semiotic-tooltip",style:Ph,children:[(0,Ch.jsxs)("div",{children:[(0,Ch.jsx)("span",{style:Rh,children:"x:"}),Th(e)]}),(0,Ch.jsxs)("div",{children:[(0,Ch.jsx)("span",{style:Rh,children:"y:"}),Th(o)]})]})}return(0,Ch.jsxs)("div",{className:"semiotic-tooltip",style:Ph,children:[(0,Ch.jsxs)("div",{children:[(0,Ch.jsx)("span",{style:Rh,children:"range:"}),Th(r.binStart),"–",Th(r.binEnd)]}),null!=r.total&&(0,Ch.jsxs)("div",{children:[(0,Ch.jsx)("span",{style:Rh,children:"count:"}),Th(r.total)]}),null!=r.category&&(0,Ch.jsxs)("div",{children:[(0,Ch.jsx)("span",{style:Rh,children:"category:"}),Th(r.category)]})]})}}({timeAccessor:h,valueAccessor:d}),oe=(0,Gh.useRef)(null),{customHoverBehavior:ie}=Sh({selection:N,linkedHover:L,unwrapData:!0,onObservation:z,chartType:"RealtimeHistogram",chartId:O}),se=(0,Gh.useCallback)(e=>{C&&C(e),ie(e)},[C,ie]),ae=!0===G?{dimension:"x",snap:"bin"}:"x"===G?{dimension:"x"}:"object"==typeof G?G:void 0,le=(ce=U)?"string"==typeof ce?{name:ce}:ce:null;var ce;const ue="string"==typeof h?h:"time",he=function(e){const{name:t,xField:n,yField:r}=e,{predicate:o,isActive:i,selectInterval:s,clear:a}=uh({name:t,fields:[n,r].filter(Boolean)}),l=n&&r?"xyBrush":n?"xBrush":"yBrush",c=(0,ch.useCallback)(e=>{if(!e)return void a();const t={};"xyBrush"===l&&function(e){return 2===e.length&&Array.isArray(e[0])&&2===e[0].length&&Array.isArray(e[1])&&2===e[1].length}(e)?(n&&(t[n]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),r&&(t[r]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===l&&hh(e)?n&&(t[n]=[Math.min(e[0],e[1]),Math.max(e[0],e[1])]):"yBrush"===l&&hh(e)&&r&&(t[r]=[Math.min(e[0],e[1]),Math.max(e[0],e[1])]),dh(t)&&s(t)},[l,n,r,s,a]);return{brushInteraction:(0,ch.useMemo)(()=>({brush:l,during:c,end:c}),[l,c]),predicate:o,isActive:i,clear:a}}({name:le?.name||"__unused_hist_brush__",xField:le?.xField||ue,...le?.yField?{yField:le.yField}:{}}),de=(0,Gh.useRef)(he.brushInteraction);de.current=he.brushInteraction;const fe=(0,Gh.useCallback)(e=>{if(V&&V(e),z&&z(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:O}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:O}),le){const t=de.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)}},[V,z,O,le]);(0,Gh.useImperativeHandle)(t,()=>({push:e=>oe.current?.push(e),pushMany:e=>oe.current?.pushMany(e),remove:e=>oe.current?.remove(e)??[],update:(e,t)=>oe.current?.update(e,t)??[],clear:()=>oe.current?.clear(),getData:()=>oe.current?.getData()??[],getScales:()=>oe.current?.getScales()??null}),[]);const ye=yu(F,Z[0],Z[1],B),pe=ye?null:fu(u,Z[0],Z[1],Y),ge={};null!=v&&(ge.fill=v),null!=b&&(ge.stroke=b),null!=k&&(ge.strokeWidth=k),null!=w&&(ge.opacity=w),null!=A&&(ge.gap=A);const me=H?`${s||""} semiotic-emphasis-${H}`.trim():s,xe=Lh(c,u),ve=(0,Gh.useMemo)(()=>"down"!==f?p:function({data:e,valueAccessor:t,timeAccessor:n,binSize:r,valueExtent:o,extentPadding:i}){if(o)return[o[1],o[0]];if(!e||0===e.length)return;const s=new Map;for(const o of e){const e=Vh(o,n,"time"),i=Vh(o,t,"value");if(null==e||null==i)continue;const a=Math.floor(e/r)*r;s.set(a,(s.get(a)??0)+i)}let a=0;for(const e of s.values())a=Math.max(a,e);return[a>0?a+a*(i??.1):1,0]}({data:u,valueAccessor:d,timeAccessor:h,binSize:r,valueExtent:p,extentPadding:g}),[f,u,d,h,r,p,g]);return ye||pe||(0,Uh.jsx)(rl,{ref:oe,chartType:"bar",runtimeMode:"streaming",size:Z,margin:te,className:me,arrowOfTime:a,windowMode:l,windowSize:xe,data:u,timeAccessor:h,valueAccessor:d,xExtent:y,yExtent:ve,extentPadding:g,binSize:r,categoryAccessor:m,barColors:x,barStyle:ge,showAxes:K,background:S,hoverAnnotation:Q,tooltipContent:re,...Yh({linkedHover:L,selection:N,onObservation:z,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:se}),annotations:P,autoPlaceAnnotations:R,svgAnnotationRules:j,tickFormatTime:T,tickFormatValue:E,decay:D,pulse:I,staleness:$,transition:W,pointIdAccessor:e.pointIdAccessor,legend:ee,legendPosition:ne,brush:ae||(U?{dimension:"x"}:void 0),onBrush:ae||U?fe:void 0})});function Qh(e){return(0,Uh.jsx)(Kh,{...e,windowMode:"growing"})}Kh.displayName="RealtimeHistogram",Qh.displayName="TemporalHistogram";var Zh=require("react"),Jh=require("react/jsx-runtime"),ed=(0,Zh.forwardRef)(function(e,t){const n=_h(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:r,margin:o,className:i,arrowOfTime:s="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:h,timeExtent:d,valueExtent:f,yScaleType:y,extentPadding:p,categoryAccessor:g,colors:m,radius:x,fill:v,opacity:b,stroke:k,strokeWidth:w,pointStyle:A,background:S,tooltipContent:M,tooltip:_,onHover:C,annotations:P,autoPlaceAnnotations:R,svgAnnotationRules:j,tickFormatTime:T,tickFormatValue:E,linkedHover:L,selection:N,onObservation:D,chartId:I,loading:$,loadingContent:W,emptyContent:z,emphasis:O,legendPosition:F}=e,B=n.showAxes,Y=n.enableHover,H=o??n.marginDefaults,X=r??[n.width,n.height],q=M??_??Eh({timeAccessor:u,valueAccessor:h}),G=(0,Zh.useRef)(null),{customHoverBehavior:V}=Sh({selection:N,linkedHover:L,unwrapData:!0,onObservation:D,chartType:"RealtimeSwarmChart",chartId:I}),U=(0,Zh.useCallback)(e=>{C&&C(e),V(e)},[C,V]);(0,Zh.useImperativeHandle)(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 K=yu($,X[0],X[1],W),Q=K?null:fu(c,X[0],X[1],z),Z={};null!=x&&(Z.radius=x),null!=v&&(Z.fill=v),null!=b&&(Z.opacity=b),null!=k&&(Z.stroke=k),null!=w&&(Z.strokeWidth=w);const J=A,ee=O?`${i||""} semiotic-emphasis-${O}`.trim():i,te=Lh(l,c);return K||Q||(0,Jh.jsx)(rl,{ref:G,chartType:"swarm",runtimeMode:"streaming",size:X,margin:H,className:ee,arrowOfTime:s,windowMode:a,windowSize:te,data:c,timeAccessor:u,valueAccessor:h,xExtent:d,yExtent:f,yScaleType:y,extentPadding:p,categoryAccessor:g,barColors:m,swarmStyle:Z,pointStyle:J,showAxes:B,background:S,hoverAnnotation:Y,tooltipContent:q,...Yh({linkedHover:L,selection:N,onObservation:D,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:U}),annotations:P,autoPlaceAnnotations:R,svgAnnotationRules:j,tickFormatTime:T,tickFormatValue:E,legendPosition:F,pointIdAccessor:e.pointIdAccessor})});ed.displayName="RealtimeSwarmChart";var td=require("react"),nd=require("react/jsx-runtime"),rd=(0,td.forwardRef)(function(e,t){const n=_h(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:r,margin:o,className:i,arrowOfTime:s="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:h,timeExtent:d,valueExtent:f,extentPadding:y,positiveColor:p,negativeColor:g,connectorStroke:m,connectorWidth:x,gap:v,stroke:b,strokeWidth:k,opacity:w,background:A,tooltipContent:S,tooltip:M,onHover:_,annotations:C,autoPlaceAnnotations:P,svgAnnotationRules:R,tickFormatTime:j,tickFormatValue:T,linkedHover:E,selection:L,onObservation:N,chartId:D,loading:I,loadingContent:$,emptyContent:W,emphasis:z,legendPosition:O}=e,F=n.showAxes,B=n.enableHover,Y=o??n.marginDefaults,H=r??[n.width,n.height],X=S??M??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const r=e?.data??null,o=jh(r,t,"time"),i=r?.delta??jh(r,n,"value"),s=r?.cumEnd,a="number"==typeof i?0>i?Th(i):"+"+Th(i):Th(i);return(0,Ch.jsxs)("div",{className:"semiotic-tooltip",style:Ph,children:[(0,Ch.jsxs)("div",{children:[(0,Ch.jsx)("span",{style:Rh,children:"x:"}),Th(o)]}),(0,Ch.jsxs)("div",{children:[(0,Ch.jsx)("span",{style:Rh,children:"Δ:"}),a]}),null!=s&&(0,Ch.jsxs)("div",{children:[(0,Ch.jsx)("span",{style:Rh,children:"total:"}),Th(s)]})]})}}({timeAccessor:u,valueAccessor:h}),q=(0,td.useRef)(null),{customHoverBehavior:G}=Sh({selection:L,linkedHover:E,unwrapData:!0,onObservation:N,chartType:"RealtimeWaterfallChart",chartId:D}),V=(0,td.useCallback)(e=>{_&&_(e),G(e)},[_,G]);(0,td.useImperativeHandle)(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 U=yu(I,H[0],H[1],$),K=U?null:fu(c,H[0],H[1],W),Q={};null!=p&&(Q.positiveColor=p),null!=g&&(Q.negativeColor=g),null!=m&&(Q.connectorStroke=m),null!=x&&(Q.connectorWidth=x),null!=v&&(Q.gap=v),null!=b&&(Q.stroke=b),null!=k&&(Q.strokeWidth=k),null!=w&&(Q.opacity=w);const Z=z?`${i||""} semiotic-emphasis-${z}`.trim():i,J=Lh(l,c);return U||K||(0,nd.jsx)(rl,{ref:q,chartType:"waterfall",runtimeMode:"streaming",size:H,margin:Y,className:Z,arrowOfTime:s,windowMode:a,windowSize:J,data:c,timeAccessor:u,valueAccessor:h,xExtent:d,yExtent:f,extentPadding:y,waterfallStyle:Q,showAxes:F,background:A,hoverAnnotation:B,tooltipContent:X,...Yh({linkedHover:E,selection:L,onObservation:N,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:V}),annotations:C,autoPlaceAnnotations:P,svgAnnotationRules:R,tickFormatTime:j,tickFormatValue:T,legendPosition:O,pointIdAccessor:e.pointIdAccessor})});rd.displayName="RealtimeWaterfallChart";var od=require("react"),id=require("react/jsx-runtime"),sd=(0,od.forwardRef)(function(e,t){const n=_h(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:r,margin:o,className:i,arrowOfTime:s="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:h,categoryAccessor:d,timeExtent:f,valueExtent:y,extentPadding:p,heatmapXBins:g=20,heatmapYBins:m=20,aggregation:x="count",background:v,tooltipContent:b,tooltip:k,onHover:w,annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:M,tickFormatTime:_,tickFormatValue:C,decay:P,pulse:R,staleness:j,linkedHover:T,selection:E,onObservation:L,chartId:N,loading:D,loadingContent:I,emptyContent:$,emphasis:W,legendPosition:z}=e,O=n.showAxes,F=n.enableHover,B=o??n.marginDefaults,Y=r??[n.width,n.height],H=b??k??function(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:r="x",yLabel:o="y"}=e;return e=>{const i=e?.data??null,s=i?.xCenter??jh(i,t,"time"),a=i?.yCenter??jh(i,n,"value"),l=i?.count,c=i?.sum,u=i?.value,h=i?.agg??"count";return(0,Ch.jsxs)("div",{className:"semiotic-tooltip",style:Ph,children:[(0,Ch.jsxs)("div",{children:[(0,Ch.jsxs)("span",{style:Rh,children:[r,":"]}),Th(s)]}),(0,Ch.jsxs)("div",{children:[(0,Ch.jsxs)("span",{style:Rh,children:[o,":"]}),Th(a)]}),null!=l&&(0,Ch.jsxs)("div",{children:[(0,Ch.jsx)("span",{style:Rh,children:"count:"}),Th(l)]}),"sum"===h&&null!=c&&(0,Ch.jsxs)("div",{children:[(0,Ch.jsx)("span",{style:Rh,children:"sum:"}),Th(c)]}),"mean"===h&&null!=u&&(0,Ch.jsxs)("div",{children:[(0,Ch.jsx)("span",{style:Rh,children:"mean:"}),Th(u)]})]})}}({timeAccessor:u,valueAccessor:h}),X=(0,od.useRef)(null),{customHoverBehavior:q}=Sh({selection:E,linkedHover:T,unwrapData:!0,onObservation:L,chartType:"RealtimeHeatmap",chartId:N}),G=(0,od.useCallback)(e=>{w&&w(e),q(e)},[w,q]);(0,od.useImperativeHandle)(t,()=>({push:e=>X.current?.push(e),pushMany:e=>X.current?.pushMany(e),remove:e=>X.current?.remove(e)??[],update:(e,t)=>X.current?.update(e,t)??[],clear:()=>X.current?.clear(),getData:()=>X.current?.getData()??[],getScales:()=>X.current?.getScales()??null}),[]);const V=yu(D,Y[0],Y[1],I),U=V?null:fu(c,Y[0],Y[1],$),K=W?`${i||""} semiotic-emphasis-${W}`.trim():i,Q=Lh(l,c);return V||U||(0,id.jsx)(rl,{ref:X,chartType:"heatmap",runtimeMode:"streaming",size:Y,margin:B,className:K,arrowOfTime:s,windowMode:a,windowSize:Q,data:c,timeAccessor:u,valueAccessor:h,categoryAccessor:d,xExtent:f,yExtent:y,extentPadding:p,heatmapXBins:g,heatmapYBins:m,heatmapAggregation:x,showAxes:O,background:v,hoverAnnotation:F,tooltipContent:H,...Yh({linkedHover:T,selection:E,onObservation:L,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:G}),annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:M,tickFormatTime:_,tickFormatValue:C,decay:P,pulse:R,staleness:j,legendPosition:z,pointIdAccessor:e.pointIdAccessor})});sd.displayName="RealtimeHeatmap";var ad=require("react"),ld=Symbol("semiotic.useStreamStatus.wrapped");function cd(e={}){const{staleThresholdMs:t=5e3,pollIntervalMs:n=1e3}=e,r=(0,ad.useRef)(null),[o,i]=(0,ad.useState)("idle"),[s,a]=(0,ad.useState)(null),l=(0,ad.useCallback)(()=>{const e="undefined"!=typeof performance?performance.now():Date.now();r.current=e,a(e),i(e=>"active"===e?e:"active")},[]),c=(0,ad.useMemo)(()=>{const e={_frame:null,_origPush:null,_origPushMany:null};return{get current(){return e._frame},set current(t){const n=e._frame;if(n&&n!==t&&e._origPush&&e._origPushMany&&(n.push=e._origPush,n.pushMany=e._origPushMany,delete n[ld]),e._frame=t,!t)return e._origPush=null,void(e._origPushMany=null);if(t[ld])return;t[ld]=!0;const r=t.push,o=t.pushMany,i=r.bind(t),s=o.bind(t);e._origPush=r,e._origPushMany=o,t.push=e=>(l(),i(e)),t.pushMany=e=>(e&&e.length>0&&l(),s(e))}}},[l]);return(0,ad.useEffect)(()=>{const e=setInterval(()=>{const e=r.current;if(null==e)return;const n=("undefined"!=typeof performance?performance.now():Date.now())-e>t;i(e=>{const t=n?"stale":"active";return e===t?e:t})},n);return()=>clearInterval(e)},[t,n]),{ref:c,status:o,lastPushTime:s}}var ud=require("react");function hd(e,t,n,r){const o=new Map;n.forEach((e,t)=>{o.set(r?r(e,t):t+"",e)});const i=[];t.forEach((e,t)=>{o.has(t)||i.push(t)}),i.length>0&&e.remove?.(i);const s=[];if(o.forEach((n,r)=>{const o=t.get(r);void 0===o?s.push(n):o!==n&&(e.update?e.update(r,()=>n):(e.remove?.(r),s.push(n)))}),s.length>0)if(e.pushMany)e.pushMany(s);else if(e.push)for(const t of s)e.push(t);return o}function dd(e,t,n={}){const{id:r,resetKey:o}=n,i=(0,ud.useMemo)(()=>function(e){return null==e?null:"function"==typeof e?(t,n)=>{const r=e(t,n);return null==r?n+"":r+""}:(t,n)=>{const r=t[e];return null==r?n+"":r+""}}(r),[r]),s=(0,ud.useRef)({map:new Map,handle:null,resetKey:void 0});(0,ud.useEffect)(()=>{const n=e.current;if(!n)return;const r=s.current;r.handle===n&&r.resetKey===o||(n.clear?.(),r.map=new Map,r.handle=n,r.resetKey=o),r.map=hd(n,r.map,t,i)},[e,t,i,o])}