semiotic 3.8.2 → 3.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/CLAUDE.md +1 -1
  2. package/README.md +34 -33
  3. package/ai/schema.json +1 -1
  4. package/ai/surface-manifest.json +1 -1
  5. package/ai/system-prompt.md +1 -1
  6. package/dist/{chunk-chunk-C6EJ4IOD.module.min.js → chunk-chunk-2CCFBTQC.module.min.js} +1 -1
  7. package/dist/chunk-chunk-2RXP3FS3.module.min.js +1 -0
  8. package/dist/chunk-chunk-4TMZXLCR.module.min.js +1 -0
  9. package/dist/{chunk-chunk-H4PPRW6N.module.min.js → chunk-chunk-5APBQXZA.module.min.js} +1 -1
  10. package/dist/{chunk-chunk-NO4MCQVD.module.min.js → chunk-chunk-5RKXZQ2P.module.min.js} +1 -1
  11. package/dist/chunk-chunk-6HSGDMTA.module.min.js +2 -0
  12. package/dist/{chunk-chunk-7LHMKRKE.module.min.js → chunk-chunk-7FW6EGLP.module.min.js} +1 -1
  13. package/dist/{chunk-chunk-RH5TSQPH.module.min.js → chunk-chunk-7OEOSCBP.module.min.js} +1 -1
  14. package/dist/{chunk-chunk-FAKO3RGQ.module.min.js → chunk-chunk-A63CTACR.module.min.js} +1 -1
  15. package/dist/chunk-chunk-ANYDWOZF.module.min.js +1 -0
  16. package/dist/{chunk-chunk-ZLKRTF5N.module.min.js → chunk-chunk-AZJUDQRM.module.min.js} +1 -1
  17. package/dist/{chunk-chunk-W3DB2MN4.module.min.js → chunk-chunk-B6V35LMY.module.min.js} +1 -1
  18. package/dist/chunk-chunk-BOSVL645.module.min.js +2 -0
  19. package/dist/chunk-chunk-EMO5NUGE.module.min.js +1 -0
  20. package/dist/chunk-chunk-F25UA5HT.module.min.js +1 -0
  21. package/dist/chunk-chunk-FRIO6MCV.module.min.js +1 -0
  22. package/dist/{chunk-chunk-T27ZEV6A.module.min.js → chunk-chunk-GWSWSPXN.module.min.js} +1 -1
  23. package/dist/chunk-chunk-I6C3KR5H.module.min.js +2 -0
  24. package/dist/chunk-chunk-IP2UE74X.module.min.js +1 -0
  25. package/dist/chunk-chunk-J5RL6GXU.module.min.js +2 -0
  26. package/dist/chunk-chunk-JNCHKRIR.module.min.js +2 -0
  27. package/dist/{chunk-chunk-Z5KXAVQD.module.min.js → chunk-chunk-L3H6DQCR.module.min.js} +1 -1
  28. package/dist/{chunk-chunk-5WEFWNUW.module.min.js → chunk-chunk-M7VYYHCE.module.min.js} +1 -1
  29. package/dist/chunk-chunk-MC35ILYP.module.min.js +2 -0
  30. package/dist/{chunk-chunk-2VUEY5TH.module.min.js → chunk-chunk-N72SWNBV.module.min.js} +1 -1
  31. package/dist/chunk-chunk-OBQRFTIL.module.min.js +2 -0
  32. package/dist/chunk-chunk-OQTLSTGI.module.min.js +2 -0
  33. package/dist/{chunk-chunk-2UN3ANRN.module.min.js → chunk-chunk-SA3D43RA.module.min.js} +1 -1
  34. package/dist/chunk-chunk-SANERMIZ.module.min.js +2 -0
  35. package/dist/{chunk-chunk-DNY43POY.module.min.js → chunk-chunk-UHSZEB74.module.min.js} +1 -1
  36. package/dist/{chunk-chunk-CYIML3AV.module.min.js → chunk-chunk-XQYVEKEJ.module.min.js} +1 -1
  37. package/dist/{chunk-chunk-27HVVXS6.module.min.js → chunk-chunk-Y6AXCRVO.module.min.js} +1 -1
  38. package/dist/components/charts/custom/XYCustomChart.d.ts +3 -0
  39. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +5 -6
  40. package/dist/components/charts/realtime/temporalHistogramConfig.d.ts +11 -0
  41. package/dist/components/charts/shared/areaSeriesData.d.ts +15 -0
  42. package/dist/components/charts/shared/chartMode.d.ts +67 -0
  43. package/dist/components/charts/shared/colorUtils.d.ts +8 -0
  44. package/dist/components/charts/shared/geoStyleDefaults.d.ts +3 -0
  45. package/dist/components/charts/shared/hooks.d.ts +13 -80
  46. package/dist/components/charts/shared/useChartSetup.d.ts +3 -0
  47. package/dist/components/charts/shared/useCustomChartSetup.d.ts +3 -0
  48. package/dist/components/charts/shared/useXYLineStyle.d.ts +3 -2
  49. package/dist/components/charts/shared/xyLineStyle.d.ts +21 -0
  50. package/dist/components/charts/xy/LineChart.d.ts +3 -0
  51. package/dist/components/legendLayout.d.ts +31 -0
  52. package/dist/components/server/serverChartConfigShared.d.ts +29 -0
  53. package/dist/components/server/serverChartConfigs.d.ts +2 -13
  54. package/dist/components/server/serverChartConfigsXY.d.ts +3 -0
  55. package/dist/components/server/serverGaugeOverlay.d.ts +28 -0
  56. package/dist/components/server/staticLegend.d.ts +7 -1
  57. package/dist/components/server/staticSVGChrome.d.ts +57 -0
  58. package/dist/components/stream/GeoPipelineStore.d.ts +2 -0
  59. package/dist/components/stream/GeoSVGOverlay.d.ts +2 -0
  60. package/dist/components/stream/SceneToSVG.d.ts +8 -6
  61. package/dist/components/stream/SceneToSVGGeo.d.ts +10 -0
  62. package/dist/components/stream/SceneToSVGNetwork.d.ts +12 -0
  63. package/dist/components/stream/canvasBackground.d.ts +7 -0
  64. package/dist/components/stream/networkTypes.d.ts +2 -4
  65. package/dist/components/stream/renderBackend.d.ts +14 -0
  66. package/dist/components/stream/sceneToSVGShared.d.ts +51 -0
  67. package/dist/components/types/legendTypes.d.ts +16 -3
  68. package/dist/geo.min.js +1 -1
  69. package/dist/geo.module.min.js +1 -1
  70. package/dist/network.min.js +1 -1
  71. package/dist/network.module.min.js +1 -1
  72. package/dist/ordinal.min.js +1 -1
  73. package/dist/ordinal.module.min.js +1 -1
  74. package/dist/physics.min.js +1 -1
  75. package/dist/physics.module.min.js +1 -1
  76. package/dist/realtime.min.js +1 -1
  77. package/dist/realtime.module.min.js +1 -1
  78. package/dist/semiotic-ai-core.min.js +1 -1
  79. package/dist/semiotic-ai-core.module.min.js +1 -1
  80. package/dist/semiotic-ai.min.js +1 -1
  81. package/dist/semiotic-ai.module.min.js +1 -1
  82. package/dist/semiotic-experimental.min.js +1 -1
  83. package/dist/semiotic-experimental.module.min.js +1 -1
  84. package/dist/semiotic-realtime-core.min.js +1 -1
  85. package/dist/semiotic-realtime-core.module.min.js +1 -1
  86. package/dist/semiotic-recipes-core.module.min.js +1 -1
  87. package/dist/semiotic-recipes.module.min.js +1 -1
  88. package/dist/semiotic-server-edge.min.js +1 -1
  89. package/dist/semiotic-server-edge.module.min.js +1 -1
  90. package/dist/semiotic-server-node.min.js +1 -1
  91. package/dist/semiotic-server-node.module.min.js +1 -1
  92. package/dist/semiotic-utils-core.module.min.js +1 -1
  93. package/dist/semiotic-utils.module.min.js +1 -1
  94. package/dist/semiotic.min.js +1 -1
  95. package/dist/semiotic.module.min.js +1 -1
  96. package/dist/server.min.js +1 -1
  97. package/dist/server.module.min.js +1 -1
  98. package/dist/xy.min.js +1 -1
  99. package/dist/xy.module.min.js +1 -1
  100. package/package.json +1 -1
  101. package/dist/chunk-chunk-6F6GEAQU.module.min.js +0 -1
  102. package/dist/chunk-chunk-BHYTYMY2.module.min.js +0 -2
  103. package/dist/chunk-chunk-E7MIQX7D.module.min.js +0 -2
  104. package/dist/chunk-chunk-ES4DCG3L.module.min.js +0 -1
  105. package/dist/chunk-chunk-IFYPMWKY.module.min.js +0 -1
  106. package/dist/chunk-chunk-L6D3I3V7.module.min.js +0 -2
  107. package/dist/chunk-chunk-ODUZEEBH.module.min.js +0 -2
  108. package/dist/chunk-chunk-P6UBCMSQ.module.min.js +0 -2
  109. package/dist/chunk-chunk-STZFFTAN.module.min.js +0 -2
  110. package/dist/chunk-chunk-U3AGQ5EF.module.min.js +0 -2
  111. package/dist/chunk-chunk-WDIN4LRC.module.min.js +0 -1
  112. package/dist/chunk-chunk-XOYX77KF.module.min.js +0 -2
  113. package/dist/chunk-chunk-ZTNVDWAK.module.min.js +0 -2
@@ -1 +1 @@
1
- import{buildCollisionSwarmPhysics as e,buildEventDropPhysics as t,buildGaltonBoardPhysics as o,buildPhysicalFlowPhysics as i,buildPhysicsPile as s,buildProcessFlowPhysics as r,generateGaltonMechanicalSamples as n,generatePhysicsPileMechanicalSamples as a,physicsBodiesToXYSceneNodes as c,renderPhysicsSettledSVG as l,resolveCustomLayout as h,styleFromColorAccessor as d}from"./chunk-chunk-2VUEY5TH.module.min.js";import{composeStyleRules as u,makeNodeRuleContext as g,styleRulesToNodeStyle as p,styleRulesToPieceStyle as f,styleRulesToXYStyle as y}from"./chunk-chunk-EMO5NUGE.module.min.js";import{PhysicsPipelineStore as m}from"./chunk-chunk-DNY43POY.module.min.js";import"./chunk-chunk-SIRIJ3DY.module.min.js";import{PipelineStore as x,attachUpdateResultStore as b,buildDatumIndexMap as A,buildRectNode as v,buildRibbonGeometry as S,compactTimestampBufferForRemoval as w,computeDecayOpacity as k,computePulseIntensity as _,createCustomLayoutFailureDiagnostic as M,createTimestampBufferForData as T,ensureRingBufferCapacity as P,getLayoutPlugin as R,hasActivePulses as z,pushWithTimestamp as L,renderSceneWithBackend as F,setPulseState as C,ticksForMode as B,toIdSet as D,warnCustomLayoutDiagnostics as E}from"./chunk-chunk-T27ZEV6A.module.min.js";import{IncrementalExtent as O,RingBuffer as j}from"./chunk-chunk-VVCA3DB7.module.min.js";import"./chunk-chunk-H4PPRW6N.module.min.js";import{AnnotationLabel as N,DEFAULT_COLOR as W,STREAMING_PALETTE as $,SemioticAnnotation as I,TITLE_BASELINE as G,applyAnnotationEmphasis as V,buildResolveColor as Y,computeEasing as H,computeRawProgress as X,createColorScale as q,filterSparseArray as Q,geoSceneNodeToSVG as Z,getColor as U,getSize as K,hasTextTitle as J,isGradientLegendConfig as ee,isLegendConfig as te,lerp as oe,networkLabelToSVG as ie,networkSceneEdgeToSVG as se,networkSceneNodeToSVG as re,now as ne,ordinalSceneNodeToSVG as ae,reserveTitleMargin as ce,resolveCustomLayoutPalette as le,resolveExplicitColor as he,xySceneNodeToSVG as de}from"./chunk-chunk-ES4DCG3L.module.min.js";import"./chunk-chunk-XEVJDUTH.module.min.js";import{accessorsEquivalent as ue,resolveAccessor as ge,resolveStringAccessor as pe,resolveSvgFill as fe}from"./chunk-chunk-2WVCH4PL.module.min.js";import{SYMBOL_SEQUENCE as ye,UpdateResultTracker as me,annotationLayout as xe,getSequentialInterpolator as be,interpolateViridis as Ae,schemeCategory10 as ve}from"./chunk-chunk-NO4MCQVD.module.min.js";import"./chunk-chunk-U66USBWU.module.min.js";import{getMax as Se,getMin as we,getMinMax as ke}from"./chunk-chunk-JJ2OOIET.module.min.js";import"./chunk-chunk-J3QOW4OE.module.min.js";import{DARK_THEME as _e,HIGH_CONTRAST_THEME as Me,LIGHT_THEME as Te,THEME_PRESETS as Pe,applyThemeAccessibility as Re,resolveThemeSemanticColors as ze}from"./chunk-chunk-DSNGDNJY.module.min.js";import*as Le from"react-dom/server";import*as Fe from"react";function Ce(e,t,o){return"function"==typeof e?e(o):o[e||t]}function Be(e){return e instanceof Date?e.getTime():Number(e)}function De(e,t){return Ae(1===t?.5:e/(t-1))}function Ee(e){return Math.max(0,Math.min(1,e))}function Oe(e){const t=e.trim();if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e.split("").map(e=>e+e).join("")),6===e.length&&/^[0-9a-f]{6}$/i.test(e))return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const o=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(o){const e=[Number(o[1]),Number(o[2]),Number(o[3])];if(e.every(Number.isFinite))return e}return null}function je(e,t,o){const i=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return`#${i(e)}${i(t)}${i(o)}`}function Ne(e,t){const o=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Ee(e.offset),color:e.color})).sort((e,t)=>e.offset-t.offset);if(0===o.length)return"#999999";if(1===o.length)return o[0].color;const i=Ee(t);if(o[0].offset>=i)return o[0].color;if(i>=o[o.length-1].offset)return o[o.length-1].color;for(let e=0;o.length-1>e;e++){const t=o[e],s=o[e+1];if(t.offset>i||i>s.offset)continue;const r=s.offset-t.offset,n=r>0?(i-t.offset)/r:0,a=Oe(t.color),c=Oe(s.color);if(!a||!c)return.5>n?t.color:s.color;const[l,h,d]=a,[u,g,p]=c;return je(l+(u-l)*n,h+(g-h)*n,d+(p-d)*n)}return o[o.length-1].color}function We(e,t,o){return null==o?`${e}-${t}`:`${e}-${t}-${o}`}function $e(e){return!0===e?{topOpacity:.8,bottomOpacity:.05}:!1===e?void 0:e}import{scaleTime as Ie}from"d3-scale";function Ge(e){return"invalid-node-time"===e.kind?`node ${e.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===e.kind?`edge ${e.id} has an invalid startTime or endTime`:"invalid-domain"===e.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===e.kind?`edge ${e.id} must have a positive finite value`:"missing-node"===e.kind?`edge ${e.id} references missing ${e.endpoint} node "${e.nodeId}"`:"backward-edge"===e.kind?`edge ${e.id} (${e.source}->${e.target}) ends before it starts`:e.kind}function Ve(e,t,o){const i=t.incoming[e.id],s=t.outgoing[e.id],r=[];for(const e of i)r.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:o.get(e.id).targetSide});for(const e of s)r.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:o.get(e.id).sourceSide});const n={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{r.sort((e,t)=>e.time-t.time||(n[e.kind]??99)-(n[t.kind]??99))},c=r.length?we(r.map(e=>e.time)):null,l=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,h=null!=l?l-1:null!=c&&Number.isFinite(c)?c-1:null,d=[...new Set(r.map(e=>e.time))].sort((e,t)=>e-t),u=new Map;for(let e=1;d.length>e;e++)u.set(d[e],d[e-1]);const g=e=>{const t=u.get(e);return null!=t?(t+e)/2:null!=h?h:e};a();const p=[];let f=0,y=0;for(const e of r)if("out"===e.kind){const t=Math.abs(e.delta);let o=t-("top"===e.side?f:y);if(o>0){const t="top"===e.side?"bot":"top",i=Math.min(o,"top"===t?f:y);if(i>0){const s=g(e.time);p.push({time:s,delta:-i,kind:"transfer-out",side:t}),p.push({time:s,delta:+i,kind:"transfer-in",side:e.side}),"top"===t?f-=i:y-=i,"top"===e.side?f+=i:y+=i,o-=i}o>0&&null!==h&&(p.push({time:h,delta:+o,kind:"create",side:e.side}),"top"===e.side?f+=o:y+=o)}"top"===e.side?f-=t:y-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?f+=t:y+=t}r.push(...p),a();let m=0,x=0,b=0,A=0,v=0;const S=[],w=new Map;for(const e of r){if(S.push({t:e.time,topMass:m,botMass:x}),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?m:x;w.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta)})}"top"===e.side?m+=e.delta:x+=e.delta,m+x>b&&(b=m+x),m>A&&(A=m),x>v&&(v=x),S.push({t:e.time,topMass:m,botMass:x})}const k=[];let _=0;for(;S.length>_;){let e=_;for(;S.length>e+1&&S[e+1].t===S[_].t;)e++;k.push(S[_]);for(let t=_+1;e>=t;t++){const e=k[k.length-1];S[t].topMass===e.topMass&&S[t].botMass===e.botMass||k.push(S[t])}_=e+1}const M=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let T=null;for(const e of s)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===T||T>e.systemInTime)&&(T=e.systemInTime);let P=null;for(const e of i)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===P||e.systemOutTime>P)&&(P=e.systemOutTime);if(k.length>0){const e=k[k.length-1],t=Math.max(null!=M?M:-1/0,null!=P?P:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&k.push({t:t,topMass:e.topMass,botMass:e.botMass});const o=k[0],i=Math.min(null!=l?l:1/0,null!=T?T:1/0);Number.isFinite(i)&&o.t>i&&o.topMass+o.botMass>0&&k.unshift({t:i,topMass:o.topMass,botMass:o.botMass})}return{samples:k,peak:b,topPeak:A,botPeak:v,localAttachments:w}}function Ye(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function He(e,t){return e.map(e=>({t:Ye(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function Xe(e,t,o){const i=e.value*o;if("out"===e.kind){const s=e.sideMassBefore*o;if("top"===e.side){const e=t-s;return[e,e+i]}const r=t+s;return[r-i,r]}const s=e.sideMassAfter*o;if("top"===e.side){const e=t-s;return[e,e+i]}const r=t+s;return[r-i,r]}function qe(e,t){let o=0;for(let i=0;t.length>i;i++)for(let s=i+1;t.length>s;s++){const r=t[i],n=t[s];r.source!==n.source&&r.target!==n.target&&r.source!==n.target&&r.target!==n.source&&(Math.min(r.endTime,n.endTime)>Math.max(r.startTime,n.startTime)&&e[n.source]>e[r.source]!=e[n.target]>e[r.target]&&o++)}return o}function Qe(e,t){let o=0;for(const i of t)o+=Math.abs(e[i.source]-e[i.target])*(i.value||1);return o}function Ze(e,t){return 1e3*qe(e,t)+Qe(e,t)}function Ue(e,t){return{slots:e.map(e=>({peak:{...e.peak},occupants:e.occupants.slice()})),map:{...t}}}function Ke(e,t,o){e.length>8||o.length>40?(function(e,t,o,i=6){const s=e.length;if(1>=s)return;let r=Ue(e,t),n=Ze(t,o);for(let a=0;i>a;a++){const i=Array(s).fill(0),a=Array(s).fill(0);for(const e of o){const o=t[e.source],s=t[e.target];i[o]+=s*(e.value||1),a[o]+=e.value||1,i[s]+=o*(e.value||1),a[s]+=e.value||1}const c=Array.from({length:s},(e,t)=>t).sort((e,t)=>(a[e]>0?i[e]/a[e]:e)-(a[t]>0?i[t]/a[t]:t)),l=c.map(t=>e[t]),h=new Map;c.forEach((e,t)=>h.set(e,t));for(const e of Object.keys(t))t[e]=h.get(t[e]);e.length=0;for(const t of l)e.push(t);const d=Ze(t,o);if(n>d)n=d,r=Ue(e,t);else if(d===n)break}!function(e,t,o){e.length=0;for(const t of o.slots)e.push(t);for(const e of Object.keys(t))delete t[e];for(const e of Object.keys(o.map))t[e]=o.map[e]}(e,t,r)}(e,t,o,6),function(e,t,o,i=6){const s=e.length;if(1>=s)return;let r=Ze(t,o);for(let n=0;i>n;n++){let i=!1;for(let n=0;s-1>n;n++){const s=e[n];e[n]=e[n+1],e[n+1]=s;for(const e of Object.keys(t))t[e]===n?t[e]=n+1:t[e]===n+1&&(t[e]=n);const a=Ze(t,o);if(r>a)r=a,i=!0;else{const o=e[n];e[n]=e[n+1],e[n+1]=o;for(const e of Object.keys(t))t[e]===n?t[e]=n+1:t[e]===n+1&&(t[e]=n)}}if(!i)break}}(e,t,o,6)):function(e,t,o){const i=e.length;if(1>=i)return;const s={...t},r=Object.keys(s),n=Array.from({length:i},(e,t)=>t),a=n.slice(),c={...s};let l=n.slice(),h=1/0;const d=()=>{for(const e of r)c[e]=a[s[e]];const e=Ze(c,o);h>e&&(h=e,l=n.slice())},u=(e,t)=>{const o=n[e],i=n[t];n[e]=i,n[t]=o,a[o]=t,a[i]=e};d();const g=Array(i).fill(0);let p=0;for(;i>p;)p>g[p]?(u(p%2==0?0:g[p],p),d(),g[p]++,p=0):(g[p]=0,p++);const f=l.map(t=>e[t]),y=new Map;l.forEach((e,t)=>y.set(e,t));for(const e of Object.keys(t))t[e]=y.get(t[e]);e.length=0;for(const t of f)e.push(t)}(e,t,o)}function Je(e,t,o,i,s){const{plotH:r,padding:n,valueScale:a,packing:c,laneOrder:l,lifetimeMode:h="full"}=s,d={},u={};for(const t of e)d[t.id]=o[t.id].topPeak||0,u[t.id]=o[t.id].botPeak||0;const g="half"===h,p={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,o=Array.isArray(t.xExtent)?t.xExtent[1]:null;let s=null!=e&&Number.isFinite(e)?e:1/0,r=null!=o&&Number.isFinite(o)?o:-1/0;for(const e of i.outgoing[t.id]){s>e.startTime&&(s=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&s>e.systemInTime&&(s=e.systemInTime);const t=g?(e.startTime+e.endTime)/2:e.endTime;t>r&&(r=t)}for(const e of i.incoming[t.id]){const t=g?(e.startTime+e.endTime)/2:e.startTime;s>t&&(s=t),e.endTime>r&&(r=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>r&&(r=e.systemOutTime)}p[t.id]={start:Number.isFinite(s)?s:null,end:Number.isFinite(r)?r:null}}const f={},y=[];if("reuse"===c){const o=new Map;for(const t of e)o.set(t.id,0);const s=new Map;for(const t of e)s.set(t.id,0);for(const e of t)s.set(e.target,(s.get(e.target)??0)+1);const r=[];for(const t of e)0===(s.get(t.id)??0)&&r.push(t.id);for(;r.length;){const e=r.shift();for(const t of i.outgoing[e]??[]){const i=(o.get(e)??0)+1;i>(o.get(t.target)??0)&&o.set(t.target,i),s.set(t.target,s.get(t.target)-1),0===s.get(t.target)&&r.push(t.target)}}const n=[...e].filter(e=>null!==p[e.id].start).sort((e,t)=>{const i=o.get(e.id)??0,s=o.get(t.id)??0;return i!==s?i-s:p[e.id].start-p[t.id].start}),a=e.filter(e=>null===p[e.id].start);for(const e of[...n,...a]){const t=p[e.id];let o=-1;for(let e=0;y.length>e;e++){const i=y[e].occupants[y[e].occupants.length-1];if(null===t.start||void 0===i||t.start>=i.end){o=e;break}}-1===o&&(y.push({occupants:[],peak:{topPeak:0,botPeak:0}}),o=y.length-1),y[o].occupants.push({id:e.id,end:t?.end??-1/0}),y[o].peak.topPeak=Math.max(y[o].peak.topPeak,d[e.id]),y[o].peak.botPeak=Math.max(y[o].peak.botPeak,u[e.id]),f[e.id]=o}}else e.forEach((e,t)=>{y.push({occupants:[{id:e.id,end:p[e.id]?.end??-1/0}],peak:{topPeak:d[e.id],botPeak:u[e.id]}}),f[e.id]=t});let m=null,x=null,b=null,A=null;const v=()=>{m=qe(f,t),b=Qe(f,t)},S=()=>{x=qe(f,t),A=Qe(f,t)};"crossing-min"===l?(v(),Ke(y,f,t),S()):"inside-out"===l?(v(),function(e,t){const o=e.length;if(1>=o)return;const i=e=>e.peak.topPeak+e.peak.botPeak,s=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>i(t.slot)-i(e.slot)),r=Array(o),n=Math.floor((o-1)/2);r[n]=s[0].idx;let a=n-1,c=n+1;for(let e=1;s.length>e;e++)e%2==1&&o>c||0>a?r[c++]=s[e].idx:r[a--]=s[e].idx;const l=r.map(t=>e[t]),h=new Map;r.forEach((e,t)=>h.set(e,t));for(const e of Object.keys(t))t[e]=h.get(t[e]);e.length=0;for(const t of l)e.push(t)}(y,f),S()):"crossing-min+inside-out"===l&&(v(),Ke(y,f,t),function(e,t,o){const i=e.length;if(1>=i)return;const s=e.map(e=>{return{slot:e,size:(t=e,t.peak.topPeak+t.peak.botPeak)};var t}).sort((e,t)=>t.size-e.size),r=Math.floor((i-1)/2);let n=Ze(t,o);for(const{slot:a}of s){const s=e.indexOf(a);if(0>s)continue;const c=r;if(s===c)continue;const l=e[s];e.splice(s,1),e.splice(c,0,l);const h=new Map;for(let e=0;i>e;e++)h.set(e,e);if(c>s){for(let e=s+1;c>=e;e++)h.set(e,e-1);h.set(s,c)}else{for(let e=c;s>e;e++)h.set(e,e+1);h.set(s,c)}for(const e of Object.keys(t))t[e]=h.get(t[e]);const d=Ze(t,o);if(d>n){const o=e[c];e.splice(c,1),e.splice(s,0,o);const r=new Map;for(let e=0;i>e;e++)r.set(e,e);if(s>c){for(let e=c+1;s>=e;e++)r.set(e,e-1);r.set(c,s)}else{for(let e=s;c>e;e++)r.set(e,e+1);r.set(c,s)}for(const e of Object.keys(t))t[e]=r.get(t[e])}else n=d}}(y,f,t),S());const w=y.map(e=>{const t=new Map;for(const i of e.occupants){const e=o[i.id];if(e)for(const o of e.samples){const e=t.get(o.t)||{top:0,bot:0};t.set(o.t,{top:Math.max(e.top,o.topMass),bot:Math.max(e.bot,o.botMass)})}}return[...t.entries()].sort((e,t)=>e[0]-t[0])}),k=(e,t)=>{let o={top:0,bot:0};for(const[i,s]of e){if(i>t)break;o=s}return o},_=[];for(let e=0;y.length-1>e;e++){const t=w[e],o=w[e+1],i=new Set([...t.map(e=>e[0]),...o.map(e=>e[0])]);let s=0;for(const e of i){const i=k(t,e),r=k(o,e);i.bot+r.top>s&&(s=i.bot+r.top)}_.push(s)}const M=[];let T=n+(y[0]?.peak.topPeak??0)*a;y.length>0&&M.push(T);for(let e=1;y.length>e;e++)T+=_[e-1]*a+n,M.push(T);if(y.length>0&&(T+=y[y.length-1].peak.botPeak*a+n),T>r){const e=r/T;for(let t=0;M.length>t;t++)M[t]*=e}const P=0===y.length?0:y[0].peak.topPeak+_.reduce((e,t)=>e+t,0)+y[y.length-1].peak.botPeak,R={};for(const t of e)R[t.id]=M[f[t.id]];return{effectiveSlotsHeight:P,centerlines:R,laneLifetime:p,slots:y,slotByNode:f,slotCenter:M,crossingsBefore:m,crossingsAfter:x,lengthBefore:b,lengthAfter:A}}function et(e){const{nodes:t,edges:o,domain:i,plotW:s,plotH:r,ribbonLane:n,edgeOpacity:a,colorOf:c,layoutOpts:l}=e,h=function(e,t,o){const i=[],s=new Set(e.map(e=>e.id)),r=Array.isArray(o)&&2===o.length,n=r&&Number.isFinite(o[0])&&Number.isFinite(o[1]);r&&n&&n&&o[1]>=o[0]||i.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||i.push({kind:"invalid-node-time",id:t.id}));for(const e of t)s.has(e.source)||i.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),s.has(e.target)||i.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?(Number.isFinite(e.value)&&e.value>0||i.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||i.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):i.push({kind:"invalid-edge-time",id:e.id});return i}(t,o,i),d=Ie().domain(i).range([0,s]);if(h.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:h,xScale:d};const u=function(e,t,o){const{plotH:i,pairing:s="temporal",packing:r="reuse",laneOrder:n="crossing-min",lifetimeMode:a="half"}=o,c=function(e,t){const o={},i={};for(const t of e)o[t.id]=[],i[t.id]=[];for(const e of t)i[e.source]&&i[e.source].push(e),o[e.target]&&o[e.target].push(e);return{incoming:o,outgoing:i}}(e,t),l=function(e,t,o,i="value"){const s="temporal"===i?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,r="temporal"===i?(e,t)=>e.startTime-t.startTime:(e,t)=>t.value-e.value,n=new Map;for(const e of t)n.set(e.id,{});const a=(e,t)=>{const o=new Map;for(const i of e){const e=i[t];o.has(e)||o.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const s=o.get(e);s.edges.push(i),s.total+=i.value,s.earliestStart=Math.min(s.earliestStart,i.startTime),s.latestEnd=Math.max(s.latestEnd,i.endTime)}const n=[...o.values()];n.sort("temporal"===i?(e,o)=>"target"===t?e.earliestStart-o.earliestStart:e.latestEnd-o.latestEnd:(e,t)=>t.total-e.total);for(const e of n)e.edges.sort("target"===t?r:s);return n};for(const t of e){const e=o.outgoing[t.id],i=o.incoming[t.id];if(0===i.length)a(e,"target").forEach((e,t)=>{const o=t%2==0?"top":"bot";for(const t of e.edges)n.get(t.id).sourceSide=o});else if(0===e.length)a(i,"source").forEach((e,t)=>{const o=t%2==0?"top":"bot";for(const t of e.edges)n.get(t.id).targetSide=o});else{const t=a(i,"source"),o=a(e,"target"),s=Math.max(t.length,o.length);for(let e=0;s>e;e++){const i=e%2==0?"top":"bot";if(t[e])for(const o of t[e].edges)n.get(o.id).targetSide=i;if(o[e])for(const t of o[e].edges)n.get(t.id).sourceSide=i}}}return n}(e,t,c,s);let h={};for(const t of e)h[t.id]=Ve(t,c,l);const d=Je(e,t,h,c,{plotH:i,padding:12,valueScale:1,packing:r,laneOrder:n,lifetimeMode:a}),u=new Set;for(const e of t){const t=d.slotByNode[e.source],o=d.slotByNode[e.target];if(void 0===t||void 0===o)continue;const i=l.get(e.id);t!==o?t>o?(i.sourceSide="top",i.targetSide="bot"):(i.sourceSide="bot",i.targetSide="top"):(u.add(e.id),i.sourceSide="bot",i.targetSide="bot")}for(const t of e){const e=c.outgoing[t.id],o=c.incoming[t.id],i=new Set(e.map(e=>l.get(e.id).sourceSide)),s=new Set(o.map(e=>l.get(e.id).targetSide));if(1===i.size&&o.length>0){const e=[...i][0];for(const t of o)d.slotByNode[t.source]===d.slotByNode[t.target]&&(l.get(t.id).targetSide=e)}if(1===s.size&&e.length>0){const t=[...s][0];for(const o of e)d.slotByNode[o.source]===d.slotByNode[o.target]&&(l.get(o.id).sourceSide=t)}}for(const t of e){const e=c.incoming[t.id],o=c.outgoing[t.id];if(0===e.length||0===o.length)continue;const i=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const o of e)"top"===l.get(o.id).targetSide?t.inTop+=o.value:t.inBot+=o.value;for(const e of o)"top"===l.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},s=(e,t)=>{const s=i(),r="top"===e?s.outTop-s.inTop:s.outBot-s.inBot,n="top"===t?s.inTop-s.outTop:s.inBot-s.outBot;if(0>=r||0>=n)return!1;const a=Math.min(r,n),c=o.filter(t=>!u.has(t.id)&&l.get(t.id).sourceSide===e&&a>=t.value).sort((e,t)=>t.value-e.value);return 0!==c.length&&(l.get(c[0].id).sourceSide=t,!0)};let r=o.length+1;for(;r-- >0&&(s("top","bot")||s("bot","top")););}h={};for(const t of e)h[t.id]=Ve(t,c,l);const g=Je(e,t,h,c,{plotH:i,padding:12,valueScale:1,packing:r,laneOrder:n,lifetimeMode:a}),p=g.effectiveSlotsHeight??g.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),f=Math.min(12,.35*i/Math.max(g.slots.length+1,1)),y=p>0?Math.max(0,(i-f*(g.slots.length+1))/p):1,m=Je(e,t,h,c,{plotH:i,padding:f,valueScale:y,packing:r,laneOrder:n,lifetimeMode:a});return{nodeData:h,sides:l,valueScale:y,padding:f,compressedPadding:12>f,centerlines:m.centerlines,laneLifetime:m.laneLifetime,slots:m.slots,slotByNode:m.slotByNode,crossingsBefore:m.crossingsBefore,crossingsAfter:m.crossingsAfter,lengthBefore:m.lengthBefore,lengthAfter:m.lengthAfter}}(t,o,{plotH:r,...l}),{centerlines:g,nodeData:p,valueScale:f}=u,y=[],m=[];t.forEach((e,t)=>{const s=p[e.id];if(!s||0===s.samples.length)return;const r=function(e,t,o,i,s){if(0===e.length)return null;const r=He(e,s),n=e=>t-r[e].topMass*o,a=e=>t+r[e].botMass*o;let c=`M${i(r[0].t)},${n(0)}`;for(let e=1;r.length>e;e++)c+=` L${i(r[e].t)},${n(e)}`;c+=` L${i(r[r.length-1].t)},${a(r.length-1)}`;for(let e=r.length-2;e>=0;e--)c+=` L${i(r[e].t)},${a(e)}`;return c+" Z"}(s.samples,g[e.id],f,d,i);if(!r)return;const n=He(s.samples,i),a=n.find(e=>e.topMass+e.botMass>0)||n[0],l=g[e.id]+(a.botMass-a.topMass)*f/2,h=c(e.id,t),m=function(e,t,o,i,s){const r=o.nodeData[e];if(!r||0===r.samples.length)return[];const n=o.valueScale,a=o.centerlines[e],c=He(r.samples,s),l=c.find(e=>e.topMass+e.botMass>0)||c[0],h=[...c].reverse().find(e=>e.topMass+e.botMass>0)||c[c.length-1],d=i(l.t),u=i(h.t),g=e=>i(Ye(e,s)),p=[],f=(e,t,o,i)=>`M${e},${t} L${o},${t} L${o},${i} L${e},${i} Z`;for(const o of t){if(o.source===e&&null!=o.systemInTime&&Number.isFinite(o.systemInTime)){const e=r.localAttachments.get(o.id);if(e&&"out"===e.kind&&o.startTime>o.systemInTime){const t=g(o.systemInTime),i=g(o.startTime),s=t-20,r=Math.max(d,s);if(i>r){const[o,c]=Xe(e,a,n);p.push({pathD:f(r,o,i,c),x0:s,x1:t,from:0,to:1})}}}if(o.target===e&&null!=o.systemOutTime&&Number.isFinite(o.systemOutTime)){const e=r.localAttachments.get(o.id);if(e&&"in"===e.kind&&o.systemOutTime>o.endTime){const t=g(o.systemOutTime),i=g(o.endTime),s=t+20,r=Math.min(u,s);if(r>i){const[o,c]=Xe(e,a,n);p.push({pathD:f(i,o,r,c),x0:t,x1:s,from:1,to:0})}}}}return p}(e.id,o,u,d,i);y.push({id:e.id,pathD:r,fill:h,stroke:h,strokeWidth:.5,...m.length>0&&{gradientStubs:m},rawDatum:e.__raw??e,labelX:d(a.t)-4,labelY:l,labelText:e.id})});const x=new Map;return t.forEach((e,t)=>x.set(e.id,t)),o.forEach(e=>{const t=p[e.source]?.localAttachments.get(e.id),o=p[e.target]?.localAttachments.get(e.id);if(!t||!o)return;const s=x.get(e.source)??0,r=c(e.source,s),l=function(e,t,o,i,s,r,n,a){const c=s,l=e=>a?Math.max(a[0],Math.min(a[1],e)):e,h=r(l(e.time)),d=r(l(o.time)),u=e.value*c,g=o.value*c,p=e.sideMassBefore*c,f=o.sideMassAfter*c;let y,m,x,b;"top"===e.side?(y=t-p,m=y+u):(m=t+p,y=m-u),"top"===o.side?(x=i-f,b=x+g):(b=i+f,x=b-g);const A="source"===n?h+.85*(d-h):"target"===n?h+.15*(d-h):(h+d)/2;return{sx:h,sTop:y,sBot:m,tx:d,tTop:x,tBot:b,cp1X:A,cp2X:A}}(t,g[e.source],o,g[e.target],f,d,n,i),{pathD:h,bezier:u}=S(l);m.push({id:e.id,pathD:h,fill:r,opacity:a,rawDatum:e.__raw??e,bezier:u})}),{layout:u,layoutConfig:{bands:y,ribbons:m,showLabels:!0},issues:[],xScale:d}}var tt=e=>{const{bands:t=[],ribbons:o=[],showLabels:i=!0}=e.config,s=[];for(const e of o)s.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:e.opacity,stroke:"none"},datum:{__kind:"ribbon",data:e.rawDatum,id:e.id}});for(const e of t)if(e.gradientStubs)for(let t=0;e.gradientStubs.length>t;t++){const o=e.gradientStubs[t];s.push({type:"bezier",pathD:o.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:o.x0,x1:o.x1,from:o.from,to:o.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${t}`}})}for(const e of t)s.push({type:"bezier",pathD:e.pathD,style:{...e.gradientStubs&&e.gradientStubs.length>0?{fill:"none"}:{fill:e.fill,fillOpacity:.86},stroke:e.stroke??e.fill,strokeWidth:e.strokeWidth??.5},datum:{__kind:"band",data:e.rawDatum,id:e.id}});const r=i?t.map(e=>({x:e.labelX,y:e.labelY,text:e.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:t.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:s,labels:r}};import{scaleSequential as ot}from"d3-scale";function it(e){return e&&"object"==typeof e&&e.properties?{...e.properties,...e}:e}function st(e){return[{id:"gauntlet-left",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:76,x2:28,y2:e.floorY,thickness:8}},{id:"gauntlet-ceiling",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:76,x2:e.width-30,y2:76,thickness:8}},{id:"gauntlet-floor",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:e.floorY,x2:e.width-30,y2:e.floorY,thickness:8}},{id:"gauntlet-right",restitution:.12,friction:.42,shape:{type:"segment",x1:e.width-30,y1:76,x2:e.width-30,y2:e.floorY,thickness:8}}]}function rt(e,t,o,i){return o?"function"==typeof o?o(e,t):e[o]??i:i}function nt(e){return`gauntlet:${e}:core`}function at(e,t){return`gauntlet:${e}:positive:${t}`}function ct(e,t,o){return`gauntlet:${e}:negative:${t}:${o}`}function lt(e,t,o,i){const s=Math.max(2,o+2),r=80+s,n=i.floorY-s;return{x:Math.max(32+s,Math.min(i.width-30-4-s,e)),y:Math.max(r,Math.min(n,t))}}function ht(e,t){const o=[...e].sort((e,t)=>e.localeCompare(t)),i=Math.max(0,o.indexOf(t));return{angle:.82*-Math.PI+(o.length>1?i/(o.length-1):.5)*Math.PI*.64,index:i,radius:48+i%2*6}}function dt(e,t,o){const i=e.activePositiveIds.reduce((e,o)=>e+(t.get(o)?.value??1),0),s=e.missingPositiveIds.length+e.poppedPositiveIds.length,r=e.negativeIds.reduce((e,t)=>e+(o.get(t)?.load??1),0);return Math.max(0,Math.min(100,75+3*i-8*r-1.2*e.delay-5*s))}function ut(e){const t=function(e,t,o){const[i,s]=e,r=Math.round(.48*s),n=s-36,a=(t??[]).filter(e=>!1!==e.enabled),c=Math.max(1,a.length),l=.22*i,h=c>1?(.78*i-l)/(c-1):0,d=Math.max(Math.round(.14*i),110);return{crashY:n-o,floorY:n,gates:a.map((e,t)=>({...e,id:e.id,x:e.x??Math.round(l+t*h),width:e.width??Math.max(54,Math.round(.07*i))})),graveyardX:Math.round(.84*i),graveyardY:n-4,height:s,routeY:r,socketX:Math.round(.92*i),startX:d,width:i}}(e.size??[900,520],e.gates,e.crashOffset??30),o=e.positiveProperties??[],i=new Map(o.map(e=>[e.id,e])),s=new Map((e.negativeProperties??[]).map(e=>[e.id,e])),r={idAccessor:e.idAccessor,initialViability:e.initialViability,metricsAccessor:e.metricsAccessor,negativeAccessor:e.negativeAccessor,positiveAccessor:e.positiveAccessor,startTimeAccessor:e.startTimeAccessor},n=(e.data??[]).map((t,n)=>{const a=function(e,t,o,i,s){const r=rt(e,t,o.idAccessor,null!=e.id?e.id+"":"project-"+t)+"",n=i.map(e=>e.id),a=[...rt(e,t,o.positiveAccessor,n)],c=[...rt(e,t,o.negativeAccessor,[])].filter(e=>s.has(e));return{id:r,activePositiveIds:a,datum:e,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...rt(e,t,o.metricsAccessor,{})},missingPositiveIds:n.filter(e=>!a.includes(e)),negativeIds:c,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(rt(e,t,o.startTimeAccessor,0))||0),stage:"project filed",viability:rt(e,t,o.initialViability,100)}}(t,n,r,o,s);return{...a,viability:e.viability?.(a,{negativeProperties:s,positiveProperties:i})??dt(a,i,s)}}),a=n.flatMap((o,r)=>{const n=function(e,t,o,i){const s=function(e){return{graveyardX:e.graveyardX,graveyardY:e.graveyardY,routeY:e.routeY,socketX:e.socketX,socketY:e.routeY-4,startX:e.startX,startY:e.routeY}}(o),r=i?.(e,t,o)??{};return{...s,...r,startY:r.startY??r.routeY??s.startY,socketY:r.socketY??r.routeY??s.socketY,graveyardY:r.graveyardY??s.graveyardY}}(o,r,t,e.projectPlacement);return function(e,t,o,i,s,r,n){const a=i.startX,c=i.startY+(i.startY===o.routeY?38*t:0),l=n?.(e,t,o,i)??{},h={__gauntlet:!0,kind:"gauntlet-core",projectId:e.id,sourceDatum:e.datum},d=[{...l,id:nt(e.id),x:l.x??a,y:l.y??c,vx:l.vx??42,vy:l.vy??0,mass:l.mass??7,bodyCollisions:l.bodyCollisions??!0,shape:l.shape??{type:"circle",radius:28},spawnAt:l.spawnAt??e.startedAt,datum:h}],u=lt(a,c,l.shape&&"radius"in l.shape&&Number(l.shape.radius)||28,o);d[0].x=u.x,d[0].y=u.y;for(const t of e.activePositiveIds){const i=s.get(t);if(!i)continue;const r=ht(e.activePositiveIds,t),n=i.radius??10,a=lt(u.x+Math.cos(r.angle)*r.radius,u.y+Math.sin(r.angle)*r.radius,n,o);d.push({id:at(e.id,t),x:a.x,y:a.y,vx:18*Math.cos(r.angle),vy:18*Math.sin(r.angle),mass:i.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:n},spawnAt:l.spawnAt??e.startedAt,datum:{__gauntlet:!0,kind:"gauntlet-positive",projectId:e.id,property:i,sourceDatum:e.datum},springs:!1===i.spring?[]:[{target:{type:"body",bodyId:nt(e.id)},stiffness:.56,damping:.9,restLength:52+r.index%2*4,...i.spring??{}}]})}return e.negativeIds.forEach((t,i)=>{const s=r.get(t);s&&d.push(function(e,t,o,i,s,r,n){const a=t.radius??7.2,c=lt(i-12+o%4*12,s+54+12*Math.floor(o/4),a,r);return{id:ct(e.id,t.id,o),x:c.x,y:c.y,vx:10,vy:6,mass:t.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:a},spawnAt:n,datum:{__gauntlet:!0,kind:"gauntlet-negative",projectId:e.id,property:t,sourceDatum:e.datum},springs:!1===t.spring?[]:[{target:{type:"body",bodyId:nt(e.id)},stiffness:.62,damping:.92,restLength:52+o%4*3,...t.spring??{}}]}}(e,s,i,u.x,u.y,o,l.spawnAt??e.startedAt))}),d}(o,r,t,n,i,s,e.coreBody)});return{layout:t,initialSpawns:a,config:{fixedDt:1/60,maxSubsteps:8,kernel:{gravity:{x:0,y:0},restitution:.16,friction:.44,velocityDamping:.982,maxVelocity:520,sleepAfter:.8,sleepSpeed:7},colliders:st(t)}}}function gt(e){return e.map(e=>({...e,spawnAt:void 0}))}var pt={Sparkline:{frameType:"xy",buildProps:(e,t,o,i,s)=>({chartType:"line",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",groupAccessor:s.lineBy||t,colorAccessor:t,...i,showAxes:!1,margin:i.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0})},LineChart:{frameType:"xy",buildProps:(e,t,o,i,s)=>({chartType:"line",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",groupAccessor:s.lineBy||t,colorAccessor:t,colorScheme:o,lineStyle:s.lineStyle,...i,...s.styleRules&&{lineStyle:y(s.styleRules,s.xAccessor||"x",s.yAccessor||"y",i.lineStyle||s.lineStyle)}})},AreaChart:{frameType:"xy",buildProps:(e,t,o,i,s)=>({chartType:"area",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",y0Accessor:s.y0Accessor,groupAccessor:s.areaBy||t,colorAccessor:t,colorScheme:o,...i,...s.styleRules&&{lineStyle:y(s.styleRules,s.xAccessor||"x",s.yAccessor||"y",i.lineStyle)}})},DifferenceChart:{frameType:"xy",buildProps:(e,t,o,i,s)=>{const r=s.xAccessor||"x",n=s.seriesAAccessor||"a",a=s.seriesBAccessor||"b",c=e=>Be(Ce(r,"x",e)),l=e=>Be(Ce(n,"a",e)),h=e=>Be(Ce(a,"b",e)),d=s.seriesAColor||"var(--semiotic-danger, #dc2626)",u=s.seriesBColor||"var(--semiotic-info, #2563eb)",g=s.areaOpacity??.6,p=s.lineWidth??1.5,f=!1!==s.showLines,y=function(e,t,o,i){if(!e.length)return[];const s=e.filter(e=>Number.isFinite(t(e))).sort((e,o)=>t(e)-t(o)),r=[];let n=0,a=null,c=null,l=[];const h=(e,t)=>e>t?"A":t>e?"B":null,d=e=>`seg-${n}-${e}`,u=e=>r.push(e),g=(e,t)=>{u({__x:e.x,__y:e.y,__y0:e.y,__diffSegment:d(t),__diffWinner:t,__valA:e.y,__valB:e.y,__sourceDatum:e.datum})};for(let e=0;s.length>e;e++){const r=s[e],p=t(r),f=o(r),y=i(r);if(!Number.isFinite(p)||!Number.isFinite(f)||!Number.isFinite(y))continue;const m=h(f,y);if(null!==m)if(null!=a){if(c&&c.w!==m){let e,t;if(l.length>0)e=l[0].x,t=l[0].y;else{const o=f-c.a-(y-c.b);if(0!==o){const i=Math.max(0,Math.min(1,(c.b-c.a)/o));e=c.x+i*(p-c.x),t=c.a+i*(f-c.a)}else e=c.x,t=c.a}u({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t}),n++,a=m,u({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t});for(let e=1;l.length>e;e++)g(l[e],a)}else for(const e of l)g(e,a);l=[],u({__x:p,__y:y>f?y:f,__y0:y>f?f:y,__diffSegment:d(a),__diffWinner:a,__valA:f,__valB:y,__sourceDatum:r}),c={x:p,a:f,b:y,w:m}}else{a=m;for(const e of l)g(e,a);l=[],u({__x:p,__y:y>f?y:f,__y0:y>f?f:y,__diffSegment:d(a),__diffWinner:a,__valA:f,__valB:y,__sourceDatum:r}),c={x:p,a:f,b:y,w:m}}else l.push({x:p,y:f,datum:r})}for(const e of l)g(e,a??"A");return r}(Array.isArray(e)?e:[],c,l,h),m=[];if(f&&Array.isArray(e)){const t=e.filter(e=>Number.isFinite(c(e))).sort((e,t)=>c(e)-c(t));for(const e of t){const t=c(e),o=l(e),i=h(e);Number.isFinite(o)&&m.push({__x:t,__y:o,__diffSegment:"line-A"}),Number.isFinite(i)&&m.push({__x:t,__y:i,__diffSegment:"line-B"})}}return{chartType:"mixed",data:[...y,...m],xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:Array.from(new Set(y.map(e=>e.__diffSegment))),areaStyle:e=>{const t=e.__diffSegment;return{fill:"A"==(t?.endsWith("-A")?"A":"B")?d:u,stroke:"none",fillOpacity:g}},lineStyle:e=>({stroke:"A"==("line-A"===e.__diffSegment?"A":"B")?d:u,strokeWidth:p,fill:"none"}),curve:s.curve||"linear",...i}}},StackedAreaChart:{frameType:"xy",buildProps:(e,t,o,i,s)=>{const r=t||s.areaBy,n="string"==typeof r&&Array.isArray(e)?q(e,r,o):void 0;return{chartType:"stackedarea",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",groupAccessor:s.areaBy,colorAccessor:r,colorScheme:o,normalize:s.normalize,stackOrder:s.stackOrder,lineStyle:null==s.areaOpacity?void 0:e=>{const t=null==r?void 0:U(e,r,n),o=s.showLine??!0;return{fill:s.color??t,stroke:o?s.stroke??t:"none",...o?{strokeWidth:s.strokeWidth??s.lineWidth??2}:{},fillOpacity:s.areaOpacity,...null==s.opacity?{}:{opacity:s.opacity}}},...i}}},Scatterplot:{frameType:"xy",buildProps:(e,t,o,i,s)=>({chartType:"scatter",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",colorAccessor:t,sizeAccessor:s.sizeBy,...s.symbolBy&&{symbolAccessor:s.symbolBy},...s.symbolMap&&{symbolMap:s.symbolMap},colorScheme:o,...i,...s.styleRules&&{pointStyle:y(s.styleRules,s.xAccessor||"x",s.yAccessor||"y",i.pointStyle)}})},CandlestickChart:{frameType:"xy",buildProps:(e,t,o,i,s)=>({chartType:"candlestick",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.highAccessor||"high",highAccessor:s.highAccessor||"high",lowAccessor:s.lowAccessor||"low",openAccessor:s.openAccessor,closeAccessor:s.closeAccessor,candlestickStyle:s.candlestickStyle,...i})},BubbleChart:{frameType:"xy",buildProps:(e,t,o,i,s)=>({chartType:"scatter",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",colorAccessor:t,sizeAccessor:s.sizeBy,sizeRange:s.sizeRange||[5,40],colorScheme:o,...i})},ConnectedScatterplot:{frameType:"xy",buildProps:(e,t,o,i,s)=>{const r=function(e,t){if(!Array.isArray(e))return{data:e,orderMap:new WeakMap};const o=t.xAccessor||"x",i=t.yAccessor||"y",s=t.orderAccessor?[...e].sort((e,o)=>null==e||"object"!=typeof e?1:null==o||"object"!=typeof o?-1:Be(Ce(t.orderAccessor,"order",e))-Be(Ce(t.orderAccessor,"order",o))):e,r=new WeakMap;let n=0;for(const e of s){if(null==e||"object"!=typeof e)continue;const t=Be(Ce(o,"x",e)),s=Be(Ce(i,"y",e));Number.isFinite(t)&&Number.isFinite(s)&&n++}let a=0;for(const e of s){if(null==e||"object"!=typeof e)continue;const t=Be(Ce(o,"x",e)),s=Be(Ce(i,"y",e));Number.isFinite(t)&&Number.isFinite(s)&&r.set(e,{idx:a++,total:n})}return{data:s,orderMap:r}}(e,s),n=s.pointRadius??4;return{chartType:"line",data:r.data,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",colorAccessor:t,colorScheme:o,lineStyle:s.lineStyle||{stroke:s.stroke||"#6366f1",strokeWidth:s.strokeWidth??n,opacity:s.opacity},pointStyle:e=>{const t=r.orderMap.get(e),o=t?.idx??0,i=t?.total??1;return{fill:i>0?De(o,i):"#6366f1",stroke:"white",strokeWidth:1,r:n,fillOpacity:1}},...i}}},QuadrantChart:{frameType:"xy",buildProps:(e,t,o,i,s)=>{const r=s.xCenter,n=s.yCenter,a=s.quadrants,c=s.centerlineStyle||{},l=!1!==s.showQuadrantLabels,h=s.quadrantLabelSize??12,d=c.stroke||"#999",u=c.strokeWidth??1,g=Array.isArray(c.strokeDasharray)?c.strokeDasharray.join(","):c.strokeDasharray,p=Fe.createElement,f=a?[(e,t,o)=>{if(!t?.x||!t?.y)return null;const i=o.width,s=o.height,c=null!=r?t.x(r):i/2,f=null!=n?t.y(n):s/2;if(null!=r&&!Number.isFinite(c))return null;if(null!=n&&!Number.isFinite(f))return null;const y=Math.max(0,Math.min(i,c)),m=Math.max(0,Math.min(s,f)),x=[{c:a.topLeft,x:0,y:0,w:y,h:m},{c:a.topRight,x:y,y:0,w:i-y,h:m},{c:a.bottomLeft,x:0,y:m,w:y,h:s-m},{c:a.bottomRight,x:y,y:m,w:i-y,h:s-m}],b=l?[p("text",{key:"ltl",x:8,y:8+h,fill:a.topLeft.color,fontWeight:600,fontSize:h,opacity:.5},a.topLeft.label),p("text",{key:"ltr",x:i-8,y:8+h,fill:a.topRight.color,fontWeight:600,fontSize:h,opacity:.5,textAnchor:"end"},a.topRight.label),p("text",{key:"lbl",x:8,y:s-8,fill:a.bottomLeft.color,fontWeight:600,fontSize:h,opacity:.5},a.bottomLeft.label),p("text",{key:"lbr",x:i-8,y:s-8,fill:a.bottomRight.color,fontWeight:600,fontSize:h,opacity:.5,textAnchor:"end"},a.bottomRight.label)]:[];return p(Fe.Fragment,null,...x.map((e,t)=>e.w>0&&e.h>0?p("rect",{key:"qf-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.c.color,opacity:e.c.opacity??.08}):null),p("line",{key:"vc",x1:y,y1:0,x2:y,y2:s,stroke:d,strokeWidth:u,strokeDasharray:g}),p("line",{key:"hc",x1:0,y1:m,x2:i,y2:m,stroke:d,strokeWidth:u,strokeDasharray:g}),...b)}]:void 0;return{chartType:"scatter",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",colorAccessor:t,sizeAccessor:s.sizeBy,sizeRange:s.sizeRange,colorScheme:o,pointStyle:s.pointStyle,...i,...f&&{svgPreRenderers:f}}}},Heatmap:{frameType:"xy",buildProps:(e,t,o,i,s)=>({chartType:"heatmap",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",valueAccessor:s.valueAccessor,colorScheme:o||s.colorScheme||"blues",showValues:s.showValues,cellBorderColor:s.cellBorderColor,...i})},XYCustomChart:{frameType:"xy",buildProps:(e,t,o,i,s)=>({chartType:"custom",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",colorAccessor:t,colorScheme:o,customLayout:s.layout||s.customLayout,layoutConfig:s.layoutConfig,...i,showAxes:i.showAxes??!1})},BarChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"bar",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",projection:"horizontal"===s.orientation?"horizontal":"vertical",oSort:s.sort??!1,colorAccessor:t,colorScheme:o,barPadding:s.barPadding,...null!=s.roundedTop&&{roundedTop:s.roundedTop},...i,gradientFill:$e(i.gradientFill),...s.styleRules&&{pieceStyle:f(s.styleRules,s.valueAccessor||"value",i.pieceStyle)}})},StackedBarChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"bar",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",stackBy:s.stackBy,colorAccessor:t||s.stackBy,colorScheme:o,projection:"horizontal"===s.orientation?"horizontal":"vertical",normalize:s.normalize,oSort:s.sort??!1,barPadding:s.barPadding,...null!=s.roundedTop&&{roundedTop:s.roundedTop},...i,gradientFill:$e(i.gradientFill),...s.styleRules&&{pieceStyle:f(s.styleRules,s.valueAccessor||"value",i.pieceStyle)}})},GroupedBarChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"clusterbar",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",groupBy:s.groupBy,colorAccessor:t||s.groupBy,colorScheme:o,projection:"horizontal"===s.orientation?"horizontal":"vertical",oSort:s.sort??!1,barPadding:s.barPadding,...null!=s.roundedTop&&{roundedTop:s.roundedTop},...i,gradientFill:$e(i.gradientFill),...s.styleRules&&{pieceStyle:f(s.styleRules,s.valueAccessor||"value",i.pieceStyle)}})},PieChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"pie",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",projection:"radial",colorAccessor:t||s.categoryAccessor,colorScheme:o,...null!=s.cornerRadius&&{cornerRadius:s.cornerRadius},...i})},DonutChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"donut",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",projection:"radial",innerRadius:s.innerRadius||60,colorAccessor:t||s.categoryAccessor,colorScheme:o,...null!=s.cornerRadius&&{cornerRadius:s.cornerRadius},...i})},Histogram:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"histogram",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",projection:"horizontal",bins:s.bins,colorAccessor:t,colorScheme:o,...i})},BoxPlot:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"boxplot",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",colorScheme:o,...i})},ViolinPlot:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"violin",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",bins:s.bins,colorScheme:o,...i})},SwarmPlot:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"swarm",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",colorAccessor:t,...s.symbolBy&&{symbolAccessor:s.symbolBy},...s.symbolMap&&{symbolMap:s.symbolMap},colorScheme:o,...i})},DotPlot:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"point",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",colorAccessor:t,colorScheme:o,...i,showGrid:i.showGrid??!0})},SwimlaneChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"swimlane",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",stackBy:s.subcategoryAccessor,colorAccessor:t||s.subcategoryAccessor,categoryAccessor:s.categoryAccessor,subcategoryAccessor:s.subcategoryAccessor,colorScheme:o,projection:"horizontal"===s.orientation?"horizontal":"vertical",...null!=s.trackFill&&{trackFill:s.trackFill},...i,gradientFill:$e(i.gradientFill)})},RidgelinePlot:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"ridgeline",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",bins:s.bins,amplitude:s.amplitude,...i})},LikertChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"bar",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",stackBy:s.levelAccessor||"level",colorAccessor:t||s.levelAccessor||"level",colorScheme:o,normalize:!0,projection:"vertical"===s.orientation?"vertical":"horizontal",...i})},FunnelChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>{const r="vertical"===s.orientation;return{chartType:r?"bar-funnel":"funnel",data:e,oAccessor:s.stepAccessor||"step",rAccessor:s.valueAccessor||"value",colorAccessor:t||s.categoryAccessor,categoryAccessor:s.categoryAccessor,projection:r?"vertical":"horizontal",connectorAccessor:s.connectorAccessor,connectorStyle:s.connectorStyle,...!r&&null!=s.connectorOpacity&&{connectorOpacity:s.connectorOpacity},barPadding:r?40:0,showAxes:r,showGrid:r,colorScheme:o,...i}}},GaugeChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>{const r=s.min??0,n=s.max??100,a=s.sweep??240,c=s.arcWidth??.3,l=180+(360-a)/2,h=s.thresholds||[{value:n,color:s.color||"#4e79a7"}],d=i.gradientFill,u=function(e){const{min:t,max:o,value:i,thresholds:s,fillColor:r,backgroundColor:n,fillZones:a,showScaleLabels:c,gradientFill:l,gradientSteps:h=240}=e,d=o-t||1,u=(Math.max(t,Math.min(o,i))-t)/d;let g=s&&s.length>0?[...s].sort((e,t)=>e.value-t.value):[{value:o,color:r||"#007bff"}];g=g.map(e=>({...e,value:Math.max(t,Math.min(o,e.value))})),o>g[g.length-1].value&&g.push({value:o,color:g[g.length-1].color});const p=!!l&&l.colorStops.length>=2,f=[],y=new Map,m=[];if(p){const e=a?u:1,t=We("bg",0);if(f.push({category:t,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),y.set(t,{fill:n,opacity:.4}),e>0){const t=Math.max(1,Math.floor(h)),o=Math.max(1,Math.min(t,Math.round(e*t))),i=[];for(let t=0;o>t;t++)i.push(Ne(l.colorStops,e*(t+.5)/o));const s=We("fill",0);f.push({category:s,value:e,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:e,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:i}}),y.set(s,{fill:i[0]||n})}}else{let e=t;for(let o=0;g.length>o;o++){const i=g[o],s=(i.value-e)/d,r=(e-t)/d,c=(i.value-t)/d,l=Math.max(0,(a?Math.min(u,c):c)-r),h=a?Math.max(0,s-l):0;if(l>0){const e=We("fill",o);f.push({category:e,value:l,_zone:i.label||"Zone "+(o+1),_isFill:!0}),y.set(e,{fill:i.color})}if(h>0){const e=We("bg",o);f.push({category:e,value:h,_zone:i.label||"Zone "+(o+1),_isFill:!1}),y.set(e,{fill:n,opacity:.4})}e=i.value}}if(c&&s&&s.length>0)for(const e of s)e.value>t&&o>e.value&&m.push({type:"gauge-label",value:e.value,label:e.label||e.value+""});return{gaugeData:f,pieceStyle:(e,t)=>y.get(t||e.category)||{fill:n},gaugeAnnotations:m}}({min:r,max:n,value:s.value,thresholds:h,fillColor:s.color,backgroundColor:s.backgroundColor||"#e0e0e0",fillZones:!1!==s.fillZones,showScaleLabels:!1!==s.showScaleLabels,gradientFill:d&&"object"==typeof d&&"colorStops"in d?d:void 0}),g=i.margin||{top:20,right:20,bottom:30,left:40},[p,f]=i.size||[300,300];return{chartType:"donut",data:u.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:Math.max(10,Math.min(p-(g.left||0)-(g.right||0),f-(g.top||0)-(g.bottom||0))/2*(1-c)),sweepAngle:a,startAngle:l,oSort:!1,pieceStyle:u.pieceStyle,...null!=s.cornerRadius&&{cornerRadius:s.cornerRadius},...i,showAxes:!1,annotations:[...Array.isArray(i.annotations)?i.annotations:[],...u.gaugeAnnotations],__gauge:{gMin:r,gMax:n,sweep:a,arcWidth:c,value:s.value,startAngleDeg:l,thresholds:h}}}},OrdinalCustomChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"custom",data:e,oAccessor:s.categoryAccessor||s.oAccessor||"category",rAccessor:s.valueAccessor||s.rAccessor||"value",projection:s.projection||"vertical",colorAccessor:t,colorScheme:o,customLayout:s.layout||s.customLayout,layoutConfig:s.layoutConfig,...i,showAxes:i.showAxes??!1})},ForceDirectedGraph:{frameType:"network",buildProps:(e,t,o,i,s)=>{const{edgeWidth:r,edgeColor:n,edgeOpacity:a}=s,c=s.edgeStyle??(void 0!==r||void 0!==n||void 0!==a?e=>{const t=e?.data||e;let o=1;if("number"==typeof r)o=r;else if("function"==typeof r)o=r(t);else if("string"==typeof r){const e=t?.[r],i="number"==typeof e?e:Number(e);o=Number.isFinite(i)&&i>0?i:1}return{stroke:n??"#999",strokeWidth:o,opacity:a??.6}}:void 0);return{chartType:"force",nodes:s.nodes,edges:s.edges,nodeIDAccessor:s.nodeIdAccessor||s.nodeIDAccessor,sourceAccessor:s.sourceAccessor,targetAccessor:s.targetAccessor,colorBy:t,colorScheme:o,iterations:s.iterations,forceStrength:s.forceStrength,showLabels:s.showLabels,nodeLabel:s.nodeLabel,nodeSize:s.nodeSize,nodeSizeRange:s.nodeSizeRange,nodeStyle:p(s.styleRules,t,"number"==typeof s.nodeSize?void 0:s.nodeSize,s.nodeStyle)??s.nodeStyle,edgeStyle:c,...i}}},NetworkCustomChart:{frameType:"network",buildProps:(e,t,o,i,s)=>({chartType:"force",nodes:s.nodes||e||[],edges:s.edges||[],nodeIDAccessor:s.nodeIdAccessor||s.nodeIDAccessor||"id",sourceAccessor:s.sourceAccessor||"source",targetAccessor:s.targetAccessor||"target",valueAccessor:s.valueAccessor||"value",colorBy:t,colorScheme:o,customNetworkLayout:s.layout||s.customNetworkLayout,layoutConfig:s.layoutConfig,...i})},SankeyDiagram:{frameType:"network",buildProps:(e,t,o,i,s)=>({chartType:"sankey",nodes:s.nodes,edges:s.edges,nodeIDAccessor:s.nodeIdAccessor||s.nodeIDAccessor,sourceAccessor:s.sourceAccessor,targetAccessor:s.targetAccessor,valueAccessor:s.valueAccessor,orientation:s.orientation,nodeAlign:s.nodeAlign,nodeWidth:s.nodeWidth,nodePaddingRatio:s.nodePaddingRatio,showLabels:s.showLabels,nodeLabel:s.nodeLabel,colorBy:t,edgeColorBy:s.edgeColorBy,edgeOpacity:s.edgeOpacity,nodeStyle:s.nodeStyle,edgeStyle:s.edgeStyle,colorScheme:o,...i})},ProcessSankey:{frameType:"network",buildProps:(e,t,o,i,s)=>{const r=e=>null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime(),n=s.sourceAccessor||"source",a=s.targetAccessor||"target",c=s.valueAccessor||"value",l=s.nodeIdAccessor||"id",h=s.startTimeAccessor||"startTime",d=s.endTimeAccessor||"endTime",u=s.systemInTimeAccessor,g=s.systemOutTimeAccessor,p=s.xExtentAccessor||"xExtent",f=s.edgeIdAccessor||"id",y=(e,t)=>"function"==typeof e?e(t):t[e],m=Array.isArray(s.edges)?s.edges:[],x=Array.isArray(s.nodes)?s.nodes:[],b=x.length>0?x:function(e,t,o,i){const s=new Set;return t.forEach(e=>{const t="function"==typeof o?o(e):e[o],r="function"==typeof i?i(e):e[i];s.add(t),s.add(r)}),Array.from(s).map(e=>({id:e}))}(0,m,n,a),A=[r(s.domain?.[0]),r(s.domain?.[1])],v=b.map(e=>{const t=y(l,e)+"",o=y(p,e),i={id:t,__raw:e};if(Array.isArray(o)&&2===o.length){const e=r(o[0]),t=r(o[1]);Number.isFinite(e)&&Number.isFinite(t)&&(i.xExtent=[e,t])}return i}),S=m.map((e,t)=>{const o=y(f,e),i={id:null!=o?o+"":`${y(n,e)}-${y(a,e)}-${t}`,source:y(n,e)+"",target:y(a,e)+"",value:Number(y(c,e)),startTime:r(y(h,e)),endTime:r(y(d,e)),__raw:e};if(u){const t=r(y(u,e));Number.isFinite(t)&&(i.systemInTime=t)}if(g){const t=r(y(g,e));Number.isFinite(t)&&(i.systemOutTime=t)}return i}),[w,k]=i.size??[600,400],_={top:20,right:20,bottom:20,left:20,...i.margin},M=i.legendPosition??"right";i.showLegend&&("right"===M?_.right=Math.max(_.right,100):"left"===M?_.left=Math.max(_.left,100):"bottom"===M?_.bottom=Math.max(_.bottom,70):"top"===M&&(_.top=Math.max(_.top,40)));const T=_,P=w-T.left-T.right,R=k-T.top-T.bottom,z=Array.isArray(o)?o:null,L=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],F="function"==typeof t?t:null,C=F?b.map(e=>({_cat:F(e)})):b,B=F?"_cat":"string"==typeof t?t:void 0,D=B?q(C,B,o):null,E=new Map;for(const e of v)E.set(e.id,e.__raw);const{layoutConfig:O,issues:j}=et({nodes:v,edges:S,domain:A,plotW:P,plotH:R,ribbonLane:s.ribbonLane||"both",edgeOpacity:"number"==typeof s.edgeOpacity?s.edgeOpacity:.35,colorOf:(e,o)=>{if(t&&E.has(e)){const o=E.get(e);return F?U({_cat:F(o)},"_cat",D??void 0):U(o,"string"==typeof t?t:"id",D??void 0)}const i=z||L;return i[o%i.length]},layoutOpts:{pairing:s.pairing||"temporal",packing:s.packing||"reuse",laneOrder:s.laneOrder||"crossing-min",lifetimeMode:s.lifetimeMode||"half"}});if(j.length>0){const e=j.map(Ge).join("; ");throw Error("ProcessSankey: data invalid — "+e)}return{chartType:"force",nodes:b,edges:m,customNetworkLayout:tt,layoutConfig:O,sourceAccessor:n,targetAccessor:a,valueAccessor:c,nodeIDAccessor:l,colorBy:t,colorScheme:o,...i,margin:T}}},ChordDiagram:{frameType:"network",buildProps:(e,t,o,i,s)=>({chartType:"chord",nodes:s.nodes,edges:s.edges,valueAccessor:s.valueAccessor,padAngle:s.padAngle,groupWidth:s.groupWidth,showLabels:s.showLabels,colorBy:t,edgeColorBy:s.edgeColorBy,colorScheme:o,...i})},TreeDiagram:{frameType:"network",buildProps:(e,t,o,i,s)=>({chartType:"cluster"===s.layout?"cluster":"tree",data:e,childrenAccessor:s.childrenAccessor,colorBy:t,colorByDepth:s.colorByDepth,orientation:s.orientation,showLabels:s.showLabels,colorScheme:o,...i})},Treemap:{frameType:"network",buildProps:(e,t,o,i,s)=>({chartType:"treemap",data:e,childrenAccessor:s.childrenAccessor,hierarchySum:s.valueAccessor,colorBy:t,colorByDepth:s.colorByDepth,showLabels:s.showLabels,colorScheme:o,...i})},CirclePack:{frameType:"network",buildProps:(e,t,o,i,s)=>({chartType:"circlepack",data:e,childrenAccessor:s.childrenAccessor,hierarchySum:s.valueAccessor,colorBy:t,colorByDepth:s.colorByDepth,colorScheme:o,...i})},ChoroplethMap:{frameType:"geo",buildProps:(e,t,o,i,s)=>{const r="string"==typeof o?o:"blues",n=s.areaStyle??function(e,t,o,i){if(!Array.isArray(e))return;const s=e=>"function"==typeof t?t(e):null!=t?e?.properties?.[t]??e?.[t]:void 0;let r=1/0,n=-1/0;for(const t of e){const e=s(t);null!=e&&isFinite(e)&&(r>e&&(r=e),e>n&&(n=e))}const a=ot(be(o)).domain([Number.isFinite(r)?r:0,Number.isFinite(n)?n:1]);return e=>{const t=s(e);return{fill:null!=t&&isFinite(t)?a(t):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:i}}}(s.areas,s.valueAccessor,r,s.areaOpacity??1),a=s.styleRules?u(n,s.styleRules,e=>{return{value:(t=e,"function"==typeof s.valueAccessor?s.valueAccessor(t):null!=s.valueAccessor?t?.properties?.[s.valueAccessor]??t?.[s.valueAccessor]:void 0)};var t},it):n;return{areas:s.areas,projection:s.projection||"equalEarth",areaStyle:a,valueAccessor:s.valueAccessor,colorScheme:r,graticule:s.graticule,fitPadding:s.fitPadding,...i}}},ProportionalSymbolMap:{frameType:"geo",buildProps:(e,t,o,i,s)=>{const r=e||s.points,n=s.pointStyle??function(e,t,o,i){const s=Array.isArray(e)?e:[];let r,n;if(t){const e="string"==typeof t?t:"__geoColorBy",i="string"==typeof t?s:s.map(e=>({...e,__geoColorBy:t(e)}));r=q(i,e,o)}if(i.sizeBy){const e=s.map("function"==typeof i.sizeBy?i.sizeBy:e=>e?.[i.sizeBy]).filter(e=>null!=e&&isFinite(e));e.length>0&&(n=ke(e))}return e=>({fill:t&&r?U(e,t,r):W,fillOpacity:i.fillOpacity,stroke:"#fff",strokeWidth:i.strokeWidth,r:i.sizeBy?K(e,i.sizeBy,i.sizeRange,n):i.pointRadius??6})}(r,t,o,{sizeBy:s.sizeBy,sizeRange:s.sizeRange||[3,30],fillOpacity:.7,strokeWidth:.5}),a=s.styleRules?u(n,s.styleRules,g(t,s.sizeBy)):n;return{points:r,xAccessor:s.xAccessor||"lon",yAccessor:s.yAccessor||"lat",areas:s.areas,areaStyle:s.areaStyle,pointStyle:a,sizeBy:s.sizeBy,colorBy:t,colorScheme:o,projection:s.projection||"equalEarth",graticule:s.graticule,fitPadding:s.fitPadding,...i}}},FlowMap:{frameType:"geo",buildProps:(e,t,o,i,s)=>{const r=(Array.isArray(e)?e:null)||s.flows||[],n=s.nodeIdAccessor||"id",a=s.valueAccessor||"value",c=s.xAccessor||"lon",l=s.yAccessor||"lat",h="function"==typeof c?c:e=>e[c],d="function"==typeof l?l:e=>e[l],u=(s.nodes||[]).map(e=>({...e,x:h(e),y:d(e)})),g=new Map;for(const e of u)g.set(e[n]+"",e);const p=s.edgeColorBy??t,f="function"==typeof p,y=r.map(e=>{if(!e||null==e.source||null==e.target)return null;const t=g.get(e.source+""),o=g.get(e.target+"");return t&&o?{...e,coordinates:[{x:t.x,y:t.y},{x:o.x,y:o.y}]}:null}).filter(Boolean),m="__flowMapEdgeColor",x=(()=>{if(!p)return null;if(f){const e=y.map(e=>({[m]:p(e)}));return q(e,m,o||"category10")}return q(y,p,o||"category10")})(),b=e=>p&&x?U(e,p,x):"#007bff";let A=1/0,v=-1/0;for(const e of y){const t=Number(e[a]??0);isFinite(t)&&(A>t&&(A=t),t>v&&(v=t))}const S=v>A?v-A:0,[w,k]=s.edgeWidthRange??[1,8],_=k-w,M=s.edgeOpacity??.6,T=s.edgeLinecap??"round";return{lines:y,points:u,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:s.lineType||"geo",flowStyle:s.flowStyle||"basic",areas:s.areas,areaStyle:s.areaStyle,projection:s.projection||"equalEarth",graticule:s.graticule,fitPadding:s.fitPadding,colorScheme:o,lineStyle:e=>{const t=Number(e?.[a]),o=Number.isFinite(t)?t:A,i=w+Math.max(0,Math.min(1,S>0?(o-A)/S:0))*_;return{stroke:b(e),strokeWidth:i,strokeLinecap:T,opacity:M,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...i}}},GeoCustomChart:{frameType:"geo",buildProps:(e,t,o,i,s)=>({points:s.points||e||[],areas:s.areas||[],lines:s.lines||[],projection:s.projection||"equirectangular",xAccessor:s.xAccessor||"lon",yAccessor:s.yAccessor||"lat",lineDataAccessor:s.lineDataAccessor,colorBy:t,colorScheme:o,customLayout:s.layout||s.customLayout,layoutConfig:s.layoutConfig,...i})},GaltonBoardChart:{frameType:"physics",buildProps:(e,t,i,s,r)=>{const a=s.size??[600,400],c=r.bins??21,l=r.seed??1,h=Math.max(1,Math.round(r.pegRows??c-1)),u="mechanical"===r.mode,g=u?n({bins:c,branchProbability:r.branchProbability,count:r.mechanicalCount,pegRows:h,seed:l}):Array.isArray(e)?e:[],p=o({data:g,valueAccessor:r.valueAccessor||"value",bins:c,ballRadius:r.ballRadius??4,seed:l,size:a,valueExtent:u?[0,h]:void 0});return{...s,config:p.config,initialSpawns:gt(p.initialSpawns),projectionRows:p.projectionRows,bodyStyle:d(t||r.colorBy||(u?"side":void 0),"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.valueAccessor||"value"})}}},EventDropChart:{frameType:"physics",buildProps:(e,o,i,s,r)=>{const n=s.size??[600,400],a=t({data:Array.isArray(e)?e:[],timeAccessor:r.timeAccessor||"time",arrivalAccessor:r.arrivalAccessor||"arrivalTime",windows:r.windows||{size:10},watermark:r.watermark,ballRadius:r.ballRadius??5,seed:r.seed??1,size:n,timeExtent:r.timeExtent,timeScale:r.timeScale??1});return{...s,config:a.config,initialSpawns:gt(a.initialSpawns),projectionRows:a.projectionRows,bodyStyle:d(o||r.colorBy,"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.valueAccessor||r.timeAccessor||"time"})}}},PhysicsPileChart:{frameType:"physics",buildProps:(e,t,o,i,r)=>{const n=i.size??[600,400],c="mechanical"===r.mode,l=c?a({categories:r.mechanicalCategories,count:r.mechanicalCount,seed:r.seed??1,unitValue:r.unitValue??1}):Array.isArray(e)?e:[],h=s({data:l,categoryAccessor:r.categoryAccessor||"category",valueAccessor:r.valueAccessor||(c?"value":void 0),unitValue:r.unitValue??1,ballRadius:r.ballRadius??5,seed:r.seed??1,size:n});return{...i,config:h.config,initialSpawns:gt(h.initialSpawns),projectionRows:h.projectionRows,bodyStyle:d(t||r.colorBy||(c?"category":void 0),"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.valueAccessor||"value"})}}},CollisionSwarmChart:{frameType:"physics",buildProps:(t,o,i,s,r)=>{const n=s.size??[600,360],a=e({data:Array.isArray(t)?t:[],xAccessor:r.xAccessor||"x",groupAccessor:r.groupAccessor,radiusAccessor:r.radiusAccessor,pointRadius:r.pointRadius??5,seed:r.seed??1,size:n,xExtent:r.xExtent,collisionIterations:r.collisionIterations,settle:r.settle});return{...s,config:a.config,initialSpawns:gt(a.initialSpawns),projectionRows:a.projectionRows,bodyStyle:d(o||r.colorBy||r.groupAccessor,"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.xAccessor||"x"})}}},ProcessFlowChart:{frameType:"physics",buildProps:(e,t,o,i,s)=>{const n=i.size??[900,420],a=Array.isArray(s.stages)?s.stages:[],c=r({data:Array.isArray(e)?e:[],stages:a,size:n,idAccessor:s.idAccessor,stageAccessor:s.stageAccessor||"stage",groupBy:s.groupBy,groupLabelAccessor:s.groupLabelAccessor,workAccessor:s.workAccessor,radiusAccessor:s.radiusAccessor,ballRadius:s.ballRadius??6,seed:s.seed??1,groupCompletion:s.groupCompletion,groupAnchorAlong:s.groupAnchorAlong,settle:s.settle??!0,gravityX:s.gravityX,gravityY:s.gravityY}),l=c.metadata;return{...i,config:c.config,initialSpawns:gt(c.initialSpawns),projectionRows:c.projectionRows,regionEffects:l?.regionEffects,bodyStyle:d(t||s.colorBy||s.groupBy)}}},GauntletChart:{frameType:"physics",buildProps:(e,t,o,i,s)=>{const r=i.size??[900,520],n=ut({data:Array.isArray(e)?e:[],size:r,gates:s.gates,positiveProperties:s.positiveProperties,negativeProperties:s.negativeProperties,crashOffset:s.crashOffset,idAccessor:s.idAccessor,positiveAccessor:s.positiveAccessor,negativeAccessor:s.negativeAccessor,metricsAccessor:s.metricsAccessor,initialViability:s.initialViability,projectPlacement:s.projectPlacement,coreBody:s.coreBody,viability:s.viability});return{...i,config:n.config,initialSpawns:gt(n.initialSpawns),projectionRows:[],bodyStyle:d(t||s.colorBy)}}},PhysicalFlowChart:{frameType:"physics",buildProps:(e,t,o,s,r)=>{const n=s.size??[760,420],a=i({nodes:Array.isArray(r.nodes)?r.nodes:[],links:Array.isArray(r.links)?r.links:Array.isArray(r.edges)?r.edges:Array.isArray(e)?e:[],nodeIdAccessor:r.nodeIdAccessor||"id",nodeXAccessor:r.nodeXAccessor||"x",nodeYAccessor:r.nodeYAccessor||"y",sourceAccessor:r.sourceAccessor||"source",targetAccessor:r.targetAccessor||"target",throughputAccessor:r.throughputAccessor||"value",pathAccessor:r.pathAccessor||"path",coordinateMode:r.coordinateMode||"auto",particleRate:r.particleRate??.16,maxParticles:r.maxParticles??180,particleRadius:r.particleRadius??4,flowSpeed:r.flowSpeed??90,pathConstraint:r.pathConstraint||"path",reducedMotion:!0,seed:r.seed??1,size:n});return{...s,config:a.config,initialSpawns:gt(a.initialSpawns),projectionRows:a.projectionRows,bodyStyle:d(t||r.colorBy||"source")}}},PhysicsCustomChart:{frameType:"physics",buildProps:(e,t,o,i,s)=>{const r=i.size??[700,380],n=h({chartId:s.chartId,colorScheme:o,config:s.config,data:Array.isArray(e)?e:[],layout:s.layout,layoutConfig:s.layoutConfig,semantic:ze(Te)??{},size:r,themeCategorical:Te.colors.categorical,xExtent:s.xExtent,yExtent:s.yExtent});return{...i,config:n.config,initialSpawns:gt(n.initialSpawns),projectionRows:[],bodyStyle:n.result.bodyStyle??d(t||s.colorBy)}}}};function ft(e){if(!e)return Te;if("string"==typeof e){if("light"===e)return Te;if("dark"===e)return _e;if("high-contrast"===e)return Me;return Pe[e]||Te}const t="dark"===e.mode?_e:Te,o={...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}},tooltip:{...t.tooltip,...e.tooltip||{}}};return Re(o)}function yt(e){return{background:e.colors.background,text:e.colors.text,textSecondary:e.colors.textSecondary,grid:e.colors.grid,border:e.colors.border,primary:e.colors.primary,fontFamily:e.typography.fontFamily,titleSize:e.typography.titleSize,labelSize:e.typography.labelSize,tickSize:e.typography.tickSize,categorical:e.colors.categorical,annotation:e.colors.annotation??e.colors.text,legendSize:e.typography.legendSize??e.typography.labelSize,titleFontSize:e.typography.titleFontSize??e.typography.titleSize,tickFontFamily:e.typography.tickFontFamily??e.typography.fontFamily}}function mt(e){const t=e instanceof Date?e.getTime():"number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function xt(e){if(!e||2>e.length)return;const t=mt(e[0]),o=mt(e[e.length-1]);return null!==t&&null!==o?[t,o]:void 0}function bt(e){const{count:t,byType:o}=function(e){const t={};for(const o of e){const e="string"==typeof o?.type&&o.type.length>0?o.type:"node";t[e]=(t[e]??0)+1}return{count:e.length,byType:t}}(e.marks),i=0===t,s=[...e.extraWarnings??[]];return i&&!s.includes("EMPTY_SCENE")&&s.push("EMPTY_SCENE"),{component:"",frameType:e.frameType,status:i?"empty":"ok",empty:i,markCount:t,markCountByType:o,width:e.width,height:e.height,...e.xDomain?{xDomain:e.xDomain}:{},...e.yDomain?{yDomain:e.yDomain}:{},...e.categories?{categories:e.categories}:{},...void 0!==e.nodeCount?{nodeCount:e.nodeCount}:{},...void 0!==e.edgeCount?{edgeCount:e.edgeCount}:{},...void 0!==e.legendItems?{legendItems:e.legendItems}:{},annotationCount:Array.isArray(e.annotations)?e.annotations.length:0,ariaLabel:"string"==typeof e.description&&e.description||"string"==typeof e.title&&e.title||`${e.frameType} chart, ${t} marks`,warnings:s}}import*as At from"react";import*as vt from"react-dom/server";import{scaleOrdinal as St}from"d3-scale";import{jsx as wt,jsxs as kt}from"react/jsx-runtime";function _t(e){return"left"===e?"start":"right"===e?"end":e??"start"}function Mt(e){return Number(e.typography.legendSize??e.typography.labelSize??e.typography.tickSize)||11}function Tt(e,t,o,i){const s=Mt(i);return t+o+Math.ceil(e.length*s*.58)}function Pt(e){const{categories:t,theme:o,position:i="right",totalWidth:s,totalHeight:r,margin:n,legendLayout:a}=e,c=Math.max(1,a?.swatchSize??14),l=Math.max(0,a?.labelGap??6),h=Math.max(0,a?.itemGap??8),d=Math.max(c,a?.rowHeight??20),u=c+l,g=Math.min(2,c/2),p="top"===i||"bottom"===i,f=Math.max(c,s-n.left-n.right),y=Math.max(d,r-n.top-n.bottom),m=t.map(e=>Tt(e,c,l,o));if(p){const e=Math.max(c,a?.maxWidth??f),o=[];let i=0,s=0;m.forEach((t,r)=>{const n=0===s?t:s+h+t;s>0&&n>e?(o.push({start:i,end:r,width:s}),i=r,s=t):s=n}),t.length>0&&o.push({start:i,end:t.length,width:s});const r=_t(a?.align),n=[];return o.forEach((o,i)=>{let s="center"===r?Math.max(0,(e-o.width)/2):"end"===r?Math.max(0,e-o.width):0;for(let e=o.start;o.end>e;e++)n.push({category:t[e],width:m[e],x:s,y:i*d}),s+=m[e]+h}),{items:n,width:Math.max(0,...o.map(e=>e.width)),height:o.length*d,swatchSize:c,labelOffset:u,swatchRadius:g}}const x=Math.max(0,...m),b=Math.max(1,Math.floor(y/d)),A=Math.max(1,Math.ceil(t.length/b));return{items:t.map((e,t)=>({category:e,width:m[t],x:Math.floor(t/b)*(x+h),y:t%b*d})),width:A*x+Math.max(0,A-1)*h,height:Math.min(t.length,b)*d,swatchSize:c,labelOffset:u,swatchRadius:g}}function Rt(e){const{legendGroups:t,theme:o,position:i="right",totalWidth:s,totalHeight:r,margin:n,legendLayout:a}=e,c=Math.max(1,a?.swatchSize??14),l=Math.max(0,a?.labelGap??6),h=Math.max(0,a?.itemGap??8),d=Math.max(c,a?.rowHeight??20),u=c+l,g=Math.min(2,c/2),p=Math.max(12,Mt(o)),f="top"===i||"bottom"===i,y=Math.max(c,s-n.left-n.right),m=Math.max(d,r-n.top-n.bottom);if(f){const i=Math.max(c,a?.maxWidth??y),s=_t(a?.align);let r=0,n=0;const l=[];for(const s of t){const t=s.items.map(e=>e.label),h=Pt({...e,categories:t,legendLayout:{...a,maxWidth:Math.max(c,i-p-8),align:"start"}}),d=s.label?p:0,u=s.label?Tt(s.label,0,0,o):0,g=d>0?d+8:0,f=g+h.width,y=Math.max(h.height,u);l.push({group:s,x:r,y:0,itemOffsetX:g,itemOffsetY:0,width:f,height:y,items:h.items}),r+=f+12,n=Math.max(n,y)}const h=l.length>0?r-12:0,d=h>i?0:"center"===s?Math.max(0,(i-h)/2):"end"===s?Math.max(0,i-h):0;return{groups:l.map(e=>({...e,x:e.x+d})),width:h,height:n,swatchSize:c,labelOffset:u,swatchRadius:g}}let x=0,b=0;const A=[];for(const e of t){const t=e.items.map(e=>e.label).map(e=>Tt(e,c,l,o)),i=Math.max(0,...t),s=Math.max(1,Math.min(e.items.length||1,Math.max(1,Math.floor(Math.max(d,m-x)/d)))),r=Math.max(1,Math.ceil(e.items.length/s)),n=e.items.map((e,o)=>({category:e.label,width:t[o],x:Math.floor(o/s)*(i+h),y:o%s*d})),a=r*i+Math.max(0,r-1)*h,u=Math.min(e.items.length,s)*d,g=e.label?Tt(e.label,0,0,o):0,f=e.label?p+8:0,y=f+u+12,v=Math.max(a,g);A.push({group:e,x:0,y:x,itemOffsetX:0,itemOffsetY:f,width:v,height:y,items:n}),b=Math.max(b,v),x+=y}return{groups:A,width:b,height:Math.max(0,x),swatchSize:c,labelOffset:u,swatchRadius:g}}function zt(e){const t="top"===e.position||"bottom"===e.position,o=Math.max(1,e.totalWidth-e.margin.left-e.margin.right);return t?{width:Math.min(e.legendLayout?.maxWidth??o,200),height:e.gradient.label?34:26,swatchSize:12}:{width:e.gradient.label?86:72,height:e.gradient.label?124:108,swatchSize:14}}function Lt(e){const{categories:t,colorScheme:o,theme:i,position:s="right",totalWidth:r,totalHeight:n,margin:a,hasTitle:c=!1}=e;if(!t||0===t.length)return null;const l=function(e,t,o){if(t&&"object"==typeof t&&!Array.isArray(t)){const e=t;return t=>he(e,t)??"#999"}const i=Array.isArray(t)?t:o.colors.categorical.length>0?o.colors.categorical:ve;return St().domain(e).range(i)}(t,o,i),h="top"===s||"bottom"===s,d=Pt(e);let u,g;if("left"===s?(u=Math.max(4,a.left-d.width-10),g=a.top):"top"===s?(u=a.left,g=c?32:8):"bottom"===s?(u=a.left,g=Math.min(n-a.bottom+38,n-d.height-2)):(u=Math.min(r-d.width-4,r-a.right+10),g=a.top),h){const e=d.items.map((e,t)=>kt("g",{transform:`translate(${e.x},${e.y})`,children:[wt("rect",{width:d.swatchSize,height:d.swatchSize,fill:l(e.category),rx:d.swatchRadius}),wt("text",{x:d.labelOffset,y:d.swatchSize/2,dominantBaseline:"central",fontSize:Mt(i),fill:i.colors.text,fontFamily:i.typography.fontFamily,children:e.category})]},"legend-"+t));return wt("g",{className:"semiotic-legend",transform:`translate(${u},${g})`,children:e})}const p=d.items.map((e,t)=>kt("g",{transform:`translate(${e.x},${e.y})`,children:[wt("rect",{width:d.swatchSize,height:d.swatchSize,fill:l(e.category),rx:d.swatchRadius}),wt("text",{x:d.labelOffset,y:d.swatchSize/2,dominantBaseline:"central",fontSize:Mt(i),fill:i.colors.text,fontFamily:i.typography.fontFamily,children:e.category})]},"legend-"+t));return wt("g",{className:"semiotic-legend",transform:`translate(${u},${g})`,children:p})}function Ft(e,t){if(!t||!e||0===e.length)return[];const o="function"==typeof t?t:e=>e[t],i=new Set;for(const t of e){const e=o(t);null!=e&&i.add(e+"")}return Array.from(i)}import{jsx as Ct,jsxs as Bt}from"react/jsx-runtime";var Dt=16;function Et(e,t){return e.color||t.colors.annotation||t.colors.text}function Ot(e,t,o){const i=e.labelBackground,s=t.colors.background;return void 0===i?"none"===o?"none":{type:"halo",fill:s}:!1===i||"none"===i?"none":!0===i||"halo"===i?{type:"halo",fill:s}:"box"===i?{type:"box",fill:s}:{fill:s,...i}}function jt(e,t,o){return null!=e.x&&t.x?t.x(e.x):o&&null!=e[o]&&t.x?t.x(e[o]):"number"==typeof e.x?e.x:null}function Nt(e,t,o){return null!=e.y&&t.y?t.y(e.y):o&&null!=e[o]&&t.y?t.y(e[o]):"number"==typeof e.y?e.y:null}function Wt(e){const{annotations:t}=e;if(!t||0===t.length)return null;const o=e.autoPlaceAnnotations?xe({annotations:t,context:{scales:{x:e.scales.x,y:e.scales.y,time:e.scales.x,value:e.scales.y,o:e.scales.o,geoProjection:e.scales.geoProjection},width:e.layout.width,height:e.layout.height,xAccessor:e.xAccessor,yAccessor:e.yAccessor,frameType:e.projection?"ordinal":"xy",projection:"horizontal"===e.projection?"horizontal":"vertical"},..."object"==typeof e.autoPlaceAnnotations?e.autoPlaceAnnotations:{}}):t,i=[];for(let t=0;o.length>t;t++){const s=$t(o[t],t,e);s&&i.push({node:s,annotation:o[t]})}const s=V(i);return s.length>0?Ct("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:s}):null}function $t(e,t,o){const{scales:i,layout:s,theme:r,xAccessor:n,yAccessor:a}=o;switch(e.type){case"y-threshold":{const n=e.value;if(null==n)return null;const a=Et(e,r),c=e.label,l=e.labelPosition||"right",h=e.strokeDasharray||"6,4",d=e.strokeWidth??1.5;if("horizontal"===o.projection&&i.r){const o=i.r(n);return null==o?null:Bt("g",{opacity:e.opacity,children:[Ct("line",{x1:o,y1:0,x2:o,y2:s.height,stroke:a,strokeWidth:d,strokeDasharray:h}),c&&Ct(N,{x:o+4,y:Dt,textAnchor:"start",fontSize:r.typography.tickSize,fill:a,fontFamily:r.typography.fontFamily,text:c,background:Ot(e,r,"halo")})]},"ann-ythresh-"+t)}const u=i.y?i.y(n):i.r?i.r(n):null;return null==u?null:Bt("g",{children:[Ct("line",{x1:0,y1:u,x2:s.width,y2:u,stroke:a,strokeWidth:d,strokeDasharray:h}),c&&Ct(N,{x:"left"===l?4:"center"===l?s.width/2:s.width-4,y:20>u?Math.min(s.height-4,u+Dt):u-6,textAnchor:"left"===l?"start":"center"===l?"middle":"end",fontSize:r.typography.tickSize,fill:a,fontFamily:r.typography.fontFamily,text:c,background:Ot(e,r,"halo")})]},"ann-ythresh-"+t)}case"x-threshold":{const o=e.value;if(null==o||!i.x)return null;const n=i.x(o);if(null==n)return null;const a=Et(e,r),c=e.label,l=e.labelPosition||"top";return Bt("g",{opacity:e.opacity,children:[Ct("line",{x1:n,y1:0,x2:n,y2:s.height,stroke:a,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray||"6,4"}),c&&Ct(N,{x:n>.6*s.width?n-4:n+4,y:"bottom"===l?s.height-4:"center"===l?s.height/2:Dt,textAnchor:n>.6*s.width?"end":"start",fontSize:r.typography.tickSize,fill:a,fontFamily:r.typography.fontFamily,text:c,background:Ot(e,r,"halo")})]},"ann-xthresh-"+t)}case"band":{const o=null!=e.y0&&i.y?i.y(e.y0):null,n=null!=e.y1&&i.y?i.y(e.y1):null;if(null==o||null==n)return null;const a=Math.min(o,n),c=Math.abs(n-o),l=fe(e.fill||Et(e,r),"ssr-band-"+t),h=e.fillOpacity??.1;return Bt("g",{opacity:e.opacity,children:[l.def&&Ct("defs",{children:l.def}),Ct("rect",{x:0,y:a,width:s.width,height:c,fill:l.fill,fillOpacity:h}),e.label&&Ct(N,{x:s.width-4,y:Math.max(a,0)+Dt,textAnchor:"end",fontSize:r.typography.tickSize,fill:e.color||Et(e,r),fontFamily:r.typography.fontFamily,fontWeight:"bold",text:e.label,background:Ot(e,r,"halo")})]},"ann-band-"+t)}case"x-band":{const o=null!=e.x0&&i.x?i.x(e.x0):null,n=null!=e.x1&&i.x?i.x(e.x1):null;if(null==o||null==n)return null;const a=Math.min(o,n),c=Math.abs(n-o),l=fe(e.fill||Et(e,r),"ssr-xband-"+t),h=e.fillOpacity??.1;return Bt("g",{opacity:e.opacity,children:[l.def&&Ct("defs",{children:l.def}),Ct("rect",{x:a,y:0,width:c,height:s.height,fill:l.fill,fillOpacity:h}),e.label&&Ct(N,{x:a+4,y:Dt,textAnchor:"start",fontSize:r.typography.tickSize,fill:e.color||Et(e,r),fontFamily:r.typography.fontFamily,fontWeight:"bold",text:e.label,background:Ot(e,r,"halo")})]},"ann-xband-"+t)}case"category-highlight":{if(null==e.category||!i.o)return null;const n=i.o(e.category+"");if(null==n)return null;const a=i.o.bandwidth?i.o.bandwidth():40,c=Et(e,r),l=e.opacity??.1,h=e.label;return Bt("g","horizontal"===o.projection?{children:[Ct("rect",{x:0,y:n,width:s.width,height:a,fill:c,opacity:l}),h&&Ct(N,{x:12,y:n+a/2,dominantBaseline:"middle",fill:c,fontSize:r.typography.tickSize,fontWeight:"bold",fontFamily:r.typography.fontFamily,text:h,background:Ot(e,r,"none")})]}:{children:[Ct("rect",{x:n,y:0,width:a,height:s.height,fill:c,opacity:l}),h&&Ct(N,{x:n+a/2,y:Dt,textAnchor:"middle",fill:c,fontSize:r.typography.tickSize,fontWeight:"bold",fontFamily:r.typography.fontFamily,text:h,background:Ot(e,r,"none")})]},"ann-cathighlight-"+t)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{const{x:o,y:s}=function(e,t,o,i){if(Array.isArray(e.coordinates)&&e.coordinates.length>=2&&t.geoProjection){const o=t.geoProjection([e.coordinates[0],e.coordinates[1]]);if(o)return{x:o[0],y:o[1]}}return{x:jt(e,t,o),y:Nt(e,t,i)}}(e,i,n,a);if(null==o||null==s)return null;const c="text"===e.type,l=e.dx??(c?0:30),h=e.dy??(c?0:-30),d=e.color||r.colors.text;if(!c){const i="callout"===e.type?"callout-circle":e.type,r="callout-circle"===i?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===i?{width:e.width,height:e.height}:void 0;return Ct(I,{noteData:{x:o,y:s,dx:l,dy:h,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:i,...r?{subject:r}:{},connector:e.connector||{end:"arrow"},color:d,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-label-"+t)}return Ct("g",{children:Ct("text",{x:o+l,y:s+h,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||r.typography.labelSize,fill:d,fontFamily:r.typography.fontFamily,fontWeight:e.fontWeight,opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:e.label||e.title})},"ann-label-"+t)}default:return null}}import{jsx as It,jsxs as Gt}from"react/jsx-runtime";function Vt(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){const t=e.id;return null==t?null:t+""}return null}function Yt(e,t){if(0===t.categories.length)return;const o=t.position||"right",i=function(e){const{width:t,height:o,swatchSize:i}=Pt(e);return{width:t,height:o,swatchSize:i}}({categories:t.categories,colorScheme:t.colorScheme,theme:t.theme,position:o,totalWidth:t.size[0],totalHeight:t.size[1],margin:e,hasTitle:t.hasTitle,legendLayout:t.legendLayout});"right"===o?e.right=Math.max(e.right,i.width+14):"left"===o?e.left=Math.max(e.left,i.width+14):"top"===o?e.top=Math.max(e.top,(t.hasTitle?32:8)+i.height+4):e.bottom=Math.max(e.bottom,38+i.height+4)}function Ht(e,t){const o=t.position||"right",i={theme:t.theme,position:o,totalWidth:t.size[0],totalHeight:t.size[1],margin:e,hasTitle:t.hasTitle,legendLayout:t.legendLayout},s=te(t.legend)?function(e){const{width:t,height:o,swatchSize:i}=Rt(e);return{width:t,height:o,swatchSize:i}}({...i,legendGroups:t.legend.legendGroups}):ee(t.legend)?zt({...i,gradient:t.legend.gradient}):null;s&&("right"===o?e.right=Math.max(e.right,s.width+14):"left"===o?e.left=Math.max(e.left,s.width+14):"top"===o?e.top=Math.max(e.top,(t.hasTitle?32:8)+s.height+4):e.bottom=Math.max(e.bottom,38+s.height+4))}function Xt(e,t){const o={theme:t.theme,position:t.position||"right",totalWidth:t.size[0],totalHeight:t.size[1],margin:t.margin,hasTitle:t.hasTitle,legendLayout:t.legendLayout,idPrefix:t.idPrefix};return te(e)?function(e){if(0===(t=e.legendGroups,t.flatMap(e=>e.items.map((t,o)=>({group:e,item:t,itemIndex:o,label:t.label})))).length)return null;var t;const o=Rt(e),i="top"===e.position||"bottom"===e.position,s=e.theme.colors.grid||e.theme.colors.textSecondary;let r,n;"left"===e.position?(r=Math.max(4,e.margin.left-o.width-10),n=e.margin.top):"top"===e.position?(r=e.margin.left,n=e.hasTitle?32:8):"bottom"===e.position?(r=e.margin.left,n=Math.min(e.totalHeight-e.margin.bottom+38,e.totalHeight-o.height-2)):(r=Math.min(e.totalWidth-o.width-4,e.totalWidth-e.margin.right+10),n=e.margin.top);const a=o.groups.flatMap((t,r)=>{const{group:n}=t,a=n.type??"fill",c=[];if(n.label&&c.push(wt("text",i?{transform:`translate(${t.x},${t.y}) rotate(90)`,textAnchor:"start",fontSize:Mt(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:n.label}:{x:t.x,y:t.y+Mt(e.theme),fontSize:Mt(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:n.label},"legend-group-label-"+r)),c.push(...t.items.map((i,s)=>{const c=n.items[s],l=n.styleFn(c,s),h="function"==typeof a?a(c):"line"===a?wt("line",{x1:0,y1:0,x2:o.swatchSize,y2:o.swatchSize,style:l}):wt("rect",{width:o.swatchSize,height:o.swatchSize,rx:o.swatchRadius,style:l});return kt("g",{transform:`translate(${t.x+t.itemOffsetX+i.x},${t.y+t.itemOffsetY+i.y})`,children:[h,wt("text",{x:o.labelOffset,y:o.swatchSize/2,dominantBaseline:"central",fontSize:Mt(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:i.category})]},`legend-${r}-${s}`)})),!i&&o.groups.length-1>r)c.push(wt("line",{x1:0,y1:t.y+t.height-6,x2:o.width,y2:t.y+t.height-6,stroke:s},"legend-group-separator-"+r));else if(i&&o.groups.length-1>r){const e=t.x+t.width+6;c.push(wt("line",{x1:e,y1:0,x2:e,y2:o.height,stroke:s},"legend-group-separator-"+r))}return c});return wt("g",{className:"semiotic-legend",transform:`translate(${r},${n})`,"data-orientation":i?"horizontal":"vertical",children:a})}({...o,legendGroups:e.legendGroups}):ee(e)?function(e){const t=zt(e),o="top"===e.position||"bottom"===e.position,i=(e.idPrefix?e.idPrefix+"-":"")+"semiotic-static-gradient-legend",s=e.gradient.format||(e=>Math.round(100*e)/100+"");let r,n;"left"===e.position?(r=Math.max(4,e.margin.left-t.width-10),n=e.margin.top):"top"===e.position?(r=e.margin.left,n=e.hasTitle?32:8):"bottom"===e.position?(r=e.margin.left,n=Math.min(e.totalHeight-e.margin.bottom+38,e.totalHeight-t.height-2)):(r=Math.min(e.totalWidth-t.width-4,e.totalWidth-e.margin.right+10),n=e.margin.top);const a=Array.from({length:17},(t,i)=>{const s=i/16;return wt("stop",{offset:100*s+"%",stopColor:e.gradient.colorFn(o?e.gradient.domain[0]+s*(e.gradient.domain[1]-e.gradient.domain[0]):e.gradient.domain[1]-s*(e.gradient.domain[1]-e.gradient.domain[0]))},i)});if(o){const o=12,c=e.gradient.label?0:void 0,l=e.gradient.label?8:0;return kt("g",{className:"semiotic-legend",transform:`translate(${r},${n})`,children:[wt("defs",{children:wt("linearGradient",{id:i,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:a})}),e.gradient.label&&wt("text",{x:t.width/2,y:c,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:e.gradient.label}),wt("rect",{x:0,y:l,width:t.width,height:o,fill:`url(#${i})`,rx:2}),wt("text",{x:0,y:l+o+12,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:s(e.gradient.domain[0])}),wt("text",{x:t.width,y:l+o+12,textAnchor:"end",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:s(e.gradient.domain[1])})]})}const c=e.gradient.label?-6:void 0;return kt("g",{className:"semiotic-legend",transform:`translate(${r},${n+(e.gradient.label?12:0)})`,children:[wt("defs",{children:wt("linearGradient",{id:i,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:a})}),e.gradient.label&&wt("text",{x:7,y:c,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:e.gradient.label}),wt("rect",{x:0,y:0,width:14,height:100,fill:`url(#${i})`,rx:2}),wt("text",{x:19,y:10,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:s(e.gradient.domain[1])}),wt("text",{x:19,y:100,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:s(e.gradient.domain[0])})]})}({...o,gradient:e.gradient}):null}function qt(e){return Math.round(100*e)/100+""}function Qt(e,t){const o=yt(t.theme),i=t.idPrefix?t.idPrefix+"-":"",s="string"==typeof t.title?t.title:void 0,r=s?i+"semiotic-title":void 0,n=t.description?i+"semiotic-desc":void 0,a=[r,n].filter(Boolean).join(" ")||void 0;return Gt("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className,width:t.width,height:t.height,role:"img","aria-labelledby":a,style:{fontFamily:o.fontFamily},children:[s&&It("title",{id:r,children:s}),t.description&&It("desc",{id:n,children:t.description}),t.defs&&It("defs",{children:t.defs}),t.background&&"transparent"!==t.background&&It("rect",{x:0,y:0,width:t.width,height:t.height,fill:t.background}),It("g",{id:i+"data-area",transform:t.innerTransform,children:e}),s&&It("text",{id:i+"chart-title",x:t.width/2,y:G,textAnchor:"middle",fontSize:o.titleSize,fontWeight:"bold",fill:o.text,fontFamily:o.fontFamily,children:s}),t.legend&&It("g",{id:i+"legend",children:t.legend}),t.outerElements]})}import{Fragment as Zt,jsx as Ut,jsxs as Kt}from"react/jsx-runtime";function Jt(e,t){const o=ft(e.theme),i=e.size||[500,300],s=ce({top:20,right:20,bottom:30,left:40,...e.margin},e.title),r=J(e.title),n=Q(e.data),a=e.showLegend?Ft(n,e.colorAccessor||e.groupAccessor):[],c=e.legendPosition;te(e.legend)||ee(e.legend)?Ht(s,{legend:e.legend,theme:o,position:c||"right",size:i,hasTitle:r,legendLayout:e.legendLayout}):e.showLegend&&a.length>0&&Yt(s,{categories:a,colorScheme:e.colorScheme,theme:o,position:c||"right",size:i,hasTitle:r,legendLayout:e.legendLayout});const l=i[0]-s.left-s.right,h=i[1]-s.top-s.bottom,d="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),u=e.colorScheme||o.colors.categorical,g={chartType:e.chartType,windowSize:e.windowSize??200,windowMode:e.windowMode??"sliding",arrowOfTime:d?e.arrowOfTime??"right":"right",extentPadding:e.extentPadding??.1,xAccessor:d?void 0:e.xAccessor,yAccessor:d?void 0:e.yAccessor,timeAccessor:d?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,groupAccessor:e.groupAccessor,categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,axisExtent:e.axisExtent,sizeRange:e.sizeRange,xScaleType:e.xScaleType,yScaleType:e.yScaleType,scalePadding:e.scalePadding,binSize:e.binSize,normalize:e.normalize,stackOrder:e.stackOrder,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,y0Accessor:e.y0Accessor,areaGroups:e.areaGroups?e.areaGroups instanceof Set?e.areaGroups:new Set(e.areaGroups):void 0,curve:e.curve,gradientFill:!0===e.gradientFill?{topOpacity:.8,bottomOpacity:.05}:!1===e.gradientFill?void 0:e.gradientFill,lineGradient:e.lineGradient,openAccessor:e.openAccessor,highAccessor:e.highAccessor,lowAccessor:e.lowAccessor,closeAccessor:e.closeAccessor,candlestickStyle:e.candlestickStyle,lineStyle:e.lineStyle,pointStyle:e.pointStyle,areaStyle:e.areaStyle,barStyle:e.barStyle,waterfallStyle:e.waterfallStyle,swarmStyle:e.swarmStyle,colorScheme:u,themeCategorical:o.colors.categorical,themeSemantic:ze(o),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:s,layoutSelection:e.layoutSelection,barColors:e.barColors},p=new x(g);if(e.data&&p.ingest({inserts:n,bounded:!0}),p.computeScene({width:l,height:h}),!p.scales||0===p.scene.length)return t&&(t.evidence=bt({frameType:"xy",width:i[0],height:i[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,extraWarnings:p.scales?[]:["NO_SCALES"]})),vt.renderToStaticMarkup(Qt(null,{width:i[0],height:i[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${s.left},${s.top})`,innerWidth:l,innerHeight:h,idPrefix:e._idPrefix}));t&&(t.evidence=bt({frameType:"xy",width:i[0],height:i[1],marks:p.scene,title:e.title,description:e.description,annotations:e.annotations,xDomain:xt(p.scales.x?.domain?.()),yDomain:xt(p.scales.y?.domain?.()),legendItems:a.length>0?a.length:void 0}));const f=e._idPrefix,y=e.showGrid?function(e,t,o,i,s){const{grid:r}=yt(o),n=i?i+"-":"",a=B(e.x,5,s),c=B(e.y,5,s);return Gt("g",{id:n+"grid",className:"semiotic-grid",opacity:.8,children:[a.map((o,i)=>{const s=e.x(o);return It("line",{x1:s,y1:0,x2:s,y2:t.height,stroke:r,strokeWidth:.5},"gx-"+i)}),c.map((o,i)=>{const s=e.y(o);return It("line",{x1:0,y1:s,x2:t.width,y2:s,stroke:r,strokeWidth:.5},"gy-"+i)})]})}(p.scales,{width:l,height:h},o,f,e.axisExtent):null,m=p.scene.map((t,o)=>F({node:t,index:o,renderMode:e.renderMode,fallback:()=>de(t,o,f)})).filter(Boolean),b=!1!==e.showAxes?function(e,t,o,i,s){const r=yt(i),n=B(e.x,5,o.axisExtent).map(t=>({pixel:e.x(t),label:(o.xFormat||o.tickFormatTime||qt)(t)})),a=B(e.y,5,o.axisExtent).map(t=>({pixel:e.y(t),label:(o.yFormat||o.tickFormatValue||qt)(t)}));return Gt("g",{id:(s?s+"-":"")+"axes",className:"stream-axes",children:[It("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:r.border,strokeWidth:1}),n.map((e,o)=>Gt("g",{transform:`translate(${e.pixel},${t.height})`,children:[It("line",{y2:5,stroke:r.border,strokeWidth:1}),It("text",{y:18,textAnchor:"middle",fontSize:r.tickSize,fill:r.textSecondary,fontFamily:r.fontFamily,children:e.label})]},"xtick-"+o)),o.xLabel&&It("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:r.labelSize,fill:r.text,fontFamily:r.fontFamily,children:o.xLabel}),It("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:r.border,strokeWidth:1}),a.map((e,t)=>Gt("g",{transform:`translate(0,${e.pixel})`,children:[It("line",{x2:-5,stroke:r.border,strokeWidth:1}),It("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:r.tickSize,fill:r.textSecondary,fontFamily:r.fontFamily,children:e.label})]},"ytick-"+t)),o.yLabel&&It("text",{x:15-(o.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:r.labelSize,fill:r.text,fontFamily:r.fontFamily,transform:`rotate(-90, ${15-(o.margin?.left??40)}, ${t.height/2})`,children:o.yLabel})]})}(p.scales,{width:l,height:h},e,o,f):null,A=e.annotations?Wt({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{x:p.scales.x,y:p.scales.y},layout:{width:l,height:h},theme:o,xAccessor:"string"==typeof e.xAccessor?e.xAccessor:void 0,yAccessor:"string"==typeof e.yAccessor?e.yAccessor:void 0,idPrefix:f}):null,v=e.svgPreRenderers&&p.scales?e.svgPreRenderers.map((e,t)=>{try{return Ut(At.Fragment,{children:e(p.scene,p.scales,{width:l,height:h})},"pre-"+t)}catch{return null}}).filter(Boolean):null,S=e.showLegend?0===a.length?null:Lt({categories:a,colorScheme:e.colorScheme,theme:o,position:e.legendPosition||"right",totalWidth:i[0],totalHeight:i[1],margin:s,hasTitle:r,legendLayout:e.legendLayout}):null,w=At.isValidElement(e.legend)?e.legend:Xt(e.legend,{theme:o,position:e.legendPosition||"right",size:i,margin:s,hasTitle:r,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||S;return vt.renderToStaticMarkup(Qt(Kt(Zt,{children:[e.backgroundGraphics,v,y,m,b,A,e.foregroundGraphics,p.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${s.left},${s.top})`,innerWidth:l,innerHeight:h,legend:w,idPrefix:e._idPrefix}))}import*as eo from"react";import*as to from"react-dom/server";import{scaleBand as oo,scaleLinear as io}from"d3-scale";var so=class{constructor(){this.colorSchemeMap=new Map,this.colorSchemeIndex=0}resetColors(){this.colorSchemeMap.clear(),this.colorSchemeIndex=0}resolvePieceStyle(e,t,o){if(t&&"function"==typeof e.pieceStyle){const i=e.pieceStyle(t,o);return i&&!i.fill&&o?{...i,fill:this.getColorFromScheme(e,o)}:i}return e.pieceStyle&&"object"==typeof e.pieceStyle?e.pieceStyle:e.barColors&&o?{fill:e.barColors[o]||"#007bff"}:{fill:o?this.getColorFromScheme(e,o):"#007bff"}}resolveSummaryStyle(e,t,o){return t&&"function"==typeof e.summaryStyle?e.summaryStyle(t,o):e.summaryStyle&&"object"==typeof e.summaryStyle?e.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}getColorFromScheme(e,t){const o=this.colorSchemeMap.get(t);if(o)return o;const i=Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical||$,s=i[this.colorSchemeIndex%i.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(t,s),s}};function ro(e){const t=e.getSymbol;if(!t)return null;const o=e.config.symbolMap,i=new Map;let s=0;return e=>{const r=t(e)+"",n=o?.[r];if(n)return n;let a=i.get(r);return a||(a=ye[s%ye.length],s++,i.set(r,a)),a}}function no(e,t,o,i,s,r,n){e.push(t?{type:"symbol",x:i,y:s,size:Math.PI*r*r,symbolType:t(o),style:n,datum:o}:{type:"point",x:i,y:s,r:r,style:n,datum:o})}function ao(e,t){const{columns:o,config:i,resolvePieceStyle:s}=e,r=[],n=Math.min(t.width,t.height)/2-4,a="donut"===i.chartType?i.innerRadius||60:0,c=-Math.PI/2+(i.startAngle||0)*Math.PI/180,l=null!=i.sweepAngle?i.sweepAngle*Math.PI/180:2*Math.PI,h=null!=i.sweepAngle&&360>i.sweepAngle,d=Object.values(o),u=d.some(e=>{const t=e.pieceData[0];return t&&("number"==typeof t._pct||"number"==typeof t._pctStart||null!=t._roundedEnds)}),g=h&&!u&&d.length>1&&(i.cornerRadius??0)>0;for(let e=0;d.length>e;e++){const t=d[e],o=t.pieceData[0],h="number"==typeof o?._pctStart?o._pctStart:t.pctStart,u=c+h*l,p=c+(h+("number"==typeof o?._pct?o._pct:t.pct))*l,f=s(t.pieceData[0],t.name),y=0===e,m=e===d.length-1,x={type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:n,startAngle:u,endAngle:p,...i.cornerRadius&&{cornerRadius:i.cornerRadius},style:f,datum:o?._nonInteractive?null:t.pieceData,category:t.name};o?._roundedEnds?x.roundedEnds=o._roundedEnds:g&&(x.roundedEnds={start:y,end:m}),o?._gradientBand&&(x._gradientBand=o._gradientBand),r.push(x)}return r}import{quantile as co}from"d3-array";function lo(e){const t=e.length,o=e[0],i=e[t-1];return{n:t,min:o,q1:co(e,.25)??o,median:co(e,.5)??(o+i)/2,q3:co(e,.75)??i,max:i,mean:e.reduce((e,t)=>e+t,0)/t}}import{scaleLinear as ho}from"d3-scale";var uo={bar:function(e,t){const{scales:o,columns:i,config:s,getR:r,getStack:n,resolvePieceStyle:a}=e,{r:c,projection:l}=o,h=[],d="vertical"===l,u="horizontal"===l,g=s.normalize,p=[];if(n){const e=new Set;for(const t of Object.values(i))for(const o of t.pieceData){const t=n(o);e.has(t)||(e.add(t),p.push(t))}}else p.push("_default");for(const e of Object.values(i)){const t=new Map;for(const o of e.pieceData){const e=n?n(o):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const i=t.get(e);i.total+=r(o),i.pieces.push(o)}let o=0;if(g)for(const e of t.values())o+=Math.abs(e.total);let i=0,s=0;for(const r of p){const l=t.get(r);if(!l)continue;let p=l.total;g&&o>0&&(p/=o);const f=a(l.pieces[0],n?r:e.name),y={...l.pieces[0],__aggregateValue:l.total,__pieceCount:l.pieces.length,category:e.name};if(d){const t=c(0>p?s:i+p),o=0>p?c(s+p)-c(s):c(i)-c(i+p);h.push(v(e.x,t,e.width,Math.abs(o),f,y,r)),0>p?s+=p:i+=p}else if(u){const t=c(0>p?s+p:i),o=0>p?c(s)-c(s+p):c(i+p)-c(i);h.push(v(t,e.x,Math.abs(o),e.width,f,y,r)),0>p?s+=p:i+=p}}}const f="vertical"===l,y=s.roundedTop&&s.roundedTop>0?Math.max(0,s.roundedTop):0;for(const e of h){if("rect"!==e.type)continue;const t=e.datum?.__aggregateValue??0;e.roundedEdge=f?0>t?"bottom":"top":0>t?"left":"right",s.gradientFill&&(e.fillGradient=s.gradientFill)}if(y>0){const e=new Map;for(const t of h){if("rect"!==t.type)continue;const o=t.datum?.category||"";e.has(o)||e.set(o,[]),e.get(o).push(t)}for(const t of e.values()){if(0===t.length)continue;const e=t.filter(e=>(e.datum?.__aggregateValue??0)>=0),o=t.filter(e=>0>(e.datum?.__aggregateValue??0));e.length>0&&(e.reduce(f?(e,t)=>t.y>e.y?e:t:(e,t)=>e.x+e.w>t.x+t.w?e:t).roundedTop=y),o.length>0&&(o.reduce(f?(e,t)=>e.y+e.h>t.y+t.h?e:t:(e,t)=>t.x>e.x?e:t).roundedTop=y)}}return h},clusterbar:function(e,t){const{scales:o,columns:i,config:s,getR:r,getGroup:n,resolvePieceStyle:a}=e,{r:c,projection:l}=o,h=[],d="vertical"===l,u=[],g=new Set;for(const e of Object.values(i))for(const t of e.pieceData){const e=n?n(t):"_default";g.has(e)||(g.add(e),u.push(e))}const p=u.length||1;for(const e of Object.values(i)){const t=e.width/p,o=.2*t,i=t-o,s=new Map;for(const t of e.pieceData){const e=n?n(t):"_default";s.has(e)||s.set(e,[]),s.get(e).push(t)}for(let n=0;u.length>n;n++){const l=s.get(u[n])||[];for(const s of l){const l=r(s),g=a(s,u[n]);if(d){const r=e.x+n*t+o/2,a=c(0),d=c(l);h.push(v(r,Math.min(a,d),i,Math.abs(a-d),g,s,u[n]))}else{const r=e.x+n*t+o/2,a=c(0),d=c(l);h.push(v(Math.min(a,d),r,Math.abs(d-a),i,g,s,u[n]))}}}}const f=s.roundedTop&&s.roundedTop>0?Math.max(0,s.roundedTop):0;for(const e of h){if("rect"!==e.type)continue;if(null==e.datum)continue;const t=r(e.datum);f>0&&(e.roundedTop=f),e.roundedEdge=d?0>t?"bottom":"top":0>t?"left":"right",s.gradientFill&&(e.fillGradient=s.gradientFill)}return h},point:function(e,t){const{scales:o,columns:i,getR:s,multiScales:r,resolvePieceStyle:n}=e,{r:a,projection:c}=o,l=[],h="vertical"===c,d="radial"===c,u=r.length>0,g=ro(e),p=2*Math.PI,f=-Math.PI/2;for(const e of Object.values(i))for(const t of e.pieceData){const o=t.__rIndex??0,i=t.__rValue??s(t),c=u&&r[o]||a,y=n(t,e.name),m=y.r||5;let x,b;if(d){const t=f+(e.pctStart+e.pct/2)*p,o=c(i);x=Math.cos(t)*o,b=Math.sin(t)*o}else h?(x=e.middle,b=c(i)):(x=c(i),b=e.middle);no(l,g,t,x,b,m,y)}return l},swarm:function(e,t){const{scales:o,columns:i,getR:s,resolvePieceStyle:r}=e,{r:n,projection:a}=o,c=[],l="vertical"===a,h=ro(e);for(const e of Object.values(i)){const t=e.width/2;for(let o=0;e.pieceData.length>o;o++){const i=e.pieceData[o],a=s(i),d=r(i,e.name),u=d.r||4,g=(7919*o%100/100-.5)*t*.8;no(c,h,i,l?e.middle+g:n(a),l?n(a):e.middle+g,u,d)}}return c},pie:ao,donut:ao,boxplot:function(e,t){const{scales:o,columns:i,config:s,getR:r,resolveSummaryStyle:n}=e,{r:a,projection:c}=o,l=[],h="vertical"===c,d=!1!==s.showOutliers;for(const t of Object.values(i)){const o=t.pieceData.map(e=>r(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===o.length)continue;const i=o[0],s=o[o.length-1],c=co(o,.25)??i,u=co(o,.5)??(i+s)/2,g=co(o,.75)??s,p=g-c,f=c-1.5*p,y=g+1.5*p,m=o.find(e=>e>=f)??i,x=[...o].reverse().find(e=>y>=e)??s,b=n(t.pieceData[0],t.name),A=[];if(d)for(const e of t.pieceData){const o=r(e);if(f>o||o>y){const i=h?t.middle:a(o),s=h?a(o):t.middle;A.push({px:i,py:s,value:o,datum:e})}}if(l.push({type:"boxplot",x:h?t.middle:0,y:h?0:t.middle,projection:h?"vertical":"horizontal",columnWidth:.6*t.width,minPos:a(m),q1Pos:a(c),medianPos:a(u),q3Pos:a(g),maxPos:a(x),stats:{n:o.length,min:m,q1:c,median:u,q3:g,max:x,mean:o.reduce((e,t)=>e+t,0)/o.length},style:b,datum:t.pieceData,category:t.name,outliers:A}),d)for(const t of A)l.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:b.fill||e.config.themeSemantic?.secondary||"#999",opacity:.6},datum:t.datum})}return l},violin:function(e,t){const{scales:o,columns:i,config:s,getR:r,resolveSummaryStyle:n}=e,{r:a,projection:c}=o,l=[],h="vertical"===c,d=s.bins||20,u=!1!==s.showIQR;for(const e of Object.values(i)){const t=e.pieceData.map(e=>r(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const o=t[0],i=t[t.length-1],s=(i-o)/d||1,c=Array(d).fill(0);for(const e of t)c[Math.min(Math.floor((e-o)/s),d-1)]++;const g=Se(c,1),p=e.width/2*.9;let f;if(h){f=`M ${e.middle} ${a(o)}`;for(let t=0;d>t;t++){const i=a(o+(t+.5)*s);f+=` L ${e.middle+c[t]/g*p} ${i}`}f+=` L ${e.middle} ${a(i)}`;for(let t=d-1;t>=0;t--){const i=a(o+(t+.5)*s);f+=` L ${e.middle-c[t]/g*p} ${i}`}f+=" Z"}else{f=`M ${a(o)} ${e.middle}`;for(let t=0;d>t;t++)f+=` L ${a(o+(t+.5)*s)} ${e.middle-c[t]/g*p}`;f+=` L ${a(i)} ${e.middle}`;for(let t=d-1;t>=0;t--)f+=` L ${a(o+(t+.5)*s)} ${e.middle+c[t]/g*p}`;f+=" Z"}const y=n(e.pieceData[0],e.name);let m;if(u&&t.length>=4){const s=co(t,.25)??o,r=co(t,.5)??(o+i)/2,n=co(t,.75)??i;m={q1Pos:a(s),medianPos:a(r),q3Pos:a(n),centerPos:e.middle,isVertical:h}}const x=h?{x:e.x,y:Math.min(a(i),a(o)),width:e.width,height:Math.abs(a(i)-a(o))}:{x:Math.min(a(o),a(i)),y:e.x,width:Math.abs(a(i)-a(o)),height:e.width};l.push({type:"violin",pathString:f,translateX:0,translateY:0,bounds:x,iqrLine:m,stats:lo(t),style:y,datum:e.pieceData,category:e.name})}return l},histogram:function(e,t){const{scales:o,columns:i,config:s,getR:r,resolveSummaryStyle:n}=e,{r:a}=o,c=[],l=s.bins||25,h=s.normalize,d=a.domain?.(),u=d?+d[0]:void 0,g=d?+d[1]:void 0;for(const e of Object.values(i)){const t=e.pieceData.map(e=>r(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const[o,i]=ke(t),s=null!=u&&isFinite(u)?u:o,d=null!=g&&isFinite(g)?g:i,p=(d-s)/l||1,f=Array(l).fill(0);for(const e of t)s>e||e>d||f[Math.min(Math.floor((e-s)/p),l-1)]++;const y=t.length,m=Se(f,1),x=n(e.pieceData[0],e.name);for(let t=0;l>t;t++){if(0===f[t])continue;const o=(h?f[t]/y:f[t]/m)*e.width*.9,i=a(s+t*p),r=a(s+(t+1)*p);c.push(v(Math.min(i,r),e.x+e.width-o,Math.abs(r-i),o,x,{bin:t,count:f[t],range:[s+t*p,s+(t+1)*p],category:e.name},e.name))}}return c},ridgeline:function(e,t){const{scales:o,columns:i,config:s,getR:r,resolveSummaryStyle:n}=e,{r:a,projection:c}=o,l=[],h=s.bins||20,d="horizontal"===c,u=s.amplitude||1.5;for(const e of Object.values(i)){const t=e.pieceData.map(e=>r(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const o=t[0],i=t[t.length-1],s=(i-o)/h||1,c=Array(h).fill(0);for(const e of t)o>e||e>i||c[Math.min(Math.floor((e-o)/s),h-1)]++;const g=Se(c,1),p=n(e.pieceData[0],e.name),f=e.width*u;let y;if(d){const t=e.x+e.width;y=`M ${a(o)} ${t}`;for(let e=0;h>e;e++)y+=` L ${a(o+(e+.5)*s)} ${t-c[e]/g*f}`;y+=` L ${a(i)} ${t} Z`}else{const t=e.x;y=`M ${t} ${a(o)}`;for(let e=0;h>e;e++){const i=a(o+(e+.5)*s);y+=` L ${t+c[e]/g*f} ${i}`}y+=` L ${t} ${a(i)} Z`}const m=d?{x:Math.min(a(o),a(i)),y:e.x,width:Math.abs(a(i)-a(o)),height:e.width}:{x:e.x,y:Math.min(a(i),a(o)),width:e.width,height:Math.abs(a(i)-a(o))};l.push({type:"violin",pathString:y,translateX:0,translateY:0,bounds:m,stats:lo(t),style:{...p,fillOpacity:p.fillOpacity??.5},datum:e.pieceData,category:e.name})}return l},timeline:function(e,t){const{scales:o,columns:i,getRawRange:s,resolvePieceStyle:r}=e,{r:n,projection:a}=o,c=[],l="horizontal"===a;for(const e of Object.values(i))for(const t of e.pieceData){const o=s(t);if(!o)continue;const[i,a]=o,h=r(t,e.name);if(l){const o=n(Math.min(i,a)),s=n(Math.max(i,a));c.push(v(o,e.x,s-o,e.width,h,t,e.name))}else{const o=n(Math.max(i,a)),s=n(Math.min(i,a));c.push(v(e.x,o,e.width,s-o,h,t,e.name))}}return c},funnel:function(e,t){const{columns:o,getR:i,getStack:s,resolvePieceStyle:r}=e,n=[],a=t.width/2,c=!1!==e.config.showLabels,l=e.scales.o.domain().map(e=>o[e]).filter(Boolean);if(0===l.length)return n;const h=[],d=new Set;for(const e of l)for(const t of e.pieceData){const e=s?s(t):"_default";d.has(e)||(d.add(e),h.push(e))}const u=h.length>1&&"_default"!==h[0],g=[];let p=0;for(const e of l){const t=new Map;let o=0;for(const r of e.pieceData){const e=s?s(r):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const n=t.get(e),a=i(r);n.total+=a,n.pieces.push(r),o+=a}g.push({col:e,groups:t,stepTotal:o}),u||o>p&&(p=o)}if(u)for(const e of g){let t=0,o=0;for(let i=0;h.length>i;i++){const s=e.groups.get(h[i]);s&&(i%2==0?t+=s.total:o+=s.total)}const i=Math.max(t,o);i>p&&(p=i)}if(0===p)return n;const f=new Map;for(const e of h){const t=g[0].groups.get(e);f.set(e,t?.total??0)}const y=g[0].stepTotal,m=u?.95*a:.9*t.width,x=ho().domain([0,p]).range([0,m]),b=e.config.connectorOpacity??.3;let A=new Map;for(let t=0;g.length>t;t++){const o=g[t],i=o.col,s=0===t,l=i.width,d=.55*l,p=i.x+(l-d)/2,m=new Map;if(u){let e=0;for(const t of h){const i=o.groups.get(t);i&&(e+=x(i.total))}let t=a,l=a;for(let u=0;h.length>u;u++){const g=h[u],y=o.groups.get(g);if(!y)continue;const b=x(y.total),A=u%2==0,S=A?t:l-b;A?t+=b:l-=b;const w=r(y.pieces[0],g),k=f.get(g)??y.total,_={...y.pieces[0],__funnelValue:y.total,__funnelPercent:k>0?y.total/k*100:0,__funnelStep:i.name,__funnelIsFirstStep:s,__aggregateValue:y.total,__pieceCount:y.pieces.length,category:g};c&&(0===u&&(_.__funnelStepLabel=i.name,_.__funnelStepLabelX=a,_.__funnelStepLabelY=p,_.__funnelRowWidth=e),_.__funnelValueLabelX=S+b/2,_.__funnelValueLabelY=p,_.__funnelBarW=b),n.push(v(S,p,b,d,w,_,g)),m.set(g,{x:S,y:p,w:b,h:d})}}else{const e=o.stepTotal,t=x(e),l=a-t/2,u=h[0],g="_default"!==u,f=o.groups.get(u)?.pieces[0]??i.pieceData[0],b=g?u:i.name,A=r(f,b),S=y>0?e/y*100:0,w={...f,__funnelValue:e,__funnelPercent:S,__funnelStep:i.name,__funnelIsFirstStep:s,category:g?u:i.name};c&&(w.__funnelStepLabel=i.name,w.__funnelStepLabelX=a,w.__funnelStepLabelY=p,w.__funnelRowWidth=t,w.__funnelValueLabelX=a,w.__funnelValueLabelY=p,w.__funnelBarW=t),n.push(v(l,p,t,d,A,w,b)),m.set(u,{x:l,y:p,w:t,h:d})}if(t>0&&A.size>0){const t=u?h:[h[0]];for(const s of t){const t=A.get(s),a=m.get(s);if(!t||!a)continue;const c=(()=>{const e=o.groups.get(s);return r(e?e.pieces[0]:i.pieceData[0],"_default"===s?i.name:s)})(),l={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[a.x+a.w,a.y],[a.x,a.y]],style:{fill:c.fill||e.config.themeSemantic?.secondary||"#999",opacity:b},datum:o.groups.get(s)?.pieces[0]??i.pieceData[0],category:"_default"===s?i.name:s};n.push(l)}}A=m}return n},"bar-funnel":function(e,t){const{columns:o,getR:i,getStack:s,resolvePieceStyle:r,scales:n}=e,a=[],c=n.o.domain().map(e=>o[e]).filter(Boolean);if(0===c.length)return a;const l=[],h=new Set;for(const e of c)for(const t of e.pieceData){const e=s?s(t):"_default";h.has(e)||(h.add(e),l.push(e))}const d=l.length>1&&"_default"!==l[0],u=[];for(const e of c){const t=new Map;let o=0;for(const r of e.pieceData){const e=s?s(r):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const n=t.get(e),a=i(r);n.total+=a,n.pieces.push(r),o+=a}u.push({col:e,groups:t,stepTotal:o})}const g=new Map;for(const e of l){const t=u[0]?.groups.get(e);g.set(e,t?.total??0)}const p=n.r,f=d?l.length:1,y=d?.15:0;for(let e=0;u.length>e;e++){const t=u[e],o=t.col,i=0===e,s=e>0?u[e-1]:null,n=o.width/f,c=n*y,h=n-c;for(let e=0;l.length>e;e++){const u=l[e],f=t.groups.get(u);if(!f)continue;const y=f.total,m=g.get(u)??y,x=m>0?y/m*100:0,b=s?.groups.get(u),A=i?0:Math.max(0,(b?.total??y)-y),S=o.x+e*n+c/2,w=p(y),k=p(0)-w,_=r(f.pieces[0],d?u:o.name),M={...f.pieces[0],__barFunnelValue:y,__barFunnelPercent:x,__barFunnelIsFirstStep:i,__barFunnelIsDropoff:!1,__barFunnelStep:o.name,__barFunnelDropoffValue:A,__barFunnelCategory:"_default"===u?void 0:u,category:d?u:o.name,__barFunnelLabelX:S+h/2,__barFunnelLabelY:p(y+A)};if(a.push(v(S,w,h,k,_,M,d?u:o.name)),A>0){const e=p(y+A),t=w-e,i={..._},s={...f.pieces[0],__barFunnelValue:A,__barFunnelPercent:m>0?A/m*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:o.name,__barFunnelCategory:"_default"===u?void 0:u,category:d?u:o.name};a.push(v(S,e,h,t,i,s,d?u:o.name))}}}return a},swimlane:function(e,t){const{scales:o,columns:i,getR:s,getStack:r,resolvePieceStyle:n}=e,{r:a,projection:c}=o,l=[],h="horizontal"===c,d=e.config.gradientFill,u=h?"left":"bottom",g=e.config.trackFill;if(g){const e="string"==typeof g?g:g.color,t="string"==typeof g?1:g.opacity??1,[o,s]=a.range(),r=Math.min(o,s),n=Math.abs(s-o);for(const o of Object.values(i)){const i={fill:e,opacity:t},s=h?v(r,o.x,n,o.width,i,null,"__track__"):v(o.x,r,o.width,n,i,null,"__track__");l.push(s)}}const p=e.config.roundedTop&&e.config.roundedTop>0?Math.max(0,e.config.roundedTop):0;for(const e of Object.values(i)){let t=0;const o=l.length;for(const o of e.pieceData){const i=Math.abs(s(o));if(0===i)continue;const c=r?r(o):e.name,g=n(o,c);let p;if(h){const s=a(t),r=a(t+i);p=v(s,e.x,r-s,e.width,g,o,c)}else{const s=a(t+i),r=a(t);p=v(e.x,s,e.width,r-s,g,o,c)}d&&(p.fillGradient=d,p.roundedEdge=u),l.push(p),t+=i}if(p>0&&l.length>o){const e=l.slice(o),t=e[0],i=e[e.length-1];1===e.length?t.cornerRadii={tl:p,tr:p,br:p,bl:p}:h?(t.cornerRadii={tl:p,bl:p},i.cornerRadii={tr:p,br:p}):(t.cornerRadii={bl:p,br:p},i.cornerRadii={tl:p,tr:p})}}return l}},go=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],po=["scene-style","data-paint","accessibility","evidence"],fo=(e,t)=>({retainedData:e,invalidations:t}),yo=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],mo=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],xo=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],bo=["scene-geometry","data-paint","accessibility","evidence"],Ao=["scene-style","data-paint","accessibility","evidence"],vo=[],So={chartType:fo("rebuild",yo),runtimeMode:fo("rebuild",yo),categoryAccessor:fo("rebuild",yo),valueAccessor:fo("rebuild",yo),oAccessor:fo("rebuild",yo),rAccessor:fo("rebuild",yo),stackBy:fo("rebuild",yo),groupBy:fo("rebuild",yo),timeAccessor:fo("rebuild",yo),accessorRevision:fo("rebuild",yo),colorAccessor:fo("rebuild",Ao),symbolAccessor:fo("rebuild",bo),connectorAccessor:fo("rebuild",bo),dataIdAccessor:fo("rebuild",bo),projection:fo("preserve",mo),extentPadding:fo("preserve",mo),axisExtent:fo("preserve",mo),rExtent:fo("preserve",mo),oExtent:fo("preserve",mo),multiAxis:fo("preserve",mo),normalize:fo("preserve",mo),bins:fo("preserve",mo),oSort:fo("preserve",xo),barPadding:fo("preserve",xo),roundedTop:fo("preserve",xo),baselinePadding:fo("preserve",xo),innerRadius:fo("preserve",xo),cornerRadius:fo("preserve",xo),startAngle:fo("preserve",xo),sweepAngle:fo("preserve",xo),trackFill:fo("preserve",xo),showOutliers:fo("preserve",xo),showIQR:fo("preserve",xo),amplitude:fo("preserve",xo),connectorOpacity:fo("preserve",xo),showLabels:fo("preserve",xo),dynamicColumnWidth:fo("rebuild",xo),customLayout:fo("preserve",xo),layoutConfig:fo("preserve",xo),layoutMargin:fo("preserve",xo),symbolMap:fo("preserve",bo),pieceStyle:fo("preserve",Ao),summaryStyle:fo("preserve",Ao),connectorStyle:fo("preserve",Ao),gradientFill:fo("preserve",Ao),colorScheme:fo("preserve",Ao),themeCategorical:fo("preserve",Ao),themeSemantic:fo("preserve",Ao),themeSequential:fo("preserve",Ao),themeDiverging:fo("preserve",Ao),barColors:fo("preserve",Ao),decay:fo("preserve",Ao),pulse:fo("preserve",Ao),staleness:fo("preserve",Ao),layoutSelection:fo("preserve",Ao),windowSize:fo("preserve",vo),windowMode:fo("preserve",vo),clock:fo("preserve",vo),transition:fo("preserve",vo),introAnimation:fo("preserve",vo),onLayoutError:fo("preserve",vo)},wo=fo("preserve",xo),ko=class{constructor(){this.tracker=new me}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}},go)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},po):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const o=new Set;for(const i of e){const e=So[i]??wo;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)o.add(t)}return{retainedData:t,invalidations:o}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}};import{quadtree as _o}from"d3-quadtree";var Mo=class{constructor(e){this.rExtent=new O,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new ko,this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this.styleResolver=new so,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},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.version=0,this._dataVersion=0,this._bufferArrayCache=null,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=e,this.buffer=new j(e.windowSize),this.getO=pe(e.categoryAccessor||e.oAccessor,"category");const t=e.valueAccessor||e.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(e=>ge(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new O)):(this.getR=ge(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=pe(e.stackBy),this.getGroup=pe(e.groupBy),this.getColor=pe(e.colorAccessor),this.getSymbol=pe(e.symbolAccessor),this.getConnector=pe(e.connectorAccessor),this.getDataId=pe(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new j(e.windowSize))}syncPulseTimestampBuffer(){var e,t,o,i;this.timestampBuffer=(e=!!this.config.pulse,t=this.buffer,o=this.timestampBuffer,i=this.currentTime(),e?null!=o&&o.capacity===t.capacity&&o.size===t.size?o:T(t,i):null)}currentTime(){return this.config.clock?.()??ne()}ingest(e){const t=this.currentTime();if(this.lastIngestTime=t,this._dataVersion++,e.bounded){this.buffer.clear(),this.rExtent.clear();for(const e of this.rExtents)e.clear();e.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),P(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const o of e.inserts)L(this.buffer,o,this.timestampBuffer,t),this.categories.add(this.getO(o)),this.pushValueExtent(o)}else{this._hasStreamingData=!0;for(const o of e.inserts){const e=L(this.buffer,o,this.timestampBuffer,t);this.categories.add(this.getO(o)),this.pushValueExtent(o),null!=e&&this.evictValueExtent(e)}}return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}pushValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.push(t[0]),this.rExtent.push(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].push(this.rAccessors[t](e));this.rExtent.push(this.getR(e))}else this.rExtent.push(this.getR(e))}evictValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.evict(t[0]),this.rExtent.evict(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].evict(this.rAccessors[t](e));this.rExtent.evict(this.getR(e))}else this.rExtent.evict(this.getR(e))}getRawRange(e){const t=this.config.valueAccessor||this.config.rAccessor;if(!t)return null;const o="function"==typeof t?t(e):e[t];return Array.isArray(o)&&o.length>=2?[+o[0],+o[1]]:null}computeScene(e){const{config:t,buffer:o}=this,i=this.scales,s=this.multiScales,r=this.columns;if(0===o.size)return this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(o,this.getR);const n=this.getBufferArray(),a=t.projection||"vertical",c=t.oExtent||this.resolveCategories(n),l=this.computeValueDomain(n,c),h="horizontal"===a,d="radial"===a,u=Math.min(.9,Math.max(0,null!=t.barPadding?t.barPadding/("vertical"===a?e.width:e.height):.1));let g,p;if(d){g=oo().domain(c).range([0,1]).padding(0);const o=Math.min(e.width,e.height)/2,i=t.innerRadius||0;p=io().domain(l).range([i,o])}else h?(g=oo().domain(c).range([0,e.height]).padding(u),p=io().domain(l).range([0,e.width])):(g=oo().domain(c).range([0,e.width]).padding(u),p=io().domain(l).range([e.height,0]));this.scales={o:g,r:p,projection:a},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((i,s)=>{const r=this.rExtents[s];r.dirty&&r.recalculate(o,i);let[n,a]=r.extent;n===1/0&&(n=0,a=1);const c=a-n,l=c>0?c*(t.extentPadding??.05):1;return n-=l,a+=l,n>0&&(n=0),h?io().domain([n,a]).range([0,e.width]):io().domain([n,a]).range([e.height,0])}):[];let f=n;this.rAccessors.length>1&&(f=n.flatMap(e=>this.rAccessors.map((t,o)=>({...e,__rIndex:o,__rValue:t(e),__rName:this.resolveRAccessorName(o)})))),this.columns=this.buildColumns(f,c,g,a,e),this._customLayoutFailedThisBuild=!1;const y=this.buildSceneNodes(f,e);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=i,this.multiScales=s,this.columns=r):(this.scene=[],this.rebuildPointQuadtree()):(this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=y,this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,n),this.config.pulse&&this.applyPulse(this.scene,n),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.startTransition(),this.version++)}resolveRAccessorName(e){const t=this.config.valueAccessor||this.config.rAccessor,o=Array.isArray(t)?t[e]:t;return"string"==typeof o?o:"value"+e}resolveCategories(e){const t=this.config.oSort,o="streaming"===this.config.runtimeMode||this._hasStreamingData,i="auto"===t?void 0:t;let s=null;if(o){s=new Set;for(const t of e)s.add(this.getO(t))}const r=s?Array.from(this.categories).filter(e=>s.has(e)):Array.from(this.categories);if(o&&void 0===i){const e=Math.max(50,3*s.size);if(this.categories.size>e){let t=this.categories.size-e;for(const e of this.categories){if(0>=t)break;s.has(e)||(this.categories.delete(e),t--)}}return r}if(!1===i)return r;if("function"==typeof i)return r.sort(i);const n=new Map;for(const t of e){const e=this.getO(t);n.set(e,(n.get(e)||0)+Math.abs(this.getR(t)))}return r.sort("asc"===i?(e,t)=>(n.get(e)||0)-(n.get(t)||0):(e,t)=>(n.get(t)||0)-(n.get(e)||0))}computeValueDomain(e,t){return function(e){const{data:t,chartType:o,projection:i,normalize:s,rExtent:r,extentPadding:n=.05,baselinePadding:a,axisExtent:c,getO:l,getR:h,getStack:d,rawRExtent:u}=e,g=n;if("radial"===i&&("pie"===o||"donut"===o))return[0,1];let p=0,f=0;if("bar"===o&&d&&s)p=0,f=1;else if("bar"===o&&d){const e=new Map,o=new Map;for(const i of t){const t=l(i),s=h(i);0>s?o.set(t,(o.get(t)||0)+s):e.set(t,(e.get(t)||0)+s)}for(const t of e.values())t>f&&(f=t);for(const e of o.values())p>e&&(p=e)}else if("bar"===o){const e=new Map;for(const o of t){const t=l(o),i=h(o);e.set(t,(e.get(t)||0)+i)}for(const t of e.values())t>f&&(f=t),p>t&&(p=t)}else if("swimlane"===o){const e=new Map;for(const o of t){const t=l(o),i=Math.abs(h(o));e.set(t,(e.get(t)||0)+i)}for(const t of e.values())t>f&&(f=t)}else if("clusterbar"===o||"bar-funnel"===o)for(const e of t){const t=h(e);t>f&&(f=t),p>t&&(p=t)}else{const e=u[0],t=u[1];e!==1/0&&(p=e),t!==-1/0&&(f=t)}r&&(null!=r[0]&&(p=r[0]),null!=r[1]&&(f=r[1]));const y="bar"===o||"clusterbar"===o||"bar-funnel"===o||"swimlane"===o;if(y&&null==r?.[0]&&null==r?.[1]&&(p>0&&(p=0),0>f&&(f=0)),"bar-funnel"!==o&&"exact"!==c){const e=f-p,t=e>0?e*g:1,i=y&&!a&&0===p,s=y&&!a&&0===f||"swimlane"===o;null!=r?.[0]||i||(p-=t),null!=r?.[1]||s||(f+=t)}return[p,f]}({data:e,chartType:this.config.chartType,projection:this.config.projection,normalize:this.config.normalize,rExtent:this.config.rExtent,extentPadding:this.config.extentPadding,baselinePadding:this.config.baselinePadding,axisExtent:this.config.axisExtent,getO:this.getO,getR:this.getR,getStack:this.getStack,rawRExtent:this.rExtent.extent})}buildColumns(e,t,o,i,s){return function(e){const{data:t,oExtent:o,oScale:i,projection:s,layout:r,dynamicColumnWidth:n,getO:a,getR:c}=e,l={},h=new Map;for(const e of t){const t=a(e);h.has(t)||h.set(t,[]),h.get(t).push(e)}let d=0;if("radial"===s)for(const e of t)d+=Math.abs(c(e));let u=null;if(n&&"radial"!==s){u=new Map;let e=0;for(const t of o){const o=h.get(t)||[];let i;i="string"==typeof n?o.reduce((e,t)=>e+(Number(t[n])||0),0):n(o),u.set(t,i),e+=i}const t=("horizontal"===s?r.height:r.width)-i.padding()*i.step()*o.length;if(e>0)for(const[o,i]of u)u.set(o,i/e*t)}let g=0,p=0;for(const e of o){const t=h.get(e)||[],o=t.reduce((e,t)=>e+Math.abs(c(t)),0),s=d>0?o/d:0;let r,n;u?(r=p,n=u.get(e)||i.bandwidth(),p+=n+i.padding()*i.step()):(r=i(e)??0,n=i.bandwidth()),l[e]={name:e,x:r,y:0,width:n,middle:r+n/2,padding:i.padding()*i.step(),pieceData:t,pct:s,pctStart:g},g+=s}return l}({data:e,oExtent:t,oScale:o,projection:i,layout:s,dynamicColumnWidth:this.config.dynamicColumnWidth,getO:this.getO,getR:this.getR})}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getSymbol:this.getSymbol,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(e,t)=>this.styleResolver.resolvePieceStyle(this.config,e,t),resolveSummaryStyle:(e,t)=>this.styleResolver.resolveSummaryStyle(this.config,e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];if(this.config.customLayout){const o=this.buildLayoutContext(e,t);let i;try{i=this.config.customLayout(o)}catch(e){const t=null!==this.lastCustomLayoutResult,o=M("ordinal",e,t,this.version);this.lastCustomLayoutFailure=o,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",e);try{this.config.onLayoutError?.(o)}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,this.config.layoutSelection??null)}return E({label:"ordinal customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;const o=this.getSceneContext(),i=uo[this.config.chartType];let s=i?i(o,t):[];if(this.getConnector&&this.scales){const e=function(e,t){const{scales:o,config:i,getConnector:s,getO:r}=e;if(!s||!o)return[];const n=[],{projection:a}=o,c=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const o=s(t);if(!o)continue;let i,n;"point"===e.type?(i=e.x,n=e.y):(i=e.x+e.w/2,n=e.y+("vertical"===a?0:e.h/2)),c.has(o)||c.set(o,[]),c.get(o).push({x:i,y:n,datum:t,category:r(t)})}const l=o.o.domain(),h=i.connectorStyle;for(const[t,o]of c)if(o.length>=2){o.sort((e,t)=>l.indexOf(e.category)-l.indexOf(t.category));for(let i=0;o.length-1>i;i++){const s=o[i],r=o[i+1],a="function"==typeof h?h(s.datum):h||{stroke:e.config.themeSemantic?.border||e.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5};n.push({type:"connector",x1:s.x,y1:s.y,x2:r.x,y2:r.y,style:a,datum:s.datum,group:t})}}return n}(o,s);s=[...e,...s]}return s}buildLayoutContext(e,t){const o=this.config,i=o.layoutMargin??{top:0,right:0,bottom:0,left:0},s=le(o.colorScheme,o.themeCategorical,$),r=this.scales;return{data:e,scales:{o:r.o,r:r.r,projection:r.projection},dimensions:{width:t.width,height:t.height,margin:i,plot:"radial"===r.projection?{x:-t.width/2,y:-t.height/2,width:t.width,height:t.height}:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:o.themeSemantic??{},categorical:[...s]},resolveColor:Y(s,o.colorScheme),config:o.layoutConfig??{},selection:o.layoutSelection??null}}computeDecayOpacity(e,t){const o=this.config.decay;return o&&t>1?k(o,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const t=A(e);return this._datumIndexCache={version:this._dataVersion,map:t},t}getCategoryIndexMap(e){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const t=function(e,t){const o="function"==typeof t,i=o?null:t||"category",s=new Map;for(let r=0;e.length>r;r++){const n=e[r],a=o?t(n):n[i],c=s.get(a);c?c.push(r):s.set(a,[r])}return s}(e,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:t},t}rebuildPointQuadtree(){const e=function(e){let t=0,o=0;for(const i of e)"point"===i.type&&(t++,i.r>o&&(o=i.r));if(500>=t)return{quadtree:null,maxRadius:o};const i=Array(t);let s=0;for(const t of e)"point"===t.type&&(i[s++]=t);return{maxRadius:o,quadtree:_o().x(e=>e.x).y(e=>e.y).addAll(i)}}(this.scene);this._pointQuadtree=e.quadtree,this._maxPointRadius=e.maxRadius}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(e,t){if(!this.config.decay)return;const o=t.length;if(1>=o)return;const i=this.getDatumIndexMap(t);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;if(!t.datum)continue;const e=i.get(t.datum);if(null==e)continue;const s=this.computeDecayOpacity(e,o);t.style={...t.style,opacity:(t.style?.opacity??1)*s}}}applyPulse(e,t,o=this.currentTime()){return!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,o,i,s,r){const n=e.color??"rgba(255,255,255,0.6)",a=e.glowRadius??4;let c=!1;for(const l of t){if("connector"===l.type||"violin"===l.type||"boxplot"===l.type)continue;if("wedge"===l.type){const t=l.category;if(!t)continue;let i=0;for(const n of s(t)??[]){const t=o.get(n);null!=t&&(i=Math.max(i,_(e,t,r)))}c=C(l,i,n)||c;continue}if(null==l.datum)continue;const t=i.get(l.datum);if(null==t)continue;const h=o.get(t),d=null==h?0:_(e,h,r);c=C(l,d,n,a)||c}return c}(this.config.pulse,e,this.timestampBuffer,this.getDatumIndexMap(t),e=>this.getCategoryIndexMap(t).get(e),o)}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&z(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}synthesizeIntroPositions(){this.prevPositionMap.clear();const e=new Map,t=this.scales?.r(0)??0,o="horizontal"!==this.scales?.projection;let i;for(let s=0;this.scene.length>s;s++){const r=this.scene[s],n=this.getNodeKey(r,e);n&&("rect"===r.type?this.prevPositionMap.set(n,o?{x:r.x,y:t,w:r.w,h:0,opacity:r.style.opacity??1}:{x:t,y:r.y,w:0,h:r.h,opacity:r.style.opacity??1}):"point"===r.type?this.prevPositionMap.set(n,{x:r.x,y:r.y,r:0,opacity:0}):"wedge"===r.type&&(void 0===i&&(i=r.startAngle),this.prevPositionMap.set(n,{x:r.cx,y:r.cy,startAngle:i,endAngle:i,innerRadius:r.innerRadius,outerRadius:r.outerRadius,opacity:0})))}}getNodeKey(e,t){if("point"===e.type){const o=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,i=t.get(o)||0;return t.set(o,i+1),`${o}:${i}`}return"rect"===e.type?`r:${e.group||""}:${e.datum?.category??""}`:"wedge"===e.type?"w:"+(e.category??""):null}snapshotPositions(){this.prevPositionMap.clear();const e=new Map;for(let t=0;this.scene.length>t;t++){const o=this.scene[t],i=this.getNodeKey(o,e);i&&("point"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity}):"rect"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity}):"wedge"===o.type&&this.prevPositionMap.set(i,{x:o.cx,y:o.cy,startAngle:o.startAngle,endAngle:o.endAngle,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:o.style.opacity??1}))}}startTransition(){if(!this.config.transition||0===this.prevPositionMap.size)return;const e=this.config.transition.duration??300;if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let t=!1;const o=new Set,i=new Map;for(let e=0;this.scene.length>e;e++){const s=this.scene[e],r=this.getNodeKey(s,i);if(!r)continue;s._transitionKey=r;const n=this.prevPositionMap.get(r);if("point"===s.type)n?(o.add(r),s._targetOpacity=s.style.opacity??1,(n.x!==s.x||n.y!==s.y||void 0!==n.r&&n.r!==s.r)&&(s._targetX=s.x,s._targetY=s.y,s._targetR=s.r,s.x=n.x,s.y=n.y,void 0!==n.r&&(s.r=n.r),t=!0)):(s._targetOpacity=s.style.opacity??1,s._targetR=s.r,s.r=0,s.style={...s.style,opacity:0},t=!0);else if("rect"===s.type)n?(o.add(r),s._targetOpacity=s.style.opacity??1,n.x===s.x&&n.y===s.y&&n.w===s.w&&n.h===s.h||(s._targetX=s.x,s._targetY=s.y,s._targetW=s.w,s._targetH=s.h,s.x=n.x,s.y=n.y,s.w=n.w??s.w,s.h=n.h??s.h,t=!0)):(s._targetOpacity=s.style.opacity??1,s.style={...s.style,opacity:0},t=!0);else if("wedge"===s.type)if(n)o.add(r),s._targetOpacity=s.style.opacity??1,n.startAngle===s.startAngle&&n.endAngle===s.endAngle||(s._targetStartAngle=s.startAngle,s._targetEndAngle=s.endAngle,s.startAngle=n.startAngle,s.endAngle=n.endAngle,t=!0);else{s._targetOpacity=s.style.opacity??1,s._targetStartAngle=s.startAngle,s._targetEndAngle=s.endAngle;const e=s.startAngle;s.startAngle=e,s.endAngle=e,s.style={...s.style,opacity:0},this.prevPositionMap.set(r,{x:s.cx,y:s.cy,startAngle:e,endAngle:e,innerRadius:s.innerRadius,outerRadius:s.outerRadius,opacity:0}),t=!0}}this.exitNodes=[];for(const[e,i]of this.prevPositionMap)if(!o.has(e)){if(e.startsWith("p:"))this.exitNodes.push({type:"point",x:i.x,y:i.y,r:i.r??3,style:{opacity:i.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))this.exitNodes.push({type:"rect",x:i.x,y:i.y,w:i.w??0,h:i.h??0,style:{opacity:i.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("w:")){const t=((i.startAngle??0)+(i.endAngle??0))/2,o={type:"wedge",cx:i.x,cy:i.y,innerRadius:i.innerRadius??0,outerRadius:i.outerRadius??100,startAngle:i.startAngle??0,endAngle:i.endAngle??0,style:{opacity:i.opacity??1},datum:null,category:e.slice(2),_targetStartAngle:t,_targetEndAngle:t,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(o)}t=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),t&&(this.activeTransition={startTime:this.currentTime(),duration:e})}advanceTransition(e){if(!this.activeTransition)return!1;const t=X(e,this.activeTransition),o=H(t,"linear"===this.config.transition?.easing?"linear":"ease-out-cubic");for(const e of this.scene){const t=e._transitionKey;if(t)if("point"===e.type){if(void 0!==e._targetOpacity){const i=this.prevPositionMap.get(t);e.style.opacity=oe(i?i.opacity??1:0,e._targetOpacity,o)}const i=this.prevPositionMap.get(t);void 0!==e._targetX&&i&&(e.x=oe(i.x,e._targetX,o),e.y=oe(i.y,e._targetY,o)),void 0!==e._targetR&&void 0!==i?.r&&(e.r=oe(i.r,e._targetR,o))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const i=this.prevPositionMap.get(t);e.style.opacity=oe(i?i.opacity??1:0,e._targetOpacity,o)}if(void 0===e._targetX)continue;const i=this.prevPositionMap.get(t);if(!i)continue;e.x=oe(i.x,e._targetX,o),e.y=oe(i.y,e._targetY,o),void 0!==i.w&&(e.w=oe(i.w,e._targetW,o),e.h=oe(i.h,e._targetH,o))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){const i=this.prevPositionMap.get(t);e.style={...e.style,opacity:oe(i?i.opacity??1:0,e._targetOpacity,o)}}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){const i=this.prevPositionMap.get(t);i&&void 0!==i.startAngle&&(e.startAngle=oe(i.startAngle,e._targetStartAngle,o),e.endAngle=oe(i.endAngle,e._targetEndAngle,o))}}}if(t>=1){for(const e of this.scene)if(void 0!==e._targetOpacity&&(e.style={...e.style||{},opacity:0===e._targetOpacity?0:e._targetOpacity},e._targetOpacity=void 0),"point"===e.type){if(void 0===e._targetX&&void 0===e._targetR)continue;void 0!==e._targetX&&(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("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"wedge"===e.type&&void 0!==e._targetStartAngle&&(e.startAngle=e._targetStartAngle,e.endAngle=e._targetEndAngle,e._targetStartAngle=void 0,e._targetEndAngle=void 0);if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}cancelIntroAnimation(){this.prevPositionMap.clear(),this.activeTransition=null}getBufferArray(){return this._bufferArrayCache?.version!==this._dataVersion&&(this._bufferArrayCache={version:this._dataVersion,data:this.buffer.toArray()}),this._bufferArrayCache.data}getData(){return this.buffer.toArray()}remove(e){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=D(e),o=this.getDataId,i=e=>t.has(o(e));w(this.buffer,this.timestampBuffer,i);const s=this.buffer.remove(i);if(0===s.length)return this.updateResults.recordNoop("remove"),s;for(const e of s)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach(e=>this.categories.add(this.getO(e))),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",s.length),s}update(e,t){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const o=D(e),i=this.getDataId,s=new Set;this.buffer.forEach((e,t)=>{o.has(i(e))&&s.add(t)});const r=this.buffer.update(e=>o.has(i(e)),t);if(0===r.length)return this.updateResults.recordNoop("update"),r;for(const e of r)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach((e,t)=>{this.categories.add(this.getO(e)),s.has(t)&&this.pushValueExtent(e)}),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",r.length),r}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.multiScales=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._pointQuadtree=null,this._maxPointRadius=0,this.styleResolver.resetColors(),this._dataVersion++,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}applyCustomRestyle(e,t){const o=this._customRestyle;if(o)for(const i of e){const e=this._baseStyles.get(i)??i.style??{},s=o(i,t);i.style=s?{...e,...s}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}rebuildAccessorDerivedState(){this.categories.clear(),this.rExtent.clear();for(const e of this.rExtents)e.clear();this._categoryIndexCache=null,this.buffer.forEach(e=>{this.categories.add(this.getO(e)),this.pushValueExtent(e)})}updateConfig(e){const t={...this.config},o=Object.keys(e).filter(o=>e[o]!==t[o]);"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&&e.colorScheme!==t.colorScheme||"themeCategorical"in e&&e.themeCategorical!==t.themeCategorical||"colorAccessor"in e&&!ue(e.colorAccessor,t.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in e&&!ue(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!ue(e.oAccessor,t.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();let i=!1;("categoryAccessor"in e||"oAccessor"in e)&&(ue(this.config.categoryAccessor||this.config.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=pe(this.config.categoryAccessor||this.config.oAccessor,"category"),i=!0));let s=!1;if("valueAccessor"in e||"rAccessor"in e){const e=this.config.valueAccessor||this.config.rAccessor,o=t.valueAccessor||t.rAccessor,i=Array.isArray(e)?e:[e],r=Array.isArray(o)?o:[o];if(s=i.length!==r.length||i.some((e,t)=>!ue(e,r[t])),s){const e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>ge(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new O)):(this.getR=ge(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!ue(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?pe(this.config.stackBy):void 0),"groupBy"in e&&!ue(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?pe(this.config.groupBy):void 0),"colorAccessor"in e&&!ue(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?pe(this.config.colorAccessor):void 0),"symbolAccessor"in e&&!ue(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?pe(this.config.symbolAccessor):void 0),"connectorAccessor"in e&&!ue(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?pe(this.config.connectorAccessor):void 0),(i||s||"accessorRevision"in e&&e.accessorRevision!==t.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(o)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};b(Mo);import{jsx as To,jsxs as Po}from"react/jsx-runtime";import{Fragment as Ro,jsx as zo,jsxs as Lo}from"react/jsx-runtime";function Fo(e,t){const o=ft(e.theme),i=e.size||[500,400],s=ce({top:20,right:20,bottom:30,left:40,...e.margin},e.title),r=J(e.title),n=Q(e.data),a=e.showLegend?Ft(n,e.colorAccessor||e.stackBy||e.groupBy):[],c=e.legendPosition;te(e.legend)||ee(e.legend)?Ht(s,{legend:e.legend,theme:o,position:c||"right",size:i,hasTitle:r,legendLayout:e.legendLayout}):e.showLegend&&a.length>0&&Yt(s,{categories:a,colorScheme:e.colorScheme,theme:o,position:c||"right",size:i,hasTitle:r,legendLayout:e.legendLayout});const l=i[0]-s.left-s.right,h=i[1]-s.top-s.bottom,d=e.projection||"vertical",u="radial"===d,g={chartType:e.chartType,windowSize:e.windowSize??1e4,windowMode:e.windowMode??"sliding",extentPadding:e.extentPadding??.05,projection:d,oAccessor:e.oAccessor,rAccessor:e.rAccessor,colorAccessor:e.colorAccessor,stackBy:e.stackBy,groupBy:e.groupBy,categoryAccessor:e.categoryAccessor,valueAccessor:e.valueAccessor,timeAccessor:e.timeAccessor,rExtent:e.rExtent,oExtent:e.oExtent,axisExtent:e.axisExtent,barPadding:e.barPadding,roundedTop:e.roundedTop,innerRadius:e.innerRadius,cornerRadius:e.cornerRadius,normalize:e.normalize,startAngle:e.startAngle,sweepAngle:e.sweepAngle,bins:e.bins,showOutliers:e.showOutliers,showIQR:e.showIQR,amplitude:e.amplitude,oSort:e.oSort,connectorAccessor:e.connectorAccessor,connectorStyle:e.connectorStyle,dynamicColumnWidth:e.dynamicColumnWidth,pieceStyle:e.pieceStyle,summaryStyle:e.summaryStyle,gradientFill:e.gradientFill,symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,multiAxis:e.multiAxis,baselinePadding:e.baselinePadding,trackFill:e.trackFill,connectorOpacity:e.connectorOpacity,showLabels:e.showLabels,colorScheme:e.colorScheme||o.colors.categorical,themeCategorical:o.colors.categorical,themeSemantic:ze(o),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:s,layoutSelection:e.layoutSelection,barColors:e.barColors},p=new Mo(g);if(e.data&&p.ingest({inserts:n,bounded:!0}),p.computeScene({width:l,height:h}),!p.scales||0===p.scene.length)return t&&(t.evidence=bt({frameType:"ordinal",width:i[0],height:i[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,extraWarnings:p.scales?[]:["NO_SCALES"]})),to.renderToStaticMarkup(Qt(null,{width:i[0],height:i[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${s.left},${s.top})`,innerWidth:l,innerHeight:h,idPrefix:e._idPrefix}));if(t){const o=p.scales.o?.domain?.();t.evidence=bt({frameType:"ordinal",width:i[0],height:i[1],marks:p.scene,title:e.title,description:e.description,annotations:e.annotations,yDomain:xt(p.scales.r?.domain?.()),categories:Array.isArray(o)?o.map(String):void 0})}const f=e._idPrefix,y=e.showGrid?function(e,t,o,i,s){const r=e.scales;if(!r||"radial"===r.projection)return null;const{grid:n}=yt(o),a=i?i+"-":"",c="vertical"===r.projection,l=B(r.r,5,s);return It("g",c?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,o)=>{const i=r.r(e);return It("line",{x1:0,y1:i,x2:t.width,y2:i,stroke:n,strokeWidth:.5},"gr-"+o)})}:{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,o)=>{const i=r.r(e);return It("line",{x1:i,y1:0,x2:i,y2:t.height,stroke:n,strokeWidth:.5},"gr-"+o)})})}(p,{width:l,height:h},o,f,e.axisExtent):null;let m=null;if(p.scene.some(e=>"rect"===e.type&&e.datum?.__barFunnelIsDropoff)){const t=function(e){const t=e._idPrefix||e.chartId;if(t){const e=(t+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(e)?e:"c"+e}const o=`${e.chartType||""}:${e.title||""}:${Array.isArray(e.data)?e.data.length:0}`;let i=0;for(let e=0;o.length>e;e++)i=31*i+o.charCodeAt(e)|0;return"c"+(i>>>0).toString(36)}(e),i=new Set;for(const e of p.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&i.add("string"==typeof e.style.fill?e.style.fill:"#666");m=Array.from(i).map((e,i)=>function(e){const{id:t,background:o="transparent",stroke:i="#000",lineWidth:s=1.5,spacing:r=6,angle:n=45}=e,a=Math.max(8,Math.ceil(2*r));return Po("pattern",{id:t,width:a,height:a,patternUnits:"userSpaceOnUse",patternTransform:0!==n?`rotate(${n})`:void 0,children:[o&&"transparent"!==o&&To("rect",{width:a,height:a,fill:o}),To("line",{x1:0,y1:0,x2:0,y2:a,stroke:i,strokeWidth:s}),To("line",{x1:r,y1:0,x2:r,y2:a,stroke:i,strokeWidth:s})]},t)}({id:`funnel-hatch-${t}-${i}`,background:e,stroke:"transparent"===o.colors.background?"#fff":o.colors.background,lineWidth:1.5,spacing:5,angle:45}));const s=new Map;Array.from(i).forEach((e,o)=>s.set(e,`funnel-hatch-${t}-${o}`));for(const e of p.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&(e.style={...e.style,fill:`url(#${s.get("string"==typeof e.style.fill?e.style.fill:"#666")})`})}const x=p.scene.map((t,o)=>F({node:t,index:o,renderMode:e.renderMode,fallback:()=>ae(t,o,f)})).filter(Boolean),b=!1!==e.showAxes?function(e,t,o,i,s){const r=e.scales;if(!r)return null;if("radial"===r.projection)return null;const n=yt(i),a="vertical"===r.projection,c=o.categoryFormat||o.oFormat,l=o.valueFormat||o.rFormat,h=o.categoryLabel||o.oLabel,d=o.valueLabel||o.rLabel,u=Object.values(e.columns).map(e=>({pixel:e.middle,label:(c||String)(e.name)})),g=B(r.r,5,o.axisExtent).map(e=>({pixel:r.r(e),label:(l||qt)(e)}));return Lo("g",a?{id:(s?s+"-":"")+"axes",className:"ordinal-axes",children:[zo("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:n.border,strokeWidth:1}),u.map((e,o)=>Lo("g",{transform:`translate(${e.pixel},${t.height})`,children:[zo("line",{y2:5,stroke:n.border,strokeWidth:1}),zo("text",{y:18,textAnchor:"middle",fontSize:n.tickSize,fill:n.textSecondary,fontFamily:n.fontFamily,children:e.label})]},"oxtick-"+o)),h&&zo("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:n.labelSize,fill:n.text,fontFamily:n.fontFamily,children:h}),zo("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:n.border,strokeWidth:1}),g.map((e,t)=>Lo("g",{transform:`translate(0,${e.pixel})`,children:[zo("line",{x2:-5,stroke:n.border,strokeWidth:1}),zo("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n.tickSize,fill:n.textSecondary,fontFamily:n.fontFamily,children:e.label})]},"oytick-"+t)),d&&zo("text",{x:15-(o.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:n.labelSize,fill:n.text,fontFamily:n.fontFamily,transform:`rotate(-90, ${15-(o.margin?.left??40)}, ${t.height/2})`,children:d})]}:{id:(s?s+"-":"")+"axes",className:"ordinal-axes",children:[zo("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:n.border,strokeWidth:1}),g.map((e,o)=>Lo("g",{transform:`translate(${e.pixel},${t.height})`,children:[zo("line",{y2:5,stroke:n.border,strokeWidth:1}),zo("text",{y:18,textAnchor:"middle",fontSize:n.tickSize,fill:n.textSecondary,fontFamily:n.fontFamily,children:e.label})]},"oxtick-"+o)),d&&zo("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:n.labelSize,fill:n.text,fontFamily:n.fontFamily,children:d}),zo("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:n.border,strokeWidth:1}),u.map((e,t)=>Lo("g",{transform:`translate(0,${e.pixel})`,children:[zo("line",{x2:-5,stroke:n.border,strokeWidth:1}),zo("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n.tickSize,fill:n.textSecondary,fontFamily:n.fontFamily,children:e.label})]},"oytick-"+t)),h&&zo("text",{x:15-(o.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:n.labelSize,fill:n.text,fontFamily:n.fontFamily,transform:`rotate(-90, ${15-(o.margin?.left??40)}, ${t.height/2})`,children:h})]})}(p,{width:l,height:h},e,o,f):null,A=e.annotations?Wt({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{o:p.scales.o,r:p.scales.r,y:"vertical"===p.scales.projection?p.scales.r:void 0},layout:{width:l,height:h},theme:o,projection:d,idPrefix:f}):null,v=e.showLegend?0===a.length?null:Lt({categories:a,colorScheme:e.colorScheme,theme:o,position:e.legendPosition||"right",totalWidth:i[0],totalHeight:i[1],margin:s,hasTitle:r,legendLayout:e.legendLayout}):null,S=eo.isValidElement(e.legend)?e.legend:Xt(e.legend,{theme:o,position:e.legendPosition||"right",size:i,margin:s,hasTitle:r,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||v,w=u?s.left+l/2:s.left,k=u?s.top+h/2:s.top;return to.renderToStaticMarkup(Qt(Lo(Ro,{children:[e.backgroundGraphics,y,x,b,A,e.foregroundGraphics,p.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${w},${k})`,innerWidth:l,innerHeight:h,legend:S,defs:m,idPrefix:e._idPrefix}))}import*as Co from"react";import*as Bo from"react-dom/server";import{Fragment as Do,jsxs as Eo}from"react/jsx-runtime";function Oo(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}var jo=new Set(["tree","cluster","treemap","circlepack","partition"]);function No(e,t){const o=ft(e.theme),i=e.chartType||"force",s=()=>bt({frameType:"network",width:r[0],height:r[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,nodeCount:0,edgeCount:0}),r=e.size||[500,500],n=ce({top:20,right:20,bottom:20,left:20,...e.margin},e.title),a=J(e.title),c=e.showLegend?(()=>{const t="string"==typeof(o=e.colorBy)||"function"==typeof o?e.colorBy:void 0;var o;if(!t)return[];const i=Q(e.nodes||[]);if(i.length>0)return Ft(i,t);const s=Array.isArray(e.edges)?Q(e.edges):[];if(0===s.length)return[];const r=Oo(e.sourceAccessor,"source"),n=Oo(e.targetAccessor,"target");return Ft(Array.from(new Set(s.flatMap(e=>[r(e),n(e)]).filter(e=>null!=e).map(String))).map(e=>({id:e})),t)})():[],l=e.legendPosition;te(e.legend)||ee(e.legend)?Ht(n,{legend:e.legend,theme:o,position:l||"right",size:r,hasTitle:a,legendLayout:e.legendLayout}):e.showLegend&&c.length>0&&Yt(n,{categories:c,colorScheme:e.colorScheme,theme:o,position:l||"right",size:r,hasTitle:a,legendLayout:e.legendLayout});const h=r[0]-n.left-n.right,d=r[1]-n.top-n.bottom,u=R(i);if(!u&&!e.customNetworkLayout)throw Error(`No layout plugin found for chart type: "${i}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const g={chartType:i,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,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,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,colorBy:e.colorBy,colorScheme:e.colorScheme||o.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,customNetworkLayout:e.customNetworkLayout,layoutConfig:e.layoutConfig};let p,f;if(jo.has(i)){const i=e.data||e.edges;if(!i||Array.isArray(i))return t&&(t.evidence=s()),Bo.renderToStaticMarkup(Qt(null,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${n.left},${n.top})`,innerWidth:h,innerHeight:d,idPrefix:e._idPrefix}));g.__hierarchyRoot=i,p=[],f=[]}else{const i=Q(e.nodes||[]),a=Array.isArray(e.edges)?Q(e.edges):[];if(0===i.length&&0===a.length)return t&&(t.evidence=s()),Bo.renderToStaticMarkup(Qt(null,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${n.left},${n.top})`,innerWidth:h,innerHeight:d,idPrefix:e._idPrefix}));if(f=function(e,t){const o=Oo(t.sourceAccessor,"source"),i=Oo(t.targetAccessor,"target"),s=Oo(t.valueAccessor,"value");return e.map(e=>({source:o(e)+"",target:i(e)+"",value:Number(s(e))||1,y0:0,y1:0,sankeyWidth:0,data:e}))}(a,g),0===i.length&&f.length>0){const e=new Set;for(const t of f){const o=Vt(t.source),i=Vt(t.target);o&&e.add(o),i&&e.add(i)}p=Array.from(e).map(e=>({id:e,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:e}}))}else p=function(e,t){const o=Oo(t.nodeIDAccessor,"id");return e.map(e=>({id:o(e)+"",x:e.x??0,y:e.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:e}))}(i,g)}let y=[],m=[],x=[],b=null;if(g.customNetworkLayout){const e=g.colorScheme,t=le(e,o.colors.categorical,ve),i=Y(t,e),s={nodes:p,edges:f,dimensions:{width:h,height:d,plot:{x:0,y:0,width:h,height:d}},theme:{semantic:o.colors,categorical:[...t]},resolveColor:i,config:g.layoutConfig??{}},r=g.customNetworkLayout(s);y=r.sceneNodes??[],m=r.sceneEdges??[],x=r.labels??[],b=r.overlays??null}else if(u){u.computeLayout(p,f,g,[h,d]);const e=u.buildScene(p,f,g,[h,d]);y=e.sceneNodes,m=e.sceneEdges,x=e.labels}const A=yt(o);for(const e of x)e.fill||(e.fill=A.text);t&&(t.evidence=bt({frameType:"network",width:r[0],height:r[1],marks:[...y.map(e=>({type:"node:"+(e.type??"node")})),...m.map(e=>({type:"edge:"+(e.type??"edge")}))],title:e.title,description:e.description,annotations:e.annotations,nodeCount:y.length,edgeCount:m.length}));const v=m.map((t,o)=>F({node:t,index:o,renderMode:e.renderMode,fallback:()=>se(t,o)})).filter(Boolean),S=y.map((t,o)=>F({node:t,index:o,renderMode:e.renderMode,fallback:()=>re(t,o)})).filter(Boolean),w=x.map((e,t)=>ie(e,t)).filter(Boolean),k=e.annotations?Wt({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{},layout:{width:h,height:d},theme:o,idPrefix:e._idPrefix}):null,_=e.showLegend?(()=>{const t="string"==typeof(i=e.colorBy)||"function"==typeof i?e.colorBy:void 0;var i;if(!t)return[];const s=Ft(p.length>0?p.map(e=>e.data||{id:e.id}):Array.from(new Set(f.flatMap(e=>[Vt(e.source),Vt(e.target)]).filter(Boolean))).map(e=>({id:e})),t);return 0===s.length?null:Lt({categories:s,colorScheme:e.colorScheme,theme:o,position:e.legendPosition||"right",totalWidth:r[0],totalHeight:r[1],margin:n,hasTitle:a,legendLayout:e.legendLayout})})():null,M=Co.isValidElement(e.legend)?e.legend:Xt(e.legend,{theme:o,position:e.legendPosition||"right",size:r,margin:n,hasTitle:a,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||_;return Bo.renderToStaticMarkup(Qt(Eo(Do,{children:[e.backgroundGraphics,v,S,w,k,e.foregroundGraphics,b]}),{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${n.left},${n.top})`,innerWidth:h,innerHeight:d,legend:M,idPrefix:e._idPrefix}))}import*as Wo from"react";import*as $o from"react-dom/server";import{geoPath as Io}from"d3-geo";import{quadtree as Go}from"d3-quadtree";import{geoMercator as Vo,geoEqualEarth as Yo,geoAlbersUsa as Ho,geoOrthographic as Xo,geoNaturalEarth1 as qo,geoEquirectangular as Qo}from"d3-geo";var Zo={mercator:Vo,equalEarth:Yo,albersUsa:Ho,orthographic:Xo,naturalEarth:qo,equirectangular:Qo};function Uo(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function Ko(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function Jo(e,t,o){return e?"function"==typeof e?{...o,...e(t)}:{...o,...e}:{...o}}function ei(e,t){if(2>e.length)return[e];const o=.4*t,i=[];let s=[e[0]];for(let t=1;e.length>t;t++){const r=e[t];Math.abs(r[0]-e[t-1][0])>o?(2>s.length||i.push(s),s=[r]):s.push(r)}return 2>s.length||i.push(s),i}function ti(e,t,o=24){const i=t[0]-e[0],s=t[1]-e[1],r=Math.sqrt(i*i+s*s);if(0===r)return[e,t];const n=-s/r,a=i/r,c=Math.min(.3*r,80),l=(e[0]+t[0])/2+n*c,h=(e[1]+t[1])/2+a*c,d=[];for(let i=0;o>=i;i++){const s=i/o,r=1-s;d.push([r*r*e[0]+2*r*s*l+s*s*t[0],r*r*e[1]+2*r*s*h+s*s*t[1]])}return d}function oi(e,t){if(2>e.length)return e;const o=t/2+1,i=[];for(let t=0;e.length>t;t++){const s=e[t];let r,n;0===t?(r=e[1][0]-s[0],n=e[1][1]-s[1]):t===e.length-1?(r=s[0]-e[t-1][0],n=s[1]-e[t-1][1]):(r=e[t+1][0]-e[t-1][0],n=e[t+1][1]-e[t-1][1]);const a=Math.sqrt(r*r+n*n)||1;i.push([s[0]+n/a*o,s[1]+-r/a*o])}return i}function ii(e,t,o,i,s){const r=t[0]-e[0],n=t[1]-e[1],a=Math.sqrt(r*r+n*n);if(0===a)return[e,t];const c=n/a,l=-r/a,h=s/2+1;return[[e[0]+c*h,e[1]+l*h],[t[0]+c*h,t[1]+l*h]]}import{scaleLinear as si}from"d3-scale";var ri=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ni=["scene-style","data-paint","accessibility","evidence"],ai=(e,t)=>({retainedData:e,invalidations:t}),ci=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],li=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],hi=["scene-geometry","data-paint","accessibility","evidence"],di=["scene-style","data-paint","accessibility","evidence"],ui=["overlay","accessibility","evidence"],gi=[],pi={xAccessor:ai("rebuild",ci),yAccessor:ai("rebuild",ci),lineDataAccessor:ai("rebuild",ci),pointIdAccessor:ai("rebuild",hi),lineIdAccessor:ai("rebuild",hi),windowSize:ai("rebuild",ci),projection:ai("preserve",li),projectionExtent:ai("preserve",li),fitPadding:ai("preserve",li),lineType:ai("preserve",li),flowStyle:ai("preserve",li),graticule:ai("preserve",li),projectionTransform:ai("preserve",li),customLayout:ai("preserve",li),layoutConfig:ai("preserve",li),layoutMargin:ai("preserve",li),areaStyle:ai("preserve",di),pointStyle:ai("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:ai("preserve",di),colorScheme:ai("preserve",di),themeCategorical:ai("preserve",di),themeDiverging:ai("preserve",di),themeSemantic:ai("preserve",di),themeSequential:ai("preserve",di),decay:ai("preserve",di),pulse:ai("preserve",di),layoutSelection:ai("preserve",di),annotations:ai("preserve",ui),autoPlaceAnnotations:ai("preserve",ui),clock:ai("preserve",gi),transition:ai("preserve",gi),introAnimation:ai("preserve",gi),onLayoutError:ai("preserve",gi)},fi=ai("preserve",li),yi=class{constructor(){this.tracker=new me}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}},ri)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},ni):this.recordNoop("restyle")}recordConfig(e,t={}){const o=function(e){let t="preserve";const o=new Set;for(const i of e){const e=pi[i]??fi;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)o.add(t)}return{retainedData:t,invalidations:o}}(e),i=new Set(o.invalidations);return t.retainedDataChanged&&i.add("data"),this.tracker.record({kind:"config",keys:e},i)}};import{geoDistance as mi,geoGraticule as xi,geoInterpolate as bi}from"d3-geo";function Ai(e){if(null==e)return 0;if("number"==typeof e&&Number.isFinite(e)&&e>=0&&.5>e)return e;throw new RangeError(`[semiotic] fitPadding must be a finite fraction in [0, 0.5); received ${e+""}.`)}var vi=class e{constructor(e){this.updateResults=new yi,this.scene=[],this.scales=null,this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this.config=function(e){return{...e,fitPadding:Ai(e.fitPadding)}}(e)}currentTime(){return this.config.clock?.()??ne()}getConfiguredWindowSize(){const e=this.config.windowSize??500;if(!Number.isInteger(e)||1>e)throw Error("GeoPipelineStore windowSize must be a positive integer");return e}retainNewestLines(e=this.getConfiguredWindowSize()){this.lineData.length>e&&(this.lineData=this.lineData.slice(-e))}resizeStreamingWindow(e){if(this.pointBuffer){const t=this.pointBuffer.toArray(),o=this.timestampBuffer?.toArray()??[],i=t.slice(-e),s=o.slice(-i.length),r=this.currentTime();this.pointBuffer=new j(e),this.timestampBuffer=new j(e),i.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(s[t]??r)})}this.retainNewestLines(e)}updateConfig(e){const t=function(e){return"fitPadding"in e?{...e,fitPadding:Ai(e.fitPadding)}:e}(e),o=this.config,i=this.getConfiguredWindowSize(),s=Object.keys(t).filter(e=>t[e]!==o[e]);this.config={...this.config,...t};const r=this.getConfiguredWindowSize(),n=this.streaming&&r!==i;n&&(this.resizeStreamingWindow(r),this.version++),"customLayout"in t&&!t.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(s,{retainedDataChanged:n})}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setAreas(e){this.areas=e,this.updateResults.recordData("replace",e.length)}setAreasWithResult(e){return this.setAreas(e),this.updateResults.last}setPoints(e){this.pointData=e.slice(),this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.updateResults.recordData("replace",e.length)}setPointsWithResult(e){return this.setPoints(e),this.updateResults.last}setLines(e){this.lineData=e.slice(),this.streaming&&this.retainNewestLines(),this.updateResults.recordData("replace",e.length)}setLinesWithResult(e){return this.setLines(e),this.updateResults.last}initStreaming(e){void 0!==e&&e!==this.config.windowSize&&(this.config={...this.config,windowSize:e});const t=this.getConfiguredWindowSize(),o=this.pointBuffer?this.pointBuffer.toArray():this.pointData,i=this.timestampBuffer?.toArray()??[],s=o.slice(-t),r=i.slice(-s.length),n=this.currentTime();this.pointBuffer=new j(t),this.timestampBuffer=new j(t),s.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(r[t]??n)}),this.pointData=[],this.retainNewestLines(t),this.streaming=!0}pushPoint(e){this.pointBuffer||this.initStreaming();const t=this.currentTime();L(this.pointBuffer,e,this.timestampBuffer,t),this.lastIngestTime=t,this.updateResults.recordData("ingest",1)}pushPointWithResult(e){return this.pushPoint(e),this.updateResults.last}pushMany(e){this.pointBuffer||this.initStreaming();const t=this.currentTime();for(const o of e)L(this.pointBuffer,o,this.timestampBuffer,t);this.lastIngestTime=t,this.updateResults.recordData("ingest",e.length)}pushManyWithResult(e){return this.pushMany(e),this.updateResults.last}pushLine(e){null!=e&&"object"==typeof e?(this.streaming||this.initStreaming(),this.lineData.push(e),this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",1)):this.updateResults.recordNoop("ingest")}pushManyLines(e){if(!Array.isArray(e)||0===e.length)return void this.updateResults.recordNoop("ingest");const t=e.filter(e=>null!=e&&"object"==typeof e);if(0!==t.length){this.streaming||this.initStreaming();for(const e of t)this.lineData.push(e);this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",t.length)}else this.updateResults.recordNoop("ingest")}removeLine(e){const{lineIdAccessor:t}=this.config;if(!t)throw Error("removeLine() requires lineIdAccessor to be configured");const o="function"==typeof t?t:e=>e[t],i=new Set(Array.isArray(e)?e:[e]),s=[];return this.lineData=this.lineData.filter(e=>!i.has(o(e)+"")||(s.push(e),!1)),s.length>0?(this.version++,this.updateResults.recordData("remove",s.length)):this.updateResults.recordNoop("remove"),s}getLines(){return this.lineData.slice()}removePoint(e){const{pointIdAccessor:t}=this.config;if(!t)throw Error("removePoint() requires pointIdAccessor to be configured");const o="function"==typeof t?t:e=>e[t],i=new Set(Array.isArray(e)?e:[e]);if(this.streaming&&this.pointBuffer){const e=e=>i.has(o(e)+"");w(this.pointBuffer,this.timestampBuffer,e);const t=this.pointBuffer.remove(e);return t.length>0?(this.version++,this.updateResults.recordData("remove",t.length)):this.updateResults.recordNoop("remove"),t}{const e=[];return this.pointData=this.pointData.filter(t=>!i.has(o(t)+"")||(e.push(t),!1)),e.length>0?(this.version++,this.updateResults.recordData("remove",e.length)):this.updateResults.recordNoop("remove"),e}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this.version++,this.updateResults.recordData("clear")}restyleScene(e){const t=this._customRestyle;if(t){for(const o of this.scene){const i=this._baseStyles.get(o)??o.style,s=t(o,e);o.style=s?{...i,...s}:i}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(e){const{config:t}=this,o=this.projection,i=this.geoPath,s=this.scales,r=this.baseScale,n=[...this.baseTranslate],a=[...this.baseRotation],c=this.scene;this.projection=function(e){if(!e)return Yo();if("string"==typeof e){const t=Zo[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),Yo())}if("object"==typeof e&&"type"in e){const t=Zo[e.type],o=t?t():Yo();return e.rotate&&"rotate"in o&&o.rotate(e.rotate),e.center&&"center"in o&&o.center(e.center),o}return e}(t.projection),this.geoPath=Io(this.projection),this.fitProjection(e),this.geoPath=Io(this.projection);const l=this.projection;this.scales={projection:l,geoPath:this.geoPath,projectedPoint:(e,t)=>l([e,t]),invertedPoint:(e,t)=>l.invert?l.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const h=this.buildSceneNodes(e);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=o,this.geoPath=i,this.scales=s,this.baseScale=r,this.baseTranslate=n,this.baseRotation=a):(this.scene=[],this.rebuildQuadtree());else{if(this.scene=h,this.rebuildQuadtree(),t.projectionTransform&&this.applyCartogramTransform(t.projectionTransform,e),t.decay&&this.streaming&&this.applyDecay(),t.pulse&&this.streaming&&this.applyPulse(),t.transition&&!this._hasRenderedOnce&&this.scene.length>0&&t.introAnimation){const t=e.width/2,o=e.height/2,i=this.scene.filter(e=>"point"===e.type).map(e=>({...e,x:t,y:o}));i.length>0&&this.startTransition(i)}this._hasRenderedOnce=!0,t.transition&&c.length>0&&this.startTransition(c),this.version++}}fitProjection(e){const t=this.projection,o=this.config,i=[...this.areas],s=Uo(o.xAccessor,"lon"),r=Uo(o.yAccessor,"lat"),n=this.getPoints();if(n.length>0){const e=n.map(e=>[s(e),r(e)]);i.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}const a=Ko(o.lineDataAccessor);for(const e of this.lineData){const t=a(e);if(t&&t.length>0){const e=t.map(e=>[s(e),r(e)]);i.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==i.length){if(o.projectionExtent){const[[i,s],[r,n]]=o.projectionExtent;t.fitExtent([[0,0],[e.width,e.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[i,s],[r,s],[r,n],[i,n],[i,s]]]}})}else if(t.clipAngle&&(t.clipAngle()??0)>0){const i=o.fitPadding??0,s=Math.min(e.width,e.height);t.scale(s/2-s*i),t.translate([e.width/2,e.height/2])}else{const s=o.fitPadding??0,r=e.width*s,n=e.height*s;t.fitExtent([[r,n],[e.width-r,e.height-n]],{type:"FeatureCollection",features:i})}this.baseScale=t.scale(),this.baseTranslate=t.translate(),this.baseRotation=t.rotate?.()??[0,0,0]}}applyZoomTransform(e,t){const o=this.projection;if(!o)return;const i=this.geoPath,s=this.scales,r=o.scale(),n=[...o.translate()],a=this.currentZoom;o.scale(this.baseScale*e.k),o.translate([this.baseTranslate[0]*e.k+e.x,this.baseTranslate[1]*e.k+e.y]),this.currentZoom=e.k,this.geoPath=Io(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(e,t)=>o([e,t]),invertedPoint:(e,t)=>o.invert?o.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(o.scale(r),o.translate(n),this.currentZoom=a,this.geoPath=i,this.scales=s):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyZoomScale(e,t){const o=this.projection;if(!o)return;const i=this.geoPath,s=this.scales,r=o.scale(),n=[...o.translate()],a=this.currentZoom;o.scale(this.baseScale*e),o.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=Io(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(e,t)=>o([e,t]),invertedPoint:(e,t)=>o.invert?o.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(o.scale(r),o.translate(n),this.currentZoom=a,this.geoPath=i,this.scales=s):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyRotation(e,t){const o=this.projection;if(!o||!o.rotate)return;const i=this.geoPath,s=this.scales,r=[...o.rotate()];o.rotate(e),this.geoPath=Io(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(e,t)=>o([e,t]),invertedPoint:(e,t)=>o.invert?o.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const n=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(o.rotate(r),this.geoPath=i,this.scales=s):(this.scene=[],this.rebuildQuadtree()):(this.scene=n,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}setRotation(e){const t=this.projection;t&&t.rotate&&t.rotate(e)}getRotation(){return this.projection?.rotate?.()??this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let t=0,o=0;for(const e of this.scene)"point"===e.type&&(o++,e.r>t&&(t=e.r));if(this._maxPointRadius=t,e.QUADTREE_THRESHOLD>=o)return void(this._quadtree=null);const i=Array(o);let s=0;for(const e of this.scene)"point"===e.type&&(i[s++]=e);this._quadtree=Go().x(e=>e.x).y(e=>e.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(e){this._customLayoutFailedThisBuild=!1;const{config:t}=this,o=this.projection,i=this.geoPath;if(t.customLayout&&this.scales){const o=t.layoutMargin??{top:0,right:0,bottom:0,left:0},i=le(t.colorScheme,t.themeCategorical,$),s={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:e.width,height:e.height,margin:o,plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:t.themeSemantic??{},categorical:[...i]},resolveColor:Y(i,t.colorScheme),config:t.layoutConfig??{},selection:t.layoutSelection??null};let r;try{r=t.customLayout(s)}catch(e){const o=null!==this.lastCustomLayoutResult,i=M("geo",e,o,this.version);this.lastCustomLayoutFailure=i,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] geo customLayout threw:",e);try{t.onLayoutError?.(i)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return o?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}const n=r.nodes??[];if(this.customLayoutOverlays=r.overlays??null,this.lastCustomLayoutResult=r,this.lastCustomLayoutFailure=null,this._customRestyle=r.restyle,this.hasCustomRestyle=!!r.restyle,this._baseStyles=new WeakMap,this.hasCustomRestyle){for(const e of n)this._baseStyles.set(e,e.style);this.restyleScene(t.layoutSelection??null)}return E({label:"geo customLayout",nodes:n,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),n}return this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,function({config:e,projection:t,path:o,areas:i,points:s,lines:r,layout:n}){const a=Uo(e.xAccessor,"lon"),c=Uo(e.yAccessor,"lat"),l=[],h=function(e){return{fill:e.themeSemantic?.surface||"#e0e0e0",stroke:e.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}(e),d=function(e){return{stroke:e.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}(e),u=function(e){return{fill:e.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(e);if(e.graticule){const t=!0===e.graticule?{}:e.graticule,i=xi();t.step&&i.step(t.step);const s=o(i())||"";s&&l.push({type:"geoarea",pathData:s,centroid:[n.width/2,n.height/2],bounds:[[0,0],[n.width,n.height]],screenArea:0,style:{fill:"none",stroke:t.stroke||"#e0e0e0",strokeWidth:t.strokeWidth||.5,strokeDasharray:t.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const t of i){const i=o(t);if(!i)continue;const s=o.centroid(t),r=o.bounds(t),n=o.area(t);l.push({type:"geoarea",pathData:i,centroid:s,bounds:r,screenArea:n,style:Jo(e.areaStyle,t,h),datum:t,interactive:!0})}const g=Ko(e.lineDataAccessor);for(const o of r){const i=g(o);if(!i||2>i.length)continue;let s=[];if("geo"===e.lineType){const e=Array(i.length);for(let t=0;i.length>t;t++)e[t]=[a(i[t]),c(i[t])];for(let o=0;e.length-1>o;o++){const i=e[o],r=e[o+1],n=mi(i,r)||0,a=Math.max(2,Math.ceil(n/(Math.PI/180))),c=bi(i,r);for(let e=0;a>=e;e++){if(o>0&&0===e)continue;const i=t(c(e/a));null!=i&&s.push(i)}}}else for(let e=0;i.length>e;e++){const o=i[e],r=t([a(o),c(o)]);null!=r&&s.push(r)}if(2>s.length)continue;const r=Jo(e.lineStyle,o,d),h="number"==typeof r.strokeWidth?r.strokeWidth:1;2!==i.length||2>s.length||"arc"!==e.flowStyle?2!==i.length||2>s.length||"offset"!==e.flowStyle||(s="geo"===e.lineType?oi(s,h):ii(s[0],s[s.length-1],0,0,h)):s=ti(s[0],s[s.length-1]);const u=ei(s,n.width);if(u.length>1)for(const e of u)2>e.length||l.push({type:"line",path:e,style:{...r,_edgeFade:!0},datum:o});else l.push({type:"line",path:2>s.length&&u[0]||s,style:r,datum:o})}const p=e.pointIdAccessor?"function"==typeof e.pointIdAccessor?e.pointIdAccessor:t=>t[e.pointIdAccessor]:null,f=t.clipAngle?t.clipAngle()??0:0,y=f>0?f*Math.PI/180:null,m=t.rotate?t.rotate():[0,0,0],x="function"==typeof t.center?t.center():[0,0],b=[(x[0]??0)-m[0],(x[1]??0)-m[1]];for(const o of s){const i=a(o),s=c(o);if(null!=y&&mi([i,s],b)>y)continue;const r=t([i,s]);if(!r)continue;const n=e.pointStyle?e.pointStyle(o):{...u},h={type:"point",x:r[0],y:r[1],r:n.r||4,style:n,datum:o,pointId:p?p(o)+"":void 0};l.push(h)}return l}({config:t,projection:o,path:i,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:e})}applyCartogramTransform(e,t){const o=function(e,t,o,i){const s=e.filter(e=>"point"===e.type);if(2>s.length)return null;const r=t.strength??1;if(0===r)return null;const n=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:e=>e.id,a="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],c=s.find(e=>e.datum&&n(e.datum)+""==t.center+"");if(!c)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`),null;const l=c.x,h=c.y,d=s.map(e=>e.datum?a(e.datum):NaN).filter(e=>isFinite(e)&&e>=0),u=Se(d,1),g=Math.min(o.width,o.height)/2,p=si().domain([0,u]).range([0,g]);i>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them.");for(let t=e.length-1;t>=0;t--){const o=e[t];"geoarea"===o.type&&o.interactive&&e.splice(t,1)}for(const e of s){if(e===c)continue;if(!e.datum)continue;const t=Math.atan2(e.y-h,e.x-l),o=Math.sqrt((e.x-l)**2+(e.y-h)**2),i=a(e.datum),s=o+((isFinite(i)?p(i):o)-o)*r;e.x=l+Math.cos(t)*s,e.y=h+Math.sin(t)*s}const f=o.width/2,y=o.height/2,m=f-c.x,x=y-c.y;if(Math.abs(m)>.5||Math.abs(x)>.5)for(const e of s)e.x+=m,e.y+=x;const b={cx:f,cy:y,maxCost:u,availableRadius:g},A=e.filter(e=>"line"===e.type);if(A.length>0&&"fractional"!==t.lineMode){const e=new Map;for(const t of s)t.pointId&&e.set(t.pointId,[t.x,t.y]);for(const t of A){const o=t.datum?.source,i=t.datum?.target;if(o&&i){const s=e.get(o+""),r=e.get(i+"");s&&r&&(t.path=[s,r])}}}return b}(this.scene,e,t,this.areas.length);o&&(this.cartogramLayout=o)}applyDecay(){const e=this.config.decay;if(!e||!this.pointBuffer)return;const t=this.pointBuffer.size;if(0===t)return;const o=this.scene.filter(e=>"point"===e.type);for(let i=0;o.length>i;i++){const s=k(e,i,t);o[i]._decayOpacity=s,o[i].style={...o[i].style,opacity:s}}}applyPulse(e=this.currentTime()){const t=this.config.pulse;if(!t||!this.timestampBuffer)return!1;const o=this.scene.filter(e=>"point"===e.type),i=this.timestampBuffer.toArray(),s=t.color||"rgba(255,255,255,0.6)",r=t.glowRadius??4;let n=!1;for(let a=0;o.length>a&&i.length>a;a++){const c=_(t,i[a],e);n=C(o[a],c,s,r)||n}return n}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(e)}hasActivePulsesAt(e){return!!this.config.pulse&&z(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}startTransition(e){const t=this.config.transition?.duration??300;if(0>=t)return;const o=new Map;for(const t of e)"point"===t.type&&t.pointId&&o.set(t.pointId,[t.x,t.y]);const i=this.scene.filter(e=>"point"===e.type);let s=!1;for(const e of i)if(e.pointId){const t=o.get(e.pointId);t&&(e._targetX=e.x,e._targetY=e.y,e.x=t[0],e.y=t[1],(Math.abs(t[0]-e._targetX)>.5||Math.abs(t[1]-e._targetY)>.5)&&(s=!0))}for(const e of i)e.pointId&&!o.has(e.pointId)&&(e._targetOpacity=e.style?.opacity??1,e.style={...e.style,opacity:0},s=!0);s&&(this.activeTransition={startTime:this.currentTime(),duration:t})}cancelIntroAnimation(){this.activeTransition=null}advanceTransition(e){if(!this.activeTransition)return!1;const t=X(e,this.activeTransition),o=H(t),i=this.scene.filter(e=>"point"===e.type);for(const e of i){if(null!=e._targetX&&null!=e._targetY){const t=e.y;e.x=oe(e.x,e._targetX,o),e.y=oe(t,e._targetY,o)}null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity*o})}if(t>=1){for(const e of i)null!=e._targetX&&(e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0),null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity},e._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}};vi.QUADTREE_THRESHOLD=500;var Si=vi;b(Si);import{Fragment as wi,jsxs as ki}from"react/jsx-runtime";function _i(e,t){const o=ft(e.theme),i=e.size||[e.width||600,e.height||400],s=ce({top:10,right:10,bottom:10,left:10,...e.margin},e.title),r=J(e.title),n=Array.isArray(e.areas)?Q(e.areas):e.areas,a=Q(e.points),c=Q(e.lines),l=e.showLegend?(()=>{const t="string"==typeof(o=e.colorBy)||"function"==typeof o?e.colorBy:void 0;var o;return Ft(a.length>0?a:Array.isArray(n)&&n.length>0?"string"==typeof t?n.map(e=>({...e.properties||{},...e})):n:[],t)})():[],h=e.legendPosition;te(e.legend)||ee(e.legend)?Ht(s,{legend:e.legend,theme:o,position:h||"right",size:i,hasTitle:r,legendLayout:e.legendLayout}):e.showLegend&&l.length>0&&Yt(s,{categories:l,colorScheme:e.colorScheme,theme:o,position:h||"right",size:i,hasTitle:r,legendLayout:e.legendLayout});const d=i[0]-(s.left??0)-(s.right??0),u=i[1]-(s.top??0)-(s.bottom??0),g={projection:e.projection||"equalEarth",xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineType:e.lineType,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform,customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:s,themeCategorical:o.colors.categorical,themeSemantic:ze(o)},p=new Si(g);if(n){if("string"==typeof n)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${n}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${n}')\` before calling renderGeoToStaticSVG.`);p.setAreas(n)}if(e.points&&p.setPoints(a),e.lines&&p.setLines(c),p.computeScene({width:d,height:u}),t&&(t.evidence=bt({frameType:"geo",width:i[0],height:i[1],marks:p.scene,title:e.title,description:e.description,annotations:e.annotations,legendItems:l.length>0?l.length:void 0})),0===p.scene.length){const t=e.backgroundGraphics||e.foregroundGraphics||e.annotations||p.customLayoutOverlays?ki(wi,{children:[e.backgroundGraphics,e.annotations?Wt({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{geoProjection:p.scales?.projectedPoint?([e,t])=>p.scales.projectedPoint(e,t):void 0},layout:{width:d,height:u},theme:o,idPrefix:e._idPrefix}):null,e.foregroundGraphics,p.customLayoutOverlays]}):null;return $o.renderToStaticMarkup(Qt(t,{width:i[0],height:i[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${s.left??0},${s.top??0})`,innerWidth:d,innerHeight:u,idPrefix:e._idPrefix}))}const f=p.scene.map((t,o)=>F({node:t,index:o,renderMode:e.renderMode,fallback:()=>Z(t,o)})).filter(Boolean),y=e.annotations?Wt({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{geoProjection:p.scales?.projectedPoint?([e,t])=>p.scales.projectedPoint(e,t):void 0},layout:{width:d,height:u},theme:o,idPrefix:e._idPrefix}):null,m=e.showLegend?0===l.length?null:Lt({categories:l,colorScheme:e.colorScheme,theme:o,position:e.legendPosition||"right",totalWidth:i[0],totalHeight:i[1],margin:s,hasTitle:r,legendLayout:e.legendLayout}):null,x=Wo.isValidElement(e.legend)?e.legend:Xt(e.legend,{theme:o,position:e.legendPosition||"right",size:i,margin:s,hasTitle:r,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||m;return $o.renderToStaticMarkup(Qt(ki(wi,{children:[e.backgroundGraphics,f,y,e.foregroundGraphics,p.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${s.left??0},${s.top??0})`,innerWidth:d,innerHeight:u,legend:x,idPrefix:e._idPrefix}))}function Mi(e,t){const o=e.size??[e.width??600,e.height??400],i=new m(e.config);Array.isArray(e.initialSpawns)&&e.initialSpawns.length>0&&i.enqueue(e.initialSpawns.map(e=>({...e,spawnAt:void 0})));const s=l(i,{...e,width:o[0],height:o[1],idPrefix:e.idPrefix??e._idPrefix??"physics"});return t&&(t.evidence=bt({frameType:"physics",width:o[0],height:o[1],marks:s.scene.sceneNodes,title:e.title,description:e.description,annotations:[],extraWarnings:0===s.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[]})),s.svg}import{Fragment as Ti,jsx as Pi,jsxs as Ri}from"react/jsx-runtime";function zi(e,t){switch(e){case"xy":return Jt(t);case"ordinal":return Fo(t);case"network":return No(t);case"geo":return _i(t);case"physics":return Mi(t);default:throw Error(`Unknown frame type: ${e}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function Li(e){return Jt(e)}function Fi(e){return Fo(e)}function Ci(e){return No(e)}function Bi(e){return _i(e)}var Di=["showAxes","axes","axisExtent","xLabel","yLabel","yLabelRight","categoryLabel","valueLabel","xFormat","yFormat","categoryFormat","valueFormat","tickFormatTime","tickFormatValue","xScaleType","yScaleType","xExtent","yExtent","rExtent","oExtent","extentPadding","scalePadding","sizeRange","curve","gradientFill","lineGradient","lineStyle","pointStyle","areaStyle","barStyle","waterfallStyle","swarmStyle","pieceStyle","summaryStyle","nodeStyle","edgeStyle","connectorStyle","backgroundGraphics","foregroundGraphics","svgPreRenderers","barColors","legend","legendLayout"];function Ei(e,t,o){return ji(e,t).svg}function Oi(e,t,o){const i={},{svg:s,frameType:r}=ji(e,t,0,i),n=i.evidence??bt({frameType:r,width:"number"==typeof t.width?t.width:600,height:"number"==typeof t.height?t.height:400,marks:[],title:"string"==typeof t.title?t.title:void 0,description:"string"==typeof t.description?t.description:void 0,annotations:t.annotations,extraWarnings:["NO_EVIDENCE"]});return n.component=e,{svg:s,evidence:n}}function ji(e,t,o,i){const{data:s,width:r=600,height:n=400,theme:a,title:c,description:l,showLegend:h,showGrid:d,background:u,className:g,annotations:p,margin:f,colorScheme:y,colorBy:m,legendPosition:x,...b}=t,A=[r,n],v={...b.frameProps||{},...function(e,t){const o={};for(const i of t)void 0!==e[i]&&(o[i]=e[i]);return o}(b,Di),theme:a,title:c,description:l,showLegend:h,showGrid:d,background:u,className:g,annotations:p,size:A,...void 0!==f&&{margin:f},...void 0!==y&&{colorScheme:y},...void 0!==x&&{legendPosition:x},_idPrefix:b._idPrefix},S=pt[e];if(!S)throw Error(`Unknown chart component: "${e}". See CLAUDE.md for supported chart types.`);const w=S.buildProps(s,m,y,v,b);let k;switch(S.frameType){case"xy":k=Jt(w,i);break;case"ordinal":k=Fo(w,i);break;case"network":k=No(w,i);break;case"geo":k=_i(w,i);break;case"physics":k=Mi(w,i)}if("GaugeChart"===e&&w.__gauge){const e=w.__gauge,t=v.margin||{top:20,right:20,bottom:30,left:40},o=(r||300)-t.left-t.right,i=(n||300)-t.top-t.bottom,s=Math.min(o,i)/2*.85,c=t.left+o/2,l=t.top+i/2,h=(e.startAngleDeg+(e.gMax===e.gMin?0:(Math.max(e.gMin,Math.min(e.gMax,e.value??e.gMin))-e.gMin)/(e.gMax-e.gMin))*e.sweep-90)*Math.PI/180,d=ft(a).colors.text,u=Le.renderToStaticMarkup(Ri(Ti,{children:[Pi("line",{x1:c,y1:l,x2:c+s*Math.cos(h),y2:l+s*Math.sin(h),stroke:d,strokeWidth:2.5,strokeLinecap:"round"}),Pi("circle",{cx:c,cy:l,r:4,fill:d})]}));k=k.replace("</svg>",u+"</svg>")}return{svg:k,frameType:S.frameType}}function Ni(e,t={}){const{title:o,subtitle:i,theme:s,width:r=1200,height:n,layout:a={},background:c}=t,l=yt(ft(s)),h=a.columns||2,d=a.gap??16;let u=0;o&&(u+=30),i&&(u+=20),u>0&&(u+=10);const g=Math.floor((r-d-d*(h-1))/h),p=[];let f=0,y=u+d,m=0;for(const t of e){const e=Math.min(t.colSpan||1,h),o=t.props.height||300;f+e>h&&(y+=m+d,f=0,m=0),p.push({chart:t,x:d/2+f*(g+d),y:y,w:g*e+d*(e-1),h:o}),m=Math.max(m,o),f+=e}const x=n||y+m+d,b=p.map((e,t)=>{const{chart:o,x:i,y:r,w:n,h:a}=e,c={...o.props,width:n,height:a,theme:s,_idPrefix:"chart-"+t};let l;return l=o.component?Ei(o.component,c):o.frameType?zi(o.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${a}"></svg>`,Pi("g",{transform:`translate(${i},${r})`,children:Pi("foreignObject",{width:n,height:a,children:Pi("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:l}})})},"dashboard-chart-"+t)});return Le.renderToStaticMarkup(Ri("svg",{xmlns:"http://www.w3.org/2000/svg",width:r,height:x,role:"img","aria-label":o||"Dashboard",style:{fontFamily:l.fontFamily},children:[o&&Pi("title",{children:o}),c&&Pi("rect",{x:0,y:0,width:r,height:x,fill:c}),o&&Pi("text",{x:r/2,y:24,textAnchor:"middle",fontSize:l.titleSize+4,fontWeight:"bold",fill:l.text,fontFamily:l.fontFamily,children:o}),i&&Pi("text",{x:r/2,y:o?46:20,textAnchor:"middle",fontSize:l.labelSize,fill:l.textSecondary,fontFamily:l.fontFamily,children:i}),b]}))}import*as Wi from"react-dom/server";import{Fragment as $i,jsx as Ii,jsxs as Gi}from"react/jsx-runtime";function Vi(e,t,o,i={}){const{stepSize:s,windowSize:r,frameCount:n,xExtent:a,yExtent:c,transitionFrames:l=4,fps:h=12,easing:d="ease-out",decay:u}=i,g=o.width||600,p=o.height||400,f=ft(o.theme),y={...o,...a&&{xExtent:a},...c&&{yExtent:c}};if(!t||0===t.length)return[];const m=s||Math.max(1,Math.ceil(t.length/(n||Math.min(60,Math.max(10,t.length))))),b=[];for(let e=m;t.length>=e;e+=m)b.push(e);b[b.length-1]!==t.length&&b.push(t.length);const A=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(e),v=ce({top:20,right:20,bottom:30,left:40,...o.margin},o.title),S=g-v.left-v.right,w=p-v.top-v.bottom,k=[];if(A)for(let i=0;b.length>i;i++){const s=b[i],n=t.slice(r?Math.max(0,s-r):0,s),a={chartType:e,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:o.projection||"vertical",oAccessor:o.oAccessor||o.categoryAccessor||"category",rAccessor:o.rAccessor||o.valueAccessor||"value",colorAccessor:o.colorAccessor||o.colorBy,stackBy:o.stackBy,groupBy:o.groupBy,barPadding:o.barPadding,innerRadius:o.innerRadius,normalize:o.normalize,bins:o.bins,colorScheme:o.colorScheme||f.colors.categorical,...u&&{decay:u}},c=new Mo(a);c.ingest({inserts:n,bounded:!0}),c.computeScene({width:S,height:w}),c.scene.length>0&&k.push(Zi(c.scene,g,p,f,y))}else for(let i=0;b.length>i;i++){const s=b[i],n=t.slice(r?Math.max(0,s-r):0,s),m={chartType:e,windowSize:n.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:o.colorAccessor||o.colorBy,groupAccessor:o.groupAccessor||o.lineBy,lineDataAccessor:o.lineDataAccessor,xExtent:a,yExtent:c,colorScheme:o.colorScheme||f.colors.categorical,lineStyle:o.lineStyle,pointStyle:o.pointStyle,areaStyle:o.areaStyle,sizeAccessor:o.sizeAccessor||o.sizeBy,sizeRange:o.sizeRange,...u&&{decay:u},...l>0&&{transition:{duration:l*(1e3/h),easing:d}}},A=new x(m);if(A.ingest({inserts:n,bounded:!0}),A.computeScene({width:S,height:w}),0===A.scene.length)continue;const v=A.scales?{y:A.scales.y}:void 0;if(k.push(Qi(A.scene,g,p,f,y,v)),l>0&&i>0&&A.activeTransition){const e=l*(1e3/h);for(let t=1;l>=t;t++)A.advanceTransition(A.activeTransition.startTime+t/l*e),k.push(Qi(A.scene,g,p,f,y,v))}}return k}function Yi(e,t,o={}){return t.map(t=>{try{return Ei(e,{...o,...t})}catch{return`<svg xmlns="http://www.w3.org/2000/svg" width="${o.width||t.width||600}" height="${o.height||t.height||400}"></svg>`}})}function Hi(e,t,o){const i=t.size??[t.width??600,t.height??400],s=ft(t.theme),r=yt(s),n=t.background||s.colors.background,a=t.idPrefix??"physics-gif",l=t.title?`${a}-title-${o}`:void 0,h=t.description?`${a}-desc-${o}`:void 0,d=[l,h].filter(Boolean).join(" ")||void 0,u=c(e.readBodies(),{bodyStyle:t.bodyStyle,getBodyLabel:t.getBodyLabel}),g=Gi("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className??"stream-physics-frame",width:i[0],height:i[1],viewBox:`0 0 ${i[0]} ${i[1]}`,role:"img","aria-labelledby":d,style:{fontFamily:r.fontFamily},children:[t.title&&Ii("title",{id:l,children:t.title}),t.description&&Ii("desc",{id:h,children:t.description}),n&&"transparent"!==n?Ii("rect",{x:0,y:0,width:i[0],height:i[1],fill:n}):null,Ii("g",{id:`${a}-frame-${o}`,children:u.map((e,t)=>de(e,t,`${a}-${o}`))})]});return Wi.renderToStaticMarkup(g)}function Xi(e,t={}){const{fps:o=12,frameCount:i,durationSeconds:s=2,includeInitialFrame:r=!0,stepDt:n,stepsPerFrame:a,background:c}=t,l=Math.max(.001,n??e.config?.fixedDt??1/120),h=a??Math.max(1,Math.round(1/Math.max(1,o)/l)),d=i??Math.max(1,Math.ceil(s*Math.max(1,o))),u=c?{...e,background:c}:e,g=new m(e.config);e.initialSpawns?.length&&g.enqueue(e.initialSpawns,e.initialSpawnPacing);const p=[];for(r&&(g.tick(0),p.push(Hi(g,u,0)));d>p.length;){for(let e=0;h>e;e+=1)g.tick(l);p.push(Hi(g,u,p.length))}return p}function qi(e,t){const o=e.background||t.colors.background;return o&&"transparent"!==o?o:null}function Qi(e,t,o,i,s,r){const n=yt(i),a=ce({top:20,right:20,bottom:30,left:40,...s.margin},s.title),c=t-a.left-a.right,l=o-a.top-a.bottom,h=qi(s,i),d=s.renderMode,u=e.map((e,t)=>F({node:e,index:t,renderMode:d,fallback:()=>de(e,t)})).filter(Boolean),g=function(e,t,o,i,s,r){if(!e||0===e.length)return null;const n=yt(i),a=[];for(let i=0;e.length>i;i++){const c=e[i];if("y-threshold"===c.type&&null!=c.value){let e=null;if(r)e=r(c.value);else if(s){const[t,i]=s,r=i-t;if(0===r)continue;e=o-(c.value-t)/r*o}if(null==e)continue;const l=c.color||n.primary,h=c.labelPosition||"right";a.push(Gi("g",{children:[Ii("line",{x1:0,y1:e,x2:t,y2:e,stroke:l,strokeWidth:c.strokeWidth??1.5,strokeDasharray:c.strokeDasharray||"6,4"}),c.label&&Ii("text",{x:"left"===h?4:"center"===h?t/2:t-4,y:20>e?Math.min(o-4,e+16):e-5,textAnchor:"left"===h?"start":"center"===h?"middle":"end",fontSize:n.tickSize,fill:l,fontFamily:n.fontFamily,children:c.label})]},"ann-"+i))}}return a.length>0?Ii($i,{children:a}):null}(s.annotations,c,l,i,s.yExtent,r?.y),p="string"==typeof s.title?s.title:void 0,f="string"==typeof s.description?s.description:void 0,y=p?"semiotic-title":void 0,m=f?"semiotic-desc":void 0,x=[y,m].filter(Boolean).join(" ")||void 0;return Wi.renderToStaticMarkup(Gi("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:o,role:"img","aria-labelledby":x,style:{fontFamily:n.fontFamily},children:[p&&Ii("title",{id:y,children:p}),f&&Ii("desc",{id:m,children:f}),h&&Ii("rect",{x:0,y:0,width:t,height:o,fill:h}),Gi("g",{transform:`translate(${a.left},${a.top})`,children:[g,u]}),p&&Ii("text",{x:t/2,y:G,textAnchor:"middle",fontSize:n.titleSize,fontWeight:"bold",fill:n.text,fontFamily:n.fontFamily,children:p})]}))}function Zi(e,t,o,i,s){const r=yt(i),n=ce({top:20,right:20,bottom:30,left:40,...s.margin},s.title),a="radial"===s.projection,c=a?n.left+(t-n.left-n.right)/2:n.left,l=a?n.top+(o-n.top-n.bottom)/2:n.top,h=qi(s,i),d=s.renderMode,u=e.map((e,t)=>F({node:e,index:t,renderMode:d,fallback:()=>ae(e,t)})).filter(Boolean),g="string"==typeof s.title?s.title:void 0,p="string"==typeof s.description?s.description:void 0,f=g?"semiotic-title":void 0,y=p?"semiotic-desc":void 0,m=[f,y].filter(Boolean).join(" ")||void 0;return Wi.renderToStaticMarkup(Gi("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:o,role:"img","aria-labelledby":m,style:{fontFamily:r.fontFamily},children:[g&&Ii("title",{id:f,children:g}),p&&Ii("desc",{id:y,children:p}),h&&Ii("rect",{x:0,y:0,width:t,height:o,fill:h}),Ii("g",{transform:`translate(${c},${l})`,children:u}),g&&Ii("text",{x:t/2,y:G,textAnchor:"middle",fontSize:r.titleSize,fontWeight:"bold",fill:r.text,fontFamily:r.fontFamily,children:g})]}))}export{Vi as generateFrameSVGs,Yi as generateFrameSequence,Xi as generatePhysicsFrameSVGs,Ei as renderChart,Oi as renderChartWithEvidence,Ni as renderDashboard,Bi as renderGeoToStaticSVG,Ci as renderNetworkToStaticSVG,Fi as renderOrdinalToStaticSVG,zi as renderToStaticSVG,Li as renderXYToStaticSVG,ft as resolveTheme,yt as themeStyles};
1
+ import{computeArcBoundingBox as e,sweepToAngles as t}from"./chunk-chunk-ANYDWOZF.module.min.js";import{buildCollisionSwarmPhysics as o,buildEventDropPhysics as i,buildGaltonBoardPhysics as s,buildPhysicalFlowPhysics as r,buildPhysicsPile as n,buildProcessFlowPhysics as a,generateGaltonMechanicalSamples as c,generatePhysicsPileMechanicalSamples as l,physicsBodiesToXYSceneNodes as h,renderPhysicsSettledSVG as d,resolveCustomLayout as u,styleFromColorAccessor as g}from"./chunk-chunk-N72SWNBV.module.min.js";import{composeStyleRules as p,makeNodeRuleContext as f,makeRuleValueResolver as y,makeXYRuleContext as m,resolveStyleRules as x,styleRulesToNodeStyle as b,styleRulesToXYStyle as v}from"./chunk-chunk-IP2UE74X.module.min.js";import{PhysicsPipelineStore as A}from"./chunk-chunk-UHSZEB74.module.min.js";import"./chunk-chunk-SIRIJ3DY.module.min.js";import{PipelineStore as w,attachUpdateResultStore as S,buildDatumIndexMap as k,buildRectNode as _,buildRibbonGeometry as M,compactTimestampBufferForRemoval as P,computeDecayOpacity as T,computePulseIntensity as R,createCustomLayoutFailureDiagnostic as L,createTimestampBufferForData as z,ensureRingBufferCapacity as C,getLayoutPlugin as F,hasActivePulses as B,pushWithTimestamp as O,renderSceneListWithBackend as E,renderSceneWithBackend as j,resolveDownwardHistogramExtent as D,setPulseState as N,ticksForMode as W,toIdSet as $,warnCustomLayoutDiagnostics as I}from"./chunk-chunk-GWSWSPXN.module.min.js";import{IncrementalExtent as G,RingBuffer as Y}from"./chunk-chunk-VVCA3DB7.module.min.js";import"./chunk-chunk-5APBQXZA.module.min.js";import{AnnotationLabel as V,DEFAULT_COLOR as X,DEFAULT_LEGEND_ROW_HEIGHT as H,STREAMING_PALETTE as q,SemioticAnnotation as Q,TITLE_BASELINE as Z,applyAnnotationEmphasis as U,buildResolveColor as K,composeLegendConfigs as J,computeEasing as ee,computeRawProgress as te,createColorScale as oe,filterSparseArray as ie,geoSceneNodeToSVG as se,getColor as re,getSize as ne,hasTextTitle as ae,isChartMode as ce,isGradientLegendConfig as le,isLegendConfig as he,layoutVerticalLegendGroups as de,lerp as ue,networkLabelToSVG as ge,networkSceneEdgeToSVG as pe,networkSceneNodeToSVG as fe,now as ye,ordinalSceneNodeToSVG as me,reserveTitleMargin as xe,resolveCategoricalPalette as be,resolveChartMode as ve,resolveCustomLayoutPalette as Ae,resolveDefaultFill as we,resolveExplicitColor as Se,resolveLegendMetrics as ke,xySceneNodeToSVG as _e}from"./chunk-chunk-F25UA5HT.module.min.js";import"./chunk-chunk-XEVJDUTH.module.min.js";import{accessorsEquivalent as Me,resolveAccessor as Pe,resolveStringAccessor as Te,resolveSvgFill as Re}from"./chunk-chunk-2WVCH4PL.module.min.js";import{SYMBOL_SEQUENCE as Le,UpdateResultTracker as ze,annotationLayout as Ce,getSequentialInterpolator as Fe,interpolateBrBG as Be,interpolatePRGn as Oe,interpolatePiYG as Ee,interpolateRdBu as je,interpolateRdYlBu as De,interpolateRdYlGn as Ne,interpolateSpectral as We,interpolateViridis as $e,schemeCategory10 as Ie}from"./chunk-chunk-5RKXZQ2P.module.min.js";import"./chunk-chunk-U66USBWU.module.min.js";import{getMax as Ge,getMin as Ye,getMinMax as Ve}from"./chunk-chunk-JJ2OOIET.module.min.js";import"./chunk-chunk-QRIBHZYW.module.min.js";import"./chunk-chunk-J3QOW4OE.module.min.js";import{DARK_THEME as Xe,HIGH_CONTRAST_THEME as He,LIGHT_THEME as qe,THEME_PRESETS as Qe,applyThemeAccessibility as Ze,resolveThemeSemanticColors as Ue}from"./chunk-chunk-DSNGDNJY.module.min.js";import*as Ke from"react-dom/server";import*as Je from"react";function et(e,t,o){return"function"==typeof e?e(o):o[e||t]}function tt(e){return e instanceof Date?e.getTime():Number(e)}function ot(e,t){return $e(1===t?.5:e/(t-1))}function it(e){if(!e)return qe;if("string"==typeof e){if("light"===e)return qe;if("dark"===e)return Xe;if("high-contrast"===e)return He;return Qe[e]||qe}const t="dark"===e.mode?Xe:qe,o={...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}},tooltip:{...t.tooltip,...e.tooltip||{}}};return Ze(o)}function st(e){return{background:e.colors.background,text:e.colors.text,textSecondary:e.colors.textSecondary,grid:e.colors.grid,border:e.colors.border,primary:e.colors.primary,fontFamily:e.typography.fontFamily,titleSize:e.typography.titleSize,labelSize:e.typography.labelSize,tickSize:e.typography.tickSize,categorical:e.colors.categorical,annotation:e.colors.annotation??e.colors.text,legendSize:e.typography.legendSize??e.typography.labelSize,titleFontSize:e.typography.titleFontSize??e.typography.titleSize,tickFontFamily:e.typography.tickFontFamily??e.typography.fontFamily}}function rt(e,t,o,i,s){const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=it(i.theme).colors.categorical,a=o??i.colorScheme??n,c="string"==typeof t?t:"__ssrLineColorBy",l="function"==typeof t?r.map(e=>({...e,__ssrLineColorBy:t(e)})):r,h=t?oe(l,c,a):void 0,d=m(s.xAccessor,s.yAccessor),u=function(e){const{lineWidth:t=2,colorBy:o,colorScale:i,color:s,resolveStroke:r,fillArea:n,areaOpacity:a=.3,styleRules:c,ruleContext:l}=e;return(e,h)=>{const d={strokeWidth:t},u=!0===n||Array.isArray(n)&&null!=h&&n.includes(h);let g;return r?g=r(e,h):o?i&&(g=re(e,o,i)):g=s||X,void 0!==g&&(d.stroke=g,u&&(d.fill=g,d.fillOpacity=a)),c?.length&&Object.assign(d,x(e,c,l?l(e,h):{value:void 0,category:h})),d}}({lineWidth:"number"==typeof s.lineWidth?s.lineWidth:2,colorBy:t,colorScale:h,color:"string"==typeof s.color?s.color:void 0,fillArea:s.fillArea,areaOpacity:"number"==typeof s.areaOpacity?s.areaOpacity:.3,styleRules:s.styleRules,ruleContext:d});return function(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return e??((...e)=>({}));const o={};return void 0!==t.stroke&&(o.stroke=t.stroke),void 0!==t.strokeWidth&&(o.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(o.opacity=t.opacity),e?(...t)=>({...e(...t)||{},...o}):(...e)=>({...o})}(u,{stroke:"string"==typeof s.stroke?s.stroke:void 0,strokeWidth:"number"==typeof s.strokeWidth?s.strokeWidth:void 0,opacity:"number"==typeof s.opacity?s.opacity:void 0})}function nt(e,t,o,i,s){const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=it(i.theme).colors.categorical,a=o??i.colorScheme??n,c="string"==typeof t?t:"__ssrAreaColorBy",l="function"==typeof t?r.map(e=>({...e,__ssrAreaColorBy:t(e)})):r,h=t?oe(l,c,a):void 0,d=!1!==s.showLine,u="number"==typeof s.lineWidth?s.lineWidth:2,g="number"==typeof s.areaOpacity?s.areaOpacity:.7,p=y(s.yAccessor),f=s.styleRules;return(e,o)=>{const i=t&&h?re(e,t,h):"string"==typeof s.color?s.color:X,r={fill:i,fillOpacity:g,stroke:d?i:"none",...d&&{strokeWidth:u}};return f?.length&&Object.assign(r,x(e,f,{value:p(e),category:o})),void 0!==s.stroke&&(r.stroke=s.stroke),void 0!==s.strokeWidth&&(r.strokeWidth=s.strokeWidth),void 0!==s.opacity&&(r.opacity=s.opacity),r}}function at(e,t,o,i,s){const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=it(i.theme).colors.categorical,a=o??i.colorScheme??n,c="string"==typeof t?t:"__ssrBubbleColorBy",l="function"==typeof t?r.map(e=>({...e,__ssrBubbleColorBy:t(e)})):r,h=t?oe(l,c,a):void 0,d=s.sizeBy,u=Array.isArray(s.sizeRange)?s.sizeRange:[5,40],g=d?r.map(e=>"function"==typeof d?d(e):Number(e[d])).filter(Number.isFinite):[],p=g.length?Ve(g):void 0;return e=>({fill:t&&h?re(e,t,h):"string"==typeof s.color?s.color:X,fillOpacity:"number"==typeof s.bubbleOpacity?s.bubbleOpacity:.6,r:d?ne(e,d,u,p):u[0],stroke:s.stroke??s.bubbleStrokeColor??"white",strokeWidth:s.strokeWidth??s.bubbleStrokeWidth??1,...void 0!==s.opacity&&{opacity:s.opacity}})}function ct(e,t,o,i,s){const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=it(i.theme).colors.categorical,a=o??i.colorScheme??n,c="string"==typeof t?t:"__ssrScatterColorBy",l="function"==typeof t?r.map(e=>({...e,__ssrScatterColorBy:t(e)})):r,h=t?oe(l,c,a):void 0,d=s.sizeBy,u=Array.isArray(s.sizeRange)?s.sizeRange:[3,15],g=d?r.map(e=>"function"==typeof d?d(e):Number(e[d])).filter(Number.isFinite):[],p=g.length?Ve(g):void 0,f=m(s.xAccessor,s.yAccessor),y=s.styleRules;return e=>{const o={fill:t&&h?re(e,t,h):"string"==typeof s.color?s.color:X,fillOpacity:"number"==typeof s.pointOpacity?s.pointOpacity:.8,r:d?ne(e,d,u,p):"number"==typeof s.pointRadius?s.pointRadius:5};return y?.length&&Object.assign(o,x(e,y,f(e))),void 0!==s.stroke&&(o.stroke=s.stroke),void 0!==s.strokeWidth&&(o.strokeWidth=s.strokeWidth),void 0!==s.opacity&&(o.opacity=s.opacity),o}}function lt(e){return Math.max(0,Math.min(1,e))}function ht(e){const t=e.trim();if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e.split("").map(e=>e+e).join("")),6===e.length&&/^[0-9a-f]{6}$/i.test(e))return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const o=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(o){const e=[Number(o[1]),Number(o[2]),Number(o[3])];if(e.every(Number.isFinite))return e}return null}function dt(e,t,o){const i=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return`#${i(e)}${i(t)}${i(o)}`}function ut(e,t){const o=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:lt(e.offset),color:e.color})).sort((e,t)=>e.offset-t.offset);if(0===o.length)return"#999999";if(1===o.length)return o[0].color;const i=lt(t);if(o[0].offset>=i)return o[0].color;if(i>=o[o.length-1].offset)return o[o.length-1].color;for(let e=0;o.length-1>e;e++){const t=o[e],s=o[e+1];if(t.offset>i||i>s.offset)continue;const r=s.offset-t.offset,n=r>0?(i-t.offset)/r:0,a=ht(t.color),c=ht(s.color);if(!a||!c)return.5>n?t.color:s.color;const[l,h,d]=a,[u,g,p]=c;return dt(l+(u-l)*n,h+(g-h)*n,d+(p-d)*n)}return o[o.length-1].color}function gt(e,t,o){return null==o?`${e}-${t}`:`${e}-${t}-${o}`}import{Fragment as pt,jsx as ft,jsxs as yt}from"react/jsx-runtime";import{useMemo as mt,useCallback as xt,useRef as bt}from"react";var vt={RdBu:je,PiYG:Ee,PRGn:Oe,BrBG:Be,RdYlBu:De,RdYlGn:Ne,Spectral:We},At="__likert_neutral_neg",wt="__likert_neutral_pos";function St(e,t){if("function"==typeof e)return e;const o=e||t;return e=>e[o]}import*as kt from"react";function _t(e){return!0===e?{topOpacity:.8,bottomOpacity:.05}:!1===e?void 0:e}function Mt(e,t,o,i,s){const r=it(i.theme).colors.categorical,n=o??i.colorScheme,a=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],c="string"==typeof t?t:"__ssrColorBy",l="function"==typeof t?a.map(e=>({...e,__ssrColorBy:t(e)})):a,h=t?oe(l,c,n??r):void 0,d=we("string"==typeof s.color?s.color:void 0,r,n,void 0,new Map),u=y(s.valueAccessor),g=s.styleRules,p=i.pieceStyle;return(e,o)=>{const i={fill:t&&h?re(e,t,h):d};return g?.length&&Object.assign(i,x(e,g,{value:u(e),category:o})),"function"==typeof p?Object.assign(i,p(e,o)||{}):p&&"object"==typeof p&&Object.assign(i,p),void 0!==s.stroke&&(i.stroke=s.stroke),void 0!==s.strokeWidth&&(i.strokeWidth=s.strokeWidth),void 0!==s.opacity&&(i.opacity=s.opacity),i}}function Pt(e,t,o,i,s){const r=Mt(e,t,o,i,s);return(e,t)=>{const o=r(e,t);return void 0===o.fillOpacity&&(o.fillOpacity=.8),void 0===o.stroke&&(o.stroke=o.fill),o}}function Tt(e,t,o,i,s){const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n="string"==typeof t?t:"__ssrViolinColorBy",a="function"==typeof t?r.map(e=>({...e,__ssrViolinColorBy:t(e)})):r,c=it(i.theme).colors.categorical,l=o??i.colorScheme,h=t?oe(a,n,l??c):void 0,d=we("string"==typeof s.color?s.color:void 0,c,l,void 0,new Map);return e=>{const o=t&&h?re(e,t,h):d;return{fill:o,fillOpacity:.6,stroke:s.stroke??o,...void 0!==s.strokeWidth&&{strokeWidth:s.strokeWidth},...void 0!==s.opacity&&{opacity:s.opacity}}}}function Rt(e,t,o,i,s){const r=Mt(e,t,o,i,s),n="number"==typeof s.dotRadius?s.dotRadius:5;return(e,t)=>({r:n,fillOpacity:.8,...r(e,t)})}function Lt(e,t,o,i,s){const r=Mt(e,t,o,i,s),n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=s.sizeBy,c=Array.isArray(s.sizeRange)?s.sizeRange:[3,8],l=a?n.map(e=>"function"==typeof a?a(e):Number(e[a])).filter(Number.isFinite):[],h=l.length?Ve(l):void 0,d="number"==typeof s.pointRadius?s.pointRadius:4,u="number"==typeof s.pointOpacity?s.pointOpacity:.7;return(e,t)=>({r:a?ne(e,a,c,h):d,fillOpacity:u,...r(e,t)})}import{scaleTime as zt}from"d3-scale";function Ct(e){return"invalid-node-time"===e.kind?`node ${e.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===e.kind?`edge ${e.id} has an invalid startTime or endTime`:"invalid-domain"===e.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===e.kind?`edge ${e.id} must have a positive finite value`:"missing-node"===e.kind?`edge ${e.id} references missing ${e.endpoint} node "${e.nodeId}"`:"backward-edge"===e.kind?`edge ${e.id} (${e.source}->${e.target}) ends before it starts`:e.kind}function Ft(e,t,o){const i=t.incoming[e.id],s=t.outgoing[e.id],r=[];for(const e of i)r.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:o.get(e.id).targetSide});for(const e of s)r.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:o.get(e.id).sourceSide});const n={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{r.sort((e,t)=>e.time-t.time||(n[e.kind]??99)-(n[t.kind]??99))},c=r.length?Ye(r.map(e=>e.time)):null,l=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,h=null!=l?l-1:null!=c&&Number.isFinite(c)?c-1:null,d=[...new Set(r.map(e=>e.time))].sort((e,t)=>e-t),u=new Map;for(let e=1;d.length>e;e++)u.set(d[e],d[e-1]);const g=e=>{const t=u.get(e);return null!=t?(t+e)/2:null!=h?h:e};a();const p=[];let f=0,y=0;for(const e of r)if("out"===e.kind){const t=Math.abs(e.delta);let o=t-("top"===e.side?f:y);if(o>0){const t="top"===e.side?"bot":"top",i=Math.min(o,"top"===t?f:y);if(i>0){const s=g(e.time);p.push({time:s,delta:-i,kind:"transfer-out",side:t}),p.push({time:s,delta:+i,kind:"transfer-in",side:e.side}),"top"===t?f-=i:y-=i,"top"===e.side?f+=i:y+=i,o-=i}o>0&&null!==h&&(p.push({time:h,delta:+o,kind:"create",side:e.side}),"top"===e.side?f+=o:y+=o)}"top"===e.side?f-=t:y-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?f+=t:y+=t}r.push(...p),a();let m=0,x=0,b=0,v=0,A=0;const w=[],S=new Map;for(const e of r){if(w.push({t:e.time,topMass:m,botMass:x}),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?m:x;S.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta)})}"top"===e.side?m+=e.delta:x+=e.delta,m+x>b&&(b=m+x),m>v&&(v=m),x>A&&(A=x),w.push({t:e.time,topMass:m,botMass:x})}const k=[];let _=0;for(;w.length>_;){let e=_;for(;w.length>e+1&&w[e+1].t===w[_].t;)e++;k.push(w[_]);for(let t=_+1;e>=t;t++){const e=k[k.length-1];w[t].topMass===e.topMass&&w[t].botMass===e.botMass||k.push(w[t])}_=e+1}const M=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let P=null;for(const e of s)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===P||P>e.systemInTime)&&(P=e.systemInTime);let T=null;for(const e of i)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===T||e.systemOutTime>T)&&(T=e.systemOutTime);if(k.length>0){const e=k[k.length-1],t=Math.max(null!=M?M:-1/0,null!=T?T:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&k.push({t:t,topMass:e.topMass,botMass:e.botMass});const o=k[0],i=Math.min(null!=l?l:1/0,null!=P?P:1/0);Number.isFinite(i)&&o.t>i&&o.topMass+o.botMass>0&&k.unshift({t:i,topMass:o.topMass,botMass:o.botMass})}return{samples:k,peak:b,topPeak:v,botPeak:A,localAttachments:S}}function Bt(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Ot(e,t){return e.map(e=>({t:Bt(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function Et(e,t,o){const i=e.value*o;if("out"===e.kind){const s=e.sideMassBefore*o;if("top"===e.side){const e=t-s;return[e,e+i]}const r=t+s;return[r-i,r]}const s=e.sideMassAfter*o;if("top"===e.side){const e=t-s;return[e,e+i]}const r=t+s;return[r-i,r]}function jt(e,t){let o=0;for(let i=0;t.length>i;i++)for(let s=i+1;t.length>s;s++){const r=t[i],n=t[s];r.source!==n.source&&r.target!==n.target&&r.source!==n.target&&r.target!==n.source&&(Math.min(r.endTime,n.endTime)>Math.max(r.startTime,n.startTime)&&e[n.source]>e[r.source]!=e[n.target]>e[r.target]&&o++)}return o}function Dt(e,t){let o=0;for(const i of t)o+=Math.abs(e[i.source]-e[i.target])*(i.value||1);return o}function Nt(e,t){return 1e3*jt(e,t)+Dt(e,t)}function Wt(e,t){return{slots:e.map(e=>({peak:{...e.peak},occupants:e.occupants.slice()})),map:{...t}}}function $t(e,t,o){e.length>8||o.length>40?(function(e,t,o,i=6){const s=e.length;if(1>=s)return;let r=Wt(e,t),n=Nt(t,o);for(let a=0;i>a;a++){const i=Array(s).fill(0),a=Array(s).fill(0);for(const e of o){const o=t[e.source],s=t[e.target];i[o]+=s*(e.value||1),a[o]+=e.value||1,i[s]+=o*(e.value||1),a[s]+=e.value||1}const c=Array.from({length:s},(e,t)=>t).sort((e,t)=>(a[e]>0?i[e]/a[e]:e)-(a[t]>0?i[t]/a[t]:t)),l=c.map(t=>e[t]),h=new Map;c.forEach((e,t)=>h.set(e,t));for(const e of Object.keys(t))t[e]=h.get(t[e]);e.length=0;for(const t of l)e.push(t);const d=Nt(t,o);if(n>d)n=d,r=Wt(e,t);else if(d===n)break}!function(e,t,o){e.length=0;for(const t of o.slots)e.push(t);for(const e of Object.keys(t))delete t[e];for(const e of Object.keys(o.map))t[e]=o.map[e]}(e,t,r)}(e,t,o,6),function(e,t,o,i=6){const s=e.length;if(1>=s)return;let r=Nt(t,o);for(let n=0;i>n;n++){let i=!1;for(let n=0;s-1>n;n++){const s=e[n];e[n]=e[n+1],e[n+1]=s;for(const e of Object.keys(t))t[e]===n?t[e]=n+1:t[e]===n+1&&(t[e]=n);const a=Nt(t,o);if(r>a)r=a,i=!0;else{const o=e[n];e[n]=e[n+1],e[n+1]=o;for(const e of Object.keys(t))t[e]===n?t[e]=n+1:t[e]===n+1&&(t[e]=n)}}if(!i)break}}(e,t,o,6)):function(e,t,o){const i=e.length;if(1>=i)return;const s={...t},r=Object.keys(s),n=Array.from({length:i},(e,t)=>t),a=n.slice(),c={...s};let l=n.slice(),h=1/0;const d=()=>{for(const e of r)c[e]=a[s[e]];const e=Nt(c,o);h>e&&(h=e,l=n.slice())},u=(e,t)=>{const o=n[e],i=n[t];n[e]=i,n[t]=o,a[o]=t,a[i]=e};d();const g=Array(i).fill(0);let p=0;for(;i>p;)p>g[p]?(u(p%2==0?0:g[p],p),d(),g[p]++,p=0):(g[p]=0,p++);const f=l.map(t=>e[t]),y=new Map;l.forEach((e,t)=>y.set(e,t));for(const e of Object.keys(t))t[e]=y.get(t[e]);e.length=0;for(const t of f)e.push(t)}(e,t,o)}function It(e,t,o,i,s){const{plotH:r,padding:n,valueScale:a,packing:c,laneOrder:l,lifetimeMode:h="full"}=s,d={},u={};for(const t of e)d[t.id]=o[t.id].topPeak||0,u[t.id]=o[t.id].botPeak||0;const g="half"===h,p={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,o=Array.isArray(t.xExtent)?t.xExtent[1]:null;let s=null!=e&&Number.isFinite(e)?e:1/0,r=null!=o&&Number.isFinite(o)?o:-1/0;for(const e of i.outgoing[t.id]){s>e.startTime&&(s=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&s>e.systemInTime&&(s=e.systemInTime);const t=g?(e.startTime+e.endTime)/2:e.endTime;t>r&&(r=t)}for(const e of i.incoming[t.id]){const t=g?(e.startTime+e.endTime)/2:e.startTime;s>t&&(s=t),e.endTime>r&&(r=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>r&&(r=e.systemOutTime)}p[t.id]={start:Number.isFinite(s)?s:null,end:Number.isFinite(r)?r:null}}const f={},y=[];if("reuse"===c){const o=new Map;for(const t of e)o.set(t.id,0);const s=new Map;for(const t of e)s.set(t.id,0);for(const e of t)s.set(e.target,(s.get(e.target)??0)+1);const r=[];for(const t of e)0===(s.get(t.id)??0)&&r.push(t.id);for(;r.length;){const e=r.shift();for(const t of i.outgoing[e]??[]){const i=(o.get(e)??0)+1;i>(o.get(t.target)??0)&&o.set(t.target,i),s.set(t.target,s.get(t.target)-1),0===s.get(t.target)&&r.push(t.target)}}const n=[...e].filter(e=>null!==p[e.id].start).sort((e,t)=>{const i=o.get(e.id)??0,s=o.get(t.id)??0;return i!==s?i-s:p[e.id].start-p[t.id].start}),a=e.filter(e=>null===p[e.id].start);for(const e of[...n,...a]){const t=p[e.id];let o=-1;for(let e=0;y.length>e;e++){const i=y[e].occupants[y[e].occupants.length-1];if(null===t.start||void 0===i||t.start>=i.end){o=e;break}}-1===o&&(y.push({occupants:[],peak:{topPeak:0,botPeak:0}}),o=y.length-1),y[o].occupants.push({id:e.id,end:t?.end??-1/0}),y[o].peak.topPeak=Math.max(y[o].peak.topPeak,d[e.id]),y[o].peak.botPeak=Math.max(y[o].peak.botPeak,u[e.id]),f[e.id]=o}}else e.forEach((e,t)=>{y.push({occupants:[{id:e.id,end:p[e.id]?.end??-1/0}],peak:{topPeak:d[e.id],botPeak:u[e.id]}}),f[e.id]=t});let m=null,x=null,b=null,v=null;const A=()=>{m=jt(f,t),b=Dt(f,t)},w=()=>{x=jt(f,t),v=Dt(f,t)};"crossing-min"===l?(A(),$t(y,f,t),w()):"inside-out"===l?(A(),function(e,t){const o=e.length;if(1>=o)return;const i=e=>e.peak.topPeak+e.peak.botPeak,s=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>i(t.slot)-i(e.slot)),r=Array(o),n=Math.floor((o-1)/2);r[n]=s[0].idx;let a=n-1,c=n+1;for(let e=1;s.length>e;e++)e%2==1&&o>c||0>a?r[c++]=s[e].idx:r[a--]=s[e].idx;const l=r.map(t=>e[t]),h=new Map;r.forEach((e,t)=>h.set(e,t));for(const e of Object.keys(t))t[e]=h.get(t[e]);e.length=0;for(const t of l)e.push(t)}(y,f),w()):"crossing-min+inside-out"===l&&(A(),$t(y,f,t),function(e,t,o){const i=e.length;if(1>=i)return;const s=e.map(e=>{return{slot:e,size:(t=e,t.peak.topPeak+t.peak.botPeak)};var t}).sort((e,t)=>t.size-e.size),r=Math.floor((i-1)/2);let n=Nt(t,o);for(const{slot:a}of s){const s=e.indexOf(a);if(0>s)continue;const c=r;if(s===c)continue;const l=e[s];e.splice(s,1),e.splice(c,0,l);const h=new Map;for(let e=0;i>e;e++)h.set(e,e);if(c>s){for(let e=s+1;c>=e;e++)h.set(e,e-1);h.set(s,c)}else{for(let e=c;s>e;e++)h.set(e,e+1);h.set(s,c)}for(const e of Object.keys(t))t[e]=h.get(t[e]);const d=Nt(t,o);if(d>n){const o=e[c];e.splice(c,1),e.splice(s,0,o);const r=new Map;for(let e=0;i>e;e++)r.set(e,e);if(s>c){for(let e=c+1;s>=e;e++)r.set(e,e-1);r.set(c,s)}else{for(let e=s;c>e;e++)r.set(e,e+1);r.set(c,s)}for(const e of Object.keys(t))t[e]=r.get(t[e])}else n=d}}(y,f,t),w());const S=y.map(e=>{const t=new Map;for(const i of e.occupants){const e=o[i.id];if(e)for(const o of e.samples){const e=t.get(o.t)||{top:0,bot:0};t.set(o.t,{top:Math.max(e.top,o.topMass),bot:Math.max(e.bot,o.botMass)})}}return[...t.entries()].sort((e,t)=>e[0]-t[0])}),k=(e,t)=>{let o={top:0,bot:0};for(const[i,s]of e){if(i>t)break;o=s}return o},_=[];for(let e=0;y.length-1>e;e++){const t=S[e],o=S[e+1],i=new Set([...t.map(e=>e[0]),...o.map(e=>e[0])]);let s=0;for(const e of i){const i=k(t,e),r=k(o,e);i.bot+r.top>s&&(s=i.bot+r.top)}_.push(s)}const M=[];let P=n+(y[0]?.peak.topPeak??0)*a;y.length>0&&M.push(P);for(let e=1;y.length>e;e++)P+=_[e-1]*a+n,M.push(P);if(y.length>0&&(P+=y[y.length-1].peak.botPeak*a+n),P>r){const e=r/P;for(let t=0;M.length>t;t++)M[t]*=e}const T=0===y.length?0:y[0].peak.topPeak+_.reduce((e,t)=>e+t,0)+y[y.length-1].peak.botPeak,R={};for(const t of e)R[t.id]=M[f[t.id]];return{effectiveSlotsHeight:T,centerlines:R,laneLifetime:p,slots:y,slotByNode:f,slotCenter:M,crossingsBefore:m,crossingsAfter:x,lengthBefore:b,lengthAfter:v}}function Gt(e){const{nodes:t,edges:o,domain:i,plotW:s,plotH:r,ribbonLane:n,edgeOpacity:a,colorOf:c,layoutOpts:l}=e,h=function(e,t,o){const i=[],s=new Set(e.map(e=>e.id)),r=Array.isArray(o)&&2===o.length,n=r&&Number.isFinite(o[0])&&Number.isFinite(o[1]);r&&n&&n&&o[1]>=o[0]||i.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||i.push({kind:"invalid-node-time",id:t.id}));for(const e of t)s.has(e.source)||i.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),s.has(e.target)||i.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?(Number.isFinite(e.value)&&e.value>0||i.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||i.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):i.push({kind:"invalid-edge-time",id:e.id});return i}(t,o,i),d=zt().domain(i).range([0,s]);if(h.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:h,xScale:d};const u=function(e,t,o){const{plotH:i,pairing:s="temporal",packing:r="reuse",laneOrder:n="crossing-min",lifetimeMode:a="half"}=o,c=function(e,t){const o={},i={};for(const t of e)o[t.id]=[],i[t.id]=[];for(const e of t)i[e.source]&&i[e.source].push(e),o[e.target]&&o[e.target].push(e);return{incoming:o,outgoing:i}}(e,t),l=function(e,t,o,i="value"){const s="temporal"===i?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,r="temporal"===i?(e,t)=>e.startTime-t.startTime:(e,t)=>t.value-e.value,n=new Map;for(const e of t)n.set(e.id,{});const a=(e,t)=>{const o=new Map;for(const i of e){const e=i[t];o.has(e)||o.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const s=o.get(e);s.edges.push(i),s.total+=i.value,s.earliestStart=Math.min(s.earliestStart,i.startTime),s.latestEnd=Math.max(s.latestEnd,i.endTime)}const n=[...o.values()];n.sort("temporal"===i?(e,o)=>"target"===t?e.earliestStart-o.earliestStart:e.latestEnd-o.latestEnd:(e,t)=>t.total-e.total);for(const e of n)e.edges.sort("target"===t?r:s);return n};for(const t of e){const e=o.outgoing[t.id],i=o.incoming[t.id];if(0===i.length)a(e,"target").forEach((e,t)=>{const o=t%2==0?"top":"bot";for(const t of e.edges)n.get(t.id).sourceSide=o});else if(0===e.length)a(i,"source").forEach((e,t)=>{const o=t%2==0?"top":"bot";for(const t of e.edges)n.get(t.id).targetSide=o});else{const t=a(i,"source"),o=a(e,"target"),s=Math.max(t.length,o.length);for(let e=0;s>e;e++){const i=e%2==0?"top":"bot";if(t[e])for(const o of t[e].edges)n.get(o.id).targetSide=i;if(o[e])for(const t of o[e].edges)n.get(t.id).sourceSide=i}}}return n}(e,t,c,s);let h={};for(const t of e)h[t.id]=Ft(t,c,l);const d=It(e,t,h,c,{plotH:i,padding:12,valueScale:1,packing:r,laneOrder:n,lifetimeMode:a}),u=new Set;for(const e of t){const t=d.slotByNode[e.source],o=d.slotByNode[e.target];if(void 0===t||void 0===o)continue;const i=l.get(e.id);t!==o?t>o?(i.sourceSide="top",i.targetSide="bot"):(i.sourceSide="bot",i.targetSide="top"):(u.add(e.id),i.sourceSide="bot",i.targetSide="bot")}for(const t of e){const e=c.outgoing[t.id],o=c.incoming[t.id],i=new Set(e.map(e=>l.get(e.id).sourceSide)),s=new Set(o.map(e=>l.get(e.id).targetSide));if(1===i.size&&o.length>0){const e=[...i][0];for(const t of o)d.slotByNode[t.source]===d.slotByNode[t.target]&&(l.get(t.id).targetSide=e)}if(1===s.size&&e.length>0){const t=[...s][0];for(const o of e)d.slotByNode[o.source]===d.slotByNode[o.target]&&(l.get(o.id).sourceSide=t)}}for(const t of e){const e=c.incoming[t.id],o=c.outgoing[t.id];if(0===e.length||0===o.length)continue;const i=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const o of e)"top"===l.get(o.id).targetSide?t.inTop+=o.value:t.inBot+=o.value;for(const e of o)"top"===l.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},s=(e,t)=>{const s=i(),r="top"===e?s.outTop-s.inTop:s.outBot-s.inBot,n="top"===t?s.inTop-s.outTop:s.inBot-s.outBot;if(0>=r||0>=n)return!1;const a=Math.min(r,n),c=o.filter(t=>!u.has(t.id)&&l.get(t.id).sourceSide===e&&a>=t.value).sort((e,t)=>t.value-e.value);return 0!==c.length&&(l.get(c[0].id).sourceSide=t,!0)};let r=o.length+1;for(;r-- >0&&(s("top","bot")||s("bot","top")););}h={};for(const t of e)h[t.id]=Ft(t,c,l);const g=It(e,t,h,c,{plotH:i,padding:12,valueScale:1,packing:r,laneOrder:n,lifetimeMode:a}),p=g.effectiveSlotsHeight??g.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),f=Math.min(12,.35*i/Math.max(g.slots.length+1,1)),y=p>0?Math.max(0,(i-f*(g.slots.length+1))/p):1,m=It(e,t,h,c,{plotH:i,padding:f,valueScale:y,packing:r,laneOrder:n,lifetimeMode:a});return{nodeData:h,sides:l,valueScale:y,padding:f,compressedPadding:12>f,centerlines:m.centerlines,laneLifetime:m.laneLifetime,slots:m.slots,slotByNode:m.slotByNode,crossingsBefore:m.crossingsBefore,crossingsAfter:m.crossingsAfter,lengthBefore:m.lengthBefore,lengthAfter:m.lengthAfter}}(t,o,{plotH:r,...l}),{centerlines:g,nodeData:p,valueScale:f}=u,y=[],m=[];t.forEach((e,t)=>{const s=p[e.id];if(!s||0===s.samples.length)return;const r=function(e,t,o,i,s){if(0===e.length)return null;const r=Ot(e,s),n=e=>t-r[e].topMass*o,a=e=>t+r[e].botMass*o;let c=`M${i(r[0].t)},${n(0)}`;for(let e=1;r.length>e;e++)c+=` L${i(r[e].t)},${n(e)}`;c+=` L${i(r[r.length-1].t)},${a(r.length-1)}`;for(let e=r.length-2;e>=0;e--)c+=` L${i(r[e].t)},${a(e)}`;return c+" Z"}(s.samples,g[e.id],f,d,i);if(!r)return;const n=Ot(s.samples,i),a=n.find(e=>e.topMass+e.botMass>0)||n[0],l=g[e.id]+(a.botMass-a.topMass)*f/2,h=c(e.id,t),m=function(e,t,o,i,s){const r=o.nodeData[e];if(!r||0===r.samples.length)return[];const n=o.valueScale,a=o.centerlines[e],c=Ot(r.samples,s),l=c.find(e=>e.topMass+e.botMass>0)||c[0],h=[...c].reverse().find(e=>e.topMass+e.botMass>0)||c[c.length-1],d=i(l.t),u=i(h.t),g=e=>i(Bt(e,s)),p=[],f=(e,t,o,i)=>`M${e},${t} L${o},${t} L${o},${i} L${e},${i} Z`;for(const o of t){if(o.source===e&&null!=o.systemInTime&&Number.isFinite(o.systemInTime)){const e=r.localAttachments.get(o.id);if(e&&"out"===e.kind&&o.startTime>o.systemInTime){const t=g(o.systemInTime),i=g(o.startTime),s=t-20,r=Math.max(d,s);if(i>r){const[o,c]=Et(e,a,n);p.push({pathD:f(r,o,i,c),x0:s,x1:t,from:0,to:1})}}}if(o.target===e&&null!=o.systemOutTime&&Number.isFinite(o.systemOutTime)){const e=r.localAttachments.get(o.id);if(e&&"in"===e.kind&&o.systemOutTime>o.endTime){const t=g(o.systemOutTime),i=g(o.endTime),s=t+20,r=Math.min(u,s);if(r>i){const[o,c]=Et(e,a,n);p.push({pathD:f(i,o,r,c),x0:t,x1:s,from:1,to:0})}}}}return p}(e.id,o,u,d,i);y.push({id:e.id,pathD:r,fill:h,stroke:h,strokeWidth:.5,...m.length>0&&{gradientStubs:m},rawDatum:e.__raw??e,labelX:d(a.t)-4,labelY:l,labelText:e.id})});const x=new Map;return t.forEach((e,t)=>x.set(e.id,t)),o.forEach(e=>{const t=p[e.source]?.localAttachments.get(e.id),o=p[e.target]?.localAttachments.get(e.id);if(!t||!o)return;const s=x.get(e.source)??0,r=c(e.source,s),l=function(e,t,o,i,s,r,n,a){const c=s,l=e=>a?Math.max(a[0],Math.min(a[1],e)):e,h=r(l(e.time)),d=r(l(o.time)),u=e.value*c,g=o.value*c,p=e.sideMassBefore*c,f=o.sideMassAfter*c;let y,m,x,b;"top"===e.side?(y=t-p,m=y+u):(m=t+p,y=m-u),"top"===o.side?(x=i-f,b=x+g):(b=i+f,x=b-g);const v="source"===n?h+.85*(d-h):"target"===n?h+.15*(d-h):(h+d)/2;return{sx:h,sTop:y,sBot:m,tx:d,tTop:x,tBot:b,cp1X:v,cp2X:v}}(t,g[e.source],o,g[e.target],f,d,n,i),{pathD:h,bezier:u}=M(l);m.push({id:e.id,pathD:h,fill:r,opacity:a,rawDatum:e.__raw??e,bezier:u})}),{layout:u,layoutConfig:{bands:y,ribbons:m,showLabels:!0},issues:[],xScale:d}}var Yt=e=>{const{bands:t=[],ribbons:o=[],showLabels:i=!0}=e.config,s=[];for(const e of o)s.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:e.opacity,stroke:"none"},datum:{__kind:"ribbon",data:e.rawDatum,id:e.id}});for(const e of t)if(e.gradientStubs)for(let t=0;e.gradientStubs.length>t;t++){const o=e.gradientStubs[t];s.push({type:"bezier",pathD:o.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:o.x0,x1:o.x1,from:o.from,to:o.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${t}`}})}for(const e of t)s.push({type:"bezier",pathD:e.pathD,style:{...e.gradientStubs&&e.gradientStubs.length>0?{fill:"none"}:{fill:e.fill,fillOpacity:.86},stroke:e.stroke??e.fill,strokeWidth:e.strokeWidth??.5},datum:{__kind:"band",data:e.rawDatum,id:e.id}});const r=i?t.map(e=>({x:e.labelX,y:e.labelY,text:e.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:t.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:s,labels:r}};function Vt(e,t,o,i){if(e&&e.length>0)return e;const s=new Set;return t.forEach(e=>{const t="function"==typeof o?o(e):e[o],r="function"==typeof i?i(e):e[i];s.add(t),s.add(r)}),Array.from(s).map(e=>({id:e}))}import*as Xt from"react";var Ht={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5};import{scaleSequential as qt}from"d3-scale";function Qt(e){return e&&"object"==typeof e&&e.properties?{...e.properties,...e}:e}function Zt(e){return[{id:"gauntlet-left",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:76,x2:28,y2:e.floorY,thickness:8}},{id:"gauntlet-ceiling",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:76,x2:e.width-30,y2:76,thickness:8}},{id:"gauntlet-floor",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:e.floorY,x2:e.width-30,y2:e.floorY,thickness:8}},{id:"gauntlet-right",restitution:.12,friction:.42,shape:{type:"segment",x1:e.width-30,y1:76,x2:e.width-30,y2:e.floorY,thickness:8}}]}function Ut(e,t,o,i){return o?"function"==typeof o?o(e,t):e[o]??i:i}function Kt(e){return`gauntlet:${e}:core`}function Jt(e,t){return`gauntlet:${e}:positive:${t}`}function eo(e,t,o){return`gauntlet:${e}:negative:${t}:${o}`}function to(e,t,o,i){const s=Math.max(2,o+2),r=80+s,n=i.floorY-s;return{x:Math.max(32+s,Math.min(i.width-30-4-s,e)),y:Math.max(r,Math.min(n,t))}}function oo(e,t){const o=[...e].sort((e,t)=>e.localeCompare(t)),i=Math.max(0,o.indexOf(t));return{angle:.82*-Math.PI+(o.length>1?i/(o.length-1):.5)*Math.PI*.64,index:i,radius:48+i%2*6}}function io(e,t,o){const i=e.activePositiveIds.reduce((e,o)=>e+(t.get(o)?.value??1),0),s=e.missingPositiveIds.length+e.poppedPositiveIds.length,r=e.negativeIds.reduce((e,t)=>e+(o.get(t)?.load??1),0);return Math.max(0,Math.min(100,75+3*i-8*r-1.2*e.delay-5*s))}function so(e){const t=function(e,t,o){const[i,s]=e,r=Math.round(.48*s),n=s-36,a=(t??[]).filter(e=>!1!==e.enabled),c=Math.max(1,a.length),l=.22*i,h=c>1?(.78*i-l)/(c-1):0,d=Math.max(Math.round(.14*i),110);return{crashY:n-o,floorY:n,gates:a.map((e,t)=>({...e,id:e.id,x:e.x??Math.round(l+t*h),width:e.width??Math.max(54,Math.round(.07*i))})),graveyardX:Math.round(.84*i),graveyardY:n-4,height:s,routeY:r,socketX:Math.round(.92*i),startX:d,width:i}}(e.size??[900,520],e.gates,e.crashOffset??30),o=e.positiveProperties??[],i=new Map(o.map(e=>[e.id,e])),s=new Map((e.negativeProperties??[]).map(e=>[e.id,e])),r={idAccessor:e.idAccessor,initialViability:e.initialViability,metricsAccessor:e.metricsAccessor,negativeAccessor:e.negativeAccessor,positiveAccessor:e.positiveAccessor,startTimeAccessor:e.startTimeAccessor},n=(e.data??[]).map((t,n)=>{const a=function(e,t,o,i,s){const r=Ut(e,t,o.idAccessor,null!=e.id?e.id+"":"project-"+t)+"",n=i.map(e=>e.id),a=[...Ut(e,t,o.positiveAccessor,n)],c=[...Ut(e,t,o.negativeAccessor,[])].filter(e=>s.has(e));return{id:r,activePositiveIds:a,datum:e,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...Ut(e,t,o.metricsAccessor,{})},missingPositiveIds:n.filter(e=>!a.includes(e)),negativeIds:c,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(Ut(e,t,o.startTimeAccessor,0))||0),stage:"project filed",viability:Ut(e,t,o.initialViability,100)}}(t,n,r,o,s);return{...a,viability:e.viability?.(a,{negativeProperties:s,positiveProperties:i})??io(a,i,s)}}),a=n.flatMap((o,r)=>{const n=function(e,t,o,i){const s=function(e){return{graveyardX:e.graveyardX,graveyardY:e.graveyardY,routeY:e.routeY,socketX:e.socketX,socketY:e.routeY-4,startX:e.startX,startY:e.routeY}}(o),r=i?.(e,t,o)??{};return{...s,...r,startY:r.startY??r.routeY??s.startY,socketY:r.socketY??r.routeY??s.socketY,graveyardY:r.graveyardY??s.graveyardY}}(o,r,t,e.projectPlacement);return function(e,t,o,i,s,r,n){const a=i.startX,c=i.startY+(i.startY===o.routeY?38*t:0),l=n?.(e,t,o,i)??{},h={__gauntlet:!0,kind:"gauntlet-core",projectId:e.id,sourceDatum:e.datum},d=[{...l,id:Kt(e.id),x:l.x??a,y:l.y??c,vx:l.vx??42,vy:l.vy??0,mass:l.mass??7,bodyCollisions:l.bodyCollisions??!0,shape:l.shape??{type:"circle",radius:28},spawnAt:l.spawnAt??e.startedAt,datum:h}],u=to(a,c,l.shape&&"radius"in l.shape&&Number(l.shape.radius)||28,o);d[0].x=u.x,d[0].y=u.y;for(const t of e.activePositiveIds){const i=s.get(t);if(!i)continue;const r=oo(e.activePositiveIds,t),n=i.radius??10,a=to(u.x+Math.cos(r.angle)*r.radius,u.y+Math.sin(r.angle)*r.radius,n,o);d.push({id:Jt(e.id,t),x:a.x,y:a.y,vx:18*Math.cos(r.angle),vy:18*Math.sin(r.angle),mass:i.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:n},spawnAt:l.spawnAt??e.startedAt,datum:{__gauntlet:!0,kind:"gauntlet-positive",projectId:e.id,property:i,sourceDatum:e.datum},springs:!1===i.spring?[]:[{target:{type:"body",bodyId:Kt(e.id)},stiffness:.56,damping:.9,restLength:52+r.index%2*4,...i.spring??{}}]})}return e.negativeIds.forEach((t,i)=>{const s=r.get(t);s&&d.push(function(e,t,o,i,s,r,n){const a=t.radius??7.2,c=to(i-12+o%4*12,s+54+12*Math.floor(o/4),a,r);return{id:eo(e.id,t.id,o),x:c.x,y:c.y,vx:10,vy:6,mass:t.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:a},spawnAt:n,datum:{__gauntlet:!0,kind:"gauntlet-negative",projectId:e.id,property:t,sourceDatum:e.datum},springs:!1===t.spring?[]:[{target:{type:"body",bodyId:Kt(e.id)},stiffness:.62,damping:.92,restLength:52+o%4*3,...t.spring??{}}]}}(e,s,i,u.x,u.y,o,l.spawnAt??e.startedAt))}),d}(o,r,t,n,i,s,e.coreBody)});return{layout:t,initialSpawns:a,config:{fixedDt:1/60,maxSubsteps:8,kernel:{gravity:{x:0,y:0},restitution:.16,friction:.44,velocityDamping:.982,maxVelocity:520,sleepAfter:.8,sleepSpeed:7},colliders:Zt(t)}}}function ro(e){return e.map(e=>({...e,spawnAt:void 0}))}var no={Sparkline:{frameType:"xy",layout:{mode:"sparkline"},buildProps:(e,t,o,i,s)=>({chartType:"line",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",groupAccessor:s.lineBy||t,colorAccessor:t,...i,showAxes:!1,margin:i.margin,showLegend:!1,showGrid:!1,title:void 0})},LineChart:{frameType:"xy",buildProps:(e,t,o,i,s)=>{const r=t||s.lineBy;return{chartType:"line",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",groupAccessor:s.lineBy||t,colorAccessor:r,colorScheme:o,lineStyle:rt(e,r,o,i,s),...i,showLegend:i.showLegend??!!r}}},AreaChart:{frameType:"xy",buildProps:(e,t,o,i,s)=>{const r=t||s.areaBy,n=function({data:e,safeData:t,areaBy:o,lineDataAccessor:i}){if(null==e)return[];const s=void 0!==t[0]?.[i];if(!s&&!o)return t;let r;if(s)r=t;else{const e=t.reduce((e,t)=>{const s="function"==typeof o?o(t):t[o],r=s+"";if(!e[r]){const t={[i]:[]};"string"==typeof o&&(t[o]=s),e[r]=t}return e[r][i].push(t),e},{});r=Object.values(e)}return r.flatMap(e=>{const t=Array.isArray(e[i])?e[i]:[];return"string"==typeof o?t.map(t=>({...t,[o]:t[o]??e[o]})):t})}({data:e,safeData:Array.isArray(e)?ie(e):[],areaBy:s.areaBy,lineDataAccessor:s.lineDataAccessor||"coordinates"});return{chartType:"area",data:n,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",y0Accessor:s.y0Accessor,groupAccessor:s.areaBy||void 0,colorAccessor:r,colorScheme:o,...i,lineStyle:i.lineStyle||nt(n,r,o,i,s)}}},DifferenceChart:{frameType:"xy",buildProps:(e,t,o,i,s)=>{const r=s.xAccessor||"x",n=s.seriesAAccessor||"a",a=s.seriesBAccessor||"b",c=e=>tt(et(r,"x",e)),l=e=>tt(et(n,"a",e)),h=e=>tt(et(a,"b",e)),d=s.seriesAColor||"var(--semiotic-danger, #dc2626)",u=s.seriesBColor||"var(--semiotic-info, #2563eb)",g=s.areaOpacity??.6,p=s.lineWidth??1.5,f=!1!==s.showLines,y=!1!==i.showLegend,m=s.seriesALabel||"A",x=s.seriesBLabel||"B",b=i.legendPosition||"right",v=function(e,t,o,i){if(!e.length)return[];const s=e.filter(e=>Number.isFinite(t(e))).sort((e,o)=>t(e)-t(o)),r=[];let n=0,a=null,c=null,l=[];const h=(e,t)=>e>t?"A":t>e?"B":null,d=e=>`seg-${n}-${e}`,u=e=>r.push(e),g=(e,t)=>{u({__x:e.x,__y:e.y,__y0:e.y,__diffSegment:d(t),__diffWinner:t,__valA:e.y,__valB:e.y,__sourceDatum:e.datum})};for(let e=0;s.length>e;e++){const r=s[e],p=t(r),f=o(r),y=i(r);if(!Number.isFinite(p)||!Number.isFinite(f)||!Number.isFinite(y))continue;const m=h(f,y);if(null!==m)if(null!=a){if(c&&c.w!==m){let e,t;if(l.length>0)e=l[0].x,t=l[0].y;else{const o=f-c.a-(y-c.b);if(0!==o){const i=Math.max(0,Math.min(1,(c.b-c.a)/o));e=c.x+i*(p-c.x),t=c.a+i*(f-c.a)}else e=c.x,t=c.a}u({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t}),n++,a=m,u({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t});for(let e=1;l.length>e;e++)g(l[e],a)}else for(const e of l)g(e,a);l=[],u({__x:p,__y:y>f?y:f,__y0:y>f?f:y,__diffSegment:d(a),__diffWinner:a,__valA:f,__valB:y,__sourceDatum:r}),c={x:p,a:f,b:y,w:m}}else{a=m;for(const e of l)g(e,a);l=[],u({__x:p,__y:y>f?y:f,__y0:y>f?f:y,__diffSegment:d(a),__diffWinner:a,__valA:f,__valB:y,__sourceDatum:r}),c={x:p,a:f,b:y,w:m}}else l.push({x:p,y:f,datum:r})}for(const e of l)g(e,a??"A");return r}(Array.isArray(e)?e:[],c,l,h),A=[];if(f&&Array.isArray(e)){const t=e.filter(e=>Number.isFinite(c(e))).sort((e,t)=>c(e)-c(t));for(const e of t){const t=c(e),o=l(e),i=h(e);Number.isFinite(o)&&A.push({__x:t,__y:o,__diffSegment:"line-A"}),Number.isFinite(i)&&A.push({__x:t,__y:i,__diffSegment:"line-B"})}}return{chartType:"mixed",data:[...v,...A],xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:Array.from(new Set(v.map(e=>e.__diffSegment))),areaStyle:e=>{const t=e.__diffSegment;return{fill:"A"==(t?.endsWith("-A")?"A":"B")?d:u,stroke:"none",fillOpacity:g}},lineStyle:e=>({stroke:"A"==("line-A"===e.__diffSegment?"A":"B")?d:u,strokeWidth:p,fill:"none"}),curve:s.curve||"linear",...i,...y&&{legend:{legendGroups:[{label:"",type:"fill",styleFn:e=>({fill:e.color||"currentColor"}),items:[{label:m,color:d},{label:x,color:u}]}]},legendPosition:b}}}},StackedAreaChart:{frameType:"xy",buildProps:(e,t,o,i,s)=>{const r=t||s.areaBy,n="string"==typeof r&&Array.isArray(e)?oe(e,r,o):void 0;return{chartType:"stackedarea",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",groupAccessor:s.areaBy,colorAccessor:r,colorScheme:o,normalize:s.normalize,stackOrder:s.stackOrder,lineStyle:null==s.areaOpacity?void 0:e=>{const t=null==r?void 0:re(e,r,n),o=s.showLine??!0;return{fill:s.color??t,stroke:o?s.stroke??t:"none",...o?{strokeWidth:s.strokeWidth??s.lineWidth??2}:{},fillOpacity:s.areaOpacity,...null==s.opacity?{}:{opacity:s.opacity}}},...i,curve:i.curve??s.curve??"monotoneX",showLegend:i.showLegend??!!r}}},Scatterplot:{frameType:"xy",buildProps:(e,t,o,i,s)=>{const r=i.pointStyle||ct(e,t,o,i,s),n=v(s.styleRules,s.xAccessor||"x",s.yAccessor||"y"),a=n?e=>({..."function"==typeof r?r(e):r,...n(e)}):r;return{chartType:"scatter",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",colorAccessor:t,sizeAccessor:s.sizeBy,...s.symbolBy&&{symbolAccessor:s.symbolBy},...s.symbolMap&&{symbolMap:s.symbolMap},colorScheme:o,...i,sizeRange:s.sizeRange||[3,15],pointStyle:a,showLegend:i.showLegend??!!t}}},CandlestickChart:{frameType:"xy",buildProps:(e,t,o,i,s)=>{const[r]=i.size??[600,400];return{chartType:"candlestick",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.highAccessor||"high",highAccessor:s.highAccessor||"high",lowAccessor:s.lowAccessor||"low",openAccessor:s.openAccessor,closeAccessor:s.closeAccessor,candlestickStyle:s.candlestickStyle,...i,scalePadding:i.scalePadding??Math.max(2,Math.min(12,Math.round(r/40))),extentPadding:i.extentPadding??(r>200?.1:.02)}}},BubbleChart:{frameType:"xy",buildProps:(e,t,o,i,s)=>({chartType:"scatter",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",colorAccessor:t,sizeAccessor:s.sizeBy,sizeRange:s.sizeRange||[5,40],colorScheme:o,...i,pointStyle:i.pointStyle||at(e,t,o,i,s),showLegend:i.showLegend??!!t})},ConnectedScatterplot:{frameType:"xy",buildProps:(e,t,o,i,s)=>{const r=function(e,t){if(!Array.isArray(e))return{data:e,orderMap:new WeakMap};const o=t.xAccessor||"x",i=t.yAccessor||"y",s=t.orderAccessor?[...e].sort((e,o)=>null==e||"object"!=typeof e?1:null==o||"object"!=typeof o?-1:tt(et(t.orderAccessor,"order",e))-tt(et(t.orderAccessor,"order",o))):e,r=new WeakMap;let n=0;for(const e of s){if(null==e||"object"!=typeof e)continue;const t=tt(et(o,"x",e)),s=tt(et(i,"y",e));Number.isFinite(t)&&Number.isFinite(s)&&n++}let a=0;for(const e of s){if(null==e||"object"!=typeof e)continue;const t=tt(et(o,"x",e)),s=tt(et(i,"y",e));Number.isFinite(t)&&Number.isFinite(s)&&r.set(e,{idx:a++,total:n})}return{data:s,orderMap:r}}(e,s),n=s.pointRadius??4;return{chartType:"scatter",data:r.data,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",colorAccessor:t,colorScheme:o,pointStyle:e=>{const t=r.orderMap.get(e),o=t?.idx??0,i=t?.total??1;return{fill:i>0?ot(o,i):"#6366f1",stroke:"white",strokeWidth:1,r:n,fillOpacity:1}},...i,svgPreRenderers:[e=>{const t=e.filter(e=>"point"===e.type&&"number"==typeof e.x&&"number"==typeof e.y);if(2>t.length)return null;const o=[];for(let e=0;t.length-1>e;e++){const i=t[e],s=t[e+1],r=ot(e,t.length);100>t.length&&o.push(Je.createElement("line",{key:"halo-"+e,x1:i.x,y1:i.y,x2:s.x,y2:s.y,stroke:"white",strokeWidth:n+2,strokeLinecap:"round",opacity:.5})),o.push(Je.createElement("line",{key:"segment-"+e,x1:i.x,y1:i.y,x2:s.x,y2:s.y,stroke:r,strokeWidth:n,strokeLinecap:"round"}))}return Je.createElement(Je.Fragment,null,...o)}]}}},QuadrantChart:{frameType:"xy",buildProps:(e,t,o,i,s)=>{const r=s.xCenter,n=s.yCenter,a=s.quadrants,c=s.centerlineStyle||{},l=!1!==s.showQuadrantLabels,h=s.quadrantLabelSize??12,d=c.stroke||"#999",u=c.strokeWidth??1,g=Array.isArray(c.strokeDasharray)?c.strokeDasharray.join(","):c.strokeDasharray,p=Je.createElement,f=a?[(e,t,o)=>{if(!t?.x||!t?.y)return null;const i=o.width,s=o.height,c=null!=r?t.x(r):i/2,f=null!=n?t.y(n):s/2;if(null!=r&&!Number.isFinite(c))return null;if(null!=n&&!Number.isFinite(f))return null;const y=Math.max(0,Math.min(i,c)),m=Math.max(0,Math.min(s,f)),x=[{c:a.topLeft,x:0,y:0,w:y,h:m},{c:a.topRight,x:y,y:0,w:i-y,h:m},{c:a.bottomLeft,x:0,y:m,w:y,h:s-m},{c:a.bottomRight,x:y,y:m,w:i-y,h:s-m}],b=l?[p("text",{key:"ltl",x:8,y:8+h,fill:a.topLeft.color,fontWeight:600,fontSize:h,opacity:.5},a.topLeft.label),p("text",{key:"ltr",x:i-8,y:8+h,fill:a.topRight.color,fontWeight:600,fontSize:h,opacity:.5,textAnchor:"end"},a.topRight.label),p("text",{key:"lbl",x:8,y:s-8,fill:a.bottomLeft.color,fontWeight:600,fontSize:h,opacity:.5},a.bottomLeft.label),p("text",{key:"lbr",x:i-8,y:s-8,fill:a.bottomRight.color,fontWeight:600,fontSize:h,opacity:.5,textAnchor:"end"},a.bottomRight.label)]:[];return p(Je.Fragment,null,...x.map((e,t)=>e.w>0&&e.h>0?p("rect",{key:"qf-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.c.color,opacity:e.c.opacity??.08}):null),p("line",{key:"vc",x1:y,y1:0,x2:y,y2:s,stroke:d,strokeWidth:u,strokeDasharray:g}),p("line",{key:"hc",x1:0,y1:m,x2:i,y2:m,stroke:d,strokeWidth:u,strokeDasharray:g}),...b)}]:void 0;return{chartType:"scatter",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",colorAccessor:t,sizeAccessor:s.sizeBy,sizeRange:s.sizeRange||[3,15],colorScheme:o,pointStyle:i.pointStyle||s.pointStyle||ct(e,t,o,i,s),...i,showLegend:i.showLegend??!!t,...f&&{svgPreRenderers:f}}}},Heatmap:{frameType:"xy",buildProps:(e,t,o,i,s)=>({chartType:"heatmap",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",valueAccessor:s.valueAccessor,colorScheme:o||s.colorScheme||"blues",showValues:s.showValues,heatmapValueFormat:s.valueFormat,cellBorderColor:s.cellBorderColor,...i})},TemporalHistogram:{frameType:"xy",buildProps:(e,t,o,i,s)=>{const r=Array.isArray(e)?ie(e):[],n=s.timeAccessor||"time",a=s.valueAccessor||"value",c=s.categoryAccessor,l=s.valueExtent||i.yExtent,h="down"===s.direction?D({data:r,timeAccessor:n,valueAccessor:a,binSize:Number(s.binSize),valueExtent:l,extentPadding:s.extentPadding}):l,d={...void 0!==s.fill&&{fill:s.fill},...void 0!==s.stroke&&{stroke:s.stroke},...void 0!==s.strokeWidth&&{strokeWidth:s.strokeWidth},...void 0!==s.opacity&&{opacity:s.opacity},...void 0!==s.gap&&{gap:s.gap}};return{chartType:"bar",data:r,...i,runtimeMode:"streaming",windowMode:"growing",windowSize:Math.max(1,r.length),arrowOfTime:s.arrowOfTime||"right",timeAccessor:n,valueAccessor:a,xExtent:s.timeExtent||i.xExtent,yExtent:h,extentPadding:s.extentPadding??i.extentPadding,binSize:s.binSize,categoryAccessor:c,barColors:s.colors||i.barColors,colorScheme:s.colors||i.colorScheme,barStyle:i.barStyle||d,showLegend:i.showLegend??!!c}}},XYCustomChart:{frameType:"xy",buildProps:(e,t,o,i,s)=>({chartType:"custom",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",colorAccessor:t,colorScheme:o,customLayout:s.layout||s.customLayout,layoutConfig:s.layoutConfig,...i,showAxes:s.frameProps?.showAxes??s.showAxes??!1,showLegend:i.showLegend??!!t})},BarChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"bar",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",projection:"horizontal"===s.orientation?"horizontal":"vertical",oSort:s.sort??!1,colorAccessor:t,colorScheme:o,barPadding:s.barPadding,...null!=s.roundedTop&&{roundedTop:s.roundedTop},...i,gradientFill:_t(i.gradientFill),pieceStyle:Mt(e,t,o,i,s)})},StackedBarChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>{const r=t||s.stackBy;return{chartType:"bar",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",stackBy:s.stackBy,colorAccessor:r,colorScheme:o,projection:"horizontal"===s.orientation?"horizontal":"vertical",normalize:s.normalize,oSort:s.sort??!1,barPadding:s.barPadding,...null!=s.roundedTop&&{roundedTop:s.roundedTop},...i,gradientFill:_t(i.gradientFill),pieceStyle:Mt(e,r,o,i,s),showLegend:i.showLegend??!!r}}},GroupedBarChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>{const r=t||s.groupBy;return{chartType:"clusterbar",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",groupBy:s.groupBy,colorAccessor:r,colorScheme:o,projection:"horizontal"===s.orientation?"horizontal":"vertical",oSort:s.sort??!1,barPadding:s.barPadding,...null!=s.roundedTop&&{roundedTop:s.roundedTop},...i,gradientFill:_t(i.gradientFill),pieceStyle:Mt(e,r,o,i,s),showLegend:i.showLegend??!!r}}},PieChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>{const r=t||s.categoryAccessor;return{chartType:"pie",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",projection:"radial",colorAccessor:r,colorScheme:o,...null!=s.cornerRadius&&{cornerRadius:s.cornerRadius},...i,pieceStyle:Mt(e,r,o,i,s),showLegend:i.showLegend??!!r}}},DonutChart:{frameType:"ordinal",layout:{primarySize:{width:400,height:400}},buildProps:(e,t,o,i,s)=>{const r=t||s.categoryAccessor;return{chartType:"donut",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",projection:"radial",margin:i.margin??{top:50,right:40,bottom:60,left:70},innerRadius:s.innerRadius??60,colorAccessor:r,colorScheme:o,...null!=s.cornerRadius&&{cornerRadius:s.cornerRadius},...i,pieceStyle:Mt(e,r,o,i,s)}}},Histogram:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>{const r=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=s.valueAccessor||"value",a=r.map(e=>Number("function"==typeof n?n(e):e[n])).filter(Number.isFinite),c=a.length?[Math.min(...a),Math.max(...a)]:void 0;return{chartType:"histogram",data:e,oAccessor:s.categoryAccessor||(e=>null==e.category?"All":e.category+""),rAccessor:n,projection:"horizontal",bins:s.bins??25,normalize:s.relative??!1,colorAccessor:t,colorScheme:o,barPadding:s.categoryPadding??20,...s.valueExtent?{rExtent:s.valueExtent}:c?{rExtent:c}:{},...i,summaryStyle:Pt(e,t,o,i,s)}}},BoxPlot:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"boxplot",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",colorAccessor:t,colorScheme:o,...i,summaryStyle:i.summaryStyle||Pt(e,t,o,i,s)})},ViolinPlot:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"violin",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",colorAccessor:t,projection:"horizontal"===s.orientation?"horizontal":"vertical",bins:s.bins??25,showIQR:s.showIQR??!0,barPadding:s.categoryPadding??20,colorScheme:o,...i,summaryStyle:i.summaryStyle||Tt(e,t,o,i,s),showLegend:i.showLegend??!!t,...s.valueExtent&&{rExtent:s.valueExtent}})},SwarmPlot:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"swarm",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",colorAccessor:t,...s.symbolBy&&{symbolAccessor:s.symbolBy},...s.symbolMap&&{symbolMap:s.symbolMap},colorScheme:o,...i,sizeRange:s.sizeRange||[3,8],pieceStyle:i.pieceStyle||Lt(e,t,o,i,s),showLegend:i.showLegend??!!t})},DotPlot:{frameType:"ordinal",layout:{modeDefaults:{showGrid:!0}},buildProps:(e,t,o,i,s)=>({chartType:"point",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",colorAccessor:t,colorScheme:o,projection:"vertical"===s.orientation?"vertical":"horizontal",oSort:s.sort??"auto",barPadding:s.categoryPadding??10,...i,pieceStyle:Rt(e,t,o,i,s),showGrid:i.showGrid??!0,showLegend:i.showLegend??!!t})},SwimlaneChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>{const r=t||s.subcategoryAccessor;return{chartType:"swimlane",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",stackBy:s.subcategoryAccessor,colorAccessor:r,categoryAccessor:s.categoryAccessor,subcategoryAccessor:s.subcategoryAccessor,colorScheme:o,projection:"vertical"===s.orientation?"vertical":"horizontal",...null!=s.trackFill&&{trackFill:s.trackFill},...i,gradientFill:_t(i.gradientFill),pieceStyle:i.pieceStyle||Mt(e,r,o,i,s),showLegend:i.showLegend??!!r,barPadding:s.barPadding??40}}},RidgelinePlot:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"ridgeline",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",colorAccessor:t,colorScheme:o,projection:"vertical"===s.orientation?"vertical":"horizontal",bins:s.bins??20,amplitude:s.amplitude??1.5,barPadding:s.categoryPadding??5,oSort:s.oSort??!1,...i,summaryStyle:i.summaryStyle||((r,n)=>({fillOpacity:.5,...Mt(e,t,o,i,s)(r,n)})),showLegend:i.showLegend??!!t})},LikertChart:{frameType:"ordinal",layout:{margin:(e,t)=>({...t.marginDefaults,left:"vertical"===e.orientation?t.marginDefaults.left:Math.max(100,t.marginDefaults.left)})},buildProps:(e,t,o,i,s)=>{const r=Array.isArray(s.levels)&&s.levels.length>=2?s.levels:["Strongly disagree","Disagree","Neutral","Agree","Strongly agree"],n="vertical"!==s.orientation;let a=function(e,t,o,i,s,r){const n=new Map,a=new Set(t);for(const c of e){const e=o(c);n.has(e)||n.set(e,new Map);const l=n.get(e);if(i){const e=i(c);if(null==e||!Number.isFinite(e))continue;if(!Number.isInteger(e)){"production"!==process.env.NODE_ENV&&console.warn("[LikertChart] Ignoring non-integer Likert score:",e);continue}const o=e-1;if(0>o||o>=t.length)continue;const s=t[o];l.set(s,(l.get(s)||0)+1)}else if(s&&r){const e=s(c),t=r(c);if(!a.has(e))continue;l.set(e,(l.get(e)||0)+(Number.isFinite(t)?t:0))}}const c=[];for(const[e,o]of n){let i=0;for(const e of t)i+=o.get(e)||0;if(0!==i)for(let s=0;t.length>s;s++){const r=t[s],n=o.get(r)||0;c.push({__likertCategory:e,__likertLevel:r,__likertLevelLabel:r,__likertCount:n,__likertPct:n/i*100,__likertLevelIndex:s})}}return c}(Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],r,St(s.categoryAccessor,"question"),s.levelAccessor?null:St(s.valueAccessor,"score"),s.levelAccessor?St(s.levelAccessor,"level"):null,s.levelAccessor?St(s.countAccessor,"count"):null);n&&(a=function(e,t){const o=t.length,i=o%2!=0,s=Math.floor(o/2),r=new Map;for(const t of e){const e=r.get(t.__likertCategory)||[];e.push(t),r.set(t.__likertCategory,e)}const n=[];for(const[,e]of r){const t=new Map;let r,a;for(const o of e)o.__likertLevel===At?r=o:o.__likertLevel===wt?a=o:t.set(o.__likertLevelIndex,o);i&&r&&n.push(r);for(let e=s-1;e>=0;e--){const o=t.get(e);o&&n.push(o)}i&&a&&n.push(a);for(let e=i?s+1:s;o>e;e++){const o=t.get(e);o&&n.push(o)}}return n}(function(e,t){const o=t.length,i=o%2!=0,s=Math.floor(o/2),r=[];for(const t of e){const e=t.__likertLevelIndex;if(i&&e===s){const e=t.__likertPct/2;r.push({...t,__likertLevel:At,__likertPct:-e}),r.push({...t,__likertLevel:wt,__likertPct:e})}else r.push(s>e?{...t,__likertPct:-t.__likertPct}:t)}return r}(a,r),r));const c=it(i.theme).colors.diverging,l=Array.isArray(o)&&o.length>=r.length?o:function(e,t){if(0>=e)return[];if(t){const o=vt[t];if(o){if(1===e)return[o(.5)];const t=[];for(let i=0;e>i;i++)t.push(o(i/(e-1)));return t}}const o=["#da1e28","#ff8389","#ffb3b8"],i=["#a6c8ff","#4589ff","#0043ce"],s="#a8a8a8";if(1===e)return[s];const r=e%2!=0,n=Math.floor(e/2),a=[];for(let e=0;n>e;e++)a.push(o[Math.min(Math.floor(e*o.length/n),o.length-1)]);r&&a.push(s);for(let e=0;n>e;e++)a.push(i[Math.min(Math.floor(e*i.length/n),i.length-1)]);return a}(r.length,c),h=new Map(r.map((e,t)=>[e,l[t]||"#888"])),d=r.length%2&&h.get(r[Math.floor(r.length/2)])||"#888",u="function"==typeof s.valueFormat?s.valueFormat:e=>Math.abs(Number(e)).toFixed(0)+"%",g=!1===i.showLegend?void 0:{legendGroups:[{label:"",items:r.map(e=>({label:e})),styleFn:e=>({fill:h.get(e.label)||"#888"})}]},p=J(g,i.legend);return{chartType:"bar",data:a,oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:n?"horizontal":"vertical",barPadding:s.barPadding,showGrid:i.showGrid,oLabel:s.categoryLabel,rLabel:s.valueLabel||(n?void 0:"Percentage"),rFormat:u,...s.categoryFormat&&{oFormat:s.categoryFormat},...s.valueExtent&&{rExtent:s.valueExtent},...i,pieceStyle:e=>{const t=e.__likertLevel||e.data?.__likertLevel;return{fill:t===At||t===wt?d:h.get((e.__likertLevelLabel||e.data?.__likertLevelLabel||t)+"")||"#888"}},showLegend:i.showLegend??!0,legendPosition:i.legendPosition||"right",...p&&{legend:p},__legendIncludesAutomatic:!0}}},FunnelChart:{frameType:"ordinal",layout:{margin:(e,t)=>"vertical"===e.orientation?{top:t.title?60:40,right:20,bottom:60,left:60}:{top:t.title?40:10,right:10,bottom:10,left:10}},buildProps:(e,t,o,i,s)=>{const r="vertical"===s.orientation,n=t||s.categoryAccessor;return{chartType:r?"bar-funnel":"funnel",data:e,oAccessor:s.stepAccessor||"step",rAccessor:s.valueAccessor||"value",colorAccessor:n,categoryAccessor:s.categoryAccessor,projection:r?"vertical":"horizontal",connectorAccessor:s.connectorAccessor,connectorStyle:s.connectorStyle,...!r&&null!=s.connectorOpacity&&{connectorOpacity:s.connectorOpacity},barPadding:r?40:0,colorScheme:o,...i,showAxes:r,showGrid:r,pieceStyle:Mt(e,n,o,i,s),showLabels:s.showLabels??!0}}},GaugeChart:{frameType:"ordinal",layout:{primarySize:{width:300,height:250}},renderOverlay:function(e,{theme:t}){const o=e.__gauge;if(!o)return null;const i=(o.startAngleDeg+(o.gMax===o.gMin?0:(Math.max(o.gMin,Math.min(o.gMax,o.value??o.gMin))-o.gMin)/(o.gMax-o.gMin))*o.sweep-90)*Math.PI/180,s=o.needleColor||t.colors.text,r=o.showScaleLabels?(o.thresholds||[]).filter(e=>e.value>o.gMin&&o.gMax>e.value):[];return yt(pt,{children:[o.showNeedle&&yt(pt,{children:[ft("line",{x1:o.centerX,y1:o.centerY,x2:o.centerX+o.needleLength*Math.cos(i),y2:o.centerY+o.needleLength*Math.sin(i),stroke:s,strokeWidth:2.5,strokeLinecap:"round"}),ft("circle",{cx:o.centerX,cy:o.centerY,r:4,fill:s})]}),null!=o.contextValue&&ft("text",{x:o.centerX,y:o.contextValueY,textAnchor:"middle",dominantBaseline:"middle",fontSize:o.valueFontSize,fontWeight:700,fill:s,children:o.contextValue}),r.map((e,i)=>{const s=(o.startAngleDeg+(o.gMax===o.gMin?0:(e.value-o.gMin)/(o.gMax-o.gMin))*o.sweep-90)*Math.PI/180,r=o.innerRadius-1,n=o.radius+1,a=o.radius+10,c=((s+Math.PI/2)/(2*Math.PI)*12+12)%12,l=c>=11||1>c?"middle":5>c?"start":7>c?"middle":"end",h=c>=11||1>c?"auto":5>c?"middle":7>c?"hanging":"middle";return yt("g",{children:[ft("line",{x1:o.centerX+Math.cos(s)*r,y1:o.centerY+Math.sin(s)*r,x2:o.centerX+Math.cos(s)*n,y2:o.centerY+Math.sin(s)*n,stroke:t.colors.border,strokeWidth:2,strokeLinecap:"round"}),ft("text",{x:o.centerX+Math.cos(s)*a,y:o.centerY+Math.sin(s)*a,textAnchor:l,dominantBaseline:h,fill:t.colors.textSecondary,fontSize:10,children:e.label||e.value+""})]},"gauge-label-"+i)})]})},buildProps:(o,i,s,r,n)=>{const a=n.min??0,c=n.max??100,l=n.sweep??240,h=n.arcWidth??.3,d=!1!==n.showNeedle,u=!1!==n.fillZones,{startAngleDeg:g}=t(l),p=n.thresholds||[{value:c,color:n.color||"#4e79a7"}],f=r.gradientFill,y=function(e){const{min:t,max:o,value:i,thresholds:s,fillColor:r,backgroundColor:n,fillZones:a,showScaleLabels:c,gradientFill:l,gradientSteps:h=240}=e,d=o-t||1,u=(Math.max(t,Math.min(o,i))-t)/d;let g=s&&s.length>0?[...s].sort((e,t)=>e.value-t.value):[{value:o,color:r||"#007bff"}];g=g.map(e=>({...e,value:Math.max(t,Math.min(o,e.value))})),o>g[g.length-1].value&&g.push({value:o,color:g[g.length-1].color});const p=!!l&&l.colorStops.length>=2,f=[],y=new Map,m=[];if(p){const e=a?u:1,t=gt("bg",0);if(f.push({category:t,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),y.set(t,{fill:n,opacity:.4}),e>0){const t=Math.max(1,Math.floor(h)),o=Math.max(1,Math.min(t,Math.round(e*t))),i=[];for(let t=0;o>t;t++)i.push(ut(l.colorStops,e*(t+.5)/o));const s=gt("fill",0);f.push({category:s,value:e,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:e,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:i}}),y.set(s,{fill:i[0]||n})}}else{let e=t;for(let o=0;g.length>o;o++){const i=g[o],s=(i.value-e)/d,r=(e-t)/d,c=(i.value-t)/d,l=Math.max(0,(a?Math.min(u,c):c)-r),h=a?Math.max(0,s-l):0;if(l>0){const e=gt("fill",o);f.push({category:e,value:l,_zone:i.label||"Zone "+(o+1),_isFill:!0}),y.set(e,{fill:i.color})}if(h>0){const e=gt("bg",o);f.push({category:e,value:h,_zone:i.label||"Zone "+(o+1),_isFill:!1}),y.set(e,{fill:n,opacity:.4})}e=i.value}}if(c&&s&&s.length>0)for(const e of s)e.value>t&&o>e.value&&m.push({type:"gauge-label",value:e.value,label:e.label||e.value+""});return{gaugeData:f,pieceStyle:(e,t)=>y.get(t||e.category)||{fill:n},gaugeAnnotations:m}}({min:a,max:c,value:n.value,thresholds:p,fillColor:n.color,backgroundColor:n.backgroundColor||"#e0e0e0",fillZones:u,showScaleLabels:!1!==n.showScaleLabels,gradientFill:f&&"object"==typeof f&&"colorStops"in f?f:void 0}),[m,x]=r.size||[300,250],b=e(l),v=Math.min(10,Math.max(1,Math.min(m,x)/12)),A=Math.max(4,Math.min((m-2*v)/b.width,(x-2*v)/b.height)-2),w=Math.max(0,Math.min(A-1.5,A*(1-h))),S=m/2-b.cx*A,k=x/2-b.cy*A,_=2*(A+4),M=Math.max(a,Math.min(c,n.value??a)),P="function"==typeof n.valueFormat?n.valueFormat(M):Math.round(M)+"",T=n.centerContent??r.centerContent,R=null!=T?"function"==typeof T?T(M,a,c):T:"sparkline"===n.mode||"context"===n.mode?void 0:kt.createElement("div",{style:{textAlign:"center",lineHeight:1.2}},kt.createElement("div",{style:{fontSize:Math.max(16,.3*A),fontWeight:700,color:"var(--semiotic-text, #333)"}},P),!1!==n.showScaleLabels&&kt.createElement("div",{style:{fontSize:11,color:"var(--semiotic-text-secondary, #666)"}},`${a} – ${c}`));return{chartType:"donut",data:y.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:w,sweepAngle:l,startAngle:g,oSort:!1,pieceStyle:y.pieceStyle,...null!=n.cornerRadius&&{cornerRadius:n.cornerRadius},...r,size:[m,x],margin:{top:k-_/2,bottom:x-k-_/2,left:S-_/2,right:m-S-_/2},...null!=R&&{centerContent:R},showAxes:!1,annotations:[...Array.isArray(r.annotations)?r.annotations:[],...y.gaugeAnnotations],__gauge:{gMin:a,gMax:c,sweep:l,arcWidth:h,value:M,startAngleDeg:g,thresholds:p,centerX:S,centerY:k,radius:A,innerRadius:w,showScaleLabels:!1!==n.showScaleLabels,needleLength:w>20?w-8:A-1,showNeedle:d,needleColor:n.needleColor,..."context"===n.mode&&null==T&&{contextValue:P,contextValueY:k-.2*w,valueFontSize:Math.max(12,Math.min(22,.28*A))}}}}},OrdinalCustomChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"custom",data:e,oAccessor:s.categoryAccessor||s.oAccessor||"category",rAccessor:s.valueAccessor||s.rAccessor||"value",projection:s.projection||"vertical",colorAccessor:t,colorScheme:o,customLayout:s.layout||s.customLayout,layoutConfig:s.layoutConfig,...i,showAxes:s.frameProps?.showAxes??s.showAxes??!1})},ForceDirectedGraph:{frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,o,i,s)=>{const{edgeWidth:r,edgeColor:n,edgeOpacity:a}=s,c=s.edgeStyle??(void 0!==r||void 0!==n||void 0!==a?e=>{const t=e?.data||e;let o=1;if("number"==typeof r)o=r;else if("function"==typeof r)o=r(t);else if("string"==typeof r){const e=t?.[r],i="number"==typeof e?e:Number(e);o=Number.isFinite(i)&&i>0?i:1}return{stroke:n??"#999",strokeWidth:o,opacity:a??.6}}:void 0),l=it(i.theme).colors.categorical,h=new Map,d=s.nodeStyle??(e=>({fill:t?re(e?.data||e,t,void 0):we(void 0,l,o,void 0,h),..."number"==typeof s.nodeSize&&{r:s.nodeSize}})),u=b(s.styleRules,t,"number"==typeof s.nodeSize?void 0:s.nodeSize);return{chartType:"force",nodes:s.nodes,edges:s.edges,nodeIDAccessor:s.nodeIdAccessor||s.nodeIDAccessor,sourceAccessor:s.sourceAccessor,targetAccessor:s.targetAccessor,colorBy:t,colorScheme:o,iterations:s.iterations,forceStrength:s.forceStrength,showLabels:s.showLabels??!1,nodeLabel:s.nodeLabel,nodeSize:s.nodeSize??8,nodeSizeRange:s.nodeSizeRange,nodeStyle:u?(e,t)=>({...d(e),...u(e,t)}):d,edgeStyle:c,...i}}},NetworkCustomChart:{frameType:"network",layout:{margin:{top:40,right:40,bottom:40,left:40}},buildProps:(e,t,o,i,s)=>({chartType:"force",nodes:s.nodes||e||[],edges:s.edges||[],nodeIDAccessor:s.nodeIdAccessor||s.nodeIDAccessor||"id",sourceAccessor:s.sourceAccessor||"source",targetAccessor:s.targetAccessor||"target",valueAccessor:s.valueAccessor||"value",colorBy:t,colorScheme:o,customNetworkLayout:s.layout||s.customNetworkLayout,layoutConfig:s.layoutConfig,...i})},SankeyDiagram:{frameType:"network",layout:{primarySize:{width:800,height:600}},buildProps:(e,t,o,i,s)=>{const r=Array.isArray(s.nodes)?s.nodes:Vt([],Array.isArray(s.edges)?s.edges:[],s.sourceAccessor||"source",s.targetAccessor||"target"),n=it(i.theme).colors.categorical,a=new Map,c="string"==typeof t?t:"__ssrSankeyColorBy",l="function"==typeof t?r.map(e=>({...e,__ssrSankeyColorBy:t(e)})):r,h=t?oe(l,c,o??i.colorScheme??n):void 0,d=e=>({fill:t?re(e?.data||e,t,h):we(void 0,n,o,void 0,a),stroke:i.stroke??"black",strokeWidth:i.strokeWidth??1,...void 0!==i.opacity&&{opacity:i.opacity}}),u=function({edgeColorBy:e,colorBy:t,colorScale:o,nodeStyleFn:i,edgeOpacity:s,baseStyle:r={}}){return n=>{const a={fillOpacity:s,...r};if("function"==typeof e)a.fill=e(n);else if("source"===e){const e="object"==typeof n.source?n.source:null;t&&e?a.fill=re(e.data||e,t,o):e&&(a.fill=i(e,e.index).fill)}else if("target"===e){const e="object"==typeof n.target?n.target:null;t&&e?a.fill=re(e.data||e,t,o):e&&(a.fill=i(e,e.index).fill)}else"gradient"===e&&(a.fill="#999",a.fillOpacity=.7*s);return a}}({edgeColorBy:s.edgeColorBy??"source",colorBy:t,colorScale:h,nodeStyleFn:d,edgeOpacity:s.edgeOpacity??.5,baseStyle:{stroke:"none",strokeWidth:0}});return{chartType:"sankey",nodes:s.nodes,edges:s.edges,nodeIDAccessor:s.nodeIdAccessor||s.nodeIDAccessor,sourceAccessor:s.sourceAccessor,targetAccessor:s.targetAccessor,valueAccessor:s.valueAccessor,orientation:s.orientation,nodeAlign:s.nodeAlign,nodeWidth:s.nodeWidth,nodePaddingRatio:s.nodePaddingRatio,showLabels:s.showLabels,nodeLabel:s.nodeLabel,colorBy:t,edgeColorBy:s.edgeColorBy,edgeOpacity:s.edgeOpacity,nodeStyle:i.nodeStyle||s.nodeStyle||d,edgeStyle:i.edgeStyle||s.edgeStyle||u,colorScheme:o,...i}}},ProcessSankey:{frameType:"network",layout:{margin:{top:30,right:80,bottom:40,left:80}},buildProps:(e,t,o,i,s)=>{const r=e=>null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime(),n=s.sourceAccessor||"source",a=s.targetAccessor||"target",c=s.valueAccessor||"value",l=s.nodeIdAccessor||"id",h=s.startTimeAccessor||"startTime",d=s.endTimeAccessor||"endTime",u=s.systemInTimeAccessor,g=s.systemOutTimeAccessor,p=s.xExtentAccessor||"xExtent",f=s.edgeIdAccessor||"id",y=(e,t)=>"function"==typeof e?e(t):t[e],m=Array.isArray(s.edges)?s.edges:[],x=Array.isArray(s.nodes)?s.nodes:[],b=x.length>0?x:Vt([],m,n,a),v=[r(s.domain?.[0]),r(s.domain?.[1])],A=b.map(e=>{const t=y(l,e)+"",o=y(p,e),i={id:t,__raw:e};if(Array.isArray(o)&&2===o.length){const e=r(o[0]),t=r(o[1]);Number.isFinite(e)&&Number.isFinite(t)&&(i.xExtent=[e,t])}return i}),w=m.map((e,t)=>{const o=y(f,e),i={id:null!=o?o+"":`${y(n,e)}-${y(a,e)}-${t}`,source:y(n,e)+"",target:y(a,e)+"",value:Number(y(c,e)),startTime:r(y(h,e)),endTime:r(y(d,e)),__raw:e};if(u){const t=r(y(u,e));Number.isFinite(t)&&(i.systemInTime=t)}if(g){const t=r(y(g,e));Number.isFinite(t)&&(i.systemOutTime=t)}return i}),[S,k]=i.size??[600,400],_={top:20,right:20,bottom:20,left:20,...i.margin},M=(i.showLegend??!!t)&&!!t,P=i.legendPosition??"right",T=i.__explicitMargin,R=e=>"number"==typeof T||null!=T&&"object"==typeof T&&null!=T[e];M&&("right"!==P||R("right")?"bottom"!==P||R("bottom")||(_.bottom=Math.max(_.bottom,80)):_.right=Math.max(_.right,140));const L=_,z=S-L.left-L.right,C=k-L.top-L.bottom,F=it(i.theme),B=be(o,F.colors.categorical,Ie),O="function"==typeof t?t:null,E=O?b.map(e=>({_cat:O(e)})):b,j=O?"_cat":"string"==typeof t?t:void 0,D=o??[...B],N=j?oe(E,j,D):null,W=new Map;for(const e of A)W.set(e.id,e.__raw);const $=(e,o)=>{if(t&&W.has(e)){const o=W.get(e);return O?re({_cat:O(o)},"_cat",N??void 0):re(o,"string"==typeof t?t:"id",N??void 0)}return B[o%B.length]},I=M&&t?(()=>{const e=new Map;b.forEach((o,i)=>{const s=y(t,o),r=null==s?"":s+"";r&&!e.has(r)&&e.set(r,{label:r,color:$(y(l,o)+"",i)})});const o=Array.from(e.values());return o.length>0?{legendGroups:[{type:"fill",label:"",items:o,styleFn:e=>{const t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0})():void 0,G=J(I,i.legend),{layout:Y,layoutConfig:V,issues:X,xScale:H}=Gt({nodes:A,edges:w,domain:v,plotW:z,plotH:C,ribbonLane:s.ribbonLane||"both",edgeOpacity:"number"==typeof s.edgeOpacity?s.edgeOpacity:.35,colorOf:$,layoutOpts:{pairing:s.pairing||"temporal",packing:s.packing||"reuse",laneOrder:s.laneOrder||"crossing-min",lifetimeMode:s.lifetimeMode||"half"}});if(X.length>0){const e=X.map(Ct).join("; ");throw Error("ProcessSankey: data invalid — "+e)}const q=Array.isArray(s.axisTicks)?s.axisTicks:[],Q=Y?(()=>{let e=null,t=null;for(const o of A){const i=Y.laneLifetime[o.id];if(!i||null==i.start||null==i.end)continue;const s=Number(H(i.start)),r=Number(H(i.end));e=null==e?s:Math.min(e,s),t=null==t?r:Math.max(t,r)}const o=e=>Math.max(0,Math.min(z,e)),i=o(e??0),n=Math.max(i,o(t??z)),a=q.map((e,t)=>({tick:e,index:t,x:Number(H(r(e.date)))})).filter(({x:e})=>e>=i-.5&&n+.5>=e);return Xt.createElement("g",null,...a.map(({index:e,x:t})=>Xt.createElement("line",{key:"grid-"+e,x1:t,y1:0,x2:t,y2:C,stroke:"#94a3b8",strokeOpacity:.15,strokeDasharray:"2 4"})),Xt.createElement("line",{key:"axis",x1:i,y1:C+4,x2:n,y2:C+4,stroke:"#94a3b8"}),...a.map(({tick:e,index:t,x:o})=>{const i=r(e.date),n=null!=e.label?e.label:"function"==typeof s.timeFormat?s.timeFormat(new Date(i)):"";return Xt.createElement("g",{key:"tick-"+t,transform:`translate(${o},${C+4})`},Xt.createElement("line",{y2:6,stroke:"#94a3b8"}),Xt.createElement("text",{y:20,textAnchor:"middle",fontSize:11,fill:"#475569"},n))}))})():void 0;return{chartType:"force",nodes:b,edges:m,customNetworkLayout:Yt,layoutConfig:V,sourceAccessor:n,targetAccessor:a,valueAccessor:c,nodeIDAccessor:l,colorBy:t,colorScheme:o,...Q&&{backgroundGraphics:Q},...i,showLegend:M,...G&&{legend:G,legendPosition:P},__legendIncludesAutomatic:!0,margin:L}}},ChordDiagram:{frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,o,i,s)=>({chartType:"chord",nodes:s.nodes,edges:s.edges,valueAccessor:s.valueAccessor,padAngle:s.padAngle,groupWidth:s.groupWidth,showLabels:s.showLabels,colorBy:t,edgeColorBy:s.edgeColorBy,colorScheme:o,...i})},TreeDiagram:{frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,o,i,s)=>{const r=it(i.theme).colors.categorical,n=new Map,a=t&&"string"==typeof t?oe(e&&"object"==typeof e?[e]:[],t,o??i.colorScheme??r):void 0,c=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7"];return{chartType:"cluster"===s.layout?"cluster":"tree",data:e,childrenAccessor:s.childrenAccessor,colorBy:t,colorByDepth:s.colorByDepth,orientation:s.orientation,showLabels:s.showLabels,colorScheme:o,...i,nodeStyle:i.nodeStyle||s.nodeStyle||(e=>{const l=e?.data||e;return{fill:s.colorByDepth?c[Number(e?.depth||0)%c.length]:t?re(l,t,a):we(void 0,r,o,void 0,n),stroke:i.stroke??"black",strokeWidth:i.strokeWidth??1,...void 0!==i.opacity&&{opacity:i.opacity}}})}}},Treemap:{frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,o,i,s)=>({chartType:"treemap",data:e,childrenAccessor:s.childrenAccessor,hierarchySum:s.valueAccessor,colorBy:t,colorByDepth:s.colorByDepth,showLabels:s.showLabels,colorScheme:o,...i,nodeStyle:i.nodeStyle||s.nodeStyle||(()=>({stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8}))})},CirclePack:{frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,o,i,s)=>{const r=it(i.theme).colors.categorical,n=new Map;return{chartType:"circlepack",data:e,childrenAccessor:s.childrenAccessor,hierarchySum:s.valueAccessor,colorBy:t,colorByDepth:s.colorByDepth,colorScheme:o,...i,nodeStyle:i.nodeStyle||(()=>({fill:we(void 0,r,o,void 0,n),fillOpacity:s.circleOpacity??.7,stroke:"currentColor",strokeWidth:1,strokeOpacity:.3}))}}},ChoroplethMap:{frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,o,i,s)=>{const r="string"==typeof o?o:"blues",n=s.areaStyle??function(e,t,o,i){if(!Array.isArray(e))return;const s=e=>"function"==typeof t?t(e):null!=t?e?.properties?.[t]??e?.[t]:void 0;let r=1/0,n=-1/0;for(const t of e){const e=s(t);null!=e&&isFinite(e)&&(r>e&&(r=e),e>n&&(n=e))}const a=qt(Fe(o)).domain([Number.isFinite(r)?r:0,Number.isFinite(n)?n:1]);return e=>{const t=s(e);return{fill:null!=t&&isFinite(t)?a(t):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:i}}}(s.areas,s.valueAccessor,r,s.areaOpacity??1),a=s.styleRules?p(n,s.styleRules,e=>{return{value:(t=e,"function"==typeof s.valueAccessor?s.valueAccessor(t):null!=s.valueAccessor?t?.properties?.[s.valueAccessor]??t?.[s.valueAccessor]:void 0)};var t},Qt):n;return{areas:s.areas,projection:s.projection||"equalEarth",areaStyle:a,valueAccessor:s.valueAccessor,colorScheme:r,graticule:s.graticule,fitPadding:s.fitPadding,...i}}},ProportionalSymbolMap:{frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,o,i,s)=>{const r=e||s.points,n=s.pointStyle??function(e,t,o,i){const s=Array.isArray(e)?e:[];let r,n;if(t){const e="string"==typeof t?t:"__geoColorBy",i="string"==typeof t?s:s.map(e=>({...e,__geoColorBy:t(e)}));r=oe(i,e,o)}if(i.sizeBy){const e=s.map("function"==typeof i.sizeBy?i.sizeBy:e=>e?.[i.sizeBy]).filter(e=>null!=e&&isFinite(e));e.length>0&&(n=Ve(e))}return e=>({fill:t&&r?re(e,t,r):X,fillOpacity:i.fillOpacity,stroke:"#fff",strokeWidth:i.strokeWidth,r:i.sizeBy?ne(e,i.sizeBy,i.sizeRange,n):i.pointRadius??6})}(r,t,o,{sizeBy:s.sizeBy,sizeRange:s.sizeRange||[3,30],fillOpacity:.7,strokeWidth:.5}),a=s.styleRules?p(n,s.styleRules,f(t,s.sizeBy)):n;return{points:r,xAccessor:s.xAccessor||"lon",yAccessor:s.yAccessor||"lat",areas:s.areas,areaStyle:s.areaStyle||Ht,pointStyle:a,sizeBy:s.sizeBy,colorBy:t,colorScheme:o,projection:s.projection||"equalEarth",graticule:s.graticule,fitPadding:s.fitPadding,...i}}},FlowMap:{frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,o,i,s)=>{const r=(Array.isArray(e)?e:null)||s.flows||[],n=s.nodeIdAccessor||"id",a=s.valueAccessor||"value",c=s.xAccessor||"lon",l=s.yAccessor||"lat",h="function"==typeof c?c:e=>e[c],d="function"==typeof l?l:e=>e[l],u=(s.nodes||[]).map(e=>({...e,x:h(e),y:d(e)})),g=new Map;for(const e of u)g.set(e[n]+"",e);const p=s.edgeColorBy??t,f="function"==typeof p,y=r.map(e=>{if(!e||null==e.source||null==e.target)return null;const t=g.get(e.source+""),o=g.get(e.target+"");return t&&o?{...e,coordinates:[{x:t.x,y:t.y},{x:o.x,y:o.y}]}:null}).filter(Boolean),m="__flowMapEdgeColor",x=(()=>{if(!p)return null;if(f){const e=y.map(e=>({[m]:p(e)}));return oe(e,m,o||"category10")}return oe(y,p,o||"category10")})(),b=e=>p&&x?re(e,p,x):"#007bff";let v=1/0,A=-1/0;for(const e of y){const t=Number(e[a]??0);isFinite(t)&&(v>t&&(v=t),t>A&&(A=t))}const w=A>v?A-v:0,[S,k]=s.edgeWidthRange??[1,8],_=k-S,M=s.edgeOpacity??.6,P=s.edgeLinecap??"round";return{lines:y,points:u,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:s.lineType||"geo",flowStyle:s.flowStyle||"basic",areas:s.areas,areaStyle:s.areaStyle||Ht,projection:s.projection||"equalEarth",graticule:s.graticule,fitPadding:s.fitPadding,colorScheme:o,lineStyle:e=>{const t=Number(e?.[a]),o=Number.isFinite(t)?t:v,i=S+Math.max(0,Math.min(1,w>0?(o-v)/w:0))*_;return{stroke:b(e),strokeWidth:i,strokeLinecap:P,opacity:M,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...i}}},GeoCustomChart:{frameType:"geo",buildProps:(e,t,o,i,s)=>({points:s.points||e||[],areas:s.areas||[],lines:s.lines||[],projection:s.projection||"equirectangular",xAccessor:s.xAccessor||"lon",yAccessor:s.yAccessor||"lat",lineDataAccessor:s.lineDataAccessor,colorBy:t,colorScheme:o,customLayout:s.layout||s.customLayout,layoutConfig:s.layoutConfig,...i})},GaltonBoardChart:{frameType:"physics",buildProps:(e,t,o,i,r)=>{const n=i.size??[600,400],a=r.bins??21,l=r.seed??1,h=Math.max(1,Math.round(r.pegRows??a-1)),d="mechanical"===r.mode,u=d?c({bins:a,branchProbability:r.branchProbability,count:r.mechanicalCount,pegRows:h,seed:l}):Array.isArray(e)?e:[],p=s({data:u,valueAccessor:r.valueAccessor||"value",bins:a,ballRadius:r.ballRadius??4,seed:l,size:n,valueExtent:d?[0,h]:void 0});return{...i,config:p.config,initialSpawns:ro(p.initialSpawns),projectionRows:p.projectionRows,bodyStyle:g(t||r.colorBy||(d?"side":void 0),"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.valueAccessor||"value"})}}},EventDropChart:{frameType:"physics",buildProps:(e,t,o,s,r)=>{const n=s.size??[600,400],a=i({data:Array.isArray(e)?e:[],timeAccessor:r.timeAccessor||"time",arrivalAccessor:r.arrivalAccessor||"arrivalTime",windows:r.windows||{size:10},watermark:r.watermark,ballRadius:r.ballRadius??5,seed:r.seed??1,size:n,timeExtent:r.timeExtent,timeScale:r.timeScale??1});return{...s,config:a.config,initialSpawns:ro(a.initialSpawns),projectionRows:a.projectionRows,bodyStyle:g(t||r.colorBy,"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.valueAccessor||r.timeAccessor||"time"})}}},PhysicsPileChart:{frameType:"physics",buildProps:(e,t,o,i,s)=>{const r=i.size??[600,400],a="mechanical"===s.mode,c=a?l({categories:s.mechanicalCategories,count:s.mechanicalCount,seed:s.seed??1,unitValue:s.unitValue??1}):Array.isArray(e)?e:[],h=n({data:c,categoryAccessor:s.categoryAccessor||"category",valueAccessor:s.valueAccessor||(a?"value":void 0),unitValue:s.unitValue??1,ballRadius:s.ballRadius??5,seed:s.seed??1,size:r});return{...i,config:h.config,initialSpawns:ro(h.initialSpawns),projectionRows:h.projectionRows,bodyStyle:g(t||s.colorBy||(a?"category":void 0),"#4e79a7",{styleRules:s.styleRules,valueAccessor:s.valueAccessor||"value"})}}},CollisionSwarmChart:{frameType:"physics",buildProps:(e,t,i,s,r)=>{const n=s.size??[600,360],a=o({data:Array.isArray(e)?e:[],xAccessor:r.xAccessor||"x",groupAccessor:r.groupAccessor,radiusAccessor:r.radiusAccessor,pointRadius:r.pointRadius??5,seed:r.seed??1,size:n,xExtent:r.xExtent,collisionIterations:r.collisionIterations,settle:r.settle});return{...s,config:a.config,initialSpawns:ro(a.initialSpawns),projectionRows:a.projectionRows,bodyStyle:g(t||r.colorBy||r.groupAccessor,"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.xAccessor||"x"})}}},ProcessFlowChart:{frameType:"physics",buildProps:(e,t,o,i,s)=>{const r=i.size??[900,420],n=Array.isArray(s.stages)?s.stages:[],c=a({data:Array.isArray(e)?e:[],stages:n,size:r,idAccessor:s.idAccessor,stageAccessor:s.stageAccessor||"stage",groupBy:s.groupBy,groupLabelAccessor:s.groupLabelAccessor,workAccessor:s.workAccessor,radiusAccessor:s.radiusAccessor,ballRadius:s.ballRadius??6,seed:s.seed??1,groupCompletion:s.groupCompletion,groupAnchorAlong:s.groupAnchorAlong,settle:s.settle??!0,gravityX:s.gravityX,gravityY:s.gravityY}),l=c.metadata;return{...i,config:c.config,initialSpawns:ro(c.initialSpawns),projectionRows:c.projectionRows,regionEffects:l?.regionEffects,bodyStyle:g(t||s.colorBy||s.groupBy)}}},GauntletChart:{frameType:"physics",buildProps:(e,t,o,i,s)=>{const r=i.size??[900,520],n=so({data:Array.isArray(e)?e:[],size:r,gates:s.gates,positiveProperties:s.positiveProperties,negativeProperties:s.negativeProperties,crashOffset:s.crashOffset,idAccessor:s.idAccessor,positiveAccessor:s.positiveAccessor,negativeAccessor:s.negativeAccessor,metricsAccessor:s.metricsAccessor,initialViability:s.initialViability,projectPlacement:s.projectPlacement,coreBody:s.coreBody,viability:s.viability});return{...i,config:n.config,initialSpawns:ro(n.initialSpawns),projectionRows:[],bodyStyle:g(t||s.colorBy)}}},PhysicalFlowChart:{frameType:"physics",buildProps:(e,t,o,i,s)=>{const n=i.size??[760,420],a=r({nodes:Array.isArray(s.nodes)?s.nodes:[],links:Array.isArray(s.links)?s.links:Array.isArray(s.edges)?s.edges:Array.isArray(e)?e:[],nodeIdAccessor:s.nodeIdAccessor||"id",nodeXAccessor:s.nodeXAccessor||"x",nodeYAccessor:s.nodeYAccessor||"y",sourceAccessor:s.sourceAccessor||"source",targetAccessor:s.targetAccessor||"target",throughputAccessor:s.throughputAccessor||"value",pathAccessor:s.pathAccessor||"path",coordinateMode:s.coordinateMode||"auto",particleRate:s.particleRate??.16,maxParticles:s.maxParticles??180,particleRadius:s.particleRadius??4,flowSpeed:s.flowSpeed??90,pathConstraint:s.pathConstraint||"path",reducedMotion:!0,seed:s.seed??1,size:n});return{...i,config:a.config,initialSpawns:ro(a.initialSpawns),projectionRows:a.projectionRows,bodyStyle:g(t||s.colorBy||"source")}}},PhysicsCustomChart:{frameType:"physics",buildProps:(e,t,o,i,s)=>{const r=i.size??[700,380],n=u({chartId:s.chartId,colorScheme:o,config:s.config,data:Array.isArray(e)?e:[],layout:s.layout,layoutConfig:s.layoutConfig,semantic:Ue(qe)??{},size:r,themeCategorical:qe.colors.categorical,xExtent:s.xExtent,yExtent:s.yExtent});return{...i,config:n.config,initialSpawns:ro(n.initialSpawns),projectionRows:[],bodyStyle:n.result.bodyStyle??g(t||s.colorBy)}}}};function ao(e){const t=e instanceof Date?e.getTime():"number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function co(e){if(!e||2>e.length)return;const t=ao(e[0]),o=ao(e[e.length-1]);return null!==t&&null!==o?[t,o]:void 0}function lo(e){const{count:t,byType:o}=function(e){const t={};for(const o of e){const e="string"==typeof o?.type&&o.type.length>0?o.type:"node";t[e]=(t[e]??0)+1}return{count:e.length,byType:t}}(e.marks),i=0===t,s=[...e.extraWarnings??[]];return i&&!s.includes("EMPTY_SCENE")&&s.push("EMPTY_SCENE"),{component:"",frameType:e.frameType,status:i?"empty":"ok",empty:i,markCount:t,markCountByType:o,width:e.width,height:e.height,...e.xDomain?{xDomain:e.xDomain}:{},...e.yDomain?{yDomain:e.yDomain}:{},...e.categories?{categories:e.categories}:{},...void 0!==e.nodeCount?{nodeCount:e.nodeCount}:{},...void 0!==e.edgeCount?{edgeCount:e.edgeCount}:{},...void 0!==e.legendItems?{legendItems:e.legendItems}:{},annotationCount:Array.isArray(e.annotations)?e.annotations.length:0,ariaLabel:"string"==typeof e.description&&e.description||"string"==typeof e.title&&e.title||`${e.frameType} chart, ${t} marks`,warnings:s}}import*as ho from"react";import*as uo from"react-dom/server";import{scaleOrdinal as go}from"d3-scale";import{jsx as po,jsxs as fo}from"react/jsx-runtime";var yo=H;function mo(e,t,o){if(t&&"object"==typeof t&&!Array.isArray(t)){const e=t;return t=>Se(e,t)??"#999"}const i=Array.isArray(t)?t:o.colors.categorical.length>0?o.colors.categorical:Ie;return go().domain(e).range(i)}function xo(e){return"left"===e?"start":"right"===e?"end":e??"start"}function bo(e){return Number(e.typography.legendSize??e.typography.labelSize??e.typography.tickSize)||11}function vo(e,t,o,i){const s=bo(i);return t+o+Math.ceil(e.length*s*.58)}function Ao(e){const{categories:t,theme:o,position:i="right",totalWidth:s,margin:r,legendLayout:n}=e,{swatchSize:a,labelGap:c,itemGap:l,rowHeight:h}=ke(n),d=a+c,u="top"===i||"bottom"===i,g=Math.max(a,s-r.left-r.right),p=t.map(e=>vo(e,a,c,o));if(u){const e=Math.max(a,n?.maxWidth??g),o=[];let i=0,s=0;p.forEach((t,r)=>{const n=0===s?t:s+l+t;s>0&&n>e?(o.push({start:i,end:r,width:s}),i=r,s=t):s=n}),t.length>0&&o.push({start:i,end:t.length,width:s});const r=xo(n?.align),c=[];return o.forEach((o,i)=>{let s="center"===r?Math.max(0,(e-o.width)/2):"end"===r?Math.max(0,e-o.width):0;for(let e=o.start;o.end>e;e++)c.push({category:t[e],width:p[e],x:s,y:i*h}),s+=p[e]+l}),{items:c,width:Math.max(0,...o.map(e=>e.width)),height:o.length*h,swatchSize:a,labelOffset:d,swatchRadius:0}}const f=Math.max(0,...p);return{items:t.map((e,t)=>({category:e,width:p[t],x:0,y:t*h})),width:f,height:t.length*h,swatchSize:a,labelOffset:d,swatchRadius:0}}function wo(e){const{legendGroups:t,theme:o,position:i="right",totalWidth:s,margin:r,legendLayout:n}=e,{swatchSize:a,labelGap:c,rowHeight:l}=ke(n),h=a+c,d=Math.max(12,bo(o)),u="top"===i||"bottom"===i,g=Math.max(a,s-r.left-r.right);if(u){const i=Math.max(a,n?.maxWidth??g),s=xo(n?.align);let r=0,c=0;const l=[];for(const s of t){const t=s.items.map(e=>e.label),h=Ao({...e,categories:t,legendLayout:{...n,maxWidth:Math.max(a,i-d-8),align:"start"}}),u=s.label?d:0,g=s.label?vo(s.label,0,0,o):0,p=u>0?u+8:0,f=p+h.width,y=Math.max(h.height,g);l.push({group:s,x:r,y:0,itemOffsetX:p,itemOffsetY:0,width:f,height:y,items:h.items}),r+=f+12,c=Math.max(c,y)}const u=l.length>0?r-12:0,p=u>i?0:"center"===s?Math.max(0,(i-u)/2):"end"===s?Math.max(0,i-u):0;return{groups:l.map(e=>({...e,x:e.x+p})),width:u,height:c,swatchSize:a,labelOffset:h,swatchRadius:0}}const p=de(t.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),l);let f=0;return{groups:t.map((e,t)=>{const i=e.items.map(e=>vo(e.label,a,c,o)),s=Math.max(0,...i,e.label?vo(e.label,0,0,o):0);return f=Math.max(f,s),{group:e,x:0,y:p[t].itemsY,itemOffsetX:0,itemOffsetY:0,width:s,height:e.items.length*l,items:e.items.map((e,t)=>({category:e.label,width:i[t],x:0,y:t*l}))}}),width:f,height:p.at(-1)?.endY??0,swatchSize:a,labelOffset:h,swatchRadius:0}}function So(e){const t="top"===e.position||"bottom"===e.position,o=Math.max(1,e.totalWidth-e.margin.left-e.margin.right);return t?{width:Math.min(e.legendLayout?.maxWidth??o,200),height:e.gradient.label?34:26,swatchSize:12}:{width:e.gradient.label?86:72,height:e.gradient.label?124:108,swatchSize:14}}function ko(e,t){if(!t||!e||0===e.length)return[];const o="function"==typeof t?t:e=>e[t],i=new Set;for(const t of e){const e=o(t);null!=e&&i.add(e+"")}return Array.from(i)}import{jsx as _o,jsxs as Mo}from"react/jsx-runtime";var Po=16;function To(e,t){return e.color||t.colors.annotation||t.colors.text}function Ro(e,t,o){const i=e.labelBackground,s=t.colors.background;return void 0===i?"none"===o?"none":{type:"halo",fill:s}:!1===i||"none"===i?"none":!0===i||"halo"===i?{type:"halo",fill:s}:"box"===i?{type:"box",fill:s}:{fill:s,...i}}function Lo(e,t,o){return null!=e.x&&t.x?t.x(e.x):o&&null!=e[o]&&t.x?t.x(e[o]):"number"==typeof e.x?e.x:null}function zo(e,t,o){return null!=e.y&&t.y?t.y(e.y):o&&null!=e[o]&&t.y?t.y(e[o]):"number"==typeof e.y?e.y:null}function Co(e){const{annotations:t}=e;if(!t||0===t.length)return null;const o=e.autoPlaceAnnotations?Ce({annotations:t,context:{scales:{x:e.scales.x,y:e.scales.y,time:e.scales.x,value:e.scales.y,o:e.scales.o,geoProjection:e.scales.geoProjection},width:e.layout.width,height:e.layout.height,xAccessor:e.xAccessor,yAccessor:e.yAccessor,frameType:e.projection?"ordinal":"xy",projection:"horizontal"===e.projection?"horizontal":"vertical"},..."object"==typeof e.autoPlaceAnnotations?e.autoPlaceAnnotations:{}}):t,i=[];for(let t=0;o.length>t;t++){const s=Fo(o[t],t,e);s&&i.push({node:s,annotation:o[t]})}const s=U(i);return s.length>0?_o("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:s}):null}function Fo(e,t,o){const{scales:i,layout:s,theme:r,xAccessor:n,yAccessor:a}=o;switch(e.type){case"y-threshold":{const n=e.value;if(null==n)return null;const a=To(e,r),c=e.label,l=e.labelPosition||"right",h=e.strokeDasharray||"6,4",d=e.strokeWidth??1.5;if("horizontal"===o.projection&&i.r){const o=i.r(n);return null==o?null:Mo("g",{opacity:e.opacity,children:[_o("line",{x1:o,y1:0,x2:o,y2:s.height,stroke:a,strokeWidth:d,strokeDasharray:h}),c&&_o(V,{x:o+4,y:Po,textAnchor:"start",fontSize:r.typography.tickSize,fill:a,fontFamily:r.typography.fontFamily,text:c,background:Ro(e,r,"halo")})]},"ann-ythresh-"+t)}const u=i.y?i.y(n):i.r?i.r(n):null;return null==u?null:Mo("g",{children:[_o("line",{x1:0,y1:u,x2:s.width,y2:u,stroke:a,strokeWidth:d,strokeDasharray:h}),c&&_o(V,{x:"left"===l?4:"center"===l?s.width/2:s.width-4,y:20>u?Math.min(s.height-4,u+Po):u-6,textAnchor:"left"===l?"start":"center"===l?"middle":"end",fontSize:r.typography.tickSize,fill:a,fontFamily:r.typography.fontFamily,text:c,background:Ro(e,r,"halo")})]},"ann-ythresh-"+t)}case"x-threshold":{const o=e.value;if(null==o||!i.x)return null;const n=i.x(o);if(null==n)return null;const a=To(e,r),c=e.label,l=e.labelPosition||"top";return Mo("g",{opacity:e.opacity,children:[_o("line",{x1:n,y1:0,x2:n,y2:s.height,stroke:a,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray||"6,4"}),c&&_o(V,{x:n>.6*s.width?n-4:n+4,y:"bottom"===l?s.height-4:"center"===l?s.height/2:Po,textAnchor:n>.6*s.width?"end":"start",fontSize:r.typography.tickSize,fill:a,fontFamily:r.typography.fontFamily,text:c,background:Ro(e,r,"halo")})]},"ann-xthresh-"+t)}case"band":{const o=null!=e.y0&&i.y?i.y(e.y0):null,n=null!=e.y1&&i.y?i.y(e.y1):null;if(null==o||null==n)return null;const a=Math.min(o,n),c=Math.abs(n-o),l=Re(e.fill||To(e,r),"ssr-band-"+t),h=e.fillOpacity??.1;return Mo("g",{opacity:e.opacity,children:[l.def&&_o("defs",{children:l.def}),_o("rect",{x:0,y:a,width:s.width,height:c,fill:l.fill,fillOpacity:h}),e.label&&_o(V,{x:s.width-4,y:Math.max(a,0)+Po,textAnchor:"end",fontSize:r.typography.tickSize,fill:e.color||To(e,r),fontFamily:r.typography.fontFamily,fontWeight:"bold",text:e.label,background:Ro(e,r,"halo")})]},"ann-band-"+t)}case"x-band":{const o=null!=e.x0&&i.x?i.x(e.x0):null,n=null!=e.x1&&i.x?i.x(e.x1):null;if(null==o||null==n)return null;const a=Math.min(o,n),c=Math.abs(n-o),l=Re(e.fill||To(e,r),"ssr-xband-"+t),h=e.fillOpacity??.1;return Mo("g",{opacity:e.opacity,children:[l.def&&_o("defs",{children:l.def}),_o("rect",{x:a,y:0,width:c,height:s.height,fill:l.fill,fillOpacity:h}),e.label&&_o(V,{x:a+4,y:Po,textAnchor:"start",fontSize:r.typography.tickSize,fill:e.color||To(e,r),fontFamily:r.typography.fontFamily,fontWeight:"bold",text:e.label,background:Ro(e,r,"halo")})]},"ann-xband-"+t)}case"category-highlight":{if(null==e.category||!i.o)return null;const n=i.o(e.category+"");if(null==n)return null;const a=i.o.bandwidth?i.o.bandwidth():40,c=To(e,r),l=e.opacity??.1,h=e.label;return Mo("g","horizontal"===o.projection?{children:[_o("rect",{x:0,y:n,width:s.width,height:a,fill:c,opacity:l}),h&&_o(V,{x:12,y:n+a/2,dominantBaseline:"middle",fill:c,fontSize:r.typography.tickSize,fontWeight:"bold",fontFamily:r.typography.fontFamily,text:h,background:Ro(e,r,"none")})]}:{children:[_o("rect",{x:n,y:0,width:a,height:s.height,fill:c,opacity:l}),h&&_o(V,{x:n+a/2,y:Po,textAnchor:"middle",fill:c,fontSize:r.typography.tickSize,fontWeight:"bold",fontFamily:r.typography.fontFamily,text:h,background:Ro(e,r,"none")})]},"ann-cathighlight-"+t)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{const{x:o,y:s}=function(e,t,o,i){if(Array.isArray(e.coordinates)&&e.coordinates.length>=2&&t.geoProjection){const o=t.geoProjection([e.coordinates[0],e.coordinates[1]]);if(o)return{x:o[0],y:o[1]}}return{x:Lo(e,t,o),y:zo(e,t,i)}}(e,i,n,a);if(null==o||null==s)return null;const c="text"===e.type,l=e.dx??(c?0:30),h=e.dy??(c?0:-30),d=e.color||r.colors.text;if(!c){const i="callout"===e.type?"callout-circle":e.type,r="callout-circle"===i?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===i?{width:e.width,height:e.height}:void 0;return _o(Q,{noteData:{x:o,y:s,dx:l,dy:h,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:i,...r?{subject:r}:{},connector:e.connector||{end:"arrow"},color:d,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-label-"+t)}return _o("g",{children:_o("text",{x:o+l,y:s+h,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||r.typography.labelSize,fill:d,fontFamily:r.typography.fontFamily,fontWeight:e.fontWeight,opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:e.label||e.title})},"ann-label-"+t)}default:return null}}import*as Bo from"react";import{jsx as Oo,jsxs as Eo}from"react/jsx-runtime";function jo(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){const t=e.id;return null==t?null:t+""}return null}function Do(e){const t=e._idPrefix||e.chartId;if(t){const e=(t+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(e)?e:"c"+e}const o=`${e.chartType||""}:${e.title||""}:${Array.isArray(e.data)?e.data.length:0}`;let i=0;for(let e=0;o.length>e;e++)i=31*i+o.charCodeAt(e)|0;return"c"+(i>>>0).toString(36)}function No(e,t,o){const i=e.showLegend&&!e.__legendIncludesAutomatic?function(e,t,o){if(0===e.length)return;const i=mo(e,t,o);return{legendGroups:[{label:"",type:"fill",items:e.map(e=>({label:e})),styleFn:e=>({fill:i(e.label)})}]}}(t,e.colorScheme,o):void 0;return J(i,e.legend)}var Wo={right:110,left:110,top:50,bottom:80};function $o(e,t){if(e.__autoLegendMargin&&!Io(e,t))return Wo[t]}function Io(e,t){const o=e.__explicitMargin;return"number"==typeof o||!(!o||"object"!=typeof o||"number"!=typeof o[t])}function Go(e,t){const{props:o,categories:i,theme:s,size:r,hasTitle:n}=t,a=o.legendPosition||"right",c={theme:s,position:a,size:r,hasTitle:n,legendLayout:o.legendLayout,minimumMargin:$o(o,a),preserveExplicitMargin:Io(o,a)};if(null!=o.legend){const t=No(o,i,s);(he(t)||le(t))&&function(e,t){if(t.preserveExplicitMargin)return;const o=t.position||"right",i={theme:t.theme,position:o,totalWidth:t.size[0],totalHeight:t.size[1],margin:e,hasTitle:t.hasTitle,legendLayout:t.legendLayout},s=he(t.legend)?function(e){const{width:t,height:o,swatchSize:i}=wo(e);return{width:t,height:o,swatchSize:i}}({...i,legendGroups:t.legend.legendGroups}):le(t.legend)?So({...i,gradient:t.legend.gradient}):null;if(!s)return;const r=t.minimumMargin??s.width+14,n=t.minimumMargin??(t.hasTitle?32:8)+s.height+4,a=t.minimumMargin??38+s.height+4;"right"===o?e.right=Math.max(e.right,r):"left"===o?e.left=Math.max(e.left,r):"top"===o?e.top=Math.max(e.top,n):e.bottom=Math.max(e.bottom,a)}(e,{...c,legend:t})}else o.showLegend&&i.length>0&&function(e,t){if(0===t.categories.length)return;if(t.preserveExplicitMargin)return;const o=t.position||"right",i=function(e){const{width:t,height:o,swatchSize:i}=Ao(e);return{width:t,height:o,swatchSize:i}}({categories:t.categories,colorScheme:t.colorScheme,theme:t.theme,position:o,totalWidth:t.size[0],totalHeight:t.size[1],margin:e,hasTitle:t.hasTitle,legendLayout:t.legendLayout}),s=t.minimumMargin??i.width+14,r=t.minimumMargin??(t.hasTitle?32:8)+i.height+4,n=t.minimumMargin??38+i.height+4;"right"===o?e.right=Math.max(e.right,s):"left"===o?e.left=Math.max(e.left,s):"top"===o?e.top=Math.max(e.top,r):e.bottom=Math.max(e.bottom,n)}(e,{...c,categories:i,colorScheme:o.colorScheme});return a}function Yo(e){const{props:t,categories:o,theme:i,size:s,margin:r,hasTitle:n}=e,a=t.legendPosition||"right",c={theme:i,position:a,size:s,margin:r,hasTitle:n,legendLayout:t.legendLayout,idPrefix:t._idPrefix,reservedWidth:t.__autoLegendMargin?100:void 0};if(null!=t.legend){const e=No(t,o,i);if(Bo.isValidElement(e))return e;const s=function(e,t){const o={theme:t.theme,position:t.position||"right",totalWidth:t.size[0],totalHeight:t.size[1],margin:t.margin,hasTitle:t.hasTitle,legendLayout:t.legendLayout,idPrefix:t.idPrefix,reservedWidth:t.reservedWidth};return he(e)?function(e){if(0===(t=e.legendGroups,t.flatMap(e=>e.items.map((t,o)=>({group:e,item:t,itemIndex:o,label:t.label})))).length)return null;var t;const o=wo(e),i="top"===e.position||"bottom"===e.position,s=e.theme.colors.grid||e.theme.colors.textSecondary;let r,n;if("left"===e.position?(r=Math.max(4,e.margin.left-(e.reservedWidth??100)-10),n=e.margin.top):"top"===e.position?(r=e.margin.left,n=e.hasTitle?32:8):"bottom"===e.position?(r=e.margin.left,n=e.totalHeight-e.margin.bottom+38):(r=e.totalWidth-e.margin.right+10,n=e.margin.top),!i){const t=de(e.legendGroups.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),Math.max(o.swatchSize,e.legendLayout?.rowHeight??yo)),i=e.legendGroups.flatMap((i,s)=>{const r=t[s],n=i.type??"fill",a=[po("line",{x1:0,y1:r.lineY,x2:e.reservedWidth??100,y2:r.lineY,stroke:"gray"},"legend-group-neatline-"+s)];return i.label&&null!=r.labelY&&a.push(po("text",{y:r.labelY,fontSize:bo(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:i.label},"legend-group-label-"+s)),a.push(po("g",{transform:`translate(0,${r.itemsY})`,children:i.items.map((t,r)=>{const a=i.styleFn(t,r),c="function"==typeof n?n(t):"line"===n?po("line",{x1:0,y1:0,x2:o.swatchSize,y2:o.swatchSize,style:a}):po("rect",{width:o.swatchSize,height:o.swatchSize,rx:o.swatchRadius,style:a});return fo("g",{transform:`translate(0,${r*Math.max(o.swatchSize,e.legendLayout?.rowHeight??yo)})`,children:[c,po("text",{x:o.labelOffset,y:o.swatchSize/2,dominantBaseline:"central",fontSize:bo(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:t.label})]},`legend-${s}-${r}`)})},"legend-group-"+s)),a});return po("g",{className:"semiotic-legend",transform:`translate(${r},${n})`,"data-orientation":"vertical",children:i})}const a=o.groups.flatMap((t,r)=>{const{group:n}=t,a=n.type??"fill",c=[];if(n.label&&c.push(po("text",i?{transform:`translate(${t.x},${t.y}) rotate(90)`,textAnchor:"start",fontSize:bo(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:n.label}:{x:t.x,y:t.y+bo(e.theme),fontSize:bo(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:n.label},"legend-group-label-"+r)),c.push(...t.items.map((i,s)=>{const c=n.items[s],l=n.styleFn(c,s),h="function"==typeof a?a(c):"line"===a?po("line",{x1:0,y1:0,x2:o.swatchSize,y2:o.swatchSize,style:l}):po("rect",{width:o.swatchSize,height:o.swatchSize,rx:o.swatchRadius,style:l});return fo("g",{transform:`translate(${t.x+t.itemOffsetX+i.x},${t.y+t.itemOffsetY+i.y})`,children:[h,po("text",{x:o.labelOffset,y:o.swatchSize/2,dominantBaseline:"central",fontSize:bo(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:i.category})]},`legend-${r}-${s}`)})),i&&o.groups.length-1>r){const e=t.x+t.width+6;c.push(po("line",{x1:e,y1:0,x2:e,y2:o.height,stroke:s},"legend-group-separator-"+r))}return c});return po("g",{className:"semiotic-legend",transform:`translate(${r},${n})`,"data-orientation":i?"horizontal":"vertical",children:a})}({...o,legendGroups:e.legendGroups}):le(e)?function(e){const t=So(e),o="top"===e.position||"bottom"===e.position,i=(e.idPrefix?e.idPrefix+"-":"")+"semiotic-static-gradient-legend",s=e.gradient.format||(e=>Math.round(100*e)/100+"");let r,n;"left"===e.position?(r=Math.max(4,e.margin.left-100-10),n=e.margin.top):"top"===e.position?(r=e.margin.left,n=e.hasTitle?32:8):"bottom"===e.position?(r=e.margin.left,n=e.totalHeight-e.margin.bottom+38):(r=e.totalWidth-e.margin.right+10,n=e.margin.top);const a=Array.from({length:17},(t,i)=>{const s=i/16;return po("stop",{offset:100*s+"%",stopColor:e.gradient.colorFn(o?e.gradient.domain[0]+s*(e.gradient.domain[1]-e.gradient.domain[0]):e.gradient.domain[1]-s*(e.gradient.domain[1]-e.gradient.domain[0]))},i)});if(o){const o=12,c=e.gradient.label?0:void 0,l=e.gradient.label?8:0;return fo("g",{className:"semiotic-legend",transform:`translate(${r},${n})`,children:[po("defs",{children:po("linearGradient",{id:i,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:a})}),e.gradient.label&&po("text",{x:t.width/2,y:c,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:e.gradient.label}),po("rect",{x:0,y:l,width:t.width,height:o,fill:`url(#${i})`,rx:2}),po("text",{x:0,y:l+o+12,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:s(e.gradient.domain[0])}),po("text",{x:t.width,y:l+o+12,textAnchor:"end",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:s(e.gradient.domain[1])})]})}const c=e.gradient.label?-6:void 0;return fo("g",{className:"semiotic-legend",transform:`translate(${r},${n+(e.gradient.label?12:0)})`,children:[po("defs",{children:po("linearGradient",{id:i,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:a})}),e.gradient.label&&po("text",{x:7,y:c,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:e.gradient.label}),po("rect",{x:0,y:0,width:14,height:100,fill:`url(#${i})`,rx:2}),po("text",{x:19,y:10,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:s(e.gradient.domain[1])}),po("text",{x:19,y:100,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:s(e.gradient.domain[0])})]})}({...o,gradient:e.gradient}):null}(e,c);return s||(he(e)||le(e)?null:e??null)}return t.showLegend&&0!==o.length?function(e){const{categories:t,colorScheme:o,theme:i,position:s="right",totalWidth:r,totalHeight:n,margin:a,hasTitle:c=!1}=e;if(!t||0===t.length)return null;const l=mo(t,o,i),h="top"===s||"bottom"===s,d=Ao(e);let u,g;if("left"===s?(u=Math.max(4,a.left-(e.reservedWidth??100)-10),g=a.top):"top"===s?(u=a.left,g=c?32:8):"bottom"===s?(u=a.left,g=n-a.bottom+38):(u=r-a.right+10,g=a.top),h){const e=d.items.map((e,t)=>fo("g",{transform:`translate(${e.x},${e.y})`,children:[po("rect",{width:d.swatchSize,height:d.swatchSize,fill:l(e.category),rx:d.swatchRadius}),po("text",{x:d.labelOffset,y:d.swatchSize/2,dominantBaseline:"central",fontSize:bo(i),fill:i.colors.text,fontFamily:i.typography.fontFamily,children:e.category})]},"legend-"+t));return po("g",{className:"semiotic-legend",transform:`translate(${u},${g})`,children:e})}const p=de([{hasLabel:!1,itemCount:t.length}],Math.max(d.swatchSize,e.legendLayout?.rowHeight??yo))[0],f=d.items.map((e,t)=>fo("g",{transform:`translate(${e.x},${e.y+p.itemsY})`,children:[po("rect",{width:d.swatchSize,height:d.swatchSize,fill:l(e.category),rx:d.swatchRadius}),po("text",{x:d.labelOffset,y:d.swatchSize/2,dominantBaseline:"central",fontSize:bo(i),fill:i.colors.text,fontFamily:i.typography.fontFamily,children:e.category})]},"legend-"+t));return fo("g",{className:"semiotic-legend",transform:`translate(${u},${g})`,children:[po("line",{x1:0,y1:p.lineY,x2:e.reservedWidth??100,y2:p.lineY,stroke:"gray"}),f]})}({categories:o,colorScheme:t.colorScheme,theme:i,position:a,totalWidth:s[0],totalHeight:s[1],margin:r,hasTitle:n,legendLayout:t.legendLayout,reservedWidth:t.__autoLegendMargin?100:void 0,idPrefix:t._idPrefix}):null}function Vo(e){return Math.round(100*e)/100+""}function Xo(e,t){const o=st(t.theme),i=t.background??o.background,s=t.idPrefix?t.idPrefix+"-":"",r="string"==typeof t.title?t.title:void 0,n=r?s+"semiotic-title":void 0,a=t.description?s+"semiotic-desc":void 0,c=[n,a].filter(Boolean).join(" ")||void 0;return Eo("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className,width:t.width,height:t.height,role:"img","aria-labelledby":c,style:{fontFamily:o.fontFamily},children:[r&&Oo("title",{id:n,children:r}),t.description&&Oo("desc",{id:a,children:t.description}),t.defs&&Oo("defs",{children:t.defs}),i&&"transparent"!==i&&Oo("rect",{x:0,y:0,width:t.width,height:t.height,fill:i}),Oo("g",{id:s+"data-area",transform:t.innerTransform,children:e}),r&&Oo("text",{id:s+"chart-title",x:t.width/2,y:Z,textAnchor:"middle",fontSize:o.titleSize,fontWeight:"bold",fill:o.text,fontFamily:o.fontFamily,children:r}),t.legend&&Oo("g",{id:s+"legend",children:t.legend}),t.outerElements]})}import{Fragment as Ho,jsx as qo,jsxs as Qo}from"react/jsx-runtime";function Zo(e,t){const o=it(e.theme),i=e.size||[500,300],s=xe({top:20,right:20,bottom:30,left:40,...e.margin},e.title),r=ae(e.title),n=ie(e.data),a=e.showLegend?ko(n,e.colorAccessor||e.groupAccessor||e.categoryAccessor):[];Go(s,{props:e,categories:a,theme:o,size:i,hasTitle:r});const c=i[0]-s.left-s.right,l=i[1]-s.top-s.bottom,h="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),d=e.colorScheme||o.colors.categorical,u={chartType:e.chartType,windowSize:e.windowSize??200,windowMode:e.windowMode??"sliding",arrowOfTime:h?e.arrowOfTime??"right":"right",extentPadding:e.extentPadding??.1,xAccessor:h?void 0:e.xAccessor,yAccessor:h?void 0:e.yAccessor,timeAccessor:h?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,groupAccessor:e.groupAccessor,categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,axisExtent:e.axisExtent,sizeRange:e.sizeRange,xScaleType:e.xScaleType,yScaleType:e.yScaleType,scalePadding:e.scalePadding,binSize:e.binSize,normalize:e.normalize,stackOrder:e.stackOrder,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,y0Accessor:e.y0Accessor,areaGroups:e.areaGroups?e.areaGroups instanceof Set?e.areaGroups:new Set(e.areaGroups):void 0,curve:e.curve,gradientFill:!0===e.gradientFill?{topOpacity:.8,bottomOpacity:.05}:!1===e.gradientFill?void 0:e.gradientFill,lineGradient:e.lineGradient,openAccessor:e.openAccessor,highAccessor:e.highAccessor,lowAccessor:e.lowAccessor,closeAccessor:e.closeAccessor,candlestickStyle:e.candlestickStyle,lineStyle:e.lineStyle,pointStyle:e.pointStyle,areaStyle:e.areaStyle,barStyle:e.barStyle,waterfallStyle:e.waterfallStyle,swarmStyle:e.swarmStyle,colorScheme:d,themeCategorical:o.colors.categorical,themeSemantic:Ue(o),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:s,layoutSelection:e.layoutSelection,barColors:e.barColors,showValues:e.showValues,heatmapValueFormat:e.heatmapValueFormat},g=new w(u);if(e.data&&g.ingest({inserts:n,bounded:!0}),g.computeScene({width:c,height:l}),!g.scales||0===g.scene.length)return t&&(t.evidence=lo({frameType:"xy",width:i[0],height:i[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,extraWarnings:g.scales?[]:["NO_SCALES"]})),uo.renderToStaticMarkup(Xo(null,{width:i[0],height:i[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${s.left},${s.top})`,innerWidth:c,innerHeight:l,idPrefix:e._idPrefix}));const p=e._idPrefix,f=E({nodes:g.scene,renderMode:e.renderMode,fallback:(e,t)=>_e(e,t,p)});t&&(t.evidence=lo({frameType:"xy",width:i[0],height:i[1],marks:f.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,xDomain:co(g.scales.x?.domain?.()),yDomain:co(g.scales.y?.domain?.()),legendItems:a.length>0?a.length:void 0}));const y=e.showGrid?function(e,t,o,i,s){const{grid:r}=st(o),n=i?i+"-":"",a="exact"===s?5:Math.min(5,Math.max(2,Math.floor(t.width/70))),c="exact"===s?5:Math.min(5,Math.max(2,Math.floor(t.height/30))),l=W(e.x,a,s),h=W(e.y,c,s);return Eo("g",{id:n+"grid",className:"semiotic-grid",opacity:.8,children:[l.map((o,i)=>{const s=e.x(o);return Oo("line",{x1:s,y1:0,x2:s,y2:t.height,stroke:r,strokeWidth:.5},"gx-"+i)}),h.map((o,i)=>{const s=e.y(o);return Oo("line",{x1:0,y1:s,x2:t.width,y2:s,stroke:r,strokeWidth:.5},"gy-"+i)})]})}(g.scales,{width:c,height:l},o,p,e.axisExtent):null,m=f.map(e=>e.element),x=Do(e)+"-plot-clip",b=!1!==e.showAxes?function(e,t,o,i,s){const r=st(i),n="exact"===o.axisExtent?5:Math.min(5,Math.max(2,Math.floor(t.width/70))),a="exact"===o.axisExtent?5:Math.min(5,Math.max(2,Math.floor(t.height/30))),c=W(e.x,n,o.axisExtent).map(t=>({pixel:e.x(t),label:(o.xFormat||o.tickFormatTime||Vo)(t)})),l=W(e.y,a,o.axisExtent).map(t=>({pixel:e.y(t),label:(o.yFormat||o.tickFormatValue||Vo)(t)}));return Eo("g",{id:(s?s+"-":"")+"axes",className:"stream-axes",children:[Oo("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:r.border,strokeWidth:1}),c.map((e,o)=>Eo("g",{transform:`translate(${e.pixel},${t.height})`,children:[Oo("line",{y2:5,stroke:r.border,strokeWidth:1}),Oo("text",{y:18,textAnchor:"middle",fontSize:r.tickSize,fill:r.textSecondary,fontFamily:r.fontFamily,children:e.label})]},"xtick-"+o)),o.xLabel&&Oo("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:r.labelSize,fill:r.text,fontFamily:r.fontFamily,children:o.xLabel}),Oo("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:r.border,strokeWidth:1}),l.map((e,t)=>Eo("g",{transform:`translate(0,${e.pixel})`,children:[Oo("line",{x2:-5,stroke:r.border,strokeWidth:1}),Oo("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:r.tickSize,fill:r.textSecondary,fontFamily:r.fontFamily,children:e.label})]},"ytick-"+t)),o.yLabel&&Oo("text",{x:15-(o.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:r.labelSize,fill:r.text,fontFamily:r.fontFamily,transform:`rotate(-90, ${15-(o.margin?.left??40)}, ${t.height/2})`,children:o.yLabel})]})}(g.scales,{width:c,height:l},e,o,p):null,v=e.annotations?Co({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{x:g.scales.x,y:g.scales.y},layout:{width:c,height:l},theme:o,xAccessor:"string"==typeof e.xAccessor?e.xAccessor:void 0,yAccessor:"string"==typeof e.yAccessor?e.yAccessor:void 0,idPrefix:p}):null,A=e.svgPreRenderers&&g.scales?e.svgPreRenderers.map((e,t)=>{try{return qo(ho.Fragment,{children:e(g.scene,g.scales,{width:c,height:l})},"pre-"+t)}catch{return null}}).filter(Boolean):null,S=Yo({props:e,categories:a,theme:o,size:i,margin:s,hasTitle:r});return uo.renderToStaticMarkup(Xo(Qo(Ho,{children:[e.backgroundGraphics,A,y,qo("defs",{children:qo("clipPath",{id:x,children:qo("rect",{x:0,y:0,width:c,height:l})})}),qo("g",{clipPath:`url(#${x})`,children:m}),b,v,e.foregroundGraphics,g.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${s.left},${s.top})`,innerWidth:c,innerHeight:l,legend:S,idPrefix:e._idPrefix}))}import*as Uo from"react-dom/server";import{scaleBand as Ko,scaleLinear as Jo}from"d3-scale";var ei=class{constructor(){this.colorSchemeMap=new Map,this.colorSchemeIndex=0}resetColors(){this.colorSchemeMap.clear(),this.colorSchemeIndex=0}resolvePieceStyle(e,t,o){if(t&&"function"==typeof e.pieceStyle){const i=e.pieceStyle(t,o);return i&&!i.fill&&o?{...i,fill:this.getColorFromScheme(e,o)}:i}return e.pieceStyle&&"object"==typeof e.pieceStyle?e.pieceStyle:e.barColors&&o?{fill:e.barColors[o]||"#007bff"}:{fill:o?this.getColorFromScheme(e,o):"#007bff"}}resolveSummaryStyle(e,t,o){return t&&"function"==typeof e.summaryStyle?e.summaryStyle(t,o):e.summaryStyle&&"object"==typeof e.summaryStyle?e.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}getColorFromScheme(e,t){const o=this.colorSchemeMap.get(t);if(o)return o;const i=Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical||q,s=i[this.colorSchemeIndex%i.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(t,s),s}};function ti(e){const t=e.getSymbol;if(!t)return null;const o=e.config.symbolMap,i=new Map;let s=0;return e=>{const r=t(e)+"",n=o?.[r];if(n)return n;let a=i.get(r);return a||(a=Le[s%Le.length],s++,i.set(r,a)),a}}function oi(e,t,o,i,s,r,n){e.push(t?{type:"symbol",x:i,y:s,size:Math.PI*r*r,symbolType:t(o),style:n,datum:o}:{type:"point",x:i,y:s,r:r,style:n,datum:o})}function ii(e,t){const{columns:o,config:i,resolvePieceStyle:s}=e,r=[],n=Math.min(t.width,t.height)/2-4,a="donut"===i.chartType?i.innerRadius||60:0,c=-Math.PI/2+(i.startAngle||0)*Math.PI/180,l=null!=i.sweepAngle?i.sweepAngle*Math.PI/180:2*Math.PI,h=null!=i.sweepAngle&&360>i.sweepAngle,d=Object.values(o),u=d.some(e=>{const t=e.pieceData[0];return t&&("number"==typeof t._pct||"number"==typeof t._pctStart||null!=t._roundedEnds)}),g=h&&!u&&d.length>1&&(i.cornerRadius??0)>0;for(let e=0;d.length>e;e++){const t=d[e],o=t.pieceData[0],h="number"==typeof o?._pctStart?o._pctStart:t.pctStart,u=c+h*l,p=c+(h+("number"==typeof o?._pct?o._pct:t.pct))*l,f=s(t.pieceData[0],t.name),y=0===e,m=e===d.length-1,x={type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:n,startAngle:u,endAngle:p,...i.cornerRadius&&{cornerRadius:i.cornerRadius},style:f,datum:o?._nonInteractive?null:t.pieceData,category:t.name};o?._roundedEnds?x.roundedEnds=o._roundedEnds:g&&(x.roundedEnds={start:y,end:m}),o?._gradientBand&&(x._gradientBand=o._gradientBand),r.push(x)}return r}import{quantile as si}from"d3-array";function ri(e){const t=e.length,o=e[0],i=e[t-1];return{n:t,min:o,q1:si(e,.25)??o,median:si(e,.5)??(o+i)/2,q3:si(e,.75)??i,max:i,mean:e.reduce((e,t)=>e+t,0)/t}}import{scaleLinear as ni}from"d3-scale";var ai={bar:function(e,t){const{scales:o,columns:i,config:s,getR:r,getStack:n,resolvePieceStyle:a}=e,{r:c,projection:l}=o,h=[],d="vertical"===l,u="horizontal"===l,g=s.normalize,p=[];if(n){const e=new Set;for(const t of Object.values(i))for(const o of t.pieceData){const t=n(o);e.has(t)||(e.add(t),p.push(t))}}else p.push("_default");for(const e of Object.values(i)){const t=new Map;for(const o of e.pieceData){const e=n?n(o):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const i=t.get(e);i.total+=r(o),i.pieces.push(o)}let o=0;if(g)for(const e of t.values())o+=Math.abs(e.total);let i=0,s=0;for(const r of p){const l=t.get(r);if(!l)continue;let p=l.total;g&&o>0&&(p/=o);const f=a(l.pieces[0],n?r:e.name),y={...l.pieces[0],__aggregateValue:l.total,__pieceCount:l.pieces.length,category:e.name};if(d){const t=c(0>p?s:i+p),o=0>p?c(s+p)-c(s):c(i)-c(i+p);h.push(_(e.x,t,e.width,Math.abs(o),f,y,r)),0>p?s+=p:i+=p}else if(u){const t=c(0>p?s+p:i),o=0>p?c(s)-c(s+p):c(i+p)-c(i);h.push(_(t,e.x,Math.abs(o),e.width,f,y,r)),0>p?s+=p:i+=p}}}const f="vertical"===l,y=s.roundedTop&&s.roundedTop>0?Math.max(0,s.roundedTop):0;for(const e of h){if("rect"!==e.type)continue;const t=e.datum?.__aggregateValue??0;e.roundedEdge=f?0>t?"bottom":"top":0>t?"left":"right",s.gradientFill&&(e.fillGradient=s.gradientFill)}if(y>0){const e=new Map;for(const t of h){if("rect"!==t.type)continue;const o=t.datum?.category||"";e.has(o)||e.set(o,[]),e.get(o).push(t)}for(const t of e.values()){if(0===t.length)continue;const e=t.filter(e=>(e.datum?.__aggregateValue??0)>=0),o=t.filter(e=>0>(e.datum?.__aggregateValue??0));e.length>0&&(e.reduce(f?(e,t)=>t.y>e.y?e:t:(e,t)=>e.x+e.w>t.x+t.w?e:t).roundedTop=y),o.length>0&&(o.reduce(f?(e,t)=>e.y+e.h>t.y+t.h?e:t:(e,t)=>t.x>e.x?e:t).roundedTop=y)}}return h},clusterbar:function(e,t){const{scales:o,columns:i,config:s,getR:r,getGroup:n,resolvePieceStyle:a}=e,{r:c,projection:l}=o,h=[],d="vertical"===l,u=[],g=new Set;for(const e of Object.values(i))for(const t of e.pieceData){const e=n?n(t):"_default";g.has(e)||(g.add(e),u.push(e))}const p=u.length||1;for(const e of Object.values(i)){const t=e.width/p,o=.2*t,i=t-o,s=new Map;for(const t of e.pieceData){const e=n?n(t):"_default";s.has(e)||s.set(e,[]),s.get(e).push(t)}for(let n=0;u.length>n;n++){const l=s.get(u[n])||[];for(const s of l){const l=r(s),g=a(s,u[n]);if(d){const r=e.x+n*t+o/2,a=c(0),d=c(l);h.push(_(r,Math.min(a,d),i,Math.abs(a-d),g,s,u[n]))}else{const r=e.x+n*t+o/2,a=c(0),d=c(l);h.push(_(Math.min(a,d),r,Math.abs(d-a),i,g,s,u[n]))}}}}const f=s.roundedTop&&s.roundedTop>0?Math.max(0,s.roundedTop):0;for(const e of h){if("rect"!==e.type)continue;if(null==e.datum)continue;const t=r(e.datum);f>0&&(e.roundedTop=f),e.roundedEdge=d?0>t?"bottom":"top":0>t?"left":"right",s.gradientFill&&(e.fillGradient=s.gradientFill)}return h},point:function(e,t){const{scales:o,columns:i,getR:s,multiScales:r,resolvePieceStyle:n}=e,{r:a,projection:c}=o,l=[],h="vertical"===c,d="radial"===c,u=r.length>0,g=ti(e),p=2*Math.PI,f=-Math.PI/2;for(const e of Object.values(i))for(const t of e.pieceData){const o=t.__rIndex??0,i=t.__rValue??s(t),c=u&&r[o]||a,y=n(t,e.name),m=y.r||5;let x,b;if(d){const t=f+(e.pctStart+e.pct/2)*p,o=c(i);x=Math.cos(t)*o,b=Math.sin(t)*o}else h?(x=e.middle,b=c(i)):(x=c(i),b=e.middle);oi(l,g,t,x,b,m,y)}return l},swarm:function(e,t){const{scales:o,columns:i,getR:s,resolvePieceStyle:r}=e,{r:n,projection:a}=o,c=[],l="vertical"===a,h=ti(e);for(const e of Object.values(i)){const t=e.width/2;for(let o=0;e.pieceData.length>o;o++){const i=e.pieceData[o],a=s(i),d=r(i,e.name),u=d.r||4,g=(7919*o%100/100-.5)*t*.8;oi(c,h,i,l?e.middle+g:n(a),l?n(a):e.middle+g,u,d)}}return c},pie:ii,donut:ii,boxplot:function(e,t){const{scales:o,columns:i,config:s,getR:r,resolveSummaryStyle:n}=e,{r:a,projection:c}=o,l=[],h="vertical"===c,d=!1!==s.showOutliers;for(const t of Object.values(i)){const o=t.pieceData.map(e=>r(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===o.length)continue;const i=o[0],s=o[o.length-1],c=si(o,.25)??i,u=si(o,.5)??(i+s)/2,g=si(o,.75)??s,p=g-c,f=c-1.5*p,y=g+1.5*p,m=o.find(e=>e>=f)??i,x=[...o].reverse().find(e=>y>=e)??s,b=n(t.pieceData[0],t.name),v=[];if(d)for(const e of t.pieceData){const o=r(e);if(f>o||o>y){const i=h?t.middle:a(o),s=h?a(o):t.middle;v.push({px:i,py:s,value:o,datum:e})}}if(l.push({type:"boxplot",x:h?t.middle:0,y:h?0:t.middle,projection:h?"vertical":"horizontal",columnWidth:.6*t.width,minPos:a(m),q1Pos:a(c),medianPos:a(u),q3Pos:a(g),maxPos:a(x),stats:{n:o.length,min:m,q1:c,median:u,q3:g,max:x,mean:o.reduce((e,t)=>e+t,0)/o.length},style:b,datum:t.pieceData,category:t.name,outliers:v}),d)for(const t of v)l.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:b.fill||e.config.themeSemantic?.secondary||"#999",opacity:.6},datum:t.datum})}return l},violin:function(e,t){const{scales:o,columns:i,config:s,getR:r,resolveSummaryStyle:n}=e,{r:a,projection:c}=o,l=[],h="vertical"===c,d=s.bins||20,u=!1!==s.showIQR;for(const e of Object.values(i)){const t=e.pieceData.map(e=>r(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const o=t[0],i=t[t.length-1],s=(i-o)/d||1,c=Array(d).fill(0);for(const e of t)c[Math.min(Math.floor((e-o)/s),d-1)]++;const g=Ge(c,1),p=e.width/2*.9;let f;if(h){f=`M ${e.middle} ${a(o)}`;for(let t=0;d>t;t++){const i=a(o+(t+.5)*s);f+=` L ${e.middle+c[t]/g*p} ${i}`}f+=` L ${e.middle} ${a(i)}`;for(let t=d-1;t>=0;t--){const i=a(o+(t+.5)*s);f+=` L ${e.middle-c[t]/g*p} ${i}`}f+=" Z"}else{f=`M ${a(o)} ${e.middle}`;for(let t=0;d>t;t++)f+=` L ${a(o+(t+.5)*s)} ${e.middle-c[t]/g*p}`;f+=` L ${a(i)} ${e.middle}`;for(let t=d-1;t>=0;t--)f+=` L ${a(o+(t+.5)*s)} ${e.middle+c[t]/g*p}`;f+=" Z"}const y=n(e.pieceData[0],e.name);let m;if(u&&t.length>=4){const s=si(t,.25)??o,r=si(t,.5)??(o+i)/2,n=si(t,.75)??i;m={q1Pos:a(s),medianPos:a(r),q3Pos:a(n),centerPos:e.middle,isVertical:h}}const x=h?{x:e.x,y:Math.min(a(i),a(o)),width:e.width,height:Math.abs(a(i)-a(o))}:{x:Math.min(a(o),a(i)),y:e.x,width:Math.abs(a(i)-a(o)),height:e.width};l.push({type:"violin",pathString:f,translateX:0,translateY:0,bounds:x,iqrLine:m,stats:ri(t),style:y,datum:e.pieceData,category:e.name})}return l},histogram:function(e,t){const{scales:o,columns:i,config:s,getR:r,resolveSummaryStyle:n}=e,{r:a}=o,c=[],l=s.bins||25,h=s.normalize,d=a.domain?.(),u=d?+d[0]:void 0,g=d?+d[1]:void 0;for(const e of Object.values(i)){const t=e.pieceData.map(e=>r(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const[o,i]=Ve(t),s=null!=u&&isFinite(u)?u:o,d=null!=g&&isFinite(g)?g:i,p=(d-s)/l||1,f=Array(l).fill(0);for(const e of t)s>e||e>d||f[Math.min(Math.floor((e-s)/p),l-1)]++;const y=t.length,m=Ge(f,1),x=n(e.pieceData[0],e.name);for(let t=0;l>t;t++){if(0===f[t])continue;const o=(h?f[t]/y:f[t]/m)*e.width*.9,i=a(s+t*p),r=a(s+(t+1)*p);c.push(_(Math.min(i,r),e.x+e.width-o,Math.abs(r-i),o,x,{bin:t,count:f[t],range:[s+t*p,s+(t+1)*p],category:e.name},e.name))}}return c},ridgeline:function(e,t){const{scales:o,columns:i,config:s,getR:r,resolveSummaryStyle:n}=e,{r:a,projection:c}=o,l=[],h=s.bins||20,d="horizontal"===c,u=s.amplitude||1.5;for(const e of Object.values(i)){const t=e.pieceData.map(e=>r(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const o=t[0],i=t[t.length-1],s=(i-o)/h||1,c=Array(h).fill(0);for(const e of t)o>e||e>i||c[Math.min(Math.floor((e-o)/s),h-1)]++;const g=Ge(c,1),p=n(e.pieceData[0],e.name),f=e.width*u;let y;if(d){const t=e.x+e.width;y=`M ${a(o)} ${t}`;for(let e=0;h>e;e++)y+=` L ${a(o+(e+.5)*s)} ${t-c[e]/g*f}`;y+=` L ${a(i)} ${t} Z`}else{const t=e.x;y=`M ${t} ${a(o)}`;for(let e=0;h>e;e++){const i=a(o+(e+.5)*s);y+=` L ${t+c[e]/g*f} ${i}`}y+=` L ${t} ${a(i)} Z`}const m=d?{x:Math.min(a(o),a(i)),y:e.x,width:Math.abs(a(i)-a(o)),height:e.width}:{x:e.x,y:Math.min(a(i),a(o)),width:e.width,height:Math.abs(a(i)-a(o))};l.push({type:"violin",pathString:y,translateX:0,translateY:0,bounds:m,stats:ri(t),style:{...p,fillOpacity:p.fillOpacity??.5},datum:e.pieceData,category:e.name})}return l},timeline:function(e,t){const{scales:o,columns:i,getRawRange:s,resolvePieceStyle:r}=e,{r:n,projection:a}=o,c=[],l="horizontal"===a;for(const e of Object.values(i))for(const t of e.pieceData){const o=s(t);if(!o)continue;const[i,a]=o,h=r(t,e.name);if(l){const o=n(Math.min(i,a)),s=n(Math.max(i,a));c.push(_(o,e.x,s-o,e.width,h,t,e.name))}else{const o=n(Math.max(i,a)),s=n(Math.min(i,a));c.push(_(e.x,o,e.width,s-o,h,t,e.name))}}return c},funnel:function(e,t){const{columns:o,getR:i,getStack:s,resolvePieceStyle:r}=e,n=[],a=t.width/2,c=!1!==e.config.showLabels,l=e.scales.o.domain().map(e=>o[e]).filter(Boolean);if(0===l.length)return n;const h=[],d=new Set;for(const e of l)for(const t of e.pieceData){const e=s?s(t):"_default";d.has(e)||(d.add(e),h.push(e))}const u=h.length>1&&"_default"!==h[0],g=[];let p=0;for(const e of l){const t=new Map;let o=0;for(const r of e.pieceData){const e=s?s(r):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const n=t.get(e),a=i(r);n.total+=a,n.pieces.push(r),o+=a}g.push({col:e,groups:t,stepTotal:o}),u||o>p&&(p=o)}if(u)for(const e of g){let t=0,o=0;for(let i=0;h.length>i;i++){const s=e.groups.get(h[i]);s&&(i%2==0?t+=s.total:o+=s.total)}const i=Math.max(t,o);i>p&&(p=i)}if(0===p)return n;const f=new Map;for(const e of h){const t=g[0].groups.get(e);f.set(e,t?.total??0)}const y=g[0].stepTotal,m=u?.95*a:.9*t.width,x=ni().domain([0,p]).range([0,m]),b=e.config.connectorOpacity??.3;let v=new Map;for(let t=0;g.length>t;t++){const o=g[t],i=o.col,s=0===t,l=i.width,d=.55*l,p=i.x+(l-d)/2,m=new Map;if(u){let e=0;for(const t of h){const i=o.groups.get(t);i&&(e+=x(i.total))}let t=a,l=a;for(let u=0;h.length>u;u++){const g=h[u],y=o.groups.get(g);if(!y)continue;const b=x(y.total),v=u%2==0,A=v?t:l-b;v?t+=b:l-=b;const w=r(y.pieces[0],g),S=f.get(g)??y.total,k={...y.pieces[0],__funnelValue:y.total,__funnelPercent:S>0?y.total/S*100:0,__funnelStep:i.name,__funnelIsFirstStep:s,__aggregateValue:y.total,__pieceCount:y.pieces.length,category:g};c&&(0===u&&(k.__funnelStepLabel=i.name,k.__funnelStepLabelX=a,k.__funnelStepLabelY=p,k.__funnelRowWidth=e),k.__funnelValueLabelX=A+b/2,k.__funnelValueLabelY=p,k.__funnelBarW=b),n.push(_(A,p,b,d,w,k,g)),m.set(g,{x:A,y:p,w:b,h:d})}}else{const e=o.stepTotal,t=x(e),l=a-t/2,u=h[0],g="_default"!==u,f=o.groups.get(u)?.pieces[0]??i.pieceData[0],b=g?u:i.name,v=r(f,b),A=y>0?e/y*100:0,w={...f,__funnelValue:e,__funnelPercent:A,__funnelStep:i.name,__funnelIsFirstStep:s,category:g?u:i.name};c&&(w.__funnelStepLabel=i.name,w.__funnelStepLabelX=a,w.__funnelStepLabelY=p,w.__funnelRowWidth=t,w.__funnelValueLabelX=a,w.__funnelValueLabelY=p,w.__funnelBarW=t),n.push(_(l,p,t,d,v,w,b)),m.set(u,{x:l,y:p,w:t,h:d})}if(t>0&&v.size>0){const t=u?h:[h[0]];for(const s of t){const t=v.get(s),a=m.get(s);if(!t||!a)continue;const c=(()=>{const e=o.groups.get(s);return r(e?e.pieces[0]:i.pieceData[0],"_default"===s?i.name:s)})(),l={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[a.x+a.w,a.y],[a.x,a.y]],style:{fill:c.fill||e.config.themeSemantic?.secondary||"#999",opacity:b},datum:o.groups.get(s)?.pieces[0]??i.pieceData[0],category:"_default"===s?i.name:s};n.push(l)}}v=m}return n},"bar-funnel":function(e,t){const{columns:o,getR:i,getStack:s,resolvePieceStyle:r,scales:n}=e,a=[],c=n.o.domain().map(e=>o[e]).filter(Boolean);if(0===c.length)return a;const l=[],h=new Set;for(const e of c)for(const t of e.pieceData){const e=s?s(t):"_default";h.has(e)||(h.add(e),l.push(e))}const d=l.length>1&&"_default"!==l[0],u=[];for(const e of c){const t=new Map;let o=0;for(const r of e.pieceData){const e=s?s(r):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const n=t.get(e),a=i(r);n.total+=a,n.pieces.push(r),o+=a}u.push({col:e,groups:t,stepTotal:o})}const g=new Map;for(const e of l){const t=u[0]?.groups.get(e);g.set(e,t?.total??0)}const p=n.r,f=d?l.length:1,y=d?.15:0;for(let e=0;u.length>e;e++){const t=u[e],o=t.col,i=0===e,s=e>0?u[e-1]:null,n=o.width/f,c=n*y,h=n-c;for(let e=0;l.length>e;e++){const u=l[e],f=t.groups.get(u);if(!f)continue;const y=f.total,m=g.get(u)??y,x=m>0?y/m*100:0,b=s?.groups.get(u),v=i?0:Math.max(0,(b?.total??y)-y),A=o.x+e*n+c/2,w=p(y),S=p(0)-w,k=r(f.pieces[0],d?u:o.name),M={...f.pieces[0],__barFunnelValue:y,__barFunnelPercent:x,__barFunnelIsFirstStep:i,__barFunnelIsDropoff:!1,__barFunnelStep:o.name,__barFunnelDropoffValue:v,__barFunnelCategory:"_default"===u?void 0:u,category:d?u:o.name,__barFunnelLabelX:A+h/2,__barFunnelLabelY:p(y+v)};if(a.push(_(A,w,h,S,k,M,d?u:o.name)),v>0){const e=p(y+v),t=w-e,i={...k},s={...f.pieces[0],__barFunnelValue:v,__barFunnelPercent:m>0?v/m*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:o.name,__barFunnelCategory:"_default"===u?void 0:u,category:d?u:o.name};a.push(_(A,e,h,t,i,s,d?u:o.name))}}}return a},swimlane:function(e,t){const{scales:o,columns:i,getR:s,getStack:r,resolvePieceStyle:n}=e,{r:a,projection:c}=o,l=[],h="horizontal"===c,d=e.config.gradientFill,u=h?"left":"bottom",g=e.config.trackFill;if(g){const e="string"==typeof g?g:g.color,t="string"==typeof g?1:g.opacity??1,[o,s]=a.range(),r=Math.min(o,s),n=Math.abs(s-o);for(const o of Object.values(i)){const i={fill:e,opacity:t},s=h?_(r,o.x,n,o.width,i,null,"__track__"):_(o.x,r,o.width,n,i,null,"__track__");l.push(s)}}const p=e.config.roundedTop&&e.config.roundedTop>0?Math.max(0,e.config.roundedTop):0;for(const e of Object.values(i)){let t=0;const o=l.length;for(const o of e.pieceData){const i=Math.abs(s(o));if(0===i)continue;const c=r?r(o):e.name,g=n(o,c);let p;if(h){const s=a(t),r=a(t+i);p=_(s,e.x,r-s,e.width,g,o,c)}else{const s=a(t+i),r=a(t);p=_(e.x,s,e.width,r-s,g,o,c)}d&&(p.fillGradient=d,p.roundedEdge=u),l.push(p),t+=i}if(p>0&&l.length>o){const e=l.slice(o),t=e[0],i=e[e.length-1];1===e.length?t.cornerRadii={tl:p,tr:p,br:p,bl:p}:h?(t.cornerRadii={tl:p,bl:p},i.cornerRadii={tr:p,br:p}):(t.cornerRadii={bl:p,br:p},i.cornerRadii={tl:p,tr:p})}}return l}},ci=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],li=["scene-style","data-paint","accessibility","evidence"],hi=(e,t)=>({retainedData:e,invalidations:t}),di=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ui=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],gi=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],pi=["scene-geometry","data-paint","accessibility","evidence"],fi=["scene-style","data-paint","accessibility","evidence"],yi=[],mi={chartType:hi("rebuild",di),runtimeMode:hi("rebuild",di),categoryAccessor:hi("rebuild",di),valueAccessor:hi("rebuild",di),oAccessor:hi("rebuild",di),rAccessor:hi("rebuild",di),stackBy:hi("rebuild",di),groupBy:hi("rebuild",di),timeAccessor:hi("rebuild",di),accessorRevision:hi("rebuild",di),colorAccessor:hi("rebuild",fi),symbolAccessor:hi("rebuild",pi),connectorAccessor:hi("rebuild",pi),dataIdAccessor:hi("rebuild",pi),projection:hi("preserve",ui),extentPadding:hi("preserve",ui),axisExtent:hi("preserve",ui),rExtent:hi("preserve",ui),oExtent:hi("preserve",ui),multiAxis:hi("preserve",ui),normalize:hi("preserve",ui),bins:hi("preserve",ui),oSort:hi("preserve",gi),barPadding:hi("preserve",gi),roundedTop:hi("preserve",gi),baselinePadding:hi("preserve",gi),innerRadius:hi("preserve",gi),cornerRadius:hi("preserve",gi),startAngle:hi("preserve",gi),sweepAngle:hi("preserve",gi),trackFill:hi("preserve",gi),showOutliers:hi("preserve",gi),showIQR:hi("preserve",gi),amplitude:hi("preserve",gi),connectorOpacity:hi("preserve",gi),showLabels:hi("preserve",gi),dynamicColumnWidth:hi("rebuild",gi),customLayout:hi("preserve",gi),layoutConfig:hi("preserve",gi),layoutMargin:hi("preserve",gi),symbolMap:hi("preserve",pi),pieceStyle:hi("preserve",fi),summaryStyle:hi("preserve",fi),connectorStyle:hi("preserve",fi),gradientFill:hi("preserve",fi),colorScheme:hi("preserve",fi),themeCategorical:hi("preserve",fi),themeSemantic:hi("preserve",fi),themeSequential:hi("preserve",fi),themeDiverging:hi("preserve",fi),barColors:hi("preserve",fi),decay:hi("preserve",fi),pulse:hi("preserve",fi),staleness:hi("preserve",fi),layoutSelection:hi("preserve",fi),windowSize:hi("preserve",yi),windowMode:hi("preserve",yi),clock:hi("preserve",yi),transition:hi("preserve",yi),introAnimation:hi("preserve",yi),onLayoutError:hi("preserve",yi)},xi=hi("preserve",gi),bi=class{constructor(){this.tracker=new ze}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}},ci)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},li):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const o=new Set;for(const i of e){const e=mi[i]??xi;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)o.add(t)}return{retainedData:t,invalidations:o}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}};import{quadtree as vi}from"d3-quadtree";var Ai=class{constructor(e){this.rExtent=new G,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new bi,this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this.styleResolver=new ei,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},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.version=0,this._dataVersion=0,this._bufferArrayCache=null,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=e,this.buffer=new Y(e.windowSize),this.getO=Te(e.categoryAccessor||e.oAccessor,"category");const t=e.valueAccessor||e.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(e=>Pe(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new G)):(this.getR=Pe(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=Te(e.stackBy),this.getGroup=Te(e.groupBy),this.getColor=Te(e.colorAccessor),this.getSymbol=Te(e.symbolAccessor),this.getConnector=Te(e.connectorAccessor),this.getDataId=Te(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new Y(e.windowSize))}syncPulseTimestampBuffer(){var e,t,o,i;this.timestampBuffer=(e=!!this.config.pulse,t=this.buffer,o=this.timestampBuffer,i=this.currentTime(),e?null!=o&&o.capacity===t.capacity&&o.size===t.size?o:z(t,i):null)}currentTime(){return this.config.clock?.()??ye()}ingest(e){const t=this.currentTime();if(this.lastIngestTime=t,this._dataVersion++,e.bounded){this.buffer.clear(),this.rExtent.clear();for(const e of this.rExtents)e.clear();e.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),C(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const o of e.inserts)O(this.buffer,o,this.timestampBuffer,t),this.categories.add(this.getO(o)),this.pushValueExtent(o)}else{this._hasStreamingData=!0;for(const o of e.inserts){const e=O(this.buffer,o,this.timestampBuffer,t);this.categories.add(this.getO(o)),this.pushValueExtent(o),null!=e&&this.evictValueExtent(e)}}return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}pushValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.push(t[0]),this.rExtent.push(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].push(this.rAccessors[t](e));this.rExtent.push(this.getR(e))}else this.rExtent.push(this.getR(e))}evictValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.evict(t[0]),this.rExtent.evict(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].evict(this.rAccessors[t](e));this.rExtent.evict(this.getR(e))}else this.rExtent.evict(this.getR(e))}getRawRange(e){const t=this.config.valueAccessor||this.config.rAccessor;if(!t)return null;const o="function"==typeof t?t(e):e[t];return Array.isArray(o)&&o.length>=2?[+o[0],+o[1]]:null}computeScene(e){const{config:t,buffer:o}=this,i=this.scales,s=this.multiScales,r=this.columns;if(0===o.size)return this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(o,this.getR);const n=this.getBufferArray(),a=t.projection||"vertical",c=t.oExtent||this.resolveCategories(n),l=this.computeValueDomain(n,c),h="horizontal"===a,d="radial"===a,u=Math.min(.9,Math.max(0,null!=t.barPadding?t.barPadding/("vertical"===a?e.width:e.height):.1));let g,p;if(d){g=Ko().domain(c).range([0,1]).padding(0);const o=Math.min(e.width,e.height)/2,i=t.innerRadius||0;p=Jo().domain(l).range([i,o])}else h?(g=Ko().domain(c).range([0,e.height]).padding(u),p=Jo().domain(l).range([0,e.width])):(g=Ko().domain(c).range([0,e.width]).padding(u),p=Jo().domain(l).range([e.height,0]));this.scales={o:g,r:p,projection:a},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((i,s)=>{const r=this.rExtents[s];r.dirty&&r.recalculate(o,i);let[n,a]=r.extent;n===1/0&&(n=0,a=1);const c=a-n,l=c>0?c*(t.extentPadding??.05):1;return n-=l,a+=l,n>0&&(n=0),h?Jo().domain([n,a]).range([0,e.width]):Jo().domain([n,a]).range([e.height,0])}):[];let f=n;this.rAccessors.length>1&&(f=n.flatMap(e=>this.rAccessors.map((t,o)=>({...e,__rIndex:o,__rValue:t(e),__rName:this.resolveRAccessorName(o)})))),this.columns=this.buildColumns(f,c,g,a,e),this._customLayoutFailedThisBuild=!1;const y=this.buildSceneNodes(f,e);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=i,this.multiScales=s,this.columns=r):(this.scene=[],this.rebuildPointQuadtree()):(this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=y,this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,n),this.config.pulse&&this.applyPulse(this.scene,n),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.startTransition(),this.version++)}resolveRAccessorName(e){const t=this.config.valueAccessor||this.config.rAccessor,o=Array.isArray(t)?t[e]:t;return"string"==typeof o?o:"value"+e}resolveCategories(e){const t=this.config.oSort,o="streaming"===this.config.runtimeMode||this._hasStreamingData,i="auto"===t?void 0:t;let s=null;if(o){s=new Set;for(const t of e)s.add(this.getO(t))}const r=s?Array.from(this.categories).filter(e=>s.has(e)):Array.from(this.categories);if(o&&void 0===i){const e=Math.max(50,3*s.size);if(this.categories.size>e){let t=this.categories.size-e;for(const e of this.categories){if(0>=t)break;s.has(e)||(this.categories.delete(e),t--)}}return r}if(!1===i)return r;if("function"==typeof i)return r.sort(i);const n=new Map;for(const t of e){const e=this.getO(t);n.set(e,(n.get(e)||0)+Math.abs(this.getR(t)))}return r.sort("asc"===i?(e,t)=>(n.get(e)||0)-(n.get(t)||0):(e,t)=>(n.get(t)||0)-(n.get(e)||0))}computeValueDomain(e,t){return function(e){const{data:t,chartType:o,projection:i,normalize:s,rExtent:r,extentPadding:n=.05,baselinePadding:a,axisExtent:c,getO:l,getR:h,getStack:d,rawRExtent:u}=e,g=n;if("radial"===i&&("pie"===o||"donut"===o))return[0,1];let p=0,f=0;if("bar"===o&&d&&s)p=0,f=1;else if("bar"===o&&d){const e=new Map,o=new Map;for(const i of t){const t=l(i),s=h(i);0>s?o.set(t,(o.get(t)||0)+s):e.set(t,(e.get(t)||0)+s)}for(const t of e.values())t>f&&(f=t);for(const e of o.values())p>e&&(p=e)}else if("bar"===o){const e=new Map;for(const o of t){const t=l(o),i=h(o);e.set(t,(e.get(t)||0)+i)}for(const t of e.values())t>f&&(f=t),p>t&&(p=t)}else if("swimlane"===o){const e=new Map;for(const o of t){const t=l(o),i=Math.abs(h(o));e.set(t,(e.get(t)||0)+i)}for(const t of e.values())t>f&&(f=t)}else if("clusterbar"===o||"bar-funnel"===o)for(const e of t){const t=h(e);t>f&&(f=t),p>t&&(p=t)}else{const e=u[0],t=u[1];e!==1/0&&(p=e),t!==-1/0&&(f=t)}r&&(null!=r[0]&&(p=r[0]),null!=r[1]&&(f=r[1]));const y="bar"===o||"clusterbar"===o||"bar-funnel"===o||"swimlane"===o;if(y&&null==r?.[0]&&null==r?.[1]&&(p>0&&(p=0),0>f&&(f=0)),"bar-funnel"!==o&&"exact"!==c){const e=f-p,t=e>0?e*g:1,i=y&&!a&&0===p,s=y&&!a&&0===f||"swimlane"===o;null!=r?.[0]||i||(p-=t),null!=r?.[1]||s||(f+=t)}return[p,f]}({data:e,chartType:this.config.chartType,projection:this.config.projection,normalize:this.config.normalize,rExtent:this.config.rExtent,extentPadding:this.config.extentPadding,baselinePadding:this.config.baselinePadding,axisExtent:this.config.axisExtent,getO:this.getO,getR:this.getR,getStack:this.getStack,rawRExtent:this.rExtent.extent})}buildColumns(e,t,o,i,s){return function(e){const{data:t,oExtent:o,oScale:i,projection:s,layout:r,dynamicColumnWidth:n,getO:a,getR:c}=e,l={},h=new Map;for(const e of t){const t=a(e);h.has(t)||h.set(t,[]),h.get(t).push(e)}let d=0;if("radial"===s)for(const e of t)d+=Math.abs(c(e));let u=null;if(n&&"radial"!==s){u=new Map;let e=0;for(const t of o){const o=h.get(t)||[];let i;i="string"==typeof n?o.reduce((e,t)=>e+(Number(t[n])||0),0):n(o),u.set(t,i),e+=i}const t=("horizontal"===s?r.height:r.width)-i.padding()*i.step()*o.length;if(e>0)for(const[o,i]of u)u.set(o,i/e*t)}let g=0,p=0;for(const e of o){const t=h.get(e)||[],o=t.reduce((e,t)=>e+Math.abs(c(t)),0),s=d>0?o/d:0;let r,n;u?(r=p,n=u.get(e)||i.bandwidth(),p+=n+i.padding()*i.step()):(r=i(e)??0,n=i.bandwidth()),l[e]={name:e,x:r,y:0,width:n,middle:r+n/2,padding:i.padding()*i.step(),pieceData:t,pct:s,pctStart:g},g+=s}return l}({data:e,oExtent:t,oScale:o,projection:i,layout:s,dynamicColumnWidth:this.config.dynamicColumnWidth,getO:this.getO,getR:this.getR})}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getSymbol:this.getSymbol,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(e,t)=>this.styleResolver.resolvePieceStyle(this.config,e,t),resolveSummaryStyle:(e,t)=>this.styleResolver.resolveSummaryStyle(this.config,e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];if(this.config.customLayout){const o=this.buildLayoutContext(e,t);let i;try{i=this.config.customLayout(o)}catch(e){const t=null!==this.lastCustomLayoutResult,o=L("ordinal",e,t,this.version);this.lastCustomLayoutFailure=o,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",e);try{this.config.onLayoutError?.(o)}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,this.config.layoutSelection??null)}return I({label:"ordinal customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;const o=this.getSceneContext(),i=ai[this.config.chartType];let s=i?i(o,t):[];if(this.getConnector&&this.scales){const e=function(e,t){const{scales:o,config:i,getConnector:s,getO:r}=e;if(!s||!o)return[];const n=[],{projection:a}=o,c=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const o=s(t);if(!o)continue;let i,n;"point"===e.type?(i=e.x,n=e.y):(i=e.x+e.w/2,n=e.y+("vertical"===a?0:e.h/2)),c.has(o)||c.set(o,[]),c.get(o).push({x:i,y:n,datum:t,category:r(t)})}const l=o.o.domain(),h=i.connectorStyle;for(const[t,o]of c)if(o.length>=2){o.sort((e,t)=>l.indexOf(e.category)-l.indexOf(t.category));for(let i=0;o.length-1>i;i++){const s=o[i],r=o[i+1],a="function"==typeof h?h(s.datum):h||{stroke:e.config.themeSemantic?.border||e.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5};n.push({type:"connector",x1:s.x,y1:s.y,x2:r.x,y2:r.y,style:a,datum:s.datum,group:t})}}return n}(o,s);s=[...e,...s]}return s}buildLayoutContext(e,t){const o=this.config,i=o.layoutMargin??{top:0,right:0,bottom:0,left:0},s=Ae(o.colorScheme,o.themeCategorical,q),r=this.scales;return{data:e,scales:{o:r.o,r:r.r,projection:r.projection},dimensions:{width:t.width,height:t.height,margin:i,plot:"radial"===r.projection?{x:-t.width/2,y:-t.height/2,width:t.width,height:t.height}:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:o.themeSemantic??{},categorical:[...s]},resolveColor:K(s,o.colorScheme),config:o.layoutConfig??{},selection:o.layoutSelection??null}}computeDecayOpacity(e,t){const o=this.config.decay;return o&&t>1?T(o,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const t=k(e);return this._datumIndexCache={version:this._dataVersion,map:t},t}getCategoryIndexMap(e){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const t=function(e,t){const o="function"==typeof t,i=o?null:t||"category",s=new Map;for(let r=0;e.length>r;r++){const n=e[r],a=o?t(n):n[i],c=s.get(a);c?c.push(r):s.set(a,[r])}return s}(e,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:t},t}rebuildPointQuadtree(){const e=function(e){let t=0,o=0;for(const i of e)"point"===i.type&&(t++,i.r>o&&(o=i.r));if(500>=t)return{quadtree:null,maxRadius:o};const i=Array(t);let s=0;for(const t of e)"point"===t.type&&(i[s++]=t);return{maxRadius:o,quadtree:vi().x(e=>e.x).y(e=>e.y).addAll(i)}}(this.scene);this._pointQuadtree=e.quadtree,this._maxPointRadius=e.maxRadius}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(e,t){if(!this.config.decay)return;const o=t.length;if(1>=o)return;const i=this.getDatumIndexMap(t);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;if(!t.datum)continue;const e=i.get(t.datum);if(null==e)continue;const s=this.computeDecayOpacity(e,o);t.style={...t.style,opacity:(t.style?.opacity??1)*s}}}applyPulse(e,t,o=this.currentTime()){return!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,o,i,s,r){const n=e.color??"rgba(255,255,255,0.6)",a=e.glowRadius??4;let c=!1;for(const l of t){if("connector"===l.type||"violin"===l.type||"boxplot"===l.type)continue;if("wedge"===l.type){const t=l.category;if(!t)continue;let i=0;for(const n of s(t)??[]){const t=o.get(n);null!=t&&(i=Math.max(i,R(e,t,r)))}c=N(l,i,n)||c;continue}if(null==l.datum)continue;const t=i.get(l.datum);if(null==t)continue;const h=o.get(t),d=null==h?0:R(e,h,r);c=N(l,d,n,a)||c}return c}(this.config.pulse,e,this.timestampBuffer,this.getDatumIndexMap(t),e=>this.getCategoryIndexMap(t).get(e),o)}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&B(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}synthesizeIntroPositions(){this.prevPositionMap.clear();const e=new Map,t=this.scales?.r(0)??0,o="horizontal"!==this.scales?.projection;let i;for(let s=0;this.scene.length>s;s++){const r=this.scene[s],n=this.getNodeKey(r,e);n&&("rect"===r.type?this.prevPositionMap.set(n,o?{x:r.x,y:t,w:r.w,h:0,opacity:r.style.opacity??1}:{x:t,y:r.y,w:0,h:r.h,opacity:r.style.opacity??1}):"point"===r.type?this.prevPositionMap.set(n,{x:r.x,y:r.y,r:0,opacity:0}):"wedge"===r.type&&(void 0===i&&(i=r.startAngle),this.prevPositionMap.set(n,{x:r.cx,y:r.cy,startAngle:i,endAngle:i,innerRadius:r.innerRadius,outerRadius:r.outerRadius,opacity:0})))}}getNodeKey(e,t){if("point"===e.type){const o=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,i=t.get(o)||0;return t.set(o,i+1),`${o}:${i}`}return"rect"===e.type?`r:${e.group||""}:${e.datum?.category??""}`:"wedge"===e.type?"w:"+(e.category??""):null}snapshotPositions(){this.prevPositionMap.clear();const e=new Map;for(let t=0;this.scene.length>t;t++){const o=this.scene[t],i=this.getNodeKey(o,e);i&&("point"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity}):"rect"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity}):"wedge"===o.type&&this.prevPositionMap.set(i,{x:o.cx,y:o.cy,startAngle:o.startAngle,endAngle:o.endAngle,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:o.style.opacity??1}))}}startTransition(){if(!this.config.transition||0===this.prevPositionMap.size)return;const e=this.config.transition.duration??300;if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let t=!1;const o=new Set,i=new Map;for(let e=0;this.scene.length>e;e++){const s=this.scene[e],r=this.getNodeKey(s,i);if(!r)continue;s._transitionKey=r;const n=this.prevPositionMap.get(r);if("point"===s.type)n?(o.add(r),s._targetOpacity=s.style.opacity??1,(n.x!==s.x||n.y!==s.y||void 0!==n.r&&n.r!==s.r)&&(s._targetX=s.x,s._targetY=s.y,s._targetR=s.r,s.x=n.x,s.y=n.y,void 0!==n.r&&(s.r=n.r),t=!0)):(s._targetOpacity=s.style.opacity??1,s._targetR=s.r,s.r=0,s.style={...s.style,opacity:0},t=!0);else if("rect"===s.type)n?(o.add(r),s._targetOpacity=s.style.opacity??1,n.x===s.x&&n.y===s.y&&n.w===s.w&&n.h===s.h||(s._targetX=s.x,s._targetY=s.y,s._targetW=s.w,s._targetH=s.h,s.x=n.x,s.y=n.y,s.w=n.w??s.w,s.h=n.h??s.h,t=!0)):(s._targetOpacity=s.style.opacity??1,s.style={...s.style,opacity:0},t=!0);else if("wedge"===s.type)if(n)o.add(r),s._targetOpacity=s.style.opacity??1,n.startAngle===s.startAngle&&n.endAngle===s.endAngle||(s._targetStartAngle=s.startAngle,s._targetEndAngle=s.endAngle,s.startAngle=n.startAngle,s.endAngle=n.endAngle,t=!0);else{s._targetOpacity=s.style.opacity??1,s._targetStartAngle=s.startAngle,s._targetEndAngle=s.endAngle;const e=s.startAngle;s.startAngle=e,s.endAngle=e,s.style={...s.style,opacity:0},this.prevPositionMap.set(r,{x:s.cx,y:s.cy,startAngle:e,endAngle:e,innerRadius:s.innerRadius,outerRadius:s.outerRadius,opacity:0}),t=!0}}this.exitNodes=[];for(const[e,i]of this.prevPositionMap)if(!o.has(e)){if(e.startsWith("p:"))this.exitNodes.push({type:"point",x:i.x,y:i.y,r:i.r??3,style:{opacity:i.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))this.exitNodes.push({type:"rect",x:i.x,y:i.y,w:i.w??0,h:i.h??0,style:{opacity:i.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("w:")){const t=((i.startAngle??0)+(i.endAngle??0))/2,o={type:"wedge",cx:i.x,cy:i.y,innerRadius:i.innerRadius??0,outerRadius:i.outerRadius??100,startAngle:i.startAngle??0,endAngle:i.endAngle??0,style:{opacity:i.opacity??1},datum:null,category:e.slice(2),_targetStartAngle:t,_targetEndAngle:t,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(o)}t=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),t&&(this.activeTransition={startTime:this.currentTime(),duration:e})}advanceTransition(e){if(!this.activeTransition)return!1;const t=te(e,this.activeTransition),o=ee(t,"linear"===this.config.transition?.easing?"linear":"ease-out-cubic");for(const e of this.scene){const t=e._transitionKey;if(t)if("point"===e.type){if(void 0!==e._targetOpacity){const i=this.prevPositionMap.get(t);e.style.opacity=ue(i?i.opacity??1:0,e._targetOpacity,o)}const i=this.prevPositionMap.get(t);void 0!==e._targetX&&i&&(e.x=ue(i.x,e._targetX,o),e.y=ue(i.y,e._targetY,o)),void 0!==e._targetR&&void 0!==i?.r&&(e.r=ue(i.r,e._targetR,o))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const i=this.prevPositionMap.get(t);e.style.opacity=ue(i?i.opacity??1:0,e._targetOpacity,o)}if(void 0===e._targetX)continue;const i=this.prevPositionMap.get(t);if(!i)continue;e.x=ue(i.x,e._targetX,o),e.y=ue(i.y,e._targetY,o),void 0!==i.w&&(e.w=ue(i.w,e._targetW,o),e.h=ue(i.h,e._targetH,o))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){const i=this.prevPositionMap.get(t);e.style={...e.style,opacity:ue(i?i.opacity??1:0,e._targetOpacity,o)}}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){const i=this.prevPositionMap.get(t);i&&void 0!==i.startAngle&&(e.startAngle=ue(i.startAngle,e._targetStartAngle,o),e.endAngle=ue(i.endAngle,e._targetEndAngle,o))}}}if(t>=1){for(const e of this.scene)if(void 0!==e._targetOpacity&&(e.style={...e.style||{},opacity:0===e._targetOpacity?0:e._targetOpacity},e._targetOpacity=void 0),"point"===e.type){if(void 0===e._targetX&&void 0===e._targetR)continue;void 0!==e._targetX&&(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("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"wedge"===e.type&&void 0!==e._targetStartAngle&&(e.startAngle=e._targetStartAngle,e.endAngle=e._targetEndAngle,e._targetStartAngle=void 0,e._targetEndAngle=void 0);if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}cancelIntroAnimation(){this.prevPositionMap.clear(),this.activeTransition=null}getBufferArray(){return this._bufferArrayCache?.version!==this._dataVersion&&(this._bufferArrayCache={version:this._dataVersion,data:this.buffer.toArray()}),this._bufferArrayCache.data}getData(){return this.buffer.toArray()}remove(e){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=$(e),o=this.getDataId,i=e=>t.has(o(e));P(this.buffer,this.timestampBuffer,i);const s=this.buffer.remove(i);if(0===s.length)return this.updateResults.recordNoop("remove"),s;for(const e of s)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach(e=>this.categories.add(this.getO(e))),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",s.length),s}update(e,t){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const o=$(e),i=this.getDataId,s=new Set;this.buffer.forEach((e,t)=>{o.has(i(e))&&s.add(t)});const r=this.buffer.update(e=>o.has(i(e)),t);if(0===r.length)return this.updateResults.recordNoop("update"),r;for(const e of r)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach((e,t)=>{this.categories.add(this.getO(e)),s.has(t)&&this.pushValueExtent(e)}),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",r.length),r}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.multiScales=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._pointQuadtree=null,this._maxPointRadius=0,this.styleResolver.resetColors(),this._dataVersion++,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}applyCustomRestyle(e,t){const o=this._customRestyle;if(o)for(const i of e){const e=this._baseStyles.get(i)??i.style??{},s=o(i,t);i.style=s?{...e,...s}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}rebuildAccessorDerivedState(){this.categories.clear(),this.rExtent.clear();for(const e of this.rExtents)e.clear();this._categoryIndexCache=null,this.buffer.forEach(e=>{this.categories.add(this.getO(e)),this.pushValueExtent(e)})}updateConfig(e){const t={...this.config},o=Object.keys(e).filter(o=>e[o]!==t[o]);"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&&e.colorScheme!==t.colorScheme||"themeCategorical"in e&&e.themeCategorical!==t.themeCategorical||"colorAccessor"in e&&!Me(e.colorAccessor,t.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in e&&!Me(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!Me(e.oAccessor,t.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();let i=!1;("categoryAccessor"in e||"oAccessor"in e)&&(Me(this.config.categoryAccessor||this.config.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=Te(this.config.categoryAccessor||this.config.oAccessor,"category"),i=!0));let s=!1;if("valueAccessor"in e||"rAccessor"in e){const e=this.config.valueAccessor||this.config.rAccessor,o=t.valueAccessor||t.rAccessor,i=Array.isArray(e)?e:[e],r=Array.isArray(o)?o:[o];if(s=i.length!==r.length||i.some((e,t)=>!Me(e,r[t])),s){const e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>Pe(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new G)):(this.getR=Pe(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!Me(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?Te(this.config.stackBy):void 0),"groupBy"in e&&!Me(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?Te(this.config.groupBy):void 0),"colorAccessor"in e&&!Me(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Te(this.config.colorAccessor):void 0),"symbolAccessor"in e&&!Me(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?Te(this.config.symbolAccessor):void 0),"connectorAccessor"in e&&!Me(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?Te(this.config.connectorAccessor):void 0),(i||s||"accessorRevision"in e&&e.accessorRevision!==t.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(o)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};S(Ai);import{jsx as wi,jsxs as Si}from"react/jsx-runtime";import{Fragment as ki,jsx as _i,jsxs as Mi}from"react/jsx-runtime";function Pi(e,t){const o=it(e.theme),i=e.size||[500,400],s=xe({top:20,right:20,bottom:30,left:40,...e.margin},e.title),r=ae(e.title),n=ie(e.data),a=e.showLegend?ko(n,e.colorAccessor||e.stackBy||e.groupBy):[];Go(s,{props:e,categories:a,theme:o,size:i,hasTitle:r});const c=i[0]-s.left-s.right,l=i[1]-s.top-s.bottom,h=e.projection||"vertical",d="radial"===h,u={chartType:e.chartType,windowSize:e.windowSize??1e4,windowMode:e.windowMode??"sliding",extentPadding:e.extentPadding??.05,projection:h,oAccessor:e.oAccessor,rAccessor:e.rAccessor,colorAccessor:e.colorAccessor,stackBy:e.stackBy,groupBy:e.groupBy,categoryAccessor:e.categoryAccessor,valueAccessor:e.valueAccessor,timeAccessor:e.timeAccessor,rExtent:e.rExtent,oExtent:e.oExtent,axisExtent:e.axisExtent,barPadding:e.barPadding,roundedTop:e.roundedTop,innerRadius:e.innerRadius,cornerRadius:e.cornerRadius,normalize:e.normalize,startAngle:e.startAngle,sweepAngle:e.sweepAngle,bins:e.bins,showOutliers:e.showOutliers,showIQR:e.showIQR,amplitude:e.amplitude,oSort:e.oSort,connectorAccessor:e.connectorAccessor,connectorStyle:e.connectorStyle,dynamicColumnWidth:e.dynamicColumnWidth,pieceStyle:e.pieceStyle,summaryStyle:e.summaryStyle,gradientFill:e.gradientFill,symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,multiAxis:e.multiAxis,baselinePadding:e.baselinePadding,trackFill:e.trackFill,connectorOpacity:e.connectorOpacity,showLabels:e.showLabels,colorScheme:e.colorScheme||o.colors.categorical,themeCategorical:o.colors.categorical,themeSemantic:Ue(o),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:s,layoutSelection:e.layoutSelection,barColors:e.barColors},g=new Ai(u);if(e.data&&g.ingest({inserts:n,bounded:!0}),g.computeScene({width:c,height:l}),!g.scales||0===g.scene.length)return t&&(t.evidence=lo({frameType:"ordinal",width:i[0],height:i[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,extraWarnings:g.scales?[]:["NO_SCALES"]})),Uo.renderToStaticMarkup(Xo(null,{width:i[0],height:i[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${s.left},${s.top})`,innerWidth:c,innerHeight:l,idPrefix:e._idPrefix}));const p=e._idPrefix,f=e.showGrid?function(e,t,o,i,s){const r=e.scales;if(!r||"radial"===r.projection)return null;const{grid:n}=st(o),a=i?i+"-":"",c="vertical"===r.projection,l=W(r.r,5,s);return Oo("g",c?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,o)=>{const i=r.r(e);return Oo("line",{x1:0,y1:i,x2:t.width,y2:i,stroke:n,strokeWidth:.5},"gr-"+o)})}:{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,o)=>{const i=r.r(e);return Oo("line",{x1:i,y1:0,x2:i,y2:t.height,stroke:n,strokeWidth:.5},"gr-"+o)})})}(g,{width:c,height:l},o,p,e.axisExtent):null;let y=null;if(g.scene.some(e=>"rect"===e.type&&e.datum?.__barFunnelIsDropoff)){const t=Do(e),i=new Set;for(const e of g.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&i.add("string"==typeof e.style.fill?e.style.fill:"#666");y=Array.from(i).map((e,i)=>function(e){const{id:t,background:o="transparent",stroke:i="#000",lineWidth:s=1.5,spacing:r=6,angle:n=45}=e,a=Math.max(8,Math.ceil(2*r));return Si("pattern",{id:t,width:a,height:a,patternUnits:"userSpaceOnUse",patternTransform:0!==n?`rotate(${n})`:void 0,children:[o&&"transparent"!==o&&wi("rect",{width:a,height:a,fill:o}),wi("line",{x1:0,y1:0,x2:0,y2:a,stroke:i,strokeWidth:s}),wi("line",{x1:r,y1:0,x2:r,y2:a,stroke:i,strokeWidth:s})]},t)}({id:`funnel-hatch-${t}-${i}`,background:e,stroke:"transparent"===o.colors.background?"#fff":o.colors.background,lineWidth:1.5,spacing:5,angle:45}));const s=new Map;Array.from(i).forEach((e,o)=>s.set(e,`funnel-hatch-${t}-${o}`));for(const e of g.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&(e.style={...e.style,fill:`url(#${s.get("string"==typeof e.style.fill?e.style.fill:"#666")})`})}const m=E({nodes:g.scene,renderMode:e.renderMode,fallback:(e,t)=>me(e,t,p)}),x=m.map(e=>e.element);if(t){const o=g.scales.o?.domain?.();t.evidence=lo({frameType:"ordinal",width:i[0],height:i[1],marks:m.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,yDomain:co(g.scales.r?.domain?.()),categories:Array.isArray(o)?o.map(String):void 0})}const b=!1!==e.showAxes?function(e,t,o,i,s){const r=e.scales;if(!r)return null;if("radial"===r.projection)return null;const n=st(i),a="vertical"===r.projection,c=o.categoryFormat||o.oFormat,l=o.valueFormat||o.rFormat,h=o.categoryLabel||o.oLabel,d=o.valueLabel||o.rLabel,u=Object.values(e.columns).map(e=>({pixel:e.middle,label:(c||String)(e.name)})),g=W(r.r,5,o.axisExtent).map(e=>({pixel:r.r(e),label:(l||Vo)(e)}));return Mi("g",a?{id:(s?s+"-":"")+"axes",className:"ordinal-axes",children:[_i("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:n.border,strokeWidth:1}),u.map((e,o)=>Mi("g",{transform:`translate(${e.pixel},${t.height})`,children:[_i("line",{y2:5,stroke:n.border,strokeWidth:1}),_i("text",{y:18,textAnchor:"middle",fontSize:n.tickSize,fill:n.textSecondary,fontFamily:n.fontFamily,children:e.label})]},"oxtick-"+o)),h&&_i("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:n.labelSize,fill:n.text,fontFamily:n.fontFamily,children:h}),_i("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:n.border,strokeWidth:1}),g.map((e,t)=>Mi("g",{transform:`translate(0,${e.pixel})`,children:[_i("line",{x2:-5,stroke:n.border,strokeWidth:1}),_i("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n.tickSize,fill:n.textSecondary,fontFamily:n.fontFamily,children:e.label})]},"oytick-"+t)),d&&_i("text",{x:15-(o.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:n.labelSize,fill:n.text,fontFamily:n.fontFamily,transform:`rotate(-90, ${15-(o.margin?.left??40)}, ${t.height/2})`,children:d})]}:{id:(s?s+"-":"")+"axes",className:"ordinal-axes",children:[_i("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:n.border,strokeWidth:1}),g.map((e,o)=>Mi("g",{transform:`translate(${e.pixel},${t.height})`,children:[_i("line",{y2:5,stroke:n.border,strokeWidth:1}),_i("text",{y:18,textAnchor:"middle",fontSize:n.tickSize,fill:n.textSecondary,fontFamily:n.fontFamily,children:e.label})]},"oxtick-"+o)),d&&_i("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:n.labelSize,fill:n.text,fontFamily:n.fontFamily,children:d}),_i("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:n.border,strokeWidth:1}),u.map((e,t)=>Mi("g",{transform:`translate(0,${e.pixel})`,children:[_i("line",{x2:-5,stroke:n.border,strokeWidth:1}),_i("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n.tickSize,fill:n.textSecondary,fontFamily:n.fontFamily,children:e.label})]},"oytick-"+t)),h&&_i("text",{x:15-(o.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:n.labelSize,fill:n.text,fontFamily:n.fontFamily,transform:`rotate(-90, ${15-(o.margin?.left??40)}, ${t.height/2})`,children:h})]})}(g,{width:c,height:l},e,o,p):null,v=e.annotations?Co({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{o:g.scales.o,r:g.scales.r,y:"vertical"===g.scales.projection?g.scales.r:void 0},layout:{width:c,height:l},theme:o,projection:h,idPrefix:p}):null,A=Yo({props:e,categories:a,theme:o,size:i,margin:s,hasTitle:r}),w=d?s.left+c/2:s.left,S=d?s.top+l/2:s.top,k=d&&e.centerContent?_i("foreignObject",{x:s.left,y:s.top,width:c,height:l,pointerEvents:"none",children:_i("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},children:e.centerContent})}):null;return Uo.renderToStaticMarkup(Xo(Mi(ki,{children:[e.backgroundGraphics,f,x,b,v,e.foregroundGraphics,g.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${w},${S})`,innerWidth:c,innerHeight:l,legend:A,defs:y,outerElements:k,idPrefix:e._idPrefix}))}import*as Ti from"react-dom/server";import{Fragment as Ri,jsxs as Li}from"react/jsx-runtime";function zi(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}var Ci=new Set(["tree","cluster","treemap","circlepack","partition"]);function Fi(e,t){const o=it(e.theme),i=e.chartType||"force",s=()=>lo({frameType:"network",width:r[0],height:r[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,nodeCount:0,edgeCount:0}),r=e.size||[500,500],n=xe({top:20,right:20,bottom:20,left:20,...e.margin},e.title),a=ae(e.title),c=e.showLegend?(()=>{const t="string"==typeof(o=e.colorBy)||"function"==typeof o?e.colorBy:void 0;var o;if(!t)return[];const i=ie(e.nodes||[]);if(i.length>0)return ko(i,t);const s=Array.isArray(e.edges)?ie(e.edges):[];if(0===s.length)return[];const r=zi(e.sourceAccessor,"source"),n=zi(e.targetAccessor,"target");return ko(Array.from(new Set(s.flatMap(e=>[r(e),n(e)]).filter(e=>null!=e).map(String))).map(e=>({id:e})),t)})():[];Go(n,{props:e,categories:c,theme:o,size:r,hasTitle:a});const l=r[0]-n.left-n.right,h=r[1]-n.top-n.bottom,d=F(i);if(!d&&!e.customNetworkLayout)throw Error(`No layout plugin found for chart type: "${i}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const u={chartType:i,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,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,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,colorBy:e.colorBy,colorScheme:e.colorScheme||o.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,customNetworkLayout:e.customNetworkLayout,layoutConfig:e.layoutConfig};let g,p;if(Ci.has(i)){const i=e.data||e.edges;if(!i||Array.isArray(i))return t&&(t.evidence=s()),Ti.renderToStaticMarkup(Xo(null,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${n.left},${n.top})`,innerWidth:l,innerHeight:h,idPrefix:e._idPrefix}));u.__hierarchyRoot=i,g=[],p=[]}else{const i=ie(e.nodes||[]),a=Array.isArray(e.edges)?ie(e.edges):[];if(0===i.length&&0===a.length)return t&&(t.evidence=s()),Ti.renderToStaticMarkup(Xo(null,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${n.left},${n.top})`,innerWidth:l,innerHeight:h,idPrefix:e._idPrefix}));if(p=function(e,t){const o=zi(t.sourceAccessor,"source"),i=zi(t.targetAccessor,"target"),s=zi(t.valueAccessor,"value");return e.map(e=>({source:o(e)+"",target:i(e)+"",value:Number(s(e))||1,y0:0,y1:0,sankeyWidth:0,data:e}))}(a,u),0===i.length&&p.length>0){const e=new Set;for(const t of p){const o=jo(t.source),i=jo(t.target);o&&e.add(o),i&&e.add(i)}g=Array.from(e).map(e=>({id:e,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:e}}))}else g=function(e,t){const o=zi(t.nodeIDAccessor,"id");return e.map(e=>({id:o(e)+"",x:e.x??0,y:e.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:e}))}(i,u)}let f=[],y=[],m=[],x=null;if(u.customNetworkLayout){const e=u.colorScheme,t=Ae(e,o.colors.categorical,Ie),i=K(t,e),s={nodes:g,edges:p,dimensions:{width:l,height:h,plot:{x:0,y:0,width:l,height:h}},theme:{semantic:o.colors,categorical:[...t]},resolveColor:i,config:u.layoutConfig??{}},r=u.customNetworkLayout(s);f=r.sceneNodes??[],y=r.sceneEdges??[],m=r.labels??[],x=r.overlays??null}else if(d){d.computeLayout(g,p,u,[l,h]);const e=d.buildScene(g,p,u,[l,h]);f=e.sceneNodes,y=e.sceneEdges,m=e.labels}const b=st(o);for(const e of m)e.fill||(e.fill=b.text);const v=E({nodes:y,renderMode:e.renderMode,fallback:(e,t)=>pe(e,t)}),A=E({nodes:f,renderMode:e.renderMode,fallback:(e,t)=>fe(e,t)});t&&(t.evidence=lo({frameType:"network",width:r[0],height:r[1],marks:[...A.map(({node:e})=>({type:"node:"+(e.type??"node")})),...v.map(({node:e})=>({type:"edge:"+(e.type??"edge")}))],title:e.title,description:e.description,annotations:e.annotations,nodeCount:A.length,edgeCount:v.length}));const w=v.map(e=>e.element),S=A.map(e=>e.element),k=m.map((e,t)=>ge(e,t)).filter(Boolean),_=e.annotations?Co({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{},layout:{width:l,height:h},theme:o,idPrefix:e._idPrefix}):null,M=Yo({props:e,categories:c,theme:o,size:r,margin:n,hasTitle:a});return Ti.renderToStaticMarkup(Xo(Li(Ri,{children:[e.backgroundGraphics,w,S,k,_,e.foregroundGraphics,x]}),{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${n.left},${n.top})`,innerWidth:l,innerHeight:h,legend:M,idPrefix:e._idPrefix}))}import*as Bi from"react-dom/server";import{geoPath as Oi}from"d3-geo";import{quadtree as Ei}from"d3-quadtree";import{geoMercator as ji,geoEqualEarth as Di,geoAlbersUsa as Ni,geoOrthographic as Wi,geoNaturalEarth1 as $i,geoEquirectangular as Ii}from"d3-geo";var Gi={mercator:ji,equalEarth:Di,albersUsa:Ni,orthographic:Wi,naturalEarth:$i,equirectangular:Ii};function Yi(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function Vi(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function Xi(e,t,o){return e?"function"==typeof e?{...o,...e(t)}:{...o,...e}:{...o}}function Hi(e,t){if(2>e.length)return[e];const o=.4*t,i=[];let s=[e[0]];for(let t=1;e.length>t;t++){const r=e[t];Math.abs(r[0]-e[t-1][0])>o?(2>s.length||i.push(s),s=[r]):s.push(r)}return 2>s.length||i.push(s),i}function qi(e,t,o=24){const i=t[0]-e[0],s=t[1]-e[1],r=Math.sqrt(i*i+s*s);if(0===r)return[e,t];const n=-s/r,a=i/r,c=Math.min(.3*r,80),l=(e[0]+t[0])/2+n*c,h=(e[1]+t[1])/2+a*c,d=[];for(let i=0;o>=i;i++){const s=i/o,r=1-s;d.push([r*r*e[0]+2*r*s*l+s*s*t[0],r*r*e[1]+2*r*s*h+s*s*t[1]])}return d}function Qi(e,t){if(2>e.length)return e;const o=t/2+1,i=[];for(let t=0;e.length>t;t++){const s=e[t];let r,n;0===t?(r=e[1][0]-s[0],n=e[1][1]-s[1]):t===e.length-1?(r=s[0]-e[t-1][0],n=s[1]-e[t-1][1]):(r=e[t+1][0]-e[t-1][0],n=e[t+1][1]-e[t-1][1]);const a=Math.sqrt(r*r+n*n)||1;i.push([s[0]+n/a*o,s[1]+-r/a*o])}return i}function Zi(e,t,o,i,s){const r=t[0]-e[0],n=t[1]-e[1],a=Math.sqrt(r*r+n*n);if(0===a)return[e,t];const c=n/a,l=-r/a,h=s/2+1;return[[e[0]+c*h,e[1]+l*h],[t[0]+c*h,t[1]+l*h]]}import{scaleLinear as Ui}from"d3-scale";var Ki=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ji=["scene-style","data-paint","accessibility","evidence"],es=(e,t)=>({retainedData:e,invalidations:t}),ts=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],os=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],is=["scene-geometry","data-paint","accessibility","evidence"],ss=["scene-style","data-paint","accessibility","evidence"],rs=["overlay","accessibility","evidence"],ns=[],as={xAccessor:es("rebuild",ts),yAccessor:es("rebuild",ts),lineDataAccessor:es("rebuild",ts),pointIdAccessor:es("rebuild",is),lineIdAccessor:es("rebuild",is),windowSize:es("rebuild",ts),projection:es("preserve",os),projectionExtent:es("preserve",os),fitPadding:es("preserve",os),lineType:es("preserve",os),flowStyle:es("preserve",os),graticule:es("preserve",os),projectionTransform:es("preserve",os),customLayout:es("preserve",os),layoutConfig:es("preserve",os),layoutMargin:es("preserve",os),areaStyle:es("preserve",ss),pointStyle:es("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:es("preserve",ss),colorScheme:es("preserve",ss),themeCategorical:es("preserve",ss),themeDiverging:es("preserve",ss),themeSemantic:es("preserve",ss),themeSequential:es("preserve",ss),decay:es("preserve",ss),pulse:es("preserve",ss),layoutSelection:es("preserve",ss),annotations:es("preserve",rs),autoPlaceAnnotations:es("preserve",rs),clock:es("preserve",ns),transition:es("preserve",ns),introAnimation:es("preserve",ns),onLayoutError:es("preserve",ns)},cs=es("preserve",os),ls=class{constructor(){this.tracker=new ze}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}},Ki)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Ji):this.recordNoop("restyle")}recordConfig(e,t={}){const o=function(e){let t="preserve";const o=new Set;for(const i of e){const e=as[i]??cs;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)o.add(t)}return{retainedData:t,invalidations:o}}(e),i=new Set(o.invalidations);return t.retainedDataChanged&&i.add("data"),this.tracker.record({kind:"config",keys:e},i)}};import{geoDistance as hs,geoGraticule as ds,geoInterpolate as us}from"d3-geo";function gs(e){if(null==e)return 0;if("number"==typeof e&&Number.isFinite(e)&&e>=0&&.5>e)return e;throw new RangeError(`[semiotic] fitPadding must be a finite fraction in [0, 0.5); received ${e+""}.`)}var ps=class e{constructor(e){this.updateResults=new ls,this.scene=[],this.scales=null,this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this.config=function(e){return{...e,fitPadding:gs(e.fitPadding)}}(e)}currentTime(){return this.config.clock?.()??ye()}getConfiguredWindowSize(){const e=this.config.windowSize??500;if(!Number.isInteger(e)||1>e)throw Error("GeoPipelineStore windowSize must be a positive integer");return e}retainNewestLines(e=this.getConfiguredWindowSize()){this.lineData.length>e&&(this.lineData=this.lineData.slice(-e))}resizeStreamingWindow(e){if(this.pointBuffer){const t=this.pointBuffer.toArray(),o=this.timestampBuffer?.toArray()??[],i=t.slice(-e),s=o.slice(-i.length),r=this.currentTime();this.pointBuffer=new Y(e),this.timestampBuffer=new Y(e),i.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(s[t]??r)})}this.retainNewestLines(e)}updateConfig(e){const t=function(e){return"fitPadding"in e?{...e,fitPadding:gs(e.fitPadding)}:e}(e),o=this.config,i=this.getConfiguredWindowSize(),s=Object.keys(t).filter(e=>t[e]!==o[e]);this.config={...this.config,...t};const r=this.getConfiguredWindowSize(),n=this.streaming&&r!==i;n&&(this.resizeStreamingWindow(r),this.version++),"customLayout"in t&&!t.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(s,{retainedDataChanged:n})}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setAreas(e){this.areas=e,this.updateResults.recordData("replace",e.length)}setAreasWithResult(e){return this.setAreas(e),this.updateResults.last}setPoints(e){this.pointData=e.slice(),this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.updateResults.recordData("replace",e.length)}setPointsWithResult(e){return this.setPoints(e),this.updateResults.last}setLines(e){this.lineData=e.slice(),this.streaming&&this.retainNewestLines(),this.updateResults.recordData("replace",e.length)}setLinesWithResult(e){return this.setLines(e),this.updateResults.last}initStreaming(e){void 0!==e&&e!==this.config.windowSize&&(this.config={...this.config,windowSize:e});const t=this.getConfiguredWindowSize(),o=this.pointBuffer?this.pointBuffer.toArray():this.pointData,i=this.timestampBuffer?.toArray()??[],s=o.slice(-t),r=i.slice(-s.length),n=this.currentTime();this.pointBuffer=new Y(t),this.timestampBuffer=new Y(t),s.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(r[t]??n)}),this.pointData=[],this.retainNewestLines(t),this.streaming=!0}pushPoint(e){this.pointBuffer||this.initStreaming();const t=this.currentTime();O(this.pointBuffer,e,this.timestampBuffer,t),this.lastIngestTime=t,this.updateResults.recordData("ingest",1)}pushPointWithResult(e){return this.pushPoint(e),this.updateResults.last}pushMany(e){this.pointBuffer||this.initStreaming();const t=this.currentTime();for(const o of e)O(this.pointBuffer,o,this.timestampBuffer,t);this.lastIngestTime=t,this.updateResults.recordData("ingest",e.length)}pushManyWithResult(e){return this.pushMany(e),this.updateResults.last}pushLine(e){null!=e&&"object"==typeof e?(this.streaming||this.initStreaming(),this.lineData.push(e),this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",1)):this.updateResults.recordNoop("ingest")}pushManyLines(e){if(!Array.isArray(e)||0===e.length)return void this.updateResults.recordNoop("ingest");const t=e.filter(e=>null!=e&&"object"==typeof e);if(0!==t.length){this.streaming||this.initStreaming();for(const e of t)this.lineData.push(e);this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",t.length)}else this.updateResults.recordNoop("ingest")}removeLine(e){const{lineIdAccessor:t}=this.config;if(!t)throw Error("removeLine() requires lineIdAccessor to be configured");const o="function"==typeof t?t:e=>e[t],i=new Set(Array.isArray(e)?e:[e]),s=[];return this.lineData=this.lineData.filter(e=>!i.has(o(e)+"")||(s.push(e),!1)),s.length>0?(this.version++,this.updateResults.recordData("remove",s.length)):this.updateResults.recordNoop("remove"),s}getLines(){return this.lineData.slice()}removePoint(e){const{pointIdAccessor:t}=this.config;if(!t)throw Error("removePoint() requires pointIdAccessor to be configured");const o="function"==typeof t?t:e=>e[t],i=new Set(Array.isArray(e)?e:[e]);if(this.streaming&&this.pointBuffer){const e=e=>i.has(o(e)+"");P(this.pointBuffer,this.timestampBuffer,e);const t=this.pointBuffer.remove(e);return t.length>0?(this.version++,this.updateResults.recordData("remove",t.length)):this.updateResults.recordNoop("remove"),t}{const e=[];return this.pointData=this.pointData.filter(t=>!i.has(o(t)+"")||(e.push(t),!1)),e.length>0?(this.version++,this.updateResults.recordData("remove",e.length)):this.updateResults.recordNoop("remove"),e}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this.version++,this.updateResults.recordData("clear")}restyleScene(e){const t=this._customRestyle;if(t){for(const o of this.scene){const i=this._baseStyles.get(o)??o.style,s=t(o,e);o.style=s?{...i,...s}:i}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(e){const{config:t}=this,o=this.projection,i=this.geoPath,s=this.scales,r=this.baseScale,n=[...this.baseTranslate],a=[...this.baseRotation],c=this.scene;this.projection=function(e){if(!e)return Di();if("string"==typeof e){const t=Gi[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),Di())}if("object"==typeof e&&"type"in e){const t=Gi[e.type],o=t?t():Di();return e.rotate&&"rotate"in o&&o.rotate(e.rotate),e.center&&"center"in o&&o.center(e.center),o}return e}(t.projection),this.geoPath=Oi(this.projection),this.fitProjection(e),this.geoPath=Oi(this.projection);const l=this.projection;this.scales={projection:l,geoPath:this.geoPath,projectedPoint:(e,t)=>l([e,t]),invertedPoint:(e,t)=>l.invert?l.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const h=this.buildSceneNodes(e);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=o,this.geoPath=i,this.scales=s,this.baseScale=r,this.baseTranslate=n,this.baseRotation=a):(this.scene=[],this.rebuildQuadtree());else{if(this.scene=h,this.rebuildQuadtree(),t.projectionTransform&&this.applyCartogramTransform(t.projectionTransform,e),t.decay&&this.streaming&&this.applyDecay(),t.pulse&&this.streaming&&this.applyPulse(),t.transition&&!this._hasRenderedOnce&&this.scene.length>0&&t.introAnimation){const t=e.width/2,o=e.height/2,i=this.scene.filter(e=>"point"===e.type).map(e=>({...e,x:t,y:o}));i.length>0&&this.startTransition(i)}this._hasRenderedOnce=!0,t.transition&&c.length>0&&this.startTransition(c),this.version++}}fitProjection(e){const t=this.projection,o=this.config,i=[...this.areas],s=Yi(o.xAccessor,"lon"),r=Yi(o.yAccessor,"lat"),n=this.getPoints();if(n.length>0){const e=n.map(e=>[s(e),r(e)]);i.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}const a=Vi(o.lineDataAccessor);for(const e of this.lineData){const t=a(e);if(t&&t.length>0){const e=t.map(e=>[s(e),r(e)]);i.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==i.length){if(o.projectionExtent){const[[i,s],[r,n]]=o.projectionExtent;t.fitExtent([[0,0],[e.width,e.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[i,s],[i,n],[r,n],[r,s],[i,s]]]}})}else if(t.clipAngle&&(t.clipAngle()??0)>0){const i=o.fitPadding??0,s=Math.min(e.width,e.height);t.scale(s/2-s*i),t.translate([e.width/2,e.height/2])}else{const s=o.fitPadding??0,r=e.width*s,n=e.height*s;t.fitExtent([[r,n],[e.width-r,e.height-n]],{type:"FeatureCollection",features:i})}this.baseScale=t.scale(),this.baseTranslate=t.translate(),this.baseRotation=t.rotate?.()??[0,0,0]}}applyZoomTransform(e,t){const o=this.projection;if(!o)return;const i=this.geoPath,s=this.scales,r=o.scale(),n=[...o.translate()],a=this.currentZoom;o.scale(this.baseScale*e.k),o.translate([this.baseTranslate[0]*e.k+e.x,this.baseTranslate[1]*e.k+e.y]),this.currentZoom=e.k,this.geoPath=Oi(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(e,t)=>o([e,t]),invertedPoint:(e,t)=>o.invert?o.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(o.scale(r),o.translate(n),this.currentZoom=a,this.geoPath=i,this.scales=s):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyZoomScale(e,t){const o=this.projection;if(!o)return;const i=this.geoPath,s=this.scales,r=o.scale(),n=[...o.translate()],a=this.currentZoom;o.scale(this.baseScale*e),o.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=Oi(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(e,t)=>o([e,t]),invertedPoint:(e,t)=>o.invert?o.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(o.scale(r),o.translate(n),this.currentZoom=a,this.geoPath=i,this.scales=s):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyRotation(e,t){const o=this.projection;if(!o||!o.rotate)return;const i=this.geoPath,s=this.scales,r=[...o.rotate()];o.rotate(e),this.geoPath=Oi(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(e,t)=>o([e,t]),invertedPoint:(e,t)=>o.invert?o.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const n=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(o.rotate(r),this.geoPath=i,this.scales=s):(this.scene=[],this.rebuildQuadtree()):(this.scene=n,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}setRotation(e){const t=this.projection;t&&t.rotate&&t.rotate(e)}hasProjection(){return null!=this.projection}getRotation(){return this.projection?.rotate?.()??this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let t=0,o=0;for(const e of this.scene)"point"===e.type&&(o++,e.r>t&&(t=e.r));if(this._maxPointRadius=t,e.QUADTREE_THRESHOLD>=o)return void(this._quadtree=null);const i=Array(o);let s=0;for(const e of this.scene)"point"===e.type&&(i[s++]=e);this._quadtree=Ei().x(e=>e.x).y(e=>e.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(e){this._customLayoutFailedThisBuild=!1;const{config:t}=this,o=this.projection,i=this.geoPath;if(t.customLayout&&this.scales){const o=t.layoutMargin??{top:0,right:0,bottom:0,left:0},i=Ae(t.colorScheme,t.themeCategorical,q),s={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:e.width,height:e.height,margin:o,plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:t.themeSemantic??{},categorical:[...i]},resolveColor:K(i,t.colorScheme),config:t.layoutConfig??{},selection:t.layoutSelection??null};let r;try{r=t.customLayout(s)}catch(e){const o=null!==this.lastCustomLayoutResult,i=L("geo",e,o,this.version);this.lastCustomLayoutFailure=i,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] geo customLayout threw:",e);try{t.onLayoutError?.(i)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return o?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}const n=r.nodes??[];if(this.customLayoutOverlays=r.overlays??null,this.lastCustomLayoutResult=r,this.lastCustomLayoutFailure=null,this._customRestyle=r.restyle,this.hasCustomRestyle=!!r.restyle,this._baseStyles=new WeakMap,this.hasCustomRestyle){for(const e of n)this._baseStyles.set(e,e.style);this.restyleScene(t.layoutSelection??null)}return I({label:"geo customLayout",nodes:n,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),n}return this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,function({config:e,projection:t,path:o,areas:i,points:s,lines:r,layout:n}){const a=Yi(e.xAccessor,"lon"),c=Yi(e.yAccessor,"lat"),l=[],h=function(e){return{fill:e.themeSemantic?.surface||"#e0e0e0",stroke:e.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}(e),d=function(e){return{stroke:e.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}(e),u=function(e){return{fill:e.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(e);if(e.graticule){const t=!0===e.graticule?{}:e.graticule,i=ds();t.step&&i.step(t.step);const s=o(i())||"";s&&l.push({type:"geoarea",pathData:s,centroid:[n.width/2,n.height/2],bounds:[[0,0],[n.width,n.height]],screenArea:0,style:{fill:"none",stroke:t.stroke||"#e0e0e0",strokeWidth:t.strokeWidth||.5,strokeDasharray:t.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const t of i){const i=o(t);if(!i)continue;const s=o.centroid(t),r=o.bounds(t),n=o.area(t);l.push({type:"geoarea",pathData:i,centroid:s,bounds:r,screenArea:n,style:Xi(e.areaStyle,t,h),datum:t,interactive:!0})}const g=Vi(e.lineDataAccessor);for(const o of r){const i=g(o);if(!i||2>i.length)continue;let s=[];if("geo"===e.lineType){const e=Array(i.length);for(let t=0;i.length>t;t++)e[t]=[a(i[t]),c(i[t])];for(let o=0;e.length-1>o;o++){const i=e[o],r=e[o+1],n=hs(i,r)||0,a=Math.max(2,Math.ceil(n/(Math.PI/180))),c=us(i,r);for(let e=0;a>=e;e++){if(o>0&&0===e)continue;const i=t(c(e/a));null!=i&&s.push(i)}}}else for(let e=0;i.length>e;e++){const o=i[e],r=t([a(o),c(o)]);null!=r&&s.push(r)}if(2>s.length)continue;const r=Xi(e.lineStyle,o,d),h="number"==typeof r.strokeWidth?r.strokeWidth:1;2!==i.length||2>s.length||"arc"!==e.flowStyle?2!==i.length||2>s.length||"offset"!==e.flowStyle||(s="geo"===e.lineType?Qi(s,h):Zi(s[0],s[s.length-1],0,0,h)):s=qi(s[0],s[s.length-1]);const u=Hi(s,n.width);if(u.length>1)for(const e of u)2>e.length||l.push({type:"line",path:e,style:{...r,_edgeFade:!0},datum:o});else l.push({type:"line",path:2>s.length&&u[0]||s,style:r,datum:o})}const p=e.pointIdAccessor?"function"==typeof e.pointIdAccessor?e.pointIdAccessor:t=>t[e.pointIdAccessor]:null,f=t.clipAngle?t.clipAngle()??0:0,y=f>0?f*Math.PI/180:null,m=t.rotate?t.rotate():[0,0,0],x="function"==typeof t.center?t.center():[0,0],b=[(x[0]??0)-m[0],(x[1]??0)-m[1]];for(const o of s){const i=a(o),s=c(o);if(null!=y&&hs([i,s],b)>y)continue;const r=t([i,s]);if(!r)continue;const n=e.pointStyle?e.pointStyle(o):{...u},h={type:"point",x:r[0],y:r[1],r:n.r||4,style:n,datum:o,pointId:p?p(o)+"":void 0};l.push(h)}return l}({config:t,projection:o,path:i,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:e})}applyCartogramTransform(e,t){const o=function(e,t,o,i){const s=e.filter(e=>"point"===e.type);if(2>s.length)return null;const r=t.strength??1;if(0===r)return null;const n=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:e=>e.id,a="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],c=s.find(e=>e.datum&&n(e.datum)+""==t.center+"");if(!c)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`),null;const l=c.x,h=c.y,d=s.map(e=>e.datum?a(e.datum):NaN).filter(e=>isFinite(e)&&e>=0),u=Ge(d,1),g=Math.min(o.width,o.height)/2,p=Ui().domain([0,u]).range([0,g]);i>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them.");for(let t=e.length-1;t>=0;t--){const o=e[t];"geoarea"===o.type&&o.interactive&&e.splice(t,1)}for(const e of s){if(e===c)continue;if(!e.datum)continue;const t=Math.atan2(e.y-h,e.x-l),o=Math.sqrt((e.x-l)**2+(e.y-h)**2),i=a(e.datum),s=o+((isFinite(i)?p(i):o)-o)*r;e.x=l+Math.cos(t)*s,e.y=h+Math.sin(t)*s}const f=o.width/2,y=o.height/2,m=f-c.x,x=y-c.y;if(Math.abs(m)>.5||Math.abs(x)>.5)for(const e of s)e.x+=m,e.y+=x;const b={cx:f,cy:y,maxCost:u,availableRadius:g},v=e.filter(e=>"line"===e.type);if(v.length>0&&"fractional"!==t.lineMode){const e=new Map;for(const t of s)t.pointId&&e.set(t.pointId,[t.x,t.y]);for(const t of v){const o=t.datum?.source,i=t.datum?.target;if(o&&i){const s=e.get(o+""),r=e.get(i+"");s&&r&&(t.path=[s,r])}}}return b}(this.scene,e,t,this.areas.length);o&&(this.cartogramLayout=o)}applyDecay(){const e=this.config.decay;if(!e||!this.pointBuffer)return;const t=this.pointBuffer.size;if(0===t)return;const o=this.scene.filter(e=>"point"===e.type);for(let i=0;o.length>i;i++){const s=T(e,i,t);o[i]._decayOpacity=s,o[i].style={...o[i].style,opacity:s}}}applyPulse(e=this.currentTime()){const t=this.config.pulse;if(!t||!this.timestampBuffer)return!1;const o=this.scene.filter(e=>"point"===e.type),i=this.timestampBuffer.toArray(),s=t.color||"rgba(255,255,255,0.6)",r=t.glowRadius??4;let n=!1;for(let a=0;o.length>a&&i.length>a;a++){const c=R(t,i[a],e);n=N(o[a],c,s,r)||n}return n}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(e)}hasActivePulsesAt(e){return!!this.config.pulse&&B(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}startTransition(e){const t=this.config.transition?.duration??300;if(0>=t)return;const o=new Map;for(const t of e)"point"===t.type&&t.pointId&&o.set(t.pointId,[t.x,t.y]);const i=this.scene.filter(e=>"point"===e.type);let s=!1;for(const e of i)if(e.pointId){const t=o.get(e.pointId);t&&(e._targetX=e.x,e._targetY=e.y,e.x=t[0],e.y=t[1],(Math.abs(t[0]-e._targetX)>.5||Math.abs(t[1]-e._targetY)>.5)&&(s=!0))}for(const e of i)e.pointId&&!o.has(e.pointId)&&(e._targetOpacity=e.style?.opacity??1,e.style={...e.style,opacity:0},s=!0);s&&(this.activeTransition={startTime:this.currentTime(),duration:t})}cancelIntroAnimation(){this.activeTransition=null}advanceTransition(e){if(!this.activeTransition)return!1;const t=te(e,this.activeTransition),o=ee(t),i=this.scene.filter(e=>"point"===e.type);for(const e of i){if(null!=e._targetX&&null!=e._targetY){const t=e.y;e.x=ue(e.x,e._targetX,o),e.y=ue(t,e._targetY,o)}null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity*o})}if(t>=1){for(const e of i)null!=e._targetX&&(e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0),null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity},e._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}};ps.QUADTREE_THRESHOLD=500;var fs=ps;S(fs);import{Fragment as ys,jsxs as ms}from"react/jsx-runtime";function xs(e,t){const o=it(e.theme),i=e.size||[e.width||600,e.height||400],s=xe({top:10,right:10,bottom:10,left:10,...e.margin},e.title),r=ae(e.title),n=Array.isArray(e.areas)?ie(e.areas):e.areas,a=ie(e.points),c=ie(e.lines),l=e.showLegend?(()=>{const t="string"==typeof(o=e.colorBy)||"function"==typeof o?e.colorBy:void 0;var o;return ko(a.length>0?a:Array.isArray(n)&&n.length>0?"string"==typeof t?n.map(e=>({...e.properties||{},...e})):n:[],t)})():[];Go(s,{props:e,categories:l,theme:o,size:i,hasTitle:r});const h=i[0]-(s.left??0)-(s.right??0),d=i[1]-(s.top??0)-(s.bottom??0),u={projection:e.projection||"equalEarth",xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineType:e.lineType,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform,customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:s,themeCategorical:o.colors.categorical,themeSemantic:Ue(o)},g=new fs(u);if(n){if("string"==typeof n)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${n}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${n}')\` before calling renderGeoToStaticSVG.`);g.setAreas(n)}e.points&&g.setPoints(a),e.lines&&g.setLines(c),g.computeScene({width:h,height:d});const p=E({nodes:g.scene,renderMode:e.renderMode,fallback:(e,t)=>se(e,t)});if(t&&(t.evidence=lo({frameType:"geo",width:i[0],height:i[1],marks:p.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,legendItems:l.length>0?l.length:void 0})),0===p.length){const t=e.backgroundGraphics||e.foregroundGraphics||e.annotations||g.customLayoutOverlays?ms(ys,{children:[e.backgroundGraphics,e.annotations?Co({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{geoProjection:g.scales?.projectedPoint?([e,t])=>g.scales.projectedPoint(e,t):void 0},layout:{width:h,height:d},theme:o,idPrefix:e._idPrefix}):null,e.foregroundGraphics,g.customLayoutOverlays]}):null;return Bi.renderToStaticMarkup(Xo(t,{width:i[0],height:i[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${s.left??0},${s.top??0})`,innerWidth:h,innerHeight:d,idPrefix:e._idPrefix}))}const f=p.map(e=>e.element),y=e.annotations?Co({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{geoProjection:g.scales?.projectedPoint?([e,t])=>g.scales.projectedPoint(e,t):void 0},layout:{width:h,height:d},theme:o,idPrefix:e._idPrefix}):null,m=Yo({props:e,categories:l,theme:o,size:i,margin:s,hasTitle:r});return Bi.renderToStaticMarkup(Xo(ms(ys,{children:[e.backgroundGraphics,f,y,e.foregroundGraphics,g.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${s.left??0},${s.top??0})`,innerWidth:h,innerHeight:d,legend:m,idPrefix:e._idPrefix}))}function bs(e,t){const o=e.size??[e.width??600,e.height??400],i=new A(e.config);Array.isArray(e.initialSpawns)&&e.initialSpawns.length>0&&i.enqueue(e.initialSpawns.map(e=>({...e,spawnAt:void 0})));const s=d(i,{...e,width:o[0],height:o[1],idPrefix:e.idPrefix??e._idPrefix??"physics"});return t&&(t.evidence=lo({frameType:"physics",width:o[0],height:o[1],marks:s.scene.sceneNodes,title:e.title,description:e.description,annotations:[],extraWarnings:0===s.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[]})),s.svg}import{Fragment as vs,jsx as As,jsxs as ws}from"react/jsx-runtime";function Ss(e,t){switch(e){case"xy":return Zo(t);case"ordinal":return Pi(t);case"network":return Fi(t);case"geo":return xs(t);case"physics":return bs(t);default:throw Error(`Unknown frame type: ${e}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function ks(e){return Zo(e)}function _s(e){return Pi(e)}function Ms(e){return Fi(e)}function Ps(e){return xs(e)}var Ts=["showAxes","axes","axisExtent","xLabel","yLabel","yLabelRight","categoryLabel","valueLabel","xFormat","yFormat","categoryFormat","valueFormat","tickFormatTime","tickFormatValue","xScaleType","yScaleType","xExtent","yExtent","rExtent","oExtent","extentPadding","scalePadding","sizeRange","innerRadius","centerContent","curve","gradientFill","lineGradient","lineStyle","pointStyle","areaStyle","barStyle","waterfallStyle","swarmStyle","pieceStyle","summaryStyle","nodeStyle","edgeStyle","connectorStyle","backgroundGraphics","foregroundGraphics","svgPreRenderers","barColors","legend","legendLayout"],Rs=["width","height","showAxes","showGrid","enableHover","showLegend","showLabels","showCategoryTicks","orientation","title","description","summary","accessibleTable","xLabel","yLabel","categoryLabel","valueLabel","linkedHover","mobileInteraction","mobileSemantics","responsiveRules"];function Ls(e,t){const o={};for(const i of t)void 0!==e[i]&&(o[i]=e[i]);return o}function zs(e,t,o){return Fs(e,t).svg}function Cs(e,t,o){const i={},{svg:s,frameType:r}=Fs(e,t,0,i),n=i.evidence??lo({frameType:r,width:"number"==typeof t.width?t.width:600,height:"number"==typeof t.height?t.height:400,marks:[],title:"string"==typeof t.title?t.title:void 0,description:"string"==typeof t.description?t.description:void 0,annotations:t.annotations,extraWarnings:["NO_EVIDENCE"]});return n.component=e,{svg:s,evidence:n}}function Fs(e,t,o,i){const s=no[e];if(!s)throw Error(`Unknown chart component: "${e}". See CLAUDE.md for supported chart types.`);const r=s.layout?.mode??(ce(t.mode)?t.mode:void 0),n=ve(r,{...s.layout?.modeDefaults,...Ls(t,Rs)},s.layout?.primarySize),{data:a,theme:c,background:l,className:h,annotations:d,margin:u,colorScheme:g,colorBy:p,legendPosition:f,...y}=t,{width:m,height:x}=n,b=[m,x],v=y.frameProps||{},A=s.layout?.margin,w="function"==typeof A?A(t,n):A??n.marginDefaults,S=void 0!==u?u:v.margin,k=function(e){if(null==e)return;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};const t={};return"number"==typeof e.top&&(t.top=e.top),"number"==typeof e.right&&(t.right=e.right),"number"==typeof e.bottom&&(t.bottom=e.bottom),"number"==typeof e.left&&(t.left=e.left),t}(S),_="number"==typeof S?{top:S,right:S,bottom:S,left:S}:{...w,...k},M=Ls(y,Ts),P={...v,...M,theme:c,title:n.title,description:n.description,showAxes:n.showAxes,showLegend:n.showLegend,showLabels:n.showLabels,showGrid:n.showGrid,xLabel:n.xLabel,yLabel:n.yLabel,categoryLabel:n.categoryLabel,valueLabel:n.valueLabel,background:l,className:h,annotations:d,size:b,margin:_,__explicitMargin:S,__autoLegendMargin:!0,...void 0!==g&&{colorScheme:g},...void 0!==f&&{legendPosition:f},_idPrefix:y._idPrefix},T=s.buildProps(a,p,g,P,y);let R;switch(s.frameType){case"xy":R=Zo(T,i);break;case"ordinal":R=Pi(T,i);break;case"network":R=Fi(T,i);break;case"geo":R=xs(T,i);break;case"physics":R=bs(T,i)}const L=s.renderOverlay?.(T,{theme:it(c)});if(null!=L){const e=Ke.renderToStaticMarkup(As(vs,{children:L}));R=R.replace("</svg>",e+"</svg>")}return{svg:R,frameType:s.frameType}}function Bs(e,t={}){const{title:o,subtitle:i,theme:s,width:r=1200,height:n,layout:a={},background:c}=t,l=st(it(s)),h=a.columns||2,d=a.gap??16;let u=0;o&&(u+=30),i&&(u+=20),u>0&&(u+=10);const g=Math.floor((r-d-d*(h-1))/h),p=[];let f=0,y=u+d,m=0;for(const t of e){const e=Math.min(t.colSpan||1,h),o=t.props.height||300;f+e>h&&(y+=m+d,f=0,m=0),p.push({chart:t,x:d/2+f*(g+d),y:y,w:g*e+d*(e-1),h:o}),m=Math.max(m,o),f+=e}const x=n||y+m+d,b=p.map((e,t)=>{const{chart:o,x:i,y:r,w:n,h:a}=e,c={...o.props,width:n,height:a,theme:s,_idPrefix:"chart-"+t};let l;return l=o.component?zs(o.component,c):o.frameType?Ss(o.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${a}"></svg>`,As("g",{transform:`translate(${i},${r})`,children:As("foreignObject",{width:n,height:a,children:As("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:l}})})},"dashboard-chart-"+t)});return Ke.renderToStaticMarkup(ws("svg",{xmlns:"http://www.w3.org/2000/svg",width:r,height:x,role:"img","aria-label":o||"Dashboard",style:{fontFamily:l.fontFamily},children:[o&&As("title",{children:o}),c&&As("rect",{x:0,y:0,width:r,height:x,fill:c}),o&&As("text",{x:r/2,y:24,textAnchor:"middle",fontSize:l.titleSize+4,fontWeight:"bold",fill:l.text,fontFamily:l.fontFamily,children:o}),i&&As("text",{x:r/2,y:o?46:20,textAnchor:"middle",fontSize:l.labelSize,fill:l.textSecondary,fontFamily:l.fontFamily,children:i}),b]}))}import*as Os from"react-dom/server";import{Fragment as Es,jsx as js,jsxs as Ds}from"react/jsx-runtime";function Ns(e,t,o,i={}){const{stepSize:s,windowSize:r,frameCount:n,xExtent:a,yExtent:c,transitionFrames:l=4,fps:h=12,easing:d="ease-out",decay:u}=i,g=o.width||600,p=o.height||400,f=it(o.theme),y={...o,...a&&{xExtent:a},...c&&{yExtent:c}};if(!t||0===t.length)return[];const m=s||Math.max(1,Math.ceil(t.length/(n||Math.min(60,Math.max(10,t.length))))),x=[];for(let e=m;t.length>=e;e+=m)x.push(e);x[x.length-1]!==t.length&&x.push(t.length);const b=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(e),v=xe({top:20,right:20,bottom:30,left:40,...o.margin},o.title),A=g-v.left-v.right,S=p-v.top-v.bottom,k=[];if(b)for(let i=0;x.length>i;i++){const s=x[i],n=t.slice(r?Math.max(0,s-r):0,s),a={chartType:e,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:o.projection||"vertical",oAccessor:o.oAccessor||o.categoryAccessor||"category",rAccessor:o.rAccessor||o.valueAccessor||"value",colorAccessor:o.colorAccessor||o.colorBy,stackBy:o.stackBy,groupBy:o.groupBy,barPadding:o.barPadding,innerRadius:o.innerRadius,normalize:o.normalize,bins:o.bins,colorScheme:o.colorScheme||f.colors.categorical,...u&&{decay:u}},c=new Ai(a);c.ingest({inserts:n,bounded:!0}),c.computeScene({width:A,height:S}),c.scene.length>0&&k.push(Vs(c.scene,g,p,f,y))}else for(let i=0;x.length>i;i++){const s=x[i],n=t.slice(r?Math.max(0,s-r):0,s),m={chartType:e,windowSize:n.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:o.colorAccessor||o.colorBy,groupAccessor:o.groupAccessor||o.lineBy,lineDataAccessor:o.lineDataAccessor,xExtent:a,yExtent:c,colorScheme:o.colorScheme||f.colors.categorical,lineStyle:o.lineStyle,pointStyle:o.pointStyle,areaStyle:o.areaStyle,sizeAccessor:o.sizeAccessor||o.sizeBy,sizeRange:o.sizeRange,...u&&{decay:u},...l>0&&{transition:{duration:l*(1e3/h),easing:d}}},b=new w(m);if(b.ingest({inserts:n,bounded:!0}),b.computeScene({width:A,height:S}),0===b.scene.length)continue;const v=b.scales?{y:b.scales.y}:void 0;if(k.push(Ys(b.scene,g,p,f,y,v)),l>0&&i>0&&b.activeTransition){const e=l*(1e3/h);for(let t=1;l>=t;t++)b.advanceTransition(b.activeTransition.startTime+t/l*e),k.push(Ys(b.scene,g,p,f,y,v))}}return k}function Ws(e,t,o={}){return t.map(t=>{try{return zs(e,{...o,...t})}catch{return`<svg xmlns="http://www.w3.org/2000/svg" width="${o.width||t.width||600}" height="${o.height||t.height||400}"></svg>`}})}function $s(e,t,o){const i=t.size??[t.width??600,t.height??400],s=it(t.theme),r=st(s),n=t.background||s.colors.background,a=t.idPrefix??"physics-gif",c=t.title?`${a}-title-${o}`:void 0,l=t.description?`${a}-desc-${o}`:void 0,d=[c,l].filter(Boolean).join(" ")||void 0,u=h(e.readBodies(),{bodyStyle:t.bodyStyle,getBodyLabel:t.getBodyLabel}),g=Ds("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className??"stream-physics-frame",width:i[0],height:i[1],viewBox:`0 0 ${i[0]} ${i[1]}`,role:"img","aria-labelledby":d,style:{fontFamily:r.fontFamily},children:[t.title&&js("title",{id:c,children:t.title}),t.description&&js("desc",{id:l,children:t.description}),n&&"transparent"!==n?js("rect",{x:0,y:0,width:i[0],height:i[1],fill:n}):null,js("g",{id:`${a}-frame-${o}`,children:u.map((e,t)=>_e(e,t,`${a}-${o}`))})]});return Os.renderToStaticMarkup(g)}function Is(e,t={}){const{fps:o=12,frameCount:i,durationSeconds:s=2,includeInitialFrame:r=!0,stepDt:n,stepsPerFrame:a,background:c}=t,l=Math.max(.001,n??e.config?.fixedDt??1/120),h=a??Math.max(1,Math.round(1/Math.max(1,o)/l)),d=i??Math.max(1,Math.ceil(s*Math.max(1,o))),u=c?{...e,background:c}:e,g=new A(e.config);e.initialSpawns?.length&&g.enqueue(e.initialSpawns,e.initialSpawnPacing);const p=[];for(r&&(g.tick(0),p.push($s(g,u,0)));d>p.length;){for(let e=0;h>e;e+=1)g.tick(l);p.push($s(g,u,p.length))}return p}function Gs(e,t){const o=e.background||t.colors.background;return o&&"transparent"!==o?o:null}function Ys(e,t,o,i,s,r){const n=st(i),a=xe({top:20,right:20,bottom:30,left:40,...s.margin},s.title),c=t-a.left-a.right,l=o-a.top-a.bottom,h=Gs(s,i),d=s.renderMode,u=e.map((e,t)=>j({node:e,index:t,renderMode:d,fallback:()=>_e(e,t)})).filter(Boolean),g=function(e,t,o,i,s,r){if(!e||0===e.length)return null;const n=st(i),a=[];for(let i=0;e.length>i;i++){const c=e[i];if("y-threshold"===c.type&&null!=c.value){let e=null;if(r)e=r(c.value);else if(s){const[t,i]=s,r=i-t;if(0===r)continue;e=o-(c.value-t)/r*o}if(null==e)continue;const l=c.color||n.primary,h=c.labelPosition||"right";a.push(Ds("g",{children:[js("line",{x1:0,y1:e,x2:t,y2:e,stroke:l,strokeWidth:c.strokeWidth??1.5,strokeDasharray:c.strokeDasharray||"6,4"}),c.label&&js("text",{x:"left"===h?4:"center"===h?t/2:t-4,y:20>e?Math.min(o-4,e+16):e-5,textAnchor:"left"===h?"start":"center"===h?"middle":"end",fontSize:n.tickSize,fill:l,fontFamily:n.fontFamily,children:c.label})]},"ann-"+i))}}return a.length>0?js(Es,{children:a}):null}(s.annotations,c,l,i,s.yExtent,r?.y),p="string"==typeof s.title?s.title:void 0,f="string"==typeof s.description?s.description:void 0,y=p?"semiotic-title":void 0,m=f?"semiotic-desc":void 0,x=[y,m].filter(Boolean).join(" ")||void 0;return Os.renderToStaticMarkup(Ds("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:o,role:"img","aria-labelledby":x,style:{fontFamily:n.fontFamily},children:[p&&js("title",{id:y,children:p}),f&&js("desc",{id:m,children:f}),h&&js("rect",{x:0,y:0,width:t,height:o,fill:h}),Ds("g",{transform:`translate(${a.left},${a.top})`,children:[g,u]}),p&&js("text",{x:t/2,y:Z,textAnchor:"middle",fontSize:n.titleSize,fontWeight:"bold",fill:n.text,fontFamily:n.fontFamily,children:p})]}))}function Vs(e,t,o,i,s){const r=st(i),n=xe({top:20,right:20,bottom:30,left:40,...s.margin},s.title),a="radial"===s.projection,c=a?n.left+(t-n.left-n.right)/2:n.left,l=a?n.top+(o-n.top-n.bottom)/2:n.top,h=Gs(s,i),d=s.renderMode,u=e.map((e,t)=>j({node:e,index:t,renderMode:d,fallback:()=>me(e,t)})).filter(Boolean),g="string"==typeof s.title?s.title:void 0,p="string"==typeof s.description?s.description:void 0,f=g?"semiotic-title":void 0,y=p?"semiotic-desc":void 0,m=[f,y].filter(Boolean).join(" ")||void 0;return Os.renderToStaticMarkup(Ds("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:o,role:"img","aria-labelledby":m,style:{fontFamily:r.fontFamily},children:[g&&js("title",{id:f,children:g}),p&&js("desc",{id:y,children:p}),h&&js("rect",{x:0,y:0,width:t,height:o,fill:h}),js("g",{transform:`translate(${c},${l})`,children:u}),g&&js("text",{x:t/2,y:Z,textAnchor:"middle",fontSize:r.titleSize,fontWeight:"bold",fill:r.text,fontFamily:r.fontFamily,children:g})]}))}export{Ns as generateFrameSVGs,Ws as generateFrameSequence,Is as generatePhysicsFrameSVGs,zs as renderChart,Cs as renderChartWithEvidence,Bs as renderDashboard,Ps as renderGeoToStaticSVG,Ms as renderNetworkToStaticSVG,_s as renderOrdinalToStaticSVG,Ss as renderToStaticSVG,ks as renderXYToStaticSVG,it as resolveTheme,st as themeStyles};