semiotic 3.8.3 → 3.8.4

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 (163) hide show
  1. package/CLAUDE.md +9 -9
  2. package/README.md +40 -39
  3. package/ai/examples.md +1 -1
  4. package/ai/schema.json +2726 -300
  5. package/ai/surface-manifest.json +1 -1
  6. package/ai/system-prompt.md +1 -1
  7. package/dist/chunk-chunk-2JGJ5GUG.module.min.js +0 -1
  8. package/dist/chunk-chunk-3ILKBVVQ.module.min.js +1 -0
  9. package/dist/{chunk-chunk-XQYVEKEJ.module.min.js → chunk-chunk-6TPGFL7M.module.min.js} +1 -1
  10. package/dist/{chunk-chunk-VVCA3DB7.module.min.js → chunk-chunk-7ALTGHK6.module.min.js} +1 -1
  11. package/dist/chunk-chunk-7KZJUTKP.module.min.js +2 -0
  12. package/dist/chunk-chunk-7RYBCTK5.module.min.js +1 -0
  13. package/dist/chunk-chunk-ACLDBMRH.module.min.js +2 -0
  14. package/dist/{chunk-chunk-AZJUDQRM.module.min.js → chunk-chunk-AQPQN2HH.module.min.js} +1 -1
  15. package/dist/chunk-chunk-ASKSE5F5.module.min.js +1 -0
  16. package/dist/chunk-chunk-AVBI6GDT.module.min.js +1 -0
  17. package/dist/chunk-chunk-B3DRZPBK.module.min.js +2 -0
  18. package/dist/chunk-chunk-BFHUYEOS.module.min.js +2 -0
  19. package/dist/chunk-chunk-C4YA6TDR.module.min.js +1 -0
  20. package/dist/chunk-chunk-C57LR3YG.module.min.js +1 -0
  21. package/dist/chunk-chunk-F5V4UIE6.module.min.js +2 -0
  22. package/dist/chunk-chunk-F7WFPD4O.module.min.js +2 -0
  23. package/dist/{chunk-chunk-SANERMIZ.module.min.js → chunk-chunk-FBGHXL72.module.min.js} +1 -1
  24. package/dist/chunk-chunk-FP44FHFO.module.min.js +2 -0
  25. package/dist/chunk-chunk-HKXUAEPJ.module.min.js +2 -0
  26. package/dist/chunk-chunk-ICEXPNDC.module.min.js +2 -0
  27. package/dist/chunk-chunk-IY7RYD4S.module.min.js +1 -0
  28. package/dist/{chunk-chunk-7FW6EGLP.module.min.js → chunk-chunk-JDXT6ORT.module.min.js} +1 -1
  29. package/dist/chunk-chunk-JMVEIZXP.module.min.js +1 -0
  30. package/dist/chunk-chunk-KHCOJMGK.module.min.js +1 -0
  31. package/dist/{chunk-chunk-OQTLSTGI.module.min.js → chunk-chunk-KQ546MKE.module.min.js} +1 -1
  32. package/dist/chunk-chunk-LQBSXO7K.module.min.js +2 -0
  33. package/dist/chunk-chunk-LRIFN2HK.module.min.js +1 -0
  34. package/dist/chunk-chunk-MFHF4J2Z.module.min.js +1 -0
  35. package/dist/{chunk-chunk-JNCHKRIR.module.min.js → chunk-chunk-N6VKKF3A.module.min.js} +1 -1
  36. package/dist/chunk-chunk-NEVE562N.module.min.js +1 -0
  37. package/dist/chunk-chunk-NKZ75IM5.module.min.js +2 -0
  38. package/dist/chunk-chunk-PLIDPQNG.module.min.js +2 -0
  39. package/dist/{chunk-chunk-FYY2ACNJ.module.min.js → chunk-chunk-PRDGLMJT.module.min.js} +1 -1
  40. package/dist/chunk-chunk-QGZGZI4X.module.min.js +1 -0
  41. package/dist/chunk-chunk-RP7WTID5.module.min.js +1 -0
  42. package/dist/chunk-chunk-S7KLNUO6.module.min.js +1 -0
  43. package/dist/chunk-chunk-SR4ZXOWR.module.min.js +2 -0
  44. package/dist/chunk-chunk-ZOAQDIJO.module.min.js +1 -0
  45. package/dist/chunk-minimapBrushOverlay-JU57U7NM.module.min.js +2 -0
  46. package/dist/chunk-scatterplotMatrixBrushOverlay-SDIZSN66.module.min.js +2 -0
  47. package/dist/chunk-statisticalOverlays-QGDLRUHX.module.min.js +1 -0
  48. package/dist/chunk-statisticalOverlays-T77OKLDY.module.min.js +1 -0
  49. package/dist/components/ChartContainer.d.ts +2 -2
  50. package/dist/components/ai/chartCapabilityTypes.d.ts +5 -0
  51. package/dist/components/charts/geo/ChoroplethMap.d.ts +2 -0
  52. package/dist/components/charts/geo/DistanceCartogram.d.ts +7 -3
  53. package/dist/components/charts/geo/FlowMap.d.ts +4 -0
  54. package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +3 -1
  55. package/dist/components/charts/physics/CollisionSwarmChart.d.ts +6 -1
  56. package/dist/components/charts/physics/GaltonBoardChart.d.ts +6 -1
  57. package/dist/components/charts/physics/gauntletChartProps.d.ts +7 -1
  58. package/dist/components/charts/physics/gauntletChrome.d.ts +2 -1
  59. package/dist/components/charts/physics/gauntletPhysics.d.ts +19 -4
  60. package/dist/components/charts/physics/gauntletRuntime.d.ts +3 -0
  61. package/dist/components/charts/physics/physicsHocUtils.d.ts +12 -0
  62. package/dist/components/charts/shared/chartMode.d.ts +8 -0
  63. package/dist/components/charts/shared/chartSpecCore.d.ts +2 -2
  64. package/dist/components/charts/shared/hatchPattern.d.ts +8 -3
  65. package/dist/components/charts/shared/lineSeriesSsr.d.ts +55 -0
  66. package/dist/components/charts/shared/types.d.ts +2 -2
  67. package/dist/components/charts/shared/validateProps.d.ts +1 -1
  68. package/dist/components/charts/xy/AreaChart.d.ts +10 -0
  69. package/dist/components/charts/xy/minimapBrushOverlay.d.ts +17 -0
  70. package/dist/components/charts/xy/minimapBrushOverlayLazy.d.ts +4 -0
  71. package/dist/components/charts/xy/scatterplotMatrixBrushOverlay.d.ts +8 -0
  72. package/dist/components/charts/xy/scatterplotMatrixBrushOverlayLazy.d.ts +3 -0
  73. package/dist/components/realtime/types.d.ts +5 -0
  74. package/dist/components/recipes/gridObservatory.d.ts +176 -0
  75. package/dist/components/recipes/recipeChrome.d.ts +24 -0
  76. package/dist/components/recipes/sequenceLayout.d.ts +139 -0
  77. package/dist/components/semiotic-recipes-core.d.ts +6 -2
  78. package/dist/components/server/staticAnnotations.d.ts +3 -1
  79. package/dist/components/stream/SceneToSVG.d.ts +6 -6
  80. package/dist/components/stream/SceneToSVGOrdinal.d.ts +12 -0
  81. package/dist/components/stream/networkFramePaint.d.ts +2 -0
  82. package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +18 -2
  83. package/dist/components/stream/physics/physicsBodyCanvas.d.ts +7 -0
  84. package/dist/components/stream/physics/physicsPipelineEviction.d.ts +15 -0
  85. package/dist/components/stream/physics/physicsPipelineObservations.d.ts +1 -1
  86. package/dist/components/stream/physics/physicsPipelineQuiescence.d.ts +20 -0
  87. package/dist/components/stream/sceneToSVGShared.d.ts +30 -1
  88. package/dist/components/stream/types.d.ts +4 -0
  89. package/dist/components/stream/useHydration.d.ts +7 -1
  90. package/dist/components/stream/xySceneBuilders/candlestickScene.d.ts +1 -1
  91. package/dist/forceLayoutWorker.js +1 -1
  92. package/dist/geo.min.js +1 -1
  93. package/dist/geo.module.min.js +1 -1
  94. package/dist/network.min.js +1 -1
  95. package/dist/network.module.min.js +1 -1
  96. package/dist/ordinal.min.js +1 -1
  97. package/dist/ordinal.module.min.js +1 -1
  98. package/dist/physics.min.js +1 -1
  99. package/dist/physics.module.min.js +1 -1
  100. package/dist/physicsWorker.js +1 -1
  101. package/dist/realtime.min.js +1 -1
  102. package/dist/realtime.module.min.js +1 -1
  103. package/dist/rough.min.js +1 -1
  104. package/dist/rough.module.min.js +1 -1
  105. package/dist/semiotic-ai-core.min.js +1 -1
  106. package/dist/semiotic-ai-core.module.min.js +1 -1
  107. package/dist/semiotic-ai.min.js +1 -1
  108. package/dist/semiotic-ai.module.min.js +1 -1
  109. package/dist/semiotic-experimental.min.js +1 -1
  110. package/dist/semiotic-experimental.module.min.js +1 -1
  111. package/dist/semiotic-realtime-core.min.js +1 -1
  112. package/dist/semiotic-realtime-core.module.min.js +1 -1
  113. package/dist/semiotic-recipes-core.d.ts +6 -2
  114. package/dist/semiotic-recipes-core.min.js +1 -1
  115. package/dist/semiotic-recipes-core.module.min.js +1 -1
  116. package/dist/semiotic-recipes.min.js +1 -1
  117. package/dist/semiotic-recipes.module.min.js +1 -1
  118. package/dist/semiotic-server-edge.min.js +1 -1
  119. package/dist/semiotic-server-edge.module.min.js +1 -1
  120. package/dist/semiotic-server-node.min.js +1 -1
  121. package/dist/semiotic-server-node.module.min.js +1 -1
  122. package/dist/semiotic-utils-core.min.js +1 -1
  123. package/dist/semiotic-utils-core.module.min.js +1 -1
  124. package/dist/semiotic-utils.min.js +1 -1
  125. package/dist/semiotic-utils.module.min.js +1 -1
  126. package/dist/semiotic-value.module.min.js +1 -1
  127. package/dist/semiotic.min.js +1 -1
  128. package/dist/semiotic.module.min.js +1 -1
  129. package/dist/server.min.js +1 -1
  130. package/dist/server.module.min.js +1 -1
  131. package/dist/xy.min.js +1 -1
  132. package/dist/xy.module.min.js +1 -1
  133. package/package.json +3 -2
  134. package/dist/chunk-chunk-255KDHW5.module.min.js +0 -1
  135. package/dist/chunk-chunk-2CCFBTQC.module.min.js +0 -2
  136. package/dist/chunk-chunk-2RXP3FS3.module.min.js +0 -1
  137. package/dist/chunk-chunk-2WVCH4PL.module.min.js +0 -1
  138. package/dist/chunk-chunk-4TMZXLCR.module.min.js +0 -1
  139. package/dist/chunk-chunk-5APBQXZA.module.min.js +0 -1
  140. package/dist/chunk-chunk-6HSGDMTA.module.min.js +0 -2
  141. package/dist/chunk-chunk-7OEOSCBP.module.min.js +0 -1
  142. package/dist/chunk-chunk-A63CTACR.module.min.js +0 -2
  143. package/dist/chunk-chunk-B6V35LMY.module.min.js +0 -2
  144. package/dist/chunk-chunk-BOSVL645.module.min.js +0 -2
  145. package/dist/chunk-chunk-CP3EN6KZ.module.min.js +0 -1
  146. package/dist/chunk-chunk-F25UA5HT.module.min.js +0 -1
  147. package/dist/chunk-chunk-FRIO6MCV.module.min.js +0 -1
  148. package/dist/chunk-chunk-GWSWSPXN.module.min.js +0 -1
  149. package/dist/chunk-chunk-I6C3KR5H.module.min.js +0 -2
  150. package/dist/chunk-chunk-IP2UE74X.module.min.js +0 -1
  151. package/dist/chunk-chunk-J3ELI22J.module.min.js +0 -1
  152. package/dist/chunk-chunk-J5RL6GXU.module.min.js +0 -2
  153. package/dist/chunk-chunk-L3H6DQCR.module.min.js +0 -2
  154. package/dist/chunk-chunk-M337NY6L.module.min.js +0 -1
  155. package/dist/chunk-chunk-M7VYYHCE.module.min.js +0 -2
  156. package/dist/chunk-chunk-MC35ILYP.module.min.js +0 -2
  157. package/dist/chunk-chunk-N72SWNBV.module.min.js +0 -1
  158. package/dist/chunk-chunk-OBQRFTIL.module.min.js +0 -2
  159. package/dist/chunk-chunk-QRIBHZYW.module.min.js +0 -1
  160. package/dist/chunk-chunk-SA3D43RA.module.min.js +0 -2
  161. package/dist/chunk-chunk-UHSZEB74.module.min.js +0 -1
  162. package/dist/chunk-chunk-Y6AXCRVO.module.min.js +0 -1
  163. package/dist/chunk-chunk-ZCNBUZPL.module.min.js +0 -2
@@ -1 +0,0 @@
1
- import{IncrementalExtent as t,RingBuffer as e}from"./chunk-chunk-VVCA3DB7.module.min.js";import{forceLayoutPlugin as r,wrapWithDataHint as i}from"./chunk-chunk-5APBQXZA.module.min.js";import{STREAMING_PALETTE as n,coerceDateLikeValue as o,computeEasing as a,computeRawProgress as s,lerp as c,now as l,parseDateLikeString as u}from"./chunk-chunk-F25UA5HT.module.min.js";import{accessorsEquivalent as h,resolveAccessor as f,resolveRawAccessor as y,resolveStringAccessor as g}from"./chunk-chunk-2WVCH4PL.module.min.js";import{SEQUENTIAL_INTERPOLATORS as p,SYMBOL_SEQUENCE as d,UpdateResultTracker as m,getSequentialInterpolator as v,schemeCategory10 as x}from"./chunk-chunk-5RKXZQ2P.module.min.js";function b(t,e,r){if(null!=t)return"function"==typeof t?t(e,r):"object"==typeof t&&null!==t&&"constant"in t?t.constant:e[t]}function k(t){const{data:e,encoding:r}=t,i=[],n=new Map;return e.forEach((t,e)=>{const o=b(r.id,t,e);if(null==o||""===o)throw Error(`[semiotic] Motion encoding row ${e} resolved an empty id.`);const a=o+"";if(n.has(a))throw Error(`[semiotic] Duplicate motion encoding id "${a}".`);const s=b(r.process?.group,t,e),c=b(r.process?.stage,t,e),l=b(r.accessible?.group,t,e)??(null!=s?s+"":null!=c?c+"":void 0),u={};for(const i of Object.keys(r.evidence??{}))u[i]=b(r.evidence?.[i],t,e);const h={id:a,datum:t,time:{arrival:b(r.time?.arrival,t,e),basis:r.time?.basis,unit:r.time?.unit},placement:{x:b(r.placement?.x,t,e),y:b(r.placement?.y,t,e),lane:b(r.placement?.lane,t,e),space:r.placement?.space},kinematics:{velocityX:b(r.kinematics?.velocityX,t,e),velocityY:b(r.kinematics?.velocityY,t,e),space:r.kinematics?.space},process:{group:s,stage:c,target:b(r.process?.target,t,e),work:b(r.process?.work,t,e)},evidence:u,accessible:{description:b(r.accessible?.description,t,e),group:l,label:b(r.accessible?.label,t,e)??a}};i.push(h),n.set(a,h)}),{rows:i,byId:n}}function w(t){const e=Math.max(0,Math.min(1,t.minOpacity??.1));if(Number.isNaN(t.age))return 1;if(t.age===1/0)return e;if(!Number.isFinite(t.extent)||0>=t.extent)return 1;const r=Math.max(0,t.age);if("step"===t.type)return(t.threshold??.5*t.extent)>r?1:e;if("exponential"===t.type){const i=t.halfLife??t.extent/2;return e+Math.pow(.5,r/(i>0?i:t.extent/2))*(1-e)}return e+Math.max(0,Math.min(1,1-r/t.extent))*(1-e)}function _(t,e){const r=Number.isFinite(t)?t:0,i=Number.isFinite(e)?e:0;return{velocityX:r,velocityY:i,speed:Math.hypot(r,i),direction:Math.atan2(i,r)}}function A(t,e,r){return Number.isFinite(r)&&r>0?_((e.x-t.x)/r,(e.y-t.y)/r):_(0,0)}function P(t,e,r,i){return"function"==typeof e.style?e.style(i||{},r):e.style&&"object"==typeof e.style?e.style:t.resolveBoundsStyle(r,i)}function L(t,e,r,i){if(!t.scales)return null;const n=[],o=[];for(const r of e){const e=t.getX(r);if(!Number.isFinite(e))continue;const a=i.getTop(r),s=i.getBottom(r);if(!Number.isFinite(a)||!Number.isFinite(s))continue;const c=t.scales.x(e),l=t.scales.y(a),u=t.scales.y(s);Number.isFinite(c)&&Number.isFinite(l)&&Number.isFinite(u)&&(n.push([c,l]),o.push([c,u]))}return 2>n.length?null:{type:"area",topPath:n,bottomPath:o,style:P(t,i,r,e[0]),datum:e,group:r,interactive:i.interactive}}function S(t){const e=[],r=[];if(!t)return{perSeries:e,aggregate:r};for(const i of t)i.perSeries?e.push(i):r.push(i);return{perSeries:e,aggregate:r}}function M(t,e,r){const i=[];for(const n of r){const r=L(t,e,"__ribbon_aggregate",n);r&&i.push(r)}return i}function C(t,e,r,i){const n=[];for(const o of i){const i=L(t,e,r,o);i&&n.push(i)}return n}function D(t,e){if(!t)return{};if(!e||0===e.length)return t;const r=[];for(const i of e){if("band"!==i.kind)continue;const e=i.getTop(t),n=i.getBottom(t);Number.isFinite(n)&&Number.isFinite(e)&&r.push({y0:n,y1:e})}return 0===r.length?t:{...t,band:r[0],bands:r}}function E(t){return new Set(Array.isArray(t)?t:[t])}function Y(t,e,r){if(1>=r)return 1;const i=r-1;return w({age:i-e,extent:i,type:t.type,halfLife:t.halfLife??r/2,threshold:t.stepThreshold??.5*r,minOpacity:t.minOpacity??.1})}function N(t){const e=new Map;for(let r=0;t.length>r;r++)e.set(t[r],r);return e}function R(t,e,r){const i=t.duration??500,n=r-e;return i>n?1-n/i:0}function T(t,e,r,i){let n=!1;return e>0?(t._pulseIntensity!==e&&(t._pulseIntensity=e,n=!0),t._pulseColor!==r&&(t._pulseColor=r,n=!0),t._pulseGlowRadius!==i&&(t._pulseGlowRadius=i,n=!0),n):(0!==t._pulseIntensity&&(t._pulseIntensity=0,n=!0),void 0!==t._pulseColor&&(t._pulseColor=void 0,n=!0),void 0!==t._pulseGlowRadius&&(t._pulseGlowRadius=void 0,n=!0),n)}function $(t,e,r=("undefined"!=typeof performance?performance.now():Date.now())){if(!e||0===e.size)return!1;const i=t.duration??500,n=e.peek();return null!=n&&i>r-n}function O(t,e,r){if(e._transitionKey)return e._transitionKey;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const r=t.getX(e.datum),i=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${r}:${i}`;if(null!=r&&null!=i)return`p:${r}:${i}`}return"p:"+r;case"glyph":return e.pointId?"g:"+e.pointId:"g:"+r;case"rect":return`r:${e.group||""}:${e.datum?.binStart??e.datum?.category??r}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+r:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function F(t,e,r,i,n,o){const a=[];for(const n of t){const t=r(n),o=i(n);Number.isFinite(t)&&Number.isFinite(o)&&a.push({px:e.x(t),py:e.y(o),rawY:o,d:n})}a.sort((t,e)=>t.px-e.px);const s=Array(a.length),c=Array(a.length),l=Array(a.length);for(let t=0;a.length>t;t++){const e=a[t];s[t]=[e.px,e.py],c[t]=e.rawY,l[t]=e.d}return{type:"line",path:s,rawValues:c,style:n,datum:l,group:o}}function I(t,e,r,i,n,o,a,s){const c=[];for(const o of t){const t=r(o),a=i(o);if(!Number.isFinite(t)||!Number.isFinite(a))continue;const l=e.x(t),u=s?s(o):n;c.push({px:l,topY:e.y(a),botY:e.y(u)})}c.sort((t,e)=>t.px-e.px);const l=Array(c.length),u=Array(c.length);for(let t=0;c.length>t;t++){const e=c[t];l[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:l,bottomPath:u,style:o,datum:t,group:a}}function z(t,e,r,i){const n=new Map;if("silhouette"===i)for(const i of t){let t=0;for(const n of e)t+=r(n,i)||0;n.set(i,-t/2)}else if("wiggle"===i){t.length>0&&n.set(t[0],0);for(let i=1;t.length>i;i++){const o=t[i-1],a=t[i];let s=0,c=0,l=0;for(const t of e){const e=r(t,a)||0;s+=(2*l+e)*(e-(r(t,o)||0)),c+=e,l+=e}const u=n.get(o)??0;n.set(a,u-(c>0?s/(2*c):0))}if(t.length>0){let i=0;for(const o of t){let t=0;for(const i of e)t+=r(i,o)||0;i+=(n.get(o)??0)+t/2}const o=i/t.length;for(const e of t)n.set(e,(n.get(e)??0)-o)}}else for(const e of t)n.set(e,0);return n}function W(t,e,r,i,n,o,a){const s=r(t),c=i(t);if(!Number.isFinite(s)||!Number.isFinite(c))return null;const l={type:"point",x:e.x(s),y:e.y(c),r:n,style:o,datum:t};return void 0!==a&&(l.pointId=a),l}function X(t,e,r,i,n,o,a,s){const c=r(t),l=i(t);if(!Number.isFinite(c)||!Number.isFinite(l))return null;const u={type:"symbol",x:e.x(c),y:e.y(l),size:n,symbolType:o,style:a,datum:t};return void 0!==s&&(u.pointId=s),u}function B(t,e,r,i,n,o,a){return{type:"rect",x:t,y:e,w:r,h:i,style:n,datum:o,group:a}}function G(t,e,r,i,n,o,a){const s={type:"heatcell",x:t,y:e,w:r,h:i,fill:n,datum:o};return a?.showValues&&(s.showValues=!0,s.value=a.value,a.valueFormat&&(s.valueFormat=a.valueFormat)),s}function j(t,e,r,i){if(!t.config.pointStyle)return;const n=i??t.getY;for(const i of e){const e=t.resolveGroupColor(i.key);for(const o of i.data){let i=t.config.pointStyle(o);!i.fill&&e&&(i={...i,fill:e});const a=i.r??3,s=t.getPointId?t.getPointId(o)+"":void 0,c=W(o,t.scales,t.getX,n,a,i,s);c&&r.push(c)}}}function V(t){return"threshold"===t.type&&"string"==typeof t.color&&"number"==typeof t.value}var H={topOpacity:.8,bottomOpacity:.05};function K(t){if(t)return!0===t?H:"colorStops"in t?t:{topOpacity:t.topOpacity??H.topOpacity,bottomOpacity:t.bottomOpacity??H.bottomOpacity}}var q=new Map;function Z(t,e,r,i,n){const o=new Map;for(const a of t){const t=e(a),s=r(a);if(null==t||null==s||Number.isNaN(t)||Number.isNaN(s))continue;const c=Math.floor(t/i)*i;let l=o.get(c);if(l||(l={start:c,end:c+i,total:0,categories:new Map},o.set(c,l)),l.total+=s,n){const t=n(a);l.categories.set(t,(l.categories.get(t)||0)+s)}}return o}function U(t){if("production"===process.env.NODE_ENV)return;const{label:e,nodes:r,overlays:i,warned:n}=t;Q(i)&&0===r.length&&J(n,"overlay-only",`[semiotic] ${e} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),r.length>0&&r.every(t=>null==t.datum)&&J(n,"null-datums",`[semiotic] ${e} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function Q(t){return null!=t&&!1!==t&&""!==t&&(!Array.isArray(t)||t.some(Q))}function J(t,e,r){t.has(e)||(t.add(e),console.warn(r))}function tt(t,e,r,i){const n=function(t){if(t instanceof Error)return{name:t.name||"Error",message:t.message||"Custom layout threw."};if("string"==typeof t)return{name:"Error",message:t};if(null==t)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:t+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(e),o="network"===t?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:t,source:o,message:`Semiotic ${t} ${o} failed: ${n.message}`,error:n,recovery:r?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:r,affectedRevision:i}}function et(t,e){const r="function"==typeof t?t:r=>r[t||e];return t=>{const e=r(t);return null==e?NaN:+e}}function rt(t){const e=[],r=["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode,i=et(r&&t.valueAccessor||t.yAccessor,r?"value":"y");if(t.boundsAccessor){const r=f(t.boundsAccessor,"bounds");e.push({kind:"bounds",getTop:t=>{const e=i(t);if(!Number.isFinite(e))return NaN;const n=r(t);return Number.isFinite(n)&&0!==n?e+n:e},getBottom:t=>{const e=i(t);if(!Number.isFinite(e))return NaN;const n=r(t);return Number.isFinite(n)&&0!==n?e-n:e},style:t.boundsStyle,perSeries:!0,interactive:!1})}if(t.band){const r=Array.isArray(t.band)?t.band:[t.band];for(const t of r)e.push({kind:"band",getTop:et(t.y1Accessor,"y1"),getBottom:et(t.y0Accessor,"y0"),style:t.style,perSeries:!1!==t.perSeries,interactive:!0===t.interactive})}return e}import{scaleLinear as it,scaleLog as nt,scaleSymlog as ot,scaleTime as at}from"d3-scale";function st(t,e){return e?[e[0]??t[0],e[1]??t[1]]:t}function ct(t,e,r){if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return nt().domain(t).range(r).clamp(!0)}return"symlog"===t?ot().domain(e).range(r):"time"===t?at().domain([new Date(e[0]),new Date(e[1])]).range(r):it().domain(e).range(r)}function lt(t,e,r){e>t.capacity&&(t.resize(e),r&&e>r.capacity&&r.resize(e))}function ut(t,r){const i=new e(t.capacity);return t.forEach(()=>i.push(r)),i}function ht(t,e,r,i){const n=t.push(e);return r&&r.push(i),n}function ft(t,e,r){if(!e||0===e.size)return;const i=new Set;if(t.forEach((t,e)=>{r(t)&&i.add(e)}),0===i.size)return;const n=e.toArray();e.clear();for(let t=0;n.length>t;t++)i.has(t)||e.push(n[t])}var yt=new WeakMap;function gt(){return this.updateResults.last}function pt(){return this.updateResults.last}function dt(t){return this.updateResults.subscribe(t)}function mt(t){this.config.layoutSelection=t}function vt(){yt.set(this,!0)}function xt(){const t=!0===yt.get(this);return yt.delete(this),t}function bt(t){Object.assign(t.prototype,{getLastUpdateResult:gt,getUpdateSnapshot:pt,subscribeUpdateResult:dt,setLayoutSelection:mt,markStylePaintPending:vt,consumeStylePaintPending:xt})}var kt=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],wt=["scene-style","data-paint","accessibility","evidence"],_t=(t,e)=>({retainedData:t,invalidations:e}),At=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Pt=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Lt=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],St=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Mt=["scene-geometry","data-paint","accessibility","evidence"],Ct=["scene-style","data-paint","accessibility","evidence"],Dt=[],Et={chartType:_t("rebuild",At),runtimeMode:_t("rebuild",At),xAccessor:_t("rebuild",At),yAccessor:_t("rebuild",At),timeAccessor:_t("rebuild",At),valueAccessor:_t("rebuild",At),y0Accessor:_t("rebuild",At),boundsAccessor:_t("rebuild",At),band:_t("rebuild",At),openAccessor:_t("rebuild",At),highAccessor:_t("rebuild",At),lowAccessor:_t("rebuild",At),closeAccessor:_t("rebuild",At),candlestickRangeMode:_t("rebuild",At),accessorRevision:_t("rebuild",At),groupAccessor:_t("rebuild",Pt),categoryAccessor:_t("rebuild",Pt),lineDataAccessor:_t("rebuild",Pt),colorAccessor:_t("rebuild",Ct),sizeAccessor:_t("rebuild",Mt),symbolAccessor:_t("rebuild",Mt),pointIdAccessor:_t("rebuild",Mt),xScaleType:_t("preserve",Lt),yScaleType:_t("preserve",Lt),xExtent:_t("preserve",Lt),yExtent:_t("preserve",Lt),extentPadding:_t("preserve",Lt),scalePadding:_t("preserve",Lt),axisExtent:_t("preserve",Lt),binSize:_t("preserve",Lt),normalize:_t("preserve",Lt),heatmapAggregation:_t("preserve",Lt),heatmapXBins:_t("preserve",Lt),heatmapYBins:_t("preserve",Lt),arrowOfTime:_t("preserve",St),baseline:_t("preserve",St),stackOrder:_t("preserve",St),sizeRange:_t("preserve",St),curve:_t("preserve",St),areaGroups:_t("preserve",St),customLayout:_t("preserve",St),layoutConfig:_t("preserve",St),layoutMargin:_t("preserve",St),symbolMap:_t("preserve",Mt),showValues:_t("preserve",Mt),heatmapValueFormat:_t("preserve",Mt),lineStyle:_t("preserve",Ct),pointStyle:_t("preserve",Ct),areaStyle:_t("preserve",Ct),barStyle:_t("preserve",Ct),swarmStyle:_t("preserve",Ct),waterfallStyle:_t("preserve",Ct),candlestickStyle:_t("preserve",Ct),boundsStyle:_t("preserve",Ct),gradientFill:_t("preserve",Ct),lineGradient:_t("preserve",Ct),colorScheme:_t("preserve",Ct),themeCategorical:_t("preserve",Ct),themeSemantic:_t("preserve",Ct),themeSequential:_t("preserve",Ct),themeDiverging:_t("preserve",Ct),barColors:_t("preserve",Ct),decay:_t("preserve",Ct),pulse:_t("preserve",Ct),staleness:_t("preserve",Ct),layoutSelection:_t("preserve",Ct),annotations:_t("preserve",["overlay","accessibility","evidence"]),windowSize:_t("preserve",Dt),windowMode:_t("preserve",Dt),maxCapacity:_t("preserve",Dt),clock:_t("preserve",Dt),transition:_t("preserve",Dt),introAnimation:_t("preserve",Dt),onLayoutError:_t("preserve",Dt)},Yt=_t("preserve",St),Nt=class{constructor(){this.tracker=new m}get last(){return this.tracker.last}subscribe(t){return this.tracker.subscribe(t)}recordData(t,e){return this.tracker.record({kind:t,...void 0===e?{}:{count:e}},kt)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},wt):this.recordNoop("restyle")}recordConfig(t){const e=function(t){let e="preserve";const r=new Set;for(const i of t){const t=Et[i]??Yt;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)r.add(e)}return{retainedData:e,invalidations:r}}(t);return this.tracker.record({kind:"config",keys:t},e.invalidations)}};import{quadtree as Rt}from"d3-quadtree";var Tt=class{constructor(){this.maxRadius=0,this.tree=null}get quadtree(){return this.tree}get maxPointRadius(){return this.maxRadius}clear(){this.tree=null,this.maxRadius=0}rebuild(t,e){if("scatter"!==t&&"bubble"!==t&&"custom"!==t)return void this.clear();let r=0,i=0;for(const t of e)"point"===t.type&&(r++,t.r>i&&(i=t.r));if(this.maxRadius=i,500>=r)return void(this.tree=null);const n=Array(r);let o=0;for(const t of e)"point"===t.type&&(n[o++]=t);this.tree=Rt().x(t=>t.x).y(t=>t.y).addAll(n)}},$t=class r{constructor(r){if(this.xExtent=new t,this.yExtent=new t,this.growingCapacityWarned=!1,this.windowSizeWarned=!1,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._datumIndexCache=null,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.updateResults=new Nt,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.xIsDate=!1,this.spatialIndex=new Tt,this._lastBoundedInsertsRef=null,this.applyPulse=(t,e,r)=>!(!this.config.pulse||!this.timestampBuffer)&&function(t,e,r,i,n,o=("undefined"!=typeof performance?performance.now():Date.now())){const a=t.color??"rgba(255,255,255,0.6)",s=t.glowRadius??4;let c=!1;const l=n??(()=>{const t=new Map;for(let e=0;r.length>e;e++)t.set(r[e],e);return t})();for(const r of e){if("line"===r.type)continue;if("area"===r.type){const e=Array.isArray(r.datum)?r.datum:[r.datum];let n=0,s=!1;for(const r of e){const e=l.get(r);if(null==e)continue;s=!0;const a=i.get(e);if(null==a)continue;const c=R(t,a,o);c>n&&(n=c)}s&&(c=T(r,n,a)||c);continue}const e=l.get(r.datum);if(null==e)continue;const n=i.get(e);c=T(r,null==n?0:R(t,n,o),a,s)||c}return c}(this.config.pulse,t,e,this.timestampBuffer,this.getDatumIndexMap(e),r),this.config=r,this.buffer=new e(r.windowSize),this.growingCap=r.windowSize,["bar","swarm","waterfall"].includes(r.chartType)||"streaming"===r.runtimeMode?(this.getX=f(r.timeAccessor||r.xAccessor,"time"),this.getY=f(r.valueAccessor||r.yAccessor,"value")):(this.getX=f(r.xAccessor,"x"),this.getY=f(r.yAccessor,"y")),this.getGroup=g(r.groupAccessor),this.getCategory=g(r.categoryAccessor),this.getSize=r.sizeAccessor?f(r.sizeAccessor,"size"):void 0,this.getColor=g(r.colorAccessor),this.getSymbol=g(r.symbolAccessor),this.getY0=r.y0Accessor?f(r.y0Accessor,"y0"):void 0,this.resolvedRibbons=rt(r),this.getPointId=g(r.pointIdAccessor),"candlestick"===r.chartType){const t=null!=r.openAccessor,e=null!=r.closeAccessor;this.getOpen=t?f(r.openAccessor,"open"):void 0,this.getHigh=f(r.highAccessor,"high"),this.getLow=f(r.lowAccessor,"low"),this.getClose=e?f(r.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e}r.pulse&&(this.timestampBuffer=new e(r.windowSize))}currentTime(){return this.config.clock?.()??l()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=ut(this.buffer,this.currentTime())):this.timestampBuffer=null}pushDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(t)),void this.yExtent.push(this.getLow(t));this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t));for(const e of this.resolvedRibbons){const r=e.getTop(t),i=e.getBottom(t);Number.isFinite(r)&&this.yExtent.push(r),Number.isFinite(i)&&this.yExtent.push(i)}}evictDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(t)),void this.yExtent.evict(this.getLow(t));this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t));for(const e of this.resolvedRibbons){const r=e.getTop(t),i=e.getBottom(t);Number.isFinite(r)&&this.yExtent.evict(r),Number.isFinite(i)&&this.yExtent.evict(i)}}rebuildYExtent(){this.yExtent.clear();for(const t of this.buffer)this.pushDatumYExtent(t)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const t of this.buffer)this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t)}ingest(t){if(t.bounded&&this._lastBoundedInsertsRef===t.inserts)return this.updateResults.recordNoop("replace"),!1;const e=this.currentTime();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.bounded){this._lastBoundedInsertsRef=t.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const r=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=r?f(this.config.timeAccessor||this.config.xAccessor,"time"):f(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],r=this.config.xAccessor,i="function"==typeof r?r(e):e[r||"x"],n=i instanceof Date,a="string"==typeof i&&Number.isFinite(u(i));if(this.xIsDate=n||a,a){const t="string"==typeof r?r:void 0;this.getX=t?e=>o(e[t]):t=>o(r(t))}}lt(this.buffer,t.totalSize||t.inserts.length,this.timestampBuffer);for(const r of t.inserts)ht(this.buffer,r,this.timestampBuffer,e),this.xExtent.push(this.getX(r)),this.pushDatumYExtent(r)}else for(const r of t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity??1e5;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap),"production"===process.env.NODE_ENV||this.growingCapacityWarned||5e4>this.growingCap||(this.growingCapacityWarned=!0,console.warn(`[Semiotic] Growing window buffer reached ${this.growingCap} points (cap ${t}). Large canvas scenes are expensive — prefer a sliding window, aggregation, or an explicit maxCapacity if this is intentional.`)))}const t=ht(this.buffer,r,this.timestampBuffer,e);this.xExtent.push(this.getX(r)),this.pushDatumYExtent(r),null!=t&&(this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t))}return this.updateResults.recordData(t.bounded?"replace":"ingest",t.inserts.length),!0}ingestWithResult(t){return this.ingest(t),this.updateResults.last}computeScene(t){const{config:e,buffer:r}=this,i=this.scales,n=this.lastLayout;if(!this.needsFullRebuild&&!e.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(this.config.scalePadding??0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);this.xExtent.dirty&&this.xExtent.recalculate(r,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const o=this.getBufferArray(),a=this.yExtent.extent;let s=st(this.xExtent.extent,e.xExtent),c=st(a,e.yExtent);const l=!(!(u=e.yExtent)||null==u[0]||null==u[1]);var u;const h="exact"===e.axisExtent;if("stackedarea"===e.chartType&&!l&&r.size>0){const t=function(t){const{config:e,groups:r,getX:i,getY:n}=t,o="exact"===e.axisExtent;if(e.normalize){const r=[0,o?1:1+e.extentPadding];return{yDomain:r,stackExtentCache:{key:`${t.bufferSize}:${t.ingestVersion}:norm`,yDomain:r}}}const a=`${t.bufferSize}:${t.ingestVersion}:${e.baseline??"zero"}:${e.stackOrder??"key"}`;if(t.stackExtentCache&&t.stackExtentCache.key===a)return{yDomain:t.stackExtentCache.yDomain,stackExtentCache:t.stackExtentCache};const s=new Map,c=new Set;let l=0;const u=new Map,h=new Map;for(const t of r){const e=new Map;let r=0;for(const o of t.data){const t=i(o),a=n(o);if(!Number.isFinite(t)||!Number.isFinite(a))continue;e.set(t,(e.get(t)||0)+a),c.add(t),r+=a;const s=(u.get(t)||0)+a;u.set(t,s),s>l&&(l=s)}s.set(t.key,e),h.set(t.key,r)}const f=e.stackOrder??"key",y=(t,e)=>e>t?-1:t>e?1:0;let g,p;if("input"===f)g=r.map(t=>t.key);else if("insideOut"===f){const t=[...r].map(t=>t.key).sort((t,e)=>{const r=(h.get(e)??0)-(h.get(t)??0);return 0!==r?r:y(t,e)}),e=[],i=[];let n=0,o=0;for(const r of t)o>n?(e.push(r),n+=h.get(r)??0):(i.push(r),o+=h.get(r)??0);g=[...i.reverse(),...e]}else g="asc"===f?r.map(t=>t.key).sort((t,e)=>{const r=(h.get(t)??0)-(h.get(e)??0);return 0!==r?r:y(t,e)}):"desc"===f?r.map(t=>t.key).sort((t,e)=>{const r=(h.get(e)??0)-(h.get(t)??0);return 0!==r?r:y(t,e)}):r.map(t=>t.key).sort(y);if("wiggle"===e.baseline||"silhouette"===e.baseline){const t=Array.from(c).sort((t,e)=>t-e),r=z(t,g,(t,e)=>s.get(t)?.get(e)||0,e.baseline);let i=1/0,n=-1/0;for(const e of t){const t=r.get(e)??0,o=u.get(e)??0;i>t&&(i=t),t+o>n&&(n=t+o)}Number.isFinite(i)&&Number.isFinite(n)||(i=0,n=0);const a=n-i,l=o?0:a>0?a*e.extentPadding:1;p=[i-l,n+l]}else if("diverging"===e.baseline){const t=Array.from(c).sort((t,e)=>t-e),[r,i]=function(t,e,r){let i=0,n=0;for(const o of t){let t=0,a=0;for(const i of e){const e=r(i,o)||0;0>e?a+=e:t+=e}i>a&&(i=a),t>n&&(n=t)}return[i,n]}(t,g,(t,e)=>s.get(t)?.get(e)||0),n=i-r,a=o?0:n>0?n*e.extentPadding:1;p=[r-a,i+a]}else p=[0,l+(o?0:l>0?l*e.extentPadding:1)];return{yDomain:p,stackExtentCache:{key:a,yDomain:p}}}({config:e,groups:this.groupData(o),getX:this.getX,getY:this.getY,bufferSize:r.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});c=t.yDomain,this._stackExtentCache=t.stackExtentCache}else"bar"===e.chartType&&e.binSize&&!l&&r.size>0?c=function(t,e,r,i,n,o,a){const[,s]=function(t,e,r,i,n){const o=Z(t,e,r,i,n);if(0===o.size)return[0,0];let a=0;for(const t of o.values())t.total>a&&(a=t.total);return[0,a]}(t,e,r,i,n);return[0,a?s:s+s*o]}(r,this.getX,this.getY,e.binSize,this.getCategory,e.extentPadding,h):"waterfall"===e.chartType&&!l&&r.size>0?c=function(t,e,r,i){const[n,o]=function(t,e){let r=0,i=0,n=0;for(const o of t){const t=e(o);null==t||Number.isNaN(t)||(n+=t,r>n&&(r=n),n>i&&(i=n))}return[r,i]}(t,e),a=o-n,s=i?0:a>0?a*r:1;return[Math.min(0,n-Math.abs(s)),Math.max(0,o+Math.abs(s))]}(r,this.getY,e.extentPadding,h):l||c[0]===1/0||(c=function(t,e,r){if(!r.length)return t;let[i,n]=t;for(const t of e)for(const e of r){const r=e.getTop(t),o=e.getBottom(t);Number.isFinite(r)&&(i>r&&(i=r),r>n&&(n=r)),Number.isFinite(o)&&(i>o&&(i=o),o>n&&(n=o))}return[i,n]}(c,o,this.resolvedRibbons),c=function(t,e){const r=t[1]-t[0],i=e.exactMode?0:r>0?r*e.extentPadding:1,n=[null!=e.userMin?t[0]:t[0]-i,null!=e.userMax?t[1]:t[1]+i];return"log"!==e.yScaleType||n[0]>0||0>=e.dataYDomain[0]||e.exactMode||null==e.userMin&&(n[0]=e.dataYDomain[0]/(1+e.extentPadding)),n}(c,{exactMode:h,extentPadding:e.extentPadding,userMin:e.yExtent?.[0],userMax:e.yExtent?.[1],yScaleType:e.yScaleType,dataYDomain:a}));c=function(t,e,r){if(!e||r)return t;const i=e[0],n=e[1];return null==i&&null==n?t:[null!=i?i:t[0],null!=n?n:t[1]]}(c,e.yExtent,!!l),({xDomain:s,yDomain:c}=function(t,e,r){let i=t,n=e;if(i[0]===1/0||i[1]===-1/0)if("time"===r){const t=Date.now();i=[t-864e5,t]}else i=[0,1];return n[0]!==1/0&&n[1]!==-1/0||(n=[0,1]),{xDomain:i,yDomain:n}}(s,c,e.xScaleType)),this.scales=function(t){const{config:e,layout:r,xDomain:i,yDomain:n}=t,o="streaming"===e.runtimeMode,a=Math.max(0,Math.min(e.scalePadding||0,Math.min(r.width,r.height)/2-1));if(o){if("x"==("up"===(s=e.arrowOfTime)||"down"===s?"y":"x")){const t="right"===e.arrowOfTime?[a,r.width-a]:[r.width-a,a];return{x:it().domain(i).range(t),y:ct(e.yScaleType,n,[r.height-a,a])}}const t="down"===e.arrowOfTime?[a,r.height-a]:[r.height-a,a];return{x:ct(e.yScaleType,n,[a,r.width-a]),y:it().domain(i).range(t)}}var s;return{x:ct(e.xScaleType,i,[a,r.width-a]),y:ct(e.yScaleType,n,[r.height-a,a])}}({config:e,layout:t,xDomain:s,yDomain:c}),this._customLayoutFailedThisBuild=!1;const f=this.buildSceneNodes(t,o);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=i,this.lastLayout=n):(this.scene=[],this.spatialIndex.rebuild(this.config.chartType,this.scene)),void(this.needsFullRebuild=!0);this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=f,this.config.decay&&this.applyDecay(this.scene,o),this.config.pulse&&this.applyPulse(this.scene,o,this.currentTime()),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.spatialIndex.rebuild(this.config.chartType,this.scene),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(t){const e=t.width/this.lastLayout.width,r=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const i of t.path)i[0]*=e,i[1]*=r;break;case"area":for(const i of t.topPath)i[0]*=e,i[1]*=r;for(const i of t.bottomPath)i[0]*=e,i[1]*=r;t.clipRect&&(t.clipRect={x:t.clipRect.x*e,y:t.clipRect.y*r,width:t.clipRect.width*e,height:t.clipRect.height*r});break;case"point":case"glyph":t.x*=e,t.y*=r;break;case"rect":case"heatcell":t.x*=e,t.y*=r,t.w*=e,t.h*=r;break;case"candlestick":t.x*=e,t.openY*=r,t.closeY*=r,t.highY*=r,t.lowY*=r}const i=this.scales.x.domain(),n=this.scales.y.domain(),o=this.scales.x.range(),a=this.scales.y.range(),s=ct,c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),l=a[1]>a[0];this.scales={x:s(this.config.xScaleType,i,o[0]>o[1]?[t.width-c,c]:[c,t.width-c]),y:s(this.config.yScaleType,n,l?[c,t.height-c]:[t.height-c,c])},this.lastLayout={width:t.width,height:t.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(t,e){const{config:r,scales:i}=this;if(!i)return[];if(r.customLayout){const o={data:e,scales:i,dimensions:{width:t.width,height:t.height,margin:r.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:r.themeSemantic??{},categorical:r.themeCategorical??n},resolveColor:(t,e)=>{const i=this.resolveGroupColor(t);if(i)return i;const n=this.resolveLineStyle(t,e);return n.stroke?n.stroke:"string"==typeof n.fill?n.fill:r.themeSemantic?.primary??"#4e79a7"},config:r.layoutConfig??{},selection:r.layoutSelection??null};let a;try{a=r.customLayout(o)}catch(t){const e=null!==this.lastCustomLayoutResult,i=tt("xy",t,e,this.version);this.lastCustomLayoutFailure=i,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",t);try{r.onLayoutError?.(i)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return e?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=a.overlays??null,this.lastCustomLayoutResult=a,this.lastCustomLayoutFailure=null;const s=a.nodes??[];if(this._customRestyle=a.restyle,this.hasCustomRestyle=!!a.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const t of s)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(s,r.layoutSelection??null)}return U({label:"customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}if(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===e.length)return[];const o={scales:i,config:r,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getSymbol:this.getSymbol,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(r.chartType){case"line":return function(t,e){const r=t.groupData(e),i=[],n=t.config.annotations?.filter(V).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.ribbons&&t.ribbons.length>0){const{perSeries:n,aggregate:o}=S(t.ribbons);if(o.length>0&&i.push(...M(t,e,o)),n.length>0)for(const e of r)i.push(...C(t,e.data,e.key,n))}for(const e of r){const r=t.resolveLineStyle(e.key,e.data[0]),o=F(e.data,t.scales,t.getX,t.getY,r,e.key);n&&n.length>0&&(o.colorThresholds=n),t.config.curve&&"linear"!==t.config.curve&&(o.curve=t.config.curve),t.config.lineGradient&&(o.strokeGradient=t.config.lineGradient),i.push(o)}return j(t,r,i),i}(o,e);case"area":return function(t,e){const r=t.groupData(e),i=[];if(t.ribbons&&t.ribbons.length>0){const{perSeries:n,aggregate:o}=S(t.ribbons);if(o.length>0&&i.push(...M(t,e,o)),n.length>0)for(const e of r)i.push(...C(t,e.data,e.key,n))}const n=t.scales.y.domain()[0],o=t.getY0?e=>{const r=t.getY0(e);return null==r?n:r}:void 0;for(const e of r){const r=t.resolveAreaStyle(e.key,e.data[0]),a=I(e.data,t.scales,t.getX,t.getY,n,r,e.key,o),s=K(t.config.gradientFill);s&&(a.fillGradient=s),t.config.curve&&"linear"!==t.config.curve&&(a.curve=t.config.curve),t.config.lineGradient&&(a.strokeGradient=t.config.lineGradient),i.push(a)}return j(t,r,i),i}(o,e);case"mixed":return function(t,e){const r=t.groupData(e),i=[],n=t.config.areaGroups||new Set;if(t.ribbons&&t.ribbons.length>0){const{perSeries:n,aggregate:o}=S(t.ribbons);if(o.length>0&&i.push(...M(t,e,o)),n.length>0)for(const e of r)i.push(...C(t,e.data,e.key,n))}const o=t.scales.y.domain()[0],a=t.getY0?e=>{const r=t.getY0(e);return null==r?o:r}:void 0;for(const e of r)if(n.has(e.key)){const r=t.resolveAreaStyle(e.key,e.data[0]),n=I(e.data,t.scales,t.getX,t.getY,o,r,e.key,a),s=K(t.config.gradientFill);s&&(n.fillGradient=s),t.config.curve&&"linear"!==t.config.curve&&(n.curve=t.config.curve),t.config.lineGradient&&(n.strokeGradient=t.config.lineGradient),i.push(n)}else{const r=t.resolveLineStyle(e.key,e.data[0]),n=F(e.data,t.scales,t.getX,t.getY,r,e.key);t.config.curve&&"linear"!==t.config.curve&&(n.curve=t.config.curve),t.config.lineGradient&&(n.strokeGradient=t.config.lineGradient),i.push(n)}return j(t,r,i),i}(o,e);case"stackedarea":return function(t,e){const r=t.groupData(e),i=t.config.stackOrder??"key",n=()=>r.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);if("input"===i);else if("key"===i)n();else if("asc"===i||"desc"===i||"insideOut"===i){const e=new Map;for(const i of r){let r=0;for(const e of i.data){const i=t.getX(e),n=t.getY(e);Number.isFinite(i)&&Number.isFinite(n)&&(r+=n)}e.set(i.key,r)}const n=(t,e)=>e>t?-1:t>e?1:0;if("asc"===i)r.sort((t,r)=>{const i=(e.get(t.key)??0)-(e.get(r.key)??0);return 0!==i?i:n(t.key,r.key)});else if("desc"===i)r.sort((t,r)=>{const i=(e.get(r.key)??0)-(e.get(t.key)??0);return 0!==i?i:n(t.key,r.key)});else{const t=[...r].sort((t,r)=>{const i=(e.get(r.key)??0)-(e.get(t.key)??0);return 0!==i?i:n(t.key,r.key)}),i=[],o=[];let a=0,s=0;for(const r of t)s>a?(i.push(r),a+=e.get(r.key)??0):(o.push(r),s+=e.get(r.key)??0);r.length=0,r.push(...o.reverse(),...i)}}else n();const o=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,a=t.config.normalize?"zero":t.config.baseline??"zero",{nodes:s,stackedTops:c}=function(t,e,r,i,n,o,a,s="zero"){const c=new Set;for(const e of t)for(const t of e.data){const e=r(t);Number.isFinite(e)&&c.add(e)}const l=Array.from(c).sort((t,e)=>t-e),u=new Map;for(const e of t){const t=new Map;for(const n of e.data){const e=r(n),o=i(n);Number.isFinite(e)&&Number.isFinite(o)&&t.set(e,(t.get(e)||0)+o)}u.set(e.key,t)}let h;if(o){h=new Map;for(const e of l){let r=0;for(const i of t)r+=u.get(i.key)?.get(e)||0;h.set(e,r||1)}}const f=z(l,t.map(t=>t.key),(t,e)=>u.get(t)?.get(e)||0,s),y="diverging"===s&&!o,g=[],p=new Map,d=new Map,m=new Map,v=new Map;for(const t of l)d.set(t,f.get(t)??0),m.set(t,0),v.set(t,0);for(const r of t){const t=u.get(r.key),i=new Map;let s=[],c=[];const f=()=>{if(s.length>=2){const t={type:"area",topPath:s,bottomPath:c,style:n(r.key,r.data[0]),datum:r.data,group:r.key};a&&(t.curve=a),g.push(t)}s=[],c=[]};for(const r of l){const n=t.has(r);let a,l,u=n?t.get(r):0;if(o&&n&&(u/=h.get(r)),!n||!Number.isFinite(u)||0===u){f();continue}y?u>0?(a=m.get(r),l=a+u,m.set(r,l)):(a=v.get(r),l=a+u,v.set(r,l)):(a=d.get(r),l=a+u,d.set(r,l));const g=e.x(r);c.push([g,e.y(a)]),s.push([g,e.y(l)]),i.set(r,l)}f(),p.set(r.key,i)}return{nodes:g,stackedTops:p}}(r,t.scales,t.getX,t.getY,(e,r)=>t.resolveAreaStyle(e,r),t.config.normalize,o,a),l=s;if(t.config.pointStyle){const e=new WeakMap;for(const i of r){const r=c.get(i.key);if(r)for(const n of i.data){const i=t.getX(n),o=t.getY(n);null==i||Number.isNaN(i)||null==o||Number.isNaN(o)||!r.has(i)||e.set(n,r.get(i))}}const i=r=>e.get(r)??t.getY(r);j(t,r,l,i)}return l}(o,e);case"scatter":case"bubble":return function(t,e){const r=[],i="bubble"===t.config.chartType?10:5,n=t.config.sizeRange||[3,15];let o=null;if(t.getSize&&!t.config.pointStyle){const r=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(r.length>0){let t=1/0,e=-1/0;for(const i of r)t>i&&(t=i),i>e&&(e=i);o=r=>t===e?(n[0]+n[1])/2:n[0]+(r-t)/(e-t)*(n[1]-n[0])}}const a=t.getColor?t.resolveColorMap(e):null,s=t.config.themeSemantic?.primary||"#4e79a7",c=t.getSymbol,l=t.config.symbolMap,u=new Map;let h=0;const f=t=>{const e=l?.[t];if(e)return e;let r=u.get(t);return r||(r=d[h%d.length],h++,u.set(t,r)),r};for(const n of e){let e=t.config.pointStyle?t.config.pointStyle(n):{fill:s,opacity:.8},l=e.r||i;if(o&&t.getSize){const e=t.getSize(n);null==e||Number.isNaN(e)||(l=o(e))}if(a&&t.getColor&&!e.fill){const r=t.getColor(n);r&&a.has(r)&&(e={...e,fill:a.get(r)})}const u=t.getPointId?t.getPointId(n)+"":void 0;if(c){const i=f(c(n)+""),o=X(n,t.scales,t.getX,t.getY,Math.PI*l*l,i,e,u);o&&r.push(o)}else{const i=W(n,t.scales,t.getX,t.getY,l,e,u);i&&r.push(i)}}return r}(o,e);case"heatmap":return function(t,e,r){if(t.config.heatmapAggregation)return function(t,e,r){const i=Math.max(1,Math.floor(t.config.heatmapXBins??20)),n=Math.max(1,Math.floor(t.config.heatmapYBins??20)),o=t.config.heatmapAggregation??"count",a=f(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[s,c]=t.scales.x.domain(),[l,u]=t.scales.y.domain(),h=(c-s||1)/i,y=(u-l||1)/n,g=i*n;if(g>1e6)return[];const p=new Int32Array(g),d=new Float64Array(g);for(let r=0;e.length>r;r++){const o=e[r],c=t.getX(o),u=t.getY(o);if(!isFinite(c)||!isFinite(u))continue;const f=Math.min(Math.floor((c-s)/h),i-1),g=Math.min(Math.floor((u-l)/y),n-1);if(0>f||0>g)continue;const m=g*i+f;p[m]++;const v=a(o);d[m]+=isFinite(v)?v:0}let m=1/0,v=-1/0;for(let t=0;g>t;t++){if(0===p[t])continue;let e;switch(o){case"sum":e=d[t];break;case"mean":e=d[t]/p[t];break;default:e=p[t]}m>e&&(m=e),e>v&&(v=e)}if(!isFinite(m))return[];const x=v-m||1,b=r.width/i,k=r.height/n,w=t.config.showValues,_=t.config.heatmapValueFormat,A=[];for(let t=0;n>t;t++){const e=t*i;for(let r=0;i>r;r++){const i=e+r;if(0===p[i])continue;let a;switch(o){case"sum":a=d[i];break;case"mean":a=d[i]/p[i];break;default:a=p[i]}const c=(a-m)/x;A.push(G(r*b,(n-1-t)*k,b,k,`rgb(${220-(180*c+.5)|0},${220-(100*c+.5)|0},${255-(50*c+.5)|0})`,{xi:r,yi:t,value:a,count:p[i],sum:d[i],xCenter:s+(r+.5)*h,yCenter:l+(t+.5)*y,agg:o},w?{value:a,showValues:!0,valueFormat:_}:void 0))}}return A}(t,e,r);if(0===e.length)return[];const i=f(t.config.valueAccessor,"value"),n=y(t.config.xAccessor,"x"),o=y(t.config.yAccessor,"y"),a=new Map,s=new Map,c=Array(e.length),l=Array(e.length);for(let t=0;e.length>t;t++){const r=e[t],i=n(r),u=o(r);c[t]=i,l[t]=u,a.has(i)||a.set(i,a.size),s.has(u)||s.set(u,s.size)}const u=a.size,h=s.size;if(0===u||0===h)return[];const g=Array.from(a.keys()),d=Array.from(s.keys()),m=g.every(t=>"number"==typeof t&&!isNaN(t)),x=d.every(t=>"number"==typeof t&&!isNaN(t));if(m){g.sort((t,e)=>Number(t)-Number(e)),a.clear();for(let t=0;g.length>t;t++)a.set(g[t],t)}if(x){d.sort((t,e)=>Number(t)-Number(e)),s.clear();for(let t=0;d.length>t;t++)s.set(d[t],t)}const b=new Float64Array(e.length),k=new Float64Array(e.length),w=Array(e.length),_=new Map;let A=0;for(let t=0;e.length>t;t++){const r=e[t],n=a.get(c[t]),o=s.get(l[t]);if(void 0===n||void 0===o)continue;const h=i(r),f=o*u+n,y=_.get(f);let g;void 0!==y?g=y:(g=A++,_.set(f,g)),b[g]=f,k[g]=h,w[g]=r}let P=1/0,L=-1/0;for(let t=0;A>t;t++){const e=k[t];isFinite(e)&&(P>e&&(P=e),e>L&&(L=e))}if(!isFinite(P)||!isFinite(L))return[];const S=function(t){const e=t in p?t:"blues";let r=q.get(e);if(r)return r;r=Array(256);const i=v(e);for(let t=0;256>t;t++)r[t]=i(t/255);return q.set(e,r),r}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),M=255/(L-P||1),C=r.width/u,D=r.height/h,E=t.config.showValues,Y=t.config.heatmapValueFormat,N=[];for(let t=0;A>t;t++){const e=k[t];if(!isFinite(e))continue;const r=b[t],i=r%u;N.push(G(i*C,(h-1-(r-i)/u)*D,C,D,S[Math.min((e-P)*M+.5|0,255)],w[t],E?{value:e,showValues:!0,valueFormat:Y}:void 0))}return N}(o,e,t);case"bar":{const t=function(t,e){if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const r=Z(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===r.size)return{nodes:[],binBoundaries:[]};let i=null;if(t.getCategory){const e=new Set;for(const t of r.values())for(const r of t.categories.keys())e.add(r);const n=t.config.barColors?Object.keys(t.config.barColors):[],o=new Set(n),a=Array.from(e).filter(t=>!o.has(t)).sort(),s=n.filter(t=>e.has(t)),c=s.join("\0")+""+a.join("\0");t.barCategoryCache&&t.barCategoryCache.key===c?i=t.barCategoryCache.order:(i=[...s,...a],t.barCategoryCache={key:c,order:i})}const n=[],o=t.scales,[a,s]=o.x.domain(),c=t.config.barStyle,l=t.config.themeSemantic?.primary,u=c?.gap,h="number"!=typeof u||0>u?1:u,f={};c?.stroke&&(f.stroke=c.stroke),"number"==typeof c?.strokeWidth&&(f.strokeWidth=c.strokeWidth),"number"==typeof c?.opacity&&(f.opacity=c.opacity);for(const e of r.values()){const r=Math.max(e.start,a),u=Math.min(e.end,s);if(r>=u)continue;const y=o.x(r),g=o.x(u),p=Math.abs(g-y),d=p>h+1?h:0,m=Math.min(y,g)+d/2,v=Math.max(p-d,1);if(v>0)if(i&&e.categories.size>0){let r=0;for(const a of i){const i=e.categories.get(a)||0;if(0===i)continue;const s=o.y(r),u=o.y(r+i);n.push(B(m,Math.min(s,u),v,Math.abs(s-u),{fill:t.config.barColors?.[a]||c?.fill||l||"#4e79a7",...f},{binStart:e.start,binEnd:e.end,total:e.total,category:a,categoryValue:i},a)),r+=i}}else{const t=o.y(0),r=o.y(e.total);n.push(B(m,Math.min(t,r),v,Math.abs(t-r),{fill:c?.fill||l||"#007bff",...f},{binStart:e.start,binEnd:e.end,total:e.total}))}}const y=new Set;for(const t of r.values())y.add(t.start),y.add(t.end);return{nodes:n,binBoundaries:Array.from(y).sort((t,e)=>t-e)}}(o,e);return this._barCategoryCache=o.barCategoryCache??null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){const r=[],i=t.config.swarmStyle||{},n=i.radius??3,o=i.fill??t.config.themeSemantic?.primary??"#007bff",a=i.opacity??.7,s=i.stroke,c=i.strokeWidth;for(const i of e){const e=t.getX(i),l=t.getY(i);if(null==l||Number.isNaN(l))continue;const u=t.scales.x(e),h=t.scales.y(l);let f=o;if(t.getCategory){const e=t.getCategory(i);f=t.config.barColors?.[e]||f}const{r:y,...g}=t.config.pointStyle?.(i)??{},p={type:"point",x:u,y:h,r:y??n,style:{fill:f,opacity:a,stroke:s,strokeWidth:c,...g},datum:i};t.getPointId&&(p.pointId=t.getPointId(i)+""),r.push(p)}return r}(o,e);case"waterfall":return function(t,e,r){const i=[],n=t.scales,o=t.config.waterfallStyle,a=e.filter(e=>{const r=t.getY(e),i=t.getX(e);return null!=r&&!Number.isNaN(r)&&null!=i&&isFinite(i)});if(0===a.length)return i;const s=o?.positiveColor??t.config.themeSemantic?.success??"#28a745",c=o?.negativeColor??t.config.themeSemantic?.danger??"#dc3545",l=o?.gap??1,u=o?.stroke,h=o?.strokeWidth,f=o?.opacity;let y=0;for(let e=0;a.length>e;e++){const g=a[e],p=t.getX(g),d=t.getY(g),m=y+d;let v;v=a.length-1>e?t.getX(a[e+1])-p:e>0?p-t.getX(a[e-1]):0;const x=n.x(p),b=0!==v?n.x(p+v):x+r.width/10,k=Math.min(x,b)+l/2,w=Math.max(x,b)-l/2-k;if(0>=w){y=m;continue}const _=n.y(y),A=n.y(m),P=Math.min(_,A),L=Math.abs(_-A),S={fill:0>d?c:s,stroke:u,strokeWidth:h};null!=f&&(S.opacity=f),i.push(B(k,P,w,L,S,{...g,baseline:y,cumEnd:m,delta:d,_connectorStroke:o?.connectorStroke,_connectorWidth:o?.connectorWidth})),y=m}return i}(o,e,t);case"candlestick":return function(t,e){if(!t.getHigh||!t.getLow||!t.scales)return[];const r=t.config.candlestickRangeMode??!1;if(!(r||t.getOpen&&t.getClose))return[];const i=[],n=t.config.candlestickStyle||{},o=n.rangeColor||"#6366f1",a=r?o:n.upColor||"#28a745",s=r?o:n.downColor||"#dc3545",c=r?o:n.wickColor||"#333",l=n.wickWidth||(r?2:1),u=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let h=n.bodyWidth??0;if(null==n.bodyWidth)if(u.length>1){let e=1/0;for(let r=1;u.length>r;r++){const i=Math.abs(t.scales.x(u[r])-t.scales.x(u[r-1]));i>0&&e>i&&(e=i)}h=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else h=6;for(const n of e){const e=t.getX(n);if(null==e||Number.isNaN(e))continue;const o=t.getHigh(n),u=t.getLow(n);if(null==o||Number.isNaN(o)||null==u||Number.isNaN(u))continue;const f=r?o:t.getOpen(n),y=r?u:t.getClose(n);if(!r&&[f,y].some(t=>null==t||Number.isNaN(t)))continue;const g=y>=f,p={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(f),closeY:t.scales.y(y),highY:t.scales.y(o),lowY:t.scales.y(u),bodyWidth:h,upColor:a,downColor:s,wickColor:c,wickWidth:l,isUp:g,datum:n};r&&(p.isRange=!0),i.push(p)}return i}(o,e);default:return[]}}resolveBoundsStyle(t,e){return function(t,e,r,i){const n=t.boundsStyle;return"function"==typeof n?n(r||{},e):n&&"object"==typeof n?n:{fill:i(e,r).stroke||t.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,stroke:"none"}}(this.config,t,e,(t,e)=>this.resolveLineStyle(t,e))}computeDecayOpacity(t,e){const r=this.config.decay;return r&&e>1?Y(r,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const e=N(t);return this._datumIndexCache={version:this._ingestVersion,map:e},e}applyDecay(t,e){this.config.decay&&function(t,e,r,i=N(r)){const n=r.length;if(n>1)for(const r of e){if("line"===r.type){const e=Array.isArray(r.datum)?r.datum:[];if(2>e.length)continue;const o=Array(e.length);let a=!1;for(let r=0;e.length>r;r++){const s=i.get(e[r]);null!=s?(o[r]=Y(t,s,n),1>o[r]&&(a=!0)):o[r]=1}a&&(r._decayOpacities=o);continue}if("area"===r.type){const e=Array.isArray(r.datum)?r.datum:[],o=r.topPath?r.topPath.length:e.length;if(2>o)continue;if(e.length===o){const a=Array(o);let s=!1;for(let r=0;e.length>r;r++){const o=i.get(e[r]);null!=o?(a[r]=Y(t,o,n),1>a[r]&&(s=!0)):a[r]=1}s&&(r._decayOpacities=a)}else{let a=1;for(const r of e){const e=i.get(r);if(null!=e){const r=Y(t,e,n);a>r&&(a=r)}}if(1>a){const t=Array(o);t.fill(a),r._decayOpacities=t}}continue}const e=i.get(r.datum);if(null==e)continue;const o=Y(t,e,n);"heatcell"===r.type?r.style={opacity:o}:"candlestick"===r.type?r._decayOpacity=o:r.style={...r.style,opacity:(r.style?.opacity??1)*o}}}(this.config.decay,t,e,this.getDatumIndexMap(e))}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),t)}hasActivePulsesAt(t){return!!this.config.pulse&&$(this.config.pulse,this.timestampBuffer,t)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,r,i){r.clear(),i.clear();for(let n=0;e.length>n;n++){const o=e[n],a=O(t,o,n);a&&("point"===o.type?r.set(a,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity}):"glyph"===o.type?r.set(a,{x:o.x,y:o.y,r:o.size,opacity:o.style.opacity,glyph:o.glyph}):"rect"===o.type?r.set(a,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity}):"heatcell"===o.type?r.set(a,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style?.opacity}):"candlestick"===o.type?r.set(a,{x:o.x,y:o.openY,w:o.bodyWidth,openY:o.openY,closeY:o.closeY,highY:o.highY,lowY:o.lowY,opacity:o.style?.opacity}):"line"===o.type?i.set(a,{path:o.path.map(t=>[t[0],t[1]]),opacity:o.style?.opacity}):"area"===o.type&&i.set(a,{topPath:o.topPath.map(t=>[t[0],t[1]]),bottomPath:o.bottomPath.map(t=>[t[0],t[1]]),opacity:o.style?.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();const t=this.scales?.y(0)??0;for(let e=0;this.scene.length>e;e++){const r=this.scene[e],i=O(this.transitionContext,r,e);i&&("point"===r.type?this.prevPositionMap.set(i,{x:r.x,y:r.y,r:0,opacity:0}):"rect"===r.type?this.prevPositionMap.set(i,{x:r.x,y:t,w:r.w,h:0,opacity:r.style.opacity??1}):"heatcell"===r.type?this.prevPositionMap.set(i,{x:r.x,y:r.y,w:r.w,h:r.h,opacity:0}):"line"===r.type?(r._introClipFraction=0,this.prevPathMap.set(i,{path:r.path.map(t=>[t[0],t[1]]),opacity:r.style.opacity})):"area"===r.type&&(r._introClipFraction=0,this.prevPathMap.set(i,{topPath:r.topPath.map(t=>[t[0],t[1]]),bottomPath:r.bottomPath.map(t=>[t[0],t[1]]),opacity:r.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,r,i,n,o=l()){if(0===i.size&&0===n.size)return r;const a=e.duration??300;if(r.exitNodes.length>0){const t=new Set(r.exitNodes);r.scene=r.scene.filter(e=>!t.has(e)),r.exitNodes=[]}let s=!1;const c=new Set,u=new Set;for(let e=0;r.scene.length>e;e++){const o=r.scene[e],a=O(t,o,e);if(!a)continue;if(o._transitionKey=a,"line"===o.type||"area"===o.type){const t=n.get(a);if(t){if(u.add(a),"line"===o.type&&t.path&&t.path.length===o.path.length){o._targetPath=o.path.map(t=>[t[0],t[1]]),o._prevPath=t.path;for(let e=0;o.path.length>e;e++)o.path[e]=[t.path[e][0],t.path[e][1]];s=!0}else if("area"===o.type&&t.topPath&&t.bottomPath&&t.topPath.length===o.topPath.length&&t.bottomPath.length===o.bottomPath.length){o._targetTopPath=o.topPath.map(t=>[t[0],t[1]]),o._targetBottomPath=o.bottomPath.map(t=>[t[0],t[1]]),o._prevTopPath=t.topPath,o._prevBottomPath=t.bottomPath;for(let e=0;o.topPath.length>e;e++)o.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;o.bottomPath.length>e;e++)o.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];s=!0}o._targetOpacity=o.style.opacity??1,o._startOpacity=t.opacity??o.style.opacity??1}else o._targetOpacity=o.style.opacity??1,o._startOpacity=0,o.style={...o.style,opacity:0},s=!0;continue}const l=i.get(a);if("point"===o.type)if(l){c.add(a);const t={x:o.x,y:o.y,r:o.r};o._targetOpacity=o.style.opacity??1,l.x===t.x&&l.y===t.y&&l.r===t.r||(o._targetX=t.x,o._targetY=t.y,o._targetR=t.r,o.x=l.x,o.y=l.y,o.r=l.r??o.r,s=!0)}else o._targetOpacity=o.style.opacity??1,o.style={...o.style,opacity:0},s=!0;else if("glyph"===o.type)if(l){c.add(a);const t={x:o.x,y:o.y,size:o.size};o._targetOpacity=o.style.opacity??1,l.x===t.x&&l.y===t.y&&l.r===t.size||(o._targetX=t.x,o._targetY=t.y,o._targetR=t.size,o.x=l.x,o.y=l.y,o.size=l.r??o.size,s=!0)}else o._targetOpacity=o.style.opacity??1,o.style={...o.style,opacity:0},s=!0;else if("rect"===o.type)if(l){c.add(a);const t={x:o.x,y:o.y,w:o.w,h:o.h};o._targetOpacity=o.style.opacity??1,l.x===t.x&&l.y===t.y&&l.w===t.w&&l.h===t.h||(o._targetX=t.x,o._targetY=t.y,o._targetW=t.w,o._targetH=t.h,o.x=l.x,o.y=l.y,o.w=l.w??o.w,o.h=l.h??o.h,s=!0)}else o._targetOpacity=o.style.opacity??1,o.style={...o.style,opacity:0},s=!0;else if("heatcell"===o.type)if(l){c.add(a);const t={x:o.x,y:o.y,w:o.w,h:o.h};o._targetOpacity=o.style?.opacity??1,l.x===t.x&&l.y===t.y&&l.w===t.w&&l.h===t.h||(o._targetX=t.x,o._targetY=t.y,o._targetW=t.w,o._targetH=t.h,o.x=l.x,o.y=l.y,o.w=l.w??o.w,o.h=l.h??o.h,s=!0)}else o._targetOpacity=o.style?.opacity??1,o.style={...o.style||{},opacity:0},s=!0;else if("candlestick"===o.type)if(l&&null!=l.openY){c.add(a);const t={x:o.x,openY:o.openY,closeY:o.closeY,highY:o.highY,lowY:o.lowY};o._targetOpacity=o.style?.opacity??1,(l.x!==t.x||l.openY!==t.openY||l.closeY!==t.closeY||l.highY!==t.highY||l.lowY!==t.lowY)&&(o._targetX=t.x,o._targetOpenY=t.openY,o._targetCloseY=t.closeY,o._targetHighY=t.highY,o._targetLowY=t.lowY,o.x=l.x,o.openY=l.openY,o.closeY=l.closeY??o.closeY,o.highY=l.highY??o.highY,o.lowY=l.lowY??o.lowY,s=!0)}else o._targetOpacity=o.style?.opacity??1,o.style={...o.style||{},opacity:0},s=!0}for(const[t,e]of n)if(!u.has(t))if(t.startsWith("l:")&&e.path){const i={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t,datum:null};r.exitNodes.push(i),s=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const i={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t,datum:null};r.exitNodes.push(i),s=!0}for(const[t,e]of i)if(!c.has(t)){if(t.startsWith("p:"))r.exitNodes.push({type:"point",x:e.x,y:e.y,r:e.r??3,style:{opacity:e.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("g:")&&e.glyph)r.exitNodes.push({type:"glyph",x:e.x,y:e.y,size:e.r??12,glyph:e.glyph,color:"#999",accent:"#999",style:{opacity:e.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))r.exitNodes.push({type:"rect",x:e.x,y:e.y,w:e.w??0,h:e.h??0,style:{opacity:e.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("h:"))r.exitNodes.push({type:"heatcell",x:e.x,y:e.y,w:e.w??0,h:e.h??0,fill:"#999",datum:null,style:{opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t});else if(t.startsWith("c:")){const i=e.openY??e.y;r.exitNodes.push({type:"candlestick",x:e.x,openY:i,closeY:e.closeY??i,highY:e.highY??i,lowY:e.lowY??i,bodyWidth:e.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t})}s=!0}return r.exitNodes.length>0&&(r.scene=[...r.scene,...r.exitNodes]),s&&(r.activeTransition={startTime:o,duration:a}),r}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap,this.currentTime());this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},r=function(t,e,r,i){if(!r.activeTransition)return!1;const n=s(t,r.activeTransition),o=a(n,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of r.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const r=e?i.get(e):void 0;t.style.opacity=c(r?r.opacity??1:0,t._targetOpacity,o)}if(void 0===t._targetX)continue;if(!e)continue;const r=i.get(e);if(!r)continue;t.x=c(r.x,t._targetX,o),t.y=c(r.y,t._targetY,o),void 0!==t._targetR&&void 0!==r.r&&(t.r=c(r.r,t._targetR,o))}else if("glyph"===t.type){if(void 0!==t._targetOpacity){const r=e?i.get(e):void 0;t.style.opacity=c(r?r.opacity??1:0,t._targetOpacity,o)}if(void 0===t._targetX)continue;if(!e)continue;const r=i.get(e);if(!r)continue;t.x=c(r.x,t._targetX,o),t.y=c(r.y,t._targetY,o),void 0!==t._targetR&&void 0!==r.r&&(t.size=c(r.r,t._targetR,o))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const r=e?i.get(e):void 0;t.style.opacity=c(r?r.opacity??1:0,t._targetOpacity,o)}if(void 0===t._targetX)continue;if(!e)continue;const r=i.get(e);if(!r)continue;t.x=c(r.x,t._targetX,o),t.y=c(r.y,t._targetY,o),void 0!==r.w&&(t.w=c(r.w,t._targetW,o)),void 0!==r.h&&(t.h=c(r.h,t._targetH,o))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const r=e?i.get(e):void 0;t.style={...t.style||{},opacity:c(r?r.opacity??1:0,t._targetOpacity,o)}}if(void 0===t._targetX)continue;if(!e)continue;const r=i.get(e);if(!r)continue;t.x=c(r.x,t._targetX,o),t.y=c(r.y,t._targetY,o),void 0!==r.w&&(t.w=c(r.w,t._targetW,o)),void 0!==r.h&&(t.h=c(r.h,t._targetH,o))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const r=e?i.get(e):void 0;t.style={...t.style||{},opacity:c(r?r.opacity??1:0,t._targetOpacity,o)}}if(void 0===t._targetX)continue;if(!e)continue;const r=i.get(e);if(!r)continue;t.x=c(r.x,t._targetX,o),void 0!==r.openY&&(t.openY=c(r.openY,t._targetOpenY,o)),void 0!==r.closeY&&(t.closeY=c(r.closeY,t._targetCloseY,o)),void 0!==r.highY&&(t.highY=c(r.highY,t._targetHighY,o)),void 0!==r.lowY&&(t.lowY=c(r.lowY,t._targetLowY,o))}else if("line"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:c(t._startOpacity??0,t._targetOpacity,o)}),void 0!==t._introClipFraction&&(t._introClipFraction=o);const e=t._prevPath,r=t._targetPath;if(e&&r&&e.length===t.path.length)for(let i=0;t.path.length>i;i++)t.path[i][0]=c(e[i][0],r[i][0],o),t.path[i][1]=c(e[i][1],r[i][1],o)}else if("area"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:c(t._startOpacity??0,t._targetOpacity,o)}),void 0!==t._introClipFraction&&(t._introClipFraction=o);const e=t._prevTopPath,r=t._prevBottomPath,i=t._targetTopPath,n=t._targetBottomPath;if(e&&i&&e.length===t.topPath.length)for(let r=0;t.topPath.length>r;r++)t.topPath[r][0]=c(e[r][0],i[r][0],o),t.topPath[r][1]=c(e[r][1],i[r][1],o);if(r&&n&&r.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=c(r[e][0],n[e][0],o),t.bottomPath[e][1]=c(r[e][1],n[e][1],o)}}if(n>=1){for(const t of r.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style="line"===t.type||"area"===t.type?{...t.style,opacity:0===e?0:e}:{...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("glyph"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.size=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("candlestick"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let r=0;t.path.length>r;r++)t.path[r]=e[r];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,r=t._targetBottomPath;if(e)for(let r=0;t.topPath.length>r;r++)t.topPath[r]=e[r];if(r)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=r[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(r.exitNodes.length>0){const t=new Set(r.exitNodes);r.scene=r.scene.filter(e=>!t.has(e)),r.exitNodes=[]}return r.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,r}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const t of this.scene)"line"!==t.type&&"area"!==t.type||(t._introClipFraction=void 0)}groupData(t){const{result:e,cache:r}=function(t,e,r,i){if(i&&i.version===r&&i.group===e&&i.data===t)return{result:i.result,cache:i};let n;if(e){const r=new Map;for(const i of t){const t=e(i);r.has(t)||r.set(t,[]),r.get(t).push(i)}n=Array.from(r.entries()).map(([t,e])=>({key:t,data:e}))}else n=[{key:"_default",data:t}];return{result:n,cache:{version:r,group:e,data:t,result:n}}}(t,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=r,e}resolveColorMap(t){const{map:e,cache:r}=function(t,e,r,i,o){if(o&&o.version===i)return{map:o.map,cache:o};const a=new Set;if(e)for(const r of t){const t=e(r);t&&a.add(t)}const s=Array.from(a).sort(),c=s.join("\0");if(o&&o.key===c){const t={...o,version:i};return{map:t.map,cache:t}}const l=Array.isArray(r.colorScheme)?r.colorScheme:r.themeCategorical||n,u=new Map;for(let t=0;s.length>t;t++)u.set(s[t],l[t%l.length]);return{map:u,cache:{key:c,map:u,version:i}}}(t,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=r,e}resolveLineStyle(t,e){return function(t,e,r,i){const n=t.lineStyle;if("function"==typeof n){const t=n(r||{},e);if(t&&!t.stroke&&e){const r=i(e);if(r)return{...t,stroke:r}}return t}const o=t.themeSemantic?.primary;return n&&"object"==typeof n?{stroke:n.stroke||o||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:i(e)||o||"#007bff",strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveAreaStyle(t,e){return function(t,e,r,i){if(t.areaStyle){const n=t.areaStyle(r||{});if(n&&!n.fill&&e){const t=i(e);if(t)return{...n,fill:t,stroke:n.stroke||t}}return n}const n=t.lineStyle;if("function"==typeof n){const t=n(r||{},e);if(t&&!t.fill&&e){const r=i(e);if(r)return{...t,fill:r,stroke:t.stroke||r}}return t}const o=t.themeSemantic?.primary;if(n&&"object"==typeof n)return{fill:n.fill||n.stroke||o||"#4e79a7",fillOpacity:n.fillOpacity??.7,stroke:n.stroke||o||"#4e79a7",strokeWidth:n.strokeWidth||2};const a=i(e)||o||"#4e79a7";return{fill:a,fillOpacity:.7,stroke:a,strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveGroupColor(t){const{color:e,groupColorCounter:i}=function(t){const{group:e,colorMapCache:r,groupColorMap:i,groupColorMapCap:o,config:a}=t;let{groupColorCounter:s}=t;if(r){const t=r.map.get(e);if(t)return{color:t,groupColorCounter:s}}const c=i.get(e);if(c)return{color:c,groupColorCounter:s};const l=(Array.isArray(a.colorScheme)&&a.colorScheme.length>0?a.colorScheme:null)||(Array.isArray(a.themeCategorical)&&a.themeCategorical.length>0?a.themeCategorical:null)||n;if(0===l.length)return{color:null,groupColorCounter:s};const u=l[s%l.length];if(s++,i.set(e,u),i.size>o){const t=i.keys().next().value;void 0!==t&&i.delete(t)}return{color:u,groupColorCounter:s}}({group:t,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:r.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=i,e}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=E(t),r=this.getPointId,i=t=>e.has(r(t));ft(this.buffer,this.timestampBuffer,i);const n=this.buffer.remove(i);if(0===n.length)return this.updateResults.recordNoop("remove"),n;for(const t of n)this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",n.length),n}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const r=E(t),i=this.getPointId,n=new Set;this.buffer.forEach((t,e)=>{r.has(i(t))&&n.add(e)});const o=this.buffer.update(t=>r.has(i(t)),e);if(0===o.length)return this.updateResults.recordNoop("update"),o;for(const t of o)this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t);return this.buffer.forEach((t,e)=>{n.has(e)&&(this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",o.length),o}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this._datumIndexCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.spatialIndex.clear(),this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}applyCustomRestyle(t,e){const r=this._customRestyle;if(r)for(const i of t){const t=this._baseStyles.get(i)??i.style??{},n=r(i,e);i.style=n?{...t,...n}:t}}restyleScene(t){this._customRestyle?(this.applyCustomRestyle(this.scene,t),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(t){const e={...this.config},r=Object.keys(t).filter(r=>t[r]!==e[r]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in t&&t.windowSize!==e.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${e.windowSize} → ${t.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"boundsAccessor"in t||"band"in t||"y0Accessor"in t||"openAccessor"in t||"highAccessor"in t||"lowAccessor"in t||"closeAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(this._stackExtentCache=null);let i=!1,n=!1;Object.assign(this.config,t),"pulse"in t&&this.syncPulseTimestampBuffer();const o="chartType"in t&&t.chartType!==e.chartType||"runtimeMode"in t&&t.runtimeMode!==e.runtimeMode;if(o||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const t=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,r=t&&this.config.valueAccessor||this.config.yAccessor,a=t&&e.valueAccessor||e.yAccessor,s=o||!h(t&&this.config.timeAccessor||this.config.xAccessor,t&&e.timeAccessor||e.xAccessor),c=o||!h(r,a);(s||c)&&(t?(this.getX=f(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=f(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=f(this.config.xAccessor,"x"),this.getY=f(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(t=>"bounds"===t.kind)&&(this.resolvedRibbons=rt(this.config)),i=!0,n=!0)}if("groupAccessor"in t&&!h(t.groupAccessor,e.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?g(this.config.groupAccessor):void 0,i=!0),"categoryAccessor"in t&&!h(t.categoryAccessor,e.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?g(this.config.categoryAccessor):void 0,i=!0),"sizeAccessor"in t&&!h(t.sizeAccessor,e.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?f(this.config.sizeAccessor,"size"):void 0,i=!0),"symbolAccessor"in t&&!h(t.symbolAccessor,e.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?g(this.config.symbolAccessor):void 0,i=!0),"colorAccessor"in t&&!h(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?g(this.config.colorAccessor):void 0,i=!0),"y0Accessor"in t&&!h(t.y0Accessor,e.y0Accessor)&&(this.getY0=this.config.y0Accessor?f(this.config.y0Accessor,"y0"):void 0,i=!0,n=!0),("boundsAccessor"in t&&!h(t.boundsAccessor,e.boundsAccessor)||"band"in t&&t.band!==e.band||"boundsStyle"in t&&t.boundsStyle!==e.boundsStyle)&&(this.resolvedRibbons=rt(this.config),i=!0,n=!0),"pointIdAccessor"in t&&!h(t.pointIdAccessor,e.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?g(this.config.pointIdAccessor):void 0,i=!0),"candlestick"===this.config.chartType&&(o||"openAccessor"in t&&!h(t.openAccessor,e.openAccessor)||"closeAccessor"in t&&!h(t.closeAccessor,e.closeAccessor)||"highAccessor"in t&&!h(t.highAccessor,e.highAccessor)||"lowAccessor"in t&&!h(t.lowAccessor,e.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?f(this.config.openAccessor,"open"):void 0,this.getHigh=f(this.config.highAccessor,"high"),this.getLow=f(this.config.lowAccessor,"low"),this.getClose=e?f(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,i=!0,n=!0}if("accessorRevision"in t&&t.accessorRevision!==e.accessorRevision&&(i=!0,n=!0),!i){const r=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const n of r)if(t[n]!==e[n]){i=!0;break}}i&&(n&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(r)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}};$t.GROUP_COLOR_MAP_CAP=1e3;var Ot=$t;bt(Ot);var Ft=new Set;function It(t,e){const r="function"==typeof t?t(e.datum??null,e):t;return(i=r)&&"object"==typeof i&&"string"==typeof i.id&&"function"==typeof i.cacheKey&&"function"==typeof i.drawCanvas&&"function"==typeof i.renderStaticSVG?r:void 0;var i}function zt(t,e){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const r=`${t}:${e}`;Ft.has(r)||(Ft.add(r),console.warn(`[Semiotic] Render backend "${t}" does not support scene node "${e}"; using the built-in renderer.`))}function Wt(t){const{context:e,nodes:r,renderMode:i,pixelRatio:n,paintBuiltIn:o}=t;if(!i||"sketchy"===i)return void o(r);let a=[];const s=()=>{a.length&&(o(a),a=[])};for(const t of r){const r=It(i,t);if(!r){a.push(t);continue}let c;s(),e.save();try{c=r.drawCanvas({context:e,node:t,style:t.style??{},pixelRatio:n})}finally{e.restore()}c||(zt(r.id,t.type??"unknown"),o([t]))}s()}function Xt(t){const{node:e,index:r,renderMode:i,fallback:n}=t,o=It(i,e);if(!o)return n();const a=o.renderStaticSVG({node:e,style:e.style??{},key:`${o.id}-${r}`});return null!=a?a:(zt(o.id,e.type??"unknown"),n())}function Bt(t){const e=[];return t.nodes.forEach((r,i)=>{const n=Xt({node:r,index:i,renderMode:t.renderMode,fallback:()=>t.fallback(r,i)});null!=n&&!1!==n&&e.push({node:r,element:n})}),e}function Gt(t,e,r){const i="function"==typeof e?e(t):t[e??r];if(null==i)return null;if(i instanceof Date)return i.getTime();if("string"==typeof i&&""===i.trim())return null;const n=Number(i);return Number.isFinite(n)?n:null}function jt({data:t,valueAccessor:e,timeAccessor:r,binSize:i,valueExtent:n,extentPadding:o}){if(n)return[n[1],n[0]];if(!t||0===t.length)return;const a=new Map;for(const n of t){const t=Gt(n,r,"time"),o=Gt(n,e,"value");if(null==t||null==o)continue;const s=Math.floor(t/i)*i;a.set(s,(a.get(s)??0)+o)}let s=0;for(const t of a.values())s=Math.max(s,t);return[s>0?s+s*(o??.1):1,0]}function Vt(t,e,r){return"exact"===r?function(t,e){const r=t.domain(),i=r[0],n=r[r.length-1],o=i instanceof Date,a=i instanceof Date?i.getTime():i,s=n instanceof Date?n.getTime():n;if(2>e||a===s)return o?[new Date(a),new Date(s)]:[a,s];const c=(s-a)/(e-1),l=Array(e);for(let t=0;e>t;t++){const r=t===e-1?s:a+t*c;l[t]=o?new Date(r):r}return l}(t,e):t.ticks(e)}function Ht(t,e){var r=t.get(e);if(!r)throw Error("missing: "+e);return r}function Kt(t,e){var r,i=[],n=[],o=[],a={},s=[];function c(t){o[t]=!1,a.hasOwnProperty(t)&&Object.keys(a[t]).forEach(function(e){delete a[t][e],o[e]&&c(e)})}function l(t){var e,i,h=!1;for(n.push(t),o[t]=!0,e=0;s[t].length>e;e++)(i=s[t][e])===r?(u(r,n),h=!0):o[i]||(h=l(i));if(h)c(t);else for(e=0;s[t].length>e;e++){var f=a[i=s[t][e]];f||(a[i]=f={}),f[i]=!0}return n.pop(),h}function u(t,r){var n=[].concat(r).concat(t);e?e(n):i.push(n)}function h(e){!function(e){for(var r=0;t.length>r;r++)r>=e&&t[r]||(t[r]=[]),t[r]=t[r].filter(function(t){return t>=e})}(e);for(var r,i=function(t){for(var e=t.length,r=Array(e),i=Array(e),n=Array(e),o=Array(e),a=Array(e),s=Array(e),c=0;e>c;++c)r[c]=-1,i[c]=0,n[c]=!1,o[c]=0,a[c]=-1,s[c]=[];var l,u=0,h=[],f=[];function y(e){var c=[e],l=[e];for(r[e]=i[e]=u,n[e]=!0,u+=1;l.length>0;){var y=t[e=l[l.length-1]];if(y.length>o[e]){for(var g=o[e];y.length>g;++g){var p=y[g];if(0>r[p]){r[p]=i[p]=u,n[p]=!0,u+=1,c.push(p),l.push(p);break}n[p]&&(i[e]=0|Math.min(i[e],i[p])),0>a[p]||s[e].push(a[p])}o[e]=g}else{if(i[e]===r[e]){var d=[],m=[],v=0;for(g=c.length-1;g>=0;--g){var x=c[g];if(n[x]=!1,d.push(x),m.push(s[x]),v+=s[x].length,a[x]=h.length,x===e){c.length=g;break}}h.push(d);var b=Array(v);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)b[--v]=m[g][k];f.push(b)}l.pop()}}}for(c=0;e>c;++c)0>r[c]&&y(c);for(c=0;f.length>c;c++){var g=f[c];if(0!==g.length){g.sort(function(t,e){return t-e}),l=[g[0]];for(var p=1;g.length>p;p++)g[p]!==g[p-1]&&l.push(g[p]);f[c]=l}}return{components:h,adjacencyList:f}}(t),n=i.components.filter(function(t){return t.length>1}),o=1/0,a=0;n.length>a;a++)for(var s=0;n[a].length>s;s++)o>n[a][s]&&(o=n[a][s],r=a);var c=n[r];return!!c&&{leastVertex:o,adjList:t.map(function(t,e){return-1===c.indexOf(e)?[]:t.filter(function(t){return-1!==c.indexOf(t)})})}}r=0;for(var f=t.length;f>r;){var y=h(r);if(r=y.leastVertex,s=y.adjList){for(var g=0;s.length>g;g++)for(var p=0;s[g].length>p;p++){var d=s[g][p];o[+d]=!1,a[d]={}}l(r),r+=1}else r=f}return e?void 0:i}function qt(t){return t.y0-t.y1>0?"up":"down"}function Zt(t,e){return e(t.source)==e(t.target)}function Ut(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var r=0;return t.target.targetLinks.forEach(function(t){r=t.circular?r+1:r}),1>=e&&1>=r}function Qt(t){return t.target.x0-t.source.x1}function Jt(t,e){var r=ee(t),i=Qt(e)/Math.tan(r);return"up"==qt(t)?t.y1-i:t.y1+i}function te(t,e){var r=ee(t),i=Qt(e)/Math.tan(r);return"up"==qt(t)?t.y1+i:t.y1-i}function ee(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function re(t,e){return e(t)}function ie(t){return oe(t.source)}function ne(t){return oe(t.target)}function oe(t){return(t.y0+t.y1)/2}function ae(t){return t.virtual?0:t.value}function se(t,e){var r=0;t.sourceLinks.forEach(function(t){r=t.circular&&!Zt(t,e)?r+1:r});var i=0;return t.targetLinks.forEach(function(t){i=t.circular&&!Zt(t,e)?i+1:i}),r+i}function ce(t){return t.target.depth}function le(t,e){return t.sourceLinks.length?t.depth:e-1}function ue(t,e){return t.y0-e.y0}function he(t,e){return e.y0-t.y0}function fe(t,e){return t.y1-e.y1}function ye(t,e){return e.y1-t.y1}function ge(t,e){return de(t.source,e.source)||t.index-e.index}function pe(t,e){return de(t.target,e.target)||t.index-e.index}function de(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function me(t,e){return ve(t)==ve(e)?"bottom"==t.circularLinkType?he(t,e):ue(t,e):ve(e)-ve(t)}function ve(t){return t.target.column-t.source.column}function xe(t,e){return be(t)==be(e)}function be(t){return t.y0-t.y1>0?"up":"down"}import{min as ke}from"d3-array";function we(t,e,r,i,n){let o=t;var a=Math.max(8,.15*(o.y1-o.y0));o.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,a))});var s=ke(o.links,function(t){return t.source.y0});o.links.forEach(function(t){t.circular&&(t.circularPathData={})});var c=o.links.filter(function(t){return t.circular});return c.sort(function(t,e){return e.value-t.value}),c.forEach(function(t,e){t._circularStub=e>=4}),_e(o.links.filter(function(t){return"top"==t.circularLinkType}),e,r),_e(o.links.filter(function(t){return"bottom"==t.circularLinkType}),e,r),o.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+i,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,Zt(t,e)&&Ut(t))t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+n+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-n-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var a=t.source.column,c=t.circularLinkType,l=o.links.filter(function(t){return t.source.column==a&&t.circularLinkType==c});l.sort("bottom"==t.circularLinkType?he:ue);var u=0;l.forEach(function(e,n){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=i+t._circularWidth/2+n*r+u),u+=e._circularWidth||e.width}),a=t.target.column,(l=o.links.filter(function(t){return t.target.column==a&&t.circularLinkType==c})).sort("bottom"==t.circularLinkType?ye:fe),u=0,l.forEach(function(e,n){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=i+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=i+t._circularWidth/2+n*r+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(o.y1,t.source.y1,t.target.y1)+n+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=s-n-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,r=t.y0,i=t.target.x0,n=t.y1,o=(e+i)/2;return"M"+e+","+r+"C"+o+","+r+" "+o+","+n+" "+i+","+n}(t)}),o}function _e(t,e,r){t.sort(me);var i=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,n){var o=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(Zt(t,e)&&Ut(t))t.circularPathData.verticalBuffer=o+t._circularWidth/2;else{for(var a=0;i.length>a;a++){var s=i[a];if(s!==t&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&Ae(t,s)){var c=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+r;o=c>o?c:o}}t.circularPathData.verticalBuffer=o+t._circularWidth/2}}),t}function Ae(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}import{min as Pe,max as Le,sum as Se,mean as Me,group as Ce,groups as De}from"d3-array";function Ee(t){return function(){return t}}function Ye(t){return t.index}function Ne(t){return t.nodes}function Re(t){return t.links}function Te(t,e,r){var i=De(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});i.forEach(function(n,o){var a=n.length;if(e)n.sort(e);else if(o>0){var s=new Map;n.forEach(function(t,e){var r,i,n,o=(i=0,n=0,(r=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;n+=oe(t.source)*e,i+=e}}),r.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;n+=oe(t.target)*e,i+=e}}),i>0?n/i:NaN);s.set(t,{bc:o,idx:e})}),n.sort(function(t,e){var r=s.get(t),i=s.get(e),n=r.bc,o=i.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(n)||isNaN(o)?isNaN(n)?isNaN(o)?r.idx-i.idx:1:-1:n-o})}else n.sort(function(t,e){return t.circularLinkType==e.circularLinkType?se(e,r)-se(t,r):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});n.forEach(function(e,n){e.depth==i.length-1&&1==a||0==e.depth&&1==a?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==se(e,r)?(e.y0=t.y1/2+n,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+n,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-n,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/a*n,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-a/2+n,e.y1=e.y0+e.value*t.ky)})})}function $e(t,e,r,i,n,o){var a=De(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});u();for(var s=1,c=o;c>0;--c)l(s*=.99,r),u();function l(e,r){var i=a.length;a.forEach(function(n){var o=n.length,a=n[0].depth;n.forEach(function(n){var s;if(n.sourceLinks.length||n.targetLinks.length)if(n.partOfCycle&&se(n,r)>0){var c=Me(n.sourceLinks,ne),l=Me(n.targetLinks,ie),u=c&&l?(c+l)/2:c||l;if(u){var h=(u-oe(n))*e*.3;n.y0+=h,n.y1+=h}}else if(0==a&&1==o)n.y0=t.y1/2-(s=n.y1-n.y0)/2,n.y1=t.y1/2+s/2;else if(a==i-1&&1==o)n.y0=t.y1/2-(s=n.y1-n.y0)/2,n.y1=t.y1/2+s/2;else if(1==n.targetLinks.length&&1==n.targetLinks[0].source.sourceLinks.length)s=n.y1-n.y0,n.y0=n.targetLinks[0].source.y0,n.y1=n.y0+s;else{var f=Me(n.sourceLinks,ne),y=Me(n.targetLinks,ie),g=((f&&y?(f+y)/2:f||y)-oe(n))*e;n.y0+=g,n.y1+=g}})})}function u(){a.forEach(function(r){var o,a,s,c=t.y0,l=r.length;for(r.sort(e||de),s=0;l>s;++s)(a=c-(o=r[s]).y0)>0&&(o.y0+=a,o.y1+=a),c=o.y1+i;if((a=c-i-t.y1)>0)for(c=o.y0-=a,o.y1-=a,s=l-2;s>=0;--s)(a=(o=r[s]).y1+n-c)>0&&(o.y0-=a,o.y1-=a),c=o.y0})}}function Oe(t){t.nodes.forEach(function(t){t.sourceLinks.sort(pe),t.targetLinks.sort(ge)}),t.nodes.forEach(function(t){var e=t.y0,r=e,i=t.y1,n=i;t.sourceLinks.forEach(function(t){t.circular?(t.y0=i-t.width/2,i-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=n-t.width/2,n-=t.width):(t.y1=r+t.width/2,r+=t.width)})})}function Fe(){var t=0,e=0,r=1,i=1,n=24,o=8,a=null,s=Ye,c=le,l=void 0,u=32,h=2,f=Ne,y=Re;function g(){var g={nodes:f.apply(null,arguments),links:y.apply(null,arguments)};return function(f){f.x0=t,f.y0=e,f.x1=r,f.y1=i,f.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var r=function(t,e){var r=new Map;return Ce(t,e).forEach(function(t,e){r.set(e,t[0])}),r}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var i=t.source,n=t.target;"object"!=typeof i&&(i=t.source=Ht(r,i)),"object"!=typeof n&&(n=t.target=Ht(r,n)),i.sourceLinks.push(t),n.targetLinks.push(t)})}(f,s),function(t,e){var r=0;if(null==e){for(var i=[],n=0;t.links.length>n;n++){var o=t.links[n],a=o.source.index,s=o.target.index;i[a]||(i[a]=[]),i[s]||(i[s]=[]),-1===i[a].indexOf(s)&&i[a].push(s)}var c=Kt(i);c.sort(function(t,e){return t.length-e.length});var l={};for(n=0;c.length>n;n++){var u=c[n].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}t.links.forEach(function(t){var e=t.target.index,i=t.source.index;e===i||l[i]&&l[i][e]?(t.circular=!0,t.circularLinkID=r++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=r++)})}(f,l),function(t,e){var r=0,i=0;t.links.forEach(function(n){n.circular&&(n.circularLinkType=n.source.circularLinkType||n.target.circularLinkType?n.source.circularLinkType?n.source.circularLinkType:n.target.circularLinkType:i>r?"top":"bottom","top"==n.circularLinkType?r++:i++,t.nodes.forEach(function(t){re(t,e)!=re(n.source,e)&&re(t,e)!=re(n.target,e)||(t.circularLinkType=n.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),Zt(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(f,s),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max(Se(t.sourceLinks,ae),Se(t.targetLinks,ae)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(f),function(t,e,r){var i,n,o;if(null!=e){t.nodes.sort(function(t,r){return e(t)<e(r)?-1:1});var a=0,s=e(t.nodes[0]);t.nodes.forEach(function(t){a=e(t)==s?a:a+1,s=e(t)==s?s:e(t),t.column=a})}for(i=t.nodes,n=[],o=0;i.length;++o,i=n,n=[])i.forEach(function(t){t.depth=o,t.sourceLinks.forEach(function(t){0>n.indexOf(t.target)&&!t.circular&&n.push(t.target)})});for(i=t.nodes,n=[],o=0;i.length;++o,i=n,n=[])i.forEach(function(t){t.height=o,t.targetLinks.forEach(function(t){0>n.indexOf(t.source)&&!t.circular&&n.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?r(t,o):t.column})}(f,l,c);var y=o;if(null!==a){var g=De(f.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),p=Le(g,function(t){return t.length});p>1&&(y=Math.max(1,(i-e)*a/(p-1)))}(function(t,e,r){var i=De(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var n=Pe(i,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/Se(e,function(t){return t.value})});t.ky=n,t.links.forEach(function(e){e.width=e.value*t.ky});var o=Le(t.nodes,function(t){return t.column});t.nodes.forEach(o>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-r)/o),e.x1=e.x0+r}:function(e){e.x0=t.x0,e.x1=e.x0+r})})(f,y,n),Te(f,l,s),$e(f,l,s,y,y,u),Oe(f),we(f,s,h,10,8),Te(f,l,s),$e(f,l,s,y,y,u),Oe(f),we(f,s,h,10,8),function(t,e){let r=t;r.nodes.forEach(function(t){t.y+(t.y1-t.y0)>r.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-r.y1));var i=r.links.filter(function(r){return re(r.source,e)==re(t,e)}),n=i.length;n>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!xe(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var r=Jt(e,t);return t.y1-r}if(e.target.column>t.target.column)return Jt(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var o=t.y0;i.forEach(function(t){t.y0=o+t.width/2,o+=t.width}),i.forEach(function(e,r){if("bottom"==e.circularLinkType){for(var o=r+1,a=0;n>o;o++)a+=i[o].width;e.y0=t.y1-a-e.width/2}})})}(f,s),function(t,e){let r=t;r.nodes.forEach(function(t){var i=r.links.filter(function(r){return re(r.target,e)==re(t,e)}),n=i.length;n>1&&i.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!xe(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var r=te(e,t);return t.y0-r}if(e.source.column>t.source.column)return te(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var o=t.y0;i.forEach(function(t){t.y1=o+t.width/2,o+=t.width}),i.forEach(function(e,r){if("bottom"==e.circularLinkType){for(var o=r+1,a=0;n>o;o++)a+=i[o].width;e.y1=t.y1-a-e.width/2}})})}(f,s),function(t){var e=t.nodes,r=t.links,i=!1,n=!1;if(r.forEach(function(t){"top"==t.circularLinkType?i=!0:"bottom"==t.circularLinkType&&(n=!0)}),0==i||0==n){let i=function(e){return(e-o)/(a-o)*(t.y1-t.y0)+t.y0};var o=Pe(e,function(t){return t.y0}),a=Le(e,function(t){return t.y1}),s=(t.y1-t.y0)/(a-o);1>s?(e.forEach(function(t){t.y0=i(t.y0),t.y1=i(t.y1)}),r.forEach(function(t){t.y0=i(t.y0),t.y1=i(t.y1),t.width=t.width*s})):e.forEach(function(t){var e=t.y1-t.y0,r=i(t.y0)-t.y0;t.y0=i(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+r}),t.targetLinks.forEach(function(t){t.y1=t.y1+r})})}}(f),we(f,s,h,10,8)}(g),g}return g.update=function(t){return Oe(t),we(t,s,h,10,8),t},g.nodeWidth=function(t){return arguments.length?(n=+t,g):n},g.nodePadding=function(t){return arguments.length?(o=+t,g):o},g.nodePaddingRatio=function(t){return arguments.length?(a=+t,g):a},g.nodes=function(t){return arguments.length?(f="function"==typeof t?t:Ee(t),g):f},g.links=function(t){return arguments.length?(y="function"==typeof t?t:Ee(t),g):y},g.nodeId=function(t){return arguments.length?(s="function"==typeof t?t:Ee(t),g):s},g.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:Ee(t),g):c},g.nodeSort=function(t){return arguments.length?(l=t,g):l},g.iterations=function(t){return arguments.length?(u=+t,g):u},g.circularLinkGap=function(t){return arguments.length?(h=+t,g):h},g.extent=function(n){return arguments.length?(t=+n[0][0],e=+n[0][1],r=+n[1][0],i=+n[1][1],g):[[t,e],[r,i]]},g.size=function(n){return arguments.length?(t=e=0,r=+n[0],i=+n[1],g):[r-t,i-e]},g}import{interpolateNumber as Ie}from"d3-interpolate";import{line as ze,curveLinearClosed as We}from"d3-shape";function Xe(t){const{sx:e,sTop:r,sBot:i,tx:n,tTop:o,tBot:a,cp1X:s,cp2X:c}=t,l=(r+i)/2,u=(o+a)/2;return{pathD:[`M${e},${r}`,`C${s},${r} ${c},${o} ${n},${o}`,`L${n},${a}`,`C${c},${a} ${s},${i} ${e},${i}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:e,y:l},{x:s,y:l},{x:c,y:u},{x:n,y:u}],halfWidth:(i-r)/2}}}var Be=t=>{let e,r,i,n,o,a,s,c,l;if("down"===t.direction)return e=t.y0-t.sankeyWidth/2,r=t.y1-t.sankeyWidth/2,i=t.y1+t.sankeyWidth/2,n=t.y0+t.sankeyWidth/2,o=t.source.x1,a=t.target.x0,s=Ie(o,a),c=s(.5),l=s(.5),`M${e},${o}C${e},${c} ${r},${l} ${r},${a}L${i},${a}C${i},${l} ${n},${c} ${n},${o}Z`;const u=t.sankeyWidth/2,h=Ie(t.source.x1,t.target.x0),{pathD:f}=Xe({sx:t.source.x1,sTop:t.y0-u,sBot:t.y0+u,tx:t.target.x0,tTop:t.y1-u,tBot:t.y1+u,cp1X:h(.5),cp2X:h(.5)});return f};function Ge(t){const e=t.sankeyWidth/2,r=(t._circularWidth??t.sankeyWidth)/2,i=t.circularPathData;if(!i)return null;if("down"===t.direction)return null;if(t._circularStub){const r=i.sourceX,n=i.sourceY,o=i.targetX,a=i.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const s=Math.max(15,Math.min(40,.33*(i.rightFullExtent-r))),c=Math.max(15,Math.min(40,.33*(o-i.leftFullExtent)));return`M${r},${n-e}L${r+s},${n-e}L${r+s},${n+e}L${r},${n+e}ZM${o},${a-e}L${o-c},${a-e}L${o-c},${a+e}L${o},${a+e}Z`}const n=i.sourceX,o=i.sourceY,a=i.targetX,s=i.targetY,c=i.rightFullExtent,l=i.leftFullExtent,u=i.verticalFullExtent,h="bottom"===t.circularLinkType?1:-1,f=Math.max(4,Math.min(r,15));return`M${n},${o-h*e}L${c},${o-h*e}L${c+r},${o-h*e+h*f}L${c+r},${u+h*r-h*f}L${c+r-f},${u+h*r}L${l-r+f},${u+h*r}L${l-r},${u+h*r-h*f}L${l-r},${s-h*e+h*f}L${l-r+f},${s-h*e}L${a},${s-h*e}L${a},${s+h*e}L${l+r},${s+h*e}L${l+r},${u-h*r}L${c-r},${u-h*r}L${c-r},${o+h*e}L${n},${o+h*e}Z`}var je={left:function(t){return t.depth},right:function(t,e){return e-1-t.height},center:function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Math.min.apply(Math,t.sourceLinks.map(ce))-1:0},justify:le};function Ve(t){return"string"==typeof t?t:t.id}var He={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,r,i){if(0===t.length)return;const n="vertical"===r.orientation?"down":"right",o=r.nodeAlign||"justify",a=r.nodeWidth??15,s=r.nodePaddingRatio??.05,c=r.iterations??100,l=t.map(t=>({...t})),u=e.map(t=>({...t,source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let h;h="down"===n?[[0,0],[i[1],i[0]]]:[[0,0],[i[0],i[1]]];const f=Fe().extent(h).links(u).nodes(l).nodeAlign(je[o]||le).nodeId(t=>t.id).nodeWidth(a).iterations(c);f.nodePaddingRatio&&f.nodePaddingRatio(s),f();{let t=1/0,e=-1/0,r=1/0,n=-1/0;for(const i of l)t>i.x0&&(t=i.x0),i.x1>e&&(e=i.x1),r>i.y0&&(r=i.y0),i.y1>n&&(n=i.y1);for(const i of u){if(!i.circular||!i.circularPathData)continue;const o=i.circularPathData,a=(i._circularWidth??i.width??0)/2;t>o.leftFullExtent-a&&(t=o.leftFullExtent-a),o.rightFullExtent+a>e&&(e=o.rightFullExtent+a),r>o.verticalFullExtent-a&&(r=o.verticalFullExtent-a),o.verticalFullExtent+a>n&&(n=o.verticalFullExtent+a)}const o=e-t,a=n-r,s=i[0],c=i[1];if(o>0&&a>0&&(0>t||0>r||e>s||n>c)){const e=Math.min(s/o,c/a),i=-t*e+(s-o*e)/2,n=-r*e+(c-a*e)/2;for(const t of l)t.x0=t.x0*e+i,t.x1=t.x1*e+i,t.y0=t.y0*e+n,t.y1=t.y1*e+n;for(const t of u)if(t.y0=t.y0*e+n,t.y1=t.y1*e+n,t.width=(t.width??0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const r=t.circularPathData;r.sourceX=r.sourceX*e+i,r.targetX=r.targetX*e+i,r.sourceY=r.sourceY*e+n,r.targetY=r.targetY*e+n,r.rightFullExtent=r.rightFullExtent*e+i,r.leftFullExtent=r.leftFullExtent*e+i,r.verticalFullExtent=r.verticalFullExtent*e+n,r.rightInnerExtent=r.rightInnerExtent*e+i,r.leftInnerExtent=r.leftInnerExtent*e+i,r.verticalRightInnerExtent=r.verticalRightInnerExtent*e+n,r.verticalLeftInnerExtent=r.verticalLeftInnerExtent*e+n,r.rightSmallArcRadius*=e,r.rightLargeArcRadius*=e,r.leftSmallArcRadius*=e,r.leftLargeArcRadius*=e,r.sourceWidth*=e,r.rightNodeBuffer*=e,r.leftNodeBuffer*=e,r.arcRadius*=e}}}const y=new Map;for(const e of t)y.set(e.id,e);for(const t of l){const e=y.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const g=new Map;for(const t of e)g.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of u){const e=Ve(t.source),r=Ve(t.target),i=g.get(t._edgeKey?t._edgeKey:`${e}\0${r}`);if(i){i.y0=t.y0,i.y1=t.y1,i.sankeyWidth=t.width??0,i.circular=!!t.circular,i.circularPathData=t.circularPathData,i._circularWidth=t._circularWidth,i._circularStub=t._circularStub,i.path=t.path,i.circularLinkType=t.circularLinkType,i.direction=n;const o=y.get(e),a=y.get(r);o&&(i.source=o),a&&(i.target=a)}}},buildScene(t,e,r,n){const o="vertical"===r.orientation?"down":"right",a=r.nodeStyle,s=r.edgeStyle,c=r.edgeOpacity??.5,l=r.edgeColorBy||"source",u=Array.isArray(r.colorScheme)?r.colorScheme:r.themeCategorical&&r.themeCategorical.length>0?r.themeCategorical:x,h=new Map;t.forEach((t,e)=>{h.set(t.id,u[e%u.length])});const f=[],y=[],g=[],p=new Map;for(const e of t){const t=e.x1-e.x0,r=e.y1-e.y0;if(0>=t||0>=r)continue;const n=a?a(i(e,"nodeStyle")):{},s={fill:n.fill||h.get(e.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};p.set(e.id,("string"==typeof s.fill?s.fill:null)||h.get(e.id)||"#4d430c"),f.push("down"===o?{type:"rect",x:e.y0,y:e.x0,w:r,h:t,style:s,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:r,style:s,datum:e,id:e.id,label:e.id})}const d=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of d){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;if(!e||!n)continue;let o=r.themeSemantic?.border||r.themeSemantic?.secondary||"#999";o="function"==typeof l?l(t)||o:"target"===l?p.get(n.id)||h.get(n.id)||o:p.get(e.id)||h.get(e.id)||o;const a=s?s(i(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,r=t.sankeyWidth/2,i=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),n=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),s=a.fill||o;y.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-r}L${e.sourceX+i},${e.sourceY-r}L${e.sourceX+i},${e.sourceY+r}L${e.sourceX},${e.sourceY+r}Z`,style:{fill:s,fillOpacity:a.fillOpacity??c,stroke:"none",opacity:a.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+i}}),y.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-r}L${e.targetX-n},${e.targetY-r}L${e.targetX-n},${e.targetY+r}L${e.targetX},${e.targetY+r}Z`,style:{fill:s,fillOpacity:a.fillOpacity??c,stroke:"none",opacity:a.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-n,x1:e.targetX}});continue}let u;(u=t.circular&&t.circularPathData?Ge(t):Be(t),u)&&y.push({type:"bezier",pathD:u,bezierCache:t.bezier,style:{fill:a.fill||o,fillOpacity:a.fillOpacity??c,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity},datum:t})}if(!1!==r.showLabels){const e=(m=r.nodeLabel)?"function"==typeof m?m:t=>t[m]||t.id:null;for(const r of t){const t=r.x1-r.x0,i=r.y1-r.y0;if(0>=t||0>=i)continue;const a=e?e(r):r.id;if(!a)continue;let s,c,l;"down"===o?(s=r.y0+(r.y1-r.y0)/2,c=r.x1+14,l="start"):(n[0]/2>r.x0+t/2?(s=r.x0-6,l="end"):(s=r.x1+6,l="start"),c=r.y0+i/2),g.push({x:s,y:c,text:a+"",anchor:"down"===o?"middle":l,baseline:"middle",fontSize:11})}}var m;return{sceneNodes:f,sceneEdges:y,labels:g}}};import{chord as Ke,ribbon as qe}from"d3-chord";import{arc as Ze}from"d3-shape";var Ue=x,Qe={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,r,i){if(0===t.length)return;const{padAngle:n=.01,groupWidth:o=20,sortGroups:a}=r,s=Math.min(i[0],i[1])/2,c=s-o,l=i[0]/2,u=i[1]/2,h=(f=r.valueAccessor)?"function"==typeof f?f:t=>t[f]??1:t=>t.value??1;var f;const y=new Map;for(let e=0;t.length>e;e++)y.set(t[e].id,e);const g=t.length,p=Array.from({length:g},()=>Array.from({length:g},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,r=y.get("string"==typeof t.source?t.source:t.source.id),i=y.get(e);if(void 0===r||void 0===i)continue;const n=h(t);p[r][i]=n}const d=Ke().padAngle(n);a&&d.sortGroups(a);const m=d(p),v=m.groups,x=Ze().innerRadius(c).outerRadius(s);for(const e of v){const r=t[e.index],i=x.centroid({innerRadius:c,outerRadius:s,startAngle:e.startAngle,endAngle:e.endAngle});r.x=i[0]+l,r.y=i[1]+u,r.__arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const b=new Map;for(const e of t)b.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,r=b.get("string"==typeof t.source?t.source:t.source.id),i=b.get(e);r&&(t.source=r),i&&(t.target=i)}const k=new Map;for(const t of e)k.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of m){const r=t[e.source.index].id,i=t[e.target.index].id,n=k.get(`${r}\0${i}`)||k.get(`${i}\0${r}`);n&&(n.__chordData=e)}},buildScene(t,e,r,n){const{groupWidth:o=20,edgeOpacity:a=.5}=r,s=Math.min(n[0],n[1])/2,c=s-o,l=n[0]/2,u=n[1]/2,h=r.nodeStyle,f=r.edgeStyle,y=r.edgeColorBy||"source",g=Array.isArray(r.colorScheme)?r.colorScheme:r.themeCategorical&&r.themeCategorical.length>0?r.themeCategorical:Ue,p=new Map;t.forEach((t,e)=>{p.set(t.id,g[e%g.length])});const d=qe().radius(c),m=[],v=[],x=[];for(let e=0;t.length>e;e++){const r=t[e],n=r.__arcData;if(!n)continue;let o;o=h?h(i(r,"nodeStyle")).fill||p.get(r.id)||g[e%g.length]:p.get(r.id)||g[e%g.length];const a=h?h(i(r,"nodeStyle")):{};m.push({type:"arc",cx:l,cy:u,innerR:c,outerR:s,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:{fill:o,stroke:a.stroke||"black",strokeWidth:a.strokeWidth??1,opacity:a.opacity},datum:r,id:r.id,label:r.id})}for(const t of e){const e=t.__chordData;if(!e)continue;const n=d(e);if(!n)continue;const o=Je(n,l,u);let s=r.themeSemantic?.border||r.themeSemantic?.secondary||"#999";if(f)s=f(i(t,"edgeStyle")).fill||s;else{const e="object"==typeof t.source?t.source:null,r="object"==typeof t.target?t.target:null;"target"===y&&r?s=p.get(r.id)||s:e&&(s=p.get(e.id)||s)}const c=f?f(i(t,"edgeStyle")):{};v.push({type:"ribbon",pathD:o,style:{fill:s,fillOpacity:c.fillOpacity??a,stroke:c.stroke||"none",strokeWidth:c.strokeWidth,opacity:c.opacity},datum:t})}if(!1!==r.showLabels){const e=(b=r.nodeLabel)?"function"==typeof b?b:t=>t[b]||t.id:null,i=s+12;for(const r of t){const t=r.__arcData;if(!t)continue;const n=e?e(r):r.id;if(!n)continue;const o=(t.startAngle+t.endAngle)/2,a=o-Math.PI/2;x.push({x:l+Math.cos(a)*i,y:u+Math.sin(a)*i,text:n+"",anchor:o>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var b;return{sceneNodes:m,sceneEdges:v,labels:x}}};function Je(t,e,r){const i=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!i)return t;const n=[];let o=0;for(;i.length>o;){const t=i[o];if("M"===t||"L"===t)for(n.push(t),o++;i.length>o&&!isNaN(Number(i[o]));)n.push(Number(i[o])+e+""),o++,i.length>o&&!isNaN(Number(i[o]))&&(n.push(Number(i[o])+r+""),o++);else if("C"===t)for(n.push(t),o++;i.length>o&&!isNaN(Number(i[o]));)for(let t=0;3>t&&i.length>o&&!isNaN(Number(i[o]));t++)n.push(Number(i[o])+e+""),o++,i.length>o&&!isNaN(Number(i[o]))&&(n.push(Number(i[o])+r+""),o++);else if("Q"===t)for(n.push(t),o++;i.length>o&&!isNaN(Number(i[o]));)for(let t=0;2>t&&i.length>o&&!isNaN(Number(i[o]));t++)n.push(Number(i[o])+e+""),o++,i.length>o&&!isNaN(Number(i[o]))&&(n.push(Number(i[o])+r+""),o++);else if("A"===t)for(n.push(t),o++;i.length>o&&!isNaN(Number(i[o]));)n.push(i[o++]),i.length>o&&n.push(i[o++]),i.length>o&&n.push(i[o++]),i.length>o&&n.push(i[o++]),i.length>o&&n.push(i[o++]),i.length>o&&(n.push(Number(i[o])+e+""),o++),i.length>o&&(n.push(Number(i[o])+r+""),o++);else"Z"===t||"z"===t?(n.push(t),o++):(n.push(i[o]),o++)}return n.join(" ")}import{hierarchy as tr,tree as er,cluster as rr,treemap as ir,pack as nr,partition as or,treemapBinary as ar}from"d3-hierarchy";var sr=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function cr(t){const[e,r,i]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*r+.114*i>150?"#222":"#fff"}function lr(t,e,r){const i=e.nodeIDAccessor;return"function"==typeof i?i(t.data)+"":"string"==typeof i&&void 0!==t.data[i]?t.data[i]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+r}function ur(t){if(!t)return null;if("function"==typeof t){const e=t;return t=>e(t.data??t)}return e=>e.data?.[t]||e[t]||e.id}function hr(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:sr}function fr(t){return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:t.themeSemantic?.primary?t.themeSemantic.primary:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical[0]:"#4d430c"}function yr(t,e,r,i,n){if("horizontal"===n){const n=(t+r)/2;return`M ${t},${e} C ${n},${e} ${n},${i} ${r},${i}`}if("radial"===n){const n=(t+r)/2;return`M ${t},${e} Q ${n},${e} ${n},${(e+i)/2} T ${r},${i}`}{const n=(e+i)/2;return`M ${t},${e} C ${t},${n} ${r},${n} ${r},${i}`}}var gr={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,r,i){const n=r.__hierarchyRoot;if(!n)return;const o=r.chartType,a=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(r.childrenAccessor),s=r.hierarchySum,c="function"==typeof s?s:"string"==typeof s?t=>Number(t[s])||0:t=>Number(t.value)||0,l=tr(n,a);l.sum(c),l.sort((t,e)=>(e.value??0)-(t.value??0));const[u,h]=i;switch(o){case"tree":!function(t,e,r,i){const n=e.treeOrientation||"vertical",o=er();o.size("horizontal"===n?[i,r]:"radial"===n?[2*Math.PI,Math.min(r,i)/2*.8]:[r,i]),o(t)}(l,r,u,h);break;case"cluster":!function(t,e,r,i){const n=e.treeOrientation||"vertical",o=rr();o.size("horizontal"===n?[i,r]:"radial"===n?[2*Math.PI,Math.min(r,i)/2*.8]:[r,i]),o(t)}(l,r,u,h);break;case"treemap":!function(t,e,r,i){const n=e.padding??4,o=e.paddingTop??0,a=ir().size([r,i]).tile(ar).padding(n);o>0&&a.paddingTop(o),a(t)}(l,r,u,h);break;case"circlepack":!function(t,e,r,i){const n=e.padding??4;nr().size([r,i]).padding(n)(t)}(l,r,u,h);break;case"partition":!function(t,e,r,i){or().size([r,i]).padding(e.padding??1)(t)}(l,r,u,h)}const f=l.descendants();t.length=0,e.length=0;const y=new Map;for(let e=0;f.length>e;e++){const i=f[e],n={id:lr(i,r,e),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:i.value??0,depth:i.depth,data:i.data,createdByFrame:!0};"tree"===o||"cluster"===o?pr(n,i,r):"treemap"===o||"partition"===o?dr(n,i):"circlepack"===o&&mr(n,i),n.__hierarchyNode=i,t.push(n),y.set(i,n)}if("tree"===o||"cluster"===o)for(const t of f)if(t.parent){const r=y.get(t.parent),i=y.get(t);r&&i&&e.push({source:r,target:i,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,r,n){const o=r.nodeStyle||(()=>({})),a=r.edgeStyle||(()=>({}));switch(r.chartType){case"tree":case"cluster":return function(t,e,r,n,o,a){const s=[],c=[],l=[],u=r.treeOrientation||"vertical",h="radial"===u,f=n[0]/2,y=n[1]/2,g="number"==typeof(p=r.nodeSize)?p:5;var p;for(const e of t){let t=e.x,n=e.y;h&&(t+=f,n+=y);const a=o(i(e,"nodeStyle"));let c=a.fill||fr(r);if(r.colorByDepth&&void 0!==e.depth){const t=hr(r);c=t[e.depth%t.length]}s.push({type:"circle",cx:t,cy:n,r:g,style:{fill:c,stroke:a.stroke||r.themeSemantic?.surface||"#fff",strokeWidth:a.strokeWidth??1,opacity:a.opacity},datum:e,id:e.id,label:e.id,depth:e.depth})}const d=r.edgeOpacity??.5;for(const t of e){const e="object"==typeof t.source?t.source:null,n="object"==typeof t.target?t.target:null;if(!e||!n)continue;let o=e.x,s=e.y,l=n.x,g=n.y;h&&(o+=f,s+=y,l+=f,g+=y);const p=yr(o,s,l,g,u),m=a(i(t,"edgeStyle"));c.push({type:"curved",pathD:p,style:{fill:"none",stroke:m.stroke||r.themeSemantic?.border||r.themeSemantic?.secondary||"#999",strokeWidth:m.strokeWidth??1.5,opacity:m.opacity??d},datum:t})}if(!1!==r.showLabels){const e=ur(r.nodeLabel);for(const r of t){const t=e?e(r):r.id;if(!t)continue;let i,n,o,a=r.x,s=r.y;if(h&&(a+=f,s+=y),h){const t=a-f,e=s-y,r=Math.sqrt(t*t+e*e);r>0?(i=a+t/r*10,n=s+e/r*10,o=0>t?"end":"start"):(i=a,n=s-12,o="middle")}else"horizontal"===u?(r.data?.children&&0!==r.data.children.length?(i=a-g-6,o="end"):(i=a+g+6,o="start"),n=s):(i=a,n=s+g+14,o="middle");l.push({x:i,y:n,text:t+"",anchor:o,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:c,labels:l}}(t,e,r,n,o,a);case"treemap":case"partition":return function(t,e,r,n){const o=[],a=[];for(const r of t){const t=r.x1-r.x0,a=r.y1-r.y0;if(0>=t||0>=a)continue;const s=n(i(r,"nodeStyle"));let c=s.fill||fr(e);if(e.colorByDepth&&void 0!==r.depth){const t=hr(e);c=t[r.depth%t.length]}o.push({type:"rect",x:r.x0,y:r.y0,w:t,h:a,style:{fill:c,stroke:s.stroke||e.themeSemantic?.surface||"#fff",strokeWidth:s.strokeWidth??1,opacity:s.opacity},datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==e.showLabels){const r=ur(e.nodeLabel),o=e.labelMode||"leaf",s="partition"===e.chartType;for(const c of t){const t=c.x1-c.x0,l=c.y1-c.y0;if(0>=t||0>=l)continue;const u=!(c.data?.children&&c.data.children.length>0);if(!s){if("leaf"===o&&!u)continue;if("parent"===o&&u)continue}const h=r?r(c):c.id;if(!h)continue;if((u?30:40)>t||(u?16:14)>l)continue;let f=n(i(c,"nodeStyle")).fill||fr(e);if(e.colorByDepth&&void 0!==c.depth){const t=hr(e);f=t[c.depth%t.length]}const y="string"==typeof f?cr(f):e.themeSemantic?.text??"#000";a.push(u?{x:c.x0+t/2,y:c.y0+l/2,text:h+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,l)/6)),fill:y}:{x:c.x0+4,y:c.y0+12,text:h+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:y})}}return{sceneNodes:o,sceneEdges:[],labels:a}}(t,r,0,o);case"circlepack":return function(t,e,r,n){const o=[],a=[];for(const r of t){const t=r.__radius??5;if(0>=t)continue;const a=n(i(r,"nodeStyle"));let s=a.fill||fr(e);if(e.colorByDepth&&void 0!==r.depth){const t=hr(e);s=t[r.depth%t.length]}o.push({type:"circle",cx:r.x,cy:r.y,r:t,style:{fill:s,stroke:a.stroke||e.themeSemantic?.surface||"#fff",strokeWidth:a.strokeWidth??1,opacity:a.opacity??.7},datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==e.showLabels){const r=ur(e.nodeLabel);for(const o of t){const t=o.__radius??5,s=r?r(o):o.id;if(!s)continue;if(15>t)continue;const c=!(o.data?.children&&o.data.children.length>0);let l=n(i(o,"nodeStyle")).fill||fr(e);if(e.colorByDepth&&void 0!==o.depth){const t=hr(e);l=t[o.depth%t.length]}if(c){const r="string"==typeof l?cr(l):e.themeSemantic?.text??"#000";a.push({x:o.x,y:o.y,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:r})}else a.push({x:o.x,y:o.y-t+14,text:s+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:e.themeSemantic?.text||"#000",stroke:e.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:o,sceneEdges:[],labels:a}}(t,r,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function pr(t,e,r){const i=r.treeOrientation||"vertical";if("radial"===i){const r=e.x,i=e.y;t.x=i*Math.cos(r-Math.PI/2),t.y=i*Math.sin(r-Math.PI/2)}else"horizontal"===i?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function dr(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function mr(t,e){const r=e.r??0;t.x=e.x,t.y=e.y,t.x0=e.x-r,t.x1=e.x+r,t.y0=e.y-r,t.y1=e.y+r,t.width=2*r,t.height=2*r,t.__radius=r}import{pie as vr}from"d3-shape";function xr(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}var br={sankey:He,force:r,chord:Qe,tree:gr,cluster:gr,treemap:gr,circlepack:gr,partition:gr,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,r,i){const n=r.__hierarchyRoot;n&&function(t,e,r,i,n){const o=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(r.childrenAccessor),a=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>(t[e]??"")+""}(r.nodeIDAccessor),s=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(r.orbitMode),c=r.orbitSize??2.95,l=r.orbitEccentricity??1,u="number"==typeof c?()=>c:c,h="number"==typeof l?()=>l:l,f=xr(r);f.metaMap.clear(),i.length=0,n.length=0;const y=new Map;function g(t){const e=y.get(t)??0;return y.set(t,e+1),0===e?t:`${t}__${e}`}const p=e[0]/2,d=e[1]/2,m=Math.min(e[0],e[1])/2*.85,v=g(a(t));i.push({id:v,x:p,y:d,x0:p,x1:p,y0:d,y1:d,width:0,height:0,value:0,depth:0,data:t}),f.metaMap.set(v,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,r,c,l,y,p,d){const m=o(e);if(!m?.length)return;const v=m.length;let x=0,b=0,k=0;for(;v>b;)b+=s[Math.min(k,s.length-1)],k++,x++;let w=0;for(let v=0;x>v;v++){const b=s[Math.min(v,s.length-1)],k=m.slice(w,w+b);if(!k.length)break;const _=(v+1)/x,A={id:r,depth:p,data:e,parentId:r},P=d?y/u(A)*_:y*_,L=vr().value(t=>{const e=o(t)?.length;return e?4:1}).sort(null)(k),S=h(A);for(let e=0;k.length>e;e++){const o=(L[e].startAngle+L[e].endAngle)/2,s=k[e],u=g(a(s)),h=c+P*Math.sin(o),y=l+P*Math.cos(o)*S;i.push({id:u,x:h,y:y,x0:h,x1:h,y0:y,y1:y,width:0,height:0,value:0,depth:p,data:s}),f.metaMap.set(u,{ring:P,angle:o,depth:p,parentId:r,eccentricity:S}),n.push({source:r,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:r,target:u}}),t(s,u,h,y,P,p+1,!0)}w+=b}}(t,v,p,d,m,1,!1)}(n,i,r,t,e)},buildScene(t,e,r,n){const o=r.nodeStyle,a=r.nodeSize,s="number"==typeof a?()=>a:"function"==typeof a?a:()=>6,c=[],l=[],u=[];if(!1!==r.orbitShowRings){const e=xr(r),i=new Map;for(const e of t)i.set(e.id,e);const n=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=i.get(t.parentId);if(!e)continue;const r=`${t.parentId}:${t.ring}`;n.has(r)||n.set(r,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const o=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:r,ecc:i}]of n)for(let n=0;o>n;n++){const s=n/o*Math.PI*2,c=(n+1)/o*Math.PI*2;l.push({type:"line",x1:t+r*Math.sin(s),y1:e+r*Math.cos(s)*i,x2:t+r*Math.sin(c),y2:e+r*Math.cos(c)*i,style:a,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=s(i(e,"nodeSize")),n=o?o(i(e,"nodeStyle")):{};c.push({type:"circle",cx:e.x,cy:e.y,r:t,style:{fill:n.fill||r.themeSemantic?.primary||"#6366f1",stroke:n.stroke||r.themeSemantic?.surface||"#fff",strokeWidth:n.strokeWidth??1,opacity:n.opacity??(0===(e.depth??0)?1:.85)},datum:e,id:e.id,label:e.id,depth:e.depth})}const h=new Map;for(const e of t)h.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:h.get(t.source),r="object"==typeof t.target?t.target:h.get(t.target);e&&r&&(null!=e.x&&null!=r.x&&l.push({type:"line",x1:e.x,y1:e.y,x2:r.x,y2:r.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(r.showLabels){const e=r.nodeLabel;for(const r of t){const t=s(i(r,"nodeSize"));if(4>=t)continue;const n="function"==typeof e?e(r):e?r.data?.[e]??r.id:r.id;u.push({x:r.x,y:r.y+t+12,text:n+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:c,sceneEdges:l,labels:u}},tick:(t,e,r,i,n)=>!1!==r.orbitAnimated&&(function(t,e){const r=xr(e),i=e.orbitSpeed??.25,n=e.orbitRevolution??function(t){switch(t){case"decay":return t=>Math.pow(.6,t.depth??0);case"alternate":return t=>{const e=t.depth??0;return(e%2==0?1:-1)/(e+1)};default:return t=>1/((t.depth??0)+1)}}(e.orbitRevolutionStyle),o=(("undefined"!=typeof performance?performance.now():Date.now())-r.startTime)/1e3,a=i*(Math.PI/6),s=new Map;for(const e of t)s.set(e.id,e);for(const e of t){const t=r.metaMap.get(e.id);if(!t||!t.parentId)continue;const i=s.get(t.parentId);if(!i)continue;const c=t.angle+o*a*n({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=i.x+t.ring*Math.sin(c),e.y=i.y+t.ring*Math.cos(c)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,r),!0)}};function kr(t){return br[t]}export{E as toIdSet,b as resolveMotionAccessor,k as compileMotionEncoding,w as opacityFromAge,_ as resolveMotionVector,A as deriveMotionVector,Y as computeDecayOpacity,N as buildDatumIndexMap,R as computePulseIntensity,T as setPulseState,$ as hasActivePulses,B as buildRectNode,D as enrichDatumWithBand,U as warnCustomLayoutDiagnostics,tt as createCustomLayoutFailureDiagnostic,lt as ensureRingBufferCapacity,ut as createTimestampBufferForData,ht as pushWithTimestamp,ft as compactTimestampBufferForRemoval,bt as attachUpdateResultStore,Ot as PipelineStore,Vt as ticksForMode,Wt as paintSceneWithBackend,Xt as renderSceneWithBackend,Bt as renderSceneListWithBackend,Xe as buildRibbonGeometry,kr as getLayoutPlugin,jt as resolveDownwardHistogramExtent};
@@ -1,2 +0,0 @@
1
- "use client";
2
- import{STREAMING_PALETTE as e,createColorScale as t,filterSparseArray as o,getCrosshairProps as r,resolveMobileInteraction as n,useCategoryColors as a,useChartLegendAndMargin as i,useChartMode as l,useChartSelection as c,useColorScale as u,useLegendInteraction as s,useThemeCategorical as d}from"./chunk-chunk-6HSGDMTA.module.min.js";import{useThemeSelector as g}from"./chunk-chunk-WCX6U47H.module.min.js";import{renderEmptyState as m,renderLoadingState as h}from"./chunk-chunk-ZCNBUZPL.module.min.js";import{useMemo as y}from"react";function p(e){const t=g(e=>e.theme.colors.selectionOpacity);return y(()=>{if(void 0!==e||void 0!==t)return{name:e?.name??"",...e,unselectedOpacity:e?.unselectedOpacity??t}},[e,t])}import{useCallback as f,useMemo as v,useState as b}from"react";function L(l){const{data:g,rawData:y,colorBy:L,colorScheme:k,legendInteraction:C,legendPosition:S,selection:H,linkedHover:w,fallbackFields:B,unwrapData:D=!1,onObservation:M,chartType:I,chartId:F,showLegend:A,legend:P,userMargin:R,marginDefaults:T,onClick:O,hoverHighlight:W,mobileInteraction:x,mobileSemantics:j,loading:G,loadingContent:N,emptyContent:z,width:U,height:Z}=l,_=void 0===y,V=v(()=>o(g),[g]),[X,q]=b([]),E=f(e=>{q(t=>t.length===e.length&&t.every((t,o)=>t===e[o])?t:e)},[]),J="string"==typeof l.colorBy?l.colorBy:void 0,K=v(()=>n(x,{width:U,mobileSemantics:j}),[x,U,j]),{activeSelectionHook:Q,hoverSelectionHook:Y,customHoverBehavior:$,customClickBehavior:ee,crosshairSourceId:te}=c({selection:H,linkedHover:w,fallbackFields:B,unwrapData:D,onObservation:M,chartType:I,chartId:F,onClick:O,hoverHighlight:W,colorByField:J,mobileInteraction:K}),oe=r(w,te),re=u(V,L,k),ne=v(()=>{if(!L)return[];const e=new Set;for(const t of V){const o="function"==typeof L?L(t):t[L];null!=o&&e.add(o+"")}return Array.from(e)},[V,L]),ae=v(()=>_&&X.length>0?X:ne,[_,X,ne]),ie=s(C,L,ae),le=v(()=>Y||(ie.legendSelectionHook?ie.legendSelectionHook:Q),[Y,ie.legendSelectionHook,Q]),ce=p(H),ue=d(),se=a(),de=v(()=>{if(re)return re;if(!L||0===ae.length)return;const o=Array.isArray(k)&&k.length>0||"string"==typeof k&&k.length>0?k:ue&&ue.length>0?ue:e,r="__streamCat",n=ae.map(e=>({[r]:e})),a=t(n,r,o);return e=>se?.[e]||a(e)||"#999"},[re,L,ae,k,ue,se]),{legend:ge,margin:me,legendPosition:he}=i({data:V,colorBy:L,colorScale:de,showLegend:A,legendPosition:S,userMargin:R,defaults:T,categories:ae,additionalLegend:P}),ye=v(()=>{const e={};return ge&&(e.legend=ge,e.legendPosition=he),C&&"none"!==C&&(e.legendHoverBehavior=ie.onLegendHover,e.legendClickBehavior=ie.onLegendClick,e.legendHighlightedCategory=ie.highlightedCategory,e.legendIsolatedCategories=ie.isolatedCategories),_&&L&&(e.legendCategoryAccessor=L,e.onCategoriesChange=E),e},[ge,he,C,ie.onLegendHover,ie.onLegendClick,ie.highlightedCategory,ie.isolatedCategories,_,L,E]),pe=Array.isArray(y)?o(y):y,fe=h(G,U,Z,N),ve=fe?null:m(pe,U,Z,z);return{data:V,colorScale:re,allCategories:ae,legendState:ie,effectiveSelectionHook:le,activeSelectionHook:Q,customHoverBehavior:$,customClickBehavior:ee,mobileInteraction:K,legend:ge,margin:me,legendPosition:he,earlyReturn:fe||ve||null,legendBehaviorProps:ye,crosshairProps:oe,resolvedSelection:ce}}import{useImperativeHandle as k}from"react";function C(e,t){const{variant:o,frameRef:r,overrides:n}=t;k(e,()=>{const e=function(e,t){if("xy"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>e.current?.remove(t)??[],update:(t,o)=>e.current?.update(t,o)??[],clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getScales:()=>e.current?.getScales()??null,getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}if("network"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>{const o=Array.isArray(t)?t:[t],r=e.current?.getTopology()?.nodes??[],n=[];for(const t of o){const o=r.find(e=>e.id===t);o&&n.push({...o.data??{},id:t}),e.current?.removeNode(t)}return n},update:(t,o)=>(Array.isArray(t)?t:[t]).flatMap(t=>{const r=e.current?.updateNode(t,o);return r?[{...r,id:t}]:[]}),clear:()=>e.current?.clear(),getData:()=>e.current?.getTopology()?.nodes?.map(e=>e.data)??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}if("geo-points"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>e.current?.removePoint(t)??[],update:(t,o)=>{const r=e.current?.removePoint(t)??[];for(const t of r)e.current?.push(o(t));return r},clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}const o=t;return{push:e=>o.current?.pushLine(e),pushMany:e=>o.current?.pushManyLines(e),remove:e=>o.current?.removeLine(e)??[],update:(e,t)=>{const r=o.current?.removeLine(e)??[];for(const e of r)o.current?.pushLine(t(e));return r},clear:()=>o.current?.clear(),getData:()=>o.current?.getLines()??[],getCustomLayout:()=>o.current?.getCustomLayout?.()??null,getLayoutFailure:()=>o.current?.getLayoutFailure?.()??null}}(o,r);return{...e,...n}},[r,n,o])}function S(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})}function H(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}import{useMemo as w,useRef as B}from"react";function D(e){const t=B(null);return C(e.imperativeRef,{variant:e.imperativeVariant,frameRef:t}),{frameRef:t,resolved:l(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),normalizedMargin:w(()=>H(e.margin),[e.margin])}}function M(e){const t=D(e),{resolved:o,normalizedMargin:r}=t,n=L({data:e.data??[],rawData:e.data,colorBy:e.colorBy,colorScheme:e.colorScheme,legendInteraction:void 0,selection:e.selection,linkedHover:e.linkedHover,fallbackFields:"string"==typeof e.colorBy?[e.colorBy]:[],unwrapData:e.unwrapData,onObservation:e.onObservation,onClick:e.onClick,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,chartType:e.chartTypeLabel,chartId:e.chartId,showLegend:o.showLegend,legend:e.legend,userMargin:r,marginDefaults:o.marginDefaults,loading:e.loading,loadingContent:e.loadingContent,emptyContent:e.emptyContent,width:o.width,height:o.height});return{...t,safeData:n.data,setup:n,earlyReturn:n.earlyReturn}}export{p as useResolvedSelection,L as useChartSetup,C as useFrameImperativeHandle,S as mergeShapeStyle,H as normalizePartialMargin,D as useCustomChartScaffold,M as useCustomChartSetup};
@@ -1 +0,0 @@
1
- function t(t){if(null==t)return()=>{};const n="function"==typeof t?t:n=>n[t];return t=>e(n(t))}function n(n,i){const e=t(n),o=t(i);return(t,n)=>{const i=o(t);return{value:i,x:e(t),y:i,category:n}}}function i(n,i){const e=t(i??"value"),o=null==n?void 0:"function"==typeof n?n:t=>t[n];return t=>{const n=o?o(t):void 0;return{value:e(t),category:null==n?void 0:n+""}}}function e(t){if("number"==typeof t)return Number.isFinite(t)?t:void 0;if("string"==typeof t&&""!==t.trim()){const n=Number(t);return Number.isFinite(n)?n:void 0}}function o(t,n,i){const o=null!=t.axis?i[t.axis]:null!=t.field?n[t.field]:i.value;if(void 0!==t.eq&&o!==t.eq)return!1;if(void 0!==t.ne&&o===t.ne)return!1;if(void 0!==t.in&&!t.in.includes(o))return!1;if(void 0===t.gt&&void 0===t.gte&&void 0===t.lt&&void 0===t.lte&&void 0===t.within&&void 0===t.outside)return!0;const r=e(o);if(void 0===r)return!1;if(void 0!==t.gt&&t.gt>=r)return!1;if(void 0!==t.gte&&t.gte>r)return!1;if(void 0!==t.lt&&r>=t.lt)return!1;if(void 0!==t.lte&&r>t.lte)return!1;if(void 0!==t.within){const[n,i]=t.within;if(n>r||r>i)return!1}if(void 0!==t.outside){const[n,i]=t.outside;if(r>=n&&i>=r)return!1}return!0}function r(t,n,i){const e=t.when;return void 0===e||!0===e||!1!==e&&("function"==typeof e?e(n,i):o(e,n,i))}function u(t,n,i){if(!n||0===n.length)return{};let e={};for(const o of n){if(!r(o,t,i))continue;const n="function"==typeof o.style?o.style(t,i):o.style;n&&(e={...e,...n})}return e}function f(t,n,i,e=t=>t){const o=t??(()=>({}));return n&&0!==n.length?(t,r)=>{const f=e(t),c={...o(t,r)};return Object.assign(c,u(f,n,i(f,r))),c}:o}function c(t,n,i){return t&&0!==t.length?(e,o)=>{const r=u(e,t,n(e,o)),f=i?i(e,o):void 0;return f?{...r,...f}:r}:i}function s(t,n,e,o){if(!t||0===t.length)return o;const r=i(n,e);return(n,i)=>{const e=n&&n.data||n,f=u(e,t,r(e)),c=o?o(n,i):void 0;return c?{...f,...c}:f}}function d(t,i,e,o){return c(t,n(i,e),o)}export{t as makeRuleValueResolver,n as makeXYRuleContext,i as makeNodeRuleContext,o as matchesThreshold,r as ruleMatches,u as resolveStyleRules,f as composeStyleRules,c as makeStyleRuleStyleFn,s as styleRulesToNodeStyle,d as styleRulesToXYStyle};
@@ -1 +0,0 @@
1
- function t(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}function e(e,n,r=e.responsiveRules){if(!Array.isArray(r)||0===r.length)return{props:e,matches:[]};const i=r.map((t,e)=>({rule:t,index:e})).filter(t=>function(t,e){const{when:n}=t,r=e.width,i=e.height,o=function(t){if("number"==typeof t.height&&t.height>0)return t.width/t.height}(e),a=function(t){if("number"==typeof t.height&&t.height>0)return t.height>t.width?"portrait":"landscape"}(e);return!("number"==typeof n.minWidth&&n.minWidth>r||"number"==typeof n.maxWidth&&r>n.maxWidth||"number"==typeof n.minHeight&&("number"!=typeof i||n.minHeight>i)||"number"==typeof n.maxHeight&&("number"!=typeof i||i>n.maxHeight)||"number"==typeof n.minAspectRatio&&("number"!=typeof o||n.minAspectRatio>o)||"number"==typeof n.maxAspectRatio&&("number"!=typeof o||o>n.maxAspectRatio)||n.orientation&&a!==n.orientation)}(t.rule,n)).sort((t,e)=>("number"==typeof t.rule.priority?t.rule.priority:t.index)-("number"==typeof e.rule.priority?e.rule.priority:e.index));return{props:i.reduce((e,n)=>function(e,n){const r={...e,...n};for(const i of["margin","frameProps","mobileSemantics","style"])t(e[i])&&t(n[i])&&(r[i]={...e[i],...n[i]});return"string"==typeof e.className&&"string"==typeof n.className&&(r.className=`${e.className} ${n.className}`),r}(e,n.rule.transform),e),matches:i}}function n(t,e){return t===e}function r(t,e){if("function"==typeof t)return e=>+t(e);const n=t||e;return t=>+t[n]}function i(t,e){if("function"==typeof t)return t;const n=t||e;return t=>t[n]}function o(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}var a=new Set(["label","callout","callout-circle","callout-rect","text","widget"]),u=new Set(["label","callout","callout-circle","callout-rect"]);function s(t){return"string"==typeof t?.type?t.type:""}function c(t){return!!t&&"object"==typeof t&&a.has(s(t))}function f(t){return u.has(s(t))&&!function(t){return Array.isArray(t?.disable)&&t.disable.includes("connector")}(t)}function m(t){let e=t>>>0;return function(){e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function l(t){return"primary"===t?.emphasis||!0===t?.defensive}function h(t,e,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):t>0&&e>0?Math.max(1,Math.round(t*e/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:2e4))):1/0}function p(t){let e;const n=t?.emphasis;e="primary"===n?100:"secondary"===n?10:50;const r=t?.provenance?.confidence;switch("number"==typeof r&&Number.isFinite(r)&&(e+=15*Math.max(0,Math.min(1,r))),t?.lifecycle?.freshness){case"fresh":e+=8;break;case"aging":e+=4;break;case"stale":e+=1;break;case"expired":e-=200}return e}function y(t){const{annotations:e,width:n,height:r}=t,i=Math.max(0,t.minVisible??1),o=h(n,r,t),a=e.map((t,e)=>{return{annotation:t,index:e,note:(n=t,c(n))};var n}),u=a.filter(t=>t.note);if(0===u.length||o>=u.length)return{visible:e.slice(),deferred:[],budget:o};const s=u.filter(t=>l(t.annotation)),f=u.filter(t=>!l(t.annotation)).sort((t,e)=>p(e.annotation)-p(t.annotation)||t.index-e.index),m=Math.min(f.length,Math.max(Math.max(0,o-s.length),Math.max(0,i-s.length))),y=new Set([...s.map(t=>t.index),...f.slice(0,m).map(t=>t.index)]),d=[],b=[];for(const{annotation:t,index:e,note:n}of a)!n||y.has(e)?d.push(t):b.push(t);return{visible:d,deferred:b,budget:o}}export{e as resolveResponsiveRules,m as mulberry32,n as accessorsEquivalent,r as resolveAccessor,i as resolveRawAccessor,o as resolveStringAccessor,s as annotationType,c as isNoteAnnotation,f as annotationDrawsConnector,h as annotationBudget,y as annotationDensity};