@d3plus/core 4.1.0 → 4.3.0

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 (85) hide show
  1. package/README.md +781 -688
  2. package/es/src/charts/AreaPlot/index.js +2 -1
  3. package/es/src/charts/AreaPlot/index.js.map +1 -1
  4. package/es/src/charts/BarChart/index.js +3 -1
  5. package/es/src/charts/BarChart/index.js.map +1 -1
  6. package/es/src/charts/BoxWhisker/index.js +2 -1
  7. package/es/src/charts/BoxWhisker/index.js.map +1 -1
  8. package/es/src/charts/BumpChart/index.js +2 -1
  9. package/es/src/charts/BumpChart/index.js.map +1 -1
  10. package/es/src/charts/Geomap/emit.js +44 -4
  11. package/es/src/charts/Geomap/emit.js.map +1 -1
  12. package/es/src/charts/Geomap/index.js +32 -2
  13. package/es/src/charts/Geomap/index.js.map +1 -1
  14. package/es/src/charts/LinePlot/index.js +2 -1
  15. package/es/src/charts/LinePlot/index.js.map +1 -1
  16. package/es/src/charts/Matrix/index.js +1 -0
  17. package/es/src/charts/Matrix/index.js.map +1 -1
  18. package/es/src/charts/Network/index.js +2 -1
  19. package/es/src/charts/Network/index.js.map +1 -1
  20. package/es/src/charts/Pack/index.js +1 -0
  21. package/es/src/charts/Pack/index.js.map +1 -1
  22. package/es/src/charts/Pie/index.js +1 -0
  23. package/es/src/charts/Pie/index.js.map +1 -1
  24. package/es/src/charts/Plot/index.js +99 -14
  25. package/es/src/charts/Plot/index.js.map +1 -1
  26. package/es/src/charts/Plot/pipeline.js +24 -3
  27. package/es/src/charts/Plot/pipeline.js.map +1 -1
  28. package/es/src/charts/Plot/pipelineDomains.js +3 -3
  29. package/es/src/charts/Plot/pipelineDomains.js.map +1 -1
  30. package/es/src/charts/Plot/stackHelpers.js +128 -9
  31. package/es/src/charts/Plot/stackHelpers.js.map +1 -1
  32. package/es/src/charts/Radar/index.js +2 -1
  33. package/es/src/charts/Radar/index.js.map +1 -1
  34. package/es/src/charts/RadialMatrix/index.js +1 -0
  35. package/es/src/charts/RadialMatrix/index.js.map +1 -1
  36. package/es/src/charts/Rings/index.js +2 -1
  37. package/es/src/charts/Rings/index.js.map +1 -1
  38. package/es/src/charts/Sankey/index.js +2 -1
  39. package/es/src/charts/Sankey/index.js.map +1 -1
  40. package/es/src/charts/Tree/index.js +2 -1
  41. package/es/src/charts/Tree/index.js.map +1 -1
  42. package/es/src/charts/Treemap/index.js +1 -0
  43. package/es/src/charts/Treemap/index.js.map +1 -1
  44. package/es/src/charts/features/shapeEmit.js +3 -1
  45. package/es/src/charts/features/shapeEmit.js.map +1 -1
  46. package/es/src/charts/viz/Viz.js +63 -10
  47. package/es/src/charts/viz/Viz.js.map +1 -1
  48. package/es/src/charts/viz/interactionOpacity.js +4 -1
  49. package/es/src/charts/viz/interactionOpacity.js.map +1 -1
  50. package/es/src/charts/viz/vizDefaults.js +4 -1
  51. package/es/src/charts/viz/vizDefaults.js.map +1 -1
  52. package/es/src/charts/viz/vizRender.js +7 -3
  53. package/es/src/charts/viz/vizRender.js.map +1 -1
  54. package/es/src/charts/viz/vizTypes.js.map +1 -1
  55. package/es/src/shapes/Image.js +2 -3
  56. package/es/src/shapes/Image.js.map +1 -1
  57. package/es/src/shapes/Shape.js +47 -46
  58. package/es/src/shapes/Shape.js.map +1 -1
  59. package/es/src/shapes/hitAreaNode.js +31 -5
  60. package/es/src/shapes/hitAreaNode.js.map +1 -1
  61. package/es/src/shapes/interactionPoints.js +30 -0
  62. package/es/src/shapes/interactionPoints.js.map +1 -0
  63. package/es/src/shapes/sceneSort.js +304 -24
  64. package/es/src/shapes/sceneSort.js.map +1 -1
  65. package/es/src/shapes/shapeConfig.js.map +1 -1
  66. package/es/src/utils/D3plusConfig.js.map +1 -1
  67. package/package.json +9 -9
  68. package/types/src/charts/Plot/index.d.ts +44 -7
  69. package/types/src/charts/Plot/pipeline.d.ts +2 -1
  70. package/types/src/charts/Plot/stackHelpers.d.ts +62 -4
  71. package/types/src/charts/viz/Viz.d.ts +31 -1
  72. package/types/src/charts/viz/vizTypes.d.ts +18 -0
  73. package/types/src/shapes/Image.d.ts +2 -3
  74. package/types/src/shapes/Shape.d.ts +2 -4
  75. package/types/src/shapes/hitAreaNode.d.ts +5 -4
  76. package/types/src/shapes/interactionPoints.d.ts +15 -0
  77. package/types/src/shapes/sceneSort.d.ts +83 -8
  78. package/types/src/shapes/shapeConfig.d.ts +7 -0
  79. package/types/src/utils/D3plusConfig.d.ts +19 -2
  80. package/umd/d3plus-core.full.js +2371 -672
  81. package/umd/d3plus-core.full.js.map +1 -1
  82. package/umd/d3plus-core.full.min.js +1506 -1156
  83. package/umd/d3plus-core.js +804 -259
  84. package/umd/d3plus-core.js.map +1 -1
  85. package/umd/d3plus-core.min.js +591 -390
@@ -1,10 +1,10 @@
1
1
  /*
2
- @d3plus/core v4.1.0
2
+ @d3plus/core v4.3.0
3
3
  Data visualization made easy. A javascript library that extends the popular D3.js to enable fast and beautiful visualizations.
4
4
  Copyright (c) 2026 D3plus - https://d3plus.org
5
5
  @license MIT
6
6
  */
7
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-array"),require("d3-selection"),require("@d3plus/data"),require("@d3plus/dom"),require("@d3plus/locales"),require("@d3plus/render"),require("@d3plus/text"),require("d3-color"),require("d3-brush"),require("d3-scale"),require("d3-zoom"),require("@d3plus/color"),require("@d3plus/format"),require("open-color/open-color.js"),require("d3-transition"),require("d3-shape"),require("@d3plus/math"),require("@floating-ui/dom"),require("d3-interpolate"),require("d3-time-format"),require("d3-tile"),require("d3-geo"),require("d3-geo-projection"),require("d3-composite-projections"),require("topojson-client"),require("d3-force"),require("d3-polygon"),require("d3-hierarchy"),require("d3-sankey")):"function"==typeof define&&define.amd?define("@d3plus/core",["exports","d3-array","d3-selection","@d3plus/data","@d3plus/dom","@d3plus/locales","@d3plus/render","@d3plus/text","d3-color","d3-brush","d3-scale","d3-zoom","@d3plus/color","@d3plus/format","open-color/open-color.js","d3-transition","d3-shape","@d3plus/math","@floating-ui/dom","d3-interpolate","d3-time-format","d3-tile","d3-geo","d3-geo-projection","d3-composite-projections","topojson-client","d3-force","d3-polygon","d3-hierarchy","d3-sankey"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).d3plus={},e.d3Array,e.d3Selection,e.data,e.dom,e.locales,e.render,e.text,e.d3Color,e.d3Brush,e.scales,e.d3Zoom,e.color,e.format,e.pkg,e.d3Transition,e.d3Shape,e.math,e.dom$1,e.d3Interpolate,e.d3TimeFormat,e.d3Tile,e.d3GeoCore,e.d3GeoProjection,e.d3CompositeProjections,e.topojsonClient,e.d3Force,e.d3Polygon,e.d3Hierarchy,e.d3Sankey)}(this,function(e,t,i,s,n,a,o,r,c,h,l,d,u,m,f,g,p,y,_,x,b,k,v,C,S,w,z,D,M,A){"use strict";function $(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,Object.freeze(t)}var B=$(l),P=$(p),T=$(v),O=$(C),R=$(S);
7
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-array"),require("d3-selection"),require("@d3plus/data"),require("@d3plus/dom"),require("@d3plus/locales"),require("@d3plus/render"),require("@d3plus/text"),require("d3-color"),require("d3-brush"),require("d3-scale"),require("d3-zoom"),require("@d3plus/color"),require("@d3plus/format"),require("open-color/open-color.js"),require("d3-transition"),require("@d3plus/math"),require("d3-shape"),require("@floating-ui/dom"),require("d3-interpolate"),require("d3-time-format"),require("d3-tile"),require("d3-geo"),require("d3-geo-projection"),require("d3-composite-projections"),require("topojson-client"),require("d3-force"),require("d3-polygon"),require("d3-hierarchy"),require("d3-sankey")):"function"==typeof define&&define.amd?define("@d3plus/core",["exports","d3-array","d3-selection","@d3plus/data","@d3plus/dom","@d3plus/locales","@d3plus/render","@d3plus/text","d3-color","d3-brush","d3-scale","d3-zoom","@d3plus/color","@d3plus/format","open-color/open-color.js","d3-transition","@d3plus/math","d3-shape","@floating-ui/dom","d3-interpolate","d3-time-format","d3-tile","d3-geo","d3-geo-projection","d3-composite-projections","topojson-client","d3-force","d3-polygon","d3-hierarchy","d3-sankey"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).d3plus={},e.d3Array,e.d3Selection,e.data,e.dom,e.locales,e.render,e.text,e.d3Color,e.d3Brush,e.scales,e.d3Zoom,e.color,e.format,e.pkg,e.d3Transition,e.math,e.d3Shape,e.dom$1,e.d3Interpolate,e.d3TimeFormat,e.d3Tile,e.d3GeoCore,e.d3GeoProjection,e.d3CompositeProjections,e.topojsonClient,e.d3Force,e.d3Polygon,e.d3Hierarchy,e.d3Sankey)}(this,function(e,t,i,s,n,a,o,r,c,h,l,d,u,m,f,g,p,y,_,x,b,k,v,C,S,w,z,D,M,A){"use strict";function $(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return e[i]}})}}),t.default=e,Object.freeze(t)}var B=$(l),P=$(y),T=$(v),O=$(C),R=$(S);
8
8
  /**
9
9
  Wraps non-function variables in a simple return function.
10
10
  @param value The value to wrap in a return function.
@@ -147,12 +147,12 @@ e._legendDepth=0;for(let t=0;t<=e._drawDepth;t++){const i=c.map(e=>e[t]);if(!i.s
147
147
  instance (compute mode — Legend contributes to the scene via its
148
148
  `toScene()` collected on Viz.toScene), then returns the margin claim
149
149
  derived from the previous render's outerBounds.
150
- */(e);return function(e,t,i){const{legendData:s,fill:a,getAttr:o}=t,r=(t,i)=>{let s=e._id(t,i);return Array.isArray(s)&&(s=s[0]),e._hidden.includes(s)||e._solo.length>0&&!e._solo.includes(s)},c=e._legendClass.outerBounds(),h=E(e),l=V(e.schema.legendPosition.bind(e)(h)),d=["top","bottom"].includes(l),u=e.schema.legendPadding(e)?e._padding:{top:0,right:0,bottom:0,left:0},m={transform:`translate(${d?i.left+u.left:i.left}, ${d?i.top:i.top+u.top})`},f=!1!==l&&e.schema.legend.bind(e)(h,s),g=n.elem("g.d3plus-viz-legend",{condition:f&&!e.schema.legendConfig.select,enter:m,parent:e._select,duration:e.schema.duration,update:m}).node();e._legendClass.renderMode("compute").id(a).align(d?"center":l).direction(d?"row":"column").duration(e.schema.duration).data(f?s:[]).height(d?e.schema.height-(i.bottom+i.top):e.schema.height-(i.bottom+i.top+u.bottom+u.top)).locale(e.schema.locale).parent(e).select(g).shape((t,i)=>"Circle"===e.schema.shape(t,i)?"Circle":"Rect").verticalAlign(d?l:"middle").width(d?e.schema.width-(i.left+i.right+u.left+u.right):e.schema.width-(i.left+i.right)).shapeConfig(G.bind(e)(e.schema.shapeConfig,"legend")).shapeConfig({fill:(t,i)=>r(t,i)?e.schema.hiddenColor(t,i):o(t,i,"fill"),labelConfig:{fontOpacity:(t,i)=>r(t,i)?e.schema.hiddenOpacity(t,i):1}}).config(e.schema.legendConfig).render();
150
+ */(e);return function(e,t,i){const{legendData:s,fill:a,getAttr:o}=t,r=(t,i)=>{let s=e._id(t,i);return Array.isArray(s)&&(s=s[0]),e._hidden.includes(s)||e._solo.length>0&&!e._solo.includes(s)},c=e._legendClass.outerBounds(),h=E(e),l=X(e.schema.legendPosition.bind(e)(h)),d=["top","bottom"].includes(l),u=e.schema.legendPadding(e)?e._padding:{top:0,right:0,bottom:0,left:0},m={transform:`translate(${d?i.left+u.left:i.left}, ${d?i.top:i.top+u.top})`},f=!1!==l&&e.schema.legend.bind(e)(h,s),g=n.elem("g.d3plus-viz-legend",{condition:f&&!e.schema.legendConfig.select,enter:m,parent:e._select,duration:e.schema.duration,update:m}).node();e._legendClass.renderMode("compute").id(a).align(d?"center":l).direction(d?"row":"column").duration(e.schema.duration).data(f?s:[]).height(d?e.schema.height-(i.bottom+i.top):e.schema.height-(i.bottom+i.top+u.bottom+u.top)).locale(e.schema.locale).parent(e).select(g).shape((t,i)=>"Circle"===e.schema.shape(t,i)?"Circle":"Rect").verticalAlign(d?l:"middle").width(d?e.schema.width-(i.left+i.right+u.left+u.right):e.schema.width-(i.left+i.right)).shapeConfig(G.bind(e)(e.schema.shapeConfig,"legend")).shapeConfig({fill:(t,i)=>r(t,i)?e.schema.hiddenColor(t,i):o(t,i,"fill"),labelConfig:{fontOpacity:(t,i)=>r(t,i)?e.schema.hiddenOpacity(t,i):1}}).config(e.schema.legendConfig).render();
151
151
  // Margin claim from the *previous* render's outerBounds:
152
152
  // `outerBounds()` reads stored state, so on the first render the claim
153
153
  // is zero and Legend overlaps the chart for one frame; the next render
154
154
  // flows with full margin.
155
- const p={};return!e.schema.legendConfig.select&&c.height&&(p[l]=d?c.height+2*e._legendClass.padding():c.width+2*e._legendClass.padding()),{panel:null,margin:p}}(e,a,i)}},X=new Set([!1,"top","right","bottom","left"]);
155
+ const p={};return!e.schema.legendConfig.select&&c.height&&(p[l]=d?c.height+2*e._legendClass.padding():c.width+2*e._legendClass.padding()),{panel:null,margin:p}}(e,a,i)}},V=new Set([!1,"top","right","bottom","left"]);
156
156
  /**
157
157
  Canonical sanitizer for `legendPosition` / `colorScalePosition`.
158
158
  Falls back to `"bottom"` when the user-supplied accessor returns
@@ -160,7 +160,7 @@ const p={};return!e.schema.legendConfig.select&&c.height&&(p[l]=d?c.height+2*e._
160
160
  `vizDrawPure` (for sanitized ctx publication) and by `legendFeature`
161
161
  + `colorScaleFeature` (for their internal positioning math).
162
162
  */
163
- function V(e){return X.has(e)?e:"bottom"}
163
+ function X(e){return V.has(e)?e:"bottom"}
164
164
  /**
165
165
  Runs each feature's `layout` in order, accumulating margin claims so that
166
166
  later features see the space already taken by earlier ones. The order of
@@ -242,7 +242,7 @@ u.on&&u.on.brush&&u.on.brush(e)}).on("end",t=>{!
242
242
  Helper mirroring drawTimeline's `setTimeFilter`. Triggers a re-render when
243
243
  the brush selection changes — kept here so the feature owns its event flow.
244
244
  */
245
- function(e,t){if(Array.isArray(t)||(t=[t,t]),JSON.stringify(t)!==JSON.stringify(e._timelineSelection)){e._timelineSelection=t;const i=t.map(Number);e.timeFilter(t=>{const s=n.date(e.schema.time(t)).getTime();return s>=i[0]&&s<=i[1]}).render()}}(e,t),u.on&&u.on.end&&u.on.end(t)}).render(),{panel:null,margin:{bottom:l.outerBounds().height+2*l.padding()}}}},ie={name:"colorScale",configFields:["colorScale","colorScaleConfig","colorScaleMaxSize","colorScalePadding","colorScalePosition"],layout:({viz:e,layoutMargin:i})=>{const a=Array.from(t.rollup(e._data,t=>s.merge(t,e.schema.aggs),(t,i)=>`${e.schema.time?e.schema.time(t,i):"all"}-${e._ids(t,i).join("_")}`).values()),o=V(e.schema.colorScalePosition.bind(e)(E(e))),r=["top","bottom"].includes(o),c=e.schema.colorScale&&o,h=e.schema.colorScalePadding(e)?e._padding:{top:0,right:0,bottom:0,left:0},l=e.schema.width-(i.left+i.right+h.left+h.right),d=r?t.min([e.schema.colorScaleMaxSize,l]):e.schema.width-(i.left+i.right),u=e.schema.height-(i.bottom+i.top+h.bottom+h.top),m=r?e.schema.height-(i.bottom+i.top):t.min([e.schema.colorScaleMaxSize,u]),f={opacity:o?1:0,transform:`translate(${r?i.left+h.left+(l-d)/2:i.left}, ${r?i.top:i.top+h.top+(u-m)/2})`},g=n.elem("g.d3plus-viz-colorScale",{condition:c&&!e.schema.colorScaleConfig.select,enter:f,parent:e._select,duration:e.schema.duration,update:f}).node();if(!e.schema.colorScale)return{panel:null,margin:{}};const p=a.filter((t,i)=>{const s=e.schema.colorScale(t,i);return null!=s}),y=e.schema.colorScaleConfig||{},_=!y.bucketAxis&&["buckets","jenks","quantile"].includes("string"==typeof y.scale?y.scale:"");
245
+ function(e,t){if(Array.isArray(t)||(t=[t,t]),JSON.stringify(t)!==JSON.stringify(e._timelineSelection)){e._timelineSelection=t;const i=t.map(Number);e.timeFilter(t=>{const s=n.date(e.schema.time(t)).getTime();return s>=i[0]&&s<=i[1]}).render()}}(e,t),u.on&&u.on.end&&u.on.end(t)}).render(),{panel:null,margin:{bottom:l.outerBounds().height+2*l.padding()}}}},ie={name:"colorScale",configFields:["colorScale","colorScaleConfig","colorScaleMaxSize","colorScalePadding","colorScalePosition"],layout:({viz:e,layoutMargin:i})=>{const a=Array.from(t.rollup(e._data,t=>s.merge(t,e.schema.aggs),(t,i)=>`${e.schema.time?e.schema.time(t,i):"all"}-${e._ids(t,i).join("_")}`).values()),o=X(e.schema.colorScalePosition.bind(e)(E(e))),r=["top","bottom"].includes(o),c=e.schema.colorScale&&o,h=e.schema.colorScalePadding(e)?e._padding:{top:0,right:0,bottom:0,left:0},l=e.schema.width-(i.left+i.right+h.left+h.right),d=r?t.min([e.schema.colorScaleMaxSize,l]):e.schema.width-(i.left+i.right),u=e.schema.height-(i.bottom+i.top+h.bottom+h.top),m=r?e.schema.height-(i.bottom+i.top):t.min([e.schema.colorScaleMaxSize,u]),f={opacity:o?1:0,transform:`translate(${r?i.left+h.left+(l-d)/2:i.left}, ${r?i.top:i.top+h.top+(u-m)/2})`},g=n.elem("g.d3plus-viz-colorScale",{condition:c&&!e.schema.colorScaleConfig.select,enter:f,parent:e._select,duration:e.schema.duration,update:f}).node();if(!e.schema.colorScale)return{panel:null,margin:{}};const p=a.filter((t,i)=>{const s=e.schema.colorScale(t,i);return null!=s}),y=e.schema.colorScaleConfig||{},_=!y.bucketAxis&&["buckets","jenks","quantile"].includes("string"==typeof y.scale?y.scale:"");
246
246
  // Discrete (bucket/jenks/quantile) colorScales render their swatches via an
247
247
  // internal Legend, which composes cleanly through the Viz scene — so run
248
248
  // them in compute mode (like the legend) so the Viz's toScene owns them and
@@ -707,7 +707,10 @@ function xe(e){const t=c.hsl(e);return Number.isNaN(t.l)?e:(t.s=0,`${t}`)}
707
707
  graph, so this reapplies it here: darken the fill by `darken` for the stroke
708
708
  and multiply the stroke width by `widthMult` (treating a 0/absent width as 1,
709
709
  matching the shape defaults). Non-mark nodes (labels, groups) are untouched.
710
- */function ke(e,t,i){const s={...e.paint??{}};let n="string"==typeof s.fill?s.fill:void 0;n&&"transparent"!==n&&"none"!==n||(n="string"==typeof s.stroke?s.stroke:void 0);const a=n?c.color(n):null;a&&(s.stroke=a.darker(t).formatHex());const o="number"==typeof s.strokeWidth&&s.strokeWidth?s.strokeWidth:1;return s.strokeWidth=o*i,{...e,paint:s}}
710
+ */function ke(e,t,i){const s={...e.paint??{}};let n="string"==typeof s.fill?s.fill:void 0;
711
+ // No visible paint to emphasize (e.g. an invisible hit-area node): leave it
712
+ // untouched — darkening `transparent`/`none` would format to opaque black.
713
+ if(n&&"transparent"!==n&&"none"!==n||(n="string"==typeof s.stroke?s.stroke:void 0),!n||"transparent"===n||"none"===n)return e;const a=c.color(n);a&&(s.stroke=a.darker(t).formatHex());const o="number"==typeof s.strokeWidth&&s.strokeWidth?s.strokeWidth:1;return s.strokeWidth=o*i,{...e,paint:s}}
711
714
  /**
712
715
  Reads the interaction predicate + treatment off a viz, or null when nothing
713
716
  is set. Precedence: transient `hover`, then `active`, then the standing
@@ -796,7 +799,7 @@ let n=s?s.slice():[],[a,o]=i;e.schema.range&&(void 0!==e.schema.range[0]&&(a=e.s
796
799
  /** Splits a log scale into positive/negative sub-scales when it spans zero. */(e,c),e._d3Scale.padding&&e._d3Scale.padding(e.schema.scalePadding),e._d3Scale.paddingInner&&e._d3Scale.paddingInner(e.schema.paddingInner),e._d3Scale.paddingOuter&&e._d3Scale.paddingOuter(e.schema.paddingOuter),e._d3ScaleNegative=null,"log"===e.schema.scale&&function(e){const i=e._d3Scale.domain(),s=e._data;if(0===i[0]){const e=t.min([t.min(s),Math.abs(i[1])]);i[0]=0===e||1===e?1e-6:e<=1?De(e):1,ze(i[1])&&(i[0]*=-1)}else if(0===i[i.length-1]){const e=t.min([t.min(s),Math.abs(i[0])]);i[i.length-1]=0===e||1===e?1e-6:e<=1?De(e):1,ze(i[0])&&(i[i.length-1]*=-1)}const n=e._d3Scale.range();if(ze(i[0])&&ze(i[i.length-1]))e._d3ScaleNegative=e._d3Scale.copy().domain(i).range(n),e._d3Scale=null;else if(i[0]>0&&i[i.length-1]>0)e._d3Scale.domain(i).range(n);else{const a=i.map(e=>Math.log10(Math.abs(e))).map(e=>e||-1e-6),o=a[0]/t.sum(a)*(n[1]-n[0]);let r=t.min([t.min(s.filter(e=>e>=0)),Math.abs(i[1])]);1===r&&(r=1e-6);let c=t.min([t.min(s.filter(ze)),Math.abs(i[0])]);1===c&&(c=1e-6);const h=0===r?1e-6:r<=1?De(r):1,l=0===c?-1e-6:c<=1?De(c):1,d=t.min([Math.abs(h),Math.abs(l)]);e._d3ScaleNegative=e._d3Scale.copy(),(ze(i[0])?e._d3Scale:e._d3ScaleNegative).domain([ze(i[0])?d:-d,i[1]]).range([n[0]+o,n[1]]),(ze(i[0])?e._d3ScaleNegative:e._d3Scale).domain([i[0],ze(i[0])?-d:d]).range([n[0],n[0]+o])}}
797
800
  /** Resolves the tick + label value arrays (config, scale ticks, or domain). */(e);const{ticks:h,labels:l}=function(e){let t=(e.schema.ticks?"time"===e.schema.scale?e.schema.ticks.map(n.date):e.schema.ticks:(e._d3Scale?e._d3Scale.ticks:e._d3ScaleNegative?.ticks)?e._getTicks():e.schema.domain).slice(),i=(e.schema.labels?"time"===e.schema.scale?e.schema.labels.map(n.date):e.schema.labels:(e._d3Scale?e._d3Scale.ticks:e._d3ScaleNegative?.ticks)?e._getLabels():t).slice();return"time"===e.schema.scale&&(t=t.map(Number),i=i.map(Number)),t=t.sort((t,i)=>e._getPosition(t)-e._getPosition(i)),i=i.sort((t,i)=>e._getPosition(t)-e._getPosition(i)),{ticks:t,labels:i}}
798
801
  /** Sets `axis._tickUnit` for the "smallest" linear tick-suffix mode. */(e);!function(e,t){if("linear"===e.schema.scale&&"smallest"===e.schema.tickSuffix){const i=t.filter(e=>e>=1e3);if(i.length>0){const t=Math.min(...i);let s=1;for(;s&&s<7&&t/Math.pow(10,3*s)>=1;)e._tickUnit=s,s+=1}}}
799
- /** Drops ticks that would visually collide, recording available/visible sets. */(e,l);const d=function(e,t,i){const s=[];return e._availableTicks=t,t.forEach((t,n)=>{let a=i({id:t,tick:!0},n);"Circle"===e.schema.shape&&(a*=2);const o=e._getPosition(t);!s.length||Math.abs(y.closest(o,s.filter(e=>!1!==e))-o)>2*a?s.push(o):s.push(!1)}),t=t.filter((e,t)=>!1!==s[t]),e._visibleTicks=t,t}(e,h,s);return{range:o,ticks:d,labels:l}}
802
+ /** Drops ticks that would visually collide, recording available/visible sets. */(e,l);const d=function(e,t,i){const s=[];return e._availableTicks=t,t.forEach((t,n)=>{let a=i({id:t,tick:!0},n);"Circle"===e.schema.shape&&(a*=2);const o=e._getPosition(t);!s.length||Math.abs(p.closest(o,s.filter(e=>!1!==e))-o)>2*a?s.push(o):s.push(!1)}),t=t.filter((e,t)=>!1!==s[t]),e._visibleTicks=t,t}(e,h,s);return{range:o,ticks:d,labels:l}}
800
803
  /**
801
804
  The standalone axis layout pass. Accepts any object satisfying the
802
805
  Axis-instance shape (the production `Axis` class is the canonical input).
@@ -840,34 +843,15 @@ let n="Circle"===e.schema.shape?"function"==typeof e.schema.shapeConfig.r?e.sche
840
843
  the swatch↔hit-area crossing) but a DISTINCT `key`: the hit-area and the
841
844
  visible geometry are siblings, and the SVG keyed join can't hold two nodes
842
845
  under one key — sharing it made the geometry re-enter (collapse→grow) on every
843
- redraw (a "pulse" on e.g. every timeline step). Returns null when no
844
- rect-style hitArea is configured; Line's path-style hitArea is covered by its
845
- own geometry.
846
+ redraw (a "pulse" on e.g. every timeline step). Returns null when no hitArea
847
+ is configured. A path-style hitArea (Line: a fat, transparent stroke) reuses
848
+ the resolved geometry `d`/`transform` so the hover target overlaps the
849
+ visible line exactly while extending past its ~1px stroke.
846
850
  */
847
- /** Image's fluent accessor schema. Config storage lives on `this.schema.<key>`. */const Oe=[{key:"duration",coerce:"identity",default:600},{key:"height",coerce:"accessor",default:F("height")},{key:"id",coerce:"identity",default:F("id")},{key:"opacity",coerce:"const",default:L(1)},{key:"pointerEvents",coerce:"const",default:L("auto")},{key:"renderMode",coerce:"identity",default:"full"},{key:"url",coerce:"identity",default:F("url")},{key:"width",coerce:"accessor",default:F("width")},{key:"x",coerce:"const",default:F("x",0)},{key:"y",coerce:"const",default:F("y",0)}];class Re{config(e){if(!arguments.length)return{...this.schema,data:this._data,select:this._select};const t=e;for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(
848
- // `this[k]` resolves the fluent accessor via the index signature.
849
- "function"==typeof this[e]?this[e](t[e]):this.schema[e]=t[e]);return this}
850
- /**
851
- Renders the current Image to the page. If a *callback* is specified, it will be called once the images are done drawing.
852
- @param callback Optional callback invoked after rendering completes.
853
- */render(e){
854
- // Compute mode is a no-op for DOM emission — the caller will read
855
- // `toScene()` to get a SceneNode tree, no need to mount.
856
- if("compute"===this.schema.renderMode)return e&&setTimeout(e,0),this;void 0===this._select&&this.select(i.select("body").append("svg").style("width",`${window.innerWidth}px`).style("height",`${window.innerHeight}px`).style("display","block").node());const t=this._select.selectAll(".d3plus-Image").data(this._data,this.schema.id),s=t.enter().append("image").attr("class","d3plus-Image").attr("opacity",0).attr("width",0).attr("height",0).attr("x",(e,t)=>this.schema.x(e,t)+this.schema.width(e,t)/2).attr("y",(e,t)=>this.schema.y(e,t)+this.schema.height(e,t)/2),n=g.transition().duration(this.schema.duration),a=this;return s.merge(t).attr("xlink:href",this.schema.url).style("pointer-events",this.schema.pointerEvents).transition(n).attr("opacity",this.schema.opacity).attr("width",(e,t)=>this.schema.width(e,t)).attr("height",(e,t)=>this.schema.height(e,t)).attr("x",(e,t)=>this.schema.x(e,t)).attr("y",(e,t)=>this.schema.y(e,t)).each(function(e,t){const s=i.select(this),n=a.schema.url(e,t);if(!(0===n.indexOf("http://")||0===n.indexOf("https://"))||0===n.indexOf(window.location.hostname)){const e=new window.Image;e.src=n,e.crossOrigin="Anonymous",e.onload=function(){const t=document.createElement("canvas");t.width=e.width,t.height=e.height;t.getContext("2d").drawImage(e,0,0),s.attr("xlink:href",t.toDataURL("image/png"))}}}),t.exit().transition(n).attr("width",(e,t)=>this.schema.width(e,t)).attr("height",(e,t)=>this.schema.height(e,t)).attr("x",(e,t)=>this.schema.x(e,t)).attr("y",(e,t)=>this.schema.y(e,t)).attr("opacity",0).remove(),e&&setTimeout(e,this.schema.duration+100),this}data(e){return arguments.length?(this._data=e,this):this._data}
857
- /**
858
- Compute-mode scene emission. Mirrors Shape.toScene's shape — a
859
- keyed GroupNode wrapping per-datum ImageNodes. Used by chart
860
- compositors (Shape._backgroundImageClass, plotPaint) that need
861
- Image to participate in the scene graph rather than emit
862
- d3-selection DOM.
863
- */toScene(){return{type:"group",key:"d3plus-Image",children:(this._data||[]).map((e,t)=>({type:"image",key:`${this.schema.id(e,t)}`,x:this.schema.x(e,t),y:this.schema.y(e,t),width:this.schema.width(e,t),height:this.schema.height(e,t),href:this.schema.url(e,t),paint:{opacity:this.schema.opacity(e,t)},datum:e,index:t}))}}select(e){return arguments.length?(this._select=i.select(e),this):this._select}
864
- /**
865
- Invoked when creating a new class instance, and sets any default parameters.
866
- @private
867
- */constructor(){re(this,Oe)}}
868
851
  /** Follows the chart (`__d3plus__`) and shape (`__d3plusShape__`) wrappers back
869
852
  to the source datum, so a `sort` comparator sees the same object the other
870
- per-datum accessors receive. */function Le(e){let t=e;for(;t.__d3plus__&&t.data;)t=t.data;return t.__d3plusShape__?t.data:t}
853
+ per-datum accessors receive. */
854
+ function Oe(e){let t=e;for(;t.__d3plus__&&t.data;)t=t.data;return t.__d3plusShape__?t.data:t}
871
855
  /**
872
856
  Ranks `data` by a `sort` layering comparator WITHOUT reordering it. Returns
873
857
  `rank[i]` = the paint position of datum `i` (lower = painted first = behind),
@@ -876,15 +860,62 @@ if("compute"===this.schema.renderMode)return e&&setTimeout(e,0),this;void 0===th
876
860
  comparator or nothing to reorder, so callers emit no `z` and the fast
877
861
  append-order path is preserved.
878
862
  */
879
- /** Coerces a value to a finite number, or undefined. @private */function Ee(e){const t=Number(e);return Number.isFinite(t)?t:void 0}
880
- /** Returns a non-empty string, or undefined. @private */function Fe(e){return null==e||""===e?void 0:String(e)}
881
- /** Parses an SVG stroke-dasharray value into an array of numbers. @private */function We(e){if(null==e||"none"===e||""===e)return;if("number"==typeof e)return[e];const t=String(e).split(/[\s,]+/).map(Number).filter(e=>Number.isFinite(e));return t.length?t:void 0}
882
- /** Shape's fluent accessor schema. Config storage lives on `this.schema.<key>`. */const Ne=[{key:"activeOpacity",coerce:"identity",default:.25},{key:"ariaLabel",coerce:"const",default:L("")},{key:"backgroundImage",coerce:"const",default:L(!1)},{key:"discrete",coerce:"identity"},{key:"duration",coerce:"identity",default:600},{key:"fill",coerce:"const",default:L("black")},{key:"fillOpacity",coerce:"const",default:L(1)},{key:"hitArea",coerce:"const"},{key:"hoverOpacity",coerce:"identity",default:.5},{key:"id",coerce:"accessor",default:(e,t)=>void 0!==e.id?e.id:t},{key:"label",coerce:"const",default:L(!1)},{key:"labelBounds",coerce:"const"},{key:"opacity",coerce:"const",default:L(1)},{key:"pointerEvents",coerce:"const",default:L("visiblePainted")},{key:"renderMode",coerce:"identity",default:"full"},{key:"role",coerce:"const",default:L("presentation")},{key:"rotate",coerce:"const",default:L(0)},{key:"rx",coerce:"const",default:L(0)},{key:"ry",coerce:"const",default:L(0)},{key:"scale",coerce:"const",default:L(1)},{key:"shapeRendering",coerce:"const",default:L("geometricPrecision")},{key:"stroke",coerce:"const"},{key:"strokeDasharray",coerce:"const",default:L("0")},{key:"strokeLinecap",coerce:"const",default:L("butt")},{key:"strokeOpacity",coerce:"const",default:L(1)},{key:"strokeWidth",coerce:"const",default:L(0)},{key:"textAnchor",coerce:"const",default:L("start")},{key:"texture",coerce:"const",default:L(!1)},{key:"vectorEffect",coerce:"const",default:L("non-scaling-stroke")},{key:"verticalAlign",coerce:"const",default:L("top")},
863
+ /**
864
+ The local-space bounding box `{x, y, width, height}` a backgroundImage fills,
865
+ derived from a datum's scene geometry. Rect/Bar geometry is already a box;
866
+ Circle is centered at (cx, cy) with radius r; a `path` uses the exact
867
+ (DOM-free) bounds of its `d`; Area/Line fall back to their polygon `points`.
868
+ Returns null when no finite extent can be determined.
869
+ */
870
+ function Re(e,t){if("number"==typeof e.width&&"number"==typeof e.height){return{x:"number"==typeof e.x?e.x:-e.width/2,y:"number"==typeof e.y?e.y:-e.height/2,width:e.width,height:e.height}}if("number"==typeof e.r){const t="number"==typeof e.cx?e.cx:0,i="number"==typeof e.cy?e.cy:0;return{x:t-e.r,y:i-e.r,width:2*e.r,height:2*e.r}}if("string"==typeof e.d){const t=p.pathBounds(e.d);return t.width>0&&t.height>0?t:null}
871
+ /** Bounding box of a list of polygon points, or null when degenerate. */
872
+ return function(e){if(!e.length)return null;let t=1/0,i=1/0,s=-1/0,n=-1/0;for(const[a,o]of e)a<t&&(t=a),o<i&&(i=o),a>s&&(s=a),o>n&&(n=o);return!Number.isFinite(t)||s<=t||n<=i?null:{x:t,y:i,width:s-t,height:n-i}}(t)}
873
+ /** Rounded-rectangle path `d` (falls back to a plain rect when radii are 0). */function Le(e,t,i,s,n,a){return`M${e+(n=Math.min(n,i/2))},${t}h${i-2*n}a${n},${a=Math.min(a,s/2)} 0 0 1 ${n},${a}v${s-2*a}a${n},${a} 0 0 1 ${-n},${a}h${-(i-2*n)}a${n},${a} 0 0 1 ${-n},${-a}v${-(s-2*a)}a${n},${a} 0 0 1 ${n},${-a}Z`}
874
+ /**
875
+ The shape's own geometry expressed as a clip region in its LOCAL coordinate
876
+ space, so a background image can be clipped to the shape itself (a Path image
877
+ is clipped to the path, a Circle image to the circle, etc.). Returns
878
+ undefined when the geometry has no usable outline.
879
+ */function Ee(e,t){if("string"==typeof e.d)return{type:"path",d:e.d};if("number"==typeof e.width&&"number"==typeof e.height){const t="number"==typeof e.x?e.x:-e.width/2,i="number"==typeof e.y?e.y:-e.height/2,s="number"==typeof e.rx?e.rx:0,n="number"==typeof e.ry?e.ry:0;return s>0||n>0?{type:"path",d:Le(t,i,e.width,e.height,s||n,n||s)}:{type:"rect",x:t,y:i,width:e.width,height:e.height}}if("number"==typeof e.r){const t="number"==typeof e.cx?e.cx:0,i="number"==typeof e.cy?e.cy:0,s=e.r;return{type:"path",d:`M${t-s},${i}a${s},${s} 0 1,0 ${2*s},0a${s},${s} 0 1,0 ${-2*s},0Z`}}if(t.length>2){return{type:"path",d:`M${t.map(([e,t])=>`${e},${t}`).join("L")}Z`}}}
880
+ /** A polygon (local coords) approximating the shape outline, for `largestRect`. */
881
+ /**
882
+ Resolves a backgroundImage's box + clip + `preserveAspectRatio` for a datum's
883
+ geometry, honoring the fit mode:
884
+
885
+ - `cover` — the image fills the shape's bounding box and is cropped
886
+ (`xMidYMid slice`), clipped to the shape's own outline.
887
+ - `contain` — the whole image is centered and fully visible inside the shape:
888
+ it is fit (`xMidYMid meet`) into the shape's largest inscribed axis-aligned
889
+ rectangle (a Rect uses itself; a Circle its inscribed square; a Path/Area
890
+ uses `largestRect` of its polygon). No clip is needed since the box already
891
+ sits inside the shape.
892
+
893
+ Returns null when no usable box can be derived.
894
+ */
895
+ function Fe(e,t,i){if("contain"!==i){const i=Re(e,t);return i?{box:i,clip:Ee(e,t),preserveAspectRatio:"xMidYMid slice"}:null}
896
+ // contain: fit inside the largest inscribed rectangle, fully visible.
897
+ let s=null;if("number"==typeof e.width&&"number"==typeof e.height)s=Re(e,t);// a rect contains itself
898
+ else if("number"==typeof e.r){
899
+ // Inscribed square of a circle: side = r·√2, centered on (cx, cy).
900
+ const t="number"==typeof e.cx?e.cx:0,i="number"==typeof e.cy?e.cy:0,n=e.r/Math.SQRT2;s={x:t-n,y:i-n,width:2*n,height:2*n}}else{const i=function(e,t){return"string"==typeof e.d?p.path2polygon(e.d):t}(e,t),n=i.length>2?p.largestRect(i,{angle:0}):null;s=n?{x:n.cx-n.width/2,y:n.cy-n.height/2,width:n.width,height:n.height}:Re(e,t)}return s?{box:s,preserveAspectRatio:"xMidYMid meet"}:null}
901
+ /**
902
+ Emits the per-datum background images collected during `Shape.toScene`. Each
903
+ image is wrapped in its own group carrying the shape's datum + transform, so
904
+ it is clipped to the shape's outline, positioned in local space, and dims/
905
+ raises together with its shape on hover. The image is non-interactive (and
906
+ keyed apart from the shape) so pointer events pass through to the shape below.
907
+ When `rank` is set (a `sort` comparator is active) every group needs a `z`
908
+ so the backend sort keeps images above the geometry in their own order.
909
+ */
910
+ /** Coerces a value to a finite number, or undefined. @private */function We(e){const t=Number(e);return Number.isFinite(t)?t:void 0}
911
+ /** Returns a non-empty string, or undefined. @private */function Ne(e){return null==e||""===e?void 0:String(e)}
912
+ /** Parses an SVG stroke-dasharray value into an array of numbers. @private */function He(e){if(null==e||"none"===e||""===e)return;if("number"==typeof e)return[e];const t=String(e).split(/[\s,]+/).map(Number).filter(e=>Number.isFinite(e));return t.length?t:void 0}
913
+ /** Shape's fluent accessor schema. Config storage lives on `this.schema.<key>`. */const je=[{key:"activeOpacity",coerce:"identity",default:.25},{key:"ariaLabel",coerce:"const",default:L("")},{key:"backgroundImage",coerce:"const",default:L(!1)},{key:"backgroundImageFit",coerce:"const",default:L("cover")},{key:"discrete",coerce:"identity"},{key:"duration",coerce:"identity",default:600},{key:"fill",coerce:"const",default:L("black")},{key:"fillOpacity",coerce:"const",default:L(1)},{key:"hitArea",coerce:"const"},{key:"hoverOpacity",coerce:"identity",default:.5},{key:"id",coerce:"accessor",default:(e,t)=>void 0!==e.id?e.id:t},{key:"label",coerce:"const",default:L(!1)},{key:"labelBounds",coerce:"const"},{key:"opacity",coerce:"const",default:L(1)},{key:"pointerEvents",coerce:"const",default:L("visiblePainted")},{key:"renderMode",coerce:"identity",default:"full"},{key:"role",coerce:"const",default:L("presentation")},{key:"rotate",coerce:"const",default:L(0)},{key:"rx",coerce:"const",default:L(0)},{key:"ry",coerce:"const",default:L(0)},{key:"scale",coerce:"const",default:L(1)},{key:"shapeRendering",coerce:"const",default:L("geometricPrecision")},{key:"stroke",coerce:"const"},{key:"strokeDasharray",coerce:"const",default:L("0")},{key:"strokeLinecap",coerce:"const",default:L("butt")},{key:"strokeOpacity",coerce:"const",default:L(1)},{key:"strokeWidth",coerce:"const",default:L(0)},{key:"textAnchor",coerce:"const",default:L("start")},{key:"texture",coerce:"const",default:L(!1)},{key:"vectorEffect",coerce:"const",default:L("non-scaling-stroke")},{key:"verticalAlign",coerce:"const",default:L("top")},
883
914
  // "accessor" (not "const"): a string names a data key (`.x("year")`), a
884
915
  // number is a constant (`.x(50)`), and a function passes through — so a
885
916
  // standalone shape given string accessors (as the pipeline never does, but
886
917
  // direct users do) reads the field instead of treating "x" as the literal.
887
- {key:"x",coerce:"accessor",default:F("x",0)},{key:"y",coerce:"accessor",default:F("y",0)}];class He extends j{
918
+ {key:"x",coerce:"accessor",default:F("x",0)},{key:"y",coerce:"accessor",default:F("y",0)}];class Ge extends j{
888
919
  /**
889
920
  Given a specific data point and index, returns the aesthetic properties of the shape.
890
921
  @param data point*
@@ -922,10 +953,10 @@ return Te({data:this._data,dataFilter:this._dataFilter?this._dataFilter.bind(thi
922
953
  @param callback Optional callback invoked after rendering completes.
923
954
  */
924
955
  /**
925
- Resolves a style accessor for a data point, mirroring the nested-data logic
926
- of _applyStyle so scene output matches DOM rendering.
956
+ Resolves a style accessor. For a nested shape (Line/Area) the accessor gets
957
+ the merged aggregate `d.data`/`d.i` — matching `_nestWrapper` + scene datum.
927
958
  @private
928
- */_styleVal(e,t,i){if("function"!=typeof e)return e;if(t.nested&&t.key&&t.values){const i=t.values[0];return e(i,this._data.indexOf(i))}return e(t,i)}
959
+ */_styleVal(e,t,i){return"function"!=typeof e?e:t.nested&&t.key&&t.values?e(t.data,t.i):e(t,i)}
929
960
  /**
930
961
  Builds the resolved Transform for a data point, mirroring _applyTransform.
931
962
  @private
@@ -942,7 +973,7 @@ return Te({data:this._data,dataFilter:this._dataFilter?this._dataFilter.bind(thi
942
973
  */_scenePaint(e,t){
943
974
  // A texture resolves to a stable "pattern:<key>" token (the same JSON config
944
975
  // render() uses); each backend materializes or degrades it.
945
- const i=this._getTextureKey(e,t);return{fill:i?`pattern:${i}`:Fe(this._styleVal(this.schema.fill,e,t)),fillOpacity:Ee(this._styleVal(this.schema.fillOpacity,e,t)),stroke:Fe(this._styleVal(this.schema.stroke,e,t)),strokeWidth:Ee(this._styleVal(this.schema.strokeWidth,e,t)),strokeOpacity:Ee(this._styleVal(this.schema.strokeOpacity,e,t)),strokeDasharray:We(this._styleVal(this.schema.strokeDasharray,e,t)),strokeLinecap:Fe(this._styleVal(this.schema.strokeLinecap,e,t)),vectorEffect:Fe(this._styleVal(this.schema.vectorEffect,e,t)),shapeRendering:Fe(this._nestWrapper(this.schema.shapeRendering)(e,t)),opacity:Ee(this._nestWrapper(this.schema.opacity)(e,t))}}
976
+ const i=this._getTextureKey(e,t);return{fill:i?`pattern:${i}`:Ne(this._styleVal(this.schema.fill,e,t)),fillOpacity:We(this._styleVal(this.schema.fillOpacity,e,t)),stroke:Ne(this._styleVal(this.schema.stroke,e,t)),strokeWidth:We(this._styleVal(this.schema.strokeWidth,e,t)),strokeOpacity:We(this._styleVal(this.schema.strokeOpacity,e,t)),strokeDasharray:He(this._styleVal(this.schema.strokeDasharray,e,t)),strokeLinecap:Ne(this._styleVal(this.schema.strokeLinecap,e,t)),vectorEffect:Ne(this._styleVal(this.schema.vectorEffect,e,t)),shapeRendering:Ne(this._nestWrapper(this.schema.shapeRendering)(e,t)),opacity:We(this._nestWrapper(this.schema.opacity)(e,t))}}
946
977
  /**
947
978
  Returns the geometry-specific scene fields for a data point. Overridden by
948
979
  each shape subclass; the base provides none.
@@ -952,17 +983,10 @@ const i=this._getTextureKey(e,t);return{fill:i?`pattern:${i}`:Fe(this._styleVal(
952
983
  Produces a backend-agnostic scene graph for this shape's data, reusing the
953
984
  same accessors render() applies to the DOM. This is the migration seam toward
954
985
  the @d3plus/render pluggable backends; it has no effect on render().
955
- */toScene(){let e=this._data;this._dataFilter&&(e=this._dataFilter(e));const t=[],i=[],s=function(e,t){if(!t||e.length<2)return null;const i=e.map((e,t)=>t);i.sort((i,s)=>t(Le(e[i]),Le(e[s])));const s=new Array(e.length);return i.forEach((e,t)=>s[e]=t),s}
956
- /**
957
- Renders the per-datum background images collected during `Shape.toScene` as
958
- flat sibling nodes. When `rank` is set (a `sort` comparator is active) every
959
- returned node needs a `z` — otherwise the backend sort would collapse the
960
- images to 0 and interleave them among the geometry — so they are placed
961
- above all geometry (ranks span `0..dataLen-1`) while keeping their own order.
962
- */(e,this.schema.sort);
963
- // Build the backgroundImage data for emission below. Each datum that
964
- // resolves to a non-false `backgroundImage(d, i)` becomes an
965
- // ImageNode positioned at the shape's geometry.
986
+ */toScene(){let e=this._data;this._dataFilter&&(e=this._dataFilter(e));const t=[],i=[],s=function(e,t){if(!t||e.length<2)return null;const i=e.map((e,t)=>t);i.sort((i,s)=>t(Oe(e[i]),Oe(e[s])));const s=new Array(e.length);return i.forEach((e,t)=>s[e]=t),s}(e,this.schema.sort);
987
+ // Collected background images, emitted below (after the geometry) as clipped,
988
+ // transformed groups. Each datum whose `backgroundImage(d, i)` resolves to a
989
+ // truthy URL contributes one spec.
966
990
  // NOTE: Labels are NOT pushed here. The canonical aggregation point is
967
991
  // `emitHelpers.collectComputed(shape)`, which appends `shape.toScene()`
968
992
  // AND `shape._labelClass.toScene()` independently. Pushing labels here
@@ -970,25 +994,52 @@ const i=this._getTextureKey(e,t);return{fill:i?`pattern:${i}`:Fe(this._styleVal(
970
994
  // (Pie/Donut/Pack/Treemap/Network/Priestley/Radar/RadialMatrix/Geomap…).
971
995
  // Standalone shape.render() consumers (no collectComputed wrapper) get
972
996
  // labels through Shape.render's own SvgRenderer path below.
973
- return e.forEach((e,n)=>{const a=this._sceneGeometry(e,n);if(!a)return;const o=this._nestWrapper(this.schema.id)(e,n),r=e.__d3plusShape__?e.data:e,c=this._sceneTransform(e,n);
997
+ return e.forEach((e,n)=>{const a=this._sceneGeometry(e,n);if(!a)return;const o=this._nestWrapper(this.schema.id)(e,n),r=e.__d3plusShape__?e.data:e,c=this._sceneTransform(e,n),h=
998
+ /**
999
+ For a nested shape datum (Line/Area, whose datum wraps many points) returns a
1000
+ spreadable scene-node fragment carrying each point's content-space position
1001
+ paired with its source datum, so the pointer bridge can report the point
1002
+ nearest the cursor rather than the whole-series aggregate. Points the
1003
+ `defined` accessor rejects, or whose position isn't finite (a missing value),
1004
+ are skipped — so the nearest match is always a real, defined point. Returns
1005
+ an empty object for non-nested data (spreads to nothing).
1006
+ */
1007
+ function(e,t,i,s){if(!e.__d3plusShape__||!Array.isArray(e.values))return{};const n=e.values,a=[];return n.forEach((e,n)=>{if("function"==typeof s&&!1===s(e,n))return;const o=Number(t(e,n)),r=Number(i(e,n));Number.isFinite(o)&&Number.isFinite(r)&&a.push({x:o,y:r,datum:e,index:"number"==typeof e.i?e.i:n})}),a.length?{interactionPoints:a}:{}}(e,this.schema.x,this.schema.y,this.schema.defined);
974
1008
  // Push the hit area (if any) before the geometry so it sits behind it.
975
- if(this.schema.hitArea){const i=function(e,t,i,s,n,a,o,r){const c="function"==typeof e?e(t,i,s):e;return c&&"number"==typeof c.width&&"number"==typeof c.height?{type:"rect",x:"number"==typeof c.x?c.x:-c.width/2,y:"number"==typeof c.y?c.y:-c.height/2,width:c.width,height:c.height,key:`${n}::hit`,datum:a,index:i,shapeType:o,paint:{fill:"transparent"},transform:r,aria:{hidden:!0}}:null}(this.schema.hitArea,e,n,this._aes(e,n),o,r,this._name,c);
1009
+ // Line's is a fat path built from the geometry `d`; Bar/legend etc. a rect.
1010
+ if(this.schema.hitArea){const i=function(e,t,i,s,n,a,o,r,c){const h="function"==typeof e?e(t,i,s):e;if(!h)return null;
1011
+ // Path-style hitArea (Line): widen the hover target to a fat transparent
1012
+ // stroke over the line's own geometry. `stroke: transparent` (not "none") is
1013
+ // painted, so it hit-tests across the full width on both backends.
1014
+ if("number"!=typeof h.width&&"string"==typeof c)return{type:"path",d:c,key:`${n}::hit`,datum:a,index:i,shapeType:o,paint:{fill:"none",stroke:"transparent",strokeWidth:"number"==typeof h["stroke-width"]?h["stroke-width"]:10,vectorEffect:"non-scaling-stroke"},transform:r,aria:{hidden:!0}};return"number"!=typeof h.width||"number"!=typeof h.height?null:{type:"rect",x:"number"==typeof h.x?h.x:-h.width/2,y:"number"==typeof h.y?h.y:-h.height/2,width:h.width,height:h.height,key:`${n}::hit`,datum:a,index:i,shapeType:o,paint:{fill:"transparent"},transform:r,aria:{hidden:!0}}}(this.schema.hitArea,e,n,this._aes(e,n),o,r,this._name,c,a.d);
976
1015
  // Share the datum's rank so the hit area stays paired just behind its
977
1016
  // own geometry (equal `z`, kept in push order by the stable sort).
978
- i&&t.push(s?{...i,z:s[n]}:i)}t.push({...a,key:o,datum:r,index:n,shapeType:this._name,paint:this._scenePaint(e,n),transform:c,aria:{role:Fe(this._nestWrapper(this.schema.role)(e,n)),label:Fe(this._nestWrapper(this.schema.ariaLabel)(e,n))},...s?{z:s[n]}:{}});
979
- // backgroundImage: collect a per-datum image when the accessor
980
- // returns a truthy URL. The image is sized to the shape's
981
- // geometry (preferring width/height fields when present).
982
- const h=this._nestWrapper(this.schema.backgroundImage)(e,n);if(h){const t=a,s=this._sceneTransform(e,n),o="number"==typeof t.width?t.width:void 0,r="number"==typeof t.height?t.height:void 0,c="number"==typeof t.cx?t.cx:"number"==typeof t.x?t.x:0,l="number"==typeof t.cy?t.cy:"number"==typeof t.y?t.y:0,d="number"==typeof t.r?t.r:void 0,u=o??(null!=d?2*d:0),m=r??(null!=d?2*d:0);
983
- // Shape geometry is origin-centered; its on-screen position lives in
984
- // the node transform. The background image is emitted as a flat sibling
985
- // (no transform), so bake the shape's translate into the image x/y —
986
- // otherwise every image lands at the origin (top-left).
987
- i.push({__d3plus__:!0,data:e,i:n,id:this._nestWrapper(this.schema.id)(e,n),url:h,x:(s.x??0)+c-u/2,y:(s.y??0)+l-m/2,width:u,height:m})}}),
1017
+ i&&t.push(s?{...i,...h,z:s[n]}:{...i,...h})}t.push({...a,key:o,datum:r,index:n,shapeType:this._name,paint:this._scenePaint(e,n),transform:c,aria:{role:Ne(this._nestWrapper(this.schema.role)(e,n)),label:Ne(this._nestWrapper(this.schema.ariaLabel)(e,n))},...h,...s?{z:s[n]}:{}});
1018
+ // backgroundImage: collect a per-datum image (see backgroundImageLayout for
1019
+ // the cover/contain fit). The wrapping group carries the shape transform,
1020
+ // so the image box + clip stay in local space.
1021
+ const l=this._nestWrapper(this.schema.backgroundImage)(e,n);if(l){const t=a,s=Fe(t,"string"!=typeof t.d&&"number"!=typeof t.width&&"number"!=typeof t.r?this._aes(e,n).points??[]:[],"contain"===this._nestWrapper(this.schema.backgroundImageFit)(e,n)?"contain":"cover");
1022
+ // Only Area/Line lack a `d`/box and need polygon points; Path/Rect/Circle
1023
+ // derive their layout from `d`/width/r directly.
1024
+ s&&i.push({key:o,index:n,datum:r,url:l,box:s.box,clip:s.clip,preserveAspectRatio:s.preserveAspectRatio,opacity:We(this._nestWrapper(this.schema.opacity)(e,n)),transform:c})}}),
988
1025
  // Emit background images AFTER shape children so they paint above the
989
1026
  // shape's fill — matches the DOM order where the <image> was
990
1027
  // appended as a sibling of the shape.
991
- i.length&&t.push(...function(e,t,i,s){e.data(t).id(e=>`${e.id}`).url(e=>e.url).x(e=>e.x).y(e=>e.y).width(e=>e.width).height(e=>e.height).renderMode("compute");const n=e.toScene();return n&&Array.isArray(n.children)?(i&&n.children.forEach((e,t)=>e.z=s+t),n.children):[]}(this._backgroundImageClass,i,s,e.length)),{type:"group",key:`${this._name}-group`,children:t}}render(e){
1028
+ i.length&&t.push(...function(e,t,i){return e.map((e,s)=>{const n={type:"image",
1029
+ // Keyed apart from the shape (which uses `spec.key`): sharing the key would
1030
+ // let this non-interactive image overwrite the shape in the hit-test index.
1031
+ key:`${e.key}-bgimage-img`,x:e.box.x,y:e.box.y,width:e.box.width,height:e.box.height,href:e.url,preserveAspectRatio:e.preserveAspectRatio,
1032
+ // Decorative: pointer events fall through to the shape underneath.
1033
+ interactive:!1};return{type:"group",key:`${e.key}-bgimage`,children:[n],
1034
+ // Carry the shape's datum/index so hover/active dimming treats the image
1035
+ // like its shape — dimming and hover-raising the two together (the group
1036
+ // is emitted after the geometry, so at equal `z` the image stays on top).
1037
+ datum:e.datum,index:e.index,interactive:!1,
1038
+ // A group-level opacity gives the enter/exit animation a target to fade
1039
+ // to/from (matching the shape): the animate layer collapses it to 0 on
1040
+ // enter and eases up to this. It also cascades to the image, so hover
1041
+ // dimming applied here fades the picture with its shape.
1042
+ paint:{opacity:e.opacity??1},...e.transform?{transform:e.transform}:{},...e.clip?{clip:e.clip}:{},...t?{z:i+s}:{}}})}(i,s,e.length)),{type:"group",key:`${this._name}-group`,children:t}}render(e){
992
1043
  // Populate the label TextBox so toScene() reads correct label data. The
993
1044
  // label class is always in compute mode — the scene path materializes text.
994
1045
  const t=this._labelClass;if(t&&"function"==typeof t.renderMode&&t.renderMode("compute"),
@@ -1026,7 +1077,7 @@ if(m&&"function"==typeof m.destroy&&m.destroy(),!m)for(;t.firstChild;)t.removeCh
1026
1077
  /**
1027
1078
  Invoked when creating a new class instance, and sets any default parameters.
1028
1079
  @private
1029
- */constructor(e="g"){super(),re(this,Ne),this._backgroundImageClass=new Re,this._data=[],this._labelClass=new Wt,this._name="Shape",this._tagName=e,this._textureDefs={},
1080
+ */constructor(e="g"){super(),re(this,je),this._data=[],this._labelClass=new Gt,this._name="Shape",this._tagName=e,this._textureDefs={},
1030
1081
  // stroke defaults to a darker shade of fill — closes over `this.schema`
1031
1082
  // so it tracks the current fill accessor. A fill that doesn't parse as a
1032
1083
  // color (e.g. "none"/"transparent", a gradient token) has no darker shade,
@@ -1042,7 +1093,7 @@ this.schema.labelConfig={fontColor:(e,t)=>u.colorContrast(this.schema.fill(e,t))
1042
1093
  // when `shapeConfig.opacity` is 0). Reads `this.schema.opacity` live —
1043
1094
  // like `fontColor` reads `fill` — which unwraps nested label data.
1044
1095
  fontOpacity:(e,t)=>this.schema.opacity(e,t),fontResize:!0,fontMax:50,fontMin:8,fontSize:12,padding:5,textAnchor:"start",verticalAlign:"top"},this.schema.textureDefault={}}}
1045
- /** Area's own fluent accessor schema, layered on top of Shape's. */const je=[{key:"curve",coerce:"const",default:L("linear")},{key:"defined",coerce:"identity",default:()=>!0}];class Ge extends He{
1096
+ /** Area's own fluent accessor schema, layered on top of Shape's. */const Ie=[{key:"curve",coerce:"const",default:L("linear")},{key:"defined",coerce:"identity",default:()=>!0}];class qe extends Ge{
1046
1097
  /**
1047
1098
  Returns the area geometry as a "d" string built by the same area generator
1048
1099
  render() uses, with the center offset baked into the x/x0/x1/y/y0/y1 accessors
@@ -1065,8 +1116,8 @@ return this.schema.x1?r.x1(a(this.schema.x1)):r.x1(null),this.schema.y1?r.y1(o(t
1065
1116
  /**
1066
1117
  Invoked when creating a new class instance, and overrides any default parameters inherited from Shape.
1067
1118
  @private
1068
- */constructor(){super(),re(this,je),this._name="Area",this.schema.labelBounds=(e,t,i)=>{const s=y.largestRect(i.points);return s?{angle:s.angle,width:s.width,height:s.height,x:s.cx-s.width/2-this.schema.x(e,t),y:s.cy-s.height/2-this.schema.y(e,t)}:null},this.schema.labelConfig=Object.assign(this.schema.labelConfig,{textAnchor:"middle",verticalAlign:"middle"}),this.schema.x=F("x"),this.schema.x0=F("x"),this.schema.x1=null,this.schema.y=L(0),this.schema.y0=L(0),this.schema.y1=F("y")}}
1069
- /** Bar's own fluent accessor schema, layered on top of Shape's. */const Ie=[{key:"height",coerce:"accessor",default:L(10)},{key:"width",coerce:"accessor",default:L(10)}];class qe extends He{
1119
+ */constructor(){super(),re(this,Ie),this._name="Area",this.schema.labelBounds=(e,t,i)=>{const s=p.largestRect(i.points);return s?{angle:s.angle,width:s.width,height:s.height,x:s.cx-s.width/2-this.schema.x(e,t),y:s.cy-s.height/2-this.schema.y(e,t)}:null},this.schema.labelConfig=Object.assign(this.schema.labelConfig,{textAnchor:"middle",verticalAlign:"middle"}),this.schema.x=F("x"),this.schema.x0=F("x"),this.schema.x1=null,this.schema.y=L(0),this.schema.y0=L(0),this.schema.y1=F("y")}}
1120
+ /** Bar's own fluent accessor schema, layered on top of Shape's. */const Ye=[{key:"height",coerce:"accessor",default:L(10)},{key:"width",coerce:"accessor",default:L(10)}];class Ke extends Ge{
1070
1121
  // v4: render() is inherited from Shape — the scene path handles drawing.
1071
1122
  /**
1072
1123
  Returns the bar geometry for a data point, matching _applyPosition: width/height
@@ -1107,13 +1158,13 @@ _sceneGeometry(e,t){const i=this._getWidth(e,t),s=this._getHeight(e,t);return{ty
1107
1158
  /**
1108
1159
  Invoked when creating a new class instance, and overrides any default parameters inherited from Shape.
1109
1160
  @private
1110
- */constructor(){super("rect"),re(this,Ie),this._name="Bar",this.schema.labelBounds=(e,t,i)=>({width:i.width,height:i.height,x:null!==this.schema.x1?this._getX(e,t):-i.width/2,y:null===this.schema.x1?this._getY(e,t):-i.height/2}),
1161
+ */constructor(){super("rect"),re(this,Ye),this._name="Bar",this.schema.labelBounds=(e,t,i)=>({width:i.width,height:i.height,x:null!==this.schema.x1?this._getX(e,t):-i.width/2,y:null===this.schema.x1?this._getY(e,t):-i.height/2}),
1111
1162
  // Bar labels are horizontally centered inside their bar (vs. Shape's
1112
1163
  // "start" default used by Treemap/Pie/etc.). Pre-merged into the
1113
1164
  // Shape.labelConfig defaults so plotPaint's userConfig override
1114
1165
  // path doesn't have to know about it.
1115
1166
  Object.assign(this.schema.labelConfig,{textAnchor:"middle"}),this.schema.x=F("x"),this.schema.x0=F("x"),this.schema.x1=null,this.schema.y=L(0),this.schema.y0=L(0),this.schema.y1=F("y")}}
1116
- /** Circle's own fluent accessor schema, layered on top of Shape's. */const Ye=[{key:"r",coerce:"accessor",default:F("r")},
1167
+ /** Circle's own fluent accessor schema, layered on top of Shape's. */const Ve=[{key:"r",coerce:"accessor",default:F("r")},
1117
1168
  // Motion-trail toggle: when true, the animate layer sweeps a tapering cone
1118
1169
  // behind each point as it moves between frames (Timeline play), on both the
1119
1170
  // SVG and Canvas backends.
@@ -1123,7 +1174,7 @@ Object.assign(this.schema.labelConfig,{textAnchor:"middle"}),this.schema.x=F("x"
1123
1174
  // keeps a long slowly-fading tail. Requires `trail: true`. Setting it also
1124
1175
  // makes the chart use a single-period timeline + fixed axes automatically
1125
1176
  // (see vizPreDraw) — the conditions a persistent trail needs to stay coherent.
1126
- {key:"trailPersist",coerce:"identity",default:0}];class Ke extends He{
1177
+ {key:"trailPersist",coerce:"identity",default:0}];class Xe extends Ge{
1127
1178
  /**
1128
1179
  Provides the default positioning to the <rect> elements.
1129
1180
  @private
@@ -1144,7 +1195,7 @@ _sceneGeometry(e,t){return{type:"circle",cx:0,cy:0,r:Number(this.schema.r(e,t)),
1144
1195
  /**
1145
1196
  Invoked when creating a new class instance, and overrides any default parameters inherited from Shape.
1146
1197
  @private
1147
- */constructor(){super("circle"),re(this,Ye),this._name="Circle",
1198
+ */constructor(){super("circle"),re(this,Ve),this._name="Circle",
1148
1199
  // Bound the label to the full circle (diameter box) and tag it
1149
1200
  // `shape: "circle"`, so the label TextBox flows text as circle chords —
1150
1201
  // lines fill the interior, shorter near the top and bottom and full width
@@ -1153,7 +1204,7 @@ _sceneGeometry(e,t){return{type:"circle",cx:0,cy:0,r:Number(this.schema.r(e,t)),
1153
1204
  // chart that repositions the label with its own `labelBounds` (e.g. Tree's
1154
1205
  // external node labels) gets ordinary rectangular wrapping.
1155
1206
  this.schema.labelBounds=(e,t,i)=>({width:2*i.r,height:2*i.r,x:-i.r,y:-i.r,shape:"circle"}),this.schema.labelConfig=n.assign(this.schema.labelConfig,{textAnchor:"middle",verticalAlign:"middle"})}}
1156
- /** Rect's own fluent accessor schema, layered on top of Shape's. */const Xe=[{key:"height",coerce:"accessor",default:F("height")},
1207
+ /** Rect's own fluent accessor schema, layered on top of Shape's. */const Ue=[{key:"height",coerce:"accessor",default:F("height")},
1157
1208
  // Motion-trail toggle: when true, the animate layer sweeps a tapering cone
1158
1209
  // behind each rect as it moves between frames (Timeline play), sized to the
1159
1210
  // rect's silhouette perpendicular to travel — so a square at 45° trails
@@ -1162,7 +1213,7 @@ this.schema.labelBounds=(e,t,i)=>({width:2*i.r,height:2*i.r,x:-i.r,y:-i.r,shape:
1162
1213
  // Persistent-trail length (see Circle): 0 = ephemeral, a number keeps that
1163
1214
  // many past segments, `true` keeps a long fading tail. Requires `trail: true`;
1164
1215
  // setting it auto-switches the chart to a single-period timeline + fixed axes.
1165
- {key:"trailPersist",coerce:"identity",default:0},{key:"width",coerce:"accessor",default:F("width")}];class Ve extends He{
1216
+ {key:"trailPersist",coerce:"identity",default:0},{key:"width",coerce:"accessor",default:F("width")}];class Je extends Ge{
1166
1217
  // v4: render() is inherited from Shape — the scene path handles drawing.
1167
1218
  /**
1168
1219
  Returns the rect geometry for a data point, matching _applyPosition: the
@@ -1182,8 +1233,8 @@ _sceneGeometry(e,t){const i=Number(this.schema.width(e,t)),s=Number(this.schema.
1182
1233
  /**
1183
1234
  Invoked when creating a new class instance, and overrides any default parameters inherited from Shape.
1184
1235
  @private
1185
- */constructor(){super("rect"),re(this,Xe),this._name="Rect",this.schema.labelBounds=(e,t,i)=>({width:i.width,height:i.height,x:-i.width/2,y:-i.height/2})}}
1186
- /** Line's own fluent accessor schema, layered on top of Shape's. */const Ue=[{key:"curve",coerce:"const",default:L("linear")},{key:"defined",coerce:"identity",default:e=>e}];class Je extends He{
1236
+ */constructor(){super("rect"),re(this,Ue),this._name="Rect",this.schema.labelBounds=(e,t,i)=>({width:i.width,height:i.height,x:-i.width/2,y:-i.height/2})}}
1237
+ /** Line's own fluent accessor schema, layered on top of Shape's. */const Qe=[{key:"curve",coerce:"const",default:L("linear")},{key:"defined",coerce:"identity",default:e=>e}];class Ze extends Ge{
1187
1238
  /**
1188
1239
  Filters/manipulates the data array before binding each point to an SVG group.
1189
1240
  @param data @private
@@ -1203,10 +1254,10 @@ _dataFilter(e){const i=t.groups(e,this.schema.id).map(([i,n])=>{const a={key:i,v
1203
1254
  /**
1204
1255
  Invoked when creating a new class instance, and overrides any default parameters inherited from Shape.
1205
1256
  @private
1206
- */constructor(){super(),re(this,Ue),this._name="Line",this._path=P.line(),
1257
+ */constructor(){super(),re(this,Qe),this._name="Line",this._path=P.line(),
1207
1258
  // Line-specific overrides of inherited Shape defaults.
1208
- this.schema.fill=L("none"),this.schema.stroke=L("black"),this.schema.strokeWidth=L(1),this.schema.hitArea=L({d:e=>this._path(e.values),fill:"none","stroke-width":10,transform:null})}}const Qe={Circle:Ke,Rect:Ve},Ze=[{key:"duration",coerce:"identity",default:600},{key:"endpoint",coerce:"const",default:F("endpoint","Rect")},{key:"length",coerce:"const",default:F("length",25)},{key:"orient",coerce:"const",default:F("orient","top")},{key:"renderMode",coerce:"identity",default:"full"},{key:"x",coerce:"const",default:F("x",0)},{key:"y",coerce:"const",default:F("y",0)}];
1209
- /** Whisker's fluent accessor schema. Config storage lives on `this.schema.<key>`. */class et extends j{
1259
+ this.schema.fill=L("none"),this.schema.stroke=L("black"),this.schema.strokeWidth=L(1),this.schema.hitArea=L({d:e=>this._path(e.values),fill:"none","stroke-width":10,transform:null})}}const et={Circle:Xe,Rect:Je},tt=[{key:"duration",coerce:"identity",default:600},{key:"endpoint",coerce:"const",default:F("endpoint","Rect")},{key:"length",coerce:"const",default:F("length",25)},{key:"orient",coerce:"const",default:F("orient","top")},{key:"renderMode",coerce:"identity",default:"full"},{key:"x",coerce:"const",default:F("x",0)},{key:"y",coerce:"const",default:F("y",0)}];
1260
+ /** Whisker's fluent accessor schema. Config storage lives on `this.schema.<key>`. */class it extends j{
1210
1261
  /**
1211
1262
  Draws the whisker.
1212
1263
  @param callback Optional callback invoked after rendering completes.
@@ -1215,9 +1266,9 @@ render(e){const s="compute"===this.schema.renderMode;void 0!==this._select||s||t
1215
1266
  // Draw whisker line. Don't pass `callback` to the inner Line —
1216
1267
  // doing so would fire the caller's done-callback after the LINE
1217
1268
  // finished but BEFORE endpoint shapes (below) are rendered.
1218
- this._line=(new Je).data(o).renderMode(s?"compute":"full").select(a("g.d3plus-Whisker")).config(G.bind(this)(this.schema.lineConfig,"shape")).render();const r=this._data.map((e,t)=>{const i={__d3plus__:!0};i.data=e,i.i=t,i.endpoint=this.schema.endpoint(e,t),i.length=this.schema.length(e,t),i.orient=this.schema.orient(e,t);let s=this.schema.x(e,t);"left"===i.orient?s-=i.length:"right"===i.orient&&(s+=i.length);let n=this.schema.y(e,t);return"top"===i.orient?n-=i.length:"bottom"===i.orient&&(n+=i.length),i.x=s,i.y=n,i});
1269
+ this._line=(new Ze).data(o).renderMode(s?"compute":"full").select(a("g.d3plus-Whisker")).config(G.bind(this)(this.schema.lineConfig,"shape")).render();const r=this._data.map((e,t)=>{const i={__d3plus__:!0};i.data=e,i.i=t,i.endpoint=this.schema.endpoint(e,t),i.length=this.schema.length(e,t),i.orient=this.schema.orient(e,t);let s=this.schema.x(e,t);"left"===i.orient?s-=i.length:"right"===i.orient&&(s+=i.length);let n=this.schema.y(e,t);return"top"===i.orient?n-=i.length:"bottom"===i.orient&&(n+=i.length),i.x=s,i.y=n,i});
1219
1270
  // Draw whisker endpoint.
1220
- return this._whiskerEndpoint=[],t.groups(r,e=>e.endpoint).forEach(([e,t])=>{this._whiskerEndpoint.push((new Qe[e]).data(t).renderMode(s?"compute":"full").select(a(`g.d3plus-Whisker-Endpoint-${e}`)).config({height:e=>"top"===e.orient||"bottom"===e.orient?5:20,width:e=>"top"===e.orient||"bottom"===e.orient?20:5}).config(G.bind(this)(this.schema.endpointConfig,"shape",e)).render())}),
1271
+ return this._whiskerEndpoint=[],t.groups(r,e=>e.endpoint).forEach(([e,t])=>{this._whiskerEndpoint.push((new et[e]).data(t).renderMode(s?"compute":"full").select(a(`g.d3plus-Whisker-Endpoint-${e}`)).config({height:e=>"top"===e.orient||"bottom"===e.orient?5:20,width:e=>"top"===e.orient||"bottom"===e.orient?20:5}).config(G.bind(this)(this.schema.endpointConfig,"shape",e)).render())}),
1221
1272
  // Fire the user's done-callback only after endpoints render. The inner
1222
1273
  // shapes don't share one transition queue, so schedule against
1223
1274
  // `duration + 100`.
@@ -1236,7 +1287,7 @@ e&&setTimeout(e,this.schema.duration+100),this}
1236
1287
  /**
1237
1288
  Invoked when creating a new class instance, and overrides any default parameters inherited from BaseClass.
1238
1289
  @private
1239
- */constructor(){super(),re(this,Ze),this.schema.endpointConfig={Circle:{r:F("r",5)}},this.schema.lineConfig={},this._whiskerEndpoint=[]}}const tt={Circle:Ke,Rect:Ve},it=e=>"function"==typeof e?e:F(e),st=[{key:"orient",coerce:"const",default:F("orient","vertical")},{key:"outlier",coerce:"const",default:F("outlier","Circle")},{key:"rectWidth",coerce:"const",default:L(50)},{key:"renderMode",coerce:"identity",default:"full"},{key:"whiskerMode",coerce:e=>Array.isArray(e)?e:[e,e],default:["tukey","tukey"]},{key:"x",coerce:it,default:F("x",250)},{key:"y",coerce:it,default:F("y",250)}];
1290
+ */constructor(){super(),re(this,tt),this.schema.endpointConfig={Circle:{r:F("r",5)}},this.schema.lineConfig={},this._whiskerEndpoint=[]}}const st={Circle:Xe,Rect:Je},nt=e=>"function"==typeof e?e:F(e),at=[{key:"orient",coerce:"const",default:F("orient","vertical")},{key:"outlier",coerce:"const",default:F("outlier","Circle")},{key:"rectWidth",coerce:"const",default:L(50)},{key:"renderMode",coerce:"identity",default:"full"},{key:"whiskerMode",coerce:e=>Array.isArray(e)?e:[e,e],default:["tukey","tukey"]},{key:"x",coerce:nt,default:F("x",250)},{key:"y",coerce:nt,default:F("y",250)}];
1240
1291
  // Box's x/y setters wrap every non-function (including numbers) in
1241
1292
  // `accessor(...)`, unlike the "accessor" coerce which would `constant(...)`
1242
1293
  // a non-string — so a custom coerce preserves the exact behavior.
@@ -1244,7 +1295,7 @@ e&&setTimeout(e,this.schema.duration+100),this}
1244
1295
  Computes the box statistics (quartiles, limits, geometry) for a single
1245
1296
  orientation group and appends any outliers to `outlierData`.
1246
1297
  */
1247
- function nt(e,i,n,a){const o={key:i,values:n};o.data=s.merge(o.values),o.i=e._data.indexOf(o.values[0]),o.orient=e.schema.orient(o.data,o.i);const r=o.values.map("vertical"===o.orient?e.schema.y:e.schema.x);r.sort((e,t)=>e-t),o.first=t.quantile(r,.25),o.median=t.quantile(r,.5),o.third=t.quantile(r,.75);!
1298
+ function ot(e,i,n,a){const o={key:i,values:n};o.data=s.merge(o.values),o.i=e._data.indexOf(o.values[0]),o.orient=e.schema.orient(o.data,o.i);const r=o.values.map("vertical"===o.orient?e.schema.y:e.schema.x);r.sort((e,t)=>e-t),o.first=t.quantile(r,.25),o.median=t.quantile(r,.5),o.third=t.quantile(r,.75);!
1248
1299
  /**
1249
1300
  Resolves the lower/upper whisker limits on `d` from the configured
1250
1301
  whiskerMode (tukey/extent/quantile) and the sorted group values.
@@ -1260,7 +1311,7 @@ function(e,t,i){t.values.forEach((s,n)=>{const a="vertical"===t.orient?e.schema.
1260
1311
  /**
1261
1312
  Builds the whisker startpoint coordinates (two per box) from the computed
1262
1313
  box geometry.
1263
- */class at extends j{
1314
+ */class rt extends j{
1264
1315
  /**
1265
1316
  Draws the Box.
1266
1317
  */
@@ -1268,18 +1319,18 @@ render(){const e="compute"===this.schema.renderMode;void 0!==this._select||e||th
1268
1319
  // Compute-mode helper: mount inner shapes scene-only (no parent
1269
1320
  // group needed). `select(null)` is the formal "no mount" signal —
1270
1321
  // Shape.render() honors it as long as renderMode is "compute".
1271
- const s=t=>e?null:n.elem(t,{parent:this._select}).node(),a=[],o=t.groups(this._data,(e,t)=>"vertical"===this.schema.orient(e,t)?this.schema.x(e,t):this.schema.y(e,t)).map(([e,t])=>nt(this,e,t,a));
1322
+ const s=t=>e?null:n.elem(t,{parent:this._select}).node(),a=[],o=t.groups(this._data,(e,t)=>"vertical"===this.schema.orient(e,t)?this.schema.x(e,t):this.schema.y(e,t)).map(([e,t])=>ot(this,e,t,a));
1272
1323
  // Draw box.
1273
- this._box=(new Ve).data(o).x(e=>e.x).y(e=>e.y).renderMode(e?"compute":"full").select(s("g.d3plus-Box")).config(G.bind(this)(this.schema.rectConfig,"shape")).render(),
1324
+ this._box=(new Je).data(o).x(e=>e.x).y(e=>e.y).renderMode(e?"compute":"full").select(s("g.d3plus-Box")).config(G.bind(this)(this.schema.rectConfig,"shape")).render(),
1274
1325
  // Draw median.
1275
- this._median=(new Ve).data(o).x(e=>"vertical"===e.orient?e.x:e.median).y(e=>"vertical"===e.orient?e.median:e.y).height(e=>"vertical"===e.orient?1:e.height).width(e=>"vertical"===e.orient?e.width:1).renderMode(e?"compute":"full").select(s("g.d3plus-Box-Median")).config(G.bind(this)(this.schema.medianConfig,"shape")).render();
1326
+ this._median=(new Je).data(o).x(e=>"vertical"===e.orient?e.x:e.median).y(e=>"vertical"===e.orient?e.median:e.y).height(e=>"vertical"===e.orient?1:e.height).width(e=>"vertical"===e.orient?e.width:1).renderMode(e?"compute":"full").select(s("g.d3plus-Box-Median")).config(G.bind(this)(this.schema.medianConfig,"shape")).render();
1276
1327
  // Draw 2 lines using Whisker class.
1277
1328
  // Construct coordinates for whisker startpoints and push it to the whiskerData.
1278
1329
  const r=function(e){const t=[];return e.forEach((e,i)=>{const s=e.x,n=e.y,a=e.first-e.lowerLimit,o=e.upperLimit-e.third;if("vertical"===e.orient){const r=n-e.height/2,c=n+e.height/2;t.push({__d3plus__:!0,data:e,i:i,x:s,y:r,length:a,orient:"top"},{__d3plus__:!0,data:e,i:i,x:s,y:c,length:o,orient:"bottom"})}else if("horizontal"===e.orient){const r=s+e.width/2,c=s-e.width/2;t.push({__d3plus__:!0,data:e,i:i,x:r,y:n,length:o,orient:"right"},{__d3plus__:!0,data:e,i:i,x:c,y:n,length:a,orient:"left"})}}),t}(o);
1279
1330
  // Draw whiskers.
1280
- return this._whisker=(new et).data(r).renderMode(e?"compute":"full").select(s("g.d3plus-Box-Whisker")).config(G.bind(this)(this.schema.whiskerConfig,"shape")).render(),
1331
+ return this._whisker=(new it).data(r).renderMode(e?"compute":"full").select(s("g.d3plus-Box-Whisker")).config(G.bind(this)(this.schema.whiskerConfig,"shape")).render(),
1281
1332
  // Draw outliers.
1282
- this._whiskerEndpoint=[],t.groups(a,e=>e.outlier).forEach(([t,i])=>{this._whiskerEndpoint.push((new tt[t]).data(i).renderMode(e?"compute":"full").select(s(`g.d3plus-Box-Outlier-${t}`)).config(G.bind(this)(this.schema.outlierConfig,"shape",t)).render())}),this}
1333
+ this._whiskerEndpoint=[],t.groups(a,e=>e.outlier).forEach(([t,i])=>{this._whiskerEndpoint.push((new st[t]).data(i).renderMode(e?"compute":"full").select(s(`g.d3plus-Box-Outlier-${t}`)).config(G.bind(this)(this.schema.outlierConfig,"shape",t)).render())}),this}
1283
1334
  /**
1284
1335
  Compute-mode scene aggregation. When Box is rendered with
1285
1336
  `renderMode("compute")`, the inner Rect/Whisker/Circle/etc.
@@ -1296,8 +1347,28 @@ this._whiskerEndpoint=[],t.groups(a,e=>e.outlier).forEach(([t,i])=>{this._whiske
1296
1347
  /**
1297
1348
  Invoked when creating a new class instance, and overrides any default parameters inherited from BaseClass.
1298
1349
  @private
1299
- */constructor(){super(),re(this,st),this.schema.medianConfig={fill:L("black")},this.schema.outlierConfig={Circle:{r:F("r",5)},Rect:{height:(e,t)=>"vertical"===this.schema.orient(e,t)?5:20,width:(e,t)=>"vertical"===this.schema.orient(e,t)?20:5}},this.schema.rectConfig={fill:L("white"),stroke:L("black"),strokeWidth:L(1)},this.schema.whiskerConfig={},this._whiskerEndpoint=[]}}
1300
- /** Path's own fluent accessor schema, layered on top of Shape's. */const ot=[{key:"d",coerce:"const",default:F("path")}];class rt extends He{
1350
+ */constructor(){super(),re(this,at),this.schema.medianConfig={fill:L("black")},this.schema.outlierConfig={Circle:{r:F("r",5)},Rect:{height:(e,t)=>"vertical"===this.schema.orient(e,t)?5:20,width:(e,t)=>"vertical"===this.schema.orient(e,t)?20:5}},this.schema.rectConfig={fill:L("white"),stroke:L("black"),strokeWidth:L(1)},this.schema.whiskerConfig={},this._whiskerEndpoint=[]}}
1351
+ /** Image's fluent accessor schema. Config storage lives on `this.schema.<key>`. */const ct=[{key:"duration",coerce:"identity",default:600},{key:"height",coerce:"accessor",default:F("height")},{key:"id",coerce:"identity",default:F("id")},{key:"opacity",coerce:"const",default:L(1)},{key:"pointerEvents",coerce:"const",default:L("auto")},{key:"renderMode",coerce:"identity",default:"full"},{key:"url",coerce:"identity",default:F("url")},{key:"width",coerce:"accessor",default:F("width")},{key:"x",coerce:"const",default:F("x",0)},{key:"y",coerce:"const",default:F("y",0)}];class ht{config(e){if(!arguments.length)return{...this.schema,data:this._data,select:this._select};const t=e;for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(
1352
+ // `this[k]` resolves the fluent accessor via the index signature.
1353
+ "function"==typeof this[e]?this[e](t[e]):this.schema[e]=t[e]);return this}
1354
+ /**
1355
+ Renders the current Image to the page. If a *callback* is specified, it will be called once the images are done drawing.
1356
+ @param callback Optional callback invoked after rendering completes.
1357
+ */render(e){
1358
+ // Compute mode is a no-op for DOM emission — the caller will read
1359
+ // `toScene()` to get a SceneNode tree, no need to mount.
1360
+ if("compute"===this.schema.renderMode)return e&&setTimeout(e,0),this;void 0===this._select&&this.select(i.select("body").append("svg").style("width",`${window.innerWidth}px`).style("height",`${window.innerHeight}px`).style("display","block").node());const t=this._select.selectAll(".d3plus-Image").data(this._data,this.schema.id),s=t.enter().append("image").attr("class","d3plus-Image").attr("opacity",0).attr("width",0).attr("height",0).attr("x",(e,t)=>this.schema.x(e,t)+this.schema.width(e,t)/2).attr("y",(e,t)=>this.schema.y(e,t)+this.schema.height(e,t)/2),n=g.transition().duration(this.schema.duration),a=this;return s.merge(t).attr("xlink:href",this.schema.url).style("pointer-events",this.schema.pointerEvents).transition(n).attr("opacity",this.schema.opacity).attr("width",(e,t)=>this.schema.width(e,t)).attr("height",(e,t)=>this.schema.height(e,t)).attr("x",(e,t)=>this.schema.x(e,t)).attr("y",(e,t)=>this.schema.y(e,t)).each(function(e,t){const s=i.select(this),n=a.schema.url(e,t);if(!(0===n.indexOf("http://")||0===n.indexOf("https://"))||0===n.indexOf(window.location.hostname)){const e=new window.Image;e.src=n,e.crossOrigin="Anonymous",e.onload=function(){const t=document.createElement("canvas");t.width=e.width,t.height=e.height;t.getContext("2d").drawImage(e,0,0),s.attr("xlink:href",t.toDataURL("image/png"))}}}),t.exit().transition(n).attr("width",(e,t)=>this.schema.width(e,t)).attr("height",(e,t)=>this.schema.height(e,t)).attr("x",(e,t)=>this.schema.x(e,t)).attr("y",(e,t)=>this.schema.y(e,t)).attr("opacity",0).remove(),e&&setTimeout(e,this.schema.duration+100),this}data(e){return arguments.length?(this._data=e,this):this._data}
1361
+ /**
1362
+ Compute-mode scene emission. Mirrors Shape.toScene's shape — a
1363
+ keyed GroupNode wrapping per-datum ImageNodes. Used by chart
1364
+ compositors (e.g. plotPaint) that need Image to participate in the
1365
+ scene graph rather than emit d3-selection DOM.
1366
+ */toScene(){return{type:"group",key:"d3plus-Image",children:(this._data||[]).map((e,t)=>({type:"image",key:`${this.schema.id(e,t)}`,x:this.schema.x(e,t),y:this.schema.y(e,t),width:this.schema.width(e,t),height:this.schema.height(e,t),href:this.schema.url(e,t),paint:{opacity:this.schema.opacity(e,t)},datum:e,index:t}))}}select(e){return arguments.length?(this._select=i.select(e),this):this._select}
1367
+ /**
1368
+ Invoked when creating a new class instance, and sets any default parameters.
1369
+ @private
1370
+ */constructor(){re(this,ct)}}
1371
+ /** Path's own fluent accessor schema, layered on top of Shape's. */const lt=[{key:"d",coerce:"const",default:F("path")}];class dt extends Ge{
1301
1372
  /**
1302
1373
  Returns the path geometry for a data point (the raw "d" string).
1303
1374
  @private
@@ -1307,27 +1378,27 @@ _sceneGeometry(e,t){return{type:"path",d:String(this.schema.d(e,t))}}
1307
1378
  Given a specific data point and index, returns the aesthetic properties of the shape.
1308
1379
  @param data point*
1309
1380
  @param index @private
1310
- */_aes(e,t){return{points:y.path2polygon(this.schema.d(e,t))}}config(e){return arguments.length?(super.config(e),this):super.config()}
1381
+ */_aes(e,t){return{points:p.path2polygon(this.schema.d(e,t))}}config(e){return arguments.length?(super.config(e),this):super.config()}
1311
1382
  /**
1312
1383
  Invoked when creating a new class instance, and overrides any default parameters inherited from Shape.
1313
1384
  @private
1314
- */constructor(){super("path"),re(this,ot),this._name="Path",this.schema.labelBounds=(e,t,i)=>{const s=this.schema.labelConfig.rotate,n=y.largestRect(i.points,{angle:s?s(e,t):0});return!!n&&{angle:n.angle,width:n.width,height:n.height,x:n.cx-n.width/2,y:n.cy-n.height/2}},this.schema.labelConfig=Object.assign(this.schema.labelConfig,{textAnchor:"middle",verticalAlign:"middle"})}}var ct=Object.freeze({__proto__:null,Area:Ge,Bar:qe,Box:at,Circle:Ke,Image:Re,Line:Je,Path:rt,Rect:Ve,Shape:He,Whisker:et});
1315
- /* catches for -0 and less*/const ht=e=>e<0||Object.is(e,-0),lt=e=>Math.pow(10,Math.floor(Math.log10(Math.abs(e))))*Math.pow(-1,ht(e)?1:0),dt=e=>Math.pow(10,Math.ceil(Math.log10(Math.abs(e))))*Math.pow(-1,ht(e)?1:0),ut=e=>{const t=`${e}`;if(t.includes("e-")||"0"===t)return 0;const i=t.match(/(-*[0-9]+\.[0]*)([0-8]+)9{3,}[0-9]+$/);if(i)return+`${i[1]}${+i[2]+1}`;const s=t.match(/(-*[0-9]+\.[0]*)([1-9]+)0*[0-9]*0{3,}[0-9]+$/);return s?+`${s[1]}${+s[2]}`:e},mt=936e5;
1385
+ */constructor(){super("path"),re(this,lt),this._name="Path",this.schema.labelBounds=(e,t,i)=>{const s=this.schema.labelConfig.rotate,n=p.largestRect(i.points,{angle:s?s(e,t):0});return!!n&&{angle:n.angle,width:n.width,height:n.height,x:n.cx-n.width/2,y:n.cy-n.height/2}},this.schema.labelConfig=Object.assign(this.schema.labelConfig,{textAnchor:"middle",verticalAlign:"middle"})}}var ut=Object.freeze({__proto__:null,Area:qe,Bar:Ke,Box:rt,Circle:Xe,Image:ht,Line:Ze,Path:dt,Rect:Je,Shape:Ge,Whisker:it});
1386
+ /* catches for -0 and less*/const mt=e=>e<0||Object.is(e,-0),ft=e=>Math.pow(10,Math.floor(Math.log10(Math.abs(e))))*Math.pow(-1,mt(e)?1:0),gt=e=>Math.pow(10,Math.ceil(Math.log10(Math.abs(e))))*Math.pow(-1,mt(e)?1:0),pt=e=>{const t=`${e}`;if(t.includes("e-")||"0"===t)return 0;const i=t.match(/(-*[0-9]+\.[0]*)([0-8]+)9{3,}[0-9]+$/);if(i)return+`${i[1]}${+i[2]+1}`;const s=t.match(/(-*[0-9]+\.[0]*)([1-9]+)0*[0-9]*0{3,}[0-9]+$/);return s?+`${s[1]}${+s[2]}`:e},yt=936e5;
1316
1387
  /**
1317
1388
  * Calculates ticks from a given scale (negative and/or positive)
1318
1389
  * @param {scale} scale A d3-scale object
1319
1390
  * @private
1320
1391
  */
1321
- function ft(e,i=!1){const s=B.scaleLinear().domain([200,1200]).range([8,28]),n=e.range(),a=Math.abs(n[1]-n[0]);let o=Math.floor(s(a));if("time"===this.schema.scale)if(this._data&&this._data.length){const e=t.extent(this._data),s=this._data.reduce((e,t,i,s)=>{if(i){const n=Math.abs(t-s[i-1]);n<e&&(e=n)}return e},1/0),n=Math.round((e[1]-e[0])/s);o=t.min([o*(i?2:.5),n])}else o=i?2*o:o/2;return Math.floor(o)}
1392
+ function _t(e,i=!1){const s=B.scaleLinear().domain([200,1200]).range([8,28]),n=e.range(),a=Math.abs(n[1]-n[0]);let o=Math.floor(s(a));if("time"===this.schema.scale)if(this._data&&this._data.length){const e=t.extent(this._data),s=this._data.reduce((e,t,i,s)=>{if(i){const n=Math.abs(t-s[i-1]);n<e&&(e=n)}return e},1/0),n=Math.round((e[1]-e[0])/s);o=t.min([o*(i?2:.5),n])}else o=i?2*o:o/2;return Math.floor(o)}
1322
1393
  /**
1323
1394
  * Calculates ticks from a given scale (negative and/or positive)
1324
1395
  * @param {scale} scale A d3-scale object
1325
1396
  * @private
1326
- */function gt(e,i=!1){let s=[];const n=e.copy();if("time"===this.schema.scale&&this._data.length){const i=t.extent(this._data),s=i.map(t=>e(t));n.domain(i).range(s)}const a=n.domain(),o=a[1]<a[0],r=ft.bind(this)(n,i);if(i||"log"!==this.schema.scale){if(s=n.ticks(r),!i&&!["log","time"].includes(this.schema.scale)&&s.length>1){const e=Math.abs(2*ut(s[1]-s[0]));s=s.filter(t=>{const i=Math.abs(t)%e,s=ut(i);return s!==i?!s||s===e:0===i})}}else{const e=a.map(e=>Math.log10(e)%1==0?e:(o?dt:lt)(e)),i=e[1]<e[0],c=e.map(e=>(ht(e)?-1:1)*([-1,1].includes(e)||Math.abs(e)<1?1:Math.log10(Math.abs(e)))),h=Math.ceil((Math.abs(c[1]-c[0])+1)/(.65*r));s=h<=1&&c[0]===c[1]||i!==o?n.ticks(r).filter(e=>+`${e}`.replace("0.","")%2==0):t.range(c[0],c[1],c[1]<c[0]?-1:1).concat([c[1]]).filter(e=>Math.abs(e)%h===0).map(e=>+(""+(ht(e)?-1:1)*(e?Math.pow(10,Math.abs(e)):Math.sign(1/e)>0?1:-1)).replace(/9+/g,"1"))}
1397
+ */function xt(e,i=!1){let s=[];const n=e.copy();if("time"===this.schema.scale&&this._data.length){const i=t.extent(this._data),s=i.map(t=>e(t));n.domain(i).range(s)}const a=n.domain(),o=a[1]<a[0],r=_t.bind(this)(n,i);if(i||"log"!==this.schema.scale){if(s=n.ticks(r),!i&&!["log","time"].includes(this.schema.scale)&&s.length>1){const e=Math.abs(2*pt(s[1]-s[0]));s=s.filter(t=>{const i=Math.abs(t)%e,s=pt(i);return s!==i?!s||s===e:0===i})}}else{const e=a.map(e=>Math.log10(e)%1==0?e:(o?gt:ft)(e)),i=e[1]<e[0],c=e.map(e=>(mt(e)?-1:1)*([-1,1].includes(e)||Math.abs(e)<1?1:Math.log10(Math.abs(e)))),h=Math.ceil((Math.abs(c[1]-c[0])+1)/(.65*r));s=h<=1&&c[0]===c[1]||i!==o?n.ticks(r).filter(e=>+`${e}`.replace("0.","")%2==0):t.range(c[0],c[1],c[1]<c[0]?-1:1).concat([c[1]]).filter(e=>Math.abs(e)%h===0).map(e=>+(""+(mt(e)?-1:1)*(e?Math.pow(10,Math.abs(e)):Math.sign(1/e)>0?1:-1)).replace(/9+/g,"1"))}
1327
1398
  // for time scale, if data array has been provided, filter out ticks that are not in the array
1328
- if("time"===this.schema.scale&&this._data.length){const e=this._data.map(Number);s=s.filter(t=>{const i=+t;return e.find(e=>e>=i-mt&&e<=i+mt)})}
1399
+ if("time"===this.schema.scale&&this._data.length){const e=this._data.map(Number);s=s.filter(t=>{const i=+t;return e.find(e=>e>=i-yt&&e<=i+yt)})}
1329
1400
  // forces min/max into ticks, if not present
1330
- return this._d3ScaleNegative&&ht(a[o?1:0])!==s.some(e=>ht(e))||s.map(Number).includes(+a[0])||s.unshift(a[0]),this._d3ScaleNegative&&ht(a[o?0:1])!==s.some(e=>ht(e))||s.map(Number).includes(+a[1])||s.push(a[1]),s}
1401
+ return this._d3ScaleNegative&&mt(a[o?1:0])!==s.some(e=>mt(e))||s.map(Number).includes(+a[0])||s.unshift(a[0]),this._d3ScaleNegative&&mt(a[o?0:1])!==s.some(e=>mt(e))||s.map(Number).includes(+a[1])||s.push(a[1]),s}
1331
1402
  /**
1332
1403
  Builds the per-tick config array consumed by the tick Shape. Extracted from
1333
1404
  `Axis.render` so the render method stays under the per-function line budget;
@@ -1338,7 +1409,7 @@ return this._d3ScaleNegative&&ht(a[o?1:0])!==s.some(e=>ht(e))||s.map(Number).inc
1338
1409
  Converts an attribute-style config (e.g. gridConfig, barConfig) into a Paint.
1339
1410
  @private
1340
1411
  */
1341
- function pt(e,t,i,s=0){
1412
+ function bt(e,t,i,s=0){
1342
1413
  // Resolve a config value that may be a function (d3-selection style
1343
1414
  // accessor invocation pattern) or a literal. Functions are evaluated
1344
1415
  // against the Axis instance and receive the datum + index, so per-line
@@ -1349,8 +1420,8 @@ const n=t=>{if("function"==typeof t)try{return t.call(e,i,s)}catch{return}return
1349
1420
  Replicates _gridPosition's math to compute each gridline's endpoints in the
1350
1421
  axis's internal coordinate space.
1351
1422
  @private
1352
- */const{theme:yt}=f,_t=[{key:"align",coerce:"identity",default:"middle"},{key:"domain",coerce:"identity",default:[0,10]},{key:"duration",coerce:"identity",default:600},{key:"grid",coerce:"identity"},{key:"gridLog",coerce:"identity",default:!1},{key:"gridSize",coerce:"identity"},{key:"height",coerce:"identity",default:400},{key:"labels",coerce:"identity"},{key:"labelOffset",coerce:"identity",default:!1},{key:"maxSize",coerce:"identity"},{key:"minSize",coerce:"identity"},{key:"padding",coerce:"identity",default:5},{key:"paddingInner",coerce:"identity",default:.1},{key:"paddingOuter",coerce:"identity",default:.1},{key:"range",coerce:"identity"},{key:"renderMode",coerce:"identity",default:"full"},{key:"rounding",coerce:"identity",default:"none"},{key:"roundingInsideMinPrefix",coerce:"identity",default:"< "},{key:"roundingInsideMinSuffix",coerce:"identity",default:""},{key:"roundingInsideMaxPrefix",coerce:"identity",default:""},{key:"roundingInsideMaxSuffix",coerce:"identity",default:"+"},{key:"scale",coerce:"identity",default:"linear"},{key:"scalePadding",coerce:"identity",default:.5},{key:"shape",coerce:"identity",default:"Line"},{key:"tickFormat",coerce:"identity"},{key:"ticks",coerce:"identity"},{key:"tickSize",coerce:"identity",default:8},{key:"tickSuffix",coerce:"identity",default:"normal"},{key:"timeLocale",coerce:"identity",default:void 0},{key:"title",coerce:"identity"},{key:"width",coerce:"identity",default:400}];
1353
- /** Axis's fluent accessor schema. Config storage lives on `this.schema.<key>`. */class xt extends j{
1423
+ */const{theme:kt}=f,vt=[{key:"align",coerce:"identity",default:"middle"},{key:"domain",coerce:"identity",default:[0,10]},{key:"duration",coerce:"identity",default:600},{key:"grid",coerce:"identity"},{key:"gridLog",coerce:"identity",default:!1},{key:"gridSize",coerce:"identity"},{key:"height",coerce:"identity",default:400},{key:"labels",coerce:"identity"},{key:"labelOffset",coerce:"identity",default:!1},{key:"maxSize",coerce:"identity"},{key:"minSize",coerce:"identity"},{key:"padding",coerce:"identity",default:5},{key:"paddingInner",coerce:"identity",default:.1},{key:"paddingOuter",coerce:"identity",default:.1},{key:"range",coerce:"identity"},{key:"renderMode",coerce:"identity",default:"full"},{key:"rounding",coerce:"identity",default:"none"},{key:"roundingInsideMinPrefix",coerce:"identity",default:"< "},{key:"roundingInsideMinSuffix",coerce:"identity",default:""},{key:"roundingInsideMaxPrefix",coerce:"identity",default:""},{key:"roundingInsideMaxSuffix",coerce:"identity",default:"+"},{key:"scale",coerce:"identity",default:"linear"},{key:"scalePadding",coerce:"identity",default:.5},{key:"shape",coerce:"identity",default:"Line"},{key:"tickFormat",coerce:"identity"},{key:"ticks",coerce:"identity"},{key:"tickSize",coerce:"identity",default:8},{key:"tickSuffix",coerce:"identity",default:"normal"},{key:"timeLocale",coerce:"identity",default:void 0},{key:"title",coerce:"identity"},{key:"width",coerce:"identity",default:400}];
1424
+ /** Axis's fluent accessor schema. Config storage lives on `this.schema.<key>`. */class Ct extends j{
1354
1425
  /**
1355
1426
  Returns the scale's domain, taking into account negative and positive log scales.
1356
1427
  @private
@@ -1359,7 +1430,7 @@ _getDomain(){let e=[];this._d3ScaleNegative&&(e=this._d3ScaleNegative.domain()),
1359
1430
  /**
1360
1431
  Returns a value's scale position, taking into account negative and positive log scales.
1361
1432
  @param d @private
1362
- */_getPosition(e){if("log"===this.schema.scale){if(0===e)return(this._d3Scale||this._d3ScaleNegative).range()[this._d3Scale?0:1];const t=ht(e)?this._d3ScaleNegative:this._d3Scale;return t?t(e):0}return this._d3Scale?this._d3Scale(e):0}
1433
+ */_getPosition(e){if("log"===this.schema.scale){if(0===e)return(this._d3Scale||this._d3ScaleNegative).range()[this._d3Scale?0:1];const t=mt(e)?this._d3ScaleNegative:this._d3Scale;return t?t(e):0}return this._d3Scale?this._d3Scale(e):0}
1363
1434
  /**
1364
1435
  Returns the scale's range, taking into account negative and positive log scales.
1365
1436
  @private
@@ -1367,7 +1438,7 @@ _getDomain(){let e=[];this._d3ScaleNegative&&(e=this._d3ScaleNegative.domain()),
1367
1438
  /**
1368
1439
  Returns the scale's labels, taking into account negative and positive log scales.
1369
1440
  @private
1370
- */_getLabels(){let e=[];if(this._d3ScaleNegative&&(e=e.concat(gt.bind(this)(this._d3ScaleNegative,!1))),this._d3Scale&&(e=e.concat(gt.bind(this)(this._d3Scale,!1))),"log"===this.schema.scale){if(e.some(e=>ht(e))&&e.some(e=>e>0)){const i=t.min([...this._d3ScaleNegative.domain().map(Math.abs),...this._d3Scale.domain()]);
1441
+ */_getLabels(){let e=[];if(this._d3ScaleNegative&&(e=e.concat(xt.bind(this)(this._d3ScaleNegative,!1))),this._d3Scale&&(e=e.concat(xt.bind(this)(this._d3Scale,!1))),"log"===this.schema.scale){if(e.some(e=>mt(e))&&e.some(e=>e>0)){const i=t.min([...this._d3ScaleNegative.domain().map(Math.abs),...this._d3Scale.domain()]);
1371
1442
  // add minValue if it does not exist, and should
1372
1443
  e.includes(i)||e.splice(e.findIndex(e=>e>i),0,i),
1373
1444
  // remove -minValue if minValue also exists
@@ -1375,7 +1446,7 @@ e.includes(-i)&&e.includes(i)&&e.splice(e.indexOf(-i),1)}}return e}
1375
1446
  /**
1376
1447
  Returns the scale's ticks, taking into account negative and positive log scales.
1377
1448
  @private
1378
- */_getTicks(){if(["band","ordinal","point","time"].includes(this.schema.scale)&&this._data.length&&this._data.length<this.schema.width/4)return"time"===this.schema.scale?this._data.map(e=>n.date(e)):this._data;let e=[];return this._d3ScaleNegative&&(e=e.concat(gt.bind(this)(this._d3ScaleNegative,!0))),this._d3Scale&&(e=e.concat(gt.bind(this)(this._d3Scale,!0))),"log"===this.schema.scale&&e.includes(-1)&&e.includes(1)&&e.splice(e.indexOf(-1),1),e}
1449
+ */_getTicks(){if(["band","ordinal","point","time"].includes(this.schema.scale)&&this._data.length&&this._data.length<this.schema.width/4)return"time"===this.schema.scale?this._data.map(e=>n.date(e)):this._data;let e=[];return this._d3ScaleNegative&&(e=e.concat(xt.bind(this)(this._d3ScaleNegative,!0))),this._d3Scale&&(e=e.concat(xt.bind(this)(this._d3Scale,!0))),"log"===this.schema.scale&&e.includes(-1)&&e.includes(1)&&e.splice(e.indexOf(-1),1),e}
1379
1450
  /**
1380
1451
  Produces a backend-agnostic scene graph for this axis with no DOM dependency:
1381
1452
  gridlines + domain bar emitted natively, tick marks/labels composed from the
@@ -1391,11 +1462,11 @@ return function(e){const t=[],i=e._gridLineData??[];(function(e){if(!e._gridLine
1391
1462
  /**
1392
1463
  Replicates _barPosition's math to compute the domain-bar endpoints.
1393
1464
  @private
1394
- */)(e).forEach((s,n)=>{const a=pt(e,e.schema.gridConfig,i[n],n);t.push({type:"line",key:`grid-${n}`,points:s.points,paint:a})});const s=e._tickShape&&"function"==typeof e._tickShape.toScene?e._tickShape.toScene():null;
1465
+ */)(e).forEach((s,n)=>{const a=bt(e,e.schema.gridConfig,i[n],n);t.push({type:"line",key:`grid-${n}`,points:s.points,paint:a})});const s=e._tickShape&&"function"==typeof e._tickShape.toScene?e._tickShape.toScene():null;
1395
1466
  // Tick LABELS — appended here because Shape.toScene no longer
1396
1467
  // includes _labelClass children (collectComputed is the canonical
1397
1468
  // aggregator for the chart pipeline; Axis composes labels itself).
1398
- if(s&&t.push(s),e._tickShape){const i=e._tickShape._labelClass;if(i&&"function"==typeof i.toScene&&i._data&&i._data.length){const e=i.toScene();e&&Array.isArray(e.children)&&t.push(...e.children)}}const n=function(e){if(!e._d3Scale&&!e._d3ScaleNegative)return null;const{height:t,x:i,y:s,opposite:n}=e._position,a=e._margin[n],o=["top","left"].includes(e.schema.orient)?e._outerBounds[s]+e._outerBounds[t]-a:e._outerBounds[s]+a,r="band"===e.schema.scale?e._d3Scale.step()-e._d3Scale.bandwidth():"point"===e.schema.scale?e._d3Scale.step()*e._d3Scale.padding():0,c="band"===e.schema.scale?e._d3Scale.step():"point"===e.schema.scale?e._d3Scale.step()*e._d3Scale.padding():0,h=(e._d3ScaleNegative?e._d3ScaleNegative.domain():[]).concat(e._d3Scale?e._d3Scale.domain():[]).sort((e,t)=>e-t);if(!h.length)return null;const l=e._getPosition(h[0])-r,d=e._getPosition(h[h.length-1])+c;return{points:"x"===i?[[l,o],[d,o]]:[[o,l],[o,d]]}}(e);if(n){const i=pt(e,e.schema.barConfig);t.push({type:"line",key:"bar",points:n.points,paint:i})}
1469
+ if(s&&t.push(s),e._tickShape){const i=e._tickShape._labelClass;if(i&&"function"==typeof i.toScene&&i._data&&i._data.length){const e=i.toScene();e&&Array.isArray(e.children)&&t.push(...e.children)}}const n=function(e){if(!e._d3Scale&&!e._d3ScaleNegative)return null;const{height:t,x:i,y:s,opposite:n}=e._position,a=e._margin[n],o=["top","left"].includes(e.schema.orient)?e._outerBounds[s]+e._outerBounds[t]-a:e._outerBounds[s]+a,r="band"===e.schema.scale?e._d3Scale.step()-e._d3Scale.bandwidth():"point"===e.schema.scale?e._d3Scale.step()*e._d3Scale.padding():0,c="band"===e.schema.scale?e._d3Scale.step():"point"===e.schema.scale?e._d3Scale.step()*e._d3Scale.padding():0,h=(e._d3ScaleNegative?e._d3ScaleNegative.domain():[]).concat(e._d3Scale?e._d3Scale.domain():[]).sort((e,t)=>e-t);if(!h.length)return null;const l=e._getPosition(h[0])-r,d=e._getPosition(h[h.length-1])+c;return{points:"x"===i?[[l,o],[d,o]]:[[o,l],[o,d]]}}(e);if(n){const i=bt(e,e.schema.barConfig);t.push({type:"line",key:"bar",points:n.points,paint:i})}
1399
1470
  // The axis was placed inside a container the caller positioned (e.g. Plot's
1400
1471
  // xGroup); preserve that placement on the scene root.
1401
1472
  let a;e._titleClass&&"function"==typeof e._titleClass.toScene&&e._titleClass._data&&e._titleClass._data.length&&t.push(e._titleClass.toScene());const o=e._select&&"function"==typeof e._select.node?e._select.node():null;if(o&&"function"==typeof o.getAttribute){const e=o.getAttribute("transform");if(e){const t=/translate\(\s*([-\d.eE]+)[\s,]+([-\d.eE]+)/.exec(e);t&&(a={x:Number(t[1]),y:Number(t[2])})}}return{type:"group",key:`Axis-${e._uuid.slice(0,8)}`,...a?{transform:a}:{},children:t}}(this)}
@@ -1441,7 +1512,7 @@ const c=function(e,t){const{ticks:i,labels:s,textData:n,tickFormat:a,hBuff:o,lab
1441
1512
  Instantiates and renders the compute-mode tick Shape from `tickData`.
1442
1513
  Extracted from `Axis.render`; behavior is identical.
1443
1514
  @private
1444
- */(this,t);return function(e,t){e._tickShape=(new ct[e.schema.shape]).renderMode("compute").select(null).data(t).duration(e.schema.duration).labelConfig({ellipsis:e=>e&&e.length?`${e}...`:"",
1515
+ */(this,t);return function(e,t){e._tickShape=(new ut[e.schema.shape]).renderMode("compute").select(null).data(t).duration(e.schema.duration).labelConfig({ellipsis:e=>e&&e.length?`${e}...`:"",
1445
1516
  // The label TextBox invokes this with the laid-out label record, whose
1446
1517
  // tick datum (carrying `rotate`) sits on `.data`; fall back to the raw
1447
1518
  // datum for any path that passes it directly.
@@ -1480,22 +1551,22 @@ e._titleClass.renderMode("compute").data(e.schema.title?[{text:e.schema.title}]:
1480
1551
  /**
1481
1552
  Invoked when creating a new class instance, and sets any default parameters.
1482
1553
  @private
1483
- */constructor(){super(),this._d3Scale=null,this._d3ScaleNegative=null,re(this,_t),this._data=[],this._labelRotation=!1,this.schema.barConfig={stroke:()=>{const e=this._select?n.backgroundColor(this._select.node()):"rgb(255, 255, 255)";return u.colorContrast(e)},"stroke-width":1},this.schema.gridConfig={stroke:()=>{const e=this._select?n.backgroundColor(this._select.node()):"rgb(255, 255, 255)";return u.colorContrast(e)===u.colorDefaults.dark?yt.colors.gray[200]:yt.colors.gray[600]},"stroke-width":1},this.orient("bottom"),this._outerBounds={width:0,height:0,x:0,y:0},this.schema.shapeConfig={fill:()=>{const e=this._select?n.backgroundColor(this._select.node()):"rgb(255, 255, 255)";return u.colorContrast(e)},height:e=>e.tick?8:0,label:e=>e.text,labelBounds:e=>e.labelBounds,labelConfig:{fontColor:()=>{const e=this._select?n.backgroundColor(this._select.node()):"rgb(255, 255, 255)";return u.colorContrast(e)},fontResize:!1,fontSize:L(12),padding:5,textAnchor:()=>{const e=n.rtl();return"left"===this.schema.orient?e?"start":"end":"right"===this.schema.orient?e?"end":"start":this._labelRotation?"bottom"===this.schema.orient?"end":"start":"middle"},verticalAlign:()=>"bottom"===this.schema.orient?"top":"top"===this.schema.orient?this._labelRotation?"top":"bottom":"middle"},r:e=>e.tick?4:0,stroke:()=>{const e=this._select?n.backgroundColor(this._select.node()):"rgb(255, 255, 255)";return u.colorContrast(e)},strokeWidth:1,width:e=>e.tick?8:0},this._tickUnit=0,this._titleClass=new Wt,this.schema.titleConfig={fontColor:()=>{const e=this._select?n.backgroundColor(this._select.node()):"rgb(255, 255, 255)";return u.colorContrast(e)},fontSize:12,textAnchor:"middle"},this._margin={top:0,right:0,bottom:0,left:0},this._availableTicks=[],this._visibleTicks=[]}}class bt extends xt{
1554
+ */constructor(){super(),this._d3Scale=null,this._d3ScaleNegative=null,re(this,vt),this._data=[],this._labelRotation=!1,this.schema.barConfig={stroke:()=>{const e=this._select?n.backgroundColor(this._select.node()):"rgb(255, 255, 255)";return u.colorContrast(e)},"stroke-width":1},this.schema.gridConfig={stroke:()=>{const e=this._select?n.backgroundColor(this._select.node()):"rgb(255, 255, 255)";return u.colorContrast(e)===u.colorDefaults.dark?kt.colors.gray[200]:kt.colors.gray[600]},"stroke-width":1},this.orient("bottom"),this._outerBounds={width:0,height:0,x:0,y:0},this.schema.shapeConfig={fill:()=>{const e=this._select?n.backgroundColor(this._select.node()):"rgb(255, 255, 255)";return u.colorContrast(e)},height:e=>e.tick?8:0,label:e=>e.text,labelBounds:e=>e.labelBounds,labelConfig:{fontColor:()=>{const e=this._select?n.backgroundColor(this._select.node()):"rgb(255, 255, 255)";return u.colorContrast(e)},fontResize:!1,fontSize:L(12),padding:5,textAnchor:()=>{const e=n.rtl();return"left"===this.schema.orient?e?"start":"end":"right"===this.schema.orient?e?"end":"start":this._labelRotation?"bottom"===this.schema.orient?"end":"start":"middle"},verticalAlign:()=>"bottom"===this.schema.orient?"top":"top"===this.schema.orient?this._labelRotation?"top":"bottom":"middle"},r:e=>e.tick?4:0,stroke:()=>{const e=this._select?n.backgroundColor(this._select.node()):"rgb(255, 255, 255)";return u.colorContrast(e)},strokeWidth:1,width:e=>e.tick?8:0},this._tickUnit=0,this._titleClass=new Gt,this.schema.titleConfig={fontColor:()=>{const e=this._select?n.backgroundColor(this._select.node()):"rgb(255, 255, 255)";return u.colorContrast(e)},fontSize:12,textAnchor:"middle"},this._margin={top:0,right:0,bottom:0,left:0},this._availableTicks=[],this._visibleTicks=[]}}class St extends Ct{
1484
1555
  /**
1485
1556
  Invoked when creating a new class instance, and overrides any default parameters inherited from Axis.
1486
1557
  @private
1487
1558
  */
1488
- constructor(){super(),this.orient("bottom")}}class kt extends xt{
1559
+ constructor(){super(),this.orient("bottom")}}class wt extends Ct{
1489
1560
  /**
1490
1561
  Invoked when creating a new class instance, and overrides any default parameters inherited from Axis.
1491
1562
  @private
1492
1563
  */
1493
- constructor(){super(),this.orient("left")}}class vt extends xt{
1564
+ constructor(){super(),this.orient("left")}}class zt extends Ct{
1494
1565
  /**
1495
1566
  Invoked when creating a new class instance, and overrides any default parameters inherited from Axis.
1496
1567
  @private
1497
1568
  */
1498
- constructor(){super(),this.orient("right")}}class Ct extends xt{
1569
+ constructor(){super(),this.orient("right")}}class Dt extends Ct{
1499
1570
  /**
1500
1571
  Invoked when creating a new class instance, and overrides any default parameters inherited from Axis.
1501
1572
  @private
@@ -1505,11 +1576,11 @@ constructor(){super(),this.orient("top")}}
1505
1576
  Runs the row-wrapping pass: builds rows, retries label-free if it overflows,
1506
1577
  then distributes row `y` offsets. Returns the resolved `spaceNeeded`.
1507
1578
  */
1508
- function St(e,i,s,a){const o={lines:1,newRows:[],maxLines:t.max(e._lineData.map(e=>e.words.length))};if(e._wrapLines=()=>
1579
+ function Mt(e,i,s,a){const o={lines:1,newRows:[],maxLines:t.max(e._lineData.map(e=>e.words.length))};if(e._wrapLines=()=>
1509
1580
  /** Attempts to wrap labels onto an additional line, recursing into rows. */function(e,i,s,a){if(i.lines++,i.lines>i.maxLines)return;const o=1===i.lines?e._lineData.slice():e._lineData.filter(t=>t.width+t.shapeWidth+e.schema.padding*(t.width?2:1)>s&&t.words.length>=i.lines).sort((e,t)=>t.sentence.length-e.sentence.length);if(o.length&&a>o[0].height*i.lines){let s=!1;for(let e=0;e<o.length;e++){const a=o[e],c=a.og,h=c.height*i.lines,l=c.width*(1/i.lines*1.5),d=r.textWrap().fontFamily(a.f).fontSize(a.s).lineHeight(a.lh).width(l).height(h)(a.sentence);if(d.truncated){s=!0;break}a.width=Math.ceil(t.max(d.lines.map(e=>n.textWidth(e,{"font-family":a.f,"font-size":a.s}))))+a.s,a.height=d.lines.length*(a.lh+1)}s||e._wrapRows()}else i.newRows=[]}
1510
1581
  /** Packs the measured labels into rows that fit the available width/height. */(e,o,i,s),e._wrapRows=()=>function(e,i,s,n){i.newRows=[];let a=1,o=0;for(let r=0;r<e._lineData.length;r++){const c=e._lineData[r],h=c.width+e.schema.padding*(c.width?2:1)+c.shapeWidth;if(t.sum(i.newRows.map(e=>t.max(e,e=>t.max([e.height,e.shapeHeight]))))>n){i.newRows=[];break}if(h>s){i.newRows=[],e._wrapLines();break}o+h<s?o+=h:"column"!==e.schema.direction&&(o=h,a++),i.newRows[a-1]||(i.newRows[a-1]=[]),i.newRows[a-1].push(c),"column"===e.schema.direction&&(o=0,a++)}}(e,o,i,s),e._wrapRows(),!o.newRows.length||t.sum(o.newRows,e._rowHeight.bind(e))+e.schema.padding>s){a=t.sum(e._lineData.map(t=>t.shapeWidth+e.schema.padding))-e.schema.padding;for(let t=0;t<e._lineData.length;t++)e._lineData[t].width=0,e._lineData[t].height=0;e._wrapRows()}return o.newRows.length&&t.sum(o.newRows,e._rowHeight.bind(e))+e.schema.padding<s&&(o.newRows.forEach((i,s)=>{i.forEach(i=>{s&&(i.y=t.sum(o.newRows.slice(0,s),e._rowHeight.bind(e)))})}),a=t.max(o.newRows,e._rowWidth.bind(e))),a}
1511
1582
  /** Computes `_outerBounds` (size + aligned x/y offset) from the laid-out rows. */
1512
- /** Legend's fluent accessor schema. Config storage lives on `this.schema.<key>`. */const wt=[{key:"align",coerce:"identity",default:"center"},{key:"direction",coerce:"identity",default:"row"},{key:"duration",coerce:"identity",default:600},{key:"height",coerce:"identity",default:200},{key:"id",coerce:"identity",default:F("id")},{key:"label",coerce:"const",default:F("id")},{key:"padding",coerce:"identity",default:5},{key:"renderMode",coerce:"identity",default:"full"},{key:"shape",coerce:"const",default:L("Rect")},{key:"title",coerce:"identity"},{key:"verticalAlign",coerce:"identity",default:"middle"},{key:"width",coerce:"identity",default:400}];class zt extends j{
1583
+ /** Legend's fluent accessor schema. Config storage lives on `this.schema.<key>`. */const At=[{key:"align",coerce:"identity",default:"center"},{key:"direction",coerce:"identity",default:"row"},{key:"duration",coerce:"identity",default:600},{key:"height",coerce:"identity",default:200},{key:"id",coerce:"identity",default:F("id")},{key:"label",coerce:"const",default:F("id")},{key:"padding",coerce:"identity",default:5},{key:"renderMode",coerce:"identity",default:"full"},{key:"shape",coerce:"const",default:L("Rect")},{key:"title",coerce:"identity"},{key:"verticalAlign",coerce:"identity",default:"middle"},{key:"width",coerce:"identity",default:400}];class $t extends j{
1513
1584
  /**
1514
1585
  @param key The configuration key.
1515
1586
  @param d The data point.
@@ -1551,9 +1622,9 @@ this._group=n.elem("g.d3plus-Legend",{parent:this._select}),this._titleGroup=n.e
1551
1622
  /** Wraps + measures the title, setting `_titleHeight` / `_titleWidth`. */function(e){if(e._titleHeight=0,e._titleWidth=0,e.schema.title){const i=e.schema.titleConfig.fontFamily||e._titleClass.fontFamily()(),s=e.schema.titleConfig.fontSize||e._titleClass.fontSize()();let n=e.schema.titleConfig.lineHeight||e._titleClass.lineHeight();n="function"==typeof n?n():n??1.4*s;const a=r.textWrap().fontFamily(i).fontSize(s).lineHeight(n).width(e.schema.width).height(e.schema.height)(e.schema.title);e._titleHeight=n+a.lines.length+e.schema.padding,e._titleWidth=t.max(a.widths)}}
1552
1623
  /** Measures each datum's swatch + wrapped label into the `_lineData` array. */(this);const s=this.schema.height-this._titleHeight;this._lineData=function(e,i){return e._data.map((s,a)=>{const o=e.schema.label(s,a),c=e.schema.shape(s,a),h=e._fetchConfig("r",s,a);let l={data:s,i:a,id:e.schema.id(s,a),shape:c,shapeR:h,shapeWidth:"Circle"===c?2*h:e._fetchConfig("width",s,a),shapeHeight:"Circle"===c?2*h:e._fetchConfig("height",s,a),y:0};if(!o)return l.sentence=!1,l.words=[],l.height=0,l.width=0,l;const d=e._fetchConfig("fontFamily",s,a),u=e._fetchConfig("lineHeight",s,a),m=e._fetchConfig("fontSize",s,a),f=i-(e._data.length+1)*e.schema.padding,g=e.schema.width,p=r.textWrap().fontFamily(d).fontSize(m).lineHeight(u).width(g).height(f)(o);return l=Object.assign(l,p),l.width=Math.ceil(t.max(l.lines.map(e=>n.textWidth(e,{"font-family":d,"font-size":m}))))+10,l.height=Math.ceil(l.lines.length*(u+1)),l.og={height:l.height,width:l.width},l.f=d,l.s=m,l.lh=u,l})}(this,s);let a=this._rowWidth(this._lineData);const o=this.schema.width-2*this.schema.padding;
1553
1624
  /** Renders the title TextBox into the legend's title group. */var c;
1554
- /** Builds the per-shape data and renders the Circle/Rect swatch groups. */return("column"===this.schema.direction||a>o)&&(a=St(this,o,s,a)),function(e,i){const s=t.max(e._lineData,(i,s)=>t.max([i.height,e._fetchConfig("height",i.data,s)])+i.y)+e._titleHeight,n=t.max([i,e._titleWidth]);e._outerBounds.width=n,e._outerBounds.height=s;let a=e.schema.padding,o=e.schema.padding;"center"===e.schema.align?a=(e.schema.width-n)/2:"right"===e.schema.align&&(a=e.schema.width-e.schema.padding-n),"middle"===e.schema.verticalAlign?o=(e.schema.height-s)/2:"bottom"===e.schema.verticalAlign&&(o=e.schema.height-e.schema.padding-s),e._outerBounds.x=a,e._outerBounds.y=o}(this,a),(c=this)._titleClass.renderMode("compute").data(c.schema.title?[{text:c.schema.title}]:[]).duration(c.schema.duration).select(c._titleGroup.node()).textAnchor({left:"start",center:"middle",right:"end"}[c.schema.align]).width(c.schema.width-2*c.schema.padding).x(c.schema.padding).y(c._outerBounds.y).config(c.schema.titleConfig).render(),function(e){e._shapes=[];const t=G.bind(e)(e.schema.shapeConfig,"legend"),i={id:e=>e.id,label:e=>e.label,lineHeight:e=>e.lH},s=e._data.map((t,i)=>({__d3plus__:!0,data:t,i:i,id:e.schema.id(t,i),label:!!e._lineData[i].width&&e.schema.label(t,i),lH:e._fetchConfig("lineHeight",t,i),shape:e.schema.shape(t,i)}));e._shapes=[],["Circle","Rect"].forEach(a=>{e._shapes.push(// Child shapes are compute-only — Legend composes the swatches into its
1625
+ /** Builds the per-shape data and renders the Circle/Rect swatch groups. */return("column"===this.schema.direction||a>o)&&(a=Mt(this,o,s,a)),function(e,i){const s=t.max(e._lineData,(i,s)=>t.max([i.height,e._fetchConfig("height",i.data,s)])+i.y)+e._titleHeight,n=t.max([i,e._titleWidth]);e._outerBounds.width=n,e._outerBounds.height=s;let a=e.schema.padding,o=e.schema.padding;"center"===e.schema.align?a=(e.schema.width-n)/2:"right"===e.schema.align&&(a=e.schema.width-e.schema.padding-n),"middle"===e.schema.verticalAlign?o=(e.schema.height-s)/2:"bottom"===e.schema.verticalAlign&&(o=e.schema.height-e.schema.padding-s),e._outerBounds.x=a,e._outerBounds.y=o}(this,a),(c=this)._titleClass.renderMode("compute").data(c.schema.title?[{text:c.schema.title}]:[]).duration(c.schema.duration).select(c._titleGroup.node()).textAnchor({left:"start",center:"middle",right:"end"}[c.schema.align]).width(c.schema.width-2*c.schema.padding).x(c.schema.padding).y(c._outerBounds.y).config(c.schema.titleConfig).render(),function(e){e._shapes=[];const t=G.bind(e)(e.schema.shapeConfig,"legend"),i={id:e=>e.id,label:e=>e.label,lineHeight:e=>e.lH},s=e._data.map((t,i)=>({__d3plus__:!0,data:t,i:i,id:e.schema.id(t,i),label:!!e._lineData[i].width&&e.schema.label(t,i),lH:e._fetchConfig("lineHeight",t,i),shape:e.schema.shape(t,i)}));e._shapes=[],["Circle","Rect"].forEach(a=>{e._shapes.push(// Child shapes are compute-only — Legend composes the swatches into its
1555
1626
  // own toScene, so sub-shapes never auto-render their own <svg>.
1556
- (new ct[a]).renderMode("compute").parent(e).data(s.filter(e=>e.shape===a)).duration(e.schema.duration).labelConfig({padding:0}).select(e._shapeGroup.node()).verticalAlign("top").config(n.assign({},t,i)).render())})}(this),
1627
+ (new ut[a]).renderMode("compute").parent(e).data(s.filter(e=>e.shape===a)).duration(e.schema.duration).labelConfig({padding:0}).select(e._shapeGroup.node()).verticalAlign("top").config(n.assign({},t,i)).render())})}(this),
1557
1628
  // Standalone render: paint the scene into the user's `_select`. Inside a
1558
1629
  // Viz the legend runs in compute mode and the Viz composes its toScene().
1559
1630
  "compute"!==this.schema.renderMode&&q(this),e&&setTimeout(e,this.schema.duration+100),this}
@@ -1577,14 +1648,14 @@ this._group=n.elem("g.d3plus-Legend",{parent:this._select}),this._titleGroup=n.e
1577
1648
  the `legend` instance so they read live `_lineData` / `_outerBounds` /
1578
1649
  `_rtl` / `_titleHeight` state during render.
1579
1650
  */
1580
- var e;super(),re(this,wt),this._titleClass=new Wt,this._data=[],this._lineData=[],this._outerBounds={width:0,height:0,x:0,y:0},this._shapes=[],this.schema.shapeConfig=(e=this,{fill:F("color"),height:L(12),hitArea:(i,s)=>{const n=e._lineData[s],a=t.max([n.height,n.shapeHeight]);return{width:n.width+n.shapeWidth,height:a,x:-n.shapeWidth/2,y:-a/2}},labelBounds:(i,s)=>{const n=e._lineData[s];let a=n.shapeWidth/2;"Circle"===n.shape&&(a-=n.shapeR/2);const o=t.max([n.shapeHeight,n.height]),r=e._rtl?n.shapeWidth+n.width+2*e.schema.padding:0;return{width:n.width,height:o,x:a+5-r,y:-o/2}},labelConfig:{fontColor:()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return u.colorContrast(t)},fontFamily:e._titleClass.fontFamily(),fontResize:!1,fontSize:L(10),
1651
+ var e;super(),re(this,At),this._titleClass=new Gt,this._data=[],this._lineData=[],this._outerBounds={width:0,height:0,x:0,y:0},this._shapes=[],this.schema.shapeConfig=(e=this,{fill:F("color"),height:L(12),hitArea:(i,s)=>{const n=e._lineData[s],a=t.max([n.height,n.shapeHeight]);return{width:n.width+n.shapeWidth,height:a,x:-n.shapeWidth/2,y:-a/2}},labelBounds:(i,s)=>{const n=e._lineData[s];let a=n.shapeWidth/2;"Circle"===n.shape&&(a-=n.shapeR/2);const o=t.max([n.shapeHeight,n.height]),r=e._rtl?n.shapeWidth+n.width+2*e.schema.padding:0;return{width:n.width,height:o,x:a+5-r,y:-o/2}},labelConfig:{fontColor:()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return u.colorContrast(t)},fontFamily:e._titleClass.fontFamily(),fontResize:!1,fontSize:L(10),
1581
1652
  // The swatch's `hitArea` already spans the label, so let it own pointer
1582
1653
  // events for the whole item. A bare label would carry a different scene
1583
1654
  // key than its swatch, so hovering across the swatch→label padding would
1584
1655
  // otherwise read as leaving one item and entering another.
1585
1656
  pointerEvents:L("none"),verticalAlign:"middle"},opacity:1,r:L(6),width:L(12),x:(t,i)=>{const s=e._lineData[i],n=s.y,a="left"===e.schema.align||"right"===e.schema.align&&"column"===e.schema.direction?0:"center"===e.schema.align?(e._outerBounds.width-e._rowWidth(e._lineData.filter(e=>n===e.y)))/2:e._outerBounds.width-e._rowWidth(e._lineData.filter(e=>n===e.y)),o=e._lineData.slice(0,i).filter(e=>n===e.y),r=e._rtl?s.width+e.schema.padding:0;return e._rowWidth(o)+e.schema.padding*(o.length?s.sentence?2:1:0)+e._outerBounds.x+s.shapeWidth/2+a+r},y:(i,s)=>{const n=e._lineData[s];return n.y+e._titleHeight+e._outerBounds.y+t.max(e._lineData.filter(e=>n.y===e.y).map(e=>e.height).concat(e._data.map((t,i)=>e._fetchConfig("height",t,i))))/2}}),this.schema.titleConfig={fontSize:12},this._rtl=!1,this._titleHeight=0,this._titleWidth=0}}
1586
1657
  /** Builds the jenks (ckmeans) threshold scale and assigns it to the instance. */
1587
- /** Builds the linear/log/buckets/quantile scale and assigns it to the instance. */function Dt(e,i){let s=e.schema.buckets instanceof Array?e.schema.buckets:void 0;const n=i.diverging&&!i.colors?
1658
+ /** Builds the linear/log/buckets/quantile scale and assigns it to the instance. */function Bt(e,i){let s=e.schema.buckets instanceof Array?e.schema.buckets:void 0;const n=i.diverging&&!i.colors?
1588
1659
  /** Resolves the diverging linear-gradient color/bucket arrays. */function(e,i,s){const{domain:n,numBuckets:a}=i,o=Math.floor(a/2),r=x.interpolateRgb.gamma(2.2)(e.schema.colorMin,e.schema.colorMid),c=t.range(0,o,1).map(e=>r(e/o)),h=(a%2?[0]:[]).map(()=>e.schema.colorMid),l=x.interpolateRgb.gamma(2.2)(e.schema.colorMax,e.schema.colorMid),d=t.range(0,o,1).map(e=>l(e/o)).reverse(),u=c.concat(h).concat(d);if(!s){const i=(u.length-1)/2;s=[n[0],e.schema.midpoint,n[1]],s=t.range(n[0],e.schema.midpoint,-(n[0]-e.schema.midpoint)/i).concat(t.range(e.schema.midpoint,n[1],(n[1]-e.schema.midpoint)/i)).concat([n[1]])}return{colors:u,buckets:s}}
1589
1660
  /** Resolves the non-diverging linear-gradient color/bucket arrays. */(e,i,s):function(e,i,s){const{allValues:n,domain:a,negative:o,positive:r,diverging:c,numBuckets:h}=i;let{colors:l}=i;if(!l){
1590
1661
  // Single-hue ramp of the relevant pole, stepped in OKLab (light→dark).
@@ -1593,16 +1664,16 @@ const t=o?e.schema.colorMin:e.schema.colorMax;if("buckets"===e.schema.scale||"qu
1593
1664
  /**
1594
1665
  Solves the color scale (jenks or linear) for the current ColorScale config,
1595
1666
  assigning `_colorScale` and returning the values the render branches need.
1596
- */function Mt(e){const i=["bottom","top"].includes(e.schema.orient),n=i?"height":"width",a=i?"width":"height",o=i?"x":"y",r=i?"y":"x",c=e._data.map(e.schema.value).filter(e=>null!==e&&"number"==typeof e).sort((e,t)=>e-t),h=e.schema.domain||t.extent(c),d=h[0]<e.schema.midpoint,m=h[1]>e.schema.midpoint,f=d&&m,g=t.min([e.schema.buckets instanceof Array?e.schema.buckets.length:e.schema.buckets,f&&"jenks"!==e.schema.scale?2*Math.floor(s.unique(c).length/2)-1:s.unique(c).length]);let p=f&&(!e.schema.color||e.schema.color instanceof Array&&!e.schema.color.includes(e.schema.colorMid))?void 0:e.schema.color;!p||p instanceof Array||(
1667
+ */function Pt(e){const i=["bottom","top"].includes(e.schema.orient),n=i?"height":"width",a=i?"width":"height",o=i?"x":"y",r=i?"y":"x",c=e._data.map(e.schema.value).filter(e=>null!==e&&"number"==typeof e).sort((e,t)=>e-t),h=e.schema.domain||t.extent(c),d=h[0]<e.schema.midpoint,m=h[1]>e.schema.midpoint,f=d&&m,g=t.min([e.schema.buckets instanceof Array?e.schema.buckets.length:e.schema.buckets,f&&"jenks"!==e.schema.scale?2*Math.floor(s.unique(c).length/2)-1:s.unique(c).length]);let y=f&&(!e.schema.color||e.schema.color instanceof Array&&!e.schema.color.includes(e.schema.colorMid))?void 0:e.schema.color;!y||y instanceof Array||(
1597
1668
  // A single hue expands to a light→dark ramp, stepped in OKLab.
1598
- p=u.colorRamp(p,g));const _={allValues:c,domain:h,negative:d,positive:m,diverging:f,numBuckets:g,
1669
+ y=u.colorRamp(y,g));const _={allValues:c,domain:h,negative:d,positive:m,diverging:f,numBuckets:g,
1599
1670
  // A single color string is expanded to an array above, so by here this
1600
1671
  // is always an array (or undefined).
1601
- colors:p},x="jenks"===e.schema.scale?function(e,i){const{allValues:s,diverging:n,numBuckets:a}=i;let o,r,{colors:c}=i;const h=t.min([c?c.length:a,a,s.length]);let d=[];if(e.schema.buckets instanceof Array)o=e.schema.buckets;else{if(n&&e.schema.centered){const i=Math.floor(h/2),n=h%2,a=s.filter(t=>t<e.schema.midpoint),o=t.deviation(a),r=s.concat(e.schema.midpoint).filter(t=>t>=e.schema.midpoint),c=t.deviation(r),l=o>c?1:0,u=c>o?1:0,m=y.ckmeans(a,t.min([i+n*l,a.length])),f=y.ckmeans(r,t.min([i+n*u,r.length]));d=m.concat(f)}else d=y.ckmeans(s,h);o=d.map(e=>e[0])}const m=new Set(o);if(o.length!==m.size&&(r=Array.from(m)),!c)if(n){const t=[e.schema.colorMin,e.schema.colorMid,e.schema.colorMax];c=t;const i=o.slice(0,h).filter((t,i)=>t<e.schema.midpoint&&o[i+1]<=e.schema.midpoint),s=o.slice(0,h).filter((t,i)=>t<=e.schema.midpoint&&o[i+1]>e.schema.midpoint),n=o.slice(0,h).filter(t=>t>e.schema.midpoint),a=i.map((e,s)=>s?u.colorLighter(t[0],s/i.length):t[0]),r=s.map(()=>t[1]),l=n.map((e,i)=>i===n.length-1?t[2]:u.colorLighter(t[2],1-(i+1)/n.length));c=a.concat(r).concat(l)}else
1672
+ colors:y},x="jenks"===e.schema.scale?function(e,i){const{allValues:s,diverging:n,numBuckets:a}=i;let o,r,{colors:c}=i;const h=t.min([c?c.length:a,a,s.length]);let d=[];if(e.schema.buckets instanceof Array)o=e.schema.buckets;else{if(n&&e.schema.centered){const i=Math.floor(h/2),n=h%2,a=s.filter(t=>t<e.schema.midpoint),o=t.deviation(a),r=s.concat(e.schema.midpoint).filter(t=>t>=e.schema.midpoint),c=t.deviation(r),l=o>c?1:0,u=c>o?1:0,m=p.ckmeans(a,t.min([i+n*l,a.length])),f=p.ckmeans(r,t.min([i+n*u,r.length]));d=m.concat(f)}else d=p.ckmeans(s,h);o=d.map(e=>e[0])}const m=new Set(o);if(o.length!==m.size&&(r=Array.from(m)),!c)if(n){const t=[e.schema.colorMin,e.schema.colorMid,e.schema.colorMax];c=t;const i=o.slice(0,h).filter((t,i)=>t<e.schema.midpoint&&o[i+1]<=e.schema.midpoint),s=o.slice(0,h).filter((t,i)=>t<=e.schema.midpoint&&o[i+1]>e.schema.midpoint),n=o.slice(0,h).filter(t=>t>e.schema.midpoint),a=i.map((e,s)=>s?u.colorLighter(t[0],s/i.length):t[0]),r=s.map(()=>t[1]),l=n.map((e,i)=>i===n.length-1?t[2]:u.colorLighter(t[2],1-(i+1)/n.length));c=a.concat(r).concat(l)}else
1602
1673
  // Single-hue light→dark ramp, stepped in OKLab (see @d3plus/color).
1603
- c=u.colorRamp(e.schema.colorMax,a);return o.length<=h&&(c=c.slice(-o.length)),c=[c[0]].concat(c),e._colorScale=l.scaleThreshold().domain(o).range(c),{colors:c,ticks:o,labels:r}}(e,_):Dt(e,_);return e._colorScale.clamp&&e._colorScale.clamp(!0),{allValues:c,domain:h,ticks:x.ticks,labels:x.labels,colors:x.colors,horizontal:i,height:n,width:a,x:o,y:r}}
1674
+ c=u.colorRamp(e.schema.colorMax,a);return o.length<=h&&(c=c.slice(-o.length)),c=[c[0]].concat(c),e._colorScale=l.scaleThreshold().domain(o).range(c),{colors:c,ticks:o,labels:r}}(e,_):Bt(e,_);return e._colorScale.clamp&&e._colorScale.clamp(!0),{allValues:c,domain:h,ticks:x.ticks,labels:x.labels,colors:x.colors,horizontal:i,height:n,width:a,x:o,y:r}}
1604
1675
  /** Builds the axis/label configs and trims the gradient for end labels. */
1605
- /** Renders the smooth-gradient (and bucketed-rect) ColorScale variant. */function At(e,t,i){const s={x:0,y:0},{axisConfig:a,labelConfig:r,axisDomain:c,labelData:h}=function(e,t,i){const{horizontal:s,height:a,width:o,domain:r,labels:c,ticks:h}=t,l=r.slice();if(e.schema.bucketAxis){const e=l[l.length-1],t=l[l.length-2],i=e?e/10:t/10,s=i>=1||i<=-1?Math.round(i).toString().length-1:-1*i.toString().split(".")[1].replace(/([1-9])[1-9].*$/,"$1").length,n=Math.pow(10,s);l[l.length-1]=e+n}const d=n.assign({domain:s?l:l.slice().reverse(),duration:e.schema.duration,height:e.schema.height,labels:c||h,orient:e.schema.orient,padding:e.schema.padding,scale:"log"===e.schema.scale?"log":"linear",ticks:h,width:e.schema.width},e.schema.axisConfig),u=n.assign({height:e.schema[a]/2,width:e.schema[o]/2},e.schema.labelConfig);e._labelClass.config(u);const m=[];if(s&&e._labelMin){const t={"font-family":e._labelClass.fontFamily()(e._labelMin),"font-size":e._labelClass.fontSize()(e._labelMin),"font-weight":e._labelClass.fontWeight()(e._labelMin)};t["font-family"]instanceof Array&&(t["font-family"]=t["font-family"][0]);let a=n.textWidth(e._labelMin,t);a&&a<e.schema[o]/2&&(m.push(e._labelMin),a+=e.schema.padding,s&&(i.x+=a),d[o]=d[o]-a)}if(s&&e._labelMax){const t={"font-family":e._labelClass.fontFamily()(e._labelMax),"font-size":e._labelClass.fontSize()(e._labelMax),"font-weight":e._labelClass.fontWeight()(e._labelMax)};t["font-family"]instanceof Array&&(t["font-family"]=t["font-family"][0]);let a=n.textWidth(e._labelMax,t);a&&a<e.schema[o]/2&&(m.push(e._labelMax),a+=e.schema.padding,s||(i.y+=a),d[o]=d[o]-a)}return{axisConfig:d,labelConfig:u,axisDomain:l,labelData:m}}
1676
+ /** Renders the smooth-gradient (and bucketed-rect) ColorScale variant. */function Tt(e,t,i){const s={x:0,y:0},{axisConfig:a,labelConfig:r,axisDomain:c,labelData:h}=function(e,t,i){const{horizontal:s,height:a,width:o,domain:r,labels:c,ticks:h}=t,l=r.slice();if(e.schema.bucketAxis){const e=l[l.length-1],t=l[l.length-2],i=e?e/10:t/10,s=i>=1||i<=-1?Math.round(i).toString().length-1:-1*i.toString().split(".")[1].replace(/([1-9])[1-9].*$/,"$1").length,n=Math.pow(10,s);l[l.length-1]=e+n}const d=n.assign({domain:s?l:l.slice().reverse(),duration:e.schema.duration,height:e.schema.height,labels:c||h,orient:e.schema.orient,padding:e.schema.padding,scale:"log"===e.schema.scale?"log":"linear",ticks:h,width:e.schema.width},e.schema.axisConfig),u=n.assign({height:e.schema[a]/2,width:e.schema[o]/2},e.schema.labelConfig);e._labelClass.config(u);const m=[];if(s&&e._labelMin){const t={"font-family":e._labelClass.fontFamily()(e._labelMin),"font-size":e._labelClass.fontSize()(e._labelMin),"font-weight":e._labelClass.fontWeight()(e._labelMin)};t["font-family"]instanceof Array&&(t["font-family"]=t["font-family"][0]);let a=n.textWidth(e._labelMin,t);a&&a<e.schema[o]/2&&(m.push(e._labelMin),a+=e.schema.padding,s&&(i.x+=a),d[o]=d[o]-a)}if(s&&e._labelMax){const t={"font-family":e._labelClass.fontFamily()(e._labelMax),"font-size":e._labelClass.fontSize()(e._labelMax),"font-weight":e._labelClass.fontWeight()(e._labelMax)};t["font-family"]instanceof Array&&(t["font-family"]=t["font-family"][0]);let a=n.textWidth(e._labelMax,t);a&&a<e.schema[o]/2&&(m.push(e._labelMax),a+=e.schema.padding,s||(i.y+=a),d[o]=d[o]-a)}return{axisConfig:d,labelConfig:u,axisDomain:l,labelData:m}}
1606
1677
  /** Renders the measurement + visible axes, returning bounds and the position scale. */(e,t,s),{axisBounds:d,axisScale:u,scaleRange:m}=function(e,t,i,s,a){const{horizontal:o,height:r,width:c,x:h,y:l}=t;e._axisTest.renderMode("compute").select(n.elem("g.d3plus-ColorScale-axisTest",{enter:{opacity:0},parent:e._group}).node()).config(s).duration(0).render();const d=e._axisTest.outerBounds();e._outerBounds[c]=e.schema[c]-2*e.schema.padding,e._outerBounds[r]=d[r]+e.schema.size,e._outerBounds[h]=e.schema.padding,e._outerBounds[l]=e.schema.padding,"middle"===e.schema.align?e._outerBounds[l]=(e.schema[r]-e._outerBounds[r])/2:"end"===e.schema.align&&(e._outerBounds[l]=e.schema[r]-e.schema.padding-e._outerBounds[r]);const u=e._outerBounds[l]+(["bottom","right"].includes(e.schema.orient)?e.schema.size:0)-(s.padding||e._axisClass.padding()),m=`translate(${a.x+(o?0:u)}, ${a.y+(o?u:0)})`;return e._axisClass.renderMode("compute").select(n.elem("g.d3plus-ColorScale-axis",n.assign(i.groupParams,{condition:!0,enter:{transform:m},update:{transform:m}})).node()).config(s).align("start").render(),{axisBounds:d,axisScale:e._axisTest._getPosition.bind(e._axisTest),scaleRange:e._axisTest._getRange()}}
1607
1678
  /**
1608
1679
  Computes the smooth-gradient spec and stashes its serializable fill token on
@@ -1618,14 +1689,14 @@ c=u.colorRamp(e.schema.colorMax,a);return o.length<=h&&(c=c.slice(-o.length)),c=
1618
1689
  return e._rectClass.renderMode("compute").data(h||[0]).id((e,t)=>t).select(i.rectGroup.node()).config(p).render(),p}
1619
1690
  /** Renders the labelMin/labelMax text alongside the gradient. */(e,t,i,{axisScale:u,scaleRange:m,axisDomain:c,axisBounds:d,offsets:s});!function(e,t,i,s,n,a){const{horizontal:o,height:r,width:c}=t;s.height=e._outerBounds[r],s.width=e._outerBounds[c],e._labelClass.renderMode("compute"),e._labelClass.config(s).data(a).select(i.labelGroup.node()).x(t=>t===e._labelMax?n.x+n.width/2+e.schema.padding:e._outerBounds.x).y(t=>n.y-e._labelClass.fontSize()(t)/2).text(e=>e).rotate(o?0:"right"===e.schema.orient?90:-90).render()}(e,t,i,r,f,h)}
1620
1691
  /** Renders the discrete legend ColorScale variant (jenks/buckets/quantile). */
1621
- /** ColorScale's fluent accessor schema. Config storage lives on `this.schema.<key>`. */const $t=[{key:"align",coerce:"identity",default:"middle"},{key:"buckets",coerce:"identity",default:5},{key:"bucketAxis",coerce:"identity",default:!1},{key:"bucketFormat",coerce:"identity"},{key:"bucketJoiner",coerce:"identity",default:(e,t)=>e!==t?`${e} - ${t}`:`${e}`},{key:"centered",coerce:"identity",default:!0},
1692
+ /** ColorScale's fluent accessor schema. Config storage lives on `this.schema.<key>`. */const Ot=[{key:"align",coerce:"identity",default:"middle"},{key:"buckets",coerce:"identity",default:5},{key:"bucketAxis",coerce:"identity",default:!1},{key:"bucketFormat",coerce:"identity"},{key:"bucketJoiner",coerce:"identity",default:(e,t)=>e!==t?`${e} - ${t}`:`${e}`},{key:"centered",coerce:"identity",default:!0},
1622
1693
  // No default palette: an unset `color` falls through to the single-hue
1623
1694
  // (colorMax / colorMin) ramp or the diverging (min↔mid↔max) construction,
1624
1695
  // so magnitude reads as one hue getting darker rather than a multi-hue ramp.
1625
1696
  {key:"color",coerce:"identity"},
1626
1697
  // Blue high pole (and default sequential hue), gray "nothing" midpoint, red
1627
1698
  // low pole — warm/cool poles that stay distinct under color-vision deficiency.
1628
- {key:"colorMax",coerce:"identity",default:u.colorDefaults.sequential},{key:"colorMid",coerce:"identity",default:u.colorDefaults.light},{key:"colorMin",coerce:"identity",default:u.colorDefaults.off},{key:"domain",coerce:"identity"},{key:"duration",coerce:"identity",default:600},{key:"height",coerce:"identity",default:200},{key:"midpoint",coerce:"identity",default:0},{key:"orient",coerce:"identity",default:"bottom"},{key:"padding",coerce:"identity",default:5},{key:"renderMode",coerce:"identity",default:"full"},{key:"scale",coerce:"identity",default:"linear"},{key:"size",coerce:"identity",default:10},{key:"value",coerce:"const",default:F("value")},{key:"width",coerce:"identity",default:400}];class Bt extends j{
1699
+ {key:"colorMax",coerce:"identity",default:u.colorDefaults.sequential},{key:"colorMid",coerce:"identity",default:u.colorDefaults.light},{key:"colorMin",coerce:"identity",default:u.colorDefaults.off},{key:"domain",coerce:"identity"},{key:"duration",coerce:"identity",default:600},{key:"height",coerce:"identity",default:200},{key:"midpoint",coerce:"identity",default:0},{key:"orient",coerce:"identity",default:"bottom"},{key:"padding",coerce:"identity",default:5},{key:"renderMode",coerce:"identity",default:"full"},{key:"scale",coerce:"identity",default:"linear"},{key:"size",coerce:"identity",default:10},{key:"value",coerce:"const",default:F("value")},{key:"width",coerce:"identity",default:400}];class Rt extends j{
1629
1700
  /**
1630
1701
  Renders the current ColorScale to the page.
1631
1702
  @param callback Optional callback invoked after rendering completes.
@@ -1637,7 +1708,7 @@ render(e){
1637
1708
  // compute mode, where the caller reads `toScene()` and no DOM is created.
1638
1709
  void 0===this._select&&"compute"!==this.schema.renderMode&&this.select(i.select("body").append("div").node()),
1639
1710
  // Shape <g> Group
1640
- this._group=n.elem("g.d3plus-ColorScale",{parent:this._select});const t=Mt(this),s=this.schema.bucketAxis||!["buckets","jenks","quantile"].includes(this.schema.scale),a=g.transition().duration(this.schema.duration),o={enter:{opacity:0},exit:{opacity:0},parent:this._group,transition:a,update:{opacity:1}},r={labelGroup:n.elem("g.d3plus-ColorScale-labels",Object.assign({condition:s},o)),rectGroup:n.elem("g.d3plus-ColorScale-Rect",Object.assign({condition:s},o)),legendGroup:n.elem("g.d3plus-ColorScale-legend",Object.assign({condition:!s},o)),groupParams:o,gradient:s};return s?At(this,t,r):function(e,t,i){const{horizontal:s,allValues:a,ticks:o,colors:r}=t;n.elem("g.d3plus-ColorScale-axis",Object.assign({condition:i.gradient},i.groupParams));let c=o.reduce((t,i,s)=>{const n=e.schema.bucketFormat.bind(e)(i,s,o,a);
1711
+ this._group=n.elem("g.d3plus-ColorScale",{parent:this._select});const t=Pt(this),s=this.schema.bucketAxis||!["buckets","jenks","quantile"].includes(this.schema.scale),a=g.transition().duration(this.schema.duration),o={enter:{opacity:0},exit:{opacity:0},parent:this._group,transition:a,update:{opacity:1}},r={labelGroup:n.elem("g.d3plus-ColorScale-labels",Object.assign({condition:s},o)),rectGroup:n.elem("g.d3plus-ColorScale-Rect",Object.assign({condition:s},o)),legendGroup:n.elem("g.d3plus-ColorScale-legend",Object.assign({condition:!s},o)),groupParams:o,gradient:s};return s?Tt(this,t,r):function(e,t,i){const{horizontal:s,allValues:a,ticks:o,colors:r}=t;n.elem("g.d3plus-ColorScale-axis",Object.assign({condition:i.gradient},i.groupParams));let c=o.reduce((t,i,s)=>{const n=e.schema.bucketFormat.bind(e)(i,s,o,a);
1641
1712
  // `_isColorScaleBucket` marks these as range buckets (not groupBy rows)
1642
1713
  // so a parent Viz's `_drawLabel` titles their tooltip with the bucket
1643
1714
  // label (`id`) instead of resolving to "undefined" via groupBy.
@@ -1670,7 +1741,7 @@ let i;this.schema.bucketAxis||!["buckets","jenks","quantile"].includes(this.sche
1670
1741
  /**
1671
1742
  Invoked when creating a new class instance, and sets any default parameters.
1672
1743
  @private
1673
- */constructor(){super(),re(this,$t),this._axisClass=new xt,this.schema.axisConfig={gridSize:0},this._axisTest=new xt,this.schema.bucketFormat=(e,i,s,n)=>{const a=this.schema.axisConfig.tickFormat?this.schema.axisConfig.tickFormat:m.formatAbbreviate,o=s[i+1],r=!!i&&s[i-1],c=i===s.length-1;if(e===o||c){const i=c&&e<t.max(n)?"+":"";return`${a(e)}${i}`}{const s=o?o/100:e/100,c=s>=1||s<=-1?Math.round(s).toString().length-1:-1*s.toString().split(".")[1].replace(/([1-9])[1-9].*$/,"$1").length,h=Math.pow(10,c),l=a(r===e&&1===i?t.min([e+h,n.find(t=>t>e&&t<o)]):e),d=a(e&&1===i?o:t.max([o-h,n.reverse().find(t=>t>e&&t<o)]));return this.schema.bucketJoiner(l,d)}},this._data=[],this._labelClass=new Wt,this.schema.labelConfig={fontColor:()=>{const e=this._select?n.backgroundColor(this._select.node()):"rgb(255, 255, 255)";return u.colorContrast(e)},fontSize:12},this._legendClass=new zt,this.schema.legendConfig={shapeConfig:{stroke:u.colorDefaults.dark,strokeWidth:1}},this._outerBounds={width:0,height:0,x:0,y:0},this._rectClass=(new Ve).parent(this),this.schema.rectConfig={stroke:"#999",strokeWidth:1}}}class Pt{
1744
+ */constructor(){super(),re(this,Ot),this._axisClass=new Ct,this.schema.axisConfig={gridSize:0},this._axisTest=new Ct,this.schema.bucketFormat=(e,i,s,n)=>{const a=this.schema.axisConfig.tickFormat?this.schema.axisConfig.tickFormat:m.formatAbbreviate,o=s[i+1],r=!!i&&s[i-1],c=i===s.length-1;if(e===o||c){const i=c&&e<t.max(n)?"+":"";return`${a(e)}${i}`}{const s=o?o/100:e/100,c=s>=1||s<=-1?Math.round(s).toString().length-1:-1*s.toString().split(".")[1].replace(/([1-9])[1-9].*$/,"$1").length,h=Math.pow(10,c),l=a(r===e&&1===i?t.min([e+h,n.find(t=>t>e&&t<o)]):e),d=a(e&&1===i?o:t.max([o-h,n.reverse().find(t=>t>e&&t<o)]));return this.schema.bucketJoiner(l,d)}},this._data=[],this._labelClass=new Gt,this.schema.labelConfig={fontColor:()=>{const e=this._select?n.backgroundColor(this._select.node()):"rgb(255, 255, 255)";return u.colorContrast(e)},fontSize:12},this._legendClass=new $t,this.schema.legendConfig={shapeConfig:{stroke:u.colorDefaults.dark,strokeWidth:1}},this._outerBounds={width:0,height:0,x:0,y:0},this._rectClass=(new Je).parent(this),this.schema.rectConfig={stroke:"#999",strokeWidth:1}}}class Lt{
1674
1745
  /**
1675
1746
  Removes the message from the page.
1676
1747
  */
@@ -1684,14 +1755,14 @@ exit(e,t){e.transition().duration(t).style("opacity",0).transition().remove(),th
1684
1755
  /**
1685
1756
  Invoked when creating a new class instance, and sets any default parameters.
1686
1757
  @private
1687
- */constructor(){this._isVisible=!1}}const Tt={i:"font-style: italic;",em:"font-style: italic;",b:"font-weight: bold;",strong:"font-weight: bold;"};
1688
- /** Parses a "style: foo; …" string from defaultHtmlLookup into TextRun style. */function Ot(e){const t={};for(const i of e.split(";")){const[e,s]=i.split(":").map(e=>e.trim());e&&s&&("font-weight"===e?t.weight=/^\d+$/.test(s)?Number(s):s:"font-style"===e&&(t.style="italic"===s?"italic":"normal"))}return void 0===t.weight&&void 0===t.style?void 0:t}
1758
+ */constructor(){this._isVisible=!1}}const Et={i:"font-style: italic;",em:"font-style: italic;",b:"font-weight: bold;",strong:"font-weight: bold;"};
1759
+ /** Parses a "style: foo; …" string from defaultHtmlLookup into TextRun style. */function Ft(e){const t={};for(const i of e.split(";")){const[e,s]=i.split(":").map(e=>e.trim());e&&s&&("font-weight"===e?t.weight=/^\d+$/.test(s)?Number(s):s:"font-style"===e&&(t.style="italic"===s?"italic":"normal"))}return void 0===t.weight&&void 0===t.style?void 0:t}
1689
1760
  /**
1690
1761
  Walks one wrapped line, applies the regex cleanup (closing dangling
1691
1762
  open tags, opening trailing closing tags), then splits it into runs by the
1692
1763
  configured htmlLookup. Returns the new openTag state for the next line so a
1693
1764
  multi-line bold/italic continues to style subsequent lines.
1694
- */function Rt(e,t,i){
1765
+ */function Wt(e,t,i){
1695
1766
  // textContent escaping: keep entity escaping in sync with render()
1696
1767
  // so SVG output stays identical.
1697
1768
  let s=e.trimEnd().replace(/&([^;&]*)/g,(e,t)=>"amp"===t?e:`&amp;${t}`).replace(/<([^A-z^/]+)/g,(e,t)=>`&lt;${t}`).replace(/<$/g,"&lt;").replace(/(<[^>^/]+>)([^<^>]+)$/g,(e,t,i)=>`${t}${i}${t.replace("<","</")}`).replace(/^([^<^>]+)(<\/[^>]+>)/g,(e,t,i)=>`${i.replace("</","<")}${t}${i}`),n=i;
@@ -1699,15 +1770,15 @@ let s=e.trimEnd().replace(/&([^;&]*)/g,(e,t)=>"amp"===t?e:`&amp;${t}`).replace(/
1699
1770
  // line with the opening tag so the same tag closes within the line.
1700
1771
  n&&!s.startsWith("<")&&(s=`<${n}>${s}`,s.includes(`</${n}>`)||(s+=`</${n}>`));const a=/<([A-z]+)[^>]*>([^<^>]+)<\/[^>]+>/g,o=[];let r,c=0;for(;null!==(r=a.exec(s));){r.index>c&&o.push({text:s.slice(c,r.index)});const i=r[1],a=r[2],h=t[i];h?(
1701
1772
  // If the original raw line contains a closing tag, the tag has terminated.
1702
- n=!e.includes(`</${i}>`)&&i,o.push({text:a,style:Ot(h)})):o.push({text:a}),c=r.index+r[0].length}return c<s.length&&o.push({text:s.slice(c)}),
1773
+ n=!e.includes(`</${i}>`)&&i,o.push({text:a,style:Ft(h)})):o.push({text:a}),c=r.index+r[0].length}return c<s.length&&o.push({text:s.slice(c)}),
1703
1774
  // If the raw line never opened a tag but we already had openTag set, the
1704
1775
  // line is fully inside that tag — wrap it.
1705
1776
  !o.length&&s&&o.push({text:s}),{runs:o,openTag:n}}
1706
1777
  /** Builds the per-line LineRun arrays from wrapped lines, carrying open-tag state. */
1707
- /** Assembles the final TextBoxDatum from the resolved layout values. */function Lt(e,t,i,s){const{lineData:n,line:a,fS:o,lH:r,w:c,h:h,vA:l,style:d,widths:u,padding:m}=s,f=a*r,g=e.schema.rotate(t,i);let p=0===g?"top"===l?0:"middle"===l?h/2-f/2:h-f:0;p-=.1*r;
1778
+ /** Assembles the final TextBoxDatum from the resolved layout values. */function Nt(e,t,i,s){const{lineData:n,line:a,fS:o,lH:r,w:c,h:h,vA:l,style:d,widths:u,padding:m}=s,f=a*r,g=e.schema.rotate(t,i);let p=0===g?"top"===l?0:"middle"===l?h/2-f/2:h-f:0;p-=.1*r;
1708
1779
  // Pre-compute per-line runs from HTML markup, carrying open-tag state
1709
1780
  // across lines so a multi-line <b> continues to bold subsequent lines.
1710
- const y=function(e,t){let i=null;if(e.schema.html){const s=e.schema.html;let n=!1;const a=[];let o=!1;for(const e of t){const{runs:t,openTag:i}=Rt(e,s,n);a.push(t),n=i,t.some(e=>e.style)&&(o=!0)}
1781
+ const y=function(e,t){let i=null;if(e.schema.html){const s=e.schema.html;let n=!1;const a=[];let o=!1;for(const e of t){const{runs:t,openTag:i}=Wt(e,s,n);a.push(t),n=i,t.some(e=>e.style)&&(o=!0)}
1711
1782
  // Only emit runs when at least one line carries a style; otherwise
1712
1783
  // leave runs unset so the renderer emits a single text node.
1713
1784
  o&&(i=a)}return i}
@@ -1715,7 +1786,7 @@ o&&(i=a)}return i}
1715
1786
  /**
1716
1787
  Computes the laid-out text box for a single data point, or null when the
1717
1788
  text is undefined or wraps to no visible lines.
1718
- */function Et(e,i,s){const a=e;let o=e.schema.text(i,s);if(void 0===o)return null;o=`${o}`.trim();const c=e.schema.fontResize(i,s),h=e.schema.lineHeight(i,s)/e.schema.fontSize(i,s);let l=c?e.schema.fontMax(i,s):e.schema.fontSize(i,s),d=c?l*h:e.schema.lineHeight(i,s),u=1,m=[],f={lines:[],truncated:!1,widths:[]};const g={"font-family":n.fontExists(e.schema.fontFamily(i,s)),"font-size":l,"font-weight":e.schema.fontWeight(i,s),"line-height":d},p=n.parseSides(e.schema.padding(i,s)),y=e.schema.height(i,s)-(p.top+p.bottom),_=e.schema.width(i,s)-(p.left+p.right),x=e.schema.shape(i,s),b=r.textWrap().fontFamily(g["font-family"]).fontSize(l).fontWeight(g["font-weight"]).lineHeight(d).maxLines(e.schema.maxLines(i,s)).height(y).overflow(e.schema.overflow(i,s)).shape(x).width(_).split(e.schema.split),k=e.schema.fontMax(i,s),v=e.schema.fontMin(i,s),C=e.schema.verticalAlign(i,s),S=e.schema.split(o,s);return _>v&&(y>d||c&&y>v*h)&&(c&&(l=function(e,i,s,a,o,r,c){const h=n.textWidth(o,r),l=1.165+i/s*.1,// A circle fills only ~π/4 of its bounding box, so scale the usable area
1789
+ */function Ht(e,i,s){const a=e;let o=e.schema.text(i,s);if(void 0===o)return null;o=`${o}`.trim();const c=e.schema.fontResize(i,s),h=e.schema.lineHeight(i,s)/e.schema.fontSize(i,s);let l=c?e.schema.fontMax(i,s):e.schema.fontSize(i,s),d=c?l*h:e.schema.lineHeight(i,s),u=1,m=[],f={lines:[],truncated:!1,widths:[]};const g={"font-family":n.fontExists(e.schema.fontFamily(i,s)),"font-size":l,"font-weight":e.schema.fontWeight(i,s),"line-height":d},p=n.parseSides(e.schema.padding(i,s)),y=e.schema.height(i,s)-(p.top+p.bottom),_=e.schema.width(i,s)-(p.left+p.right),x=e.schema.shape(i,s),b=r.textWrap().fontFamily(g["font-family"]).fontSize(l).fontWeight(g["font-weight"]).lineHeight(d).maxLines(e.schema.maxLines(i,s)).height(y).overflow(e.schema.overflow(i,s)).shape(x).width(_).split(e.schema.split),k=e.schema.fontMax(i,s),v=e.schema.fontMin(i,s),C=e.schema.verticalAlign(i,s),S=e.schema.split(o,s);return _>v&&(y>d||c&&y>v*h)&&(c&&(l=function(e,i,s,a,o,r,c){const h=n.textWidth(o,r),l=1.165+i/s*.1,// A circle fills only ~π/4 of its bounding box, so scale the usable area
1719
1790
  // down to keep the initial font-size guess from overshooting.
1720
1791
  d=i*s*("circle"===c?Math.PI/4:1),u=t.max(h),m=t.sum(h,e=>e*a)*l;if(u>i||m>d){const s=Math.sqrt(d/m),n=i/u,a=t.min([s,n]);e=Math.floor(e*a)}const f=Math.floor(.8*s);return e>f&&(e=f),e}(l,_,y,d,S,g,x)),
1721
1792
  /**
@@ -1724,22 +1795,22 @@ d=i*s*("circle"===c?Math.PI/4:1),u=t.max(h),m=t.sum(h,e=>e*a)*l;if(u>i||m>d){con
1724
1795
  */
1725
1796
  function e(){const i=()=>{u<1?m=[a.schema.ellipsis("",u)]:m[u-1]=a.schema.ellipsis(m[u-1],u)};
1726
1797
  // Constraint the font size
1727
- if(l=t.max([l,v]),l=t.min([l,k]),c&&(d=l*h,b.fontSize(l).lineHeight(d),g["font-size"]=l,g["line-height"]=d),f=b(o),m=f.lines.filter(e=>""!==e),u=m.length,f.truncated)if(c){if(l--,l<v)return l=v,void i();e()}else i()}()),m.length?Lt(e,i,s,{lineData:m,line:u,fS:l,lH:d,w:_,h:y,vA:C,style:g,widths:f.widths,padding:p}):null}
1728
- /** TextBox's fluent accessor schema. Config storage lives on `this.schema.<key>`. */const Ft=[{key:"ariaHidden",coerce:"const",default:L("false")},{key:"delay",coerce:"identity",default:0},{key:"duration",coerce:"identity",default:0},{key:"ellipsis",coerce:"const",default:(e,t)=>t?`${e.replace(/\.|,$/g,"")}...`:""},{key:"fontColor",coerce:"const",default:L("black")},{key:"fontFamily",coerce:"const",default:L(r.fontFamily)},{key:"fontMax",coerce:"const",default:L(50)},{key:"fontMin",coerce:"const",default:L(8)},{key:"fontOpacity",coerce:"const",default:L(1)},{key:"fontResize",coerce:"const",default:L(!1)},{key:"fontSize",coerce:"const",default:L(10)},{key:"fontStroke",coerce:"const",default:L("transparent")},{key:"fontStrokeWidth",coerce:"const",default:L(0)},{key:"fontWeight",coerce:"const",default:L(400)},{key:"height",coerce:"const",default:F("height",200)},{key:"id",coerce:"const",default:(e,t)=>e.id||`${t}`},{key:"lineHeight",coerce:"const"},{key:"maxLines",coerce:"const",default:L(null)},{key:"overflow",coerce:"const",default:L(!1)},{key:"padding",coerce:"const",default:L(0)},{key:"pointerEvents",coerce:"const",default:L("auto")},{key:"renderMode",coerce:"identity",default:"full"},{key:"rotate",coerce:"const",default:L(0)},{key:"rotateAnchor",coerce:"const",default:e=>[e.w/2,e.h/2]},
1798
+ if(l=t.max([l,v]),l=t.min([l,k]),c&&(d=l*h,b.fontSize(l).lineHeight(d),g["font-size"]=l,g["line-height"]=d),f=b(o),m=f.lines.filter(e=>""!==e),u=m.length,f.truncated)if(c){if(l--,l<v)return l=v,void i();e()}else i()}()),m.length?Nt(e,i,s,{lineData:m,line:u,fS:l,lH:d,w:_,h:y,vA:C,style:g,widths:f.widths,padding:p}):null}
1799
+ /** TextBox's fluent accessor schema. Config storage lives on `this.schema.<key>`. */const jt=[{key:"ariaHidden",coerce:"const",default:L("false")},{key:"delay",coerce:"identity",default:0},{key:"duration",coerce:"identity",default:0},{key:"ellipsis",coerce:"const",default:(e,t)=>t?`${e.replace(/\.|,$/g,"")}...`:""},{key:"fontColor",coerce:"const",default:L("black")},{key:"fontFamily",coerce:"const",default:L(r.fontFamily)},{key:"fontMax",coerce:"const",default:L(50)},{key:"fontMin",coerce:"const",default:L(8)},{key:"fontOpacity",coerce:"const",default:L(1)},{key:"fontResize",coerce:"const",default:L(!1)},{key:"fontSize",coerce:"const",default:L(10)},{key:"fontStroke",coerce:"const",default:L("transparent")},{key:"fontStrokeWidth",coerce:"const",default:L(0)},{key:"fontWeight",coerce:"const",default:L(400)},{key:"height",coerce:"const",default:F("height",200)},{key:"id",coerce:"const",default:(e,t)=>e.id||`${t}`},{key:"lineHeight",coerce:"const"},{key:"maxLines",coerce:"const",default:L(null)},{key:"overflow",coerce:"const",default:L(!1)},{key:"padding",coerce:"const",default:L(0)},{key:"pointerEvents",coerce:"const",default:L("auto")},{key:"renderMode",coerce:"identity",default:"full"},{key:"rotate",coerce:"const",default:L(0)},{key:"rotateAnchor",coerce:"const",default:e=>[e.w/2,e.h/2]},
1729
1800
  // Bounding shape for wrapping: "square" (default) fills the full width on
1730
1801
  // every line; "circle" treats width/height as the diameter and shortens
1731
1802
  // lines near the top and bottom to keep text inside the circle. Defaults to
1732
1803
  // the label record's namespaced `__d3plusWrapShape__` (stamped from a shape's
1733
1804
  // `labelBounds`) so Circle labels wrap to the circle without callers
1734
1805
  // configuring anything, while a caller's own `shape` data field is ignored.
1735
- {key:"shape",coerce:"const",default:e=>e.__d3plusWrapShape__??"square"},{key:"split",coerce:"identity",default:r.textSplit},{key:"text",coerce:"const",default:F("text")},{key:"textAnchor",coerce:"const",default:L("start")},{key:"verticalAlign",coerce:"const",default:L("top")},{key:"width",coerce:"const",default:F("width",200)},{key:"x",coerce:"const",default:F("x",0)},{key:"y",coerce:"const",default:F("y",0)}];class Wt extends j{
1806
+ {key:"shape",coerce:"const",default:e=>e.__d3plusWrapShape__??"square"},{key:"split",coerce:"identity",default:r.textSplit},{key:"text",coerce:"const",default:F("text")},{key:"textAnchor",coerce:"const",default:L("start")},{key:"verticalAlign",coerce:"const",default:L("top")},{key:"width",coerce:"const",default:F("width",200)},{key:"x",coerce:"const",default:F("x",0)},{key:"y",coerce:"const",default:F("y",0)}];class Gt extends j{
1736
1807
  /**
1737
1808
  Computes the laid-out text boxes (wrapping, font sizing, per-box position)
1738
1809
  for the current data. Shared by render() and toScene() so both produce
1739
1810
  identical layout.
1740
1811
  @private
1741
1812
  */
1742
- _textData(){return this._data.reduce((e,t,i)=>{const s=Et(this,t,i);return s&&e.push(s),e},[])}
1813
+ _textData(){return this._data.reduce((e,t,i)=>{const s=Ht(this,t,i);return s&&e.push(s),e},[])}
1743
1814
  /**
1744
1815
  Produces a backend-agnostic scene graph for the text boxes, reusing the same
1745
1816
  layout (_textData) and per-line positioning render() applies to the DOM.
@@ -1753,11 +1824,11 @@ _textData(){return this._data.reduce((e,t,i)=>{const s=Et(this,t,i);return s&&e.
1753
1824
  return e&&setTimeout(e,0),this;
1754
1825
  // Standalone use: route toScene() through SvgRenderer. Mirrors Shape.render
1755
1826
  // so `new TextBox().render()` works without a d3-selection body.
1756
- if(void 0===this._select&&"undefined"!=typeof document){const e=i.select("body").append("svg").style("width",`${window.innerWidth}px`).style("height",`${window.innerHeight}px`).node();this.select(e)}if(this._select){const e=this._select,t=e&&"function"==typeof e.node?e.node():e;if(t){const e=this.toScene(),i=e.children.reduce((e,t)=>Math.max(e,(t.transform?.x??0)+(t.width??0)),0),s=e.children.reduce((e,t)=>Math.max(e,(t.transform?.y??0)+(t.height??0)),0),n="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():null,a=n&&n.width||Number(t.getAttribute("width"))||t.clientWidth||0,r=n&&n.height||Number(t.getAttribute("height"))||t.clientHeight||0,c=Math.max(a,i)||400,h=Math.max(r,s)||300;for(;t.firstChild;)t.removeChild(t.firstChild);const l={root:e,width:c,height:h},d=new o.SvgRenderer;d.mount({container:t,width:c,height:h}),d.drawScene(l),this._sceneRenderer=d}}return e&&setTimeout(e,0),this}data(e){return arguments.length?(this._data=e,this):this._data}html(e){return arguments.length?(this.schema.html="boolean"==typeof e?!!e&&Tt:e,this):this.schema.html}select(e){return arguments.length?(this._select=i.select(e),this):this._select}
1827
+ if(void 0===this._select&&"undefined"!=typeof document){const e=i.select("body").append("svg").style("width",`${window.innerWidth}px`).style("height",`${window.innerHeight}px`).node();this.select(e)}if(this._select){const e=this._select,t=e&&"function"==typeof e.node?e.node():e;if(t){const e=this.toScene(),i=e.children.reduce((e,t)=>Math.max(e,(t.transform?.x??0)+(t.width??0)),0),s=e.children.reduce((e,t)=>Math.max(e,(t.transform?.y??0)+(t.height??0)),0),n="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():null,a=n&&n.width||Number(t.getAttribute("width"))||t.clientWidth||0,r=n&&n.height||Number(t.getAttribute("height"))||t.clientHeight||0,c=Math.max(a,i)||400,h=Math.max(r,s)||300;for(;t.firstChild;)t.removeChild(t.firstChild);const l={root:e,width:c,height:h},d=new o.SvgRenderer;d.mount({container:t,width:c,height:h}),d.drawScene(l),this._sceneRenderer=d}}return e&&setTimeout(e,0),this}data(e){return arguments.length?(this._data=e,this):this._data}html(e){return arguments.length?(this.schema.html="boolean"==typeof e?!!e&&Et:e,this):this.schema.html}select(e){return arguments.length?(this._select=i.select(e),this):this._select}
1757
1828
  /**
1758
1829
  Invoked when creating a new class instance, and sets any default parameters.
1759
1830
  @private
1760
- */constructor(){super(),re(this,Ft),this.schema.lineHeight=(e,t)=>1.2*this.schema.fontSize(e,t),this.schema.html=Tt}}const Nt="#bbb";
1831
+ */constructor(){super(),re(this,jt),this.schema.lineHeight=(e,t)=>1.2*this.schema.fontSize(e,t),this.schema.html=Et}}const It="#bbb";
1761
1832
  /**
1762
1833
  Builds the play/pause TextBox. The button's visual is composed into the
1763
1834
  scene in compute mode; its click is wired to `Timeline._togglePlay` via a
@@ -1768,8 +1839,8 @@ if(void 0===this._select&&"undefined"!=typeof document){const e=i.select("body")
1768
1839
  Sets the Timeline-specific defaults that override the inherited Axis config,
1769
1840
  mirroring the original constructor body exactly.
1770
1841
  */
1771
- function Ht(e){e.schema.brushFilter=e=>{const t=e;return!t.button&&t.detail<2},e.schema.domain=[2001,2010],e.schema.gridSize=0,e.schema.handleConfig={fill:u.colorDefaults.light,stroke:"#228be6","stroke-width":2,rx:2,ry:2},e.schema.height=100,e.schema.labelOffset=!1,e.schema.on={},e.orient("bottom"),e._playButtonClass=new Wt,e.schema.playButtonConfig={fontColor:u.colorDefaults.dark,fontSize:15,text:()=>e._playTimer?"⏸":"⏵",textAnchor:"middle",verticalAlign:"middle"},e.schema.selectionConfig={fill:"#228be6","fill-opacity":()=>"buttons"===e._buttonBehaviorCurrent?.3:1,"stroke-width":0},e.schema.shape="Rect",e.schema.barConfig=n.assign({},e.schema.barConfig,{stroke:()=>"buttons"===e._buttonBehaviorCurrent?"transparent":Nt,"stroke-width":()=>"buttons"===e._buttonBehaviorCurrent?0:1}),e.schema.shapeConfig=n.assign({},e.schema.shapeConfig,
1772
- /** Assembles the per-tick shapeConfig overrides (button vs. tick mode). */function(e){return{labelBounds:t=>"buttons"===e._buttonBehaviorCurrent?{x:t.labelBounds.x,y:-e.schema.buttonHeight/2+1,width:t.labelBounds.width,height:e.schema.buttonHeight}:t.labelBounds,labelConfig:{fontColor:()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return u.colorContrast(t)},fontSize:()=>12,verticalAlign:()=>"buttons"===e._buttonBehaviorCurrent?"middle":"top"},fill:()=>"buttons"===e._buttonBehaviorCurrent?"#fff":Nt,stroke:()=>"buttons"===e._buttonBehaviorCurrent?Nt:"transparent",height:t=>"buttons"===e._buttonBehaviorCurrent?e.schema.buttonHeight:t.tick?e.schema.handleSize:0,width:t=>"buttons"===e._buttonBehaviorCurrent?e._ticksWidth/e._availableTicks.length:t.tick?e.schema.domain.map(Number).includes(t.id)?2:1:0,y:t=>"buttons"===e._buttonBehaviorCurrent?"middle"===e.schema.align?e.schema.height/2:"start"===e.schema.align?e._margin.top+e.schema.buttonHeight/2:e.schema.height-e.schema.buttonHeight/2-e._margin.bottom:t.y,rx:t=>"buttons"===e._buttonBehaviorCurrent?0:e.schema.domain.map(Number).includes(t.id)?1:0,ry:t=>"buttons"===e._buttonBehaviorCurrent?0:e.schema.domain.map(Number).includes(t.id)?1:0}}(e)),e._buttonBehaviorCurrent="auto",e._hiddenHandles=!1,e._paddingLeft=0,e._ticksWidth=0}
1842
+ function qt(e){e.schema.brushFilter=e=>{const t=e;return!t.button&&t.detail<2},e.schema.domain=[2001,2010],e.schema.gridSize=0,e.schema.handleConfig={fill:u.colorDefaults.light,stroke:"#228be6","stroke-width":2,rx:2,ry:2},e.schema.height=100,e.schema.labelOffset=!1,e.schema.on={},e.orient("bottom"),e._playButtonClass=new Gt,e.schema.playButtonConfig={fontColor:u.colorDefaults.dark,fontSize:15,text:()=>e._playTimer?"⏸":"⏵",textAnchor:"middle",verticalAlign:"middle"},e.schema.selectionConfig={fill:"#228be6","fill-opacity":()=>"buttons"===e._buttonBehaviorCurrent?.3:1,"stroke-width":0},e.schema.shape="Rect",e.schema.barConfig=n.assign({},e.schema.barConfig,{stroke:()=>"buttons"===e._buttonBehaviorCurrent?"transparent":It,"stroke-width":()=>"buttons"===e._buttonBehaviorCurrent?0:1}),e.schema.shapeConfig=n.assign({},e.schema.shapeConfig,
1843
+ /** Assembles the per-tick shapeConfig overrides (button vs. tick mode). */function(e){return{labelBounds:t=>"buttons"===e._buttonBehaviorCurrent?{x:t.labelBounds.x,y:-e.schema.buttonHeight/2+1,width:t.labelBounds.width,height:e.schema.buttonHeight}:t.labelBounds,labelConfig:{fontColor:()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return u.colorContrast(t)},fontSize:()=>12,verticalAlign:()=>"buttons"===e._buttonBehaviorCurrent?"middle":"top"},fill:()=>"buttons"===e._buttonBehaviorCurrent?"#fff":It,stroke:()=>"buttons"===e._buttonBehaviorCurrent?It:"transparent",height:t=>"buttons"===e._buttonBehaviorCurrent?e.schema.buttonHeight:t.tick?e.schema.handleSize:0,width:t=>"buttons"===e._buttonBehaviorCurrent?e._ticksWidth/e._availableTicks.length:t.tick?e.schema.domain.map(Number).includes(t.id)?2:1:0,y:t=>"buttons"===e._buttonBehaviorCurrent?"middle"===e.schema.align?e.schema.height/2:"start"===e.schema.align?e._margin.top+e.schema.buttonHeight/2:e.schema.height-e.schema.buttonHeight/2-e._margin.bottom:t.y,rx:t=>"buttons"===e._buttonBehaviorCurrent?0:e.schema.domain.map(Number).includes(t.id)?1:0,ry:t=>"buttons"===e._buttonBehaviorCurrent?0:e.schema.domain.map(Number).includes(t.id)?1:0}}(e)),e._buttonBehaviorCurrent="auto",e._hiddenHandles=!1,e._paddingLeft=0,e._ticksWidth=0}
1773
1844
  /**
1774
1845
  Standalone paint for the Timeline's scene (axis ticks/domain line/labels
1775
1846
  plus the play button's pixels). Inside a Viz the parent composes this via
@@ -1778,7 +1849,7 @@ function Ht(e){e.schema.brushFilter=e=>{const t=e;return!t.button&&t.detail<2},e
1778
1849
  would show. This mounts (or reuses) an SvgRenderer on the Timeline's
1779
1850
  container and draws the passed scene beneath that interactive DOM.
1780
1851
  */
1781
- /** Timeline's fluent accessor schema. Config storage lives on `this.schema.<key>`. */const jt=[{key:"buttonPadding",coerce:"identity",default:10},{key:"brushing",coerce:"identity",default:!0},{key:"brushFilter",coerce:"identity"},{key:"brushMin",coerce:"const",default:L(1)},{key:"buttonAlign",coerce:"identity",default:"middle"},{key:"buttonBehavior",coerce:"identity",default:"auto"},{key:"buttonHeight",coerce:"identity",default:24},{key:"handleSize",coerce:"identity",default:6},{key:"playButton",coerce:"identity",default:!0},{key:"playButtonInterval",coerce:"identity",default:1e3},{key:"selection",coerce:"identity"},{key:"snapping",coerce:"identity",default:!0}];class Gt extends xt{
1852
+ /** Timeline's fluent accessor schema. Config storage lives on `this.schema.<key>`. */const Yt=[{key:"buttonPadding",coerce:"identity",default:10},{key:"brushing",coerce:"identity",default:!0},{key:"brushFilter",coerce:"identity"},{key:"brushMin",coerce:"const",default:L(1)},{key:"buttonAlign",coerce:"identity",default:"middle"},{key:"buttonBehavior",coerce:"identity",default:"auto"},{key:"buttonHeight",coerce:"identity",default:24},{key:"handleSize",coerce:"identity",default:6},{key:"playButton",coerce:"identity",default:!0},{key:"playButtonInterval",coerce:"identity",default:1e3},{key:"selection",coerce:"identity"},{key:"snapping",coerce:"identity",default:!0}];class Kt extends Ct{
1782
1853
  /**
1783
1854
  Triggered on brush "brush".
1784
1855
  @private
@@ -1858,7 +1929,7 @@ if(!this.schema.brushing&&"buttons"!==this._buttonBehaviorCurrent){const e=+i.at
1858
1929
  */_updateDomain(e){const s=i.pointers(e,this._select.node());let a=e.selection&&this.schema.brushing||!s.length?e.selection:[s[0][0],s[0][0]];"ticks"===this._buttonBehaviorCurrent&&(a=a.map(e=>this._d3Scale.invert(e))),a=a.map(Number);const o="ticks"===this._buttonBehaviorCurrent?this._availableTicks.map(Number):this._d3Scale.range();if("ticks"===this._buttonBehaviorCurrent){
1859
1930
  // find closest min and max ticks from data
1860
1931
  // and their indices in the ticks Array
1861
- let e=n.date(y.closest(a[0],o)),i=o.indexOf(+e),s=n.date(y.closest(a[1],o)),r=o.indexOf(+s),c=Math.abs(r-i);const h=this.schema.brushMin()-1;
1932
+ let e=n.date(p.closest(a[0],o)),i=o.indexOf(+e),s=n.date(p.closest(a[1],o)),r=o.indexOf(+s),c=Math.abs(r-i);const h=this.schema.brushMin()-1;
1862
1933
  // if the min and max are not far enough apart to satisfy
1863
1934
  // brushMin, then forcibly extend the domain.
1864
1935
  c<h&&(
@@ -1866,7 +1937,7 @@ c<h&&(
1866
1937
  r=t.min([o.length-1,r+(h-c)]),s=o[r],c=Math.abs(r-i),
1867
1938
  // if the domain is still not far enough apart, extent the minDomain
1868
1939
  // as far as possible to allow for brushMin
1869
- c<h&&(i=t.max([0,i-(h-c)]),e=o[i])),a[0]=e,a[1]=s}else a[0]=y.closest(a[0],o),a[1]=y.closest(a[1],o);
1940
+ c<h&&(i=t.max([0,i-(h-c)]),e=o[i])),a[0]=e,a[1]=s}else a[0]=p.closest(a[0],o),a[1]=p.closest(a[1],o);
1870
1941
  // if the brush event has finished, update the current "selection" value
1871
1942
  const r=+a[0]===+a[1];return"brush"!==e.type&&"end"!==e.type||(this.schema.selection="ticks"===this._buttonBehaviorCurrent?r?a[0]:a:r?n.date(this._availableTicks[o.indexOf(a[0])]):[n.date(this._availableTicks[o.indexOf(a[0])]),n.date(this._availableTicks[o.indexOf(a[1])])]),a}
1872
1943
  /**
@@ -1953,21 +2024,21 @@ const o=n.elem("rect.d3plus-Timeline-play-hit",{parent:i,condition:s.length>0});
1953
2024
  /**
1954
2025
  Invoked when creating a new class instance, and overrides any default parameters inherited from Axis.
1955
2026
  @private
1956
- */constructor(){super(),re(this,jt),Ht(this),
2027
+ */constructor(){super(),re(this,Yt),qt(this),
1957
2028
  // Timeline composes its brush/play-button after super.render(); it paints
1958
2029
  // the scene itself at the end of render() so Axis.render() must not paint
1959
2030
  // a half-built scene mid-way through.
1960
2031
  this._managesOwnScenePaint=!0}}
1961
- /** Tooltip's fluent accessor schema. Config storage lives on `this.schema.<key>`. */const It=[{key:"arrow",coerce:"const",default:F("arrow","")},{key:"background",coerce:"const",default:L(u.colorDefaults.light)},{key:"body",coerce:"const",default:F("body","")},{key:"border",coerce:"const",default:L("1px solid rgba(0, 0, 0, 0.25)")},{key:"borderRadius",coerce:"const",default:L("4px")},{key:"className",coerce:"identity",default:"d3plus-tooltip"},{key:"footer",coerce:"const",default:F("footer","")},{key:"height",coerce:"const",default:L("auto")},{key:"id",coerce:"const",default:(e,t)=>`${t}`},{key:"offset",coerce:"const",default:L(5)},{key:"padding",coerce:"const",default:L("10px")},{key:"pointerEvents",coerce:"const",default:L("auto")},{key:"tbody",coerce:"identity",default:[]},{key:"thead",coerce:"identity",default:[]},{key:"title",coerce:"const",default:F("title","")},{key:"maxWidth",coerce:"const",default:L("300px")},{key:"minWidth",coerce:"const",default:L("200px")},{key:"width",coerce:"const",default:L("auto")}];
2032
+ /** Tooltip's fluent accessor schema. Config storage lives on `this.schema.<key>`. */const Vt=[{key:"arrow",coerce:"const",default:F("arrow","")},{key:"background",coerce:"const",default:L(u.colorDefaults.light)},{key:"body",coerce:"const",default:F("body","")},{key:"border",coerce:"const",default:L("1px solid rgba(0, 0, 0, 0.25)")},{key:"borderRadius",coerce:"const",default:L("4px")},{key:"className",coerce:"identity",default:"d3plus-tooltip"},{key:"footer",coerce:"const",default:F("footer","")},{key:"height",coerce:"const",default:L("auto")},{key:"id",coerce:"const",default:(e,t)=>`${t}`},{key:"offset",coerce:"const",default:L(5)},{key:"padding",coerce:"const",default:L("10px")},{key:"pointerEvents",coerce:"const",default:L("auto")},{key:"tbody",coerce:"identity",default:[]},{key:"thead",coerce:"identity",default:[]},{key:"title",coerce:"const",default:F("title","")},{key:"maxWidth",coerce:"const",default:L("300px")},{key:"minWidth",coerce:"const",default:L("200px")},{key:"width",coerce:"const",default:L("auto")}];
1962
2033
  /**
1963
2034
  * Creates a virtual reference element for Floating UI.
1964
2035
  * @param {Number[]} position
1965
2036
  * @private
1966
- */function qt(e=[0,0]){return{getBoundingClientRect:()=>({width:0,height:0,x:e[0],y:e[1],top:e[1],right:e[0],bottom:e[1],left:e[0]})}}
2037
+ */function Xt(e=[0,0]){return{getBoundingClientRect:()=>({width:0,height:0,x:e[0],y:e[1],top:e[1],right:e[0],bottom:e[1],left:e[0]})}}
1967
2038
  /**
1968
2039
  * Positions a tooltip using Floating UI.
1969
2040
  * @private
1970
- */async function Yt(e,t,i,s,n,a){const{x:o,y:r,placement:c,middlewareData:h}=await _.computePosition(e,t,{
2041
+ */async function Ut(e,t,i,s,n,a){const{x:o,y:r,placement:c,middlewareData:h}=await _.computePosition(e,t,{
1971
2042
  // `fixed` positions the tooltip against the viewport, so it can overflow
1972
2043
  // its chart's bounds and `flip`/`shift` keep it inside the viewport
1973
2044
  // (not the chart container). Pairs with the body-level portal in
@@ -1981,15 +2052,15 @@ strategy:"fixed",placement:"top",middleware:[_.offset(s+n),_.flip({fallbackPlace
1981
2052
  Creates DIV elements with a unique class and styles.
1982
2053
  @private
1983
2054
  */
1984
- function Kt(e,t,i,s){t.append("div").attr("class",`d3plus-tooltip-${s}`).attr("id",(t,i)=>`d3plus-tooltip-${s}-${t?e.schema.id(t,i):""}`);const a=i.select(`.d3plus-tooltip-${s}`).html((t,i)=>e.schema[s](t,i)).style("display",(t,i)=>{const n=e.schema[s](t,i);return!1!==n&&null!=n?"block":"none"});n.stylize(a,e.schema[`${s}Style`])}
2055
+ function Jt(e,t,i,s){t.append("div").attr("class",`d3plus-tooltip-${s}`).attr("id",(t,i)=>`d3plus-tooltip-${s}-${t?e.schema.id(t,i):""}`);const a=i.select(`.d3plus-tooltip-${s}`).html((t,i)=>e.schema[s](t,i)).style("display",(t,i)=>{const n=e.schema[s](t,i);return!1!==n&&null!=n?"block":"none"});n.stylize(a,e.schema[`${s}Style`])}
1985
2056
  /**
1986
2057
  Sets styles for both enter and update.
1987
2058
  @private
1988
- */function Xt(e,t){t.style("background",e.schema.background).style("border-radius",e.schema.borderRadius).style("pointer-events",e.schema.pointerEvents).style("padding",e.schema.padding).style("max-width",e.schema.maxWidth).style("min-width",e.schema.minWidth).style("width",e.schema.width).style("height",e.schema.height).style("border",e.schema.border)}
2059
+ */function Qt(e,t){t.style("background",e.schema.background).style("border-radius",e.schema.borderRadius).style("pointer-events",e.schema.pointerEvents).style("padding",e.schema.padding).style("max-width",e.schema.maxWidth).style("min-width",e.schema.minWidth).style("width",e.schema.width).style("height",e.schema.height).style("border",e.schema.border)}
1989
2060
  /**
1990
2061
  Builds the tooltip table (thead + tbody) from the configured columns/rows.
1991
2062
  @private
1992
- */class Vt extends j{
2063
+ */class Zt extends j{
1993
2064
  /**
1994
2065
  The inner return object and draw function that gets assigned the public methods.
1995
2066
  @private
@@ -2004,7 +2075,7 @@ if(!e._parentEl)return n.elem("div#d3plus-portal");
2004
2075
  // styling/clipping from the chart's container (e.g. a docs page reset).
2005
2076
  // `_parentEl` (set via parent()) still scopes ownership so multiple charts
2006
2077
  // on a page each get their own portal rather than fighting over one.
2007
- let t=e._portalEl??null;return t&&t.isConnected||(t=document.createElement("div"),t.setAttribute("class","d3plus-tooltip-portal"),t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.width="0",t.style.height="0",t.style.pointerEvents="none",document.body.appendChild(t),e._portalEl=t),i.select(t)}(this),a=s.selectAll(`.${this.schema.className}`).data(this._data,this.schema.id),o=a.enter().append("div").attr("class",this.schema.className),r=a.merge(o);return n.stylize(r,this.schema.tooltipStyle),Kt(this,o,r,"title"),Kt(this,o,r,"body"),function(e,t,i,s){const a=t.append("table").attr("class","d3plus-tooltip-table"),o=i.select(".d3plus-tooltip-table");n.stylize(o,e.schema.tableStyle),a.append("thead").attr("class","d3plus-tooltip-thead");const r=i.select(".d3plus-tooltip-thead");n.stylize(r,e.schema.theadStyle);const c=r.selectAll("tr").data([0]),h=c.enter().append("tr");c.exit().remove();const l=c.merge(h);n.stylize(l,e.schema.trStyle);const d=l.selectAll("th").data(e.schema.thead);d.enter().append("th").merge(d).html(s),d.exit().remove(),a.append("tbody").attr("class","d3plus-tooltip-tbody");const u=i.select(".d3plus-tooltip-tbody");n.stylize(u,e.schema.tbodyStyle);const m=u.selectAll("tr").data(e.schema.tbody),f=m.enter().append("tr");m.exit().remove();const g=m.merge(f);n.stylize(g,e.schema.trStyle);const p=g.selectAll("td").data(e=>e);p.enter().append("td").merge(p).html(s),n.stylize(p,e.schema.tdStyle)}
2078
+ let t=e._portalEl??null;return t&&t.isConnected||(t=document.createElement("div"),t.setAttribute("class","d3plus-tooltip-portal"),t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.width="0",t.style.height="0",t.style.pointerEvents="none",document.body.appendChild(t),e._portalEl=t),i.select(t)}(this),a=s.selectAll(`.${this.schema.className}`).data(this._data,this.schema.id),o=a.enter().append("div").attr("class",this.schema.className),r=a.merge(o);return n.stylize(r,this.schema.tooltipStyle),Jt(this,o,r,"title"),Jt(this,o,r,"body"),function(e,t,i,s){const a=t.append("table").attr("class","d3plus-tooltip-table"),o=i.select(".d3plus-tooltip-table");n.stylize(o,e.schema.tableStyle),a.append("thead").attr("class","d3plus-tooltip-thead");const r=i.select(".d3plus-tooltip-thead");n.stylize(r,e.schema.theadStyle);const c=r.selectAll("tr").data([0]),h=c.enter().append("tr");c.exit().remove();const l=c.merge(h);n.stylize(l,e.schema.trStyle);const d=l.selectAll("th").data(e.schema.thead);d.enter().append("th").merge(d).html(s),d.exit().remove(),a.append("tbody").attr("class","d3plus-tooltip-tbody");const u=i.select(".d3plus-tooltip-tbody");n.stylize(u,e.schema.tbodyStyle);const m=u.selectAll("tr").data(e.schema.tbody),f=m.enter().append("tr");m.exit().remove();const g=m.merge(f);n.stylize(g,e.schema.trStyle);const p=g.selectAll("td").data(e=>e);p.enter().append("td").merge(p).html(s),n.stylize(p,e.schema.tdStyle)}
2008
2079
  /**
2009
2080
  Binds enter/update/exit: assigns ids, positions each tooltip via Floating
2010
2081
  UI, refreshes positions on update, and cleans up refs on exit.
@@ -2014,7 +2085,7 @@ let t=e._portalEl??null;return t&&t.isConnected||(t=document.createElement("div"
2014
2085
  Fetches table contents given functions or values.
2015
2086
  @private
2016
2087
  */
2017
- function(e){if("function"==typeof e){const s=i.select(this.parentNode.parentNode).datum();return e(s,t._data.indexOf(s),s)}return e}),Kt(this,o,r,"footer"),Kt(this,o,r,"arrow"),function(e,t,i,s){t.attr("id",(t,i)=>`d3plus-tooltip-${t?e.schema.id(t,i):""}`).style("visibility","hidden").call(t=>Xt(e,t)).each(function(t,i){const s=e.schema.id(t,i),n=document.getElementById(`d3plus-tooltip-${s}`),a=document.getElementById(`d3plus-tooltip-arrow-${s}`),o=a.offsetHeight,r=a.getBoundingClientRect().height/2;a.style.bottom=`-${o/2}px`;const c=e.schema.position(t,i),h=Array.isArray(c)?qt(c):c;e._tooltipRefs[s]={reference:h,arrowEl:a,tooltip:n,arrowHeight:o,arrowDistance:r},Yt(h,n,a,e.schema.offset(t,i),r,o)}),i.each(function(t,i){const s=e.schema.id(t,i),n=e.schema.position(t,i),a=e._tooltipRefs[s];a&&(a.reference=Array.isArray(n)?qt(n):n,Yt(a.reference,a.tooltip,a.arrowEl,e.schema.offset(t,i),a.arrowDistance,a.arrowHeight))}).call(t=>Xt(e,t)),s.exit().each(function(t,i){const s=e.schema.id(t,i);delete e._tooltipRefs[s]}).remove()}(this,o,r,a),e&&setTimeout(e,100),this}arrowStyle(e){return arguments.length?(this.schema.arrowStyle=n.assign(this.schema.arrowStyle,e),this):this.schema.arrowStyle}bodyStyle(e){return arguments.length?(this.schema.bodyStyle=n.assign(this.schema.bodyStyle,e),this):this.schema.bodyStyle}parent(e){if(!arguments.length)return this._parentEl;const t=this._parentEl,i=e||void 0;return t&&t!==i&&this._portalEl&&(
2088
+ function(e){if("function"==typeof e){const s=i.select(this.parentNode.parentNode).datum();return e(s,t._data.indexOf(s),s)}return e}),Jt(this,o,r,"footer"),Jt(this,o,r,"arrow"),function(e,t,i,s){t.attr("id",(t,i)=>`d3plus-tooltip-${t?e.schema.id(t,i):""}`).style("visibility","hidden").call(t=>Qt(e,t)).each(function(t,i){const s=e.schema.id(t,i),n=document.getElementById(`d3plus-tooltip-${s}`),a=document.getElementById(`d3plus-tooltip-arrow-${s}`),o=a.offsetHeight,r=a.getBoundingClientRect().height/2;a.style.bottom=`-${o/2}px`;const c=e.schema.position(t,i),h=Array.isArray(c)?Xt(c):c;e._tooltipRefs[s]={reference:h,arrowEl:a,tooltip:n,arrowHeight:o,arrowDistance:r},Ut(h,n,a,e.schema.offset(t,i),r,o)}),i.each(function(t,i){const s=e.schema.id(t,i),n=e.schema.position(t,i),a=e._tooltipRefs[s];a&&(a.reference=Array.isArray(n)?Xt(n):n,Ut(a.reference,a.tooltip,a.arrowEl,e.schema.offset(t,i),a.arrowDistance,a.arrowHeight))}).call(t=>Qt(e,t)),s.exit().each(function(t,i){const s=e.schema.id(t,i);delete e._tooltipRefs[s]}).remove()}(this,o,r,a),e&&setTimeout(e,100),this}arrowStyle(e){return arguments.length?(this.schema.arrowStyle=n.assign(this.schema.arrowStyle,e),this):this.schema.arrowStyle}bodyStyle(e){return arguments.length?(this.schema.bodyStyle=n.assign(this.schema.bodyStyle,e),this):this.schema.bodyStyle}parent(e){if(!arguments.length)return this._parentEl;const t=this._parentEl,i=e||void 0;return t&&t!==i&&this._portalEl&&(
2018
2089
  // Switching parents: tear down this Tooltip's own (body-level) portal
2019
2090
  // so it doesn't sit orphaned. A re-render against the new parent
2020
2091
  // creates a fresh one. Other Tooltip instances own their own portals.
@@ -2022,7 +2093,7 @@ this._portalEl.remove(),this._portalEl=void 0),this._parentEl=i,this}data(e){ret
2022
2093
  /**
2023
2094
  Invoked when creating a new class instance, and sets any default parameters.
2024
2095
  @private
2025
- */constructor(){super(),re(this,It),this._data=[],this._tooltipRefs={},this.schema.arrowStyle={content:"",background:"inherit",border:"inherit","border-width":"0 1px 1px 0",height:"10px",position:"absolute",transform:"rotate(45deg)",width:"10px"},this.schema.bodyStyle={"font-size":"12px","font-weight":"400","z-index":"1"},this.schema.footerStyle={"font-size":"9px","font-weight":"400","margin-top":"5px","z-index":"1"},this.schema.position=e=>[e.x,e.y],this.schema.tableStyle={"border-collapse":"collapse","border-spacing":"0",width:"100%"},this.schema.tbodyStyle={"font-size":"12px","text-align":"center"},this.schema.theadStyle={"font-size":"12px","font-weight":"600","text-align":"center"},this.schema.titleStyle={"font-size":"14px","font-weight":"600","margin-bottom":"5px","text-align":"center"},this.schema.tooltipStyle={"box-shadow":"0 1px 5px rgba(0, 0, 0, 0.25)",color:(e,t)=>u.colorContrast(this.schema.background(e,t)),"font-family":r.fontFamilyStringify(r.fontFamily)},this.schema.trStyle={"border-top":(e,t)=>t?"1px solid rgba(0, 0, 0, 0.1)":"none"},this.schema.tdStyle={}}}
2096
+ */constructor(){super(),re(this,Vt),this._data=[],this._tooltipRefs={},this.schema.arrowStyle={content:"",background:"inherit",border:"inherit","border-width":"0 1px 1px 0",height:"10px",position:"absolute",transform:"rotate(45deg)",width:"10px"},this.schema.bodyStyle={"font-size":"12px","font-weight":"400","z-index":"1"},this.schema.footerStyle={"font-size":"9px","font-weight":"400","margin-top":"5px","z-index":"1"},this.schema.position=e=>[e.x,e.y],this.schema.tableStyle={"border-collapse":"collapse","border-spacing":"0",width:"100%"},this.schema.tbodyStyle={"font-size":"12px","text-align":"center"},this.schema.theadStyle={"font-size":"12px","font-weight":"600","text-align":"center"},this.schema.titleStyle={"font-size":"14px","font-weight":"600","margin-bottom":"5px","text-align":"center"},this.schema.tooltipStyle={"box-shadow":"0 1px 5px rgba(0, 0, 0, 0.25)",color:(e,t)=>u.colorContrast(this.schema.background(e,t)),"font-family":r.fontFamilyStringify(r.fontFamily)},this.schema.trStyle={"border-top":(e,t)=>t?"1px solid rgba(0, 0, 0, 0.1)":"none"},this.schema.tdStyle={}}}
2026
2097
  /**
2027
2098
  Default label function for the legend. Bound to a Viz instance; forwards
2028
2099
  to `viz._drawLabel` at the legend's group-depth.
@@ -2030,22 +2101,22 @@ this._portalEl.remove(),this._portalEl=void 0),this._parentEl=i,this}data(e){ret
2030
2101
  Lived in drawSteps/drawLegend.ts until the panel drawSteps were retired
2031
2102
  in favor of FeatureModules; this is the only piece of that file with
2032
2103
  surviving call sites (Viz, Tree, events/mousemove.legend).
2033
- */function Ut(e,t){return this._drawLabel(e,t,this._legendDepth)}
2104
+ */function ei(e,t){return this._drawLabel(e,t,this._legendDepth)}
2034
2105
  /**
2035
2106
  @module clickShape
2036
2107
  On click event for all shapes in a Viz.
2037
2108
  @private
2038
- */function Jt(e,t,i,s){if(s.stopPropagation(),this._drawDepth<this.schema.groupBy.length-1){this._select.style("cursor","auto");const i=this.schema.groupBy[this._drawDepth],s=i(e,t);this.hover(!1),this.schema.tooltip(e,t)&&this._tooltipClass.data([]).render();const n=this.schema.filter;this._history.push({depth:this.schema.depth,filter:n}),this.config({depth:this._drawDepth+1,filter:(e,t)=>(!n||n(e,t))&&i(e,t)===s}).render()}}
2109
+ */function ti(e,t,i,s){if(s.stopPropagation(),this._drawDepth<this.schema.groupBy.length-1){this._select.style("cursor","auto");const i=this.schema.groupBy[this._drawDepth],s=i(e,t);this.hover(!1),this.schema.tooltip(e,t)&&this._tooltipClass.data([]).render();const n=this.schema.filter;this._history.push({depth:this.schema.depth,filter:n}),this.config({depth:this._drawDepth+1,filter:(e,t)=>(!n||n(e,t))&&i(e,t)===s}).render()}}
2039
2110
  /**
2040
2111
  @module clickLegend
2041
2112
  On click event for all legend shapes in a Viz.
2042
2113
  @private
2043
- */function Qt(e,i,s,n){this._select.style("cursor","auto"),this.schema.tooltip(e,i)&&this._tooltipClass.data([]).render();let a=this._id(e,i);a instanceof Array||(a=[a]);const o=this._hidden.indexOf(a[0]),r=this._solo.indexOf(a[0]),c=t.merge(this._legendClass.data().map((e,t)=>{let i=this._id(e,t);return i instanceof Array||(i=[i]),i})).length;this.schema.legendFilterInvert.bind(this)(this)?n.shiftKey?o<0&&!this._solo.length?(this._hidden=this._hidden.concat(a),r>=0&&(this._solo=[]),this._hidden.length===c&&(this._hidden=[]),this.render()):r>=0&&(this._solo=[],this._hidden=[],this.render()):(r<0&&this._hidden.length<c-1?(this._solo=a,this._hidden=[]):(this._solo=[],this._hidden=[]),this.render()):n.shiftKey&&r<0?(this._solo=a,this._hidden=[],this.render()):n.shiftKey||(o>=0?this._hidden.splice(o,a.length):r>=0?(this._solo=[],this._hidden=[]):this._solo.length&&r<0?(this._solo=this._solo.concat(a),this._solo.length===c&&(this._solo=[])):(this._hidden=this._hidden.concat(a),this._hidden.length===c&&(this._hidden=[])),this.render())}
2114
+ */function ii(e,i,s,n){this._select.style("cursor","auto"),this.schema.tooltip(e,i)&&this._tooltipClass.data([]).render();let a=this._id(e,i);a instanceof Array||(a=[a]);const o=this._hidden.indexOf(a[0]),r=this._solo.indexOf(a[0]),c=t.merge(this._legendClass.data().map((e,t)=>{let i=this._id(e,t);return i instanceof Array||(i=[i]),i})).length;this.schema.legendFilterInvert.bind(this)(this)?n.shiftKey?o<0&&!this._solo.length?(this._hidden=this._hidden.concat(a),r>=0&&(this._solo=[]),this._hidden.length===c&&(this._hidden=[]),this.render()):r>=0&&(this._solo=[],this._hidden=[],this.render()):(r<0&&this._hidden.length<c-1?(this._solo=a,this._hidden=[]):(this._solo=[],this._hidden=[]),this.render()):n.shiftKey&&r<0?(this._solo=a,this._hidden=[],this.render()):n.shiftKey||(o>=0?this._hidden.splice(o,a.length):r>=0?(this._solo=[],this._hidden=[]):this._solo.length&&r<0?(this._solo=this._solo.concat(a),this._solo.length===c&&(this._solo=[])):(this._hidden=this._hidden.concat(a),this._hidden.length===c&&(this._hidden=[])),this.render())}
2044
2115
  /**
2045
2116
  @module mouseEnter
2046
2117
  On mouseenter event for all shapes in a Viz.
2047
2118
  @private
2048
- */function Zt(e,t){
2119
+ */function si(e,t){
2049
2120
  // ColorScale range swatch: it has no groupBy id, so highlight every datum
2050
2121
  // whose colorScale value falls in this swatch's color range — mirroring the
2051
2122
  // regular legend, which highlights the data shapes by id. `colorScaleBucketOf`
@@ -2059,7 +2130,7 @@ const i=_e(e);if(i){const e=function(e,t){const i=pe(e);return i?(e,s)=>i.colorO
2059
2130
  @module mouseLeave
2060
2131
  On mouseleave event for all shapes in a Viz.
2061
2132
  @private
2062
- */function ei(e,t){setTimeout(()=>{let i=e;for(;i&&i.__d3plus__&&i.data;)i=i.data;
2133
+ */function ni(e,t){setTimeout(()=>{let i=e;for(;i&&i.__d3plus__&&i.data;)i=i.data;
2063
2134
  // A shape and its text label are separate scene nodes over the same datum,
2064
2135
  // so crossing between them fires a leave for one then an enter for the
2065
2136
  // other. `_hoverDatum` is what the pointer rests on once that hand-off
@@ -2077,18 +2148,18 @@ let s=this._hoverDatum;for(;s&&s.__d3plus__&&s.data;)s=s.data;if(s&&this._id(s)=
2077
2148
  Tooltip logic for a specified data point.
2078
2149
  @param config Optional configuration methods for the Tooltip class.
2079
2150
  @private
2080
- */function ti(e,i,s,n){const a=n.touches?[n.touches[0].clientX,n.touches[0].clientY]:[n.clientX,n.clientY],o=t.merge(this._legendClass.data().map((e,t)=>{let i=this._id(e,t);return i instanceof Array||(i=[i]),i})).length;if(e&&this.schema.tooltip(e,i)){let t=this._id(e,i);t instanceof Array&&(t=t[0]);const n=this.schema.translate,r=Qt.bind(this).toString(),c=Object.keys(this.schema.on).some(e=>// all valid click event keys,
2151
+ */function ai(e,i,s,n){const a=n.touches?[n.touches[0].clientX,n.touches[0].clientY]:[n.clientX,n.clientY],o=t.merge(this._legendClass.data().map((e,t)=>{let i=this._id(e,t);return i instanceof Array||(i=[i]),i})).length;if(e&&this.schema.tooltip(e,i)){let t=this._id(e,i);t instanceof Array&&(t=t[0]);const n=this.schema.translate,r=ii.bind(this).toString(),c=Object.keys(this.schema.on).some(e=>// all valid click event keys,
2081
2152
  ["click","click.legend"].includes(e)&&// truthy values (no nulls),
2082
2153
  this.schema.on[e]&&// and it is not our default click.legend function
2083
2154
  this.schema.on[e].toString()!==r),h=this.schema.on["click.legend"]&&this.schema.on["click.legend"].toString()===r,l=this._drawDepth<this.schema.groupBy.length-1;
2084
2155
  // only show the hand cursor when the shape has a click event
2085
- this._select.style("cursor",c||h&&l?"pointer":"auto");const d=this.schema.legendFilterInvert.bind(this)(this),u=this._solo.includes(t),m=this._hidden.includes(t);this._tooltipClass.data([s||e]).footer(!!h&&(d?this._solo.length&&!u||m?n("Click to Highlight"):1===this._solo.length&&u||this._hidden.length===o-1?n("Click to Show All"):`${n("Click to Highlight")}<br />${n("Shift+Click to Hide")}`:this._solo.length&&!u||m?`${n("Click to Show")}<br />${n("Shift+Click to Highlight")}`:1===this._solo.length&&u||this._hidden.length===o-1?n("Click to Show All"):`${n("Click to Hide")}<br />${n("Shift+Click to Highlight")}`)).title(this.schema.legendConfig.label?this._legendClass.label():Ut.bind(this)).position(a).config(G.bind(this)(this.schema.tooltipConfig)).config(G.bind(this)(this.schema.legendTooltip)).render()}}
2156
+ this._select.style("cursor",c||h&&l?"pointer":"auto");const d=this.schema.legendFilterInvert.bind(this)(this),u=this._solo.includes(t),m=this._hidden.includes(t);this._tooltipClass.data([s||e]).footer(!!h&&(d?this._solo.length&&!u||m?n("Click to Highlight"):1===this._solo.length&&u||this._hidden.length===o-1?n("Click to Show All"):`${n("Click to Highlight")}<br />${n("Shift+Click to Hide")}`:this._solo.length&&!u||m?`${n("Click to Show")}<br />${n("Shift+Click to Highlight")}`:1===this._solo.length&&u||this._hidden.length===o-1?n("Click to Show All"):`${n("Click to Hide")}<br />${n("Shift+Click to Highlight")}`)).title(this.schema.legendConfig.label?this._legendClass.label():ei.bind(this)).position(a).config(G.bind(this)(this.schema.tooltipConfig)).config(G.bind(this)(this.schema.legendTooltip)).render()}}
2086
2157
  /**
2087
2158
  @module mouseMoveShape
2088
2159
  Tooltip logic for a specified data point.
2089
2160
  @param config Optional configuration methods for the Tooltip class.
2090
2161
  @private
2091
- */function ii(e,t,i,s){if(e&&this.schema.tooltip(e,t)){const t=Jt.bind(this).toString(),n=Object.keys(this.schema.on).some(e=>// all valid click event keys,
2162
+ */function oi(e,t,i,s){if(e&&this.schema.tooltip(e,t)){const t=ti.bind(this).toString(),n=Object.keys(this.schema.on).some(e=>// all valid click event keys,
2092
2163
  ["click","click.shape"].includes(e)&&// truthy values (no nulls),
2093
2164
  this.schema.on[e]&&// and it is not our default click.shape function
2094
2165
  this.schema.on[e].toString()!==t),a=this.schema.on["click.shape"]&&this.schema.on["click.shape"].toString()===t,o=this._drawDepth<this.schema.groupBy.length-1;
@@ -2104,17 +2175,17 @@ let c=i||e;for(;c&&c.__d3plus__&&c.data;)c=c.data;this._tooltipClass.data([c]).f
2104
2175
  * Default padding logic that will return false if the screen is less than 600 pixels wide.
2105
2176
  * @private
2106
2177
  */
2107
- function si(){return"undefined"==typeof window||window.innerWidth>600}
2178
+ function ri(){return"undefined"==typeof window||window.innerWidth>600}
2108
2179
  /**
2109
2180
  Minimal LRU cache backed by a Map (insertion-order iteration enables O(1) eviction).
2110
2181
  Only .get() and .set() are used by Viz.
2111
2182
  @private
2112
- */class ni{get(e){if(!this._map.has(e))return;const t=this._map.get(e);return this._map.delete(e),this._map.set(e,t),t}set(e,t){this._map.delete(e),this._map.size>=this._cap&&this._map.delete(this._map.keys().next().value),this._map.set(e,t)}constructor(e){this._cap=e,this._map=new Map}}
2183
+ */class ci{get(e){if(!this._map.has(e))return;const t=this._map.get(e);return this._map.delete(e),this._map.set(e,t),t}set(e,t){this._map.delete(e),this._map.size>=this._cap&&this._map.delete(this._map.keys().next().value),this._map.set(e,t)}constructor(e){this._cap=e,this._map=new Map}}
2113
2184
  // E4: Viz's identity-coerce accessor schema. installFluent installs methods on
2114
2185
  // Viz.prototype (once via WeakSet) so BaseClass.config() reflection picks them
2115
2186
  // up. Constructor assignments below seed defaults (e.g. `this.schema.duration = 600`);
2116
2187
  // installFluent skips slots already set, so constructor values win.
2117
- const ai=[{key:"ariaHidden",coerce:"identity"},{key:"cache",coerce:"identity"},{key:"colorOrdinal",coerce:"identity",default:!1},{key:"dataCutoff",coerce:"identity"},{key:"depth",coerce:"identity"},{key:"discrete",coerce:"identity"},{key:"duration",coerce:"identity"},{key:"filter",coerce:"identity"},{key:"height",coerce:"identity"},{key:"legendSort",coerce:"identity"},{key:"svgDesc",coerce:"identity"},{key:"svgTitle",coerce:"identity"},{key:"timeFilter",coerce:"identity"},{key:"timeline",coerce:"identity"},{key:"width",coerce:"identity"},{key:"zoom",coerce:"identity"},{key:"zoomFactor",coerce:"identity"},{key:"zoomMax",coerce:"identity"},{key:"zoomPan",coerce:"identity"},{key:"zoomScroll",coerce:"identity"}];
2188
+ const hi=[{key:"ariaHidden",coerce:"identity"},{key:"cache",coerce:"identity"},{key:"colorOrdinal",coerce:"identity",default:!1},{key:"dataCutoff",coerce:"identity"},{key:"depth",coerce:"identity"},{key:"discrete",coerce:"identity"},{key:"duration",coerce:"identity"},{key:"filter",coerce:"identity"},{key:"height",coerce:"identity"},{key:"legendSort",coerce:"identity"},{key:"svgDesc",coerce:"identity"},{key:"svgTitle",coerce:"identity"},{key:"timeFilter",coerce:"identity"},{key:"timeline",coerce:"identity"},{key:"width",coerce:"identity"},{key:"zoom",coerce:"identity"},{key:"zoomFactor",coerce:"identity"},{key:"zoomMax",coerce:"identity"},{key:"zoomPan",coerce:"identity"},{key:"zoomScroll",coerce:"identity"}];
2118
2189
  /**
2119
2190
  Renderer backend, accessibility, attribution, and back-button defaults.
2120
2191
  @private
@@ -2123,10 +2194,14 @@ const ai=[{key:"ariaHidden",coerce:"identity"},{key:"cache",coerce:"identity"},{
2123
2194
  Event handler bindings, render queue, resize observer, and scroll container.
2124
2195
  @private
2125
2196
  */
2126
- function oi(e){e.schema.on={"click.shape":Jt.bind(e),"click.legend":Qt.bind(e),mouseenter:Zt.bind(e),mouseleave:ei.bind(e),"mousemove.shape":ii.bind(e),"mousemove.legend":ti.bind(e)},e._queue=[];
2197
+ function li(e){e.schema.on={"click.shape":ti.bind(e),"click.legend":ii.bind(e),mouseenter:si.bind(e),mouseleave:ni.bind(e),"mousemove.shape":oi.bind(e),"mousemove.legend":ai.bind(e)},e._queue=[];
2127
2198
  // Applies a detected container resize: re-sizes the SVG and re-renders when
2128
2199
  // the observed size actually differs from what the chart last drew at.
2129
- const t=t=>{const{width:i,height:s}=t[0].contentRect;(i!==e.schema.width&&e._autoWidth||s!==e.schema.height&&e._autoHeight)&&i&&s&&(e._setSVGSize(i,s),e._callback||e.render())},i=function(e,t){let i;return function(...s){const n=this;clearTimeout(i),i=setTimeout(()=>e.apply(n,s),t)}}(t,e.schema.detectResizeDelay);e._resizeObserver=new ResizeObserver(s=>{
2200
+ const t=t=>{const{width:i,height:s}=t[0].contentRect;(i!==e.schema.width&&e._autoWidth||s!==e.schema.height&&e._autoHeight)&&i&&s&&(e._setSVGSize(i,s),e._callback||e.render())},i=function(e,t){let i;return function(...s){const n=this;clearTimeout(i),i=setTimeout(()=>e.apply(n,s),t)}}(t,e.schema.detectResizeDelay);
2201
+ // Guarded so a chart can be constructed in an environment without a DOM (e.g.
2202
+ // before `@d3plus/ssr` installs one). Auto-resize is a browser-only feature;
2203
+ // when absent, `_resizeObserver` stays undefined and its call sites skip it.
2204
+ e._resizeObserver="undefined"==typeof ResizeObserver?void 0:new ResizeObserver(s=>{
2130
2205
  // The first real-size notification after `observe()` reports the
2131
2206
  // container's settled layout size, which on an auto-sized chart often
2132
2207
  // differs from the size the chart just measured pre-layout (the
@@ -2149,19 +2224,19 @@ const{width:n,height:a}=s[0].contentRect;if(e._resizeSettled)i(s);else{if(!n||!a
2149
2224
  readable and the constructor stays under the per-function line budget.
2150
2225
  @private
2151
2226
  */
2152
- function ri(e){e.schema.aggs={},
2227
+ function di(e){e.schema.aggs={},
2153
2228
  // E4: install identity-coerce accessors on the prototype. The imperative
2154
2229
  // `viz._x = …` assignments below seed defaults; installFluent's "skip
2155
2230
  // if slot already set" guard respects them. Methods are visible to
2156
2231
  // BaseClass.config()'s `getAllMethods` reflection.
2157
- re(e,ai),function(e){
2232
+ re(e,hi),function(e){
2158
2233
  // `renderer()` selects the @d3plus/render backend. Default
2159
2234
  // `"svg"` (SvgRenderer); `"canvas"` for large N via CanvasRenderer.
2160
- e._renderer="svg",e._renderMode="full",e.schema.ariaHidden=!0,e.schema.attribution=!1;const t="rgba(255, 255, 255, 0.75)";e.schema.attributionStyle={background:t,border:"1px solid rgba(0, 0, 0, 0.25)",color:u.colorContrast(t),display:"block",font:`400 11px/11px ${r.fontFamilyStringify(r.fontFamily)}`,margin:"5px",opacity:.75,padding:"4px 6px 3px"},e._backClass=(new Wt).on("click",()=>{e._history.length?e.config(e._history.pop()).render():e.depth(e._drawDepth-1).filter(!1),e.render()}).on("mousemove",()=>e._backClass.select().style("cursor","pointer")),e.schema.backConfig={fontSize:10,padding:5,resize:!1},e.schema.cache=!0}
2235
+ e._renderer="svg",e._renderMode="full",e.schema.ariaHidden=!0,e.schema.attribution=!1;const t="rgba(255, 255, 255, 0.75)";e.schema.attributionStyle={background:t,border:"1px solid rgba(0, 0, 0, 0.25)",color:u.colorContrast(t),display:"block",font:`400 11px/11px ${r.fontFamilyStringify(r.fontFamily)}`,margin:"5px",opacity:.75,padding:"4px 6px 3px"},e._backClass=(new Gt).on("click",()=>{e._history.length?e.config(e._history.pop()).render():e.depth(e._drawDepth-1).filter(!1),e.render()}).on("mousemove",()=>e._backClass.select().style("cursor","pointer")),e.schema.backConfig={fontSize:10,padding:5,resize:!1},e.schema.cache=!0}
2161
2236
  /**
2162
2237
  Color accessor and color-scale defaults.
2163
2238
  @private
2164
- */(e),function(e){e.schema.color=(t,i)=>e.schema.groupBy[0](t,i),e._colorDefaults={...u.colorDefaults,scale:l.scaleOrdinal().range(u.colorDefaults.scale.range())},e._colorScaleClass=new Bt,e.schema.colorScaleConfig={axisConfig:{rounding:"inside"},scale:"jenks"},e.schema.colorScalePadding=si,e.schema.colorScalePosition=()=>e.schema.width>1.5*e.schema.height?"right":"bottom",e.schema.colorScaleMaxSize=600}
2239
+ */(e),function(e){e.schema.color=(t,i)=>e.schema.groupBy[0](t,i),e._colorDefaults={...u.colorDefaults,scale:l.scaleOrdinal().range(u.colorDefaults.scale.range())},e._colorScaleClass=new Rt,e.schema.colorScaleConfig={axisConfig:{rounding:"inside"},scale:"jenks"},e.schema.colorScalePadding=ri,e.schema.colorScalePosition=()=>e.schema.width>1.5*e.schema.height?"right":"bottom",e.schema.colorScaleMaxSize=600}
2165
2240
  /**
2166
2241
  Data, resize/visibility detection, download, and grouping defaults.
2167
2242
  @private
@@ -2169,11 +2244,11 @@ e._renderer="svg",e._renderMode="full",e.schema.ariaHidden=!0,e.schema.attributi
2169
2244
  /**
2170
2245
  Legend visibility, class instance, and config defaults.
2171
2246
  @private
2172
- */(e),function(e){e.schema.legend=(i,s)=>{const n=t.max(s,(t,i)=>{const s=e.schema.groupBy[e._legendDepth].bind(e)(t,i);return s instanceof Array?s.length:1});return s.length>1&&(n??0)<=2},e._legendClass=new zt,e.schema.legendConfig={label:Ut.bind(e),shapeConfig:{ariaLabel:Ut.bind(e),labelConfig:{fontColor:void 0,fontResize:!1,padding:0}}},e.schema.legendFilterInvert=L(!1),e.schema.legendPadding=si,e.schema.legendPosition=()=>e.schema.width>1.5*e.schema.height?"right":"bottom",e.schema.legendSort=(t,i)=>e._drawLabel(t).localeCompare(e._drawLabel(i)),e.schema.legendTooltip={}}
2247
+ */(e),function(e){e.schema.legend=(i,s)=>{const n=t.max(s,(t,i)=>{const s=e.schema.groupBy[e._legendDepth].bind(e)(t,i);return s instanceof Array?s.length:1});return s.length>1&&(n??0)<=2},e._legendClass=new $t,e.schema.legendConfig={label:ei.bind(e),shapeConfig:{ariaLabel:ei.bind(e),labelConfig:{fontColor:void 0,fontResize:!1,padding:0}}},e.schema.legendFilterInvert=L(!1),e.schema.legendPadding=ri,e.schema.legendPosition=()=>e.schema.width>1.5*e.schema.height?"right":"bottom",e.schema.legendSort=(t,i)=>e._drawLabel(t).localeCompare(e._drawLabel(i)),e.schema.legendTooltip={}}
2173
2248
  /**
2174
2249
  Loading/no-data message HTML, class instances, and mask/style defaults.
2175
2250
  @private
2176
- */(e),function(e){e.schema.loadingHTML=()=>`\n <div style="left: 50%; top: 50%; position: absolute; transform: translate(-50%, -50%);">\n <strong>${e.schema.translate("Loading Visualization")}</strong>\n <sub style="bottom: 0; display: block; line-height: 1; margin-top: 5px;"><a href="https://d3plus.org" target="_blank">${e.schema.translate("Powered by D3plus")}</a></sub>\n </div>`,e.schema.loadingMessage=!0,e._lrucache=new ni(10),e._messageClass=new Pt,e.schema.messageMask="rgba(0, 0, 0, 0.05)",e.schema.messageStyle={bottom:"0",left:"0",position:"absolute",right:"0","text-align":"center",top:"0"},e.schema.noDataHTML=()=>`\n <div style="left: 50%; top: 50%; position: absolute; transform: translate(-50%, -50%);">\n <strong>${e.schema.translate("No Data Available")}</strong>\n </div>`,e.schema.noDataMessage=!0}(e),oi(e),function(e){e.schema.shape=L("Rect"),e._shapes=[],e.schema.shapeConfig={ariaLabel:(t,i)=>e._drawLabel(t,i),fill:(t,i)=>{for(;t.__d3plus__&&t.data;)i=(t=t.data).i;if(e.schema.colorScale){const s=e.schema.colorScale(t,i);if(null!=s){const t=e._colorScaleClass._colorScale,i=e._colorScaleClass.color();return t?t.domain().length?t(s):t.range()[t.range().length-1]:i instanceof Array?i[i.length-1]:i}}const s=e.schema.color(t,i);if(c.color(s))return s;const n="string"==typeof s?s:JSON.stringify(s);
2251
+ */(e),function(e){e.schema.loadingHTML=()=>`\n <div style="left: 50%; top: 50%; position: absolute; transform: translate(-50%, -50%);">\n <strong>${e.schema.translate("Loading Visualization")}</strong>\n <sub style="bottom: 0; display: block; line-height: 1; margin-top: 5px;"><a href="https://d3plus.org" target="_blank">${e.schema.translate("Powered by D3plus")}</a></sub>\n </div>`,e.schema.loadingMessage=!0,e._lrucache=new ci(10),e._messageClass=new Lt,e.schema.messageMask="rgba(0, 0, 0, 0.05)",e.schema.messageStyle={bottom:"0",left:"0",position:"absolute",right:"0","text-align":"center",top:"0"},e.schema.noDataHTML=()=>`\n <div style="left: 50%; top: 50%; position: absolute; transform: translate(-50%, -50%);">\n <strong>${e.schema.translate("No Data Available")}</strong>\n </div>`,e.schema.noDataMessage=!0}(e),li(e),function(e){e.schema.shape=L("Rect"),e._shapes=[],e.schema.shapeConfig={ariaLabel:(t,i)=>e._drawLabel(t,i),fill:(t,i)=>{for(;t.__d3plus__&&t.data;)i=(t=t.data).i;if(e.schema.colorScale){const s=e.schema.colorScale(t,i);if(null!=s){const t=e._colorScaleClass._colorScale,i=e._colorScaleClass.color();return t?t.domain().length?t(s):t.range()[t.range().length-1]:i instanceof Array?i[i.length-1]:i}}const s=e.schema.color(t,i);if(c.color(s))return s;const n="string"==typeof s?s:JSON.stringify(s);
2177
2252
  // Ordinal color mode: an ordered discrete field takes a single-hue
2178
2253
  // light→dark ramp (built in vizPreDraw) instead of nominal categorical
2179
2254
  // hues, so the color itself carries the ordering.
@@ -2184,7 +2259,7 @@ return n?n.darker(.25):s},role:"presentation",strokeWidth:L(0)},e._solo=[]}
2184
2259
  /**
2185
2260
  Subtitle, title, timeline, threshold, tooltip, and total label defaults.
2186
2261
  @private
2187
- */(e),function(e){e._subtitleClass=new Wt,e.schema.subtitleConfig={ariaHidden:!0,fontSize:12,padding:5,resize:!1,textAnchor:"middle"},e.schema.subtitlePadding=si,e.schema.svgDesc="",e.schema.svgTitle="",e.schema.timeline=!0,e._timelineClass=(new Gt).align("end"),e.schema.timelineConfig={padding:5},e.schema.timelinePadding=si,e.schema.threshold=L(1e-4),e.schema.thresholdKey=void 0,e.schema.thresholdName=()=>e.schema.translate("Values"),e._titleClass=new Wt,e.schema.titleConfig={ariaHidden:!0,fontSize:16,padding:5,resize:!1,textAnchor:"middle"},e.schema.titlePadding=si,e.schema.tooltip=L(!0),e._tooltipClass=new Vt,e.schema.tooltipConfig={pointerEvents:"none",titleStyle:{"max-width":"200px"}},e._totalClass=new Wt,e.schema.totalConfig={fontSize:10,padding:5,resize:!1,textAnchor:"middle"},e.schema.totalFormat=t=>`${e.schema.translate("Total")}: ${m.formatAbbreviate(t,e.schema.locale)}`,e.schema.totalPadding=si}
2262
+ */(e),function(e){e._subtitleClass=new Gt,e.schema.subtitleConfig={ariaHidden:!0,fontSize:12,padding:5,resize:!1,textAnchor:"middle"},e.schema.subtitlePadding=ri,e.schema.svgDesc="",e.schema.svgTitle="",e.schema.timeline=!0,e._timelineClass=(new Kt).align("end"),e.schema.timelineConfig={padding:5},e.schema.timelinePadding=ri,e.schema.threshold=L(1e-4),e.schema.thresholdKey=void 0,e.schema.thresholdName=()=>e.schema.translate("Values"),e._titleClass=new Gt,e.schema.titleConfig={ariaHidden:!0,fontSize:16,padding:5,resize:!1,textAnchor:"middle"},e.schema.titlePadding=ri,e.schema.tooltip=L(!0),e._tooltipClass=new Zt,e.schema.tooltipConfig={pointerEvents:"none",titleStyle:{"max-width":"200px"}},e._totalClass=new Gt,e.schema.totalConfig={fontSize:10,padding:5,resize:!1,textAnchor:"middle"},e.schema.totalFormat=t=>`${e.schema.translate("Total")}: ${m.formatAbbreviate(t,e.schema.locale)}`,e.schema.totalPadding=ri}
2188
2263
  /**
2189
2264
  Zoom behavior, brush, control button styling, and zoom limit defaults.
2190
2265
  @private
@@ -2200,7 +2275,7 @@ return n?n.darker(.25):s},role:"presentation",strokeWidth:L(0)},e._solo=[]}
2200
2275
  HtmlOverlay nodes for the zoom-control buttons, so the d3-selection
2201
2276
  `stylize` helper isn't reachable from the scene-graph escape hook.
2202
2277
  */
2203
- function ci(e,t){if(t)for(const i in t){const s=t[i];null!=s&&!1!==s&&(e.style[i]=String(s))}}
2278
+ function ui(e,t){if(t)for(const i in t){const s=t[i];null!=s&&!1!==s&&(e.style[i]=String(s))}}
2204
2279
  /**
2205
2280
  @name zoomFeature
2206
2281
  Sets up zoom + brush event behaviors and the zoom-control buttons.
@@ -2225,31 +2300,31 @@ function ci(e,t){if(t)for(const i in t){const s=t[i];null!=s&&!1!==s&&(e.style[i
2225
2300
  draw — the html string is constant, so listeners attached here
2226
2301
  survive every subsequent draw (renderers only rewrite innerHTML
2227
2302
  when it differs from the current value).
2228
- */const hi={name:"zoom",layout:({viz:e})=>{if(!e._container||!e._zoomGroup)return{panel:null,margin:{}};const t=le(e),i=e._zoomHeight||t.height,s=e,n=e._zoomWidth||t.width;e._zoomBehavior.extent([[0,0],[n,i]]).scaleExtent([1,e.schema.zoomMax]).translateExtent([[0,0],[n,i]]).on("zoom",t=>di.bind(e)(t.transform)),e._zoomToBounds=mi.bind(e);let a=null;e.schema.zoom&&(a={type:"htmlOverlay",key:"viz-zoom-controls",x:e._margin.left,y:e._margin.top,className:"d3plus-zoom-control",html:'<div class="zoom-control zoom-in">&#65291;</div><div class="zoom-control zoom-out">&#65293;</div><div class="zoom-control zoom-reset">&#8634;</div><div class="zoom-control zoom-brush">&#164;</div>',
2303
+ */const mi={name:"zoom",layout:({viz:e})=>{if(!e._container||!e._zoomGroup)return{panel:null,margin:{}};const t=le(e),i=e._zoomHeight||t.height,s=e,n=e._zoomWidth||t.width;e._zoomBehavior.extent([[0,0],[n,i]]).scaleExtent([1,e.schema.zoomMax]).translateExtent([[0,0],[n,i]]).on("zoom",t=>gi.bind(e)(t.transform)),e._zoomToBounds=yi.bind(e);let a=null;e.schema.zoom&&(a={type:"htmlOverlay",key:"viz-zoom-controls",x:e._margin.left,y:e._margin.top,className:"d3plus-zoom-control",html:'<div class="zoom-control zoom-in">&#65291;</div><div class="zoom-control zoom-out">&#65293;</div><div class="zoom-control zoom-reset">&#8634;</div><div class="zoom-control zoom-brush">&#164;</div>',
2229
2304
  // Declarative click wiring — clicks bubble, so the renderer's
2230
2305
  // delegated dispatcher can route them by selector. The four
2231
2306
  // handlers below are the single source of truth for what each
2232
2307
  // zoom button does. Hover styles can't be delegated (mouseenter
2233
2308
  // / mouseleave don't bubble), so they live in onMount below as
2234
2309
  // a per-button binding.
2235
- events:{".zoom-in":{click:()=>ui.bind(s)(s.schema.zoomFactor)},".zoom-out":{click:()=>ui.bind(s)(1/s.schema.zoomFactor)},".zoom-reset":{click:()=>ui.bind(s)(0)},".zoom-brush":{click:e=>{
2310
+ events:{".zoom-in":{click:()=>pi.bind(s)(s.schema.zoomFactor)},".zoom-out":{click:()=>pi.bind(s)(1/s.schema.zoomFactor)},".zoom-reset":{click:()=>pi.bind(s)(0)},".zoom-brush":{click:e=>{
2236
2311
  // The overlay dispatches clicks via delegation, so `e.currentTarget`
2237
2312
  // is the host wrapper that encloses all four buttons — not the
2238
2313
  // clicked button. Styling/toggling the wrapper would paint the
2239
2314
  // active background around the whole control stack and offset it by
2240
2315
  // the base margin/border. Resolve the actual button from the event
2241
2316
  // target, the same way the dispatcher matches (`target.closest`).
2242
- const t=e.target.closest(".zoom-brush");if(!t)return;const i=!function(e){return Boolean(e._brushing)}(s),n=t.classList.toggle("active",i);ci(t,n?s.schema.zoomControlStyleActive||{}:s.schema.zoomControlStyle||{}),li.bind(s)(i)}}},
2317
+ const t=e.target.closest(".zoom-brush");if(!t)return;const i=!function(e){return Boolean(e._brushing)}(s),n=t.classList.toggle("active",i);ui(t,n?s.schema.zoomControlStyleActive||{}:s.schema.zoomControlStyle||{}),fi.bind(s)(i)}}},
2243
2318
  // onMount fires AFTER innerHTML is written so the querySelectorAll
2244
2319
  // matches. Applies base styles + binds non-delegable hover events
2245
2320
  // per button (mouseenter/mouseleave don't bubble through
2246
2321
  // delegated event listeners).
2247
- onMount:e=>{e.querySelectorAll(".zoom-control").forEach(e=>{ci(e,s.schema.zoomControlStyle||{}),e.addEventListener("mouseenter",()=>{ci(e,s.schema.zoomControlStyleHover||{})}),e.addEventListener("mouseleave",()=>{ci(e,e.classList.contains("active")?s.schema.zoomControlStyleActive||{}:s.schema.zoomControlStyle||{})})})}}),e._zoomBrush.extent([[0,0],[n,i]]).filter(e=>!e.button&&e.detail<2).handleSize(e.schema.zoomBrushHandleSize).on("start",pi.bind(e)).on("brush",fi.bind(e)).on("end",gi.bind(e));const o=e._container.selectAll("g.brush").data([0]);return e._brushGroup=o.enter().append("g").attr("class","brush").merge(o).call(e._zoomBrush),li.bind(e)(),e._renderTiles&&e._renderTiles(d.zoomTransform((e._zoomEventTarget||e._container).node()),0),{panel:a,margin:{}}}};
2322
+ onMount:e=>{e.querySelectorAll(".zoom-control").forEach(e=>{ui(e,s.schema.zoomControlStyle||{}),e.addEventListener("mouseenter",()=>{ui(e,s.schema.zoomControlStyleHover||{})}),e.addEventListener("mouseleave",()=>{ui(e,e.classList.contains("active")?s.schema.zoomControlStyleActive||{}:s.schema.zoomControlStyle||{})})})}}),e._zoomBrush.extent([[0,0],[n,i]]).filter(e=>!e.button&&e.detail<2).handleSize(e.schema.zoomBrushHandleSize).on("start",bi.bind(e)).on("brush",_i.bind(e)).on("end",xi.bind(e));const o=e._container.selectAll("g.brush").data([0]);return e._brushGroup=o.enter().append("g").attr("class","brush").merge(o).call(e._zoomBrush),fi.bind(e)(),e._renderTiles&&e._renderTiles(d.zoomTransform((e._zoomEventTarget||e._container).node()),0),{panel:a,margin:{}}}};
2248
2323
  /**
2249
2324
  @name zoomEvents
2250
2325
  Handles adding/removing zoom event listeners.
2251
2326
  @private
2252
- */function li(e=!1){var t;t=e,this._brushing=t,e?this._brushGroup.style("display","inline"):this._brushGroup.style("display","none");
2327
+ */function fi(e=!1){var t;t=e,this._brushing=t,e?this._brushGroup.style("display","inline"):this._brushGroup.style("display","none");
2253
2328
  // The element d3-zoom binds its pointer listeners to. Defaults to the compute
2254
2329
  // `<svg>` container; on the Canvas backend it's the <canvas> (see
2255
2330
  // `bindCanvasZoom`), because the canvas is the interaction surface there —
@@ -2261,7 +2336,7 @@ const i=this._zoomEventTarget||this._container;!e&&this.schema.zoom?(i.call(this
2261
2336
  Handles events dispatched from this._zoomBehavior
2262
2337
  @param transform
2263
2338
  @private
2264
- */function di(e=!1,t=0){this._zoomGroup&&(t?this._zoomGroup.transition().duration(t).attr("transform",e):this._zoomGroup.attr("transform",e));
2339
+ */function gi(e=!1,t=0){this._zoomGroup&&(t?this._zoomGroup.transition().duration(t).attr("transform",e):this._zoomGroup.attr("transform",e));
2265
2340
  // Thread the zoom transform into the scene graph so Network/Geomap
2266
2341
  // pan/zoom shows up under the scene renderer. The
2267
2342
  // `_zoomGroup.attr("transform", …)` write above remains for tests and
@@ -2284,30 +2359,30 @@ this._drawSceneToTarget&&this._sceneRenderer&&this._drawSceneToTarget(t),this._r
2284
2359
  @name zoomMath
2285
2360
  Zooms in or out based on the provided multiplier.
2286
2361
  @param factor @private
2287
- */function ui(e=0){if(!this._container)return;const t=this._zoomBehavior.extent().bind(document)()[1].map(e=>e/2),i=this._zoomBehavior.scaleExtent(),s=d.zoomTransform((this._zoomEventTarget||this._container).node());if(e){const n=[(t[0]-s.x)/s.k,(t[1]-s.y)/s.k];s.k=Math.min(i[1],s.k*e),s.k<=i[0]?(s.k=i[0],s.x=0,s.y=0):(s.x+=t[0]-(n[0]*s.k+s.x),s.y+=t[1]-(n[1]*s.k+s.y))}else s.k=i[0],s.x=0,s.y=0;di.bind(this)(s,this.schema.duration)}
2362
+ */function pi(e=0){if(!this._container)return;const t=this._zoomBehavior.extent().bind(document)()[1].map(e=>e/2),i=this._zoomBehavior.scaleExtent(),s=d.zoomTransform((this._zoomEventTarget||this._container).node());if(e){const n=[(t[0]-s.x)/s.k,(t[1]-s.y)/s.k];s.k=Math.min(i[1],s.k*e),s.k<=i[0]?(s.k=i[0],s.x=0,s.y=0):(s.x+=t[0]-(n[0]*s.k+s.x),s.y+=t[1]-(n[1]*s.k+s.y))}else s.k=i[0],s.x=0,s.y=0;gi.bind(this)(s,this.schema.duration)}
2288
2363
  /**
2289
2364
  @name zoomToBounds
2290
2365
  Zooms to given bounds.
2291
2366
  @param bounds
2292
2367
  @private
2293
- */function mi(e,t=this.schema.duration){const i=this._zoomBehavior.scaleExtent(),s=d.zoomTransform((this._zoomEventTarget||this._container).node());if(e){const[t,n]=this._zoomBehavior.translateExtent()[1],a=e[1][0]-e[0][0],o=e[1][1]-e[0][1];let r,c,h=Math.min(i[1],1/Math.max(a/t,o/n));a/o<t/n?(h*=(n-2*this.schema.zoomPadding)/n,r=(t-a*h)/2/h,c=this.schema.zoomPadding/h):(h*=(t-2*this.schema.zoomPadding)/t,c=(n-o*h)/2/h,r=this.schema.zoomPadding/h),s.x=(s.x-e[0][0]+r)*(s.k*h/s.k),s.y=(s.y-e[0][1]+c)*(s.k*h/s.k),s.k*=h,s.x>0?s.x=0:s.x<t*-s.k+t&&(s.x=t*-s.k+t),s.y>0?s.y=0:s.y<n*-s.k+n&&(s.y=n*-s.k+n)}else s.k=i[0],s.x=0,s.y=0;di.bind(this)(s,t)}
2368
+ */function yi(e,t=this.schema.duration){const i=this._zoomBehavior.scaleExtent(),s=d.zoomTransform((this._zoomEventTarget||this._container).node());if(e){const[t,n]=this._zoomBehavior.translateExtent()[1],a=e[1][0]-e[0][0],o=e[1][1]-e[0][1];let r,c,h=Math.min(i[1],1/Math.max(a/t,o/n));a/o<t/n?(h*=(n-2*this.schema.zoomPadding)/n,r=(t-a*h)/2/h,c=this.schema.zoomPadding/h):(h*=(t-2*this.schema.zoomPadding)/t,c=(n-o*h)/2/h,r=this.schema.zoomPadding/h),s.x=(s.x-e[0][0]+r)*(s.k*h/s.k),s.y=(s.y-e[0][1]+c)*(s.k*h/s.k),s.k*=h,s.x>0?s.x=0:s.x<t*-s.k+t&&(s.x=t*-s.k+t),s.y>0?s.y=0:s.y<n*-s.k+n&&(s.y=n*-s.k+n)}else s.k=i[0],s.x=0,s.y=0;gi.bind(this)(s,t)}
2294
2369
  /**
2295
2370
  Triggered on brush "brush".
2296
2371
  @private
2297
- */function fi(){yi.bind(this)()}
2372
+ */function _i(){ki.bind(this)()}
2298
2373
  /**
2299
2374
  Triggered on brush "end".
2300
2375
  @private
2301
- */function gi(e){e.selection&&(// Only transition after input.
2302
- this._brushGroup.call(this._zoomBrush.move,null),mi.bind(this)(e.selection))}
2376
+ */function xi(e){e.selection&&(// Only transition after input.
2377
+ this._brushGroup.call(this._zoomBrush.move,null),yi.bind(this)(e.selection))}
2303
2378
  /**
2304
2379
  Triggered on brush "start".
2305
2380
  @private
2306
- */function pi(){yi.bind(this)()}
2381
+ */function bi(){ki.bind(this)()}
2307
2382
  /**
2308
2383
  Overrides the default brush styles.
2309
2384
  @private
2310
- */function yi(){this._brushGroup.selectAll(".selection").call(n.attrize,this.schema.zoomBrushSelectionStyle||{}),this._brushGroup.selectAll(".handle").call(n.attrize,this.schema.zoomBrushHandleStyle||{})}function _i(e){
2385
+ */function ki(){this._brushGroup.selectAll(".selection").call(n.attrize,this.schema.zoomBrushSelectionStyle||{}),this._brushGroup.selectAll(".handle").call(n.attrize,this.schema.zoomBrushHandleStyle||{})}function vi(e){
2311
2386
  // Goes through `viz._preDraw()` / `viz._draw()` (not the free functions
2312
2387
  // directly) so subclass overrides (Plot._preDraw, Treemap._draw, Plot._draw,
2313
2388
  // Pack/Pie/Matrix/…) still run. The free functions `vizPreDraw` / `vizDraw`
@@ -2324,12 +2399,12 @@ e._preDraw(),e._draw();
2324
2399
  // FeatureModule contract). The engine appends the returned panels to
2325
2400
  // the instance buffer that `toScene()` reads — including on later zoom
2326
2401
  // repaints, which re-walk `toScene()` outside this pipeline pass.
2327
- const t=U({viz:e},[hi,se]);t.panels.length&&(e._featurePanels=[...e._featurePanels||[],...t.panels]),e._drawSceneToTarget()}
2402
+ const t=U({viz:e},[mi,se]);t.panels.length&&(e._featurePanels=[...e._featurePanels||[],...t.panels]),e._drawSceneToTarget()}
2328
2403
  /**
2329
2404
  @module touchStartBody
2330
2405
  On touchstart event for the Body element.
2331
2406
  @private
2332
- */function xi(){this._tooltipClass.data([]).render()}
2407
+ */function Ci(){this._tooltipClass.data([]).render()}
2333
2408
  /**
2334
2409
  Appends a fullscreen SVG to the BODY if a container has not been provided
2335
2410
  through `.select()`, then points `_select` at the resolved svg node.
@@ -2340,7 +2415,7 @@ const t=U({viz:e},[hi,se]);t.panels.length&&(e._featurePanels=[...e._featurePane
2340
2415
  (re)attaches the resize observer, and fires the user callback.
2341
2416
  @private
2342
2417
  */
2343
- function bi(e,i){!
2418
+ function Si(e,i){!
2344
2419
  /**
2345
2420
  Builds a data table as DOM elements inside the SVG for accessibility, only
2346
2421
  when `schema.ariaHidden` is false and data is present.
@@ -2352,24 +2427,24 @@ function(e){const i=e._data instanceof Array&&e._data.length>0?Object.keys(e._da
2352
2427
  // Viz instance. Lifecycle (DOM setup, viewport detection, data
2353
2428
  // loading, callback timing) stays on the class because it's
2354
2429
  // inherently instance-bound.
2355
- _i(e),!e._messageClass._isVisible||e.schema.noDataMessage&&!e._filteredData.length||(e._messageClass.hide(),"0"===e._select.attr("opacity")&&e._select.transition().duration(e.schema.duration).attr("opacity",1)),e.schema.detectResize&&(e._autoWidth||e._autoHeight)?e._resizeObserver.observe(e._select.node().parentNode):e._resizeObserver.unobserve(e._select.node().parentNode),i&&setTimeout(()=>{i(),e._callback=void 0},e.schema.duration+100)}
2430
+ vi(e),!e._messageClass._isVisible||e.schema.noDataMessage&&!e._filteredData.length||(e._messageClass.hide(),"0"===e._select.attr("opacity")&&e._select.transition().duration(e.schema.duration).attr("opacity",1)),e.schema.detectResize&&(e._autoWidth||e._autoHeight)?e._resizeObserver?.observe(e._select.node().parentNode):e._resizeObserver?.unobserve(e._select.node().parentNode),i&&setTimeout(()=>{i(),e._callback=void 0},e.schema.duration+100)}
2356
2431
  /**
2357
2432
  Loads any queued data (showing the loading message while in flight) then
2358
2433
  draws the chart.
2359
2434
  @private
2360
- */function ki(e,t){const i=
2435
+ */function wi(e,t){const i=
2361
2436
  /**
2362
2437
  Drains the data-loading queue, returning the in-flight promises. Cache hits
2363
2438
  are applied synchronously and never produce a promise.
2364
2439
  @private
2365
2440
  */
2366
- function(e){const t=[];return e._queue.forEach(i=>{const s=e.schema.cache?e._lrucache.get(`${i[3]}_${i[1]}`):void 0;if(s){const t=i[2]?i[2](s):s;`_${i[3]}`in e?e[`_${i[3]}`]=t:e.schema[i[3]]=t}else t.push(new Promise(e=>{i[0](i[1],i[2],i[3],t=>{t&&console.error(t),e()})}))}),e._queue=[],t}(e);e.schema.loadingMessage&&i.length&&e._messageClass.render({container:e._select.node().parentNode,html:e.schema.loadingHTML(e),mask:!!e._filteredData&&e.schema.messageMask,style:e.schema.messageStyle}),Promise.all(i).then(()=>bi(e,t))}
2441
+ function(e){const t=[];return e._queue.forEach(i=>{const s=e.schema.cache?e._lrucache.get(`${i[3]}_${i[1]}`):void 0;if(s){const t=i[2]?i[2](s):s;`_${i[3]}`in e?e[`_${i[3]}`]=t:e.schema[i[3]]=t}else t.push(new Promise(e=>{i[0](i[1],i[2],i[3],t=>{t&&console.error(t),e()})}))}),e._queue=[],t}(e);e.schema.loadingMessage&&i.length&&e._messageClass.render({container:e._select.node().parentNode,html:e.schema.loadingHTML(e),mask:!!e._filteredData&&e.schema.messageMask,style:e.schema.messageStyle}),Promise.all(i).then(()=>Si(e,t))}
2367
2442
  /**
2368
2443
  Draws the visualization given the specified configuration.
2369
2444
  @param viz The Viz instance to render.
2370
2445
  @param callback Optional callback invoked after rendering completes.
2371
2446
  @private
2372
- */function vi(e,t){e._callback=t,
2447
+ */function zi(e,t){e._callback=t,
2373
2448
  // Resets margins and padding
2374
2449
  e._margin={bottom:0,left:0,right:0,top:0},e._padding={bottom:0,left:0,right:0,top:0},function(e){if(void 0===e._select||"svg"!==e._select.node().tagName.toLowerCase()){const t=void 0===e._select?i.select("body").insert("div","#d3plus-portal").style("height","100dvh").style("width","100%").style("min-height","150px"):e._select,s=t.select(".d3plus-viz").size()?t.select(".d3plus-viz"):t.append("svg");e.select(s.node())}}
2375
2450
  /**
@@ -2398,15 +2473,18 @@ const n=e._select.selectAll("desc").data([0]),a=n.enter().append("desc").attr("i
2398
2473
  Clears the visibility/resize/scroll poll timers and scroll listener so a
2399
2474
  re-render doesn't stack duplicate timers.
2400
2475
  @private
2401
- */(e,s),function(e){e._visiblePoll=clearInterval(e._visiblePoll),e._resizePoll=clearTimeout(e._resizePoll),e._scrollPoll=clearTimeout(e._scrollPoll),i.select(e.schema.scrollContainer).on(`scroll.${e._uuid}`,null)}
2476
+ */(e,s),function(e){e._visiblePoll=clearInterval(e._visiblePoll),e._resizePoll=clearTimeout(e._resizePoll),e._scrollPoll=clearTimeout(e._scrollPoll),
2477
+ // scrollContainer is "" when constructed without a window (headless/SSR);
2478
+ // there is nothing to unbind and select("") throws on an invalid selector.
2479
+ e.schema.scrollContainer&&i.select(e.schema.scrollContainer).on(`scroll.${e._uuid}`,null)}
2402
2480
  /**
2403
2481
  Installs the visibility/scroll detection that defers rendering until the
2404
2482
  chart is on-screen. Returns true when a detection branch took ownership of
2405
2483
  the render (so the caller skips the immediate draw).
2406
2484
  @private
2407
- */(e),function(e,t){return e.schema.detectVisible&&"hidden"===e._select.style("visibility")?(e._visiblePoll=setInterval(()=>{"hidden"!==e._select.style("visibility")&&(e._visiblePoll=clearInterval(e._visiblePoll),e.render(t))},e.schema.detectVisibleInterval),!0):e.schema.detectVisible&&"none"===e._select.style("display")?(e._visiblePoll=setInterval(()=>{"none"!==e._select.style("display")&&(e._visiblePoll=clearInterval(e._visiblePoll),e.render(t))},e.schema.detectVisibleInterval),!0):!(!e.schema.detectVisible||n.inViewport(e._select.node())||(i.select(e.schema.scrollContainer).on(`scroll.${e._uuid}`,()=>{e._scrollPoll||(e._scrollPoll=setTimeout(()=>{n.inViewport(e._select.node())&&(i.select(e.schema.scrollContainer).on(`scroll.${e._uuid}`,null),e.render(t)),e._scrollPoll=clearTimeout(e._scrollPoll)},e.schema.detectVisibleInterval))}),0))}(e,t)||ki(e,t),
2485
+ */(e),function(e,t){return e.schema.detectVisible&&"hidden"===e._select.style("visibility")?(e._visiblePoll=setInterval(()=>{"hidden"!==e._select.style("visibility")&&(e._visiblePoll=clearInterval(e._visiblePoll),e.render(t))},e.schema.detectVisibleInterval),!0):e.schema.detectVisible&&"none"===e._select.style("display")?(e._visiblePoll=setInterval(()=>{"none"!==e._select.style("display")&&(e._visiblePoll=clearInterval(e._visiblePoll),e.render(t))},e.schema.detectVisibleInterval),!0):!(!e.schema.detectVisible||n.inViewport(e._select.node())||(i.select(e.schema.scrollContainer).on(`scroll.${e._uuid}`,()=>{e._scrollPoll||(e._scrollPoll=setTimeout(()=>{n.inViewport(e._select.node())&&(i.select(e.schema.scrollContainer).on(`scroll.${e._uuid}`,null),e.render(t)),e._scrollPoll=clearTimeout(e._scrollPoll)},e.schema.detectVisibleInterval))}),0))}(e,t)||wi(e,t),
2408
2486
  // Attaches touchstart event listener to the BODY to hide the tooltip when the user touches any element without data
2409
- i.select("body").on(`touchstart.${e._uuid}`,xi.bind(e)),e}function Ci(e,t={}){const i={resetChartScene:!0,resetChartTransform:!0,resetShapes:!0,marginDelta:{top:0,bottom:0,left:0,right:0},featurePanels:[]};
2487
+ i.select("body").on(`touchstart.${e._uuid}`,Ci.bind(e)),e}function Di(e,t={}){const i={resetChartScene:!0,resetChartTransform:!0,resetShapes:!0,marginDelta:{top:0,bottom:0,left:0,right:0},featurePanels:[]};
2410
2488
  // Reset side effects before features run. `viz._featurePanels` is a
2411
2489
  // cross-stage accumulator: seeded here, appended to later by the
2412
2490
  // zoomControls feature, and read by Viz.toScene — so it has to live on
@@ -2418,7 +2496,7 @@ e._featurePanels=[],e._chartScene=[],e._chartTransform=void 0,e._shapes=[];
2418
2496
  // can't drift. One frozen `resolveSpec` snapshot feeds both accessors:
2419
2497
  // the position accessors take the resolved config as their argument, so
2420
2498
  // a single snapshot reflects config once instead of twice.
2421
- const s=E(e),n=V(e.schema.legendPosition.bind(e)(s)),a=V(e.schema.colorScalePosition.bind(e)(s));i.legendPosition=n,i.colorScalePosition=a;
2499
+ const s=E(e),n=X(e.schema.legendPosition.bind(e)(s)),a=X(e.schema.colorScalePosition.bind(e)(s));i.legendPosition=n,i.colorScalePosition=a;
2422
2500
  // `running` is the cross-call margin accumulator, threaded into each
2423
2501
  // runLayout as its baseMargin so features read the live running total via
2424
2502
  // ctx.layoutMargin (not viz._margin). Seeded from viz._margin so the math
@@ -2436,10 +2514,10 @@ if(i.marginDelta.bottom+=c.margin.bottom,o.bottom+=c.margin.bottom,"left"===n||"
2436
2514
  // Top/bottom legend + colorScale.
2437
2515
  if("top"===n||"bottom"===n){const t=U({viz:e},[K],o);i.marginDelta.top+=t.margin.top,i.marginDelta.bottom+=t.margin.bottom,o.top+=t.margin.top,o.bottom+=t.margin.bottom}if("top"===a||"bottom"===a){const t=U({viz:e},[ie],o);i.marginDelta.top+=t.margin.top,i.marginDelta.bottom+=t.margin.bottom,o.top+=t.margin.top,o.bottom+=t.margin.bottom}
2438
2516
  // Snapshot final featurePanels onto the returned ctx.
2439
- return i.featurePanels=e._featurePanels.slice(),i}function Si(e){const t=Ci(e).marginDelta;t&&(e._margin={top:e._margin.top+t.top,right:e._margin.right+t.right,bottom:e._margin.bottom+t.bottom,left:e._margin.left+t.left})}function wi(e,t,i){for(;t.__d3plus__&&t.data;)i=(t=t.data).i;return e(t,i)}
2517
+ return i.featurePanels=e._featurePanels.slice(),i}function Mi(e){const t=Di(e).marginDelta;t&&(e._margin={top:e._margin.top+t.top,right:e._margin.right+t.right,bottom:e._margin.bottom+t.bottom,left:e._margin.left+t.left})}function Ai(e,t,i){for(;t.__d3plus__&&t.data;)i=(t=t.data).i;return e(t,i)}
2440
2518
  /**
2441
2519
  Builds the id / ids / drawLabel snapshot closures from the viz instance.
2442
- */function zi(e,i={}){
2520
+ */function $i(e,i={}){
2443
2521
  // The pure function reads the live `viz` instance directly. The
2444
2522
  // `resolveSpec(viz)` API exists for callers that want a frozen
2445
2523
  // snapshot, but this body does NOT call it — `BaseClass.config()`
@@ -2467,7 +2545,7 @@ const{id:r,ids:c,drawLabel:h}=function(e,t){
2467
2545
  // `viz._drawDepth` after preDraw are reflected in label/aria output.
2468
2546
  // Treemap's normal `.depth(n).render()` flow still works (render reruns
2469
2547
  // preDraw); the live read covers the intra-render mutation path.
2470
- const i=e.schema.groupBy,s=e.schema.label,n=e.schema.thresholdName,a=e.schema.locale,o=(e,t)=>i.map(i=>`${wi(i,e,t)}`).filter(Boolean);return{id:(e,s)=>{const n=wi(i[t],e,s);
2548
+ const i=e.schema.groupBy,s=e.schema.label,n=e.schema.thresholdName,a=e.schema.locale,o=(e,t)=>i.map(i=>`${Ai(i,e,t)}`).filter(Boolean);return{id:(e,s)=>{const n=Ai(i[t],e,s);
2471
2549
  // groupBy values are string|number for id/keying purposes (numbers are
2472
2550
  // stringified so numeric and string ids never collide).
2473
2551
  return"number"==typeof n?`${n}`:n},ids:o,drawLabel:(i,r,c)=>{
@@ -2534,7 +2612,7 @@ i.filteredData=r,i._thresholdTree=u}else i.filteredData=r;i.legendData=c}(e,a,o,
2534
2612
  // Re-exported so the shim can compute the post-threshold values without
2535
2613
  // duplicating the logic. Takes the final filteredData (after threshold)
2536
2614
  // + relevant config fields and returns the hover-override + no-data flag.
2537
- function Di(e,i,s){const n={noDataMessage:!1};return t.group(i,s).size>e.schema.dataCutoff?n.hoverOverride={hoverOpacity:1,duration:0,stashOriginals:!0}:void 0!==e._userHover&&(n.hoverOverride={hoverOpacity:e._userHover,duration:e._userDuration,restoreOriginals:!0}),n.noDataMessage=!(!e.schema.noDataMessage||i.length),n}
2615
+ function Bi(e,i,s){const n={noDataMessage:!1};return t.group(i,s).size>e.schema.dataCutoff?n.hoverOverride={hoverOpacity:1,duration:0,stashOriginals:!0}:void 0!==e._userHover&&(n.hoverOverride={hoverOpacity:e._userHover,duration:e._userDuration,restoreOriginals:!0}),n.noDataMessage=!(!e.schema.noDataMessage||i.length),n}
2538
2616
  /**
2539
2617
  Stamps `viz._ordinalColorScale` for ordinal color mode.
2540
2618
 
@@ -2546,7 +2624,7 @@ function Di(e,i,s){const n={noDataMessage:!1};return t.group(i,s).size>e.schema.
2546
2624
  (pre-sort your data, or drive it with the existing ordering config, to
2547
2625
  control non-numeric ramps) — then maps them onto an OKLab ramp of the
2548
2626
  default sequential hue. Clears the scale when the mode is off.
2549
- */function Mi(e){const t=zi(e);
2627
+ */function Pi(e){const t=$i(e);
2550
2628
  // 1. Write computed ctx back to viz.
2551
2629
  void 0!==t.drawDepth&&(e._drawDepth=t.drawDepth),t.id&&(e._id=t.id),t.ids&&(e._ids=t.ids),t.drawLabel&&(e._drawLabel=t.drawLabel),void 0!==t.legendData&&(e._legendData=t.legendData),
2552
2630
  // 1b. A persistent trail only stays coherent with fixed axes (so committed
@@ -2570,25 +2648,25 @@ let i=t.filteredData||[];e._data.length&&t._thresholdTree&&(i=e._thresholdFuncti
2570
2648
  function(e){if(!e.schema.colorOrdinal||e.schema.colorScale)return void(e._ordinalColorScale=void 0);const t=e._filteredData??[],i=e.schema.color,s=new Set,n=[];t.forEach((e,t)=>{const a=i(e,t),o="string"==typeof a?a:JSON.stringify(a);s.has(o)||(s.add(o),n.push(a))});const a=(n.every(e=>"number"==typeof e)?[...n].sort((e,t)=>e-t):n).map(e=>"string"==typeof e?e:JSON.stringify(e)),o=u.colorRamp(u.colorDefaults.sequential,a.length||1,{ordinal:!0});e._ordinalColorScale=l.scaleOrdinal().domain(a).range(o)}(e);
2571
2649
  // 4. hover/duration override + noDataMessage flag — computed against
2572
2650
  // the post-threshold filteredData.
2573
- const s=Di(e,i,e._id);s.hoverOverride?.stashOriginals?(void 0===e._userHover&&(e._userHover=e.schema.shapeConfig.hoverOpacity||.5),void 0===e._userDuration&&(e._userDuration=e.schema.shapeConfig.duration||600),e.schema.shapeConfig.hoverOpacity=s.hoverOverride.hoverOpacity,e.schema.shapeConfig.duration=s.hoverOverride.duration):s.hoverOverride?.restoreOriginals&&(e.schema.shapeConfig.hoverOpacity=s.hoverOverride.hoverOpacity,e.schema.shapeConfig.duration=s.hoverOverride.duration),
2651
+ const s=Bi(e,i,e._id);s.hoverOverride?.stashOriginals?(void 0===e._userHover&&(e._userHover=e.schema.shapeConfig.hoverOpacity||.5),void 0===e._userDuration&&(e._userDuration=e.schema.shapeConfig.duration||600),e.schema.shapeConfig.hoverOpacity=s.hoverOverride.hoverOpacity,e.schema.shapeConfig.duration=s.hoverOverride.duration):s.hoverOverride?.restoreOriginals&&(e.schema.shapeConfig.hoverOpacity=s.hoverOverride.hoverOpacity,e.schema.shapeConfig.duration=s.hoverOverride.duration),
2574
2652
  // 5. No-data-message DOM mount + opacity fade.
2575
2653
  s.noDataMessage&&(e._messageClass.render({container:e._select.node().parentNode,html:e.schema.noDataHTML(e),mask:!1,style:e.schema.messageStyle}),e._select.transition().duration(e.schema.duration).attr("opacity",0))}
2576
2654
  /**
2577
2655
  Stamps `interactionGroup` onto a component's scene subtree so the pointer
2578
2656
  bridge can route its nodes to component-scoped handlers (e.g. legend) on
2579
2657
  every backend — including Canvas, where there is no per-shape DOM to walk.
2580
- */function Ai(e,t){e.interactionGroup=t;const i=e.children;if(i)for(const e of i)Ai(e,t)}
2658
+ */function Ti(e,t){e.interactionGroup=t;const i=e.children;if(i)for(const e of i)Ti(e,t)}
2581
2659
  /**
2582
2660
  Resolves the element a renderer mounts into. A `<canvas>` cannot paint inside
2583
2661
  an `<svg>`, so when the scene target is the compute svg, the canvas mounts
2584
2662
  into that svg's parent (the user's element); the emptied, position:absolute
2585
2663
  compute svg overlays the same top-left box. SVG mounts into the target as-is.
2586
- */class $i extends ge{
2664
+ */class Oi extends ge{
2587
2665
  /**
2588
2666
  Called by draw before anything is drawn. Formats the data and performs preparations for draw.
2589
2667
  @private
2590
2668
  */
2591
- _preDraw(){Mi(this)}
2669
+ _preDraw(){Pi(this)}
2592
2670
  /**
2593
2671
  Composes a backend-agnostic scene graph from the shapes/features produced
2594
2672
  by the most recent render. Combines:
@@ -2631,19 +2709,19 @@ const e=a.attr("transform");if("string"==typeof e){const t=e.match(/translate\(\
2631
2709
  const t=[["legend",this._legendClass],["colorScale",this._colorScaleClass],["timeline",this._timelineClass]];for(const[i,s]of t)if(s&&"function"==typeof s.toScene&&s._select&&"function"==typeof s._select.node&&s._select.node()){let t=s.toScene();
2632
2710
  // Tag the legend subtree so its swatches route to legend handlers via
2633
2711
  // the node stamp (renderer-independent), not just SVG DOM ancestry.
2634
- "legend"===i?(Ai(t,"legend"),
2712
+ "legend"===i?(Ti(t,"legend"),
2635
2713
  // Hovering a legend swatch dims the others, like the chart marks:
2636
2714
  // run the legend subtree through the same interaction-opacity pass
2637
2715
  // (a no-op when no hover/active predicate is set).
2638
- t=Se([t],this)[0]):"colorScale"===i?t=Ce([t],this)[0]:"timeline"===i&&Ai(t,"timeline"),e.push({type:"group",key:`viz-${i}`,children:[t]})}
2716
+ t=Se([t],this)[0]):"colorScale"===i?t=Ce([t],this)[0]:"timeline"===i&&Ti(t,"timeline"),e.push({type:"group",key:`viz-${i}`,children:[t]})}
2639
2717
  // E2: FeatureModule.layout() panels (title/subtitle/total/back).
2640
2718
  if(this._featurePanels&&this._featurePanels.length){const t=this._featurePanels.slice();
2641
2719
  // Tag the back-button panel so the pointer bridge can route its click.
2642
- for(const e of t)e&&"string"==typeof e.key&&e.key.toLowerCase().includes("back")&&Ai(e,"back");e.push({type:"group",key:"viz-features",children:t})}return{width:this.schema.width,height:this.schema.height,root:{type:"group",key:"viz-root",children:e}}}
2720
+ for(const e of t)e&&"string"==typeof e.key&&e.key.toLowerCase().includes("back")&&Ti(e,"back");e.push({type:"group",key:"viz-features",children:t})}return{width:this.schema.width,height:this.schema.height,root:{type:"group",key:"viz-root",children:e}}}
2643
2721
  /**
2644
2722
  Called by render once all checks are passed.
2645
2723
  @private
2646
- */_draw(){Si(this)}
2724
+ */_draw(){Mi(this)}
2647
2725
  /**
2648
2726
  * Applies the threshold algorithm according to the type of chart used.
2649
2727
  * @param {Array} data The data to process.
@@ -2656,7 +2734,20 @@ for(const e of t)e&&"string"==typeof e.key&&e.key.toLowerCase().includes("back")
2656
2734
  /**
2657
2735
  Draws the visualization given the specified configuration.
2658
2736
  @param callback Optional callback invoked after rendering completes.
2659
- */render(e){return vi(this,e)}renderer(e){return arguments.length?(this._renderer="canvas"===e?"canvas":"svg",this):this._renderer}renderMode(e){return arguments.length?(this._renderMode=e,this):this._renderMode||"full"}
2737
+ */render(e){return zi(this,e)}
2738
+ /**
2739
+ Serializes the most recently rendered output to an SVG string. Returns
2740
+ `""` if the chart has not been rendered yet. Both backends support this:
2741
+ the SVG backend returns its live `<svg>`, the canvas backend re-renders the
2742
+ retained scene through a throwaway SVG backend. Primarily used for
2743
+ server-side rendering (see `@d3plus/ssr`).
2744
+ */toSVGString(){return this._sceneRenderer?.toSVGString?.()??""}
2745
+ /**
2746
+ Returns the underlying canvas element of the most recent render when the
2747
+ canvas backend is active (`renderer("canvas")`), or `undefined` otherwise.
2748
+ Server-side callers cast this to their native canvas to encode a raster
2749
+ (see `@d3plus/ssr`).
2750
+ */toCanvas(){return"canvas"===this._renderer?this._sceneRenderer?.toCanvas?.():void 0}renderer(e){return arguments.length?(this._renderer="canvas"===e?"canvas":"svg",this):this._renderer}renderMode(e){return arguments.length?(this._renderMode=e,this):this._renderMode||"full"}
2660
2751
  /**
2661
2752
  Public entry point that renders this chart through the @d3plus/render
2662
2753
  pluggable backends. The compute pass happens via render() (in an svg
@@ -2681,7 +2772,11 @@ const s=this._sceneTarget||i;if(!s)return;const a=function(e,t){return"canvas"==
2681
2772
  // transition timers; without this, switching kind (svg<->canvas) or
2682
2773
  // container orphans that DOM in the user's element, stacking the old
2683
2774
  // mode's output behind the new one and accumulating on every switch.
2684
- this._sceneRenderer&&"function"==typeof this._sceneRenderer.destroy&&this._sceneRenderer.destroy();const e="canvas"===t?o.CanvasRenderer:o.SvgRenderer;this._sceneRenderer=new e,this._sceneRenderer.mount({container:a,width:c,height:h}),
2775
+ this._sceneRenderer&&"function"==typeof this._sceneRenderer.destroy&&this._sceneRenderer.destroy();const e="canvas"===t?o.CanvasRenderer:o.SvgRenderer;this._sceneRenderer=new e,
2776
+ // `_scenePixelRatio`, when set (e.g. by @d3plus/ssr for hi-res PNG output),
2777
+ // fixes the canvas backing-store scale; otherwise the renderer falls back
2778
+ // to `devicePixelRatio`.
2779
+ this._sceneRenderer.mount({container:a,width:c,height:h,pixelRatio:this._scenePixelRatio}),
2685
2780
  // Bridge renderer pointer events → viz.schema.on handlers. Without this,
2686
2781
  // tooltips never fire on the v4 scene-rendered path because
2687
2782
  // `shape.on(evt, fn)` in plotPaint only wires d3-selection
@@ -2735,6 +2830,16 @@ if(void 0!==f&&(this._trailSeq=f),this._sceneRenderer.drawScene(r,{duration:u,se
2735
2830
  // native brush handles), so re-enable events on just that group. On the
2736
2831
  // SVG backend `_select` IS the scene host, so events must stay enabled.
2737
2832
  this._select&&(this._select.style("pointer-events","canvas"===t?"none":null),this._container&&this._container.style("pointer-events","canvas"===t?"none":null),"canvas"===t&&this._select.select("g.d3plus-viz-timeline").style("pointer-events","auto")),"svg"===t){const e=s&&"function"==typeof s.querySelector?s:null,t=e?e.querySelector(":scope > g.d3plus-viz-timeline"):null;t&&e.appendChild(t)}}
2833
+ /**
2834
+ Resolves the `(d, i, x)` a picked scene node reports to interaction
2835
+ handlers (tooltip, click, user `on` handlers). `pick.datum` is the raw
2836
+ scene datum; for a Plot shape that's the wrapped record `{data, i}`, which
2837
+ handlers expect unwrapped to `(d.data, d.i, wrapped)`. The base does that
2838
+ unwrap; Plot overrides this to report the point nearest the cursor for
2839
+ multi-point shapes (Line/Area) so a series tooltip reflects the hovered
2840
+ x rather than the whole-series aggregate.
2841
+ @private
2842
+ */_interactionDatum(e,t){const i=e.datum;return{d:i&&i.data?i.data:i,i:i&&"number"==typeof i.i?i.i:e.index??0,x:i}}
2738
2843
  /**
2739
2844
  Routes a renderer pointer event to the matching `viz.schema.on` handlers.
2740
2845
  Bridges the v4 scene-rendered path (SvgRenderer/CanvasRenderer), where
@@ -2776,16 +2881,16 @@ if("axis"===s.interactionGroup||"timeline"===s.interactionGroup)return;
2776
2881
  // legend swatches route to legend handlers on Canvas too — where the
2777
2882
  // single canvas element has no per-shape DOM to walk. Fall back to SVG
2778
2883
  // DOM ancestry for nodes the stamp didn't reach.
2779
- const n=e.nativeEvent&&e.nativeEvent.target,a="legend"===s.interactionGroup||!(!n||"function"!=typeof n.closest)&&!!n.closest('[data-key="viz-legend"]'),o=a?"legend":"shape",r=`${e.type}.${o}`,c=t.datum,h=c&&c.data?c.data:c,l=c&&"number"==typeof c.i?c.i:t.index??0,d="string"==typeof s.shapeType?s.shapeType:null;this._lastScenePick={d:h,i:l,x:c,isLegend:a,shapeType:d},this._hoverDatum=c,i(r,h,l,c),
2884
+ const n=e.nativeEvent&&e.nativeEvent.target,a="legend"===s.interactionGroup||!(!n||"function"!=typeof n.closest)&&!!n.closest('[data-key="viz-legend"]'),o=a?"legend":"shape",r=`${e.type}.${o}`,{d:c,i:h,x:l}=this._interactionDatum(t,e),d="string"==typeof s.shapeType?s.shapeType:null;this._lastScenePick={d:c,i:h,x:l,isLegend:a,shapeType:d},this._hoverDatum=l,i(r,c,h,l),
2780
2885
  // Shape-class-scoped handlers (`"click.Bar"`, `"mousemove.Circle"`). The
2781
2886
  // emitting shape stamps its type onto the node; on the scene path this is
2782
2887
  // the only place these fire (compute-mode shapes wire no DOM listeners).
2783
2888
  // Legend nodes are excluded so a legend swatch's shape type can't
2784
2889
  // masquerade as a chart-shape handler.
2785
- !a&&d&&i(`${e.type}.${d}`,h,l,c),
2890
+ !a&&d&&i(`${e.type}.${d}`,c,h,l),
2786
2891
  // Also fire the un-suffixed handler (e.g. "mousemove") so user-registered
2787
2892
  // global handlers see the event too.
2788
- i(e.type,h,l,c)}
2893
+ i(e.type,c,h,l)}
2789
2894
  /**
2790
2895
  Coalesces interaction-driven scene repaints (hover/active dimming) into a
2791
2896
  single paint per animation frame. A fast pointer sweep across a dense
@@ -2797,26 +2902,26 @@ i(e.type,h,l,c)}
2797
2902
  */_scheduleSceneRepaint(){this._sceneRenderer&&("function"==typeof requestAnimationFrame?null==this._sceneRepaintRAF&&(this._sceneRepaintRAF=requestAnimationFrame(()=>{this._sceneRepaintRAF=void 0,this._drawSceneToTarget(0)})):this._drawSceneToTarget(0))}
2798
2903
  /**
2799
2904
  Tears down the visualization: disconnects the ResizeObserver and removes DOM event listeners. Call this when unmounting to avoid memory leaks.
2800
- */destroy(){return this._resizeObserver.disconnect(),this._tooltipClass.data([]).render(),i.select("body").on(`touchstart.${this._uuid}`,null),
2905
+ */destroy(){return this._resizeObserver?.disconnect(),this._tooltipClass.data([]).render(),i.select("body").on(`touchstart.${this._uuid}`,null),
2801
2906
  // Clear the visibility/resize/scroll poll timers + scroll listener
2802
2907
  // so a destroyed chart doesn't keep firing intervals/timeouts that
2803
2908
  // hold the entire viz instance alive. Without this, an SPA that
2804
2909
  // mounts/unmounts charts on tab switches leaks the scene tree +
2805
2910
  // a 200ms-interval timer per leaked chart.
2806
- this._visiblePoll&&(this._visiblePoll=clearInterval(this._visiblePoll)),this._resizePoll&&(this._resizePoll=clearTimeout(this._resizePoll)),this._scrollPoll&&(this._scrollPoll=clearTimeout(this._scrollPoll)),null!=this._sceneRepaintRAF&&("function"==typeof cancelAnimationFrame&&cancelAnimationFrame(this._sceneRepaintRAF),this._sceneRepaintRAF=void 0),i.select(this.schema.scrollContainer).on(`scroll.${this._uuid}`,null),
2911
+ this._visiblePoll&&(this._visiblePoll=clearInterval(this._visiblePoll)),this._resizePoll&&(this._resizePoll=clearTimeout(this._resizePoll)),this._scrollPoll&&(this._scrollPoll=clearTimeout(this._scrollPoll)),null!=this._sceneRepaintRAF&&("function"==typeof cancelAnimationFrame&&cancelAnimationFrame(this._sceneRepaintRAF),this._sceneRepaintRAF=void 0),this.schema.scrollContainer&&i.select(this.schema.scrollContainer).on(`scroll.${this._uuid}`,null),
2807
2912
  // Destroy the active scene renderer (clears its own pointer-rect
2808
2913
  // listeners, overlay host, canvas/svg DOM, timers).
2809
2914
  this._sceneRenderer&&"function"==typeof this._sceneRenderer.destroy&&(this._sceneRenderer.destroy(),this._sceneRenderer=void 0),this}
2810
2915
  /**
2811
2916
  Invoked when creating a new class instance, and sets any default parameters.
2812
2917
  @private
2813
- */constructor(){super(),ri(this)}}
2918
+ */constructor(){super(),di(this)}}
2814
2919
  /**
2815
2920
  `makeChart(def, Base?)` — produce a chart class from a def value.
2816
2921
 
2817
2922
  `Base` defaults to `Viz`; pass an existing chart class to inherit a
2818
2923
  specialization (e.g. `makeChart(donutDef, Pie)` for Donut).
2819
- */function Bi(e,t=$i){class i extends t{_draw(t){return super._draw(t),e.layoutStage&&function(e,t,i,s){
2924
+ */function Ri(e,t=Oi){class i extends t{_draw(t){return super._draw(t),e.layoutStage&&function(e,t,i,s){
2820
2925
  // Invariant: this helper OWNS `_chartScene` for the current draw — it
2821
2926
  // overwrites with `def.emit(ctx)`. The Plot family takes a different
2822
2927
  // flow: `Plot._paint` populates `_chartScene` directly from `plotPaint`
@@ -2849,14 +2954,14 @@ e._chartScene=[...a,...o],e._chartTransform=s?s(e):function(e){return{x:e._margi
2849
2954
  @module discreteBuffer
2850
2955
  Adds left/right padding to a point or time scale.
2851
2956
  @private
2852
- */const Pi=(e,t,i)=>{if(e.padding)e.padding(.5);else{const s=Array.from(new Set(t.map(e=>+e[i]))).reduce((e,t,i,s)=>{if(!i)return e;const n=s[i-1];return!e||t-n<e?t-n:e},0),n=e.domain().slice();"y"===i&&n.reverse(),n[0]=new Date(+n[0]-s/2),n[1]=new Date(+n[1]+s/2),"y"===i&&n.reverse(),e.domain(n)}},Ti=ct,Oi=e=>new Ti[e];
2957
+ */const Li=(e,t,i)=>{if(e.padding)e.padding(.5);else{const s=Array.from(new Set(t.map(e=>+e[i]))).reduce((e,t,i,s)=>{if(!i)return e;const n=s[i-1];return!e||t-n<e?t-n:e},0),n=e.domain().slice();"y"===i&&n.reverse(),n[0]=new Date(+n[0]-s/2),n[1]=new Date(+n[1]+s/2),"y"===i&&n.reverse(),e.domain(n)}},Ei=ut,Fi=e=>new Ei[e];
2853
2958
  /** The shape registry indexed by key, typed as constructable classes. */
2854
2959
  /**
2855
2960
  Resolve a per-datum accessor — either a function `(d, i) => T` or a bare
2856
2961
  value. The pattern repeats in every flat-data emit (Treemap, Pack, Pie,
2857
2962
  Priestley, …). Centralized here so each emit doesn't need its own copy.
2858
2963
  */
2859
- function Ri(e,t,i){return"function"==typeof e?e(t,i):e}
2964
+ function Wi(e,t,i){return"function"==typeof e?e(t,i):e}
2860
2965
  /**
2861
2966
  Resolve the standard paint properties (`fill`, `stroke`, `strokeWidth`,
2862
2967
  `opacity`) from a shape-config record for a single datum. Returns a
@@ -2864,7 +2969,7 @@ function Ri(e,t,i){return"function"==typeof e?e(t,i):e}
2864
2969
  forced to `string | undefined` to match `Paint.fill` (texture/object
2865
2970
  fills fall through to `undefined`; the existing flat-data emits already
2866
2971
  do this same coercion).
2867
- */function Li(e,t,i){const s=Ri(e.fill,t,i),n=Ri(e.stroke,t,i),a=Ri(e.strokeWidth,t,i),o=Ri(e.opacity,t,i),r=Ri(e.vectorEffect,t,i);return{fill:"string"==typeof s?s:void 0,stroke:n,strokeWidth:a,opacity:o,vectorEffect:"none"===r||"non-scaling-stroke"===r?r:void 0}}
2972
+ */function Ni(e,t,i){const s=Wi(e.fill,t,i),n=Wi(e.stroke,t,i),a=Wi(e.strokeWidth,t,i),o=Wi(e.opacity,t,i),r=Wi(e.vectorEffect,t,i);return{fill:"string"==typeof s?s:void 0,stroke:n,strokeWidth:a,opacity:o,vectorEffect:"none"===r||"non-scaling-stroke"===r?r:void 0}}
2868
2973
  /**
2869
2974
  Apply a shape-config object to a chart-specific shape key, returning the
2870
2975
  configPrep-massaged object suitable for `.config(...)`. Equivalent to
@@ -2876,7 +2981,7 @@ function Ri(e,t,i){return"function"==typeof e?e(t,i):e}
2876
2981
  `kind` is the second `configPrep` argument (the property to filter by).
2877
2982
  Defaults to `"shape"` — the standard call shape. Network's link config
2878
2983
  uses `"edge"` instead.
2879
- */function Ei(e,t,i,s="shape"){
2984
+ */function Hi(e,t,i,s="shape"){
2880
2985
  // configPrep binds its `this` to a VizContext-shaped object; VizLike
2881
2986
  // satisfies that contract at runtime.
2882
2987
  return G.bind(e)(i??e.schema.shapeConfig,s,t)}
@@ -2891,23 +2996,27 @@ return G.bind(e)(i??e.schema.shapeConfig,s,t)}
2891
2996
  @param opts.shape Include `shape.toScene().children` (default true).
2892
2997
  @param opts.labels Include `shape._labelClass.toScene().children`
2893
2998
  (default true).
2894
- */function Fi(e,t={}){if(!e)return[];const i=!1!==t.shape,s=!1!==t.labels;try{e.render();const t=[];if(i&&"function"==typeof e.toScene){const i=e.toScene();i&&Array.isArray(i.children)&&t.push(...i.children)}if(s){const i=e._labelClass;if(i&&"function"==typeof i.toScene){const e=i.toScene();e&&Array.isArray(e.children)&&t.push(...e.children)}}return t}catch{return[]}}
2999
+ */function ji(e,t={}){if(!e)return[];const i=!1!==t.shape,s=!1!==t.labels;try{e.render();const t=[];if(i&&"function"==typeof e.toScene){const i=e.toScene();i&&Array.isArray(i.children)&&t.push(...i.children)}if(s){const i=e._labelClass;if(i&&"function"==typeof i.toScene){const e=i.toScene();e&&Array.isArray(e.children)&&t.push(...e.children)}}return t}catch{return[]}}
2895
3000
  /**
2896
3001
  Pushes zero-value filler points for any Area series missing from a discrete
2897
3002
  group, so the d3-stack has a complete grid. Mutates `data` in place.
2898
3003
  */
2899
- /** Stacked branch: d3-stack + extent-derived domains. */function Wi(e,i){const{data:s,axisData:n,xData:a,yData:o,opp:r,stackGroup:c}=i,h=n.filter(e=>["Area","Bar"].includes(e.shape)),l=t.groups(h,e=>e.group).reduce((e,[i,s])=>(e[i]||(e[i]=0),e[i]+=t.sum(s,e=>e[r]),e),{});n.sort((t,i)=>{if(e.schema[`${e.schema.discrete}Sort`])return e.schema[`${e.schema.discrete}Sort`](t.data,i.data);const s=t[e.schema.discrete],n=i[e.schema.discrete];return s-n!==0?s-n:t.group!==i.group?l[i.group]-l[t.group]:i[r]-t[r]});const d=Array.from(new Set(n.map(e=>e.discrete))),u=Array.from(new Set(n.map(e=>e.id))),m=t.groups(n,e=>e.discrete).map(([,e])=>e);!function(e,t){const{axisData:i,data:s,stackData:n,stackKeys:a,stackGroup:o,opp:r}=t;n.forEach(t=>{const n=Array.from(new Set(t.map(e=>e.id)));n.length<a.length&&a.forEach(a=>{if(!n.includes(a)){const n=i.filter(e=>e.id===a)[0],c=n.shape;if("Area"===c){const i=o(n.data,n.i),h={__d3plus__:!0,data:n.data,discrete:"Bar"===n.shape?`${t[0][e.schema.discrete]}_${i}`:`${t[0][e.schema.discrete]}`,group:i,id:n.id,ids:a,shape:c,[e.schema.discrete]:t[0][e.schema.discrete],[r]:0};s.push(h)}}})})}(e,{axisData:n,data:s,stackData:m,stackKeys:u,stackGroup:c,opp:r}),e.schema[`${e.schema.discrete}Sort`]?s.sort((t,i)=>e.schema[`${e.schema.discrete}Sort`](t.data,i.data)):s.sort((t,i)=>t[e.schema.discrete]-i[e.schema.discrete]);const f=e._stackOrder;Array.isArray(f)?u.sort((e,t)=>f.indexOf(e)-f.indexOf(t)):f===P.stackOrderNone&&u.sort((e,t)=>`${e}`.localeCompare(`${t}`));
3004
+ /** Stacked branch: d3-stack + extent-derived domains. */function Gi(e,i){const{data:s,axisData:n,xData:a,yData:o,opp:r,stackGroup:c}=i,h=n.filter(e=>["Area","Bar"].includes(e.shape)),l=t.groups(h,e=>e.group).reduce((e,[i,s])=>(e[i]||(e[i]=0),e[i]+=t.sum(s,e=>e[r]),e),{});n.sort((t,i)=>{if(e.schema[`${e.schema.discrete}Sort`])return e.schema[`${e.schema.discrete}Sort`](t.data,i.data);const s=t[e.schema.discrete],n=i[e.schema.discrete];return s-n!==0?s-n:t.group!==i.group?l[i.group]-l[t.group]:i[r]-t[r]});const d=Array.from(new Set(n.map(e=>e.discrete))),u=Array.from(new Set(n.map(e=>e.id))),m=t.groups(n,e=>e.discrete).map(([,e])=>e);!function(e,t){const{axisData:i,data:s,stackData:n,stackKeys:a,stackGroup:o,opp:r}=t;n.forEach(t=>{const n=Array.from(new Set(t.map(e=>e.id)));n.length<a.length&&a.forEach(a=>{if(!n.includes(a)){const n=i.filter(e=>e.id===a)[0],c=n.shape;if("Area"===c){const i=o(n.data,n.i),h={__d3plus__:!0,data:n.data,discrete:"Bar"===n.shape?`${t[0][e.schema.discrete]}_${i}`:`${t[0][e.schema.discrete]}`,group:i,id:n.id,ids:a,shape:c,[e.schema.discrete]:t[0][e.schema.discrete],[r]:0};s.push(h)}}})})}(e,{axisData:n,data:s,stackData:m,stackKeys:u,stackGroup:c,opp:r}),e.schema[`${e.schema.discrete}Sort`]?s.sort((t,i)=>e.schema[`${e.schema.discrete}Sort`](t.data,i.data)):s.sort((t,i)=>t[e.schema.discrete]-i[e.schema.discrete]);const f=e._stackOrder;
3005
+ // An explicit key array orders `stackKeys` directly (then d3-stack keeps
3006
+ // that order via `stackOrderNone`); every other order is a comparator that
3007
+ // reranks the series d3-stack builds, so `stackKeys` is left in input order.
3008
+ Array.isArray(f)&&u.sort((e,t)=>f.indexOf(e)-f.indexOf(t));
2900
3009
  // d3-stack's generics don't model d3plus's dynamically-keyed rows; the
2901
3010
  // order/offset/value accessors are cast (`as never`) at the boundary, and
2902
3011
  // the configured stack is invoked as a `Row[][] -> number[][][]` function.
2903
3012
  const g=P.stack().keys(u).offset(e._stackOffset).order(Array.isArray(f)?P.stackOrderNone:f).value((e,t)=>{const i=e.filter(e=>e.id===t);return i.length?i[0][r]:0})(m),p="x"===e.schema.discrete?a:o,y="x"===e.schema.discrete?e._xTime:e._yTime;return{plotInitialDomains:{[e.schema.discrete]:y?t.extent(p):p,[r]:[t.min(g.map(e=>t.min(e.map(e=>e[0])))),t.max(g.map(e=>t.max(e.map(e=>e[1]))))]},plotDiscreteKeys:d,plotStackData:g,plotStackKeys:u}}
2904
- /** Non-stacked branch: data-values-or-extent domains per axis. */const Ni=({viz:e,plotFormattedData:i,plotAxisData:s,xData:n,x2Data:a,yData:o,y2Data:r,plotStackGroup:c})=>{const h=i||[],l=s||[],d=c,u=e.schema.discrete?"x"===e.schema.discrete?"y":"x":void 0;return e.schema.stacked?Wi(e,{data:h,axisData:l,xData:n||[],yData:o||[],opp:u,stackGroup:d}):function(e,i){const{axisData:s,xData:n,x2Data:a,yData:o,y2Data:r}=i,c=e._xTime,h=e._x2Time,l=e._yTime,d=e._y2Time,u=e.schema.discrete||"x";return e.schema[`${e.schema.discrete}Sort`]?s.sort((t,i)=>e.schema[`${e.schema.discrete}Sort`](t.data,i.data)):s.sort((e,t)=>e[u]-t[u]),{plotInitialDomains:{x:!c&&"x"===e.schema.discrete||e.schema.xSort?n:t.extent(n),x2:!h&&"x"===e.schema.discrete||e.schema.x2Sort?a:t.extent(a),y:!l&&"y"===e.schema.discrete||e.schema.ySort?o:t.extent(o),y2:!d&&"y"===e.schema.discrete||e.schema.y2Sort?r:t.extent(r)},plotDiscreteKeys:[],plotStackData:[],plotStackKeys:[]}}(e,{axisData:l,xData:n||[],x2Data:a||[],yData:o||[],y2Data:r||[]})};
2905
- /** Measures one line's label (width, position, overlap coords). */const Hi=({viz:e,plotFormattedData:i,plotScales:s,plotConfigScales:a,plotTestAxes:o,plotLineLabelTest:r,y2Exists:c})=>{const h=i||[];if(!e.schema.lineLabels||c)return{plotLabelWidths:[],plotLargestLabel:void 0,plotXRangeMax:void 0};const l=h.filter(t=>"Line"===t.shape&&("function"!=typeof e.schema.lineLabels||e.schema.lineLabels(t.data,t.i))),d=t.groups(l,e=>e.id);if(!d.length)return{plotLabelWidths:[],plotLargestLabel:void 0,plotXRangeMax:void 0};const{testLineShape:u,testTextBox:m}=r,{xTest:f,yTest:g}=o,p=s.x.domain(),y=s.y.domain(),_=a.xConfigScale,x=a.yConfigScale,b=e.schema.width-e._margin.left-e._margin.right,k=Ei(e,"Line");u.config(k);const v=u.labelConfig(),C=void 0!==v.fontColor?v.fontColor:m.fontColor(),S=void 0!==v.fontSize?v.fontSize:m.fontSize(),w=void 0!==v.fontWeight?v.fontWeight:m.fontWeight(),z=void 0!==v.fontFamily?v.fontFamily:m.fontFamily(),D=void 0!==v.padding?v.padding:m.padding(),M={labelFunction:k.label||e._drawLabel,fontColorAccessor:C,fontSizeAccessor:S,fontWeightAccessor:w,fontFamilyAccessor:z,paddingAccessor:D,xEstimate:e=>("log"===_&&0===e&&(e=p[0]<0?f._d3Scale.domain()[1]:f._d3Scale.domain()[0]),f._getPosition.bind(f)(e)),yEstimate:e=>("log"===x&&0===e&&(e=y[0]<0?g._d3Scale.domain()[1]:g._d3Scale.domain()[0]),g._getPosition.bind(g)(e))},A=d.map(e=>function([e,i],s){const{labelFunction:a,fontColorAccessor:o,fontSizeAccessor:r,fontWeightAccessor:c,fontFamilyAccessor:h,paddingAccessor:l,xEstimate:d,yEstimate:u}=s;let m,f=i[i.length-1];for(;f.__d3plus__&&f.data;)f=f.data,m=f.i;const g="function"==typeof a?a(f,m):a,p="function"==typeof o?o(f,m):o,y="function"==typeof r?r(f,m):r,_="function"==typeof c?c(f,m):c;let x="function"==typeof h?h(f,m):h;Array.isArray(x)&&(x=x.map(e=>`'${e}'`).join(", "));const b="function"==typeof l?l(f,m):l,k=n.textWidth(g,{"font-size":y,"font-family":x,"font-weight":_}),v=i.map(e=>[d(e.x),u(e.y)]),C=t.max(i.map(e=>d(e.x))),S=i.find(e=>d(e.x)===C).y;return{id:e,labelWidth:k+2*b,spaceNeeded:k+4*b,value:S,yEstimate:u(S),padding:b,fontSize:y,fontColor:p,maxX:C,xValue:t.max(i,e=>e.x),coords:v}}(e,M)).sort((e,t)=>y[1]>y[0]?e.value-t.value:t.value-e.value).filter((e,t,i)=>{const{fontSize:s,id:n,labelWidth:a,maxX:o,yEstimate:r}=e;return 0===i.filter(e=>e.id!==n&&e.coords.some(t=>(t[0]>o||t[0]===o&&e.maxX!==o)&&t[0]<=o+a&&t[1]<=r+.75*s&&t[1]>=r-.75*s)).length}),$=t.max(A,e=>e.maxX),B=t.max(A.map(e=>e.labelWidth));
3013
+ /** Non-stacked branch: data-values-or-extent domains per axis. */const Ii=({viz:e,plotFormattedData:i,plotAxisData:s,xData:n,x2Data:a,yData:o,y2Data:r,plotStackGroup:c})=>{const h=i||[],l=s||[],d=c,u=e.schema.discrete?"x"===e.schema.discrete?"y":"x":void 0;return e.schema.stacked?Gi(e,{data:h,axisData:l,xData:n||[],yData:o||[],opp:u,stackGroup:d}):function(e,i){const{axisData:s,xData:n,x2Data:a,yData:o,y2Data:r}=i,c=e._xTime,h=e._x2Time,l=e._yTime,d=e._y2Time,u=e.schema.discrete||"x";return e.schema[`${e.schema.discrete}Sort`]?s.sort((t,i)=>e.schema[`${e.schema.discrete}Sort`](t.data,i.data)):s.sort((e,t)=>e[u]-t[u]),{plotInitialDomains:{x:!c&&"x"===e.schema.discrete||e.schema.xSort?n:t.extent(n),x2:!h&&"x"===e.schema.discrete||e.schema.x2Sort?a:t.extent(a),y:!l&&"y"===e.schema.discrete||e.schema.ySort?o:t.extent(o),y2:!d&&"y"===e.schema.discrete||e.schema.y2Sort?r:t.extent(r)},plotDiscreteKeys:[],plotStackData:[],plotStackKeys:[]}}(e,{axisData:l,xData:n||[],x2Data:a||[],yData:o||[],y2Data:r||[]})};
3014
+ /** Measures one line's label (width, position, overlap coords). */const qi=({viz:e,plotFormattedData:i,plotScales:s,plotConfigScales:a,plotTestAxes:o,plotLineLabelTest:r,y2Exists:c})=>{const h=i||[];if(!e.schema.lineLabels||c)return{plotLabelWidths:[],plotLargestLabel:void 0,plotXRangeMax:void 0};const l=h.filter(t=>"Line"===t.shape&&("function"!=typeof e.schema.lineLabels||e.schema.lineLabels(t.data,t.i))),d=t.groups(l,e=>e.id);if(!d.length)return{plotLabelWidths:[],plotLargestLabel:void 0,plotXRangeMax:void 0};const{testLineShape:u,testTextBox:m}=r,{xTest:f,yTest:g}=o,p=s.x.domain(),y=s.y.domain(),_=a.xConfigScale,x=a.yConfigScale,b=e.schema.width-e._margin.left-e._margin.right,k=Hi(e,"Line");u.config(k);const v=u.labelConfig(),C=void 0!==v.fontColor?v.fontColor:m.fontColor(),S=void 0!==v.fontSize?v.fontSize:m.fontSize(),w=void 0!==v.fontWeight?v.fontWeight:m.fontWeight(),z=void 0!==v.fontFamily?v.fontFamily:m.fontFamily(),D=void 0!==v.padding?v.padding:m.padding(),M={labelFunction:k.label||e._drawLabel,fontColorAccessor:C,fontSizeAccessor:S,fontWeightAccessor:w,fontFamilyAccessor:z,paddingAccessor:D,xEstimate:e=>("log"===_&&0===e&&(e=p[0]<0?f._d3Scale.domain()[1]:f._d3Scale.domain()[0]),f._getPosition.bind(f)(e)),yEstimate:e=>("log"===x&&0===e&&(e=y[0]<0?g._d3Scale.domain()[1]:g._d3Scale.domain()[0]),g._getPosition.bind(g)(e))},A=d.map(e=>function([e,i],s){const{labelFunction:a,fontColorAccessor:o,fontSizeAccessor:r,fontWeightAccessor:c,fontFamilyAccessor:h,paddingAccessor:l,xEstimate:d,yEstimate:u}=s;let m,f=i[i.length-1];for(;f.__d3plus__&&f.data;)f=f.data,m=f.i;const g="function"==typeof a?a(f,m):a,p="function"==typeof o?o(f,m):o,y="function"==typeof r?r(f,m):r,_="function"==typeof c?c(f,m):c;let x="function"==typeof h?h(f,m):h;Array.isArray(x)&&(x=x.map(e=>`'${e}'`).join(", "));const b="function"==typeof l?l(f,m):l,k=n.textWidth(g,{"font-size":y,"font-family":x,"font-weight":_}),v=i.map(e=>[d(e.x),u(e.y)]),C=t.max(i.map(e=>d(e.x))),S=i.find(e=>d(e.x)===C).y;return{id:e,labelWidth:k+2*b,spaceNeeded:k+4*b,value:S,yEstimate:u(S),padding:b,fontSize:y,fontColor:p,maxX:C,xValue:t.max(i,e=>e.x),coords:v}}(e,M)).sort((e,t)=>y[1]>y[0]?e.value-t.value:t.value-e.value).filter((e,t,i)=>{const{fontSize:s,id:n,labelWidth:a,maxX:o,yEstimate:r}=e;return 0===i.filter(e=>e.id!==n&&e.coords.some(t=>(t[0]>o||t[0]===o&&e.maxX!==o)&&t[0]<=o+a&&t[1]<=r+.75*s&&t[1]>=r-.75*s)).length}),$=t.max(A,e=>e.maxX),B=t.max(A.map(e=>e.labelWidth));
2906
3015
  // Each accessor falls back from the Line shape's labelConfig to the test
2907
3016
  // TextBox's getter; both yield a d3plus config value (constant or accessor).
2908
- let P;const T=$===f._getRange.bind(f)()[1]?t.max(A.filter(e=>e.maxX===$),e=>e.spaceNeeded):0;if(T){P=b-t.min([T,b/4])-e._margin.right}return{plotLabelWidths:A,plotLargestLabel:B,plotXRangeMax:P}},ji=B,Gi=({viz:e})=>{if(!e._filteredData||!e._filteredData.length)return{plotFormattedData:[],plotAxisData:[],x2Exists:!1,y2Exists:!1};const i=!!e.schema.time&&e.schema.time(e._filteredData[0],0),s=e._x2Time=i&&e._x2(e._filteredData[0],0)===i,a=e._xTime=i&&e._x(e._filteredData[0],0)===i,o=e._y2Time=i&&e._y2(e._filteredData[0],0)===i,r=e._yTime=i&&e._y(e._filteredData[0],0)===i,c=a||s||r||o,h=(t,i)=>`${!c&&e.schema.time?e.schema.time(t,i):"time"}_${e.schema.stacked?`${e.schema.groupBy.length>1?e._ids(t,i).slice(0,-1).join("_"):"group"}`:`${e._ids(t,i).join("_")}`}`,l=(t,i)=>{const c={__d3plus__:!0,data:t,group:h(t,i),i:i,hci:e._confidence&&e._confidence[1]&&e._confidence[1](t,i),id:e._ids(t,i).slice(0,e._drawDepth+1).join("_"),lci:e._confidence&&e._confidence[0]&&e._confidence[0](t,i),shape:e.schema.shape(t,i),x:a?n.date(e._x(t,i)):e._x(t,i),x2:s?n.date(e._x2(t,i)):e._x2(t,i),y:r?n.date(e._y(t,i)):e._y(t,i),y2:o?n.date(e._y2(t,i)):e._y2(t,i)};return c.discrete="Bar"===c.shape?`${c[e.schema.discrete]}_${c.group}`:`${c[e.schema.discrete]}`,c.id="Bar"===c.shape?`${c.id}_${c[e.schema.discrete]}`:c.id,c},d=e._formattedData=e._filteredData.map(l),u=e._axisPersist?e._data.map(l):d;if(e._size){const i=t.extent(u,t=>e._size(t.data));e._sizeScaleD3=ji[`scale${e.schema.sizeScale.charAt(0).toUpperCase()}${e.schema.sizeScale.slice(1)}`]().domain(i).range([i[0]===i[1]?e.schema.sizeMax:t.min([e.schema.sizeMax/2,e.schema.sizeMin]),e.schema.sizeMax])}else e._sizeScaleD3=()=>e.schema.sizeMin;const m=u.some(e=>void 0!==e.x2),f=u.some(e=>void 0!==e.y2);return{plotFormattedData:d,plotAxisData:u,x2Exists:m,y2Exists:f,plotStackGroup:h}},Ii=({viz:e,plotFormattedData:i,plotAxisData:a})=>{const o=i||[],r=a||[];function c(i){const a=e[`_${i}Time`],c=a?o:r,h=c.filter(e=>![NaN,void 0,!1].includes(e[i]));if(!h.length)return[];const l="number"==typeof h[0][i];let d=e.schema.discrete===i?t.rollups(h,t=>1===t.length?t[0].data:s.merge(t.map(e=>e.data),e.schema.aggs),e=>e[i]).sort((t,s)=>{if(e.schema[`${i}Sort`])return e.schema[`${i}Sort`](t[1],s[1]);return(a||l?parseFloat(t[0]):t[0])-(a||l?parseFloat(s[0]):s[0])}).map(([e])=>a?n.date(e):l?parseFloat(e):e):s.unique(h.sort((t,s)=>e.schema[`${i}Sort`]?e.schema[`${i}Sort`](t.data,s.data):t[i]-s[i]).map(e=>e[i]),e=>`${e}`);return e.schema.discrete!==i.charAt(0)&&e._confidence&&(e._confidence[0]&&(d=d.concat(c.map(e=>e.lci))),e._confidence[1]&&(d=d.concat(c.map(e=>e.hci)))),d}return{xData:c("x"),x2Data:c("x2"),yData:c("y"),y2Data:c("y2")}},qi=({viz:e,plotFormattedData:i,plotAxisData:s,plotScales:n,plotConfigScales:a})=>{const o=i||[],r=s||[];let{x:c,y:h,x2:l,y2:d}=n;const{xConfigScale:u,yConfigScale:m,x2ConfigScale:f,y2ConfigScale:g}=a,p=n.xScale,y=n.yScale;if("Point"!==("x"===e.schema.discrete?y:p)){t.groups(r,e=>e.shape).forEach(([t,i])=>{if(["Bar","Box"].includes(t)&&Pi("x"===e.schema.discrete?c:h,o,e.schema.discrete),e._buffer[t]){const s=e._buffer[t].bind(e)({data:i,x:c,y:h,yScale:m,xScale:u,config:e.schema.shapeConfig[t]});c=s[0],h=s[1];const n=e._buffer[t].bind(e)({data:i,x:l,y:d,yScale:g,xScale:f,x2:!0,y2:!0,config:e.schema.shapeConfig[t]});l=n[0],d=n[1]}})}return{plotScales:{...n,x:c,y:h,x2:l,y2:d}}},Yi=({viz:e,plotAxisData:t,plotScales:i,x2Exists:n,y2Exists:a,x2Data:o,y2Data:r,yData:c})=>{const h=t||[],{x:l,y:d,x2:u,y2:m,xScale:f,yScale:g,x2Scale:p,y2Scale:y}=i,_=l.domain(),x=u.domain(),b=d.domain(),k=m.domain(),v={barConfig:{"stroke-width":0},gridSize:0,labels:[],title:!1,tickSize:0},C=n?{data:o}:v,S=a?{data:r}:v,w="x"===e.schema.discrete?e.schema.width>e._discreteCutoff&&e.schema.width>e.schema.xCutoff:e.schema.width>e.schema.xCutoff,z="y"===e.schema.discrete?e.schema.height>e._discreteCutoff&&e.schema.height>e.schema.yCutoff:e.schema.height>e.schema.yCutoff,D={data:c,locale:e.schema.locale,rounding:e.schema.yDomain?"none":"outside",scalePadding:d.padding?d.padding():0};!w&&z&&(D.barConfig={stroke:"transparent"},D.tickSize=0,D.shapeConfig={labelBounds:(t,i)=>{const{width:s,y:n}=t.labelBounds,a=e.schema.height/2;return{x:i?-a:0,y:n,width:s,height:a}},labelConfig:{padding:0,rotate:0},labelRotation:!1});
3017
+ let P;const T=$===f._getRange.bind(f)()[1]?t.max(A.filter(e=>e.maxX===$),e=>e.spaceNeeded):0;if(T){P=b-t.min([T,b/4])-e._margin.right}return{plotLabelWidths:A,plotLargestLabel:B,plotXRangeMax:P}},Yi=B,Ki=e=>null===e||"number"==typeof e&&!Number.isFinite(e)||Array.isArray(e)&&0===e.length,Vi=e=>!(Ki(e.x)||Ki(e.y)||void 0!==e.x2&&Ki(e.x2)||void 0!==e.y2&&Ki(e.y2)),Xi=({viz:e})=>{if(!e._filteredData||!e._filteredData.length)return{plotFormattedData:[],plotAxisData:[],x2Exists:!1,y2Exists:!1};const i=!!e.schema.time&&e.schema.time(e._filteredData[0],0),s=e._x2Time=i&&e._x2(e._filteredData[0],0)===i,a=e._xTime=i&&e._x(e._filteredData[0],0)===i,o=e._y2Time=i&&e._y2(e._filteredData[0],0)===i,r=e._yTime=i&&e._y(e._filteredData[0],0)===i,c=a||s||r||o,h=(t,i)=>`${!c&&e.schema.time?e.schema.time(t,i):"time"}_${e.schema.stacked?`${e.schema.groupBy.length>1?e._ids(t,i).slice(0,-1).join("_"):"group"}`:`${e._ids(t,i).join("_")}`}`,l=(t,i)=>{const c={__d3plus__:!0,data:t,group:h(t,i),i:i,hci:e._confidence&&e._confidence[1]&&e._confidence[1](t,i),id:e._ids(t,i).slice(0,e._drawDepth+1).join("_"),lci:e._confidence&&e._confidence[0]&&e._confidence[0](t,i),shape:e.schema.shape(t,i),x:a?n.date(e._x(t,i)):e._x(t,i),x2:s?n.date(e._x2(t,i)):e._x2(t,i),y:r?n.date(e._y(t,i)):e._y(t,i),y2:o?n.date(e._y2(t,i)):e._y2(t,i)};return c.discrete="Bar"===c.shape?`${c[e.schema.discrete]}_${c.group}`:`${c[e.schema.discrete]}`,c.id="Bar"===c.shape?`${c.id}_${c[e.schema.discrete]}`:c.id,c},d=e._formattedData=e._filteredData.map(l).filter(Vi),u=e._axisPersist?e._data.map(l).filter(Vi):d;if(e._size){const i=t.extent(u,t=>e._size(t.data));e._sizeScaleD3=Yi[`scale${e.schema.sizeScale.charAt(0).toUpperCase()}${e.schema.sizeScale.slice(1)}`]().domain(i).range([i[0]===i[1]?e.schema.sizeMax:t.min([e.schema.sizeMax/2,e.schema.sizeMin]),e.schema.sizeMax])}else e._sizeScaleD3=()=>e.schema.sizeMin;const m=u.some(e=>void 0!==e.x2),f=u.some(e=>void 0!==e.y2);return{plotFormattedData:d,plotAxisData:u,x2Exists:m,y2Exists:f,plotStackGroup:h}},Ui=({viz:e,plotFormattedData:i,plotAxisData:a})=>{const o=i||[],r=a||[];function c(i){const a=e[`_${i}Time`],c=a?o:r,h=c.filter(e=>![NaN,void 0,!1].includes(e[i]));if(!h.length)return[];const l="number"==typeof h[0][i];let d=e.schema.discrete===i?t.rollups(h,t=>1===t.length?t[0].data:s.merge(t.map(e=>e.data),e.schema.aggs),e=>e[i]).sort((t,s)=>{if(e.schema[`${i}Sort`])return e.schema[`${i}Sort`](t[1],s[1]);return(a||l?parseFloat(t[0]):t[0])-(a||l?parseFloat(s[0]):s[0])}).map(([e])=>a?n.date(e):l?parseFloat(e):e):s.unique(h.sort((t,s)=>e.schema[`${i}Sort`]?e.schema[`${i}Sort`](t.data,s.data):t[i]-s[i]).map(e=>e[i]),e=>`${e}`);return e.schema.discrete!==i.charAt(0)&&e._confidence&&(e._confidence[0]&&(d=d.concat(c.map(e=>e.lci))),e._confidence[1]&&(d=d.concat(c.map(e=>e.hci)))),d}return{xData:c("x"),x2Data:c("x2"),yData:c("y"),y2Data:c("y2")}},Ji=({viz:e,plotFormattedData:i,plotAxisData:s,plotScales:n,plotConfigScales:a})=>{const o=i||[],r=s||[];let{x:c,y:h,x2:l,y2:d}=n;const{xConfigScale:u,yConfigScale:m,x2ConfigScale:f,y2ConfigScale:g}=a,p=n.xScale,y=n.yScale;if("Point"!==("x"===e.schema.discrete?y:p)){t.groups(r,e=>e.shape).forEach(([t,i])=>{if(["Bar","Box"].includes(t)&&Li("x"===e.schema.discrete?c:h,o,e.schema.discrete),e._buffer[t]){const s=e._buffer[t].bind(e)({data:i,x:c,y:h,yScale:m,xScale:u,config:e.schema.shapeConfig[t]});c=s[0],h=s[1];const n=e._buffer[t].bind(e)({data:i,x:l,y:d,yScale:g,xScale:f,x2:!0,y2:!0,config:e.schema.shapeConfig[t]});l=n[0],d=n[1]}})}return{plotScales:{...n,x:c,y:h,x2:l,y2:d}}},Qi=({viz:e,plotAxisData:t,plotScales:i,x2Exists:n,y2Exists:a,x2Data:o,y2Data:r,yData:c})=>{const h=t||[],{x:l,y:d,x2:u,y2:m,xScale:f,yScale:g,x2Scale:p,y2Scale:y}=i,_=l.domain(),x=u.domain(),b=d.domain(),k=m.domain(),v={barConfig:{"stroke-width":0},gridSize:0,labels:[],title:!1,tickSize:0},C=n?{data:o}:v,S=a?{data:r}:v,w="x"===e.schema.discrete?e.schema.width>e._discreteCutoff&&e.schema.width>e.schema.xCutoff:e.schema.width>e.schema.xCutoff,z="y"===e.schema.discrete?e.schema.height>e._discreteCutoff&&e.schema.height>e.schema.yCutoff:e.schema.height>e.schema.yCutoff,D={data:c,locale:e.schema.locale,rounding:e.schema.yDomain?"none":"outside",scalePadding:d.padding?d.padding():0};!w&&z&&(D.barConfig={stroke:"transparent"},D.tickSize=0,D.shapeConfig={labelBounds:(t,i)=>{const{width:s,y:n}=t.labelBounds,a=e.schema.height/2;return{x:i?-a:0,y:n,width:s,height:a}},labelConfig:{padding:0,rotate:0},labelRotation:!1});
2909
3018
  // Bar labels — used to suppress redundant axis ticks.
2910
- const M=Ei(e,"Bar"),A=void 0!==M.label?"function"==typeof M.label?M.label:()=>M.label:e._drawLabel,$=h.map(e=>A(e.data,e.i)).filter(e=>"number"==typeof e||e).map(String),B=(e,t)=>{const i=s.unique(h.map(t=>t[e]));return"Point"===t&&i.every(e=>$.includes(`${e}`))?[]:null};return{plotDefaultConfig:v,plotDefaultX2Config:C,plotDefaultY2Config:S,plotShowX:w,plotShowY:z,plotYC:D,plotBarLabels:$,plotXTicks:B("x",f),plotX2Ticks:B("x2",p),plotYTicks:B("y",g),plotY2Ticks:B("y2",y),plotXDomain:_,plotX2Domain:x,plotYDomain:b,plotY2Domain:k}},Ki=({viz:e,plotFormattedData:i,plotAxisData:s,plotInitialDomains:n})=>{const a=i||[],o=s||[];let r=n;const c=e.schema.width-e._margin.left-e._margin.right,h=e.schema.height-e._margin.top-e._margin.bottom,l=e.schema.discrete?"x"===e.schema.discrete?"y":"x":void 0,d=e.schema.discrete?"x"===e.schema.discrete?"y2":"x2":void 0,u=[l,d].filter(e=>e);function m(t){const i=e[`_${t}Time`]?"Time":e.schema.discrete===t||e.schema[`${t}Sort`]?"Point":"Linear",s=e.schema[`${t}Domain`]?e.schema[`${t}Domain`].slice():r[t],n=e.schema[`${t}2Domain`]?e.schema[`${t}2Domain`].slice():r[`${t}2`];return"Point"!==i&&(s&&void 0===s[0]&&(s[0]=r[t][0]),s&&void 0===s[1]&&(s[1]=r[t][1]),n&&void 0===n[0]&&(n[0]=r[`${t}2`][0]),n&&void 0===n[1]&&(n[1]=r[`${t}2`][1])),[s,i,n,i]}const[f,g,p,y]=m("x"),[_,x,b,k]=m("y"),v=(i,s)=>{const n=e[`_${i}Config`].scale;if("auto"===n){if(e.schema.discrete===i)return s;const n=o.map(e=>e[i]);return t.deviation(n)/t.mean(n)>3?"log":"linear"}return n||s},C=v("y",x).toLowerCase(),S=v("y2",k).toLowerCase(),w=v("x",g).toLowerCase(),z=v("x2",y).toLowerCase();
3019
+ const M=Hi(e,"Bar"),A=void 0!==M.label?"function"==typeof M.label?M.label:()=>M.label:e._drawLabel,$=h.map(e=>A(e.data,e.i)).filter(e=>"number"==typeof e||e).map(String),B=(e,t)=>{const i=s.unique(h.map(t=>t[e]));return"Point"===t&&i.every(e=>$.includes(`${e}`))?[]:null};return{plotDefaultConfig:v,plotDefaultX2Config:C,plotDefaultY2Config:S,plotShowX:w,plotShowY:z,plotYC:D,plotBarLabels:$,plotXTicks:B("x",f),plotX2Ticks:B("x2",p),plotYTicks:B("y",g),plotY2Ticks:B("y2",y),plotXDomain:_,plotX2Domain:x,plotYDomain:b,plotY2Domain:k}},Zi=({viz:e,plotFormattedData:i,plotAxisData:s,plotInitialDomains:n})=>{const a=i||[],o=s||[];let r=n;const c=e.schema.width-e._margin.left-e._margin.right,h=e.schema.height-e._margin.top-e._margin.bottom,l=e.schema.discrete?"x"===e.schema.discrete?"y":"x":void 0,d=e.schema.discrete?"x"===e.schema.discrete?"y2":"x2":void 0,u=[l,d].filter(e=>e);function m(t){const i=e[`_${t}Time`]?"Time":e.schema.discrete===t||e.schema[`${t}Sort`]?"Point":"Linear",s=e.schema[`${t}Domain`]?e.schema[`${t}Domain`].slice():r[t],n=e.schema[`${t}2Domain`]?e.schema[`${t}2Domain`].slice():r[`${t}2`];return"Point"!==i&&(s&&void 0===s[0]&&(s[0]=r[t][0]),s&&void 0===s[1]&&(s[1]=r[t][1]),n&&void 0===n[0]&&(n[0]=r[`${t}2`][0]),n&&void 0===n[1]&&(n[1]=r[`${t}2`][1])),[s,i,n,i]}const[f,g,p,y]=m("x"),[_,x,b,k]=m("y"),v=(i,s)=>{const n=e[`_${i}Config`].scale;if("auto"===n){if(e.schema.discrete===i)return s;const n=o.map(e=>e[i]);return t.deviation(n)/t.mean(n)>3?"log":"linear"}return n||s},C=v("y",x).toLowerCase(),S=v("y2",k).toLowerCase(),w=v("x",g).toLowerCase(),z=v("x2",y).toLowerCase();
2911
3020
  // `.slice()` the fallback so domains.x2 isn't ALIASED to domains.x
2912
3021
  // (and same for y2 ↔ y). Without the slice, later in this function
2913
3022
  // the baseline-extension loop does `domains[o][0] = b` — when `o`
@@ -2917,7 +3026,7 @@ r={x:f,x2:p||f.slice(),y:_,y2:b||_.slice()},Object.keys(r).forEach(i=>{"log"===e
2917
3026
  // `.slice()` first so we never mutate the user's config array in
2918
3027
  // place — on the next render the (already-reversed) array would
2919
3028
  // reverse back, alternating chart correctness across renders.
2920
- const i=e[`_${t}Config`].domain.slice();"x"===e.schema.discrete&&i.reverse(),r[t]=i}else if(t&&void 0!==e.schema.baseline){const i=e.schema.baseline;r[t]&&r[t][0]>i?r[t][0]=i:r[t]&&r[t][1]<i&&(r[t][1]=i)}});const D=ji[`scale${g}`]().domain(r.x).range(t.range(0,c+1,c/(r.x.length-1))),M=ji[`scale${y}`]().domain(r.x2).range(t.range(0,c+1,c/(r.x2.length-1))),A=ji[`scale${x}`]().domain(r.y.slice().reverse()).range(t.range(0,h+1,h/(r.y.length-1))),$=ji[`scale${k}`]().domain(r.y2.slice().reverse()).range(t.range(0,h+1,h/(r.y2.length-1)));return{plotDomains:r,plotScales:{x:D,y:A,x2:M,y2:$,xScale:g,yScale:x,x2Scale:y,y2Scale:k},plotConfigScales:{xConfigScale:w,yConfigScale:C,x2ConfigScale:z,y2ConfigScale:S},plotOpps:{opp:l,opp2:d,opps:u}}},Xi={defaults:{annotations:[],axisPersist:!1,barPadding:0,discreteCutoff:100,groupPadding:5,lineMarkers:!1,shape:L("Circle")}};
3029
+ const i=e[`_${t}Config`].domain.slice();"x"===e.schema.discrete&&i.reverse(),r[t]=i}else if(t&&void 0!==e.schema.baseline){const i=e.schema.baseline;r[t]&&r[t][0]>i?r[t][0]=i:r[t]&&r[t][1]<i&&(r[t][1]=i)}});const D=Yi[`scale${g}`]().domain(r.x).range(t.range(0,c+1,c/(r.x.length-1))),M=Yi[`scale${y}`]().domain(r.x2).range(t.range(0,c+1,c/(r.x2.length-1))),A=Yi[`scale${x}`]().domain(r.y.slice().reverse()).range(t.range(0,h+1,h/(r.y.length-1))),$=Yi[`scale${k}`]().domain(r.y2.slice().reverse()).range(t.range(0,h+1,h/(r.y2.length-1)));return{plotDomains:r,plotScales:{x:D,y:A,x2:M,y2:$,xScale:g,yScale:x,x2Scale:y,y2Scale:k},plotConfigScales:{xConfigScale:w,yConfigScale:C,x2ConfigScale:z,y2ConfigScale:S},plotOpps:{opp:l,opp2:d,opps:u}}},es={defaults:{annotations:[],axisPersist:!1,barPadding:0,discreteCutoff:100,groupPadding:5,lineMarkers:!1,shape:L("Circle")}};
2921
3030
  /** d3-scale's scale constructors, indexed by the dynamic `scale<Type>` name. */
2922
3031
  /**
2923
3032
  MEASURE half of the joint axis solve. Configures + measures the four
@@ -2928,7 +3037,7 @@ const i=e[`_${t}Config`].domain.slice();"x"===e.schema.discrete&&i.reverse(),r[t
2928
3037
  `measureLineLabels` is invoked once, after the first x-axis measure and
2929
3038
  before the re-measure, so its `xRangeMax` can re-bound the x range.
2930
3039
  */
2931
- function Vi(e,i,s){const{yBounds:n,yWidth:a,y2Bounds:o,y2Width:r}=
3040
+ function ts(e,i,s){const{yBounds:n,yWidth:a,y2Bounds:o,y2Width:r}=
2932
3041
  /** Measure the y/y2 test axes and report their bounds + claimed widths. */function(e,t){const{yTest:i,y2Test:s,yDomain:n,y2Domain:a,yTicks:o,y2Ticks:r,yConfigScale:c,y2ConfigScale:h,defaultY2Config:l,yC:d,showY:u,y2Exists:m,height:f,width:g}=t;u&&i.domain(n).height(f).maxSize(g/2).range([void 0,void 0]).ticks(o).width(g).config(d).config(e._yConfig).scale(c).measure();const p=i.outerBounds(),y=p.width?p.width+i.padding():void 0;m&&s.domain(a).height(f).range([void 0,void 0]).ticks(r).width(g).config(d).config(l).config(e._y2Config).scale(h).measure();const _=s.outerBounds();return{yBounds:p,yWidth:y,y2Bounds:_,y2Width:_.width?_.width+s.padding():void 0}}
2933
3042
  /** Build the shared x-axis config object, including the no-y-axis variant. */(e,i),c=function(e,t){const{xTicks:i,showX:s,showY:n,xData:a,xScalePadding:o}=t,r={data:a,locale:e.schema.locale,rounding:e.schema.xDomain?"none":"outside",scalePadding:o};return!n&&s&&(r.barConfig={stroke:"transparent"},r.tickSize=0,r.shapeConfig={labelBounds:(t,i)=>{const{height:s,y:n}=t.labelBounds,a=e.schema.width/2;return{x:i?-a:0,y:n,width:a,height:s}},labelConfig:{padding:0,rotate:0,textAnchor:e=>i&&e.id===i[0]?"start":"end"},labelRotation:!1}),r}
2934
3043
  /**
@@ -2948,7 +3057,7 @@ function Vi(e,i,s){const{yBounds:n,yWidth:a,y2Bounds:o,y2Width:r}=
2948
3057
  bumps the line labels, and queues axis scenes for the emit phase.
2949
3058
  Returns everything `plotEmit` needs to consume.
2950
3059
  */
2951
- function Ui(e,i){let{x:s,y:n}=i;const{labelWidths:a}=i,{xHeight:o,x2Height:r,topOffset:c,height:h,horizontalMargin:l,verticalMargin:d}=i;let u=[r,h-(o+c+d)];const{yBounds:m,yWidth:f,y2Bounds:g,y2Width:p,xOffsetLeft:y,xOffsetRight:_}=function(e,i,s){const{yDomain:n,y2Domain:a,yConfigScale:o,y2ConfigScale:r}=i,{defaultY2Config:c,showY:h,y2Exists:l,yC:d}=i,{yTicks:u,x2TestRange:m,xTestRange:f,height:g,width:p}=i,{yTest:y,y2Test:_}=i;let{xOffsetRight:x}=i;h&&y.domain(n).height(g).maxSize(p/2).range(s).ticks(u).width(p).config(d).config(e._yConfig).scale(o).measure();const b=y.outerBounds(),k=b.width?b.width+y.padding():void 0,v=t.max([k,f[0],m[0]]);l&&_.config(d).domain(a).gridSize(0).height(g).range(s).width(p-t.max([0,x-i.y2Width])).title(!1).config(e._y2Config).config(c).scale(r).measure();const C=_.outerBounds(),S=C.width?C.width+_.padding():void 0;return x=t.max([0,S,p-f[1],p-m[1]]),{yBounds:b,yWidth:k,y2Bounds:C,y2Width:S,xOffsetLeft:v,xOffsetRight:x}}
3060
+ function is(e,i){let{x:s,y:n}=i;const{labelWidths:a}=i,{xHeight:o,x2Height:r,topOffset:c,height:h,horizontalMargin:l,verticalMargin:d}=i;let u=[r,h-(o+c+d)];const{yBounds:m,yWidth:f,y2Bounds:g,y2Width:p,xOffsetLeft:y,xOffsetRight:_}=function(e,i,s){const{yDomain:n,y2Domain:a,yConfigScale:o,y2ConfigScale:r}=i,{defaultY2Config:c,showY:h,y2Exists:l,yC:d}=i,{yTicks:u,x2TestRange:m,xTestRange:f,height:g,width:p}=i,{yTest:y,y2Test:_}=i;let{xOffsetRight:x}=i;h&&y.domain(n).height(g).maxSize(p/2).range(s).ticks(u).width(p).config(d).config(e._yConfig).scale(o).measure();const b=y.outerBounds(),k=b.width?b.width+y.padding():void 0,v=t.max([k,f[0],m[0]]);l&&_.config(d).domain(a).gridSize(0).height(g).range(s).width(p-t.max([0,x-i.y2Width])).title(!1).config(e._y2Config).config(c).scale(r).measure();const C=_.outerBounds(),S=C.width?C.width+_.padding():void 0;return x=t.max([0,S,p-f[1],p-m[1]]),{yBounds:b,yWidth:k,y2Bounds:C,y2Width:S,xOffsetLeft:v,xOffsetRight:x}}
2952
3061
  /**
2953
3062
  Set `viz._chartTransform` and derive the per-axis relative transform
2954
3063
  helper used when absorbing axis scenes into `_chartScene`.
@@ -2987,25 +3096,25 @@ function(e,i,s){let n={};return i&&(t.groups(i,e=>e.xValue).forEach(([,i])=>{con
2987
3096
  position. Returns the compute-mode scene nodes (empty when nothing was
2988
3097
  bumped). Coords are relative to `_chartTransform`, which the chart-cells
2989
3098
  group applies.
2990
- */(e,a,u);let C=e._xAxis.barConfig()["stroke-width"];return C&&(C/=2),{x:s,y:n,xRange:x,yRange:u,xOffsetLeft:y,xOffsetRight:_,yWidth:f,y2Width:p,yBounds:m,y2Bounds:g,axisSceneQueue:k,yOffset:C||0,labelPositions:v}}const Ji=new Je,Qi=new Wt,Zi=(e,t)=>$i.prototype._draw.call(e,t);function es(e,i){if(!e._filteredData.length&&!e._annotations?.length)
3099
+ */(e,a,u);let C=e._xAxis.barConfig()["stroke-width"];return C&&(C/=2),{x:s,y:n,xRange:x,yRange:u,xOffsetLeft:y,xOffsetRight:_,yWidth:f,y2Width:p,yBounds:m,y2Bounds:g,axisSceneQueue:k,yOffset:C||0,labelPositions:v}}const ss=new Ze,ns=new Gt,as=(e,t)=>Oi.prototype._draw.call(e,t);function os(e,i){if(!e._filteredData.length&&!e._annotations?.length)
2991
3100
  // Empty data: still run super._draw so the chart shell (title /
2992
3101
  // legend / total / timeline / colorScale) refreshes — features
2993
3102
  // tear down their DOM via .data([]) in their layout body, and
2994
3103
  // vizDrawPure resets _chartScene/_featurePanels/_shapes. Without
2995
3104
  // this, the previous render's chart shell (incl. aria-labels)
2996
3105
  // lingers in the DOM and toScene() emits stale nodes.
2997
- return Zi(e,i),e;
3106
+ return as(e,i),e;
2998
3107
  // Throwaway measure-only axes. Allocated per draw, configured + measured
2999
3108
  // below, then garbage-collected when the function returns. Plot no longer
3000
3109
  // owns long-lived Axis instances just to compute layout. gridSize(0)
3001
3110
  // signals "labels-only" measure: the production axes (`_xAxis`,
3002
3111
  // `_yAxis`, …) handle grid rendering with their default gridSize.
3003
- const s=(new bt).align("end").gridSize(0),n=(new Ct).align("start").gridSize(0),a=(new kt).align("start").gridSize(0),o=(new kt).align("end").gridSize(0),{data:r,axisData:c,x2Exists:h,y2Exists:l,xData:d,x2Data:u,yData:m,y2Data:f,stackGroup:g}=
3004
- /** Runs format + per-axis-value stages; returns formatted data and axis-value bundles. */function(e){const t=he({viz:e},[Gi,Ii]);
3112
+ const s=(new St).align("end").gridSize(0),n=(new Dt).align("start").gridSize(0),a=(new wt).align("start").gridSize(0),o=(new wt).align("end").gridSize(0),{data:r,axisData:c,x2Exists:h,y2Exists:l,xData:d,x2Data:u,yData:m,y2Data:f,stackGroup:g}=
3113
+ /** Runs format + per-axis-value stages; returns formatted data and axis-value bundles. */function(e){const t=he({viz:e},[Xi,Ui]);
3005
3114
  // Time flags (xTime/x2Time/yTime/y2Time) are written onto `viz` by
3006
3115
  // `formatPlotData` and read directly via `viz._xTime` etc. downstream.
3007
3116
  return{data:t.plotFormattedData,axisData:t.plotAxisData,x2Exists:t.x2Exists,y2Exists:t.y2Exists,xData:t.xData,x2Data:t.x2Data,yData:t.yData,y2Data:t.y2Data,stackGroup:t.plotStackGroup}}
3008
- /** Runs domain + scale stages; returns domains, stack data, and scale bundles. */(e),p=e.schema.height-e._margin.top-e._margin.bottom,y=e.schema.discrete?"x"===e.schema.discrete?"y":"x":void 0,_=e.schema.width-e._margin.left-e._margin.right,x=function(e,t,i,s,n){const{xData:a,x2Data:o,yData:r,y2Data:c}=n,h=he({viz:e,plotFormattedData:t,plotAxisData:i,xData:a,x2Data:o,yData:r,y2Data:c,plotStackGroup:s},[Ni,Ki]);
3117
+ /** Runs domain + scale stages; returns domains, stack data, and scale bundles. */(e),p=e.schema.height-e._margin.top-e._margin.bottom,y=e.schema.discrete?"x"===e.schema.discrete?"y":"x":void 0,_=e.schema.width-e._margin.left-e._margin.right,x=function(e,t,i,s,n){const{xData:a,x2Data:o,yData:r,y2Data:c}=n,h=he({viz:e,plotFormattedData:t,plotAxisData:i,xData:a,x2Data:o,yData:r,y2Data:c,plotStackGroup:s},[Ii,Zi]);
3009
3118
  // Stacked/non-stacked domain construction + domain/scale setup are stages
3010
3119
  // on `plotDef`. Run them together and read all the outputs the paint phase
3011
3120
  // below needs.
@@ -3014,9 +3123,9 @@ return{plotInitialDomains:h.plotInitialDomains,plotDiscreteKeys:h.plotDiscreteKe
3014
3123
  // Opposite-axis scale extension via buffers lives in the
3015
3124
  // `extendPlotOppScales` stage. Reassigns x/y/x2/y2 from the stage's
3016
3125
  // returned scales bundle.
3017
- const a=he({viz:e,plotFormattedData:t,plotAxisData:i,plotScales:{...s.plotScales,...n},plotConfigScales:s.plotConfigScales},[qi]).plotScales;return{x:a.x,y:a.y,x2:a.x2,y2:a.y2}}
3018
- /** Runs axis-layout prep; returns domains, default configs, show flags, ticks, and bar labels. */(e,r,c,x,{x:S,y:w,x2:z,y2:D}));const R=function(e,t,i,s,n,a){const{x2Exists:o,y2Exists:r}=n,{x2Data:c,y2Data:h,yData:l}=a,d=he({viz:e,plotAxisData:t,plotScales:{...i.plotScales,...s},x2Exists:o,y2Exists:r,x2Data:c,y2Data:h,yData:l},[Yi]);return{plotDefaultConfig:d.plotDefaultConfig,plotDefaultX2Config:d.plotDefaultX2Config,plotDefaultY2Config:d.plotDefaultY2Config,plotShowX:d.plotShowX,plotShowY:d.plotShowY,plotYC:d.plotYC,plotBarLabels:d.plotBarLabels,plotXTicks:d.plotXTicks,plotX2Ticks:d.plotX2Ticks,plotYTicks:d.plotYTicks,plotY2Ticks:d.plotY2Ticks,plotXDomain:d.plotXDomain,plotX2Domain:d.plotX2Domain,plotYDomain:d.plotYDomain,plotY2Domain:d.plotY2Domain}}
3019
- /** Builds the line-label width measure callback for the four-axis margin solve. */(e,c,x,{x:S,y:w,x2:z,y2:D},{x2Exists:h,y2Exists:l},{x2Data:u,y2Data:f,yData:m}),L=R.plotXDomain,E=R.plotX2Domain,F=R.plotYDomain,W=R.plotY2Domain,N=R.plotDefaultConfig,H=R.plotDefaultX2Config,j=R.plotDefaultY2Config,G=R.plotShowX,I=R.plotShowY,q=R.plotYC,Y=R.plotXTicks,K=R.plotX2Ticks,X=R.plotYTicks,V=R.plotY2Ticks,U=R.plotBarLabels,J=e.schema.lineLabels&&!l,Q=function(e,t,i,s,n){const{xTest:a,yTest:o}=n;return()=>{const n=he({viz:e,plotFormattedData:t,plotScales:i.plotScales,plotConfigScales:i.plotConfigScales,plotTestAxes:{xTest:a,yTest:o},plotLineLabelTest:{testLineShape:Ji,testTextBox:Qi},y2Exists:s},[Hi]);return{labelWidths:n.plotLabelWidths,largestLabel:n.plotLargestLabel,xRangeMax:n.plotXRangeMax}}}(e,r,x,l,{xTest:s,yTest:a}),{yBounds:Z,y2Bounds:ee,yWidth:te,y2Width:ie,xC:se,xRangeMax:ne,labelWidths:ae,largestLabel:oe,xTestRange:re,x2TestRange:ce,x2Height:le,xOffsetLeft:de,xOffsetRight:ue,topOffset:me,xHeight:fe}=Vi(e,{xTest:s,yTest:a,x2Test:n,y2Test:o,xDomain:L,x2Domain:E,yDomain:F,y2Domain:W,xTicks:Y,x2Ticks:K,yTicks:X,y2Ticks:V,xConfigScale:$,x2ConfigScale:P,yConfigScale:B,y2ConfigScale:T,defaultX2Config:H,defaultY2Config:j,yC:q,showX:G,showY:I,x2Exists:h,y2Exists:l,height:p,width:_,xData:d,xScalePadding:S.padding?S.padding():0},Q);Zi(e,i);const ge={domains:b,shapeData:O,axisData:c,data:r,discreteKeys:k,stackData:v,stackKeys:C,x:S,y:w,x2:z,y2:D,xScale:M,yScale:A,xConfigScale:$,yConfigScale:B,x2ConfigScale:P,y2ConfigScale:T,xDomain:L,yDomain:F,x2Domain:E,y2Domain:W,xData:d,yData:m,x2Data:u,y2Data:f,x2Exists:h,y2Exists:l,showX:G,showY:I,defaultConfig:N,defaultX2Config:H,defaultY2Config:j,yC:q,xC:se,xTicks:Y,yTicks:X,x2Ticks:K,y2Ticks:V,labelWidths:ae,largestLabel:oe,xRangeMax:ne,xTest:s,yTest:a,x2Test:n,y2Test:o,yBounds:Z,y2Bounds:ee,yWidth:te,y2Width:ie,xHeight:fe,x2Height:le,xOffsetLeft:de,xOffsetRight:ue,topOffset:me,xTestRange:re,x2TestRange:ce,height:p,width:_,opp:y,barLabels:U,showLineLabels:J,stackGroup:g,horizontalMargin:e._margin.left+e._margin.right,verticalMargin:e._margin.top+e._margin.bottom};return e._paint(ge)}
3126
+ const a=he({viz:e,plotFormattedData:t,plotAxisData:i,plotScales:{...s.plotScales,...n},plotConfigScales:s.plotConfigScales},[Ji]).plotScales;return{x:a.x,y:a.y,x2:a.x2,y2:a.y2}}
3127
+ /** Runs axis-layout prep; returns domains, default configs, show flags, ticks, and bar labels. */(e,r,c,x,{x:S,y:w,x2:z,y2:D}));const R=function(e,t,i,s,n,a){const{x2Exists:o,y2Exists:r}=n,{x2Data:c,y2Data:h,yData:l}=a,d=he({viz:e,plotAxisData:t,plotScales:{...i.plotScales,...s},x2Exists:o,y2Exists:r,x2Data:c,y2Data:h,yData:l},[Qi]);return{plotDefaultConfig:d.plotDefaultConfig,plotDefaultX2Config:d.plotDefaultX2Config,plotDefaultY2Config:d.plotDefaultY2Config,plotShowX:d.plotShowX,plotShowY:d.plotShowY,plotYC:d.plotYC,plotBarLabels:d.plotBarLabels,plotXTicks:d.plotXTicks,plotX2Ticks:d.plotX2Ticks,plotYTicks:d.plotYTicks,plotY2Ticks:d.plotY2Ticks,plotXDomain:d.plotXDomain,plotX2Domain:d.plotX2Domain,plotYDomain:d.plotYDomain,plotY2Domain:d.plotY2Domain}}
3128
+ /** Builds the line-label width measure callback for the four-axis margin solve. */(e,c,x,{x:S,y:w,x2:z,y2:D},{x2Exists:h,y2Exists:l},{x2Data:u,y2Data:f,yData:m}),L=R.plotXDomain,E=R.plotX2Domain,F=R.plotYDomain,W=R.plotY2Domain,N=R.plotDefaultConfig,H=R.plotDefaultX2Config,j=R.plotDefaultY2Config,G=R.plotShowX,I=R.plotShowY,q=R.plotYC,Y=R.plotXTicks,K=R.plotX2Ticks,V=R.plotYTicks,X=R.plotY2Ticks,U=R.plotBarLabels,J=e.schema.lineLabels&&!l,Q=function(e,t,i,s,n){const{xTest:a,yTest:o}=n;return()=>{const n=he({viz:e,plotFormattedData:t,plotScales:i.plotScales,plotConfigScales:i.plotConfigScales,plotTestAxes:{xTest:a,yTest:o},plotLineLabelTest:{testLineShape:ss,testTextBox:ns},y2Exists:s},[qi]);return{labelWidths:n.plotLabelWidths,largestLabel:n.plotLargestLabel,xRangeMax:n.plotXRangeMax}}}(e,r,x,l,{xTest:s,yTest:a}),{yBounds:Z,y2Bounds:ee,yWidth:te,y2Width:ie,xC:se,xRangeMax:ne,labelWidths:ae,largestLabel:oe,xTestRange:re,x2TestRange:ce,x2Height:le,xOffsetLeft:de,xOffsetRight:ue,topOffset:me,xHeight:fe}=ts(e,{xTest:s,yTest:a,x2Test:n,y2Test:o,xDomain:L,x2Domain:E,yDomain:F,y2Domain:W,xTicks:Y,x2Ticks:K,yTicks:V,y2Ticks:X,xConfigScale:$,x2ConfigScale:P,yConfigScale:B,y2ConfigScale:T,defaultX2Config:H,defaultY2Config:j,yC:q,showX:G,showY:I,x2Exists:h,y2Exists:l,height:p,width:_,xData:d,xScalePadding:S.padding?S.padding():0},Q);as(e,i);const ge={domains:b,shapeData:O,axisData:c,data:r,discreteKeys:k,stackData:v,stackKeys:C,x:S,y:w,x2:z,y2:D,xScale:M,yScale:A,xConfigScale:$,yConfigScale:B,x2ConfigScale:P,y2ConfigScale:T,xDomain:L,yDomain:F,x2Domain:E,y2Domain:W,xData:d,yData:m,x2Data:u,y2Data:f,x2Exists:h,y2Exists:l,showX:G,showY:I,defaultConfig:N,defaultX2Config:H,defaultY2Config:j,yC:q,xC:se,xTicks:Y,yTicks:V,x2Ticks:K,y2Ticks:X,labelWidths:ae,largestLabel:oe,xRangeMax:ne,xTest:s,yTest:a,x2Test:n,y2Test:o,yBounds:Z,y2Bounds:ee,yWidth:te,y2Width:ie,xHeight:fe,x2Height:le,xOffsetLeft:de,xOffsetRight:ue,topOffset:me,xTestRange:re,x2TestRange:ce,height:p,width:_,opp:y,barLabels:U,showLineLabels:J,stackGroup:g,horizontalMargin:e._margin.left+e._margin.right,verticalMargin:e._margin.top+e._margin.bottom};return e._paint(ge)}
3020
3129
  /**
3021
3130
  Plot label/size placement helpers. Both are invoked bound to a Plot
3022
3131
  instance (`fn.bind(this)`), so they read the live axis scales +
@@ -3024,52 +3133,70 @@ const a=he({viz:e,plotFormattedData:t,plotAxisData:i,plotScales:{...s.plotScales
3024
3133
  */
3025
3134
  /**
3026
3135
  Default shape size, routed through the chart's internal sizeScale.
3027
- */function ts(e){
3136
+ */function rs(e){
3028
3137
  // When `_size` is unset, `_sizeScaleD3` is the constant `() => sizeMin`,
3029
3138
  // so the `null` argument is ignored (cast to satisfy the scale signature).
3030
3139
  return this._sizeScaleD3(this._size?this._size(e):null)}
3031
3140
  /**
3032
3141
  Determines if a Bar label should be placed outside of the Bar.
3033
- */function is(e,t){
3142
+ */function cs(e,t){
3034
3143
  // Force all Stacked Bars to use "inside" labels.
3035
3144
  if(this.schema.stacked)return!1;
3036
3145
  // Detect user "outside" or "inside" override.
3037
3146
  const i=this._labelPosition(e,t);if("outside"===i)return!0;
3038
3147
  // Run "auto" logic based on available space, against the non-discrete axis.
3039
3148
  if("inside"===i)return!1;const s="x"===this.schema.discrete.charAt(0)?"y":"x",n=this.schema.discrete.replace(this.schema.discrete.charAt(0),s),a="y"===n?this._yAxis:this._xAxis,o="y"===n?this._y:this._x,r=a._d3Scale.range(),c=o(e,t),h=c<0,l=a._getPosition(0),d="y"===n?h?r[1]-l:l-r[0]:h?l-r[0]:r[1]-l,u=a._getPosition(c);return Math.abs(h?l-u:u-l)<d/2}
3040
- /** Builds the `Area` shape config; `self` is the Plot instance. */function ss(e){return{label:(t,i)=>!!e.schema.stacked&&e._drawLabel(t,i),labelBounds:(e,i,s)=>{let n=y.largestRect(s.points,{angle:t.range(-20,20,5)});if((!n||n.height<20||n.width<50)&&(n=y.largestRect(s.points,{angle:t.range(-80,80,5)})),!n)return null;const a=t.min(s.points,e=>e[0]),o=t.max(s.points.filter(e=>e[0]===a),e=>e[1]);return{angle:n.angle,width:n.width,height:n.height,x:n.cx-n.width/2-a,y:n.cy-n.height/2-o}},labelConfig:{fontMin:6,fontResize:!0,padding:10}}}
3041
- /** Builds the top-level `ariaLabel` accessor; `self` is the Plot instance. */function ns(e){return(t,i)=>{let s="";return t.nested?s=`${e._drawLabel(t.data,t.i)}`:(s=`${e._drawLabel(t,i)}`,void 0!==e._x(t,i)&&(s+=`, x: ${e._x(t,i)}`),void 0!==e._y(t,i)&&(s+=`, y: ${e._y(t,i)}`),void 0!==e._x2(t,i)&&(s+=`, x2: ${e._x2(t,i)}`),void 0!==e._y2(t,i)&&(s+=`, y2: ${e._y2(t,i)}`)),`${s}.`}}
3149
+ /** Builds the `Area` shape config; `self` is the Plot instance. */function hs(e){return{label:(t,i)=>!!e.schema.stacked&&e._drawLabel(t,i),labelBounds:(e,i,s)=>{let n=p.largestRect(s.points,{angle:t.range(-20,20,5)});if((!n||n.height<20||n.width<50)&&(n=p.largestRect(s.points,{angle:t.range(-80,80,5)})),!n)return null;const a=t.min(s.points,e=>e[0]),o=t.max(s.points.filter(e=>e[0]===a),e=>e[1]);return{angle:n.angle,width:n.width,height:n.height,x:n.cx-n.width/2-a,y:n.cy-n.height/2-o}},labelConfig:{fontMin:6,fontResize:!0,padding:10}}}
3150
+ /** Builds the top-level `ariaLabel` accessor; `self` is the Plot instance. */function ls(e){return(t,i)=>{let s="";return t.nested?s=`${e._drawLabel(t.data,t.i)}`:(s=`${e._drawLabel(t,i)}`,void 0!==e._x(t,i)&&(s+=`, x: ${e._x(t,i)}`),void 0!==e._y(t,i)&&(s+=`, y: ${e._y(t,i)}`),void 0!==e._x2(t,i)&&(s+=`, x2: ${e._x2(t,i)}`),void 0!==e._y2(t,i)&&(s+=`, y2: ${e._y2(t,i)}`)),`${s}.`}}
3042
3151
  /** Builds the `Bar.labelConfig` block (dynamic-`this` accessors preserved). */
3043
- /** Builds the `Line` shape config; `self` is the Plot instance. */function as(e){return{curve:()=>e.schema.discrete?`monotone${e.schema.discrete.charAt(0).toUpperCase()}`:"linear",fill:L("none"),labelConfig:{fontColor:(t,i)=>{const s="function"==typeof e.schema.shapeConfig.Line.stroke?e.schema.shapeConfig.Line.stroke(t,i):e.schema.shapeConfig.Line.stroke;return u.colorLegible(s)},fontResize:!1,padding:5,textAnchor:"start",verticalAlign:"middle"},strokeWidth:L(2)}}function os(){return{Area:ss(this),ariaLabel:ns(this),Bar:{labelBounds(e,t,i){const s="y"===this.schema.discrete?"width":"height",n="y"===this.schema.discrete?"height":"width",a="x"===this.schema.discrete.charAt(0)?"y":"x",o="y"===a,r=this.schema.discrete.replace(this.schema.discrete.charAt(0),a),c=("y"===r?this._yAxis:this._xAxis)._d3Scale.range(),h=Math.abs(c[1]-c[0]),l=("y"===r?this._y:this._x)(e,t)<0;return is.bind(this)(e,t)?{[s]:h-i[s],[n]:i[n],x:o?-i.width/2:l?-h:i.width+1,y:o?l?i.height+1:-h:-i.height/2+1}:{[s]:i[s],[n]:i[n],x:o?-i.width/2:l?(this.schema.stacked,1-i.width):-1,y:o?l?(this.schema.stacked,1):1-i.height:-i.height/2+1}},labelConfig:{fontMax:16,fontMin:6,fontResize:!0,fontColor(e,t){if(is.bind(this)(e,t)){const e="transparent"===this._backgroundConfig.fill?n.backgroundColor(this._select.node()):this._backgroundConfig.fill;return u.colorContrast(e)}return u.colorContrast("function"==typeof this.schema.shapeConfig.fill?this.schema.shapeConfig.fill(e,t):this.schema.shapeConfig.fill)},fontStroke(e,t){if(is.bind(this)(e,t)){const e="transparent"===this._backgroundConfig.fill?n.backgroundColor(this._select.node()):this._backgroundConfig.fill;return u.colorContrast(e)}return"transparent"},fontStrokeWidth(e,t){return is.bind(this)(e,t)?.1:0},padding:3,textAnchor(e,t){const i="x"===this.schema.discrete.charAt(0)?"y":"x",s="y"===i,a=("y"===this.schema.discrete.replace(this.schema.discrete.charAt(0),i)?this._y:this._x)(e,t)<0,o=s?"middle":is.bind(this)(e,t)?a?"end":"start":a?"start":"end";return n.rtl()?"start"===o?"end":"end"===o?"start":o:o},verticalAlign(e,t){const i="x"===this.schema.discrete.charAt(0)?"y":"x",s="y"===i,n=("y"===this.schema.discrete.replace(this.schema.discrete.charAt(0),i)?this._y:this._x)(e,t)<0;return s?is.bind(this)(e,t)?n?"top":"bottom":n?"bottom":"top":"middle"}}},Circle:{r:ts.bind(this),
3152
+ /** Builds the `Line` shape config; `self` is the Plot instance. */function ds(e){return{curve:()=>e.schema.discrete?`monotone${e.schema.discrete.charAt(0).toUpperCase()}`:"linear",fill:L("none"),labelConfig:{fontColor:(t,i)=>{const s="function"==typeof e.schema.shapeConfig.Line.stroke?e.schema.shapeConfig.Line.stroke(t,i):e.schema.shapeConfig.Line.stroke;return u.colorLegible(s)},fontResize:!1,padding:5,textAnchor:"start",verticalAlign:"middle"},strokeWidth:L(2)}}function us(){return{Area:hs(this),ariaLabel:ls(this),Bar:{labelBounds(e,t,i){const s="y"===this.schema.discrete?"width":"height",n="y"===this.schema.discrete?"height":"width",a="x"===this.schema.discrete.charAt(0)?"y":"x",o="y"===a,r=this.schema.discrete.replace(this.schema.discrete.charAt(0),a),c=("y"===r?this._yAxis:this._xAxis)._d3Scale.range(),h=Math.abs(c[1]-c[0]),l=("y"===r?this._y:this._x)(e,t)<0;return cs.bind(this)(e,t)?{[s]:h-i[s],[n]:i[n],x:o?-i.width/2:l?-h:i.width+1,y:o?l?i.height+1:-h:-i.height/2+1}:{[s]:i[s],[n]:i[n],x:o?-i.width/2:l?(this.schema.stacked,1-i.width):-1,y:o?l?(this.schema.stacked,1):1-i.height:-i.height/2+1}},labelConfig:{fontMax:16,fontMin:6,fontResize:!0,fontColor(e,t){if(cs.bind(this)(e,t)){const e="transparent"===this._backgroundConfig.fill?n.backgroundColor(this._select.node()):this._backgroundConfig.fill;return u.colorContrast(e)}return u.colorContrast("function"==typeof this.schema.shapeConfig.fill?this.schema.shapeConfig.fill(e,t):this.schema.shapeConfig.fill)},fontStroke(e,t){if(cs.bind(this)(e,t)){const e="transparent"===this._backgroundConfig.fill?n.backgroundColor(this._select.node()):this._backgroundConfig.fill;return u.colorContrast(e)}return"transparent"},fontStrokeWidth(e,t){return cs.bind(this)(e,t)?.1:0},padding:3,textAnchor(e,t){const i="x"===this.schema.discrete.charAt(0)?"y":"x",s="y"===i,a=("y"===this.schema.discrete.replace(this.schema.discrete.charAt(0),i)?this._y:this._x)(e,t)<0,o=s?"middle":cs.bind(this)(e,t)?a?"end":"start":a?"start":"end";return n.rtl()?"start"===o?"end":"end"===o?"start":o:o},verticalAlign(e,t){const i="x"===this.schema.discrete.charAt(0)?"y":"x",s="y"===i,n=("y"===this.schema.discrete.replace(this.schema.discrete.charAt(0),i)?this._y:this._x)(e,t)<0;return s?cs.bind(this)(e,t)?n?"top":"bottom":n?"bottom":"top":"middle"}}},Circle:{r:rs.bind(this),
3044
3153
  // Scatter/bubble points leave a motion trail when they move between
3045
3154
  // frames (Timeline play). Only affects Circle/Rect marks, so Bar/Line/Area
3046
3155
  // plots are unaffected; opt out per chart with shapeConfig.Circle.trail.
3047
- trail:!0},Line:as(this),Rect:{height:e=>2*ts.bind(this)(e),width:e=>2*ts.bind(this)(e),
3156
+ trail:!0},Line:ds(this),Rect:{height:e=>2*rs.bind(this)(e),width:e=>2*rs.bind(this)(e),
3048
3157
  // Square scatter marks trail like Circle points do; the cone is sized to
3049
3158
  // the square's silhouette perpendicular to travel (corner-to-corner at
3050
3159
  // 45°). Opt out per chart with shapeConfig.Rect.trail: false.
3051
3160
  trail:!0}}}
3161
+ /** Marks a comparator as an already-resolved d3plus stack order. */function ms(e){return e.__d3plusStackOrder=!0,e}
3162
+ // @types/d3-shape types the order accessors' param as a single `Series`,
3163
+ // though d3 passes the full stack array; this cast satisfies the signature.
3052
3164
  /**
3053
3165
  Sums a single stack series, ignoring non-numeric segments.
3054
- */function rs(e){let t,i=-1,s=0;const n=e.length;for(;++i<n;)(t=+e[i][1])&&(s+=t);return s}
3166
+ */
3167
+ function fs(e){let t,i=-1,s=0;const n=e.length;for(;++i<n;)(t=+e[i][1])&&(s+=t);return s}
3055
3168
  /**
3056
- Stack order: ascending by series key, tie-broken by summed value.
3057
- */function cs(e){const t=e.map(rs),i=e.map(e=>e.key.split("_")[0]);
3058
- // @types/d3-shape types the order accessors' param as a single `Series`,
3059
- // though d3 passes the full stack array; cast to satisfy the signature.
3060
- return P.stackOrderNone(e).sort((e,s)=>i[s].localeCompare(i[e])||t[e]-t[s])}
3169
+ Stack order: series with the smallest summed value on the bottom of the
3170
+ stack (matches d3's `stackOrderAscending`).
3171
+ */const gs=ms(e=>P.stackOrderAscending(e)),ps=ms(e=>P.stackOrderDescending(e)),ys=ms(e=>{const t=e.map(fs),i=e.map(e=>e.key.split("_")[0]);return P.stackOrderNone(e).sort((e,s)=>i[e].localeCompare(i[s])||t[e]-t[s])}),_s=ms(e=>ys(e).reverse());
3061
3172
  /**
3062
- Stack order: the reverse of {@link stackOrderAscending}.
3063
- */function hs(e){return cs(e).reverse()}
3173
+ Stack order: series with the largest summed value on the bottom of the
3174
+ stack (matches d3's `stackOrderDescending`). Plot's default.
3175
+ */
3176
+ /**
3177
+ Builds a stack order that ranks each series by an aggregate (sum) of a
3178
+ data field, letting users order stacks by any value in their data rather
3179
+ than only the plotted one. `value` receives each series' original datum.
3180
+ */
3181
+ function xs(e,t="descending"){return ms(i=>{const s=i.map(t=>{let i=0;for(let s=0;s<t.length;s++){
3182
+ // Each stacked point carries `.data` = the discrete group's rows;
3183
+ // pick the row for this series and read the field off its datum.
3184
+ const n=(t[s].data||[]).find(e=>e.id===t.key);if(n&&n.data){const t=+e(n.data);isNaN(t)||(i+=t)}}return i});return P.stackOrderNone(i).sort((e,i)=>"ascending"===t?s[e]-s[i]:s[i]-s[e])})}
3185
+ /** Named stack orders accepted by `Plot.stackOrder`. */const bs={ascending:gs,descending:ps,key:ys,keyReverse:_s,none:ms(e=>P.stackOrderNone(e)),data:ms(e=>P.stackOrderNone(e)),insideOut:ms(e=>P.stackOrderInsideOut(e)),appearance:ms(e=>P.stackOrderAppearance(e)),reverse:ms(e=>P.stackOrderReverse(e))},ks=Object.keys(bs);
3186
+ /** The named orders accepted by `Plot.stackOrder`, for docs/validation. */
3064
3187
  /**
3065
3188
  Diverging stack offset: positive segments stack upward from zero,
3066
3189
  negative segments stack downward.
3067
- */function ls(e,t){let i,s,n,a,o,r;if(!((i=e.length)>0))return;const c=e[t[0]].length;for(let h=0;h<c;++h)for(r=o=0,a=0;a<i;++a)(n=(s=e[t[a]][h])[1]-s[0])>=0?(s[0]=r,s[1]=r+=n):n<0?(s[1]=o,s[0]=o+=n):s[0]=r}
3190
+ */
3191
+ function vs(e,t){let i,s,n,a,o,r;if(!((i=e.length)>0))return;const c=e[t[0]].length;for(let h=0;h<c;++h)for(r=o=0,a=0;a<i;++a)(n=(s=e[t[a]][h])[1]-s[0])>=0?(s[0]=r,s[1]=r+=n):n<0?(s[1]=o,s[0]=o+=n):s[0]=r}
3192
+ /** Named stack offsets accepted by `Plot.stackOffset`. */const Cs={diverging:vs,none:P.stackOffsetNone,expand:P.stackOffsetExpand,silhouette:P.stackOffsetSilhouette,wiggle:P.stackOffsetWiggle},Ss=Object.keys(Cs);
3193
+ /** The named offsets accepted by `Plot.stackOffset`, for docs/validation. */
3068
3194
  /**
3069
3195
  Clone the base shape config and, for stacked Area/Bar, inject the
3070
3196
  stacking-aware opp/opp0/opp1 accessors that read the precomputed
3071
3197
  `stackData` cube.
3072
- */function ds(e,t){const{viz:i,opp:s,x:n,y:a,stackData:o,domains:r,stackKeyIndex:c,discreteKeyIndex:h}=e,l=Object.assign({},e.shapeConfig);
3198
+ */
3199
+ function ws(e,t){const{viz:i,opp:s,x:n,y:a,stackData:o,domains:r,stackKeyIndex:c,discreteKeyIndex:h}=e,l=Object.assign({},e.shapeConfig);
3073
3200
  // Bubble plots: when a `size` accessor is set, default to layering circles
3074
3201
  // largest-behind so smaller marks stay visible under bigger ones. This is a
3075
3202
  // default — `finishShape` applies the user's `shapeConfig` afterwards, so an
@@ -3078,10 +3205,13 @@ if("Circle"===t&&i._size){const e=i._size;l.sort=(t,i)=>(Number(e(i))||0)-(Numbe
3078
3205
  /**
3079
3206
  Shared tail: wire shape events, apply the user's shapeConfig, render in
3080
3207
  compute mode, and collect the resulting scene nodes.
3081
- */function us(e,t,i){const{viz:s,events:n}=e;s._wirePlotShapeEvents(i,t,n);const a=Ei(s,t);return void 0===s.schema.shapeConfig.duration&&delete a.duration,i.config(a).render(),Fi(i)}
3082
- /** Generic path — every shape key without a dedicated emitter (incl. stacked Area). */const ms=(e,t)=>us(e,t,Oi(t).renderMode("compute").config(ds(e,t)).data(e.values)),fs={Bar:e=>{const{viz:i,x:s,y:n,xScale:a,yScale:o,xDomain:r,yDomain:c,xRange:h,yRange:l,values:d}=e,u=Oi("Bar").renderMode("compute").config(ds(e,"Bar")).data(d);let m;const f="x"===i.schema.discrete?s:n,g="x"===i.schema.discrete?a:o,p="x"===i.schema.discrete?r:c,y="x"===i.schema.discrete?h:l;if("Point"!==g&&2===p.length){const e=Array.from(new Set(d.map(e=>f(e[i.schema.discrete]))));e.unshift(y[0]-e[0]-y[0]),e.push(y[1]+y[1]-e[e.length-1]),m=e.reduce((e,t,i,s)=>{if(i){const n=Math.abs(t-s[i-1]);n<e&&(e=n)}return e},1/0)}else m=p.length>1?f(p[1])-f(p[0]):y[y.length-1]-y[0];i._groupPadding<m&&(m-=i._groupPadding);let _=m||1;const x=t.groups(d,e=>e[i.schema.discrete],e=>e.group),b=t.merge(x.map(([,e])=>e.map(([e])=>e))),k=Array.from(new Set(b)),v=i.schema.discrete,C=e.shapeConfig[v];if(1===t.max(x.map(([,e])=>e.length)))u[v]((e,t)=>C(e,t));else{_=(_-i.schema.barPadding*k.length-1)/k.length;const e=m/2-_/2,t=B.scaleLinear().domain([0,k.length-1]).range([-e,e]);u[v]((e,i)=>C(e,i)+t(k.indexOf(e.group)))}return u.width(_),u.height(_),us(e,"Bar",u)},Line:e=>{const{viz:t,x:i,y:s,values:a,width:o,showLineLabels:r,labelWidths:c,largestLabel:h,labelPositions:l}=e,d=[],u=Oi("Line").renderMode("compute").config(ds(e,"Line")).data(a);if(u.duration(1.5*o),t._confidence){const o=t._confidence,r=Object.assign({},e.shapeConfig),c=t.schema.discrete||"x",h="x"===c?"y":"x",l="x"===c?s:i;r[`${h}0`]=e=>l(o[0]?e.lci:e[h]),r[`${h}1`]=e=>l(o[1]?e.hci:e[h]);const u=Oi("Area").renderMode("compute").config(r).data(a),m=Object.assign(t.schema.shapeConfig,t._confidenceConfig);u.config(n.assign(Ei(t,"Line",m),Ei(t,"Area",m))).render(),d.push(...Fi(u))}u.config({discrete:e.shapeConfig.discrete||"x",label:!!r&&((e,i)=>{if(!("function"!=typeof t.schema.lineLabels||t.schema.lineLabels(e.data,e.i)))return!1;const s=c.find(t=>t.id===e.id);if(s){const n=s.newY||s.defaultY,a=c.filter(e=>e.newY===n);return a.length>1?a[0].id===e.id&&`+${m.formatAbbreviate(a.length,t.schema.locale)} ${t.schema.translate("more")}`:t._drawLabel(e,i)}return!1}),labelBounds:!!r&&((e,i,s)=>{const[n,a]=s.points[0],[o,r]=s.points[s.points.length-1],c=t.schema.height/4;return{x:o-n,y:r-a-c/2-(l[e.id]?r-l[e.id]:0),width:h,height:c}})}),d.push(...us(e,"Line",u));const f=Oi("Circle").renderMode("compute").data(t._lineMarkers?a:[]).config(e.shapeConfig).config(t._lineMarkerConfig).id(e=>`${e.id}_${e.discrete}`);return t._wirePlotShapeEvents(f,"Circle",e.events),f.render(),d.push(...Fi(f)),d}};
3208
+ */function zs(e,t,i){const{viz:s,events:n}=e;s._wirePlotShapeEvents(i,t,n);const a=Hi(s,t);return void 0===s.schema.shapeConfig.duration&&delete a.duration,i.config(a).render(),ji(i)}
3209
+ /** Generic path — every shape key without a dedicated emitter (incl. stacked Area). */const Ds=(e,t)=>zs(e,t,Fi(t).renderMode("compute").config(ws(e,t)).data(e.values)),Ms={Bar:e=>{const{viz:i,x:s,y:n,xScale:a,yScale:o,xDomain:r,yDomain:c,xRange:h,yRange:l,values:d}=e,u=Fi("Bar").renderMode("compute").config(ws(e,"Bar")).data(d);let m;const f="x"===i.schema.discrete?s:n,g="x"===i.schema.discrete?a:o,p="x"===i.schema.discrete?r:c,y="x"===i.schema.discrete?h:l;if("Point"!==g&&2===p.length){const e=Array.from(new Set(d.map(e=>f(e[i.schema.discrete]))));e.unshift(y[0]-e[0]-y[0]),e.push(y[1]+y[1]-e[e.length-1]),m=e.reduce((e,t,i,s)=>{if(i){const n=Math.abs(t-s[i-1]);n<e&&(e=n)}return e},1/0)}else m=p.length>1?f(p[1])-f(p[0]):y[y.length-1]-y[0];i._groupPadding<m&&(m-=i._groupPadding);let _=m||1;const x=t.groups(d,e=>e[i.schema.discrete],e=>e.group),b=t.merge(x.map(([,e])=>e.map(([e])=>e))),k=Array.from(new Set(b)),v=i.schema.discrete,C=e.shapeConfig[v];if(1===t.max(x.map(([,e])=>e.length)))u[v]((e,t)=>C(e,t));else{_=(_-i.schema.barPadding*k.length-1)/k.length;const e=m/2-_/2,t=B.scaleLinear().domain([0,k.length-1]).range([-e,e]);u[v]((e,i)=>C(e,i)+t(k.indexOf(e.group)))}return u.width(_),u.height(_),zs(e,"Bar",u)},Line:e=>{const{viz:t,x:i,y:s,values:a,width:o,showLineLabels:r,labelWidths:c,largestLabel:h,labelPositions:l}=e,d=[],u=Fi("Line").renderMode("compute").config(ws(e,"Line")).data(a);if(u.duration(1.5*o),t._confidence){const o=t._confidence,r=Object.assign({},e.shapeConfig),c=t.schema.discrete||"x",h="x"===c?"y":"x",l="x"===c?s:i;r[`${h}0`]=e=>l(o[0]?e.lci:e[h]),r[`${h}1`]=e=>l(o[1]?e.hci:e[h]);const u=Fi("Area").renderMode("compute").config(r).data(a),m=Object.assign({},t.schema.shapeConfig,t._confidenceConfig);
3210
+ // Fresh object — must NOT mutate the shared `shapeConfig`, or the confidence
3211
+ // fill/fillOpacity leak onto every other shape and every later render.
3212
+ u.config(n.assign(Hi(t,"Line",m),Hi(t,"Area",m))).render(),d.push(...ji(u))}u.config({discrete:e.shapeConfig.discrete||"x",label:!!r&&((e,i)=>{if(!("function"!=typeof t.schema.lineLabels||t.schema.lineLabels(e.data,e.i)))return!1;const s=c.find(t=>t.id===e.id);if(s){const n=s.newY||s.defaultY,a=c.filter(e=>e.newY===n);return a.length>1?a[0].id===e.id&&`+${m.formatAbbreviate(a.length,t.schema.locale)} ${t.schema.translate("more")}`:t._drawLabel(e,i)}return!1}),labelBounds:!!r&&((e,i,s)=>{const[n,a]=s.points[0],[o,r]=s.points[s.points.length-1],c=t.schema.height/4;return{x:o-n,y:r-a-c/2-(l[e.id]?r-l[e.id]:0),width:h,height:c}})}),d.push(...zs(e,"Line",u));const f=Fi("Circle").renderMode("compute").data(t._lineMarkers?a:[]).config(e.shapeConfig).config(t._lineMarkerConfig).id(e=>`${e.id}_${e.discrete}`);return t._wirePlotShapeEvents(f,"Circle",e.events),f.render(),d.push(...ji(f)),d}};
3083
3213
  /** Bar — discrete-axis spacing + multi-series grouping offsets. */
3084
- /** Dispatch a shape group to its emitter (falling back to the generic path). */function gs(e,t){return(fs[t]??ms)(e,t)}
3214
+ /** Dispatch a shape group to its emitter (falling back to the generic path). */function As(e,t){return(Ms[t]??Ds)(e,t)}
3085
3215
  /**
3086
3216
  Emits the background Rect into `out` (prepended) when a non-transparent
3087
3217
  `backgroundConfig.fill` is set; no-op otherwise.
@@ -3097,7 +3227,7 @@ if("Circle"===t&&i._size){const e=i._size;l.sort=(t,i)=>(Number(e(i))||0)-(Numbe
3097
3227
  match old→new by id frame-to-frame and TWEEN instead of exit/entering. The
3098
3228
  subtree is marked inert (annotations never show tooltips).
3099
3229
  */
3100
- function ps(e,t){const i=[];try{const t=e.toScene();t&&Array.isArray(t.children)&&t.children.length&&i.push(t);const s=e._labelClass;if(s&&"function"==typeof s.toScene){const e=s.toScene();e&&Array.isArray(e.children)&&e.children.length&&i.push(e)}}catch{return null}if(!i.length)return null;const s={type:"group",key:t,children:i};
3230
+ function $s(e,t){const i=[];try{const t=e.toScene();t&&Array.isArray(t.children)&&t.children.length&&i.push(t);const s=e._labelClass;if(s&&"function"==typeof s.toScene){const e=s.toScene();e&&Array.isArray(e.children)&&e.children.length&&i.push(e)}}catch{return null}if(!i.length)return null;const s={type:"group",key:t,children:i};
3101
3231
  /**
3102
3232
  Annotations are decorative chrome, not data marks. Stamp their scene nodes
3103
3233
  `interactive: false` so the renderer's hit-test skips them: they fire no
@@ -3108,13 +3238,13 @@ return function(e){const t=e=>{e.interactive=!1;const i=e.children;if(i)for(cons
3108
3238
  /**
3109
3239
  Renders back/front annotations, pushing back-layer scenes onto `out` and
3110
3240
  returning the front-layer shape instances for later absorption.
3111
- */function ys(e,t,i,s,n,a){
3241
+ */function Bs(e,t,i,s,n,a){
3112
3242
  // Annotations run in `renderMode("compute")` and their scenes are
3113
3243
  // absorbed into `_chartScene`. Layering: "back" annotations absorb here
3114
3244
  // (before the main shape loop below); "front" annotations queue and
3115
3245
  // absorb AFTER the shape loop, giving back → shapes → front.
3116
- const o=[];return Object.keys(e._previousAnnotations).forEach(r=>{const c=e._annotations.filter(e=>"back"===r&&!e.layer||e.layer===r),h=c.map(e=>e.shape);c.forEach((c,h)=>{const l=(t=>{const o=Oi(t.shape).renderMode("compute").duration(e.schema.duration).config(t).config({x:e=>e.x2?i(e.x2,"x2"):i(e.x),x0:"x"===e.schema.discrete?e=>e.x2?i(e.x2,"x2"):i(e.x):i(n.x[0]),x1:"x"===e.schema.discrete?null:e=>e.x2?i(e.x2,"x2"):i(e.x),y:e=>e.y2?s(e.y2,"y2"):s(e.y),y0:"y"===e.schema.discrete?e=>e.y2?s(e.y2,"y2"):s(e.y):s(n.y[1])-a,y1:"y"===e.schema.discrete?null:e=>e.y2?s(e.y2,"y2"):s(e.y)-a});return o.render(),o})(c);if("front"===r)o.push(l);else{const e=ps(l,`annotation-${r}-${h}`);e&&t.push(e)}});e._previousAnnotations[r].filter(e=>!h.includes(e)).forEach(e=>{Oi(e).renderMode("compute").data([]).render()}),e._previousAnnotations[r]=h}),o}
3117
- /** Builds the per-shape `shapeConfig` object shared across the shape loop. */const _s=e=>"string"==typeof e.key&&e.key.startsWith("grid-"),xs=e=>{e.interactionGroup="axis";const t=e.children;if(t)for(const e of t)xs(e)};
3246
+ const o=[];return Object.keys(e._previousAnnotations).forEach(r=>{const c=e._annotations.filter(e=>"back"===r&&!e.layer||e.layer===r),h=c.map(e=>e.shape);c.forEach((c,h)=>{const l=(t=>{const o=Fi(t.shape).renderMode("compute").duration(e.schema.duration).config(t).config({x:e=>e.x2?i(e.x2,"x2"):i(e.x),x0:"x"===e.schema.discrete?e=>e.x2?i(e.x2,"x2"):i(e.x):i(n.x[0]),x1:"x"===e.schema.discrete?null:e=>e.x2?i(e.x2,"x2"):i(e.x),y:e=>e.y2?s(e.y2,"y2"):s(e.y),y0:"y"===e.schema.discrete?e=>e.y2?s(e.y2,"y2"):s(e.y):s(n.y[1])-a,y1:"y"===e.schema.discrete?null:e=>e.y2?s(e.y2,"y2"):s(e.y)-a});return o.render(),o})(c);if("front"===r)o.push(l);else{const e=$s(l,`annotation-${r}-${h}`);e&&t.push(e)}});e._previousAnnotations[r].filter(e=>!h.includes(e)).forEach(e=>{Fi(e).renderMode("compute").data([]).render()}),e._previousAnnotations[r]=h}),o}
3247
+ /** Builds the per-shape `shapeConfig` object shared across the shape loop. */const Ps=e=>"string"==typeof e.key&&e.key.startsWith("grid-"),Ts=e=>{e.interactionGroup="axis";const t=e.children;if(t)for(const e of t)Ts(e)};
3118
3248
  /**
3119
3249
  Stamps `interactionGroup: "axis"` onto an axis scene subtree so the pointer
3120
3250
  bridge can skip shape tooltips on axis ticks, and so the hover/active
@@ -3128,7 +3258,7 @@ const o=[];return Object.keys(e._previousAnnotations).forEach(r=>{const c=e._ann
3128
3258
  Returns the flat `SceneNode[]` array that the caller (`Plot._paint`)
3129
3259
  merges into `_chartScene`.
3130
3260
  */
3131
- function bs(e,t,i){const s=[],{shapeData:a,domains:o}=t,{labelWidths:r}=t,{x:c,y:h,xRange:l,yRange:d,yOffset:u,axisSceneQueue:m}=i,f=
3261
+ function Os(e,t,i){const s=[],{shapeData:a,domains:o}=t,{labelWidths:r}=t,{x:c,y:h,xRange:l,yRange:d,yOffset:u,axisSceneQueue:m}=i,f=
3132
3262
  /**
3133
3263
  Drains the deferred axis-scene queue, splitting each axis into its
3134
3264
  gridline children (rendered behind the data shapes) and everything else
@@ -3137,7 +3267,7 @@ function bs(e,t,i){const s=[],{shapeData:a,domains:o}=t,{labelWidths:r}=t,{x:c,y
3137
3267
  group's `_chartTransform` composes with this to land at the right
3138
3268
  absolute position.
3139
3269
  */
3140
- function(e){const t=[],i=[];return e.forEach(({key:e,transform:s,axis:n})=>{if(!n||"function"!=typeof n.toScene)return;const a=n.toScene();if(!a)return;const o=a.children||[],r=o.filter(_s),c=o.filter(e=>!_s(e));if(r.length){const i={type:"group",key:`${e}-grid`,transform:s,children:r};xs(i),t.push(i)}if(c.length){const t={type:"group",key:e,transform:s,children:c};xs(t),i.push(t)}}),{grid:t,rest:i}}(m);!function(e,t,i,s){
3270
+ function(e){const t=[],i=[];return e.forEach(({key:e,transform:s,axis:n})=>{if(!n||"function"!=typeof n.toScene)return;const a=n.toScene();if(!a)return;const o=a.children||[],r=o.filter(Ps),c=o.filter(e=>!Ps(e));if(r.length){const i={type:"group",key:`${e}-grid`,transform:s,children:r};Ts(i),t.push(i)}if(c.length){const t={type:"group",key:e,transform:s,children:c};Ts(t),i.push(t)}}),{grid:t,rest:i}}(m);!function(e,t,i,s){
3141
3271
  // Background Rect: skip rendering when transparent (the default) — under
3142
3272
  // the scene path it would emit a 5th `rect.d3plus-render-rect` that
3143
3273
  // confuses bar-counting tests. When a user customizes
@@ -3147,7 +3277,7 @@ const n=e._backgroundConfig;if(n&&n.fill&&"transparent"!==n.fill){
3147
3277
  // x2Height + topOffset), so we subtract the chart-transform offset.
3148
3278
  // yRange[0] = x2Height, so the y simplification is
3149
3279
  // (yRange[1] - yRange[0]) / 2.
3150
- const a=Oi("Rect").renderMode("compute").data([{}]).x(i[0]-e._margin.left+(i[1]-i[0])/2).width(i[1]-i[0]).y((s[1]-s[0])/2).height(s[1]-s[0]).config(n);a.render();
3280
+ const a=Fi("Rect").renderMode("compute").data([{}]).x(i[0]-e._margin.left+(i[1]-i[0])/2).width(i[1]-i[0]).y((s[1]-s[0])/2).height(s[1]-s[0]).config(n);a.render();
3151
3281
  // Background must sit BEHIND chart shapes. Unshift onto `out` so
3152
3282
  // the z-order survives even if a future emit step pushes nodes
3153
3283
  // before this point (i.e. the invariant is enforced at the call
@@ -3155,19 +3285,19 @@ const a=Oi("Rect").renderMode("compute").data([{}]).x(i[0]-e._margin.left+(i[1]-
3155
3285
  // empty here). `unshift(...nodes)` is O(out.length + nodes.length)
3156
3286
  // which is fine — `out` carries axis-queue items, not the full
3157
3287
  // shape scene, so the prepend is a few entries at most.
3158
- const o=Fi(a);t.unshift(...o)}}(e,s,l,d),
3288
+ const o=ji(a);t.unshift(...o)}}(e,s,l,d),
3159
3289
  // Gridlines sit just above the background, behind the data shapes.
3160
- s.push(...f.grid),s.push(...function(e,t){const i=t.filter(e=>void 0!==e.newY);if(!i.length)return[];const s=i.map(t=>n.assign({x:e._xAxis._getPosition.bind(e._xAxis)(t.xValue),y:t.defaultY},t)).concat(i.map(t=>n.assign({x:e._xAxis._getPosition.bind(e._xAxis)(t.xValue)+t.padding-1,y:t.newY||t.defaultY},t))),a=Oi("Line").config({data:s,stroke:e=>e.fontColor,x:e=>e.x,y:e=>e.y}).config(e._labelConnectorConfig).renderMode("compute");return a.render(),Fi(a)}(e,r));const g=ys(e,s,c,h,o,u),p=function(e,t,i,s,n){const a=e.schema.discrete||"x";return{discrete:e.schema.discrete,duration:e.schema.duration,label:t=>e._drawLabel(t.data,t.i),x:e=>void 0!==e.x2?t(e.x2,"x2"):t(e.x),x0:"x"===a?e=>e.x2?t(e.x2,"x2"):t(e.x):t("number"==typeof e.schema.baseline?e.schema.baseline:s.x[0]),x1:"x"===a?null:e=>e.x2?t(e.x2,"x2"):t(e.x),y:e=>void 0!==e.y2?i(e.y2,"y2"):i(e.y),y0:"y"===a?e=>e.y2?i(e.y2,"y2"):i(e.y):i("number"==typeof e.schema.baseline?e.schema.baseline:s.y[1])-n,y1:"y"===a?null:e=>e.y2?i(e.y2,"y2"):i(e.y)-n}}
3161
- /** Runs the main shape loop, pushing each shape's scene nodes onto `out`. */(e,c,h,o,u);return function(e,t,i,s,n){const{shapeData:a,domains:o,discreteKeys:r,stackData:c,stackKeys:h,xDomain:l,yDomain:d}=i,{xScale:u,yScale:m}=i,{labelWidths:f,largestLabel:g}=i,{width:p}=i,{opp:y,showLineLabels:_}=i,{x:x,y:b,xRange:k,yRange:v,labelPositions:C}=s,S=Object.keys(e.schema.on),w=new Map;for(let e=0;e<h.length;e++)w.set(h[e],e);const z=new Map;for(let e=0;e<r.length;e++)z.set(r[e],e);const D={viz:e,shapeConfig:n,events:S,x:x,y:b,xScale:u,yScale:m,xDomain:l,yDomain:d,xRange:k,yRange:v,opp:y,domains:o,stackData:c,stackKeyIndex:w,discreteKeyIndex:z,showLineLabels:_,labelWidths:f,largestLabel:g,labelPositions:C,width:p,values:[]};a.forEach(([e,i])=>{t.push(...gs({...D,values:i},e))})}
3290
+ s.push(...f.grid),s.push(...function(e,t){const i=t.filter(e=>void 0!==e.newY);if(!i.length)return[];const s=i.map(t=>n.assign({x:e._xAxis._getPosition.bind(e._xAxis)(t.xValue),y:t.defaultY},t)).concat(i.map(t=>n.assign({x:e._xAxis._getPosition.bind(e._xAxis)(t.xValue)+t.padding-1,y:t.newY||t.defaultY},t))),a=Fi("Line").config({data:s,stroke:e=>e.fontColor,x:e=>e.x,y:e=>e.y}).config(e._labelConnectorConfig).renderMode("compute");return a.render(),ji(a)}(e,r));const g=Bs(e,s,c,h,o,u),p=function(e,t,i,s,n){const a=e.schema.discrete||"x";return{discrete:e.schema.discrete,duration:e.schema.duration,label:t=>e._drawLabel(t.data,t.i),x:e=>void 0!==e.x2?t(e.x2,"x2"):t(e.x),x0:"x"===a?e=>e.x2?t(e.x2,"x2"):t(e.x):t("number"==typeof e.schema.baseline?e.schema.baseline:s.x[0]),x1:"x"===a?null:e=>e.x2?t(e.x2,"x2"):t(e.x),y:e=>void 0!==e.y2?i(e.y2,"y2"):i(e.y),y0:"y"===a?e=>e.y2?i(e.y2,"y2"):i(e.y):i("number"==typeof e.schema.baseline?e.schema.baseline:s.y[1])-n,y1:"y"===a?null:e=>e.y2?i(e.y2,"y2"):i(e.y)-n}}
3291
+ /** Runs the main shape loop, pushing each shape's scene nodes onto `out`. */(e,c,h,o,u);return function(e,t,i,s,n){const{shapeData:a,domains:o,discreteKeys:r,stackData:c,stackKeys:h,xDomain:l,yDomain:d}=i,{xScale:u,yScale:m}=i,{labelWidths:f,largestLabel:g}=i,{width:p}=i,{opp:y,showLineLabels:_}=i,{x:x,y:b,xRange:k,yRange:v,labelPositions:C}=s,S=Object.keys(e.schema.on),w=new Map;for(let e=0;e<h.length;e++)w.set(h[e],e);const z=new Map;for(let e=0;e<r.length;e++)z.set(r[e],e);const D={viz:e,shapeConfig:n,events:S,x:x,y:b,xScale:u,yScale:m,xDomain:l,yDomain:d,xRange:k,yRange:v,opp:y,domains:o,stackData:c,stackKeyIndex:w,discreteKeyIndex:z,showLineLabels:_,labelWidths:f,largestLabel:g,labelPositions:C,width:p,values:[]};a.forEach(([e,i])=>{t.push(...As({...D,values:i},e))})}
3162
3292
  /** Runs shape exits in compute mode and updates `viz._previousShapes`. */(e,s,t,i,p),function(e,t,i){const s=t.map(([e])=>e);s.includes("Line")&&(e._confidence&&s.push("Area"),e._lineMarkers&&s.push("Circle")),
3163
3293
  // Run exits in compute mode so Box/Whisker/Shape don't fall through
3164
3294
  // to their body-svg / body-div fallback when `_select` is unset.
3165
3295
  // Without `.renderMode("compute")` here, every exited shape would
3166
3296
  // leak a detached <svg> (Box) or <div> (Shape) into <body>.
3167
- e._previousShapes.filter(e=>!s.includes(e)).forEach(e=>{const t=Oi(e);"function"==typeof t.renderMode&&t.renderMode("compute"),"function"==typeof t.select&&t.select(null),t.config(i).data([]).render()}),e._previousShapes=s}(e,a,p),
3297
+ e._previousShapes.filter(e=>!s.includes(e)).forEach(e=>{const t=Fi(e);"function"==typeof t.renderMode&&t.renderMode("compute"),"function"==typeof t.select&&t.select(null),t.config(i).data([]).render()}),e._previousShapes=s}(e,a,p),
3168
3298
  // Absorb queued front annotations AFTER the shape loop so they render
3169
3299
  // above shapes.
3170
- g.forEach((e,t)=>{const i=ps(e,`annotation-front-${t}`);i&&s.push(i)}),
3300
+ g.forEach((e,t)=>{const i=$s(e,`annotation-front-${t}`);i&&s.push(i)}),
3171
3301
  // Ticks, tick labels, domain bar, and title render on top of the shapes.
3172
3302
  s.push(...f.rest),s}
3173
3303
  /**
@@ -3183,19 +3313,19 @@ s.push(...f.rest),s}
3183
3313
 
3184
3314
  @param viz The Plot instance (or any subclass: BarChart, LinePlot, …).
3185
3315
  @param pCtx Cross-phase locals produced by `Plot._draw`.
3186
- */function ks(e,t){return bs(e,t,Ui(e,t))}
3316
+ */function Rs(e,t){return Os(e,t,is(e,t))}
3187
3317
  /**
3188
3318
  @module barBuffer
3189
3319
  Adds a buffer to either side of the non-discrete axis.
3190
3320
 
3191
3321
 
3192
3322
  @param buffer @private
3193
- */const vs=e=>Math.pow(10,Math.ceil(Math.log10(Math.abs(e))))*Math.pow(-1,e<0?1:0);
3323
+ */const Ls=e=>Math.pow(10,Math.ceil(Math.log10(Math.abs(e))))*Math.pow(-1,e<0?1:0);
3194
3324
  /**
3195
3325
  @module numericBuffer
3196
3326
  @private
3197
3327
  */
3198
- function Cs(e,t,i,s,n,a,o,r){if(void 0===i||isNaN(a[0])||isNaN(a[1]))return a;if(r&&(a=a.slice().reverse(),n=n.slice().reverse()),a[0]===a[1]){if(a=a.slice(),"log"===t)(a=[(c=a[0],Math.pow(10,Math.floor(Math.log10(Math.abs(c))))*Math.pow(-1,c<0?1:0)),vs(a[0])])[1]<a[0]&&a.reverse();else{const e=Math.abs(parseFloat(a[0].toPrecision(1).replace(/[0-9]{1}$/,"1")));a[0]-=e,a[1]+=e}return e.domain(r?a.slice().reverse():a),r?a.reverse():a}var c;const h=a[0]===a[1]?10:Math.abs(Math.log(a[1]-a[0])/100),d=()=>{let n=e.copy(),a=!1;if("log"===t){let t=e.domain().slice(),i=e.range().slice();if(r&&(t=t.reverse(),i=i.reverse()),a=t[0]*t[1]<0,a){const e=l.scaleLog().domain([1e-6,Math.abs(t[o])]).range([0,1])(Math.abs(t[o?0:1])),s=e/(e+1)*(i[1]-i[0]);t=(0===o?[t[0],1e-6]:[1e-6,t[1]]).map(Math.abs),i=0===o?[i[0],i[0]+s]:[i[0]+s,i[1]]}n=l.scaleLog().domain(t).range(i)}let c=!1;const h=n.range();let d;return d=n("log"===t&&a?Math.abs(i):i),r?0===o?c=d+s>h[o]:1===o&&(c=d-s<h[o]):0===o?c=d-s<h[o]:1===o&&(c=d+s>h[o]),c};if(e.invert&&d()){const n=10;if("log"===t){let t=0;for(;t<10&&d();){const i=(0===o?-1:1)*(a[o]<0?-1:1);a[o]+=a[o]*h*i,e.domain(r?a.slice().reverse():a),t++}}else if(0===o){const t=e.invert(e(i)+(s+n)*(r?1:-1));t<a[o]&&(a[o]=t,e.domain(r?a.slice().reverse():a))}else if(1===o){const t=e.invert(e(i)+(s+n)*(r?-1:1));t>a[o]&&(a[o]=t,e.domain(r?a.slice().reverse():a))}}return r?a.reverse():a}
3328
+ function Es(e,t,i,s,n,a,o,r){if(void 0===i||isNaN(a[0])||isNaN(a[1]))return a;if(r&&(a=a.slice().reverse(),n=n.slice().reverse()),a[0]===a[1]){if(a=a.slice(),"log"===t)(a=[(c=a[0],Math.pow(10,Math.floor(Math.log10(Math.abs(c))))*Math.pow(-1,c<0?1:0)),Ls(a[0])])[1]<a[0]&&a.reverse();else{const e=Math.abs(parseFloat(a[0].toPrecision(1).replace(/[0-9]{1}$/,"1")));a[0]-=e,a[1]+=e}return e.domain(r?a.slice().reverse():a),r?a.reverse():a}var c;const h=a[0]===a[1]?10:Math.abs(Math.log(a[1]-a[0])/100),d=()=>{let n=e.copy(),a=!1;if("log"===t){let t=e.domain().slice(),i=e.range().slice();if(r&&(t=t.reverse(),i=i.reverse()),a=t[0]*t[1]<0,a){const e=l.scaleLog().domain([1e-6,Math.abs(t[o])]).range([0,1])(Math.abs(t[o?0:1])),s=e/(e+1)*(i[1]-i[0]);t=(0===o?[t[0],1e-6]:[1e-6,t[1]]).map(Math.abs),i=0===o?[i[0],i[0]+s]:[i[0]+s,i[1]]}n=l.scaleLog().domain(t).range(i)}let c=!1;const h=n.range();let d;return d=n("log"===t&&a?Math.abs(i):i),r?0===o?c=d+s>h[o]:1===o&&(c=d-s<h[o]):0===o?c=d-s<h[o]:1===o&&(c=d+s>h[o]),c};if(e.invert&&d()){const n=10;if("log"===t){let t=0;for(;t<10&&d();){const i=(0===o?-1:1)*(a[o]<0?-1:1);a[o]+=a[o]*h*i,e.domain(r?a.slice().reverse():a),t++}}else if(0===o){const t=e.invert(e(i)+(s+n)*(r?1:-1));t<a[o]&&(a[o]=t,e.domain(r?a.slice().reverse():a))}else if(1===o){const t=e.invert(e(i)+(s+n)*(r?-1:1));t>a[o]&&(a[o]=t,e.domain(r?a.slice().reverse():a))}}return r?a.reverse():a}
3199
3329
  /**
3200
3330
  @module circleBuffer
3201
3331
  Adds a buffer to either side of the non-discrete axis.
@@ -3203,14 +3333,16 @@ function Cs(e,t,i,s,n,a,o,r){if(void 0===i||isNaN(a[0])||isNaN(a[1]))return a;if
3203
3333
 
3204
3334
  @param buffer Defaults to the radius of the largest Circle.
3205
3335
  @private
3206
- */const{theme:Ss}=f,ws=[{key:"barPadding",coerce:"identity"},{key:"baseline",coerce:"identity"},{key:"lineLabels",coerce:"identity"},{key:"shapeSort",coerce:"identity"},{key:"sizeMax",coerce:"identity"},{key:"sizeMin",coerce:"identity"},{key:"sizeScale",coerce:"identity"},{key:"stacked",coerce:"identity"},{key:"xCutoff",coerce:"identity"},{key:"xDomain",coerce:"identity"},{key:"x2Domain",coerce:"identity"},{key:"xSort",coerce:"identity"},{key:"x2Sort",coerce:"identity"},{key:"yCutoff",coerce:"identity"},{key:"yDomain",coerce:"identity"},{key:"y2Domain",coerce:"identity"},{key:"ySort",coerce:"identity"},{key:"y2Sort",coerce:"identity"}],zs={Bar:function({data:e,x:i,y:s,x2:n,y2:a,buffer:o=10}){const r=n?"x2":"x",c=a?"y2":"y",h="x"===this.schema.discrete?s:i,l=h.domain().slice(),d="x"===this.schema.discrete;let u,m;if(d&&l.reverse(),this.schema.stacked){const i=t.groups(e,e=>`${e[this.schema.discrete]}_${e.group}`).map(([,e])=>e.map(e=>e[d?c:r]));m=i.map(e=>t.sum(e.filter(e=>e>0))),u=i.map(e=>t.sum(e.filter(e=>e<0)))}else{const t=e.map(e=>e[d?c:r]);m=t.filter(e=>e>0),u=t.filter(e=>e<0)}let f=h(t.max(m));(d?f<h(0):f>h(0))&&(f+=d?-o:o),f=h.invert(f);let g=h(t.min(u));return(d?g>h(0):g<h(0))&&(g+=d?o:-o),g=h.invert(g),f>l[1]&&(l[1]=f),g<l[0]&&(l[0]=g),d&&l.reverse(),h.domain(l),[i,s]}
3336
+ */
3337
+ /* eslint no-cond-assign: 0*/ // @ts-ignore
3338
+ const{theme:Fs}=f,Ws=[{key:"barPadding",coerce:"identity"},{key:"baseline",coerce:"identity"},{key:"lineLabels",coerce:"identity"},{key:"shapeSort",coerce:"identity"},{key:"sizeMax",coerce:"identity"},{key:"sizeMin",coerce:"identity"},{key:"sizeScale",coerce:"identity"},{key:"stacked",coerce:"identity"},{key:"xCutoff",coerce:"identity"},{key:"xDomain",coerce:"identity"},{key:"x2Domain",coerce:"identity"},{key:"xSort",coerce:"identity"},{key:"x2Sort",coerce:"identity"},{key:"yCutoff",coerce:"identity"},{key:"yDomain",coerce:"identity"},{key:"y2Domain",coerce:"identity"},{key:"ySort",coerce:"identity"},{key:"y2Sort",coerce:"identity"}],Ns={Bar:function({data:e,x:i,y:s,x2:n,y2:a,buffer:o=10}){const r=n?"x2":"x",c=a?"y2":"y",h="x"===this.schema.discrete?s:i,l=h.domain().slice(),d="x"===this.schema.discrete;let u,m;if(d&&l.reverse(),this.schema.stacked){const i=t.groups(e,e=>`${e[this.schema.discrete]}_${e.group}`).map(([,e])=>e.map(e=>e[d?c:r]));m=i.map(e=>t.sum(e.filter(e=>e>0))),u=i.map(e=>t.sum(e.filter(e=>e<0)))}else{const t=e.map(e=>e[d?c:r]);m=t.filter(e=>e>0),u=t.filter(e=>e<0)}let f=h(t.max(m));(d?f<h(0):f>h(0))&&(f+=d?-o:o),f=h.invert(f);let g=h(t.min(u));return(d?g>h(0):g<h(0))&&(g+=d?o:-o),g=h.invert(g),f>l[1]&&(l[1]=f),g<l[0]&&(l[0]=g),d&&l.reverse(),h.domain(l),[i,s]}
3207
3339
  /**
3208
3340
  @module boxBuffer
3209
3341
  Adds a buffer to either side of the non-discrete axis.
3210
3342
 
3211
3343
 
3212
3344
  @param buffer @private
3213
- */,Box:function({data:e,x:i,y:s,x2:n,y2:a,buffer:o=10}){const r=n?"x2":"x",c=a?"y2":"y",h="x"===this.schema.discrete?s:i,l=h.domain().slice(),d="x"===this.schema.discrete;let u,m;if(d&&l.reverse(),this.schema.stacked){const i=t.groups(e,e=>e[this.schema.discrete]).map(([,e])=>e.map(e=>e[d?c:r]));m=i.map(e=>t.sum(e.filter(e=>e>0))),u=i.map(e=>t.sum(e.filter(e=>e<0)))}else m=e.map(e=>e[d?c:r]),u=m;let f=h(t.max(m));f+=d?-o:o,f=h.invert(f);let g=h(t.min(u));return g+=d?o:-o,g=h.invert(g),f>l[1]&&(l[1]=f),g<l[0]&&(l[0]=g),d&&l.reverse(),h.domain(l),[i,s]},Circle:function({data:e,x:t,y:i,x2:s,y2:n,yScale:a,xScale:o,config:r,buffer:c}){t=t.copy(),i=i.copy();const h=s?"x2":"x",l=n?"y2":"y";let d=t.domain().slice(),u=i.domain().slice();const m=t.range(),f=i.range();return!t.invert&&t.padding&&Pi(t,e,this.schema.discrete),!i.invert&&i.padding&&Pi(i,e,this.schema.discrete),(t.invert||i.invert)&&e.forEach(e=>{const s=c||2*(r?.r)(e.data,e.i);t.invert&&(d=Cs(t,o??"linear",e[h],s,m,d,0,!1),d=Cs(t,o??"linear",e[h],s,m,d,1,!1)),i.invert&&(u=Cs(i,a??"linear",e[l],s,f,u,0,!0),u=Cs(i,a??"linear",e[l],s,f,u,1,!0))}),[t,i]}
3345
+ */,Box:function({data:e,x:i,y:s,x2:n,y2:a,buffer:o=10}){const r=n?"x2":"x",c=a?"y2":"y",h="x"===this.schema.discrete?s:i,l=h.domain().slice(),d="x"===this.schema.discrete;let u,m;if(d&&l.reverse(),this.schema.stacked){const i=t.groups(e,e=>e[this.schema.discrete]).map(([,e])=>e.map(e=>e[d?c:r]));m=i.map(e=>t.sum(e.filter(e=>e>0))),u=i.map(e=>t.sum(e.filter(e=>e<0)))}else m=e.map(e=>e[d?c:r]),u=m;let f=h(t.max(m));f+=d?-o:o,f=h.invert(f);let g=h(t.min(u));return g+=d?o:-o,g=h.invert(g),f>l[1]&&(l[1]=f),g<l[0]&&(l[0]=g),d&&l.reverse(),h.domain(l),[i,s]},Circle:function({data:e,x:t,y:i,x2:s,y2:n,yScale:a,xScale:o,config:r,buffer:c}){t=t.copy(),i=i.copy();const h=s?"x2":"x",l=n?"y2":"y";let d=t.domain().slice(),u=i.domain().slice();const m=t.range(),f=i.range();return!t.invert&&t.padding&&Li(t,e,this.schema.discrete),!i.invert&&i.padding&&Li(i,e,this.schema.discrete),(t.invert||i.invert)&&e.forEach(e=>{const s=c||2*(r?.r)(e.data,e.i);t.invert&&(d=Es(t,o??"linear",e[h],s,m,d,0,!1),d=Es(t,o??"linear",e[h],s,m,d,1,!1)),i.invert&&(u=Es(i,a??"linear",e[l],s,f,u,0,!0),u=Es(i,a??"linear",e[l],s,f,u,1,!0))}),[t,i]}
3214
3346
  /**
3215
3347
  @module lineBuffer
3216
3348
  Adds a buffer to either side of the non-discrete axis.
@@ -3226,12 +3358,12 @@ function Cs(e,t,i,s,n,a,o,r){if(void 0===i||isNaN(a[0])||isNaN(a[1]))return a;if
3226
3358
 
3227
3359
  @param buffer Defaults to the width/height of the largest Rect.
3228
3360
  @private
3229
- */,Rect:function({data:e,x:t,y:i,x2:s,y2:n,yScale:a,xScale:o,config:r}){t=t.copy(),i=i.copy();const c=s?"x2":"x",h=n?"y2":"y";let l=t.domain().slice(),d=i.domain().slice();const u=t.range(),m=i.range();return!t.invert&&t.padding&&Pi(t,e,this.schema.discrete),!i.invert&&i.padding&&Pi(i,e,this.schema.discrete),(t.invert||i.invert)&&e.forEach(e=>{if(t.invert){const i=(r?.width)(e.data,e.i);l=Cs(t,o??"linear",e[c],i,u,l,0,!1),l=Cs(t,o??"linear",e[c],i,u,l,1,!1)}if(i.invert){const t=(r?.height)(e.data,e.i);d=Cs(i,a??"linear",e[h],t,m,d,0,!0),d=Cs(i,a??"linear",e[h],t,m,d,1,!0)}}),[t,i]}};
3361
+ */,Rect:function({data:e,x:t,y:i,x2:s,y2:n,yScale:a,xScale:o,config:r}){t=t.copy(),i=i.copy();const c=s?"x2":"x",h=n?"y2":"y";let l=t.domain().slice(),d=i.domain().slice();const u=t.range(),m=i.range();return!t.invert&&t.padding&&Li(t,e,this.schema.discrete),!i.invert&&i.padding&&Li(i,e,this.schema.discrete),(t.invert||i.invert)&&e.forEach(e=>{if(t.invert){const i=(r?.width)(e.data,e.i);l=Es(t,o??"linear",e[c],i,u,l,0,!1),l=Es(t,o??"linear",e[c],i,u,l,1,!1)}if(i.invert){const t=(r?.height)(e.data,e.i);d=Es(i,a??"linear",e[h],t,m,d,0,!0),d=Es(i,a??"linear",e[h],t,m,d,1,!0)}}),[t,i]}};
3230
3362
  // E4: Plot's identity-coerce accessor schema (18 keys). installFluent's
3231
3363
  // per-key idempotence lets this co-exist with vizSchema on the parent
3232
3364
  // Viz.prototype — installFluent walks the actual prototype (Plot.prototype
3233
3365
  // here) and skips keys already present.
3234
- class Ds extends $i{
3366
+ class Hs extends Oi{
3235
3367
  /**
3236
3368
  Extends the preDraw behavior of the abstract Viz class.
3237
3369
  @private
@@ -3249,7 +3381,7 @@ t!==e&&this[`_${e}Title`]===this[`_${e}Config`].title&&this.schema.discrete!==e&
3249
3381
  Composes the chart's scene graph: the native shape scenes from Viz.toScene
3250
3382
  (bars/lines/areas + labels) plus snapshots of the rendered axes, so a Plot
3251
3383
  renders fully — geometry and axes — through the @d3plus/render backends.
3252
- */toScene(){const e=$i.prototype.toScene.call(this);
3384
+ */toScene(){const e=Oi.prototype.toScene.call(this);
3253
3385
  // Skip the axis walk when an explicit empty-data render just
3254
3386
  // happened. Axes are constructor-allocated and never reset between
3255
3387
  // renders, so a previous-render's axis._select.node() still exists
@@ -3280,10 +3412,25 @@ return e.root.children.unshift(...t),e}
3280
3412
  `.shape`, and shape-class-scoped (`.Bar`) handlers — the same three
3281
3413
  buckets this method wires, so SVG and Canvas behave identically.
3282
3414
  */_wirePlotShapeEvents(e,t,i){const s=i.filter(e=>e.includes(`.${t}`)),n=i.filter(e=>!e.includes(".")),a=i.filter(e=>e.includes(".shape")),o=e=>(t,i,s,n)=>this.schema.on[e](t.data,t.i,s,n);for(const t of n)e.on(t,o(t));for(const t of a)e.on(t,o(t));for(const t of s)e.on(t,o(t))}
3415
+ /**
3416
+ For a multi-point shape (Line/Area) reports the point nearest the cursor
3417
+ along the discrete axis, so every mouse event (tooltip, click, user
3418
+ handlers) reflects the hovered x rather than the whole-series aggregate.
3419
+ Non-nested shapes and legend swatches fall through to the base (aggregate)
3420
+ behavior.
3421
+ @private
3422
+ */_interactionDatum(e,t){const i=e.node,s=i&&i.interactionPoints;if(i&&"legend"!==i.interactionGroup&&Array.isArray(s)&&s.length&&t&&Array.isArray(t.point)){const e=this._nearestInteractionPoint(s,t.point);if(e){const t=e.datum;return{d:t&&t.data?t.data:t,i:"number"==typeof t.i?t.i:e.index,x:t}}}return super._interactionDatum(e,t)}
3423
+ /**
3424
+ Picks the interaction point closest to a surface-local cursor position
3425
+ along the discrete axis. `event.point` is post-zoom surface space while the
3426
+ points are in pre-zoom content space (they live under the `viz-zoom`
3427
+ group), so the cursor is un-zoomed by `_zoomTransform` before comparing.
3428
+ @private
3429
+ */_nearestInteractionPoint(e,t){const i=this._zoomTransform,s=i&&i.scale?i.scale:1,n=(t[0]-(i?i.x:0))/s,a=(t[1]-(i?i.y:0))/s,o="y"===this.schema.discrete?"y":"x",r="y"===o?a:n;let c=null,h=1/0;for(const t of e){const e=Math.abs(t[o]-r);e<h&&(h=e,c=t)}return c}
3283
3430
  /**
3284
3431
  Extends the draw behavior of the abstract Viz class.
3285
3432
  @private
3286
- */_draw(e){return es(this,e)}
3433
+ */_draw(e){return os(this,e)}
3287
3434
  /**
3288
3435
  Paint phase: production axis rendering, shape buffer setup, and shape
3289
3436
  emission with event handlers. Receives all cross-phase locals from
@@ -3295,7 +3442,7 @@ return e.root.children.unshift(...t),e}
3295
3442
  // function of its inputs. `super._draw` resets `_chartScene` to []
3296
3443
  // before the paint phase, so the emit output IS the scene. Viz.toScene
3297
3444
  // wraps the collection in viz-chart-cells + zoom transform.
3298
- return this._chartScene=ks(this,e),this}
3445
+ return this._chartScene=Rs(this,e),this}
3299
3446
  /**
3300
3447
  Allows drawing custom shapes to be used as annotations in the provided x/y plot. This method accepts custom config objects for the [Shape](http://d3plus.org/docs/#Shape) class, either a single config object or an array of config objects. Each config object requires an additional parameter, the "shape", which denotes which [Shape](http://d3plus.org/docs/#Shape) sub-class to use ([Rect](http://d3plus.org/docs/#Rect), [Line](http://d3plus.org/docs/#Line), etc).
3301
3448
 
@@ -3309,7 +3456,7 @@ return this._chartScene=ks(this,e),this}
3309
3456
  */backgroundConfig(e){return arguments.length?(this._backgroundConfig=n.assign(this._backgroundConfig,e),this):this._backgroundConfig}
3310
3457
  /**
3311
3458
  Determines whether or not to add additional padding at the ends of x or y scales. The most commone use for this is in Scatter Plots, so that the shapes do not appear directly on the axis itself. The value provided can either be `true` or `false` to toggle the behavior for all shape types, or a keyed Object for each shape type (ie. `{Bar: false, Circle: true, Line: false}`).
3312
- */buffer(e){if(arguments.length){if(e)if(!0===e)this._buffer=zs;else{this._buffer=n.assign({},this._buffer,e);for(const e in this._buffer){const t=this._buffer;!0===t[e]&&(t[e]=zs[e])}}else this._buffer={};return this}return this._buffer}
3459
+ */buffer(e){if(arguments.length){if(e)if(!0===e)this._buffer=Ns;else{this._buffer=n.assign({},this._buffer,e);for(const e in this._buffer){const t=this._buffer;!0===t[e]&&(t[e]=Ns[e])}}else this._buffer={};return this}return this._buffer}
3313
3460
  /**
3314
3461
  The confidence interval as an array of [lower, upper] bounds.
3315
3462
 
@@ -3347,11 +3494,40 @@ return this._chartScene=ks(this,e),this}
3347
3494
  Sets the size of bubbles to the given Number, data key, or function.
3348
3495
  */size(e){return arguments.length?(this._size="function"!=typeof e&&e?F(e):e,this):this._size}
3349
3496
  /**
3350
- Sets the stack offset. If *value* is not specified, returns the current stack offset function.
3351
- */stackOffset(e){return arguments.length?(this._stackOffset="function"==typeof e?e:P[`stackOffset${e.charAt(0).toUpperCase()+e.slice(1)}`],this):this._stackOffset}
3352
- /**
3353
- Sets the stack order. If *value* is not specified, returns the current stack order function.
3354
- */stackOrder(e){return arguments.length?(this._stackOrder="string"==typeof e?"ascending"===e?cs:"descending"===e?hs:P[`stackOrder${e.charAt(0).toUpperCase()+e.slice(1)}`]:e,this):this._stackOrder}
3497
+ Sets the vertical offset applied to stacked series. Accepts a named
3498
+ offset — `"diverging"` (default), `"none"`, `"expand"`, `"silhouette"`,
3499
+ or `"wiggle"` — or a custom offset function. Unknown names warn and fall
3500
+ back to `"diverging"`. If *value* is not specified, returns the current
3501
+ stack offset function.
3502
+ */stackOffset(e){return arguments.length?(this._stackOffset="function"==typeof(t=e)?t:"string"==typeof t&&t in Cs?Cs[t]:(console.warn(`[d3plus] Unknown stackOffset "${t}". Expected one of: ${Ss.join(", ")}; or an offset function. Falling back to "diverging".`),vs),this):this._stackOffset;
3503
+ /**
3504
+ Normalizes a `stackOffset` input into an offset function. Warns and falls
3505
+ back to the diverging default on an unrecognized name.
3506
+ */
3507
+ var t}
3508
+ /**
3509
+ Sets the order of stacked series, from the bottom of the stack upward.
3510
+ Accepts:
3511
+ - a named order: `"descending"` (default) / `"ascending"` by summed
3512
+ value, `"key"` / `"keyReverse"` alphabetically by series key,
3513
+ `"none"` / `"data"` for input order, or d3's `"insideOut"`,
3514
+ `"appearance"`, `"reverse"`;
3515
+ - an Array of series keys for an explicit order;
3516
+ - a value accessor, or a `{value, order}` config, to rank series by an
3517
+ aggregate of any data field.
3518
+
3519
+ Unknown named strings warn and fall back to `"descending"`. If *value*
3520
+ is not specified, returns the current stack order.
3521
+ */stackOrder(e){return arguments.length?(this._stackOrder=
3522
+ /**
3523
+ Normalizes any `stackOrder` input into a value Plot's pipeline can apply:
3524
+ a tagged comparator, or an explicit array of series keys. Warns and falls
3525
+ back to the default on an unrecognized name.
3526
+ */
3527
+ function(e){if("function"==typeof e)
3528
+ // Already-resolved order (constructor default / config() reset) passes
3529
+ // through; a bare user function is treated as a value accessor.
3530
+ return e.__d3plusStackOrder?e:xs(e);if(Array.isArray(e))return e;if(e&&"object"==typeof e){const{value:t,order:i}=e;return xs("function"==typeof t?t:F(t),i)}return"string"==typeof e?e in bs?bs[e]:(console.warn(`[d3plus] Unknown stackOrder "${e}". Expected one of: ${ks.join(", ")}; an array of series keys; a value accessor; or a {value, order} config. Falling back to "descending".`),ps):ps}(e),this):this._stackOrder}
3355
3531
  /**
3356
3532
  Accessor function or string key for the x-axis value of each data point.
3357
3533
  */x(e){return arguments.length?("function"==typeof e?this._x=e:(this._x=F(e),this._xKey=e),this):this._x}
@@ -3385,62 +3561,67 @@ return this._chartScene=ks(this,e),this}
3385
3561
  // E4: install identity-coerce accessors on Plot.prototype. Defaults
3386
3562
  // are still applied below imperatively from plotDef; installFluent
3387
3563
  // skips slots that are already set, so the constructor wins.
3388
- re(this,ws);
3564
+ re(this,Ws);
3389
3565
  // E3: scalar defaults sourced from plotDef.
3390
- const e=Xi.defaults;this._axisPersist=e.axisPersist,this._annotations=e.annotations,this._backgroundConfig={duration:0,fill:"transparent"},this.schema.barPadding=e.barPadding,this._buffer=n.assign({},zs,{Bar:!1,Line:!1}),this._confidenceConfig={fill:(e,t)=>"function"==typeof this.schema.shapeConfig.Line.stroke?this.schema.shapeConfig.Line.stroke(e,t):this.schema.shapeConfig.Line.stroke,fillOpacity:L(.5)},this._discreteCutoff=e.discreteCutoff,this._groupPadding=e.groupPadding,this._labelConnectorConfig={strokeDasharray:"1 1"},this._labelPosition=L("auto"),this._lineMarkerConfig={fill:(e,t)=>u.colorAssign(this._id(e,t)),r:L(3)},this._lineMarkers=e.lineMarkers,this._previousAnnotations={back:[],front:[]},this._previousShapes=[],this.schema.shape=e.shape,this.schema.shapeConfig=n.assign(this.schema.shapeConfig,os.call(this)),this._shapeOrder=["Area","Path","Bar","Box","Line","Rect","Circle"],this.schema.shapeSort=(e,t)=>this._shapeOrder.indexOf(e)-this._shapeOrder.indexOf(t),this.schema.sizeMax=20,this.schema.sizeMin=5,this.schema.sizeScale="sqrt",this._stackOffset=ls,this._stackOrder=hs,this.schema.timelineConfig=n.assign(this.schema.timelineConfig,{brushMin:()=>this._xTime||this._yTime||this._x2Time||this._y2Time?2:1}),this._x=F("x"),this._xKey="x",this._xAxis=(new bt).align("end"),
3566
+ const e=es.defaults;this._axisPersist=e.axisPersist,this._annotations=e.annotations,this._backgroundConfig={duration:0,fill:"transparent"},this.schema.barPadding=e.barPadding,this._buffer=n.assign({},Ns,{Bar:!1,Line:!1}),this._confidenceConfig={
3567
+ // A line's colour is its stroke, so the confidence band fills with that
3568
+ // same colour (at the reduced opacity below). Prefer a per-Line stroke
3569
+ // override, else the shared stroke accessor (the Line config itself sets
3570
+ // no `stroke` — the colour comes from the top-level `shapeConfig.stroke`).
3571
+ fill:(e,t)=>{const{Line:i,stroke:s}=this.schema.shapeConfig,n=i&&void 0!==i.stroke?i.stroke:s;return"function"==typeof n?n(e,t):n},fillOpacity:L(.5)},this._discreteCutoff=e.discreteCutoff,this._groupPadding=e.groupPadding,this._labelConnectorConfig={strokeDasharray:"1 1"},this._labelPosition=L("auto"),this._lineMarkerConfig={fill:(e,t)=>u.colorAssign(this._id(e,t)),r:L(3)},this._lineMarkers=e.lineMarkers,this._previousAnnotations={back:[],front:[]},this._previousShapes=[],this.schema.shape=e.shape,this.schema.shapeConfig=n.assign(this.schema.shapeConfig,us.call(this)),this._shapeOrder=["Area","Path","Bar","Box","Line","Rect","Circle"],this.schema.shapeSort=(e,t)=>this._shapeOrder.indexOf(e)-this._shapeOrder.indexOf(t),this.schema.sizeMax=20,this.schema.sizeMin=5,this.schema.sizeScale="sqrt",this._stackOffset=vs,this._stackOrder=ps,this.schema.timelineConfig=n.assign(this.schema.timelineConfig,{brushMin:()=>this._xTime||this._yTime||this._x2Time||this._y2Time?2:1}),this._x=F("x"),this._xKey="x",this._xAxis=(new St).align("end"),
3391
3572
  // _xTest/_yTest/_x2Test/_y2Test are NOT persistent fields anymore. The
3392
3573
  // measure-only test axes are allocated as locals inside `_draw` and
3393
3574
  // garbage-collected after each draw — proving Plot doesn't need to
3394
3575
  // own a long-lived Axis instance just for layout. See measureAxis()
3395
3576
  // in axisLayout.ts for the standalone shape.
3396
- this._xConfig={gridConfig:{stroke:e=>{if(this.schema.discrete&&"x"===this.schema.discrete.charAt(0))return"transparent";const t=this._xAxis.range(),i=this._xAxis._getPosition.bind(this._xAxis)(e.id);if(t[0]===i)return"transparent";const s=this._select?n.backgroundColor(this._select.node()):"rgb(255, 255, 255)";return u.colorContrast(s)===u.colorDefaults.dark?Ss.colors.gray[200]:Ss.colors.gray[600]}}},this.schema.xCutoff=150,this._x2=F("x2"),this._x2Key="x2",this._x2Axis=(new Ct).align("start"),this._x2Config={},this._y=F("y"),this._yKey="y",this._yAxis=(new kt).align("start"),this._yKey="y",this._yConfig={gridConfig:{stroke:e=>{if(this.schema.discrete&&"y"===this.schema.discrete.charAt(0))return"transparent";const t=this._yAxis.range(),i=this._yAxis._getPosition.bind(this._yAxis)(e.id);if(t[t.length-1]===i)return"transparent";const s=this._select?n.backgroundColor(this._select.node()):"rgb(255, 255, 255)";return u.colorContrast(s)===u.colorDefaults.dark?Ss.colors.gray[200]:Ss.colors.gray[600]}}},this.schema.yCutoff=150,this._y2=F("y2"),this._y2Key="y2",this._y2Axis=(new vt).align("end"),this._y2Config={}}}
3577
+ this._xConfig={gridConfig:{stroke:e=>{if(this.schema.discrete&&"x"===this.schema.discrete.charAt(0))return"transparent";const t=this._xAxis.range(),i=this._xAxis._getPosition.bind(this._xAxis)(e.id);if(t[0]===i)return"transparent";const s=this._select?n.backgroundColor(this._select.node()):"rgb(255, 255, 255)";return u.colorContrast(s)===u.colorDefaults.dark?Fs.colors.gray[200]:Fs.colors.gray[600]}}},this.schema.xCutoff=150,this._x2=F("x2"),this._x2Key="x2",this._x2Axis=(new Dt).align("start"),this._x2Config={},this._y=F("y"),this._yKey="y",this._yAxis=(new wt).align("start"),this._yKey="y",this._yConfig={gridConfig:{stroke:e=>{if(this.schema.discrete&&"y"===this.schema.discrete.charAt(0))return"transparent";const t=this._yAxis.range(),i=this._yAxis._getPosition.bind(this._yAxis)(e.id);if(t[t.length-1]===i)return"transparent";const s=this._select?n.backgroundColor(this._select.node()):"rgb(255, 255, 255)";return u.colorContrast(s)===u.colorDefaults.dark?Fs.colors.gray[200]:Fs.colors.gray[600]}}},this.schema.yCutoff=150,this._y2=F("y2"),this._y2Key="y2",this._y2Axis=(new zt).align("end"),this._y2Config={}}}
3397
3578
  /**
3398
3579
  Creates an area plot based on an array of data.
3399
3580
  */
3400
- var Ms=Bi({name:"AreaPlot",paintDriven:!0,features:[ee,Q,Z,ne],ctx:{},fields:[{key:"baseline",default:0},{key:"discrete",default:"x"},{key:"shape",default:L("Area")}]},Ds);
3581
+ var js=Ri({name:"AreaPlot",paintDriven:!0,features:[ee,Q,Z,ne],ctx:{},fields:[{key:"baseline",default:0},{key:"discrete",default:"x"},{key:"shape",default:L("Area"),coerce:"const"}]},Hs);
3401
3582
  /**
3402
3583
  Creates a bar chart based on an array of data.
3403
3584
  */
3404
- var As=Bi({name:"BarChart",paintDriven:!0,features:[ee,Q,Z,ne],ctx:{},fields:[{key:"baseline",default:0},{key:"discrete",default:"x"},{key:"shape",default:L("Bar")},{key:"legend",factory:e=>{const t=e.schema.legend;return(i,s)=>s.map(e.schema.groupBy[e._legendDepth].bind(e)).sort().join()!==e._filteredData.map(e.schema.groupBy[e._legendDepth].bind(e)).sort().join()&&t.call(e,i,s)}}]},Ds);
3585
+ var Gs=Ri({name:"BarChart",paintDriven:!0,features:[ee,Q,Z,ne],ctx:{},fields:[{key:"baseline",default:0},{key:"discrete",default:"x"},{key:"shape",default:L("Bar"),coerce:"const"},{key:"legend",coerce:"const",factory:e=>{const t=e.schema.legend;return(i,s)=>s.map(e.schema.groupBy[e._legendDepth].bind(e)).sort().join()!==e._filteredData.map(e.schema.groupBy[e._legendDepth].bind(e)).sort().join()&&t.call(e,i,s)}}]},Hs);
3405
3586
  /**
3406
3587
  Creates a simple box and whisker based on an array of data.
3407
3588
  */
3408
- var $s=Bi({name:"BoxWhisker",paintDriven:!0,features:[ee,Q,Z,ne],ctx:{},fields:[{key:"discrete",default:"x"},{key:"shape",default:L("Box")},{key:"tooltipConfig",merge:!0,factory:e=>({title:(t,i)=>{if(!t)return"";for(;t.__d3plus__&&t.data;)i=(t=t.data).i;const s=e.schema.label;if(s)return s(t,i);const n=e._ids(t,i).slice(0,e._drawDepth);return n[n.length-1]}})}]},Ds);const Bs={name:"BumpChart",paintDriven:!0,features:[ee,Q,Z,ne],setup:e=>{const t=e;t.y2((t,i)=>e._y(t,i)),t.yConfig({tickFormat:t=>{const i=e._formattedData??[],s=i[0].x instanceof Date?i[0].x.getTime():i[0].x,n=i.filter(e=>(e.x instanceof Date?e.x.getTime():e.x)===s),a=n.find(e=>e.y===t);return a?e._drawLabel(a,a.i):""}}),t.y2Config({tickFormat:t=>{const i=e._formattedData??[],s=i[i.length-1].x instanceof Date?i[i.length-1].x.getTime():i[i.length-1].x,n=i.filter(e=>(e.x instanceof Date?e.x.getTime():e.x)===s),a=n.find(e=>e.y===t);return a?e._drawLabel(a,a.i):""}}),t.ySort((t,i)=>e._y(i)-e._y(t)),t.y2Sort((t,i)=>e._y(i)-e._y(t))},ctx:{},fields:[{key:"discrete",default:"x"},{key:"shape",default:L("Line")}]};
3589
+ var Is=Ri({name:"BoxWhisker",paintDriven:!0,features:[ee,Q,Z,ne],ctx:{},fields:[{key:"discrete",default:"x"},{key:"shape",default:L("Box"),coerce:"const"},{key:"tooltipConfig",merge:!0,factory:e=>({title:(t,i)=>{if(!t)return"";for(;t.__d3plus__&&t.data;)i=(t=t.data).i;const s=e.schema.label;if(s)return s(t,i);const n=e._ids(t,i).slice(0,e._drawDepth);return n[n.length-1]}})}]},Hs);const qs={name:"BumpChart",paintDriven:!0,features:[ee,Q,Z,ne],setup:e=>{const t=e;t.y2((t,i)=>e._y(t,i)),t.yConfig({tickFormat:t=>{const i=e._formattedData??[],s=i[0].x instanceof Date?i[0].x.getTime():i[0].x,n=i.filter(e=>(e.x instanceof Date?e.x.getTime():e.x)===s),a=n.find(e=>e.y===t);return a?e._drawLabel(a,a.i):""}}),t.y2Config({tickFormat:t=>{const i=e._formattedData??[],s=i[i.length-1].x instanceof Date?i[i.length-1].x.getTime():i[i.length-1].x,n=i.filter(e=>(e.x instanceof Date?e.x.getTime():e.x)===s),a=n.find(e=>e.y===t);return a?e._drawLabel(a,a.i):""}}),t.ySort((t,i)=>e._y(i)-e._y(t)),t.y2Sort((t,i)=>e._y(i)-e._y(t))},ctx:{},fields:[{key:"discrete",default:"x"},{key:"shape",default:L("Line"),coerce:"const"}]};
3409
3590
  /**
3410
3591
  Creates a bump chart based on an array of data.
3411
- */var Ps=Bi(Bs,Ds);const Ts=({viz:e})=>{const{width:t,height:i}=le(e),s=Math.min(t,i)/2,n=e.ctx.pie,a=e.schema.padAngle??0,o=e.schema.padPixel??0,r=e.schema.sort,c=e.schema.value,h=n.padAngle(a||o/s).sort(r).value(c)(e._filteredData),l=h.reduce((e,t)=>e+t.value,0);h.forEach((e,t)=>{e.__d3plus__=!0,e.i=t;
3592
+ */var Ys=Ri(qs,Hs);const Ks=({viz:e})=>{const{width:t,height:i}=le(e),s=Math.min(t,i)/2,n=e.ctx.pie,a=e.schema.padAngle??0,o=e.schema.padPixel??0,r=e.schema.sort,c=e.schema.value,h=n.padAngle(a||o/s).sort(r).value(c)(e._filteredData),l=h.reduce((e,t)=>e+t.value,0);h.forEach((e,t)=>{e.__d3plus__=!0,e.i=t;
3412
3593
  // The tooltip binds the unwrapped row, so the slice's share of the total
3413
3594
  // must live on the row for the tooltip accessor to read it. Mirrors
3414
3595
  // Treemap stamping `share` onto `d.data`.
3415
- const i=l?e.value/l:0;e.share=i,e.data.share=i});const d=e.schema.innerRadius;return e.ctx.arcData=P.arc().innerRadius("function"==typeof d?d:()=>d).outerRadius(s),e.ctx.pieData=h,e.ctx.pieWidth=t,e.ctx.pieHeight=i,{shapeData:h}},Os={fontMin:8,fontMax:50,fontResize:!0,padding:5,textAnchor:"start",verticalAlign:"top",
3596
+ const i=l?e.value/l:0;e.share=i,e.data.share=i});const d=e.schema.innerRadius;return e.ctx.arcData=P.arc().innerRadius("function"==typeof d?d:()=>d).outerRadius(s),e.ctx.pieData=h,e.ctx.pieWidth=t,e.ctx.pieHeight=i,{shapeData:h}},Vs={fontMin:8,fontMax:50,fontResize:!0,padding:5,textAnchor:"start",verticalAlign:"top",
3416
3597
  // Honor the rotation/anchor `buildLabelData` precomputes onto each record
3417
3598
  // (`.r` / `.rotateAnchor`). TextBox's `rotate` accessor receives the raw
3418
3599
  // label record; `rotateAnchor` receives the laid-out datum whose `.data`
3419
3600
  // is that record — so both shapes are checked.
3420
3601
  rotate(e){const t=e.r??e.data?.r;return"number"==typeof t?t:0},rotateAnchor(e){const t=e.rotateAnchor??e.data?.rotateAnchor;return Array.isArray(t)?t:[(e.w??0)/2,(e.h??0)/2]},fontColor(e,t){const i="function"==typeof this._fill?this._fill(e,t):this._fill;return"string"==typeof i?u.colorContrast(i):"black"}};
3421
- /** Defaults that match Shape's `_labelConfig` so chart emits look like Shape labels. */function Rs(e){const t=Te(e);if(!t.length)return[];const i=(new Wt).config({...Os,...e.labelConfig??{}}).data(t).renderMode("compute");try{const e=i.toScene();return Array.isArray(e?.children)?e.children:[]}catch{return[]}}function Ls(e,t,i){return"function"==typeof e?e(t,i):e}const Es={name:"Pie",features:[ee,Q,Z,ne],layoutStage:Ts,emit:({viz:e,shapeData:t})=>{const i=t??[];if(!i.length)return[];const s=e.ctx.arcData,n=e.schema.shapeConfig??{};return[...i.map(t=>{const i=Ls(n.fill,t.data,t.i??0),a=Ls(n.stroke,t.data,t.i??0),o=Ls(n.strokeWidth,t.data,t.i??0);return{type:"path",key:`pie-${e._ids(t.data,t.i??0).join("-")}`,d:s(t),datum:t.data,paint:{fill:"string"==typeof i?i:void 0,stroke:a,strokeWidth:o}}}),...Rs({data:i,label:(t,s)=>e._drawLabel(i[s].data,i[s].i??s),
3602
+ /** Defaults that match Shape's `_labelConfig` so chart emits look like Shape labels. */function Xs(e){const t=Te(e);if(!t.length)return[];const i=(new Gt).config({...Vs,...e.labelConfig??{}}).data(t).renderMode("compute");try{const e=i.toScene();return Array.isArray(e?.children)?e.children:[]}catch{return[]}}function Us(e,t,i){return"function"==typeof e?e(t,i):e}const Js={name:"Pie",features:[ee,Q,Z,ne],layoutStage:Ks,emit:({viz:e,shapeData:t})=>{const i=t??[];if(!i.length)return[];const s=e.ctx.arcData,n=e.schema.shapeConfig??{};return[...i.map(t=>{const i=Us(n.fill,t.data,t.i??0),a=Us(n.stroke,t.data,t.i??0),o=Us(n.strokeWidth,t.data,t.i??0);return{type:"path",key:`pie-${e._ids(t.data,t.i??0).join("-")}`,d:s(t),datum:t.data,paint:{fill:"string"==typeof i?i:void 0,stroke:a,strokeWidth:o}}}),...Xs({data:i,label:(t,s)=>e._drawLabel(i[s].data,i[s].i??s),
3422
3603
  // The largest inscribed rectangle is in chart-centered path coordinates,
3423
3604
  // so the anchor is the origin and labelBounds carries the absolute box.
3424
- x:()=>0,y:()=>0,aes:()=>({}),rotate:L(0),id:(e,t)=>`pie-label-${t}`,labelBounds:(e,t)=>{const n=y.largestRect(y.path2polygon(s(i[t])),{angle:0});return!!n&&{angle:n.angle,width:n.width,height:n.height,x:n.cx-n.width/2,y:n.cy-n.height/2}},labelConfig:{fontColor:e=>{const t=e.data??e,i=Ls(n.fill,t.data,t.i??0);return u.colorContrast("string"==typeof i?i:"rgb(255, 255, 255)")},fontResize:!0,textAnchor:"middle",verticalAlign:"middle"}})]},chartTransform:e=>de(e,e.ctx.pieWidth,e.ctx.pieHeight),ctx:{pie:p.pie()},fields:[{key:"innerRadius",default:0},{key:"padAngle"},{key:"padPixel",default:0},{key:"value",default:F("value"),coerce:e=>"function"==typeof e?e:F(e)},{key:"sort",factory:e=>{const t=e.schema.value;return(e,i)=>t(i)-t(e)}},{key:"legendSort",factory:e=>{const t=e.schema.value;return(e,i)=>t(i)-t(e)}},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,i)=>{const s=e.ctx.pieData;return s?`${++s[i].index}. ${e._drawLabel(t,i)}, ${e.schema.value(t,i)}.`:""},Path:{labelConfig:{fontResize:!0}}})},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:[[()=>e.schema.translate("Share"),(t,i,s)=>{
3605
+ x:()=>0,y:()=>0,aes:()=>({}),rotate:L(0),id:(e,t)=>`pie-label-${t}`,labelBounds:(e,t)=>{const n=p.largestRect(p.path2polygon(s(i[t])),{angle:0});return!!n&&{angle:n.angle,width:n.width,height:n.height,x:n.cx-n.width/2,y:n.cy-n.height/2}},labelConfig:{fontColor:e=>{const t=e.data??e,i=Us(n.fill,t.data,t.i??0);return u.colorContrast("string"==typeof i?i:"rgb(255, 255, 255)")},fontResize:!0,textAnchor:"middle",verticalAlign:"middle"}})]},chartTransform:e=>de(e,e.ctx.pieWidth,e.ctx.pieHeight),ctx:{pie:y.pie()},fields:[{key:"innerRadius",default:0},{key:"padAngle"},{key:"padPixel",default:0},{key:"value",default:F("value"),coerce:e=>"function"==typeof e?e:F(e)},{key:"sort",factory:e=>{const t=e.schema.value;return(e,i)=>t(i)-t(e)}},{key:"legendSort",factory:e=>{const t=e.schema.value;return(e,i)=>t(i)-t(e)}},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,i)=>{const s=e.ctx.pieData;return s?`${++s[i].index}. ${e._drawLabel(t,i)}, ${e.schema.value(t,i)}.`:""},Path:{labelConfig:{fontResize:!0}}})},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:[[()=>e.schema.translate("Share"),(t,i,s)=>{
3425
3606
  // A ColorScale range swatch carries no per-row share, so sum the
3426
3607
  // share of every datum that falls in its color range.
3427
3608
  if(s._isColorScaleBucket){const t=ye(e,s.color,e.schema.value);return null==t?"":`${m.formatAbbreviate(100*t,e.schema.locale)}%`}
3428
3609
  // A Legend bucket aggregates multiple rows, so `share` arrives
3429
3610
  // as an array of the members' shares — sum it; a single cell's
3430
3611
  // share is a plain number.
3431
- const n=Array.isArray(s.share)?s.share.reduce((e,t)=>e+t,0):s.share;return Number.isFinite(n)?`${m.formatAbbreviate(100*n,e.schema.locale)}%`:""}]]})},{key:"legend",factory:e=>{const t=e.schema.legend;return(i,s)=>s.length!==e._filteredData.length&&t.call(e,i,s)}}]};
3612
+ const n=Array.isArray(s.share)?s.share.reduce((e,t)=>e+t,0):s.share;return Number.isFinite(n)?`${m.formatAbbreviate(100*n,e.schema.locale)}%`:""}]]})},{key:"legend",coerce:"const",factory:e=>{const t=e.schema.legend;return(i,s)=>s.length!==e._filteredData.length&&t.call(e,i,s)}}]};
3432
3613
  /**
3433
3614
  Uses the d3 pie layout to create SVG arcs based on an array of data.
3434
3615
  */
3435
- var Fs=Bi(Es);
3616
+ var Qs=Ri(Js);
3436
3617
  /**
3437
3618
  Extends the Pie visualization to create a donut chart.
3438
3619
  */
3439
- var Ws=Bi({name:"Donut",
3620
+ var Zs=Ri({name:"Donut",
3440
3621
  // Inherits Pie's full pipeline (features + emit). Donut adds no
3441
3622
  // chart-specific layout stage of its own — `super._draw` (Pie's)
3442
3623
  // handles the layout.
3443
- features:Es.features,emit:Es.emit,ctx:{},fields:[{key:"padPixel",default:2},{key:"innerRadius",factory:e=>()=>{const{width:i,height:s}=le(e);return(t.min([i,s])??0)/4}}]},Fs);const Ns=[{matches:["cartodb","cartocdn"],text:"© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, © <a href='https://carto.com/attribution' target='_blank'>CARTO</a>"},{matches:["opentopomap.org"],text:"© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors"},{matches:["arcgisonline.com"],text:"Powered by <a href='https://developers.arcgis.com/terms/attribution/' target='_blank'>Esri</a>"},{matches:["/watercolor/"],text:"Map tiles by <a href='http://stamen.com' target='_blank'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0' target='_blank'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org' target='_blank'>OpenStreetMap</a>, under <a href='http://www.openstreetmap.org/copyright' target='_blank'>ODbL</a>."},{matches:["stamen-tiles","stamen.com"],text:"Map tiles by <a href='http://stamen.com' target='_blank'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0' target='_blank'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org' target='_blank'>OpenStreetMap</a>, under <a href='http://creativecommons.org/licenses/by-sa/3.0' target='_blank'>CC BY SA</a>."}];
3624
+ features:Js.features,emit:Js.emit,ctx:{},fields:[{key:"padPixel",default:2},{key:"innerRadius",factory:e=>()=>{const{width:i,height:s}=le(e);return(t.min([i,s])??0)/4}}]},Qs);const en=[{matches:["cartodb","cartocdn"],text:"© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors, © <a href='https://carto.com/attribution' target='_blank'>CARTO</a>"},{matches:["opentopomap.org"],text:"© <a href='http://www.openstreetmap.org/copyright' target='_blank'>OpenStreetMap</a> contributors"},{matches:["arcgisonline.com"],text:"Powered by <a href='https://developers.arcgis.com/terms/attribution/' target='_blank'>Esri</a>"},{matches:["/watercolor/"],text:"Map tiles by <a href='http://stamen.com' target='_blank'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0' target='_blank'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org' target='_blank'>OpenStreetMap</a>, under <a href='http://www.openstreetmap.org/copyright' target='_blank'>ODbL</a>."},{matches:["stamen-tiles","stamen.com"],text:"Map tiles by <a href='http://stamen.com' target='_blank'>Stamen Design</a>, under <a href='http://creativecommons.org/licenses/by/3.0' target='_blank'>CC BY 3.0</a>. Data by <a href='http://openstreetmap.org' target='_blank'>OpenStreetMap</a>, under <a href='http://creativecommons.org/licenses/by-sa/3.0' target='_blank'>CC BY SA</a>."}];
3444
3625
  /**
3445
3626
  `ensureZoomDom(viz, kind)` — sets up the inner `<svg>` + zoom group +
3446
3627
  hitArea that d3-zoom and tile-loading need.
@@ -3463,32 +3644,38 @@ features:Es.features,emit:Es.emit,ctx:{},fields:[{key:"padPixel",default:2},{key
3463
3644
  scene-graph-native interaction path (renderer.on(...) dispatch +
3464
3645
  tile-data → image scene nodes) would let this go away; until then,
3465
3646
  it's the documented home for the imperative half of v4 zoom.
3466
- */function Hs(e,t){const{kind:i,width:s,height:n,duration:a,ocean:o}=t,r="network"===i?"d3plus-network":"d3plus-geomap",c="geomap"===i&&o||"transparent";let h=e._select.selectAll(`svg.${r}`).data([0]);if(h=h.enter().append("svg").attr("class",r).attr("opacity",0).attr("width",s).attr("height",n).attr("x",e._margin.left).attr("y",e._margin.top).style("background-color",c).merge(h),e._container=h,h.transition().duration(a).attr("opacity",1).attr("width",s).attr("height",n).attr("x",e._margin.left).attr("y",e._margin.top),"network"===i){
3647
+ */function tn(e,t){const{kind:i,width:s,height:n,duration:a,ocean:o}=t,r="network"===i?"d3plus-network":"d3plus-geomap",c="geomap"===i&&o||"transparent";let h=e._select.selectAll(`svg.${r}`).data([0]);if(h=h.enter().append("svg").attr("class",r).attr("opacity",0).attr("width",s).attr("height",n).attr("x",e._margin.left).attr("y",e._margin.top).style("background-color",c).merge(h),e._container=h,h.transition().duration(a).attr("opacity",1).attr("width",s).attr("height",n).attr("x",e._margin.left).attr("y",e._margin.top),"network"===i){
3467
3648
  // Hit-area for "click outside any node" → reset focus + zoom.
3468
3649
  const t=h.selectAll(`rect.${r}-hitArea`).data([0]);t.enter().append("rect").attr("class",`${r}-hitArea`).merge(t).attr("width",s).attr("height",n).attr("fill","transparent").on("click",()=>{e._focus&&(e.active(!1),e._focus=void 0,e._zoomToBounds(null))});let i=h.selectAll(`g.${r}-zoomGroup`).data([0]);i=i.enter().append("g").attr("class",`${r}-zoomGroup`).merge(i),e._zoomGroup=i}else{
3469
3650
  // Geomap also needs an ocean rect (under tiles + paths) and the tile
3470
3651
  // group that `_renderTiles` mutates with map imagery.
3471
- const t=h.selectAll(`rect.${r}-ocean`).data([0]);t.enter().append("rect").attr("class",`${r}-ocean`).merge(t).attr("width",s).attr("height",n).attr("fill",o||"transparent");let i=h.selectAll(`g.${r}-tileGroup`).data([0]);i=i.enter().append("g").attr("class",`${r}-tileGroup`).merge(i),e._tileGroup=i;let a=h.selectAll(`g.${r}-zoomGroup`).data([0]);a=a.enter().append("g").attr("class",`${r}-zoomGroup`).merge(a),e._zoomGroup=a}}function js(e,t){const i=t&&e.objects[t]?t:Object.keys(e.objects)[0];return w.feature(e,i)}
3472
- /** Reduces fit features, trimming far-flung MultiPolygon parts via path geometry. */const Gs=({viz:e})=>{const i=e,s=e.ctx,{width:n,height:a}=le(i),o=i.schema.topojson?js(i.schema.topojson,i.schema.topojsonKey):{type:"FeatureCollection",features:[]};s.coordData=o,i.schema.topojsonFilter&&(o.features=o.features.filter(i.schema.topojsonFilter));const r=T.geoPath().projection(i.schema.projection);s.path=r;const c=i._filteredData.filter((e,t)=>i.schema.point(e,t)instanceof Array),h=i._filteredData.filter((e,t)=>!(i.schema.point(e,t)instanceof Array)).reduce((e,t,s)=>(e[i._id(t,s)]=t,e),{}),l=o.features.reduce((e,t)=>{const s=i.schema.topojsonId(t);return e.push({__d3plus__:!0,data:h[s],feature:t,id:s}),e},[]),d=`scale${i.schema.pointSizeScale.charAt(0).toUpperCase()}${i.schema.pointSizeScale.slice(1)}`,u=B[d]().domain(t.extent(c,(e,t)=>i.schema.pointSize(e,t))).range([i.schema.pointSizeMin,i.schema.pointSizeMax]);if(!i._zoomSet||!s.extentBounds){const e=i.schema.fitObject?js(i.schema.fitObject,i.schema.fitKey):o;s.extentBounds={type:"FeatureCollection",features:i.schema.fitFilter?e.features.filter(i.schema.fitFilter):e.features.slice()},s.extentBounds.features=function(e,i){return e.reduce((e,s)=>{const n=s;if(!n.geometry)return e;const a={type:n.type,id:n.id,geometry:{coordinates:n.geometry.coordinates,type:n.geometry.type}};if("MultiPolygon"===n.geometry.type&&n.geometry.coordinates.length>1){const e=[],s=[];n.geometry.coordinates.forEach(t=>{a.geometry.coordinates=[t],e.push(i.area(a))}),a.geometry.coordinates=[n.geometry.coordinates[e.indexOf(t.max(e))]];const o=i.centroid(a);n.geometry.coordinates.forEach(e=>{a.geometry.coordinates=[e],s.push(y.pointDistance(i.centroid(a),o))});const r=t.quantile(e.reduce((t,i,n)=>(s[n]&&t.push(e[n]/s[n]),t),[]),.9);a.geometry.coordinates=n.geometry.coordinates.filter((t,i)=>{const n=s[i];return 0===n||e[i]/n>=r})}return e.push(a),e},[])}
3473
- /** Builds projected-point extent bounds + padding when no fit features exist. */(s.extentBounds.features,r),!s.extentBounds.features.length&&c.length&&function(e,i,s,n){const a=[[void 0,void 0],[void 0,void 0]];s.forEach((t,i)=>{const s=e.schema.projection(e.schema.point(t,i));(void 0===a[0][0]||s[0]<a[0][0])&&(a[0][0]=s[0]),(void 0===a[1][0]||s[0]>a[1][0])&&(a[1][0]=s[0]),(void 0===a[0][1]||s[1]<a[0][1])&&(a[0][1]=s[1]),(void 0===a[1][1]||s[1]>a[1][1])&&(a[1][1]=s[1])}),i.extentBounds={type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"MultiPoint",coordinates:a.map(t=>e.schema.projection.invert(t))}}]};const o=t.max(s,(t,i)=>n(e.schema.pointSize(t,i)));i.effectivePadding={top:e.schema.projectionPadding.top+o,right:e.schema.projectionPadding.right+o,bottom:e.schema.projectionPadding.bottom+o,left:e.schema.projectionPadding.left+o}}(i,s,c,u)}const m=s.effectivePadding||i.schema.projectionPadding;return s.effectivePadding=void 0,i.schema.projection=i.schema.projection.fitExtent(s.extentBounds.features.length?[[m.left,m.top],[n-m.right,a-m.bottom]]:[[0,0],[n,a]],s.extentBounds.features.length?s.extentBounds:{type:"Sphere"}),s.geomapWidth=n,s.geomapHeight=a,s.geomapCtx={topoData:l,pathFn:e=>r(e.feature),pointData:c,pointR:(e,t)=>u(i.schema.pointSize(e,t)),pointSort:(e,t)=>i.schema.pointSize(t)-i.schema.pointSize(e),pointX:(e,t)=>i.schema.projection(i.schema.point(e,t))[0],pointY:(e,t)=>i.schema.projection(i.schema.point(e,t))[1]},{shapeData:l}},Is=Object.assign({},T,O,R);function qs(e){const t=Ns.find(t=>t.matches.some(t=>e.includes(t)));return!!t&&t.text}
3652
+ const t=h.selectAll(`rect.${r}-ocean`).data([0]);t.enter().append("rect").attr("class",`${r}-ocean`).merge(t).attr("width",s).attr("height",n).attr("fill",o||"transparent");let i=h.selectAll(`g.${r}-tileGroup`).data([0]);i=i.enter().append("g").attr("class",`${r}-tileGroup`).merge(i),e._tileGroup=i;let a=h.selectAll(`g.${r}-zoomGroup`).data([0]);a=a.enter().append("g").attr("class",`${r}-zoomGroup`).merge(a),e._zoomGroup=a}}function sn(e,t){const i=t&&e.objects[t]?t:Object.keys(e.objects)[0];return w.feature(e,i)}
3653
+ /** Reduces fit features, trimming far-flung MultiPolygon parts via path geometry. */const nn=({viz:e})=>{const i=e,s=e.ctx,{width:n,height:a}=le(i),o=i.schema.topojson?sn(i.schema.topojson,i.schema.topojsonKey):{type:"FeatureCollection",features:[]};s.coordData=o,i.schema.topojsonFilter&&(o.features=o.features.filter(i.schema.topojsonFilter));const r=T.geoPath().projection(i.schema.projection);s.path=r;const c=i._filteredData.filter((e,t)=>i.schema.point(e,t)instanceof Array),h=i._filteredData.filter((e,t)=>!(i.schema.point(e,t)instanceof Array)).reduce((e,t,s)=>(e[i._id(t,s)]=t,e),{}),l=o.features.reduce((e,t)=>{const s=i.schema.topojsonId(t);return e.push({__d3plus__:!0,data:h[s],feature:t,id:s}),e},[]),d=`scale${i.schema.pointSizeScale.charAt(0).toUpperCase()}${i.schema.pointSizeScale.slice(1)}`,u=B[d]().domain(t.extent(c,(e,t)=>i.schema.pointSize(e,t))).range([i.schema.pointSizeMin,i.schema.pointSizeMax]);if(!i._zoomSet||!s.extentBounds){const e=i.schema.fitObject?sn(i.schema.fitObject,i.schema.fitKey):o;s.extentBounds={type:"FeatureCollection",features:i.schema.fitFilter?e.features.filter(i.schema.fitFilter):e.features.slice()},s.extentBounds.features=function(e,i){return e.reduce((e,s)=>{const n=s;if(!n.geometry)return e;const a={type:n.type,id:n.id,geometry:{coordinates:n.geometry.coordinates,type:n.geometry.type}};if("MultiPolygon"===n.geometry.type&&n.geometry.coordinates.length>1){const e=[],s=[];n.geometry.coordinates.forEach(t=>{a.geometry.coordinates=[t],e.push(i.area(a))}),a.geometry.coordinates=[n.geometry.coordinates[e.indexOf(t.max(e))]];const o=i.centroid(a);n.geometry.coordinates.forEach(e=>{a.geometry.coordinates=[e],s.push(p.pointDistance(i.centroid(a),o))});const r=t.quantile(e.reduce((t,i,n)=>(s[n]&&t.push(e[n]/s[n]),t),[]),.9);a.geometry.coordinates=n.geometry.coordinates.filter((t,i)=>{const n=s[i];return 0===n||e[i]/n>=r})}return e.push(a),e},[])}
3654
+ /** Builds projected-point extent bounds + padding when no fit features exist. */(s.extentBounds.features,r),!s.extentBounds.features.length&&c.length&&function(e,i,s,n){const a=[[void 0,void 0],[void 0,void 0]];s.forEach((t,i)=>{const s=e.schema.projection(e.schema.point(t,i));(void 0===a[0][0]||s[0]<a[0][0])&&(a[0][0]=s[0]),(void 0===a[1][0]||s[0]>a[1][0])&&(a[1][0]=s[0]),(void 0===a[0][1]||s[1]<a[0][1])&&(a[0][1]=s[1]),(void 0===a[1][1]||s[1]>a[1][1])&&(a[1][1]=s[1])}),i.extentBounds={type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"MultiPoint",coordinates:a.map(t=>e.schema.projection.invert(t))}}]};const o=t.max(s,(t,i)=>n(e.schema.pointSize(t,i)));i.effectivePadding={top:e.schema.projectionPadding.top+o,right:e.schema.projectionPadding.right+o,bottom:e.schema.projectionPadding.bottom+o,left:e.schema.projectionPadding.left+o}}(i,s,c,u)}const m=s.effectivePadding||i.schema.projectionPadding;return s.effectivePadding=void 0,i.schema.projection=i.schema.projection.fitExtent(s.extentBounds.features.length?[[m.left,m.top],[n-m.right,a-m.bottom]]:[[0,0],[n,a]],s.extentBounds.features.length?s.extentBounds:{type:"Sphere"}),s.geomapWidth=n,s.geomapHeight=a,s.geomapCtx={topoData:l,pathFn:e=>r(e.feature),pointData:c,pointR:(e,t)=>u(i.schema.pointSize(e,t)),pointSort:(e,t)=>i.schema.pointSize(t)-i.schema.pointSize(e),pointX:(e,t)=>i.schema.projection(i.schema.point(e,t))[0],pointY:(e,t)=>i.schema.projection(i.schema.point(e,t))[1]},{shapeData:l}},an=Object.assign({},T,O,R);function on(e){const t=en.find(t=>t.matches.some(t=>e.includes(t)));return!!t&&t.text}
3474
3655
  /** Installs `_renderTiles`, the per-instance method that mutates the tile group. */
3475
- /** Installs the imperative fluent accessors on the Geomap instance. */function Ys(e){
3656
+ /** Installs the imperative fluent accessors on the Geomap instance. */function rn(e){
3476
3657
  // Imperative fluent accessors. Parameter type is `unknown` since each
3477
3658
  // method accepts a function or a value (or for fitFilter/topojsonFilter,
3478
3659
  // also an array of ids). Each branch narrows with typeof / instanceof.
3479
3660
  !
3480
3661
  /** Installs the fit/point fluent accessors. */function(e){const t=e;t.fitFilter=function(e){if(arguments.length){if(this._zoomSet=!1,"function"==typeof e)return this.schema.fitFilter=e,this;const t=e instanceof Array?e:[e];return this.schema.fitFilter=e=>t.includes(e.id),this}return this.schema.fitFilter},t.fitKey=function(e){return arguments.length?(this.schema.fitKey=e,this._zoomSet=!1,this):this.schema.fitKey},t.fitObject=function(e,t){return arguments.length?(s.addToQueue.bind(this)(e,t,"fitObject"),this._zoomSet=!1,this):this.schema.fitObject},t.point=function(e){return arguments.length?(this.schema.point="function"==typeof e?e:L(e),this):this.schema.point},t.pointSize=function(e){return arguments.length?(this.schema.pointSize="function"==typeof e?e:L(e),this):this.schema.pointSize}}
3481
- /** Installs the projection fluent accessors. */(e),function(e){const t=e;t.projection=function(e){return arguments.length&&"geoMercator"!==e&&t.tiles(!1),arguments.length?(this.schema.projection="string"==typeof e?Is[e]?Is[e]():Is.geoMercator():e,this):this.schema.projection},t.projectionPadding=function(e){return arguments.length?(this.schema.projectionPadding=n.parseSides(e),this):this.schema.projectionPadding},t.projectionRotate=function(e){return arguments.length?(this.schema.projection.rotate(e),t.tiles(!1),this._zoomSet=!1,this):this.schema.projectionRotate}}
3482
- /** Installs the tile fluent accessors. */(e),function(e){const t=e;t.tiles=function(e){if(arguments.length){this.schema.tiles=e;const t=qs(this.schema.tileUrl);return e&&""===this.schema.attribution?this.schema.attribution=t:e||this.schema.attribution!==t||(this.schema.attribution=""),this}return this.schema.tiles},t.tileUrl=function(e){return arguments.length?(this.schema.tileUrl=e,this.schema.tiles&&(this.schema.attribution=qs(e)),this._tileGroup&&this._renderTiles.bind(this)(),this):this.schema.tileUrl}}
3483
- /** Installs the topojson fluent accessors. */(e),function(e){const t=e;t.topojson=function(e,t){return arguments.length?(s.addToQueue.bind(this)(e,t,"topojson"),this._zoomSet=!1,this):this.schema.topojson},t.topojsonFill=function(e){return arguments.length?(this.schema.topojsonFill="function"==typeof e?e:L(e),this):this.schema.topojsonFill},t.topojsonFilter=function(e){if(arguments.length){if(this._zoomSet=!1,"function"==typeof e)return this.schema.topojsonFilter=e,this;const t=e instanceof Array?e:[e];return this.schema.topojsonFilter=e=>t.includes(e.id),this}return this.schema.topojsonFilter},t.topojsonKey=function(e){return arguments.length?(this.schema.topojsonKey=e,this._zoomSet=!1,this):this.schema.topojsonKey},t.topojsonId=function(e){return arguments.length?(this.schema.topojsonId="function"==typeof e?e:F(e),this):this.schema.topojsonId}}(e)}const Ks={name:"Geomap",features:[ee,Q,Z,ne],layoutStage:Gs,emit:({viz:e})=>{const t=e.ctx.geomapCtx;if(!t)return[];const i=[];
3484
- // Canvas backend: ensureZoomDom keeps its imperative ocean rect transparent
3485
- // (it lives in the overlaying compute <svg>), so paint the ocean into the
3486
- // scene here — first, beneath the geography — to match the SVG backend.
3487
- if("canvas"===e._renderer){const t=e.schema.ocean;if(t&&"transparent"!==t){const{width:s,height:n}=le(e);i.push({type:"rect",key:"geomap-ocean",x:e._margin.left,y:e._margin.top,width:s,height:n,paint:{fill:t}})}}if(t.topoData&&t.topoData.length){const s=Ei(e,"Path");for(let e=0;e<t.topoData.length;e++){const n=t.topoData[e],a=n.data??n,o=Li(s,a,e);i.push({type:"path",key:`geomap-path-${n.id}`,d:t.pathFn(n),datum:a,
3662
+ /** Installs the projection fluent accessors. */(e),function(e){const t=e;t.projection=function(e){return arguments.length&&"geoMercator"!==e&&t.tiles(!1),arguments.length?(this.schema.projection="string"==typeof e?an[e]?an[e]():an.geoMercator():e,this):this.schema.projection},t.projectionPadding=function(e){return arguments.length?(this.schema.projectionPadding=n.parseSides(e),this):this.schema.projectionPadding},t.projectionRotate=function(e){return arguments.length?(this.schema.projection.rotate(e),t.tiles(!1),this._zoomSet=!1,this):this.schema.projectionRotate}}
3663
+ /** Installs the tile fluent accessors. */(e),function(e){const t=e;t.tiles=function(e){if(arguments.length){this.schema.tiles=e;const t=on(this.schema.tileUrl);return e&&""===this.schema.attribution?this.schema.attribution=t:e||this.schema.attribution!==t||(this.schema.attribution=""),this}return this.schema.tiles},t.tileUrl=function(e){return arguments.length?(this.schema.tileUrl=e,this.schema.tiles&&(this.schema.attribution=on(e)),this._tileGroup&&this._renderTiles.bind(this)(),this):this.schema.tileUrl}}
3664
+ /** Installs the topojson fluent accessors. */(e),function(e){const t=e;t.topojson=function(e,t){return arguments.length?(s.addToQueue.bind(this)(e,t,"topojson"),this._zoomSet=!1,this):this.schema.topojson},t.topojsonFill=function(e){return arguments.length?(this.schema.topojsonFill="function"==typeof e?e:L(e),this):this.schema.topojsonFill},t.topojsonFilter=function(e){if(arguments.length){if(this._zoomSet=!1,"function"==typeof e)return this.schema.topojsonFilter=e,this;const t=e instanceof Array?e:[e];return this.schema.topojsonFilter=e=>t.includes(e.id),this}return this.schema.topojsonFilter},t.topojsonKey=function(e){return arguments.length?(this.schema.topojsonKey=e,this._zoomSet=!1,this):this.schema.topojsonKey},t.topojsonId=function(e){return arguments.length?(this.schema.topojsonId="function"==typeof e?e:F(e),this):this.schema.topojsonId}}(e)}const cn={name:"Geomap",features:[ee,Q,Z,ne],layoutStage:nn,emit:({viz:e})=>{const t=e.ctx.geomapCtx;if(!t)return[];const i=[];
3665
+ // The ocean rect and basemap tiles normally live in the imperative geomap
3666
+ // <svg> (`_container`), outside the scene graph. That's fine on-screen, but a
3667
+ // server render serializes only the scene, so under SSR (`viz._ssr`) — and on
3668
+ // the canvas backend, whose compute <svg> keeps its ocean transparent — paint
3669
+ // them into the scene here, beneath the geography, so the output is complete.
3670
+ if("canvas"===e._renderer||e._ssr){const t=e.schema.ocean;if(t&&"transparent"!==t){const{width:s,height:n}=le(e);i.push({type:"rect",key:"geomap-ocean",x:e._margin.left,y:e._margin.top,width:s,height:n,paint:{fill:t}})}}
3671
+ // Basemap tiles, pre-fetched + inlined as data URIs by @d3plus/ssr. Placed
3672
+ // above the ocean and below the geography, at the positions `_computeTileList`
3673
+ // derives from the fitted projection (same math as the live `_renderTiles`).
3674
+ const s=e._ssrTiles;if(s&&s.size&&"function"==typeof e._computeTileList)for(const t of e._computeTileList()){const e=s.get(t.key);e&&i.push({type:"image",key:`geomap-tile-${t.key}`,x:t.x,y:t.y,width:t.size,height:t.size,href:e,preserveAspectRatio:"none",interactive:!1})}if(t.topoData&&t.topoData.length){const s=Hi(e,"Path");for(let e=0;e<t.topoData.length;e++){const n=t.topoData[e],a=n.data??n,o=Ni(s,a,e);i.push({type:"path",key:`geomap-path-${n.id}`,d:t.pathFn(n),datum:a,
3488
3675
  // Topojson geography is a data shape: keep its border stroke a constant
3489
3676
  // screen width as the map zooms (v3 parity), rather than scaling with
3490
3677
  // the zoom transform. Honors an explicit shapeConfig.vectorEffect.
3491
- paint:{...o,vectorEffect:o.vectorEffect??"non-scaling-stroke"}})}}if(t.pointData&&t.pointData.length){const s=Ei(e,"Circle"),n=t.pointSort?[...t.pointData].sort(t.pointSort):t.pointData;for(let a=0;a<n.length;a++){const o=n[a],r=Li(s,o,a);
3678
+ paint:{...o,vectorEffect:o.vectorEffect??"non-scaling-stroke"}})}}if(t.pointData&&t.pointData.length){const s=Hi(e,"Circle"),n=t.pointSort?[...t.pointData].sort(t.pointSort):t.pointData;for(let a=0;a<n.length;a++){const o=n[a],r=Ni(s,o,a);
3492
3679
  // Origin-centered geometry with the projected position in `transform`,
3493
3680
  // matching how Shape-emitted Circle marks are placed (cx/cy = 0, group
3494
3681
  // transform positions the mark). The motion-trail layer reads a mark's
@@ -3508,7 +3695,18 @@ chartTransform:()=>{},
3508
3695
  // chart-cells group, so it stays fixed while pan/zoom moves the map beneath it.
3509
3696
  chartClip:e=>{const{width:t,height:i}=le(e);return{type:"rect",x:e._margin.left,y:e._margin.top,width:t,height:i}},setup:e=>{const t=e;e.schema.zoom=!0,e._zoomSet=!1,e.schema.tiles=!0,e._tileGen=k.tile(),function(e){
3510
3697
  // `_renderTiles` is a per-instance method that mutates the tile group.
3511
- e._renderTiles=function(e=d.zoomTransform((this._zoomEventTarget||this._container).node()),t=0){let i=[];this.schema.tiles&&(i=this._tileGen.extent(this._zoomBehavior.translateExtent()).scale(this.schema.projection.scale()*(2*Math.PI)*e.k).translate(e.apply(this.schema.projection.translate()))(),this._tileGroup.transition().duration(t).attr("transform",e));const s=this._tileGroup.selectAll("image.d3plus-geomap-tile").data(i,([e,t,i])=>`${e}-${t}-${i}`);s.exit().transition().duration(t).attr("opacity",0).remove();const n=i.scale/e.k,a=s.enter().append("image").attr("class","d3plus-geomap-tile");a.attr("opacity",0).transition().duration(t).attr("opacity",1),s.merge(a).attr("width",n).attr("height",n).attr("xlink:href",([e,t,i])=>this.schema.tileUrl.replace("{s}",["a","b","c"][3*Math.random()|0]).replace("{z}",`${i}`).replace("{x}",`${e}`).replace("{y}",`${t}`)).attr("x",([t])=>t*n+i.translate[0]*n-e.x/e.k).attr("y",([,t])=>t*n+i.translate[1]*n-e.y/e.k)}}
3698
+ e._renderTiles=function(e=d.zoomTransform((this._zoomEventTarget||this._container).node()),t=0){
3699
+ // Under SSR the basemap is composited into the scene graph (see geomapEmit +
3700
+ // `_computeTileList`), so skip the imperative <image> tile layer entirely.
3701
+ // It wouldn't be serialized anyway, and its transform transition relies on
3702
+ // SVGGElement.transform.baseVal, which headless DOMs don't implement.
3703
+ if(this._ssr)return;let i=[];this.schema.tiles&&(i=this._tileGen.extent(this._zoomBehavior.translateExtent()).scale(this.schema.projection.scale()*(2*Math.PI)*e.k).translate(e.apply(this.schema.projection.translate()))(),this._tileGroup.transition().duration(t).attr("transform",e));const s=this._tileGroup.selectAll("image.d3plus-geomap-tile").data(i,([e,t,i])=>`${e}-${t}-${i}`);s.exit().transition().duration(t).attr("opacity",0).remove();const n=i.scale/e.k,a=s.enter().append("image").attr("class","d3plus-geomap-tile");a.attr("opacity",0).transition().duration(t).attr("opacity",1),s.merge(a).attr("width",n).attr("height",n).attr("xlink:href",([e,t,i])=>this.schema.tileUrl.replace("{s}",["a","b","c"][3*Math.random()|0]).replace("{z}",`${i}`).replace("{x}",`${e}`).replace("{y}",`${t}`)).attr("x",([t])=>t*n+i.translate[0]*n-e.x/e.k).attr("y",([,t])=>t*n+i.translate[1]*n-e.y/e.k)},
3704
+ // Static (identity-transform) tile list for server-side rendering: the tile
3705
+ // URLs + their positions in projection pixel space, so @d3plus/ssr can fetch
3706
+ // them and geomapEmit can place them as scene image nodes (both SVG string and
3707
+ // canvas output then include the basemap, with no network at view time).
3708
+ // Deterministic `{s}` = "a" so tiles are cacheable across renders.
3709
+ e._computeTileList=function(){if(!this.schema.tiles)return[];const e=this._tileGen.extent(this._zoomBehavior.translateExtent()).scale(this.schema.projection.scale()*(2*Math.PI)).translate(this.schema.projection.translate())(),t=e.scale;return e.map(([i,s,n])=>({key:`${i}-${s}-${n}`,url:this.schema.tileUrl.replace("{s}","a").replace("{z}",`${n}`).replace("{x}",`${i}`).replace("{y}",`${s}`),x:i*t+e.translate[0]*t,y:s*t+e.translate[1]*t,size:t}))}}
3512
3710
  /** Wraps `_draw` to ensure the DOM zoom group + zoom wiring exist before drawing. */(e),function(e){
3513
3711
  // Wrap _draw to ensure DOM zoom group + zoom wiring.
3514
3712
  const t=e._draw.bind(e);e._draw=function(i){
@@ -3522,7 +3720,7 @@ const t=e._draw.bind(e);e._draw=function(i){
3522
3720
  // its zoomScroll/zoomPan disabling); clear any stale handler on the geomap
3523
3721
  // svg so an ocean event isn't zoomed twice. (Canvas keeps its own target —
3524
3722
  // the <canvas>, set in `_drawSceneToTarget`.)
3525
- "canvas"!==e._renderer&&e._select&&(e._zoomEventTarget=e._select,e._container&&e._container.on(".zoom",null));const s=t(i),{width:n,height:a}=le(e);return Hs(e,{kind:"geomap",width:n,height:a,duration:e.schema.duration,
3723
+ "canvas"!==e._renderer&&e._select&&(e._zoomEventTarget=e._select,e._container&&e._container.on(".zoom",null));const s=t(i),{width:n,height:a}=le(e);return tn(e,{kind:"geomap",width:n,height:a,duration:e.schema.duration,
3526
3724
  // On the canvas backend this imperative ocean rect lives in the compute
3527
3725
  // <svg>, which overlays the <canvas> and would hide the geography. Keep
3528
3726
  // it transparent there; geomapEmit paints the ocean into the scene (and
@@ -3537,29 +3735,32 @@ ocean:"canvas"===e._renderer?"transparent":e.schema.ocean}),e._zoomSet||(e._zoom
3537
3735
  // interaction surface: CanvasRenderer's pick drives tooltips and d3-zoom
3538
3736
  // drives pan/zoom on the same element. (On SVG this is a no-op — the scene
3539
3737
  // svg already sits on top and handles both.)
3540
- const s=e._drawSceneToTarget.bind(e);e._drawSceneToTarget=function(t){if(s(t),"canvas"===e._renderer&&e._sceneRenderer&&"function"==typeof e._sceneRenderer.toCanvas){const t=e._sceneRenderer.toCanvas();t&&(
3738
+ const s=e._drawSceneToTarget.bind(e);e._drawSceneToTarget=function(t){if(s(t),"canvas"===e._renderer&&// Under SSR the canvas is a headless native surface with no
3739
+ // addEventListener; there is no interaction to wire, so skip the
3740
+ // pointer/zoom rebind entirely.
3741
+ !e._ssr&&e._sceneRenderer&&"function"==typeof e._sceneRenderer.toCanvas){const t=e._sceneRenderer.toCanvas();t&&(
3541
3742
  // The compute svg is absolutely positioned over the canvas; an svg root
3542
3743
  // hit-tests its whole box, so even an empty one swallows the canvas's
3543
3744
  // pointer events. The canvas is the sole render + interaction surface in
3544
3745
  // canvas mode, so make the entire compute svg transparent to events.
3545
- e._select&&e._select.style("pointer-events","none"),e._container&&e._container.style("pointer-events","none"),e._zoomEventTarget=i.select(t),e.schema.zoom&&!e._brushing&&e._zoomEventTarget.call(e._zoomBehavior))}}}(e),Ys(e),
3746
+ e._select&&e._select.style("pointer-events","none"),e._container&&e._container.style("pointer-events","none"),e._zoomEventTarget=i.select(t),e.schema.zoom&&!e._brushing&&e._zoomEventTarget.call(e._zoomBehavior))}}}(e),rn(e),
3546
3747
  // Seed the default tile URL through the wrapped accessor so attribution is set.
3547
- t.tileUrl("https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}@2x.png")},ctx:{},fields:[{key:"fitObject",default:!1},{key:"noDataMessage",default:!1},{key:"ocean",default:"#d4dadc"},{key:"point",default:F("point")},{key:"pointSize",default:L(1)},{key:"pointSizeMax",default:10},{key:"pointSizeMin",default:5},{key:"pointSizeScale",default:"linear"},{key:"projection",default:Is.geoMercator()},{key:"projectionPadding",default:n.parseSides(20)},{key:"shape",default:L("Circle")},{key:"topojson",default:!1},{key:"topojsonFill",default:L("#f5f5f3")},{key:"topojsonFilter",default:e=>!["010"].includes(e.id)},{key:"topojsonId",default:F("id")},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,i)=>`${e._drawLabel(t,i)}, ${e.schema.pointSize(t,i)}`,hoverOpacity:1,Path:{ariaLabel:(t,i)=>{const s=e.schema.colorScale,n=s?`, ${s(t,i)}`:"";return`${e._drawLabel(t,i)}${n}.`},fill:(t,i)=>{const s=e.ctx.coordData?.features??[],n=e.schema.colorScale;if(n&&!s.includes(t)){const i=n(t);if(null!=i){if(e._colorScaleClass._colorScale)return e._colorScaleClass._colorScale(i);let t=e._colorScaleClass.color();return t instanceof Array&&(t=t[t.length-1]),t}}return e.schema.topojsonFill(t,i)},on:{mouseenter:(t,i,s,n)=>(e.ctx.coordData?.features??[]).includes(t)?null:e.schema.on.mouseenter.bind(e)(t,i,s,n),"mousemove.shape":(t,i,s,n)=>(e.ctx.coordData?.features??[]).includes(t)?null:e.schema.on["mousemove.shape"].bind(e)(t,i,s,n),mouseleave:(t,i,s,n)=>(e.ctx.coordData?.features??[]).includes(t)?null:e.schema.on.mouseleave.bind(e)(t,i,s,n)},stroke:(t,i)=>{const s=e.schema.shapeConfig.Path,n="function"==typeof s.fill?s.fill(t,i):s.fill,a=c.color(n);return a?a.darker():n},strokeWidth:1},
3748
+ t.tileUrl("https://cartodb-basemaps-{s}.global.ssl.fastly.net/light_all/{z}/{x}/{y}@2x.png")},ctx:{},fields:[{key:"fitObject",default:!1},{key:"noDataMessage",default:!1},{key:"ocean",default:"#d4dadc"},{key:"point",default:F("point")},{key:"pointSize",default:L(1)},{key:"pointSizeMax",default:10},{key:"pointSizeMin",default:5},{key:"pointSizeScale",default:"linear"},{key:"projection",default:an.geoMercator()},{key:"projectionPadding",default:n.parseSides(20)},{key:"shape",default:L("Circle"),coerce:"const"},{key:"topojson",default:!1},{key:"topojsonFill",default:L("#f5f5f3")},{key:"topojsonFilter",default:e=>!["010"].includes(e.id)},{key:"topojsonId",default:F("id")},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,i)=>`${e._drawLabel(t,i)}, ${e.schema.pointSize(t,i)}`,hoverOpacity:1,Path:{ariaLabel:(t,i)=>{const s=e.schema.colorScale,n=s?`, ${s(t,i)}`:"";return`${e._drawLabel(t,i)}${n}.`},fill:(t,i)=>{const s=e.ctx.coordData?.features??[],n=e.schema.colorScale;if(n&&!s.includes(t)){const i=n(t);if(null!=i){if(e._colorScaleClass._colorScale)return e._colorScaleClass._colorScale(i);let t=e._colorScaleClass.color();return t instanceof Array&&(t=t[t.length-1]),t}}return e.schema.topojsonFill(t,i)},on:{mouseenter:(t,i,s,n)=>(e.ctx.coordData?.features??[]).includes(t)?null:e.schema.on.mouseenter.bind(e)(t,i,s,n),"mousemove.shape":(t,i,s,n)=>(e.ctx.coordData?.features??[]).includes(t)?null:e.schema.on["mousemove.shape"].bind(e)(t,i,s,n),mouseleave:(t,i,s,n)=>(e.ctx.coordData?.features??[]).includes(t)?null:e.schema.on.mouseleave.bind(e)(t,i,s,n)},stroke:(t,i)=>{const s=e.schema.shapeConfig.Path,n="function"==typeof s.fill?s.fill(t,i):s.fill,a=c.color(n);return a?a.darker():n},strokeWidth:1},
3548
3749
  // Coordinate points (Circles) leave a motion trail when they move
3549
3750
  // between frames (e.g. Timeline play); opt out with Circle.trail: false.
3550
3751
  Circle:{trail:!0}})}]};
3551
3752
  /**
3552
3753
  Creates a geographical map with zooming, panning, image tiles, and the ability to layer choropleth paths and coordinate points.
3553
- */var Xs=Bi(Ks);
3754
+ */var hn=Ri(cn);
3554
3755
  /**
3555
3756
  Creates a line plot based on an array of data.
3556
3757
  */
3557
- var Vs=Bi({name:"LinePlot",paintDriven:!0,features:[ee,Q,Z,ne],ctx:{},fields:[{key:"discrete",default:"x"},{key:"shape",default:L("Line")}]},Ds);
3758
+ var ln=Ri({name:"LinePlot",paintDriven:!0,features:[ee,Q,Z,ne],ctx:{},fields:[{key:"discrete",default:"x"},{key:"shape",default:L("Line"),coerce:"const"}]},Hs);
3558
3759
  /**
3559
3760
  @module matrixData
3560
3761
  @private
3561
3762
  */
3562
- function Us(e){const t=this._filteredData,i=(this.schema.rowList||s.unique(t.map(this.schema.row))).sort(this.schema.rowSort),n=(this.schema.columnList||s.unique(t.map(this.schema.column))).sort(this.schema.columnSort);if(!i.length||!n.length)return{rowValues:[],columnValues:[],shapeData:[]};var a,o;return{rowValues:i,columnValues:n,shapeData:(a=i,o=n,[].concat(...a.map(e=>o.map(t=>[e,t])))).map(([e,i])=>{const s={__d3plusTooltip__:!0,__d3plus__:!0,column:i,row:e},n=t.findIndex((t,s)=>this.schema.row(t,s)===e&&this.schema.column(t,s)===i);return n>=0?(s.i=n,s.data=t[n]):s.data={row:e,column:i},s})}}const Js=({viz:e})=>{const t=Us.bind(e)(e._filteredData),{rowValues:i,columnValues:s,shapeData:n}=t;if(!i.length||!s.length)return{shapeData:[]};const{width:a,height:o}=le(e),r=a/s.length<120||void 0;
3763
+ function dn(e){const t=this._filteredData,i=(this.schema.rowList||s.unique(t.map(this.schema.row))).sort(this.schema.rowSort),n=(this.schema.columnList||s.unique(t.map(this.schema.column))).sort(this.schema.columnSort);if(!i.length||!n.length)return{rowValues:[],columnValues:[],shapeData:[]};var a,o;return{rowValues:i,columnValues:n,shapeData:(a=i,o=n,[].concat(...a.map(e=>o.map(t=>[e,t])))).map(([e,i])=>{const s={__d3plusTooltip__:!0,__d3plus__:!0,column:i,row:e},n=t.findIndex((t,s)=>this.schema.row(t,s)===e&&this.schema.column(t,s)===i);return n>=0?(s.i=n,s.data=t[n]):s.data={row:e,column:i},s})}}const un=({viz:e})=>{const t=dn.bind(e)(e._filteredData),{rowValues:i,columnValues:s,shapeData:n}=t;if(!i.length||!s.length)return{shapeData:[]};const{width:a,height:o}=le(e),r=a/s.length<120||void 0;
3563
3764
  // Force rotation when columns are too narrow for horizontal labels; otherwise
3564
3765
  // pass `undefined` so the axis auto-rotates whenever its labels would overlap
3565
3766
  // or truncate (forcing `false` here suppressed that and dropped long labels).
@@ -3574,42 +3775,42 @@ c.renderMode("compute").select(void 0).height(o-e._padding.bottom).maxSize(u).ra
3574
3775
  /**
3575
3776
  `matrixEmit` — Rect cells positioned by the row/column scales stashed
3576
3777
  on `viz.ctx`.
3577
- */function Qs(e,t,i){return"function"==typeof e?e(t,i):e}const Zs={align:"start",barConfig:{stroke:0},gridSize:0,padding:5,paddingInner:0,paddingOuter:0,scale:"band",tickSize:0},en=(e,t)=>`${e}`.localeCompare(`${t}`),tn={name:"Matrix",features:[ee,Q,Z,ne],layoutStage:Js,emit:({viz:e,shapeData:t})=>{const i=t??[];if(!i.length)return[];const s=e.ctx.columnScale,n=e.ctx.rowScale,a=e.ctx.cellWidth,o=e.ctx.cellHeight,r=e.schema.cellPadding??0,c=e.schema.shapeConfig??{};return i.map((e,t)=>{const i=Qs(c.fill,e,t),h=Qs(c.stroke,e,t),l=Qs(c.strokeWidth,e,t),d=a-r,u=o-r;return{type:"rect",key:`matrix-${t}`,x:s(e.column)+a/2-d/2,y:n(e.row)+o/2-u/2,width:d,height:u,datum:e,paint:{fill:"string"==typeof i?i:void 0,stroke:h,strokeWidth:l}}})},chartTransform:e=>({x:0,y:e._margin.top}),setup:e=>{const t=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(i,s,n,a)=>{
3778
+ */function mn(e,t,i){return"function"==typeof e?e(t,i):e}const fn={align:"start",barConfig:{stroke:0},gridSize:0,padding:5,paddingInner:0,paddingOuter:0,scale:"band",tickSize:0},gn=(e,t)=>`${e}`.localeCompare(`${t}`),pn={name:"Matrix",features:[ee,Q,Z,ne],layoutStage:un,emit:({viz:e,shapeData:t})=>{const i=t??[];if(!i.length)return[];const s=e.ctx.columnScale,n=e.ctx.rowScale,a=e.ctx.cellWidth,o=e.ctx.cellHeight,r=e.schema.cellPadding??0,c=e.schema.shapeConfig??{};return i.map((e,t)=>{const i=mn(c.fill,e,t),h=mn(c.stroke,e,t),l=mn(c.strokeWidth,e,t),d=a-r,u=o-r;return{type:"rect",key:`matrix-${t}`,x:s(e.column)+a/2-d/2,y:n(e.row)+o/2-u/2,width:d,height:u,datum:e,paint:{fill:"string"==typeof i?i:void 0,stroke:h,strokeWidth:l}}})},chartTransform:e=>({x:0,y:e._margin.top}),setup:e=>{const t=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(i,s,n,a)=>{
3578
3779
  // A colorScale swatch routes through the shape path but has no row/column,
3579
3780
  // so its row/column hover would match nothing and wipe out the bucket
3580
3781
  // highlight `mouseenter` already set. Leave that highlight in place.
3581
- if(t(i,s,n,a),_e(n)||_e(i))return;const o=I.bind(e)("row",i,s),r=I.bind(e)("column",i,s);e.hover((t,i)=>(I.bind(e)("row",t,i)===o||I.bind(e)("column",t,i)===r)&&"number"==typeof e.schema.colorScale(t,i))}},ctx:{rowAxis:new xt,columnAxis:new xt},fields:[{key:"cellPadding",default:2},{key:"column",default:F("column"),coerce:e=>"function"==typeof e?e:F(e)},{key:"row",default:F("row"),coerce:e=>"function"==typeof e?e:F(e)},{key:"columnList"},{key:"rowList"},{key:"columnSort",default:en},{key:"rowSort",default:en},{key:"rowConfig",merge:!0,default:{orient:"left",...Zs}},{key:"columnConfig",merge:!0,default:{orient:"top",...Zs}},{key:"label",factory:e=>(t,i)=>`${I.bind(e)("row",t,i)} / ${I.bind(e)("column",t,i)}`}]};
3782
+ if(t(i,s,n,a),_e(n)||_e(i))return;const o=I.bind(e)("row",i,s),r=I.bind(e)("column",i,s);e.hover((t,i)=>(I.bind(e)("row",t,i)===o||I.bind(e)("column",t,i)===r)&&"number"==typeof e.schema.colorScale(t,i))}},ctx:{rowAxis:new Ct,columnAxis:new Ct},fields:[{key:"cellPadding",default:2},{key:"column",default:F("column"),coerce:e=>"function"==typeof e?e:F(e)},{key:"row",default:F("row"),coerce:e=>"function"==typeof e?e:F(e)},{key:"columnList"},{key:"rowList"},{key:"columnSort",default:gn},{key:"rowSort",default:gn},{key:"rowConfig",merge:!0,default:{orient:"left",...fn}},{key:"columnConfig",merge:!0,default:{orient:"top",...fn}},{key:"label",coerce:"const",factory:e=>(t,i)=>`${I.bind(e)("row",t,i)} / ${I.bind(e)("column",t,i)}`}]};
3582
3783
  /**
3583
3784
  Creates a simple rows/columns Matrix view of any dataset.
3584
3785
  */
3585
- var sn=Bi(tn);
3586
- /** Resolves filtered data + schema nodes into laid-out node records (pre-layout). */function nn(e){const i=e._filteredData.reduce((t,i,s)=>(t[e._id(i,s)]=i,t),{});let s=e.schema.nodes.reduce((i,s,n)=>(i[((i,s)=>`${e._id(i,s)||e.schema.nodeGroupBy[t.min([e._drawDepth,e.schema.nodeGroupBy.length-1])](i,s)}`)(s,n)]=s,i),{});const n=Array.from(new Set(Object.keys(i).concat(Object.keys(s)))).map((t,n)=>{const a=i[t],o=s[t];if(void 0===o)return!1;const r=(e,t=e=>void 0!==e)=>void 0!==a&&t(e(a))?e(a):e(o);return{__d3plus__:!0,data:a||o,i:n,id:t,fx:r(e._x,e=>!isNaN(e)),fy:r(e._y,e=>!isNaN(e)),node:o,r:e._size?r(e._size):e.schema.sizeMin,shape:r(e.schema.shape)}}).filter(e=>!!e);
3786
+ var yn=Ri(pn);
3787
+ /** Resolves filtered data + schema nodes into laid-out node records (pre-layout). */function _n(e){const i=e._filteredData.reduce((t,i,s)=>(t[e._id(i,s)]=i,t),{});let s=e.schema.nodes.reduce((i,s,n)=>(i[((i,s)=>`${e._id(i,s)||e.schema.nodeGroupBy[t.min([e._drawDepth,e.schema.nodeGroupBy.length-1])](i,s)}`)(s,n)]=s,i),{});const n=Array.from(new Set(Object.keys(i).concat(Object.keys(s)))).map((t,n)=>{const a=i[t],o=s[t];if(void 0===o)return!1;const r=(e,t=e=>void 0!==e)=>void 0!==a&&t(e(a))?e(a):e(o);return{__d3plus__:!0,data:a||o,i:n,id:t,fx:r(e._x,e=>!isNaN(e)),fy:r(e._y,e=>!isNaN(e)),node:o,r:e._size?r(e._size):e.schema.sizeMin,shape:r(e.schema.shape)}}).filter(e=>!!e);
3587
3788
  // rawNodes was used above; drop to avoid retention.
3588
3789
  return s={},n}
3589
- /** Resolves schema links against nodes, stashing nodeLookup + linkLookup on ctx. */const an=({viz:e})=>{const i=e,{width:s,height:n}=le(i);Array.isArray(i._filteredData)||(i._filteredData=[]),Array.isArray(i.schema.nodes)||(i.schema.nodes=[]),Array.isArray(i.schema.links)||(i.schema.links=[]);const a=nn(i),o=function(e,t){const i=t.reduce((e,t)=>(e[t.id]=t,e),{});e.ctx.nodeLookup=i;const s=new Map;for(const e of t)s.set(e.node,e);const n=e.schema.links.map(t=>{const n=typeof t.source;return{size:e.schema.linkSize(t),source:"number"===n?s.get(e.schema.nodes[t.source]):"string"===n?i[t.source]:i[t.source.id],target:"number"===n?s.get(e.schema.nodes[t.target]):"string"===n?i[t.target]:i[t.target.id]}});return e.ctx.linkLookup=n.reduce((e,t)=>(e[t.source.id]||(e[t.source.id]=[]),e[t.source.id].push(t.target),e[t.target.id]||(e[t.target.id]=[]),e[t.target.id].push(t.source),e),{}),n}
3590
- /** Runs the d3-force simulation, rotating results to the largest fitting rect. */(i,a);a.some(e=>void 0===e.fx||void 0===e.fy)&&function(e,i){const s=B.scaleLinear().domain(t.extent(i,e=>e.size)).range([.1,.5]),n=z.forceSimulation().force("link",z.forceLink(i).id(e=>e.id).distance(1).strength(e=>s(e.size)).iterations(4)).force("charge",z.forceManyBody().strength(-1)).stop(),a=1-Math.pow(.001,.01);n.velocityDecay(0),n.alphaMin(.001),n.alphaDecay(a),n.alphaDecay(0),n.nodes(e),n.tick(100).stop();const o=e.map(e=>[e.vx??0,e.vy??0]);let r=0,c=0,h=0;if(2===o.length)r=100;else if(o.length>2){const e=D.polygonHull(o)||[],t=y.largestRect(e,{verbose:!0});r=t.angle,c=t.cx,h=t.cy}e.forEach(e=>{const t=y.pointRotate([e.vx??0,e.vy??0],Math.PI/180*r*-1,[c,h]);e.fx=t[0],e.fy=t[1]})}
3591
- /** Positions nodes within bounds and assigns final r/width/height via a fitted radius scale. */(a,o);const r=function(e,i,s,n){const a=t.extent(i.map(e=>e.fx)),o=t.extent(i.map(e=>e.fy)),r=B.scaleLinear().domain(a).range([0,s]),c=B.scaleLinear().domain(o).range([0,n]),h=(a[1]-a[0])/(o[1]-o[0])||1,l=s/n;if(h>l){const e=n*l/h;c.range([(n-e)/2,n-(n-e)/2])}else{const e=s*h/l;r.range([(s-e)/2,s-(s-e)/2])}i.forEach(e=>{e.x=r(e.fx),e.y=c(e.fy)});const d=t.extent(i.map(e=>e.r));let u=e.schema.sizeMax||t.max([1,t.min(t.merge(i.map(e=>i.map(t=>e===t?null:y.pointDistance([e.x??0,e.y??0],[t.x??0,t.y??0])))))/2]);const m=B[`scale${e.schema.sizeScale.charAt(0).toUpperCase()}${e.schema.sizeScale.slice(1)}`]().domain(d).range([d[0]===d[1]?u:t.min([u/2,e.schema.sizeMin]),u]),f=r.domain(),g=c.domain(),p=f[1]-f[0],_=g[1]-g[0];i.forEach(e=>{const t=m(e.r)+3,i=e.x??0,s=e.y??0;f[0]>r.invert(i-t)&&(f[0]=r.invert(i-t)),f[1]<r.invert(i+t)&&(f[1]=r.invert(i+t)),g[0]>c.invert(s-t)&&(g[0]=c.invert(s-t)),g[1]<c.invert(s+t)&&(g[1]=c.invert(s+t))});const x=f[1]-f[0],b=g[1]-g[0];u*=t.min([p/x,_/b]),m.range([d[0]===d[1]?u:t.min([u/2,e.schema.sizeMin]),u]),r.domain(f),c.domain(g);const k=(h>l?s:n)/2;return i.forEach(e=>{e.x=r(e.fx),e.fx=e.x,e.y=c(e.fy),e.fy=e.y,e.r=m(e.r)||k,e.width=2*e.r,e.height=2*e.r}),m}
3592
- /** Normalizes link stroke sizes onto the linkSizeScale, mutating each link's size. */(i,a,s,n);!function(e,i,s){const n=t.extent(i,e=>e.size);if(n[0]!==n[1]){const t=B[`scale${e.schema.linkSizeScale.charAt(0).toUpperCase()}${e.schema.linkSizeScale.slice(1)}`]().domain(n).range([e.schema.linkSizeMin,s.range()[0]]);i.forEach(e=>{e.size=t(e.size)})}}(i,o,r);const c=Ei(i,"Path",i.schema.shapeConfig,"edge");delete c.on;const h={label:e=>!!(a.length<=i.schema.dataCutoff||i._hover&&i._hover(e)||i._active&&i._active(e))&&i._drawLabel(e.data||e.node,e.i)},l=Array.from(t.groups(a,e=>e.shape));return i.ctx.networkCtx={links:o,linkConfig:c,linkD:e=>`M${e.source.x},${e.source.y} ${e.target.x},${e.target.y}`,nodeGroups:l,nodeShapeConfig:h},{shapeData:a}};function on(e,i,s){return`${e._id(i,s)||e.schema.nodeGroupBy[t.min([e._drawDepth,e.schema.nodeGroupBy.length-1])](i,s)}`}
3790
+ /** Resolves schema links against nodes, stashing nodeLookup + linkLookup on ctx. */const xn=({viz:e})=>{const i=e,{width:s,height:n}=le(i);Array.isArray(i._filteredData)||(i._filteredData=[]),Array.isArray(i.schema.nodes)||(i.schema.nodes=[]),Array.isArray(i.schema.links)||(i.schema.links=[]);const a=_n(i),o=function(e,t){const i=t.reduce((e,t)=>(e[t.id]=t,e),{});e.ctx.nodeLookup=i;const s=new Map;for(const e of t)s.set(e.node,e);const n=e.schema.links.map(t=>{const n=typeof t.source;return{size:e.schema.linkSize(t),source:"number"===n?s.get(e.schema.nodes[t.source]):"string"===n?i[t.source]:i[t.source.id],target:"number"===n?s.get(e.schema.nodes[t.target]):"string"===n?i[t.target]:i[t.target.id]}});return e.ctx.linkLookup=n.reduce((e,t)=>(e[t.source.id]||(e[t.source.id]=[]),e[t.source.id].push(t.target),e[t.target.id]||(e[t.target.id]=[]),e[t.target.id].push(t.source),e),{}),n}
3791
+ /** Runs the d3-force simulation, rotating results to the largest fitting rect. */(i,a);a.some(e=>void 0===e.fx||void 0===e.fy)&&function(e,i){const s=B.scaleLinear().domain(t.extent(i,e=>e.size)).range([.1,.5]),n=z.forceSimulation().force("link",z.forceLink(i).id(e=>e.id).distance(1).strength(e=>s(e.size)).iterations(4)).force("charge",z.forceManyBody().strength(-1)).stop(),a=1-Math.pow(.001,.01);n.velocityDecay(0),n.alphaMin(.001),n.alphaDecay(a),n.alphaDecay(0),n.nodes(e),n.tick(100).stop();const o=e.map(e=>[e.vx??0,e.vy??0]);let r=0,c=0,h=0;if(2===o.length)r=100;else if(o.length>2){const e=D.polygonHull(o)||[],t=p.largestRect(e,{verbose:!0});r=t.angle,c=t.cx,h=t.cy}e.forEach(e=>{const t=p.pointRotate([e.vx??0,e.vy??0],Math.PI/180*r*-1,[c,h]);e.fx=t[0],e.fy=t[1]})}
3792
+ /** Positions nodes within bounds and assigns final r/width/height via a fitted radius scale. */(a,o);const r=function(e,i,s,n){const a=t.extent(i.map(e=>e.fx)),o=t.extent(i.map(e=>e.fy)),r=B.scaleLinear().domain(a).range([0,s]),c=B.scaleLinear().domain(o).range([0,n]),h=(a[1]-a[0])/(o[1]-o[0])||1,l=s/n;if(h>l){const e=n*l/h;c.range([(n-e)/2,n-(n-e)/2])}else{const e=s*h/l;r.range([(s-e)/2,s-(s-e)/2])}i.forEach(e=>{e.x=r(e.fx),e.y=c(e.fy)});const d=t.extent(i.map(e=>e.r));let u=e.schema.sizeMax||t.max([1,t.min(t.merge(i.map(e=>i.map(t=>e===t?null:p.pointDistance([e.x??0,e.y??0],[t.x??0,t.y??0])))))/2]);const m=B[`scale${e.schema.sizeScale.charAt(0).toUpperCase()}${e.schema.sizeScale.slice(1)}`]().domain(d).range([d[0]===d[1]?u:t.min([u/2,e.schema.sizeMin]),u]),f=r.domain(),g=c.domain(),y=f[1]-f[0],_=g[1]-g[0];i.forEach(e=>{const t=m(e.r)+3,i=e.x??0,s=e.y??0;f[0]>r.invert(i-t)&&(f[0]=r.invert(i-t)),f[1]<r.invert(i+t)&&(f[1]=r.invert(i+t)),g[0]>c.invert(s-t)&&(g[0]=c.invert(s-t)),g[1]<c.invert(s+t)&&(g[1]=c.invert(s+t))});const x=f[1]-f[0],b=g[1]-g[0];u*=t.min([y/x,_/b]),m.range([d[0]===d[1]?u:t.min([u/2,e.schema.sizeMin]),u]),r.domain(f),c.domain(g);const k=(h>l?s:n)/2;return i.forEach(e=>{e.x=r(e.fx),e.fx=e.x,e.y=c(e.fy),e.fy=e.y,e.r=m(e.r)||k,e.width=2*e.r,e.height=2*e.r}),m}
3793
+ /** Normalizes link stroke sizes onto the linkSizeScale, mutating each link's size. */(i,a,s,n);!function(e,i,s){const n=t.extent(i,e=>e.size);if(n[0]!==n[1]){const t=B[`scale${e.schema.linkSizeScale.charAt(0).toUpperCase()}${e.schema.linkSizeScale.slice(1)}`]().domain(n).range([e.schema.linkSizeMin,s.range()[0]]);i.forEach(e=>{e.size=t(e.size)})}}(i,o,r);const c=Hi(i,"Path",i.schema.shapeConfig,"edge");delete c.on;const h={label:e=>!!(a.length<=i.schema.dataCutoff||i._hover&&i._hover(e)||i._active&&i._active(e))&&i._drawLabel(e.data||e.node,e.i)},l=Array.from(t.groups(a,e=>e.shape));return i.ctx.networkCtx={links:o,linkConfig:c,linkD:e=>`M${e.source.x},${e.source.y} ${e.target.x},${e.target.y}`,nodeGroups:l,nodeShapeConfig:h},{shapeData:a}};function bn(e,i,s){return`${e._id(i,s)||e.schema.nodeGroupBy[t.min([e._drawDepth,e.schema.nodeGroupBy.length-1])](i,s)}`}
3593
3794
  /** Installs the `click.shape` handler that focuses/zooms a node + its links. */
3594
- /** Installs the shape/legend/mouse event handlers that drive Network focus + hover. */function rn(e,t){!function(e,t){e.schema.on["click.shape"]=(i,s,n,a)=>{if(e._tooltipClass.data([]).render(),e._drawDepth>=e.schema.groupBy.length-1){const o=on(e,i,s);if(e._focus&&e._focus===o)t.active(!1),e.schema.on.mouseenter.bind(e)(i,s,n,a),e._focus=void 0,e._zoomToBounds(null);else{t.hover(!1);const i=e.ctx.linkLookup[o]??[],s=e.ctx.nodeLookup[o],n=[o];let a=[s.x-s.r,s.x+s.r],r=[s.y-s.r,s.y+s.r];i.forEach(e=>{n.push(e.id),e.x-e.r<a[0]&&(a[0]=e.x-e.r),e.x+e.r>a[1]&&(a[1]=e.x+e.r),e.y-e.r<r[0]&&(r[0]=e.y-e.r),e.y+e.r>r[1]&&(r[1]=e.y+e.r)}),t.active((t,i)=>t.source&&t.target?t.source.id===o||t.target.id===o:n.includes(on(e,t,i))),e._focus=o;const c=d.zoomTransform((e._zoomEventTarget||e._container).node());a=a.map(e=>e*c.k+c.x),r=r.map(e=>e*c.k+c.y),e._zoomToBounds([[a[0],r[0]],[a[1],r[1]]])}}}}
3795
+ /** Installs the shape/legend/mouse event handlers that drive Network focus + hover. */function kn(e,t){!function(e,t){e.schema.on["click.shape"]=(i,s,n,a)=>{if(e._tooltipClass.data([]).render(),e._drawDepth>=e.schema.groupBy.length-1){const o=bn(e,i,s);if(e._focus&&e._focus===o)t.active(!1),e.schema.on.mouseenter.bind(e)(i,s,n,a),e._focus=void 0,e._zoomToBounds(null);else{t.hover(!1);const i=e.ctx.linkLookup[o]??[],s=e.ctx.nodeLookup[o],n=[o];let a=[s.x-s.r,s.x+s.r],r=[s.y-s.r,s.y+s.r];i.forEach(e=>{n.push(e.id),e.x-e.r<a[0]&&(a[0]=e.x-e.r),e.x+e.r>a[1]&&(a[1]=e.x+e.r),e.y-e.r<r[0]&&(r[0]=e.y-e.r),e.y+e.r>r[1]&&(r[1]=e.y+e.r)}),t.active((t,i)=>t.source&&t.target?t.source.id===o||t.target.id===o:n.includes(bn(e,t,i))),e._focus=o;const c=d.zoomTransform((e._zoomEventTarget||e._container).node());a=a.map(e=>e*c.k+c.x),r=r.map(e=>e*c.k+c.y),e._zoomToBounds([[a[0],r[0]],[a[1],r[1]]])}}}}
3595
3796
  /** Installs the `click.legend` handler that focuses/zooms a legend group. */(e,t),function(e,t){e.schema.on["click.legend"]=(i,s,n,a)=>{const o=e._ids(i,s),r=o[o.length-1],c=e._id(i,s);if(e._drawDepth>=e.schema.groupBy.length-1){if(e._focus&&e._focus===c)t.active(!1),e._focus=void 0,e._zoomToBounds(null);else{t.hover(!1);const i=(Array.isArray(c)?c:[c]).map(t=>e.ctx.nodeLookup[String(t)]),s=[`${r}`];let n=[i[0].x-i[0].r,i[0].x+i[0].r],a=[i[0].y-i[0].r,i[0].y+i[0].r];i.forEach(e=>{s.push(e.id),e.x-e.r<n[0]&&(n[0]=e.x-e.r),e.x+e.r>n[1]&&(n[1]=e.x+e.r),e.y-e.r<a[0]&&(a[0]=e.y-e.r),e.y+e.r>a[1]&&(a[1]=e.y+e.r)}),t.active((t,i)=>{if(t.source&&t.target)return s.includes(t.source.id)&&s.includes(t.target.id);const n=e._ids(t,i);return s.includes(`${n[n.length-1]}`)}),e._focus=c;const o=d.zoomTransform((e._zoomEventTarget||e._container).node());n=n.map(e=>e*o.k+o.x),a=a.map(e=>e*o.k+o.y),e._zoomToBounds([[n[0],a[0]],[n[1],a[1]]])}e.schema.on.mouseenter.bind(e)(i,s,n,a),e.schema.on["mousemove.legend"].bind(e)(i,s,n,a)}}}
3596
- /** Installs mouseenter/mouseleave/mousemove handlers that drive hover highlighting. */(e,t),function(e,t){e.schema.on.mouseenter=()=>{},e.schema.on["mouseleave.shape"]=()=>{t.hover(!1)};const i=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(s,n,a,o)=>{i(s,n,a,o);const r=on(e,s,n),c=e.ctx.linkLookup[r]??[],h=e.ctx.nodeLookup[r],l=[r],d=[h.x-h.r,h.x+h.r],u=[h.y-h.r,h.y+h.r];c.forEach(e=>{l.push(e.id),e.x-e.r<d[0]&&(d[0]=e.x-e.r),e.x+e.r>d[1]&&(d[1]=e.x+e.r),e.y-e.r<u[0]&&(u[0]=e.y-e.r),e.y+e.r>u[1]&&(u[1]=e.y+e.r)}),t.hover((t,i)=>t.source&&t.target?t.source.id===r||t.target.id===r:l.includes(`${e._ids(t,i)[e._drawDepth]}`))}}(e,t)}
3597
- /** Installs the per-instance fluent methods (links/nodes/nodeGroupBy/size/x/y/hover). */const cn={name:"Network",features:[ee,Q,Z,ne],layoutStage:an,emit:({viz:e})=>{const t=e.ctx.networkCtx;if(!t)return[];const i=[];if(t.links&&t.links.length)for(let e=0;e<t.links.length;e++){const s=t.links[e],n=s,a=Li(t.linkConfig,n,e);
3797
+ /** Installs mouseenter/mouseleave/mousemove handlers that drive hover highlighting. */(e,t),function(e,t){e.schema.on.mouseenter=()=>{},e.schema.on["mouseleave.shape"]=()=>{t.hover(!1)};const i=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(s,n,a,o)=>{i(s,n,a,o);const r=bn(e,s,n),c=e.ctx.linkLookup[r]??[],h=e.ctx.nodeLookup[r],l=[r],d=[h.x-h.r,h.x+h.r],u=[h.y-h.r,h.y+h.r];c.forEach(e=>{l.push(e.id),e.x-e.r<d[0]&&(d[0]=e.x-e.r),e.x+e.r>d[1]&&(d[1]=e.x+e.r),e.y-e.r<u[0]&&(u[0]=e.y-e.r),e.y+e.r>u[1]&&(u[1]=e.y+e.r)}),t.hover((t,i)=>t.source&&t.target?t.source.id===r||t.target.id===r:l.includes(`${e._ids(t,i)[e._drawDepth]}`))}}(e,t)}
3798
+ /** Installs the per-instance fluent methods (links/nodes/nodeGroupBy/size/x/y/hover). */const vn={name:"Network",features:[ee,Q,Z,ne],layoutStage:xn,emit:({viz:e})=>{const t=e.ctx.networkCtx;if(!t)return[];const i=[];if(t.links&&t.links.length)for(let e=0;e<t.links.length;e++){const s=t.links[e],n=s,a=Ni(t.linkConfig,n,e);
3598
3799
  // Link's strokeWidth comes from the layout-injected `d.size`.
3599
- "number"==typeof s.size&&(a.strokeWidth=s.size),i.push({type:"path",key:`network-link-${s.source.id??""}-${s.target.id??""}-${e}`,d:t.linkD(s),datum:n,paint:a})}if(t.nodeGroups&&t.nodeGroups.length)for(const[s,n]of t.nodeGroups){if(!n.length)continue;const a={...Ei(e,s),...t.nodeShapeConfig};for(let e=0;e<n.length;e++){const t=n[e],o=t.data??t,r=Li(a,o,t.i??e);if(
3800
+ "number"==typeof s.size&&(a.strokeWidth=s.size),i.push({type:"path",key:`network-link-${s.source.id??""}-${s.target.id??""}-${e}`,d:t.linkD(s),datum:n,paint:a})}if(t.nodeGroups&&t.nodeGroups.length)for(const[s,n]of t.nodeGroups){if(!n.length)continue;const a={...Hi(e,s),...t.nodeShapeConfig};for(let e=0;e<n.length;e++){const t=n[e],o=t.data??t,r=Ni(a,o,t.i??e);if(
3600
3801
  // Nodes are data shapes: keep their stroke a constant screen width as the
3601
3802
  // network zooms (the links above deliberately scale with the zoom, so
3602
3803
  // heavier connections read as heavier when zoomed in).
3603
- void 0===r.vectorEffect&&(r.vectorEffect="non-scaling-stroke"),"Circle"===s)i.push({type:"circle",key:`network-${s}-${t.id}`,cx:t.x,cy:t.y,r:t.r,datum:o,paint:r});else if("Rect"===s){const n=Number(t.width??Ri(a.width,o,t.i??e)??0),c=Number(t.height??Ri(a.height,o,t.i??e)??0);i.push({type:"rect",key:`network-${s}-${t.id}`,x:t.x-n/2,y:t.y-c/2,width:n,height:c,datum:o,paint:r})}
3804
+ void 0===r.vectorEffect&&(r.vectorEffect="non-scaling-stroke"),"Circle"===s)i.push({type:"circle",key:`network-${s}-${t.id}`,cx:t.x,cy:t.y,r:t.r,datum:o,paint:r});else if("Rect"===s){const n=Number(t.width??Wi(a.width,o,t.i??e)??0),c=Number(t.height??Wi(a.height,o,t.i??e)??0);i.push({type:"rect",key:`network-${s}-${t.id}`,x:t.x-n/2,y:t.y-c/2,width:n,height:c,datum:o,paint:r})}
3604
3805
  // Other shape kinds: skipped (Network's default is Circle).
3605
3806
  }
3606
3807
  // Labels via the chart-specific label fn. labelBounds is the
3607
3808
  // shape's aes (r for circles, width/height for rects).
3608
- const o=t.nodeShapeConfig.label;if(o){const e=Rs({data:n,label:(e,t)=>o(e,t),x:e=>e.x,y:e=>e.y,aes:e=>{const t=e;return"Circle"===s?{r:t.r,width:2*t.r,height:2*t.r}:{width:t.width??0,height:t.height??0}},rotate:L(0),id:e=>`network-label-${e.id}`,labelBounds:(e,t,i)=>{const n=i;if("Circle"===s){const e=n.r??0;return{width:1.5*e,height:1.5*e,x:.75*-e,y:.75*-e}}const a=n.width??0,o=n.height??0;return{width:a,height:o,x:-a/2,y:-o/2}},labelConfig:{...a.labelConfig??{fontResize:!0},fontColor:e=>{const t=e.data??e,i=Ri(a.fill,t.data??t,t.i??0);return u.colorContrast("string"==typeof i?i:"rgb(255, 255, 255)")}}});i.push(...e)}}return i},
3809
+ const o=t.nodeShapeConfig.label;if(o){const e=Xs({data:n,label:(e,t)=>o(e,t),x:e=>e.x,y:e=>e.y,aes:e=>{const t=e;return"Circle"===s?{r:t.r,width:2*t.r,height:2*t.r}:{width:t.width??0,height:t.height??0}},rotate:L(0),id:e=>`network-label-${e.id}`,labelBounds:(e,t,i)=>{const n=i;if("Circle"===s){const e=n.r??0;return{width:1.5*e,height:1.5*e,x:.75*-e,y:.75*-e}}const a=n.width??0,o=n.height??0;return{width:a,height:o,x:-a/2,y:-o/2}},labelConfig:{...a.labelConfig??{fontResize:!0},fontColor:e=>{const t=e.data??e,i=Wi(a.fill,t.data??t,t.i??0);return u.colorContrast("string"==typeof i?i:"rgb(255, 255, 255)")}}});i.push(...e)}}return i},
3609
3810
  // Network needs a real DOM element for d3-zoom binding; the hitArea click
3610
3811
  // handler closes over class state. `setup` installs the event surface;
3611
3812
  // `chartTransform` (default margin-origin) is fine for the scene.
3612
- setup:e=>{const i=e;e.schema.zoom=!0,rn(e,i),
3813
+ setup:e=>{const i=e;e.schema.zoom=!0,kn(e,i),
3613
3814
  // `links()` / `nodes()` / `nodeGroupBy()` / `size()` / `x()` / `y()` /
3614
3815
  // `hover()` need imperative method bodies (queue loading, aggs side
3615
3816
  // effects). Install them per-instance.
@@ -3633,18 +3834,18 @@ const n=i._draw.bind(e);i._draw=function(t){
3633
3834
  // with its zoomScroll/zoomPan disabling; clear the network svg's handlers
3634
3835
  // so an event over the background isn't zoomed twice. (Canvas keeps the
3635
3836
  // default target.)
3636
- "canvas"!==e._renderer&&e._select&&(e._zoomEventTarget=e._select,e._container&&e._container.on(".zoom",null));const i=n(t),{width:s,height:a}=le(e);return Hs(e,{kind:"network",width:s,height:a,duration:e.schema.duration}),i}},ctx:{},fields:[{key:"links",default:[]},{key:"linkSize",default:L(1),coerce:e=>"function"==typeof e?e:L(e)},{key:"linkSizeMin",default:1},{key:"linkSizeScale",default:"sqrt"},{key:"noDataMessage",default:!1},{key:"nodeGroupBy",default:[F("id")]},{key:"tooltipConfig",merge:!0,factory:e=>({title:t=>t&&t.source&&t.target?`${t.source.id} → ${t.target.id}`:e._drawLabel(t,"number"==typeof t.i?t.i:0)})},{key:"nodes",default:[]},{key:"sizeMax"},{key:"sizeMin",default:5},{key:"sizeScale",default:"sqrt"},{key:"shape",default:L("Circle")},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,i)=>{const s=e._size,n=s?`, ${s(t,i)}`:"";return`${e._drawLabel(t,i)}${n}.`},labelConfig:{duration:0,fontMin:1,fontResize:!0,labelPadding:0,textAnchor:"middle",verticalAlign:"middle"},Path:{fill:"none",label:!1,stroke:"#eee"}})}]};
3837
+ "canvas"!==e._renderer&&e._select&&(e._zoomEventTarget=e._select,e._container&&e._container.on(".zoom",null));const i=n(t),{width:s,height:a}=le(e);return tn(e,{kind:"network",width:s,height:a,duration:e.schema.duration}),i}},ctx:{},fields:[{key:"links",default:[]},{key:"linkSize",default:L(1),coerce:e=>"function"==typeof e?e:L(e)},{key:"linkSizeMin",default:1},{key:"linkSizeScale",default:"sqrt"},{key:"noDataMessage",default:!1},{key:"nodeGroupBy",default:[F("id")]},{key:"tooltipConfig",merge:!0,factory:e=>({title:t=>t&&t.source&&t.target?`${t.source.id} → ${t.target.id}`:e._drawLabel(t,"number"==typeof t.i?t.i:0)})},{key:"nodes",default:[]},{key:"sizeMax"},{key:"sizeMin",default:5},{key:"sizeScale",default:"sqrt"},{key:"shape",default:L("Circle"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,i)=>{const s=e._size,n=s?`, ${s(t,i)}`:"";return`${e._drawLabel(t,i)}${n}.`},labelConfig:{duration:0,fontMin:1,fontResize:!0,labelPadding:0,textAnchor:"middle",verticalAlign:"middle"},Path:{fill:"none",label:!1,stroke:"#eee"}})}]};
3637
3838
  /**
3638
3839
  Creates a network visualization based on a defined set of nodes and edges.
3639
- */var hn=Bi(cn);const ln=({viz:e})=>{const t=e._filteredData;if(!t||!t.length)return{shapeData:[]};const i=e.schema.height-e._margin.top-e._margin.bottom,n=e.schema.width-e._margin.left-e._margin.right,a=Math.min(i,n),o=s.nestGroups(t,e.schema.groupBy.slice(0,e._drawDepth+1)),r=e.schema.packOpacity,c=e.ctx.pack.padding(e.schema.layoutPadding).size([a,a])(M.hierarchy({key:o.key,values:o},e=>e.values).sum(e.schema.sum).sort(e.schema.sort)).descendants().filter((e,t)=>{const i=e;i.__d3plus__=!0,i.i=t,i.id=i.parent?i.parent.data.key:"root";const s=i.data;return s.__d3plusOpacity__=i.height?r(s,t):1,s.__d3plusTooltip__=!i.height,!i.children||i.children.length>1});return e.ctx.packDiameter=a,e.ctx.packOffsetX=(n-a)/2,e.ctx.packOffsetY=(i-a)/2,{shapeData:c}};function dn(e,t,i){return"function"==typeof e?e(t,i):e}
3840
+ */var Cn=Ri(vn);const Sn=({viz:e})=>{const t=e._filteredData;if(!t||!t.length)return{shapeData:[]};const i=e.schema.height-e._margin.top-e._margin.bottom,n=e.schema.width-e._margin.left-e._margin.right,a=Math.min(i,n),o=s.nestGroups(t,e.schema.groupBy.slice(0,e._drawDepth+1)),r=e.schema.packOpacity,c=e.ctx.pack.padding(e.schema.layoutPadding).size([a,a])(M.hierarchy({key:o.key,values:o},e=>e.values).sum(e.schema.sum).sort(e.schema.sort)).descendants().filter((e,t)=>{const i=e;i.__d3plus__=!0,i.i=t,i.id=i.parent?i.parent.data.key:"root";const s=i.data;return s.__d3plusOpacity__=i.height?r(s,t):1,s.__d3plusTooltip__=!i.height,!i.children||i.children.length>1});return e.ctx.packDiameter=a,e.ctx.packOffsetX=(n-a)/2,e.ctx.packOffsetY=(i-a)/2,{shapeData:c}};function wn(e,t,i){return"function"==typeof e?e(t,i):e}
3640
3841
  /**
3641
3842
  Walk a nested hierarchy, collecting every descendant into a flat array.
3642
3843
  Used by Pack's hover handlers to highlight the subtree under a hovered
3643
3844
  node.
3644
3845
  */
3645
- function un(e,t=[]){return e.values?e.values.forEach(e=>{t.push(e),un(e,t)}):t.push(e),t}const mn={name:"Pack",features:[ee,Q,Z,ne],layoutStage:ln,emit:({viz:e,shapeData:t})=>{const i=t??[];if(!i.length)return[];const s=e.schema.shapeConfig??{},n=(s.Circle??{}).label;
3846
+ function zn(e,t=[]){return e.values?e.values.forEach(e=>{t.push(e),zn(e,t)}):t.push(e),t}const Dn={name:"Pack",features:[ee,Q,Z,ne],layoutStage:Sn,emit:({viz:e,shapeData:t})=>{const i=t??[];if(!i.length)return[];const s=e.schema.shapeConfig??{},n=(s.Circle??{}).label;
3646
3847
  // Pack's per-shape config is nested under `Circle`.
3647
- return[...i.map((e,t)=>{const i=e.data,n=dn(s.fill,i,t),a=dn(s.stroke,i,t),o=dn(s.strokeWidth,i,t);return{type:"circle",key:`pack-${e.id}-${e.i}`,cx:e.x,cy:e.y,r:e.r,datum:i,paint:{fill:"string"==typeof n?n:void 0,stroke:a,opacity:i.__d3plusOpacity__,strokeWidth:o}}}),...Rs({data:i,label:(e,t)=>{const i=e;return!i.children&&(n?n(i.data,t):!!i.parent&&(i.data.id??!1))},x:e=>e.x,y:e=>e.y,
3848
+ return[...i.map((e,t)=>{const i=e.data,n=wn(s.fill,i,t),a=wn(s.stroke,i,t),o=wn(s.strokeWidth,i,t);return{type:"circle",key:`pack-${e.id}-${e.i}`,cx:e.x,cy:e.y,r:e.r,datum:i,paint:{fill:"string"==typeof n?n:void 0,stroke:a,opacity:i.__d3plusOpacity__,strokeWidth:o}}}),...Xs({data:i,label:(e,t)=>{const i=e;return!i.children&&(n?n(i.data,t):!!i.parent&&(i.data.id??!1))},x:e=>e.x,y:e=>e.y,
3648
3849
  // Store the leaf's source row (not the d3-hierarchy node) as the label's
3649
3850
  // `.data`, matching the circle node's datum (`d.data` above). Without this
3650
3851
  // the label and its circle unwrap to different objects, so on hover the
@@ -3654,70 +3855,70 @@ datum:e=>e.data,aes:e=>{const t=e.r;return{r:t,width:2*t,height:2*t}},rotate:L(0
3654
3855
  // the legend's hover state. Method shadowing doesn't fit the field
3655
3856
  // model (it's a method, not a value with a default); setup is the
3656
3857
  // right escape hatch for the genuine method-override case.
3657
- setup:e=>{const t=e.hover.bind(e);e.hover=i=>(t(i),e.schema.legend&&e._legendClass.hover(i),e)},ctx:{pack:M.pack()},fields:[{key:"layoutPadding",default:1},{key:"sort",default:(e,t)=>(t.value??0)-(e.value??0)},{key:"sum",default:F("value"),coerce:e=>"function"==typeof e?e:F(e)},{key:"packOpacity",default:L(.25),coerce:e=>"function"==typeof e?e:L(e)},{key:"shape",default:L("Circle"),coerce:e=>"function"==typeof e?e:L(e)},{key:"shapeConfig",merge:!0,factory:()=>({Circle:{label:e=>{const t=e;return!(!t.parent||t.children)&&t.id},labelConfig:{fontResize:!0},opacity:e=>e.__d3plusOpacity__}})},{key:"legend",factory:e=>{const t=e.schema.legend;return(i,s)=>s.length!==e._filteredData.length&&t.call(e,i,s)}},{
3858
+ setup:e=>{const t=e.hover.bind(e);e.hover=i=>(t(i),e.schema.legend&&e._legendClass.hover(i),e)},ctx:{pack:M.pack()},fields:[{key:"layoutPadding",default:1},{key:"sort",default:(e,t)=>(t.value??0)-(e.value??0)},{key:"sum",default:F("value"),coerce:e=>"function"==typeof e?e:F(e)},{key:"packOpacity",default:L(.25),coerce:e=>"function"==typeof e?e:L(e)},{key:"shape",default:L("Circle"),coerce:e=>"function"==typeof e?e:L(e)},{key:"shapeConfig",merge:!0,factory:()=>({Circle:{label:e=>{const t=e;return!(!t.parent||t.children)&&t.id},labelConfig:{fontResize:!0},opacity:e=>e.__d3plusOpacity__}})},{key:"legend",coerce:"const",factory:e=>{const t=e.schema.legend;return(i,s)=>s.length!==e._filteredData.length&&t.call(e,i,s)}},{
3658
3859
  // `on` is the event bus — Viz seeded it with the default handlers,
3659
3860
  // Pack layers wrap-and-extend versions for the events that need
3660
3861
  // pack-specific hover behavior. `merge` keeps Viz's other handlers
3661
3862
  // intact.
3662
- key:"on",merge:!0,factory:e=>{const t=e.schema.on["mousemove.legend"],i=e.schema.on["mousemove.shape"],s=t=>e.hover(t);return{mouseenter:()=>{},"mousemove.legend":(i,n,a,o)=>{t(i,n,a,o);const r=e._ids(i,n),c=un(i);s(e=>(Object.keys(e).filter(e=>"value"!==e).every(t=>{const s=i[t];return null!=s&&s.includes(e[t])})?c.push(e):r.includes(e.key)&&c.push(...un(e,[e])),c.includes(e)))},"mousemove.shape":(e,t,n,a)=>{e.__d3plusTooltip__&&i(e,t,n,a);const o=un(e,[e]);s(e=>o.includes(e))}}}}]};
3863
+ key:"on",merge:!0,factory:e=>{const t=e.schema.on["mousemove.legend"],i=e.schema.on["mousemove.shape"],s=t=>e.hover(t);return{mouseenter:()=>{},"mousemove.legend":(i,n,a,o)=>{t(i,n,a,o);const r=e._ids(i,n),c=zn(i);s(e=>(Object.keys(e).filter(e=>"value"!==e).every(t=>{const s=i[t];return null!=s&&s.includes(e[t])})?c.push(e):r.includes(e.key)&&c.push(...zn(e,[e])),c.includes(e)))},"mousemove.shape":(e,t,n,a)=>{e.__d3plusTooltip__&&i(e,t,n,a);const o=zn(e,[e]);s(e=>o.includes(e))}}}}]};
3663
3864
  /**
3664
3865
  Uses the d3 pack layout to create a Circle Packing chart based on an array of data.
3665
- */var fn=Bi(mn);
3666
- /** Greedy first-fit lane packer; mutates `d.lane` and returns total lane count. */const gn=({viz:e})=>{const i=e._filteredData;if(!i)return{shapeData:[]};const a=e.schema.start,o=e.schema.end,r=e._id,c=e.schema.axisConfig,h="time"===c?.scale,l=i.map((e,t)=>({__d3plus__:!0,data:e,end:h?n.date(o(e,t)):o(e,t),i:t,id:r(e,t),start:h?n.date(a(e,t)):a(e,t)})).filter(e=>Number(e.end)-Number(e.start)>0).sort((e,t)=>Number(e.start)-Number(t.start));let d;if(e.schema.groupBy.length>1&&e._drawDepth>0){const t=[];for(let i=0;i<e._drawDepth;i++)t.push(t=>e.schema.groupBy[i](t.data,t.i));d=s.nestGroups(l,t)}else d=[{values:l}];const u=(e=>{let t=0;return e.forEach(e=>{let i=[];e.values.forEach(e=>{i=i.map(t=>!(!1!==t&&t<=e.start)&&t);const s=i.indexOf(!1);s<0?(e.lane=t+i.length,i.push(e.end)):(i[s]=e.end,e.lane=t+s)}),t+=i.length}),t})(d);return((e,i,s)=>{const n={domain:[t.min(i,e=>Number(e.start))??0,t.max(i,e=>Number(e.end))??0],height:e.schema.height-e._margin.top-e._margin.bottom,width:e.schema.width-e._margin.left-e._margin.right},a=e.ctx.axisTest,o=e.ctx.axis;a.config(n).config(e.schema.axisConfig).measure(),o.config(n).config(e.schema.axisConfig).renderMode("compute").select(void 0).render();const r=o.toScene();var c;r&&((c=e)._chartScene||(c._chartScene=[])).push({type:"group",key:"priestley-axis",transform:{x:e._margin.left,y:e._margin.top},children:r.children??[]});const h=B.scaleBand().domain(t.range(0,s,1).map(String)).paddingInner(e.schema.paddingInner).paddingOuter(e.schema.paddingOuter).rangeRound([e.schema.height-e._margin.bottom-a.outerBounds().height-a.schema.padding,e._margin.top+a.schema.padding]);e.ctx.xScale=o._d3Scale,e.ctx.yScale=h,e.ctx.bandWidth=h.bandwidth()})(e,l,u),{shapeData:l}};
3667
- /** Runs both axes, pushes the axis scene, and stashes scales/bandWidth on `viz.ctx`. */function pn(e,t,i){return"function"==typeof e?e(t,i):e}const yn={name:"Priestley",features:[ee,Q,Z,ne],layoutStage:gn,emit:({viz:e,shapeData:t})=>{const i=t??[];if(!i.length)return[];const s=e.ctx.xScale,n=e.ctx.yScale,a=e.ctx.bandWidth,o=e.schema.shapeConfig??{};return[...i.map((e,t)=>{const i=pn(o.fill,e.data,t),r=pn(o.stroke,e.data,t),c=pn(o.strokeWidth,e.data,t),h=Math.abs(s(e.end)-s(e.start)),l=h>2?h-2:h,d=s(e.start)+(s(e.end)-s(e.start))/2-l/2,u=(n(String(e.lane))??0)+a/2;return{type:"rect",shapeType:"Bar",key:`priestley-${e.id}-${t}`,transform:{x:d,y:u},x:0,y:-a/2,width:l,height:a,datum:e.data,paint:{fill:"string"==typeof i?i:void 0,stroke:r,strokeWidth:c}}}),...Rs({data:i,label:(t,s)=>e._drawLabel(i[s].data,s),x:(e,t)=>{const n=i[t];return s(n.start)+(s(n.end)-s(n.start))/2},y:(e,t)=>(n(String(i[t].lane))??0)+a/2,aes:(e,t)=>{const n=i[t],o=Math.abs(s(n.end)-s(n.start));return{width:o>2?o-2:o,height:a}},rotate:L(0),id:(e,t)=>`priestley-label-${i[t].id}-${t}`,labelBounds:(e,t,i)=>{const{width:s,height:n}=i;return{x:-s/2,y:-n/2,width:s,height:n}},labelConfig:{fontColor:e=>{const t=e.data??e,i=pn(o.fill,t.data,t.i);return u.colorContrast("string"==typeof i?i:"rgb(255, 255, 255)")},fontResize:!1,textAnchor:"start",verticalAlign:"top"}})]},
3866
+ */var Mn=Ri(Dn);
3867
+ /** Greedy first-fit lane packer; mutates `d.lane` and returns total lane count. */const An=({viz:e})=>{const i=e._filteredData;if(!i)return{shapeData:[]};const a=e.schema.start,o=e.schema.end,r=e._id,c=e.schema.axisConfig,h="time"===c?.scale,l=i.map((e,t)=>({__d3plus__:!0,data:e,end:h?n.date(o(e,t)):o(e,t),i:t,id:r(e,t),start:h?n.date(a(e,t)):a(e,t)})).filter(e=>Number(e.end)-Number(e.start)>0).sort((e,t)=>Number(e.start)-Number(t.start));let d;if(e.schema.groupBy.length>1&&e._drawDepth>0){const t=[];for(let i=0;i<e._drawDepth;i++)t.push(t=>e.schema.groupBy[i](t.data,t.i));d=s.nestGroups(l,t)}else d=[{values:l}];const u=(e=>{let t=0;return e.forEach(e=>{let i=[];e.values.forEach(e=>{i=i.map(t=>!(!1!==t&&t<=e.start)&&t);const s=i.indexOf(!1);s<0?(e.lane=t+i.length,i.push(e.end)):(i[s]=e.end,e.lane=t+s)}),t+=i.length}),t})(d);return((e,i,s)=>{const n={domain:[t.min(i,e=>Number(e.start))??0,t.max(i,e=>Number(e.end))??0],height:e.schema.height-e._margin.top-e._margin.bottom,width:e.schema.width-e._margin.left-e._margin.right},a=e.ctx.axisTest,o=e.ctx.axis;a.config(n).config(e.schema.axisConfig).measure(),o.config(n).config(e.schema.axisConfig).renderMode("compute").select(void 0).render();const r=o.toScene();var c;r&&((c=e)._chartScene||(c._chartScene=[])).push({type:"group",key:"priestley-axis",transform:{x:e._margin.left,y:e._margin.top},children:r.children??[]});const h=B.scaleBand().domain(t.range(0,s,1).map(String)).paddingInner(e.schema.paddingInner).paddingOuter(e.schema.paddingOuter).rangeRound([e.schema.height-e._margin.bottom-a.outerBounds().height-a.schema.padding,e._margin.top+a.schema.padding]);e.ctx.xScale=o._d3Scale,e.ctx.yScale=h,e.ctx.bandWidth=h.bandwidth()})(e,l,u),{shapeData:l}};
3868
+ /** Runs both axes, pushes the axis scene, and stashes scales/bandWidth on `viz.ctx`. */function $n(e,t,i){return"function"==typeof e?e(t,i):e}const Bn={name:"Priestley",features:[ee,Q,Z,ne],layoutStage:An,emit:({viz:e,shapeData:t})=>{const i=t??[];if(!i.length)return[];const s=e.ctx.xScale,n=e.ctx.yScale,a=e.ctx.bandWidth,o=e.schema.shapeConfig??{};return[...i.map((e,t)=>{const i=$n(o.fill,e.data,t),r=$n(o.stroke,e.data,t),c=$n(o.strokeWidth,e.data,t),h=Math.abs(s(e.end)-s(e.start)),l=h>2?h-2:h,d=s(e.start)+(s(e.end)-s(e.start))/2-l/2,u=(n(String(e.lane))??0)+a/2;return{type:"rect",shapeType:"Bar",key:`priestley-${e.id}-${t}`,transform:{x:d,y:u},x:0,y:-a/2,width:l,height:a,datum:e.data,paint:{fill:"string"==typeof i?i:void 0,stroke:r,strokeWidth:c}}}),...Xs({data:i,label:(t,s)=>e._drawLabel(i[s].data,s),x:(e,t)=>{const n=i[t];return s(n.start)+(s(n.end)-s(n.start))/2},y:(e,t)=>(n(String(i[t].lane))??0)+a/2,aes:(e,t)=>{const n=i[t],o=Math.abs(s(n.end)-s(n.start));return{width:o>2?o-2:o,height:a}},rotate:L(0),id:(e,t)=>`priestley-label-${i[t].id}-${t}`,labelBounds:(e,t,i)=>{const{width:s,height:n}=i;return{x:-s/2,y:-n/2,width:s,height:n}},labelConfig:{fontColor:e=>{const t=e.data??e,i=$n(o.fill,t.data,t.i);return u.colorContrast("string"==typeof i?i:"rgb(255, 255, 255)")},fontResize:!1,textAnchor:"start",verticalAlign:"top"}})]},
3668
3869
  // Priestley positions in absolute scale coordinates — no chart transform.
3669
3870
  chartTransform:()=>{},
3670
3871
  // The default start/end accessors are functions, so the fields' `onSet`
3671
3872
  // can't infer a data key to register. Seed the band-edge reducers here so
3672
3873
  // the time domain spans min(start)…max(end) instead of summing them.
3673
- setup:e=>{e.schema.aggs.start||(e.schema.aggs.start=t.min),e.schema.aggs.end||(e.schema.aggs.end=t.max)},ctx:{axis:(new xt).align("end").orient("bottom"),axisTest:(new xt).align("end").gridSize(0).orient("bottom")},fields:[{key:"paddingInner",default:.05},{key:"paddingOuter",default:.05},{key:"axisConfig",merge:!0,default:{scale:"time"}},{key:"end",default:F("end"),coerce:e=>"function"==typeof e?e:F(e),onSet:(e,i)=>{
3874
+ setup:e=>{e.schema.aggs.start||(e.schema.aggs.start=t.min),e.schema.aggs.end||(e.schema.aggs.end=t.max)},ctx:{axis:(new Ct).align("end").orient("bottom"),axisTest:(new Ct).align("end").gridSize(0).orient("bottom")},fields:[{key:"paddingInner",default:.05},{key:"paddingOuter",default:.05},{key:"axisConfig",merge:!0,default:{scale:"time"}},{key:"end",default:F("end"),coerce:e=>"function"==typeof e?e:F(e),onSet:(e,i)=>{
3674
3875
  // String accessor → also seed a default aggregation (max) for that key.
3675
3876
  const s="function"==typeof i?null:i;s&&!e.schema.aggs[s]&&(e.schema.aggs[s]=t.max)}},{key:"start",default:F("start"),coerce:e=>"function"==typeof e?e:F(e),onSet:(e,i)=>{const s="function"==typeof i?null:i;s&&!e.schema.aggs[s]&&(e.schema.aggs[s]=t.min)}},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,i)=>{const s=e.schema.start(t,i),n=e.schema.end(t,i);return`${e._drawLabel(t,i)}, ${s} - ${n}.`}})}]};
3676
3877
  /**
3677
3878
  Creates a Priestley timeline based on an array of data.
3678
3879
  */
3679
- var _n=Bi(yn);const xn=2*Math.PI,bn=({viz:e})=>{const{width:n,height:a}=le(e),o=e.schema.outerPadding,r=e.schema.levels,c=e.schema.metric,h=e.schema.value,l=e.schema.axisConfig,d=(t.min([a,n])??0)/2-o,u=Math.max(0,d),m=e._filteredData,f=t.groups(m,c),g=t.groups(m,e._id,c),p=t.max(g.map(([,e])=>e.map(([,e])=>t.sum(e,(e,t)=>h(e,t)))).flat());if(!p)return e.ctx.groupData=[],e.ctx.pathConfig={},{shapeData:[]};
3880
+ var Pn=Ri(Bn);const Tn=2*Math.PI,On=({viz:e})=>{const{width:n,height:a}=le(e),o=e.schema.outerPadding,r=e.schema.levels,c=e.schema.metric,h=e.schema.value,l=e.schema.axisConfig,d=(t.min([a,n])??0)/2-o,u=Math.max(0,d),m=e._filteredData,f=t.groups(m,c),g=t.groups(m,e._id,c),p=t.max(g.map(([,e])=>e.map(([,e])=>t.sum(e,(e,t)=>h(e,t)))).flat());if(!p)return e.ctx.groupData=[],e.ctx.pathConfig={},{shapeData:[]};
3680
3881
  // Decorations: emitted as flat SceneNodes onto `_chartScene` (the
3681
3882
  // chart-transformed group). Replaces the old `absorbShapeIntoChartScene`
3682
3883
  // calls that span up transient `Circle`/`Rect`/`Path` instances in
3683
3884
  // compute mode.
3684
- const y=Array.isArray(e._chartScene)?e._chartScene:e._chartScene=[],_=l.shapeConfig??{};((e,t,i,s,n)=>{const a=Ei(e,"Circle",i);delete a.label;
3885
+ const y=Array.isArray(e._chartScene)?e._chartScene:e._chartScene=[],_=l.shapeConfig??{};((e,t,i,s,n)=>{const a=Hi(e,"Circle",i);delete a.label;
3685
3886
  // Background concentric circles, one per level.
3686
- const o=[];for(let e=0;e<s;e++){const t=n*((e+1)/s),i={id:e,r:t},r=Li(a,i,e);o.push({type:"circle",key:`radar-radial-${e}`,cx:0,cy:0,r:t,datum:i,paint:r})}o.length&&t.push({type:"group",key:"radar-radial-circles",children:o})})(e,y,_,r,u);const x=e.schema.shapeConfig?.labelConfig,b=f.length,k=f.map(([t,i],n)=>{const a=2*(1.4*(x?.fontSize?.(i,n)??11)),r=o,c=parseInt(String(360-360/b*n/90),10)%4+1,h=xn/b*n;let l=360/b*n,d="start",m=10;2!==c&&3!==c||(m=-r-10,d="end",l+=180);const f={x:m,y:-a/2,width:r,height:a};return{__d3plus__:!0,data:s.merge(i,e.schema.aggs),i:n,id:t,key:t,angle:l,textAnchor:d,labelBounds:f,rotateAnchor:[-m,a/2],x:u*Math.cos(h),y:u*Math.sin(h)}}).sort((e,t)=>Number(e.key)-Number(t.key));((e,t,i,s,n)=>{
3887
+ const o=[];for(let e=0;e<s;e++){const t=n*((e+1)/s),i={id:e,r:t},r=Ni(a,i,e);o.push({type:"circle",key:`radar-radial-${e}`,cx:0,cy:0,r:t,datum:i,paint:r})}o.length&&t.push({type:"group",key:"radar-radial-circles",children:o})})(e,y,_,r,u);const x=e.schema.shapeConfig?.labelConfig,b=f.length,k=f.map(([t,i],n)=>{const a=2*(1.4*(x?.fontSize?.(i,n)??11)),r=o,c=parseInt(String(360-360/b*n/90),10)%4+1,h=Tn/b*n;let l=360/b*n,d="start",m=10;2!==c&&3!==c||(m=-r-10,d="end",l+=180);const f={x:m,y:-a/2,width:r,height:a};return{__d3plus__:!0,data:s.merge(i,e.schema.aggs),i:n,id:t,key:t,angle:l,textAnchor:d,labelBounds:f,rotateAnchor:[-m,a/2],x:u*Math.cos(h),y:u*Math.sin(h)}}).sort((e,t)=>Number(e.key)-Number(t.key));((e,t,i,s,n)=>{
3687
3888
  // Axis labels: one TextNode per axis, positioned at the axis vertex,
3688
3889
  // rotated to read along the spoke. The original code used a Rect with
3689
3890
  // zero width/height + label; here we emit only labels.
3690
- const a=Rs({data:n,label:e=>e.id,x:e=>e.x,y:e=>e.y,aes:()=>({}),rotate:e=>e.angle||0,id:e=>e.id,labelBounds:e=>e.labelBounds,labelConfig:i.shapeConfig?.labelConfig??{}});a.length&&t.push({type:"group",key:"radar-axis-labels",children:a});
3891
+ const a=Xs({data:n,label:e=>e.id,x:e=>e.x,y:e=>e.y,aes:()=>({}),rotate:e=>e.angle||0,id:e=>e.id,labelBounds:e=>e.labelBounds,labelConfig:i.shapeConfig?.labelConfig??{}});a.length&&t.push({type:"group",key:"radar-axis-labels",children:a});
3691
3892
  // Radial spokes: one Path from center to each axis vertex.
3692
- const o=Ei(e,"Path",s),r=n.map((e,t)=>{const i=Li(o,e,t);return{type:"path",key:`radar-spoke-${e.id}`,d:`M0,0 ${-e.x},${-e.y}`,datum:e,paint:i}});r.length&&t.push({type:"group",key:"radar-axis-spokes",children:r})})(e,y,l,_,k);const v=g.map(([i,n])=>{const a=n.map(([,e],i)=>{const s=t.sum(e,(e,t)=>h(e,t))/p*u,n=xn/b*i;return{x:s*Math.cos(n),y:s*Math.sin(n)}}),o=`M ${a[0].x} ${a[0].y} ${a.map(e=>`L ${e.x} ${e.y}`).join(" ")} L ${a[0].x} ${a[0].y}`,r=e.schema.aggs;return{__d3plus__:!0,arr:n.map(([,e])=>s.merge(e,r)),id:i,points:a,d:o,data:s.merge(n.map(([,e])=>s.merge(e,r)),r)}}),C=((e,s,n)=>{const a=Ei(e,"Path"),o=Object.keys(a.on??{});
3893
+ const o=Hi(e,"Path",s),r=n.map((e,t)=>{const i=Ni(o,e,t);return{type:"path",key:`radar-spoke-${e.id}`,d:`M0,0 ${-e.x},${-e.y}`,datum:e,paint:i}});r.length&&t.push({type:"group",key:"radar-axis-spokes",children:r})})(e,y,l,_,k);const v=g.map(([i,n])=>{const a=n.map(([,e],i)=>{const s=t.sum(e,(e,t)=>h(e,t))/p*u,n=Tn/b*i;return{x:s*Math.cos(n),y:s*Math.sin(n)}}),o=`M ${a[0].x} ${a[0].y} ${a.map(e=>`L ${e.x} ${e.y}`).join(" ")} L ${a[0].x} ${a[0].y}`,r=e.schema.aggs;return{__d3plus__:!0,arr:n.map(([,e])=>s.merge(e,r)),id:i,points:a,d:o,data:s.merge(n.map(([,e])=>s.merge(e,r)),r)}}),C=((e,s,n)=>{const a=Hi(e,"Path"),o=Object.keys(a.on??{});
3693
3894
  // Event-handler wrappers: cursor → nearest polygon vertex resolution.
3694
- a.on={};for(const r of o)a.on[r]=(a,o,c,h)=>{const l=a.points.map(e=>e.x+s/2),d=a.points.map(e=>e.y+n/2),u=i.pointer(h,e._select.node()),m=l.map(e=>Math.abs(e-u[0])),f=d.map(e=>Math.abs(e-u[1])),g=m.map((e,t)=>e+f[t]);e.schema.on[r].call(e,a.arr[g.indexOf(t.min(g))],o,c,h)};return a})(e,n,a);return e.ctx.groupData=v,e.ctx.pathConfig=C,{shapeData:v}},kn={name:"Radar",features:[ee,Q,Z,ne],layoutStage:bn,emit:({viz:e})=>{const t=e.ctx.groupData,i=e.ctx.pathConfig;if(!t||!i||!t.length)return[];const s=[];for(let e=0;e<t.length;e++){const n=t[e],a=n.data??n,o=Li(i,a,e);s.push({type:"path",key:`radar-${n.id}`,d:n.d,datum:a,paint:o})}return s},chartTransform:e=>{const{width:t,height:i}=le(e);return de(e,t,i)},ctx:{},fields:[{key:"discrete",default:"metric"},{key:"levels",default:6},{key:"metric",default:F("metric"),coerce:e=>"function"==typeof e?e:F(e)},{key:"outerPadding",default:100},{key:"shape",default:L("Path")},{key:"value",default:F("value"),coerce:e=>"function"==typeof e?e:F(e)},{key:"axisConfig",merge:!0,factory:e=>({shapeConfig:{fill:L("none"),labelConfig:{fontColor:()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return u.colorContrast(t)},fontResize:!1,padding:0,textAnchor:e=>e.data?.textAnchor??"middle",verticalAlign:"middle"},stroke:()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return u.colorContrast(t)},strokeWidth:L(1)}})}]};
3895
+ a.on={};for(const r of o)a.on[r]=(a,o,c,h)=>{const l=a.points.map(e=>e.x+s/2),d=a.points.map(e=>e.y+n/2),u=i.pointer(h,e._select.node()),m=l.map(e=>Math.abs(e-u[0])),f=d.map(e=>Math.abs(e-u[1])),g=m.map((e,t)=>e+f[t]);e.schema.on[r].call(e,a.arr[g.indexOf(t.min(g))],o,c,h)};return a})(e,n,a);return e.ctx.groupData=v,e.ctx.pathConfig=C,{shapeData:v}},Rn={name:"Radar",features:[ee,Q,Z,ne],layoutStage:On,emit:({viz:e})=>{const t=e.ctx.groupData,i=e.ctx.pathConfig;if(!t||!i||!t.length)return[];const s=[];for(let e=0;e<t.length;e++){const n=t[e],a=n.data??n,o=Ni(i,a,e);s.push({type:"path",key:`radar-${n.id}`,d:n.d,datum:a,paint:o})}return s},chartTransform:e=>{const{width:t,height:i}=le(e);return de(e,t,i)},ctx:{},fields:[{key:"discrete",default:"metric"},{key:"levels",default:6},{key:"metric",default:F("metric"),coerce:e=>"function"==typeof e?e:F(e)},{key:"outerPadding",default:100},{key:"shape",default:L("Path"),coerce:"const"},{key:"value",default:F("value"),coerce:e=>"function"==typeof e?e:F(e)},{key:"axisConfig",merge:!0,factory:e=>({shapeConfig:{fill:L("none"),labelConfig:{fontColor:()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return u.colorContrast(t)},fontResize:!1,padding:0,textAnchor:e=>e.data?.textAnchor??"middle",verticalAlign:"middle"},stroke:()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return u.colorContrast(t)},strokeWidth:L(1)}})}]};
3695
3896
  /** Emits background concentric circles, one per level, onto `chartScene`. */
3696
3897
  /**
3697
3898
  Creates a radar visualization based on an array of data.
3698
3899
  */
3699
- var vn=Bi(kn);const Cn=2*Math.PI,Sn=({viz:e})=>{const{rowValues:i,columnValues:s,shapeData:n}=Us.bind(e)(e._filteredData),{width:a,height:o}=le(e);if(!i.length||!s.length)return e.ctx.radialMatrixWidth=a,e.ctx.radialMatrixHeight=o,{shapeData:[]};e.ctx.radialMatrixWidth=a,e.ctx.radialMatrixHeight=o;const r=100,c=(t.min([o-100,a-200])??0)/2,h=s.slice().reverse();h.unshift(h.pop());const l=h.length,d=h.map((e,t)=>{const i=t/l*Cn,s=Math.round(180*i/Math.PI),n=Math.floor((s+90)/90%4+1),a=[0,180].includes(s)?-50:[2,3].includes(n)?-100:0,o=[90,270].includes(s)?-25:[2,1].includes(n)?-50:0;return{key:e,angle:s,quadrant:n,radians:i,x:c*Math.sin(i+Math.PI)+a,y:c*Math.cos(i+Math.PI)+o}}),u=e.schema.columnConfig;((e,t,i,s,n)=>{const a=e.ctx.columnLabels;a.renderMode("compute").select(void 0).data(t).x(e=>e.x).y(e=>e.y).text(e=>e.key).width(i).height(s).config(n).render();const o=a.toScene();var r;o&&((r=e)._chartScene||(r._chartScene=[])).push({type:"group",key:"radialmatrix-columns",children:o.children??[]})})(e,u.labels instanceof Array?d.filter(e=>u.labels.includes(e.key)):d,r,50,u.shapeConfig?.labelConfig);const m=(0,e.schema.innerRadius)(c),f=(c-m)/i.length,g=d.length>1?d[1].radians-d[0].radians:Cn,p=i.slice().reverse(),y=new Map;p.forEach((e,t)=>y.set(e,t));const _=new Map;s.forEach((e,t)=>_.set(e,t));const x=e.schema.cellPadding,b=P.arc().padAngle(x/c).innerRadius(e=>m+(y.get(e.row)??0)*f+x/2).outerRadius(e=>m+((y.get(e.row)??0)+1)*f-x/2).startAngle(e=>d[_.get(e.column)??0].radians-g/2).endAngle(e=>d[_.get(e.column)??0].radians+g/2);return e.ctx.arcData=b,{shapeData:n}};
3900
+ var Ln=Ri(Rn);const En=2*Math.PI,Fn=({viz:e})=>{const{rowValues:i,columnValues:s,shapeData:n}=dn.bind(e)(e._filteredData),{width:a,height:o}=le(e);if(!i.length||!s.length)return e.ctx.radialMatrixWidth=a,e.ctx.radialMatrixHeight=o,{shapeData:[]};e.ctx.radialMatrixWidth=a,e.ctx.radialMatrixHeight=o;const r=100,c=(t.min([o-100,a-200])??0)/2,h=s.slice().reverse();h.unshift(h.pop());const l=h.length,d=h.map((e,t)=>{const i=t/l*En,s=Math.round(180*i/Math.PI),n=Math.floor((s+90)/90%4+1),a=[0,180].includes(s)?-50:[2,3].includes(n)?-100:0,o=[90,270].includes(s)?-25:[2,1].includes(n)?-50:0;return{key:e,angle:s,quadrant:n,radians:i,x:c*Math.sin(i+Math.PI)+a,y:c*Math.cos(i+Math.PI)+o}}),u=e.schema.columnConfig;((e,t,i,s,n)=>{const a=e.ctx.columnLabels;a.renderMode("compute").select(void 0).data(t).x(e=>e.x).y(e=>e.y).text(e=>e.key).width(i).height(s).config(n).render();const o=a.toScene();var r;o&&((r=e)._chartScene||(r._chartScene=[])).push({type:"group",key:"radialmatrix-columns",children:o.children??[]})})(e,u.labels instanceof Array?d.filter(e=>u.labels.includes(e.key)):d,r,50,u.shapeConfig?.labelConfig);const m=(0,e.schema.innerRadius)(c),f=(c-m)/i.length,g=d.length>1?d[1].radians-d[0].radians:En,p=i.slice().reverse(),y=new Map;p.forEach((e,t)=>y.set(e,t));const _=new Map;s.forEach((e,t)=>_.set(e,t));const x=e.schema.cellPadding,b=P.arc().padAngle(x/c).innerRadius(e=>m+(y.get(e.row)??0)*f+x/2).outerRadius(e=>m+((y.get(e.row)??0)+1)*f-x/2).startAngle(e=>d[_.get(e.column)??0].radians-g/2).endAngle(e=>d[_.get(e.column)??0].radians+g/2);return e.ctx.arcData=b,{shapeData:n}};
3700
3901
  /** Renders the column-label TextBox in compute mode and absorbs it into `_chartScene`. */
3701
3902
  /**
3702
3903
  `radialMatrixEmit` — Path SceneNodes for each arc cell, using the
3703
3904
  `arcData` generator stashed on `viz.ctx`.
3704
3905
  */
3705
- function wn(e,t,i){return"function"==typeof e?e(t,i):e}const zn=(e,t)=>`${e}`.localeCompare(`${t}`),Dn={name:"RadialMatrix",features:[ee,Q,Z,ne],layoutStage:Sn,emit:({viz:e,shapeData:t})=>{const i=t??[];if(!i.length)return[];const s=e.ctx.arcData,n=e.schema.shapeConfig??{};return i.map((t,i)=>{const a=wn(n.fill,t,i),o=wn(n.stroke,t,i),r=wn(n.strokeWidth,t,i);return{type:"path",key:`rm-${e._ids(t,i).join("-")}`,d:s(t),datum:t,paint:{fill:"string"==typeof a?a:void 0,stroke:o,strokeWidth:r}}})},chartTransform:e=>de(e,e.ctx.radialMatrixWidth,e.ctx.radialMatrixHeight),setup:e=>{const t=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(i,s,n,a)=>{
3906
+ function Wn(e,t,i){return"function"==typeof e?e(t,i):e}const Nn=(e,t)=>`${e}`.localeCompare(`${t}`),Hn={name:"RadialMatrix",features:[ee,Q,Z,ne],layoutStage:Fn,emit:({viz:e,shapeData:t})=>{const i=t??[];if(!i.length)return[];const s=e.ctx.arcData,n=e.schema.shapeConfig??{};return i.map((t,i)=>{const a=Wn(n.fill,t,i),o=Wn(n.stroke,t,i),r=Wn(n.strokeWidth,t,i);return{type:"path",key:`rm-${e._ids(t,i).join("-")}`,d:s(t),datum:t,paint:{fill:"string"==typeof a?a:void 0,stroke:o,strokeWidth:r}}})},chartTransform:e=>de(e,e.ctx.radialMatrixWidth,e.ctx.radialMatrixHeight),setup:e=>{const t=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(i,s,n,a)=>{
3706
3907
  // A colorScale swatch routes through the shape path but has no row/column,
3707
3908
  // so its row/column hover would match nothing and wipe out the bucket
3708
3909
  // highlight `mouseenter` already set. Leave that highlight in place.
3709
- if(t(i,s,n,a),_e(n)||_e(i))return;const o=I.bind(e)("row",i,s),r=I.bind(e)("column",i,s);e.hover((t,i)=>I.bind(e)("row",t,i)===o||I.bind(e)("column",t,i)===r)}},ctx:{columnLabels:new Wt},fields:[{key:"cellPadding",default:2},{key:"column",default:F("column"),coerce:e=>"function"==typeof e?e:F(e)},{key:"row",default:F("row"),coerce:e=>"function"==typeof e?e:F(e)},{key:"columnList"},{key:"rowList"},{key:"columnSort",default:zn},{key:"rowSort",default:zn},{key:"innerRadius",default:e=>e/5,coerce:e=>"function"==typeof e?e:L(e)},{key:"columnConfig",merge:!0,factory:e=>({shapeConfig:{labelConfig:{fontColor:()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return u.colorContrast(t)},padding:5,textAnchor:e=>[0,180].includes(e.angle)?"middle":[2,3].includes(e.quadrant)?"end":"start",verticalAlign:e=>[90,270].includes(e.angle)?"middle":[2,1].includes(e.quadrant)?"bottom":"top"}}})},{key:"label",factory:e=>(t,i)=>`${I.bind(e)("row",t,i)} / ${I.bind(e)("column",t,i)}`}]};
3910
+ if(t(i,s,n,a),_e(n)||_e(i))return;const o=I.bind(e)("row",i,s),r=I.bind(e)("column",i,s);e.hover((t,i)=>I.bind(e)("row",t,i)===o||I.bind(e)("column",t,i)===r)}},ctx:{columnLabels:new Gt},fields:[{key:"cellPadding",default:2},{key:"column",default:F("column"),coerce:e=>"function"==typeof e?e:F(e)},{key:"row",default:F("row"),coerce:e=>"function"==typeof e?e:F(e)},{key:"columnList"},{key:"rowList"},{key:"columnSort",default:Nn},{key:"rowSort",default:Nn},{key:"innerRadius",default:e=>e/5,coerce:e=>"function"==typeof e?e:L(e)},{key:"columnConfig",merge:!0,factory:e=>({shapeConfig:{labelConfig:{fontColor:()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return u.colorContrast(t)},padding:5,textAnchor:e=>[0,180].includes(e.angle)?"middle":[2,3].includes(e.quadrant)?"end":"start",verticalAlign:e=>[90,270].includes(e.angle)?"middle":[2,1].includes(e.quadrant)?"bottom":"top"}}})},{key:"label",coerce:"const",factory:e=>(t,i)=>`${I.bind(e)("row",t,i)} / ${I.bind(e)("column",t,i)}`}]};
3710
3911
  /**
3711
3912
  Creates a radial layout of a rows/columns Matrix of any dataset.
3712
3913
  */
3713
- var Mn=Bi(Dn);
3914
+ var jn=Ri(Hn);
3714
3915
  /** Shared empty `ringsCtx` value for the early-return branches. */
3715
3916
  /**
3716
3917
  Claim the center node + two rings, compute each node's angle/position, build
3717
3918
  the radius scale, and size every node. Returns the rebuilt `nodes` array
3718
3919
  plus the `primaries`/`secondaries` rings.
3719
3920
  */
3720
- function An(e,i,s,n,a,o){const{width:r,height:c,primaryRing:h,secondaryRing:l}=a;n.x=r/2,n.y=c/2,n.r=e.schema.sizeMin?t.max([e.schema.sizeMin,.65*h]):e.schema.sizeMax?t.min([e.schema.sizeMax,.65*h]):.65*h;const d=[n],u=[];(s[e.schema.center]||[]).forEach(t=>{const i=t.source.id===e.schema.center?t.target:t.source;i.edges=s[i.id].filter(t=>t.source.id!==e.schema.center||t.target.id!==e.schema.center),i.edge=t,d.push(i),u.push(i)}),u.sort((e,t)=>e.edges.length-t.edges.length);const m=[];let f=0;u.forEach(e=>{const t=e.id;e.edges=e.edges.filter(e=>!d.includes(e.source)&&e.target.id===t||!d.includes(e.target)&&e.source.id===t),f+=e.edges.length||1,e.edges.forEach(e=>{const{source:i,target:s}=e,n=s.id===t?i:s;d.push(n)})});const g=2*Math.PI;let p=0;u.forEach((e,t)=>{const i=e.edges,s=i.length||1,n=g/f*s;0===t&&(p-=n/2);const a=p+n/2-g/4;e.radians=a,e.x=r/2+h*Math.cos(a),e.y=c/2+h*Math.sin(a),p+=n,i.forEach((t,i)=>{const n=t.source.id===e.id?t.target:t.source,o=g/f,h=a-o*s/2+o/2+o*i;n.radians=h,n.x=r/2+l*Math.cos(h),n.y=c/2+l*Math.sin(h),m.push(n)})}),
3921
+ function Gn(e,i,s,n,a,o){const{width:r,height:c,primaryRing:h,secondaryRing:l}=a;n.x=r/2,n.y=c/2,n.r=e.schema.sizeMin?t.max([e.schema.sizeMin,.65*h]):e.schema.sizeMax?t.min([e.schema.sizeMax,.65*h]):.65*h;const d=[n],u=[];(s[e.schema.center]||[]).forEach(t=>{const i=t.source.id===e.schema.center?t.target:t.source;i.edges=s[i.id].filter(t=>t.source.id!==e.schema.center||t.target.id!==e.schema.center),i.edge=t,d.push(i),u.push(i)}),u.sort((e,t)=>e.edges.length-t.edges.length);const m=[];let f=0;u.forEach(e=>{const t=e.id;e.edges=e.edges.filter(e=>!d.includes(e.source)&&e.target.id===t||!d.includes(e.target)&&e.source.id===t),f+=e.edges.length||1,e.edges.forEach(e=>{const{source:i,target:s}=e,n=s.id===t?i:s;d.push(n)})});const g=2*Math.PI;let p=0;u.forEach((e,t)=>{const i=e.edges,s=i.length||1,n=g/f*s;0===t&&(p-=n/2);const a=p+n/2-g/4;e.radians=a,e.x=r/2+h*Math.cos(a),e.y=c/2+h*Math.sin(a),p+=n,i.forEach((t,i)=>{const n=t.source.id===e.id?t.target:t.source,o=g/f,h=a-o*s/2+o/2+o*i;n.radians=h,n.x=r/2+l*Math.cos(h),n.y=c/2+l*Math.sin(h),m.push(n)})}),
3721
3922
  /**
3722
3923
  Build the radius scale from the size extent (or ring defaults) and assign
3723
3924
  each ring node its `ring` + `r`. Mutates `center.r` and every ring node.
@@ -3726,7 +3927,7 @@ function(e,i,s,n,a,o){const{ringWidth:r}=s,c=r/2,h=r/4;let l=c/2-4;c/2-4<8&&(l=t
3726
3927
  /**
3727
3928
  Resolve link endpoints to placed nodes, compute bezier control points for
3728
3929
  spline edges, and push every edge onto `edges` (mutated in place).
3729
- */(e,n,a,o,u,m);return{nodes:[n].concat(u).concat(m),primaries:u,secondaries:m}}const $n=({viz:e})=>{const i=e;if(Array.isArray(i._filteredData)||(i._filteredData=[]),Array.isArray(i.schema.nodes)||(i.schema.nodes=[]),Array.isArray(i.schema.links)||(i.schema.links=[]),!i._filteredData.length&&!i.schema.nodes.length&&!i.schema.links.length)return i.ctx.nodeLookup={},i.ctx.linkLookup={},i.ctx.ringsCtx={edges:[],nodeGroups:[],linkConfig:{},linkD:()=>"",nodeShapeConfig:{}},{viz:e};const s=i._filteredData.reduce((e,t,s)=>(e[i._id(t,s)]=t,e),{}),{nodeLookup:a,links:o,linkMap:r}=
3930
+ */(e,n,a,o,u,m);return{nodes:[n].concat(u).concat(m),primaries:u,secondaries:m}}const In=({viz:e})=>{const i=e;if(Array.isArray(i._filteredData)||(i._filteredData=[]),Array.isArray(i.schema.nodes)||(i.schema.nodes=[]),Array.isArray(i.schema.links)||(i.schema.links=[]),!i._filteredData.length&&!i.schema.nodes.length&&!i.schema.links.length)return i.ctx.nodeLookup={},i.ctx.linkLookup={},i.ctx.ringsCtx={edges:[],nodeGroups:[],linkConfig:{},linkD:()=>"",nodeShapeConfig:{}},{viz:e};const s=i._filteredData.reduce((e,t,s)=>(e[i._id(t,s)]=t,e),{}),{nodeLookup:a,links:o,linkMap:r}=
3730
3931
  /**
3731
3932
  Build the Rings node set + link descriptors from filtered data and schema
3732
3933
  nodes/links. Stashes `nodeLookup` on `viz.ctx` and returns the working
@@ -3744,17 +3945,17 @@ const n=a[s];if(n)return n;if(!isNaN(s)){const e=a[parseFloat(s)];if(e)return e}
3744
3945
  // the raw value, then its coerced form.
3745
3946
  let f=a[i.schema.center];if(f||null==i.schema.center||isNaN(i.schema.center)||(f=a[parseFloat(i.schema.center)]),!f)return i.ctx.ringsCtx={edges:[],nodeGroups:[],linkConfig:{},linkD:()=>"",nodeShapeConfig:{}},{viz:e};
3746
3947
  // Normalize so downstream comparisons against node ids use the matched id.
3747
- i.schema.center=f.id;const{nodes:g,primaries:p,secondaries:y}=An(i,0,r,f,m,s);return function(e,t,i,s,n,a,o,r){const{width:c,height:h,ringWidth:l,primaryRing:d,secondaryRing:u}=o;i.forEach(e=>{const o=e.edge;["source","target"].forEach(e=>{o[e]=t.find(t=>t.id===o[e].id)}),r.push(o),n[e.id].forEach(n=>{const o=n.source.id===e.id?n.target:n.source;if(o.id===a.id)return;let m=s.find(e=>e.id===o.id);if(m||(m=i.find(e=>e.id===o.id)),!m)return;n.spline=!0;const f=c/2,g=h/2,p=d+.5*(u-d);["source","target"].forEach((i,s)=>{const a=n[i],o=a.radians,r=a.ring,c=a.x,h=a.y,d=a.r,u=2===r?o+Math.PI:o;n[`${i}X`]=c+Math.cos(u)*d,n[`${i}Y`]=h+Math.sin(u)*d,n[`${i}BisectX`]=f+p*Math.cos(o),n[`${i}BisectY`]=g+p*Math.sin(o),n[i]=t.find(e=>e.id===a.id);const y=n[i];void 0===y.edges&&(y.edges={});const _=0===s?n.target.id:n.source.id,x=y.edges;y.id===e.id?x[_]={angle:e.radians+Math.PI,radius:l/2}:x[_]={angle:m.radians,radius:l/2}}),r.push(n)})})}
3948
+ i.schema.center=f.id;const{nodes:g,primaries:p,secondaries:y}=Gn(i,0,r,f,m,s);return function(e,t,i,s,n,a,o,r){const{width:c,height:h,ringWidth:l,primaryRing:d,secondaryRing:u}=o;i.forEach(e=>{const o=e.edge;["source","target"].forEach(e=>{o[e]=t.find(t=>t.id===o[e].id)}),r.push(o),n[e.id].forEach(n=>{const o=n.source.id===e.id?n.target:n.source;if(o.id===a.id)return;let m=s.find(e=>e.id===o.id);if(m||(m=i.find(e=>e.id===o.id)),!m)return;n.spline=!0;const f=c/2,g=h/2,p=d+.5*(u-d);["source","target"].forEach((i,s)=>{const a=n[i],o=a.radians,r=a.ring,c=a.x,h=a.y,d=a.r,u=2===r?o+Math.PI:o;n[`${i}X`]=c+Math.cos(u)*d,n[`${i}Y`]=h+Math.sin(u)*d,n[`${i}BisectX`]=f+p*Math.cos(o),n[`${i}BisectY`]=g+p*Math.sin(o),n[i]=t.find(e=>e.id===a.id);const y=n[i];void 0===y.edges&&(y.edges={});const _=0===s?n.target.id:n.source.id,x=y.edges;y.id===e.id?x[_]={angle:e.radians+Math.PI,radius:l/2}:x[_]={angle:m.radians,radius:l/2}}),r.push(n)})})}
3748
3949
  /** Compute each node's label bounds, rotation, and text anchor (mutated in place). */(0,g,p,y,r,f,m,l),function(e,t,i){const{primaryRing:s,ringWidth:n}=i;t.forEach(t=>{if(t.id===e.schema.center)return void(t.labelBounds={x:-s/2,y:-s/2,width:s,height:s});const i=e.schema.shapeConfig.labelConfig,a=1.4*(i?.fontSize&&i.fontSize(t)||11),o=2*a,r=n-t.r;let c=t.radians*(180/Math.PI),h=t.r+5,l="start";(c<-90||c>90)&&(h=-t.r-r-5,l="end",c+=180),t.labelBounds={x:h,y:-a/2,width:r,height:o},t.rotate=c,t.textAnchor=l})}
3749
3950
  /**
3750
3951
  Build the link/node shape config + `linkD` accessor, scale link strokes, and
3751
3952
  stash `linkLookup` + `ringsCtx` on `viz.ctx`.
3752
- */(i,g,m),function(e,i,s,a,o){e.ctx.linkLookup=a.reduce((e,t)=>(e[t.source.id]||(e[t.source.id]=[]),e[t.source.id].push(t.target),e[t.target.id]||(e[t.target.id]=[]),e[t.target.id].push(t.source),e),{});const r=t.extent(a,e=>e.size);if(r[0]!==r[1]){const s=t.min(i,e=>e.r),n=B[`scale${e.schema.linkSizeScale.charAt(0).toUpperCase()}${e.schema.linkSizeScale.slice(1)}`]().domain(r).range([e.schema.linkSizeMin,s]);a.forEach(e=>{e.size=n(e.size)})}const c=Ei(e,"Path",e.schema.shapeConfig,"edge");delete c.on;const h={label:t=>!!(i.length<=e.schema.dataCutoff||e._hover&&e._hover(t)||e._active&&e._active(t))&&e._drawLabel(t.data||t.node,t.i),labelBounds:e=>e.labelBounds,labelConfig:{fontColor:t=>{const i=t.data??t;if(i.id===e.schema.center){const t=Ri(Ei(e,i.key??i.shape).fill,i.data??i,i.i);return u.colorContrast("string"==typeof t?t:"rgb(255, 255, 255)")}return u.colorContrast(e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)")},fontResize:t=>(t.data??t).id===e.schema.center,padding:0,textAnchor:t=>{const i=t.data??t;return s[i.id]?.textAnchor||Ei(e,i.key??i.shape).labelConfig.textAnchor},verticalAlign:t=>(t.data??t).id===e.schema.center?"middle":"top"},rotate:e=>s[e.id].rotate||0},l=Array.from(t.groups(i,e=>e.shape));e.ctx.ringsCtx={edges:o,nodeGroups:l,linkConfig:c,linkD:e=>e.spline?`M${e.sourceX},${e.sourceY}C${e.sourceBisectX},${e.sourceBisectY} ${e.targetBisectX},${e.targetBisectY} ${e.targetX},${e.targetY}`:`M${e.source.x},${e.source.y} ${e.target.x},${e.target.y}`,nodeShapeConfig:h}}(i,g,a,o,l),{shapeData:g}};const Bn={name:"Rings",features:[ee,Q,Z,ne],layoutStage:$n,emit:({viz:e})=>{const t=e.ctx.ringsCtx;if(!t)return[];const i=[];if(t.edges&&t.edges.length)for(let e=0;e<t.edges.length;e++){const s=t.edges[e],n=s,a=Li(t.linkConfig,n,e);"number"==typeof s.size&&(a.strokeWidth=s.size),i.push({type:"path",key:`rings-link-${s.source.id}-${s.target.id}`,d:t.linkD(s),datum:n,paint:a})}if(t.nodeGroups&&t.nodeGroups.length){const s=t.nodeShapeConfig;for(const[n,a]of t.nodeGroups){if(!a.length)continue;const o={...Ei(e,n),...t.nodeShapeConfig};for(let e=0;e<a.length;e++){const t=a[e],r=t.data??t,c=Li(o,r,t.i??e);
3953
+ */(i,g,m),function(e,i,s,a,o){e.ctx.linkLookup=a.reduce((e,t)=>(e[t.source.id]||(e[t.source.id]=[]),e[t.source.id].push(t.target),e[t.target.id]||(e[t.target.id]=[]),e[t.target.id].push(t.source),e),{});const r=t.extent(a,e=>e.size);if(r[0]!==r[1]){const s=t.min(i,e=>e.r),n=B[`scale${e.schema.linkSizeScale.charAt(0).toUpperCase()}${e.schema.linkSizeScale.slice(1)}`]().domain(r).range([e.schema.linkSizeMin,s]);a.forEach(e=>{e.size=n(e.size)})}const c=Hi(e,"Path",e.schema.shapeConfig,"edge");delete c.on;const h={label:t=>!!(i.length<=e.schema.dataCutoff||e._hover&&e._hover(t)||e._active&&e._active(t))&&e._drawLabel(t.data||t.node,t.i),labelBounds:e=>e.labelBounds,labelConfig:{fontColor:t=>{const i=t.data??t;if(i.id===e.schema.center){const t=Wi(Hi(e,i.key??i.shape).fill,i.data??i,i.i);return u.colorContrast("string"==typeof t?t:"rgb(255, 255, 255)")}return u.colorContrast(e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)")},fontResize:t=>(t.data??t).id===e.schema.center,padding:0,textAnchor:t=>{const i=t.data??t;return s[i.id]?.textAnchor||Hi(e,i.key??i.shape).labelConfig.textAnchor},verticalAlign:t=>(t.data??t).id===e.schema.center?"middle":"top"},rotate:e=>s[e.id].rotate||0},l=Array.from(t.groups(i,e=>e.shape));e.ctx.ringsCtx={edges:o,nodeGroups:l,linkConfig:c,linkD:e=>e.spline?`M${e.sourceX},${e.sourceY}C${e.sourceBisectX},${e.sourceBisectY} ${e.targetBisectX},${e.targetBisectY} ${e.targetX},${e.targetY}`:`M${e.source.x},${e.source.y} ${e.target.x},${e.target.y}`,nodeShapeConfig:h}}(i,g,a,o,l),{shapeData:g}};const qn={name:"Rings",features:[ee,Q,Z,ne],layoutStage:In,emit:({viz:e})=>{const t=e.ctx.ringsCtx;if(!t)return[];const i=[];if(t.edges&&t.edges.length)for(let e=0;e<t.edges.length;e++){const s=t.edges[e],n=s,a=Ni(t.linkConfig,n,e);"number"==typeof s.size&&(a.strokeWidth=s.size),i.push({type:"path",key:`rings-link-${s.source.id}-${s.target.id}`,d:t.linkD(s),datum:n,paint:a})}if(t.nodeGroups&&t.nodeGroups.length){const s=t.nodeShapeConfig;for(const[n,a]of t.nodeGroups){if(!a.length)continue;const o={...Hi(e,n),...t.nodeShapeConfig};for(let e=0;e<a.length;e++){const t=a[e],r=t.data??t,c=Ni(o,r,t.i??e);
3753
3954
  // Nodes are data shapes: keep their stroke a constant screen width as the
3754
3955
  // diagram zooms (the edges above deliberately scale with the zoom).
3755
- void 0===c.vectorEffect&&(c.vectorEffect="non-scaling-stroke");const h=s.rotate?s.rotate(t):0,l=h?{x:t.x,y:t.y,rotate:h}:{x:t.x,y:t.y};if("Circle"===n)i.push({type:"circle",key:`rings-${n}-${t.id}`,cx:0,cy:0,r:t.r,datum:r,paint:c,transform:l});else if("Rect"===n){const s=Number(Ri(o.width,r,t.i??e)??2*t.r),a=Number(Ri(o.height,r,t.i??e)??2*t.r);i.push({type:"rect",key:`rings-${n}-${t.id}`,x:-s/2,y:-a/2,width:s,height:a,datum:r,paint:c,transform:l})}
3956
+ void 0===c.vectorEffect&&(c.vectorEffect="non-scaling-stroke");const h=s.rotate?s.rotate(t):0,l=h?{x:t.x,y:t.y,rotate:h}:{x:t.x,y:t.y};if("Circle"===n)i.push({type:"circle",key:`rings-${n}-${t.id}`,cx:0,cy:0,r:t.r,datum:r,paint:c,transform:l});else if("Rect"===n){const s=Number(Wi(o.width,r,t.i??e)??2*t.r),a=Number(Wi(o.height,r,t.i??e)??2*t.r);i.push({type:"rect",key:`rings-${n}-${t.id}`,x:-s/2,y:-a/2,width:s,height:a,datum:r,paint:c,transform:l})}
3756
3957
  // Other shape kinds: skipped (Rings's default is Circle).
3757
- }if(s.label&&s.labelBounds){const e=s.label,t=s.labelBounds,n=Rs({data:a,label:(t,i)=>e(t,i),x:e=>e.x,y:e=>e.y,aes:e=>({r:e.r}),rotate:e=>s.rotate?s.rotate(e):0,id:e=>`rings-label-${e.id}`,labelBounds:(e,i)=>t(e),labelConfig:s.labelConfig??{}});i.push(...n)}}}return i},setup:e=>{!
3958
+ }if(s.label&&s.labelBounds){const e=s.label,t=s.labelBounds,n=Xs({data:a,label:(t,i)=>e(t,i),x:e=>e.x,y:e=>e.y,aes:e=>({r:e.r}),rotate:e=>s.rotate?s.rotate(e):0,id:e=>`rings-label-${e.id}`,labelBounds:(e,i)=>t(e),labelConfig:s.labelConfig??{}});i.push(...n)}}}return i},setup:e=>{!
3758
3959
  /** Installs Rings' nodes/links/size/hover fluent accessors onto the instance. */function(e){const t=e,i=(e,t,i,n)=>s.addToQueue.bind(e)(t,i,n);t.links=function(e,t){return arguments.length?(i(this,e,t,"links"),this):this.schema.links},t.nodes=function(e,t){return arguments.length?(i(this,e,t,"nodes"),this):this.schema.nodes},t.linkSize=function(e){return arguments.length?(this.schema.linkSize="function"==typeof e?e:L(e),this):this.schema.linkSize},t.nodeGroupBy=function(e){if(!arguments.length)return this.schema.nodeGroupBy;const t=e instanceof Array?e:[e];return this.schema.nodeGroupBy=t.map(e=>"function"==typeof e?e:(this.schema.aggs[e]||(this.schema.aggs[e]=(e,t)=>{const i=Array.from(new Set(e.map(t)));return 1===i.length?i[0]:i}),F(e))),this},t.size=function(e){return arguments.length?(this._size="function"!=typeof e&&e?F(e):e,this):this._size},t.hover=function(e){const t=e;return this._hover=e,this._shapes.forEach(e=>e.hover(t)),this.schema.legend&&this._legendClass.hover(t),
3759
3960
  // Scene-emit charts dim via applyInteractionOpacity during toScene(); a
3760
3961
  // hover change only takes effect once a repaint is scheduled.
@@ -3766,34 +3967,34 @@ e.hover?.(!1),e._tooltipClass?.data([]).render(),e.schema.center=t.id,e._margin=
3766
3967
  // _draw() only recomputes layout/scene; paint it with the chart duration
3767
3968
  // so the re-centering animates (a bare _draw leaves the only repaint to
3768
3969
  // the coalesced duration-0 one, which snaps).
3769
- e._sceneRenderer&&e._drawSceneToTarget(e.schema.duration)}},ctx:{},fields:[{key:"center"},{key:"tooltipConfig",merge:!0,factory:e=>({title:t=>{const i=t;return t&&i.source&&i.target?`${i.source.id} → ${i.target.id}`:e._drawLabel(t,"number"==typeof t.i?t.i:0)}})},{key:"links",default:[]},{key:"linkSize",default:L(1)},{key:"linkSizeMin",default:1},{key:"linkSizeScale",default:"sqrt"},{key:"noDataMessage",default:!1},{key:"nodes",default:[]},{key:"sizeMax"},{key:"sizeMin",default:5},{key:"sizeScale",default:"sqrt"},{key:"shape",default:L("Circle")},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,i)=>{const s=e._size,n=s?`, ${s(t,i)}`:"";return`${e._drawLabel(t,i)}${n}.`},labelConfig:{duration:0,fontMin:1,fontResize:!0,labelPadding:0,textAnchor:"middle",verticalAlign:"middle"},Path:{fill:"none",label:!1,stroke:"#eee",strokeWidth:1}})}]};
3970
+ e._sceneRenderer&&e._drawSceneToTarget(e.schema.duration)}},ctx:{},fields:[{key:"center"},{key:"tooltipConfig",merge:!0,factory:e=>({title:t=>{const i=t;return t&&i.source&&i.target?`${i.source.id} → ${i.target.id}`:e._drawLabel(t,"number"==typeof t.i?t.i:0)}})},{key:"links",default:[]},{key:"linkSize",default:L(1)},{key:"linkSizeMin",default:1},{key:"linkSizeScale",default:"sqrt"},{key:"noDataMessage",default:!1},{key:"nodes",default:[]},{key:"sizeMax"},{key:"sizeMin",default:5},{key:"sizeScale",default:"sqrt"},{key:"shape",default:L("Circle"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,i)=>{const s=e._size,n=s?`, ${s(t,i)}`:"";return`${e._drawLabel(t,i)}${n}.`},labelConfig:{duration:0,fontMin:1,fontResize:!0,labelPadding:0,textAnchor:"middle",verticalAlign:"middle"},Path:{fill:"none",label:!1,stroke:"#eee",strokeWidth:1}})}]};
3770
3971
  /**
3771
3972
  Creates a ring visualization based on a defined set of nodes and edges.
3772
- */var Pn=Bi(Bn);const Tn=({viz:e})=>{const i=e,{width:s,height:n}=le(i),a=Array.isArray(i.schema.nodes)&&i.schema.nodes.length>0,o=Array.isArray(i.schema.links)&&i.schema.links.length>0;if(!a&&!o)return i.ctx.nodeLookup={},i.ctx.linkLookup={},{viz:e};let r;if(a)r=i.schema.nodes;else{const e=new Set,t=[];for(const s of i.schema.links){const n=s[i.schema.linksSource];e.has(n)||(e.add(n),t.push(n));const a=s[i.schema.linksTarget];e.has(a)||(e.add(a),t.push(a))}r=t.map(e=>({id:e}))}const c=r.map((e,t)=>({__d3plus__:!0,data:e,i:t,id:i.schema.nodeId(e,t),node:e,shape:"Rect"})),h=c.reduce((e,t,i)=>(e[String(t.id)]=i,e),{});i.ctx.nodeLookup=h;const l=o?i.schema.links.map((e,t)=>({source:h[String(e[i.schema.linksSource])],target:h[String(e[i.schema.linksTarget])],value:i.schema.value(e,t)})):[];i.ctx.linkLookup=l.reduce((e,t)=>(e[t.source]||(e[t.source]=[]),e[t.source].push(t.target),e[t.target]||(e[t.target]=[]),e[t.target].push(t.source),e),{}),i.ctx.sankey.nodeAlign(i.schema.nodeAlign).nodePadding(i.schema.nodePadding).nodeWidth(i.schema.nodeWidth).nodes(c).nodeSort(i.schema.nodeSort).links(l).linkSort(i.schema.linkSort).iterations(i.schema.iterations).size([s,n])();const d=Array.from(t.groups(c,e=>e.shape));return i.ctx.sankeyCtx={links:l,nodeGroups:d,pathFn:i.ctx.path},{shapeData:c}},On={center:A.sankeyCenter,justify:A.sankeyJustify,left:A.sankeyLeft,right:A.sankeyRight},Rn={name:"Sankey",features:[ee,Q,Z,ne],layoutStage:Tn,emit:({viz:e})=>{const t=e.ctx.sankeyCtx;if(!t)return[];const i=[],s=e.schema.shapeConfig?.Path??{};
3973
+ */var Yn=Ri(qn);const Kn=({viz:e})=>{const i=e,{width:s,height:n}=le(i),a=Array.isArray(i.schema.nodes)&&i.schema.nodes.length>0,o=Array.isArray(i.schema.links)&&i.schema.links.length>0;if(!a&&!o)return i.ctx.nodeLookup={},i.ctx.linkLookup={},{viz:e};let r;if(a)r=i.schema.nodes;else{const e=new Set,t=[];for(const s of i.schema.links){const n=s[i.schema.linksSource];e.has(n)||(e.add(n),t.push(n));const a=s[i.schema.linksTarget];e.has(a)||(e.add(a),t.push(a))}r=t.map(e=>({id:e}))}const c=r.map((e,t)=>({__d3plus__:!0,data:e,i:t,id:i.schema.nodeId(e,t),node:e,shape:"Rect"})),h=c.reduce((e,t,i)=>(e[String(t.id)]=i,e),{});i.ctx.nodeLookup=h;const l=o?i.schema.links.map((e,t)=>({source:h[String(e[i.schema.linksSource])],target:h[String(e[i.schema.linksTarget])],value:i.schema.value(e,t)})):[];i.ctx.linkLookup=l.reduce((e,t)=>(e[t.source]||(e[t.source]=[]),e[t.source].push(t.target),e[t.target]||(e[t.target]=[]),e[t.target].push(t.source),e),{}),i.ctx.sankey.nodeAlign(i.schema.nodeAlign).nodePadding(i.schema.nodePadding).nodeWidth(i.schema.nodeWidth).nodes(c).nodeSort(i.schema.nodeSort).links(l).linkSort(i.schema.linkSort).iterations(i.schema.iterations).size([s,n])();const d=Array.from(t.groups(c,e=>e.shape));return i.ctx.sankeyCtx={links:l,nodeGroups:d,pathFn:i.ctx.path},{shapeData:c}},Vn={center:A.sankeyCenter,justify:A.sankeyJustify,left:A.sankeyLeft,right:A.sankeyRight},Xn={name:"Sankey",features:[ee,Q,Z,ne],layoutStage:Kn,emit:({viz:e})=>{const t=e.ctx.sankeyCtx;if(!t)return[];const i=[],s=e.schema.shapeConfig?.Path??{};
3773
3974
  // Sankey's link config is the raw `viz.schema.shapeConfig.Path` (no
3774
3975
  // configPrep wrap) because links are raw `{source, target, value}`
3775
3976
  // records — not d3plus-wrapped.
3776
- if(t.links&&t.links.length)for(let e=0;e<t.links.length;e++){const n=t.links[e],a=Li(s,n,e);i.push({type:"path",shapeType:"Link",key:`sankey-link-${n.source.id??""}-${n.target.id??""}`,d:t.pathFn(n),datum:n,paint:a})}if(t.nodeGroups&&t.nodeGroups.length)for(const[s,n]of t.nodeGroups){if(!n.length)continue;const t=Ei(e,s);for(let e=0;e<n.length;e++){const a=n[e],o=a.data??a,r=Li(t,o,a.i??e);if("Rect"===s)i.push({type:"rect",key:`sankey-${s}-${a.id}`,x:a.x0,y:a.y0,width:a.x1-a.x0,height:a.y1-a.y0,datum:o,paint:r});else if("Circle"===s){const n=Number(Ri(t.r,o,a.i??e)??0);i.push({type:"circle",key:`sankey-${s}-${a.id}`,cx:(a.x0+a.x1)/2,cy:(a.y0+a.y1)/2,r:n,datum:o,paint:r})}
3977
+ if(t.links&&t.links.length)for(let e=0;e<t.links.length;e++){const n=t.links[e],a=Ni(s,n,e);i.push({type:"path",shapeType:"Link",key:`sankey-link-${n.source.id??""}-${n.target.id??""}`,d:t.pathFn(n),datum:n,paint:a})}if(t.nodeGroups&&t.nodeGroups.length)for(const[s,n]of t.nodeGroups){if(!n.length)continue;const t=Hi(e,s);for(let e=0;e<n.length;e++){const a=n[e],o=a.data??a,r=Ni(t,o,a.i??e);if("Rect"===s)i.push({type:"rect",key:`sankey-${s}-${a.id}`,x:a.x0,y:a.y0,width:a.x1-a.x0,height:a.y1-a.y0,datum:o,paint:r});else if("Circle"===s){const n=Number(Wi(t.r,o,a.i??e)??0);i.push({type:"circle",key:`sankey-${s}-${a.id}`,cx:(a.x0+a.x1)/2,cy:(a.y0+a.y1)/2,r:n,datum:o,paint:r})}
3777
3978
  // Other shape kinds: skipped (Sankey's default is Rect).
3778
3979
  }}return i},setup:e=>{const t=e;e.schema.on.mouseenter=()=>{},e.schema.on["mouseleave.shape"]=()=>{t.hover(!1)};const i=e.schema.on["mousemove.shape"];e.schema.on["mousemove.shape"]=(s,n,a,o)=>{if(i(s,n,a,o),e._focus&&e._focus===s.id)return t.hover(!1),e.schema.on.mouseenter.bind(e)(s,n,a,o),void(e._focus=void 0);
3779
3980
  // An edge datum is a `{source, target}` link, not a node — highlight the
3780
3981
  // hovered link plus its two endpoint nodes.
3781
- const r=s;if(r.source&&r.target){const i=r.source.id,s=r.target.id;return void t.hover((t,n)=>{if(t.source&&t.target)return t.source.id===i&&t.target.id===s;const a=e.schema.nodeId(t,n);return a===i||a===s})}const c=e.schema.nodeId(s,n),h=e.ctx.nodeLookup[String(c)],l=e.ctx.nodeLookup,d=Object.keys(l).reduce((e,t)=>(e[l[t]]=isNaN(Number(t))?t:parseInt(t,10),e),{}),u=e.ctx.linkLookup[h]??[],m=[c];u.forEach(e=>m.push(d[e])),t.hover((t,i)=>t.source&&t.target?t.source.id===c||t.target.id===c:m.includes(e.schema.nodeId(t,i)))},t.links=function(e,t){return arguments.length?(s.addToQueue.bind(this)(e,t,"links"),this):this.schema.links},t.nodes=function(e,t){return arguments.length?(s.addToQueue.bind(this)(e,t,"nodes"),this):this.schema.nodes},t.nodeAlign=function(e){return arguments.length?(this.schema.nodeAlign="function"==typeof e?e:On[e],this):this.schema.nodeAlign},t.nodeId=function(e){return arguments.length?(this.schema.nodeId="function"==typeof e?e:F(e),this):this.schema.nodeId},t.value=function(e){return arguments.length?(this.schema.value="function"==typeof e?e:F(e),this):this.schema.value},t.hover=function(e){return this._hover=e,(this._shapes??[]).forEach(t=>t.hover(e)),this.schema.legend&&this._legendClass&&this._legendClass.hover(e),
3982
+ const r=s;if(r.source&&r.target){const i=r.source.id,s=r.target.id;return void t.hover((t,n)=>{if(t.source&&t.target)return t.source.id===i&&t.target.id===s;const a=e.schema.nodeId(t,n);return a===i||a===s})}const c=e.schema.nodeId(s,n),h=e.ctx.nodeLookup[String(c)],l=e.ctx.nodeLookup,d=Object.keys(l).reduce((e,t)=>(e[l[t]]=isNaN(Number(t))?t:parseInt(t,10),e),{}),u=e.ctx.linkLookup[h]??[],m=[c];u.forEach(e=>m.push(d[e])),t.hover((t,i)=>t.source&&t.target?t.source.id===c||t.target.id===c:m.includes(e.schema.nodeId(t,i)))},t.links=function(e,t){return arguments.length?(s.addToQueue.bind(this)(e,t,"links"),this):this.schema.links},t.nodes=function(e,t){return arguments.length?(s.addToQueue.bind(this)(e,t,"nodes"),this):this.schema.nodes},t.nodeAlign=function(e){return arguments.length?(this.schema.nodeAlign="function"==typeof e?e:Vn[e],this):this.schema.nodeAlign},t.nodeId=function(e){return arguments.length?(this.schema.nodeId="function"==typeof e?e:F(e),this):this.schema.nodeId},t.value=function(e){return arguments.length?(this.schema.value="function"==typeof e?e:F(e),this):this.schema.value},t.hover=function(e){return this._hover=e,(this._shapes??[]).forEach(t=>t.hover(e)),this.schema.legend&&this._legendClass&&this._legendClass.hover(e),
3782
3983
  // Scene-rendered Sankey emits into `_chartScene`, not `_shapes`, so the
3783
3984
  // forEach above can't dim anything. Repaint so the scene's
3784
3985
  // interaction-opacity pass re-reads `_hover` and dims non-matching nodes.
3785
3986
  // Coalesced to one paint per frame (see Viz._scheduleSceneRepaint).
3786
- this._sceneRenderer&&this._scheduleSceneRepaint(),this}},ctx:{sankey:A.sankey(),path:A.sankeyLinkHorizontal()},fields:[{key:"iterations",default:6},{key:"links",default:F("links")},{key:"linkSort"},{key:"linksSource",default:"source"},{key:"linksTarget",default:"target"},{key:"noDataMessage",default:!1},{key:"nodes",default:F("nodes")},{key:"nodeAlign",default:A.sankeyJustify},{key:"nodeId",default:F("id")},{key:"nodePadding",default:8},{key:"nodeSort"},{key:"nodeWidth",default:30},{key:"value",default:L(1)},{key:"shape",default:L("Rect")},{key:"shapeConfig",merge:!0,factory:()=>{const e=e=>Math.max(1,Math.abs(e.source.y1-e.source.y0)*(e.value/e.source.value)-2);return{Path:{fill:"none",hoverStyle:{"stroke-width":e},label:!1,stroke:"#DBDBDB",strokeOpacity:.5,strokeWidth:e},Rect:{}}}},{key:"tooltipConfig",merge:!0,factory:e=>({title:t=>t&&t.source&&t.target?`${t.source.id} → ${t.target.id}`:e._drawLabel(t,"number"==typeof t.i?t.i:0)})}]};
3987
+ this._sceneRenderer&&this._scheduleSceneRepaint(),this}},ctx:{sankey:A.sankey(),path:A.sankeyLinkHorizontal()},fields:[{key:"iterations",default:6},{key:"links",default:F("links")},{key:"linkSort"},{key:"linksSource",default:"source"},{key:"linksTarget",default:"target"},{key:"noDataMessage",default:!1},{key:"nodes",default:F("nodes")},{key:"nodeAlign",default:A.sankeyJustify},{key:"nodeId",default:F("id")},{key:"nodePadding",default:8},{key:"nodeSort"},{key:"nodeWidth",default:30},{key:"value",default:L(1)},{key:"shape",default:L("Rect"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:()=>{const e=e=>Math.max(1,Math.abs(e.source.y1-e.source.y0)*(e.value/e.source.value)-2);return{Path:{fill:"none",hoverStyle:{"stroke-width":e},label:!1,stroke:"#DBDBDB",strokeOpacity:.5,strokeWidth:e},Rect:{}}}},{key:"tooltipConfig",merge:!0,factory:e=>({title:t=>t&&t.source&&t.target?`${t.source.id} → ${t.target.id}`:e._drawLabel(t,"number"==typeof t.i?t.i:0)})}]};
3787
3988
  /**
3788
3989
  Creates a Sankey visualization based on a defined set of nodes and links.
3789
3990
  */
3790
- var Ln=Bi(Rn);
3991
+ var Un=Ri(Xn);
3791
3992
  /**
3792
3993
  Creates a stacked area plot based on an array of data.
3793
3994
  */
3794
- var En=Bi({name:"StackedArea",paintDriven:!0,features:[ee,Q,Z,ne],ctx:{},fields:[{key:"stacked",default:!0}]},Ms);
3795
- /** Merge a branch's leaf values (recursively) through the schema aggs. */function Fn(e,t){return s.merge(t.values.map(t=>t.key&&t.values?Fn(e,t):t),e.schema.aggs)}
3796
- /** Run the d3-hierarchy tree layout, flatten branch aggregations, and tag nodes. */function Wn(e,t,i){const n=e.ctx.tree.separation(e.schema.separation).size([t,i])(M.hierarchy({key:"root",values:s.nest(e._filteredData,e.schema.groupBy.slice(0,e._drawDepth+1))},e=>e.key&&e.values?e.values:null).sort(e.schema.sort)).descendants().filter(t=>(t.depth??0)<=e.schema.groupBy.length&&!!t.parent);return n.forEach((t,i)=>{const s=t.data;s.key&&s.values&&(t.data=Fn(e,s)),t.__d3plus__=!0,t.i=i,
3995
+ var Jn=Ri({name:"StackedArea",paintDriven:!0,features:[ee,Q,Z,ne],ctx:{},fields:[{key:"stacked",default:!0}]},js);
3996
+ /** Merge a branch's leaf values (recursively) through the schema aggs. */function Qn(e,t){return s.merge(t.values.map(t=>t.key&&t.values?Qn(e,t):t),e.schema.aggs)}
3997
+ /** Run the d3-hierarchy tree layout, flatten branch aggregations, and tag nodes. */function Zn(e,t,i){const n=e.ctx.tree.separation(e.schema.separation).size([t,i])(M.hierarchy({key:"root",values:s.nest(e._filteredData,e.schema.groupBy.slice(0,e._drawDepth+1))},e=>e.key&&e.values?e.values:null).sort(e.schema.sort)).descendants().filter(t=>(t.depth??0)<=e.schema.groupBy.length&&!!t.parent);return n.forEach((t,i)=>{const s=t.data;s.key&&s.values&&(t.data=Qn(e,s)),t.__d3plus__=!0,t.i=i,
3797
3998
  // The tooltip binds the unwrapped row, so the per-node hierarchy depth
3798
3999
  // (needed to label the node at its own level) must live on the row.
3799
4000
  // Mirrors Treemap stamping `share`/`rank` onto `d.data`.
@@ -3801,7 +4002,7 @@ t.data.depth=t.depth}),n}
3801
4002
  /**
3802
4003
  Measure label height + per-depth label widths, then rescale y coordinates.
3803
4004
  Stashes `labelHeight`/`labelWidths` on `viz.ctx`.
3804
- */const Nn=({viz:e})=>{const i=e.schema.orient,a="vertical"===i,o="horizontal"===i,r=a?e.schema.height-e._margin.top-e._margin.bottom:e.schema.width-e._margin.left-e._margin.right,c=o?e.schema.height-e._margin.top-e._margin.bottom:e.schema.width-e._margin.left-e._margin.right,h=a?"left":"top",d=Wn(e,c,r),{labelHeight:u,labelWidths:m}=function(e,i,n,a,o,r,c){let h=e.schema.shapeConfig.r;if("function"!=typeof h){const e=h;h=()=>e}const d=t.max(i,e=>1===e.depth?h(e.data,e.i):0),u=t.max(i,e=>e.children?0:h(e.data,e.i)),m=t.extent(i,e=>e.y),f=t.min([n?50:100,(m[1]-d-u)/(e.schema.groupBy.length+1)]);e.ctx.labelHeight=f;const g=s.nest(i,e=>e.depth).map(i=>{const s=i.values;return s.reduce((i,n,a)=>{const r=a<s.length-1?s[a+1].x:o+e._margin[c],h=a?s[a-1].x:e._margin[c];return t.min([i,r-n.x,n.x-h])},o)});e.ctx.labelWidths=g;const p=l.scaleLinear().domain(m).range([d+f,r-u-f]);return i.forEach(e=>{const t=p(e.y);a?(e.y=e.x,e.x=t):e.y=t}),{labelHeight:f,labelWidths:g}}
4005
+ */const ea=({viz:e})=>{const i=e.schema.orient,a="vertical"===i,o="horizontal"===i,r=a?e.schema.height-e._margin.top-e._margin.bottom:e.schema.width-e._margin.left-e._margin.right,c=o?e.schema.height-e._margin.top-e._margin.bottom:e.schema.width-e._margin.left-e._margin.right,h=a?"left":"top",d=Zn(e,c,r),{labelHeight:u,labelWidths:m}=function(e,i,n,a,o,r,c){let h=e.schema.shapeConfig.r;if("function"!=typeof h){const e=h;h=()=>e}const d=t.max(i,e=>1===e.depth?h(e.data,e.i):0),u=t.max(i,e=>e.children?0:h(e.data,e.i)),m=t.extent(i,e=>e.y),f=t.min([n?50:100,(m[1]-d-u)/(e.schema.groupBy.length+1)]);e.ctx.labelHeight=f;const g=s.nest(i,e=>e.depth).map(i=>{const s=i.values;return s.reduce((i,n,a)=>{const r=a<s.length-1?s[a+1].x:o+e._margin[c],h=a?s[a-1].x:e._margin[c];return t.min([i,r-n.x,n.x-h])},o)});e.ctx.labelWidths=g;const p=l.scaleLinear().domain(m).range([d+f,r-u-f]);return i.forEach(e=>{const t=p(e.y);a?(e.y=e.x,e.x=t):e.y=t}),{labelHeight:f,labelWidths:g}}
3805
4006
  /** Build the per-shape config object consumed by the Tree's shape emit. */(e,d,a,o,c,r,h);
3806
4007
  /**
3807
4008
  Build link descriptors + per-shape groupings and stash
@@ -3815,54 +4016,54 @@ e.ctx.linksData=h,e.ctx.linkD=e=>{let t=c.r;"function"==typeof t&&(t=t(e.data,e.
3815
4016
  kind (`type`, geometry coords) plus an `aes` record used by
3816
4017
  labelBounds. The position of the shape is taken from the node datum's
3817
4018
  `x` and `y` (Tree layout sets these on every TreeNode).
3818
- */function Hn(e,t,i){const s=t.data??t,n=t.i??0,a=t.x??0,o=t.y??0;switch(e){case"Circle":{const e=Number(Ri(i.r,s,n)??0);return{geom:{type:"circle",cx:a,cy:o,r:e},aes:{r:e}}}case"Rect":{const e=Number(Ri(i.width,s,n)??0),t=Number(Ri(i.height,s,n)??0);return{geom:{type:"rect",x:a-e/2,y:o-t/2,width:e,height:t},aes:{width:e,height:t}}}case"Path":return{geom:{type:"path",d:String(Ri(i.d,s,n)??"")},aes:{}};default:return null}}const jn={name:"Tree",features:[ee,Q,Z,ne],layoutStage:Nn,emit:({viz:e})=>{const t=e.ctx.linksData,i=e.ctx.linkD,s=e.ctx.shapeGroups,n=e.ctx.shapeConfig;if(!s||!n)return[];const a=[];
4019
+ */function ta(e,t,i){const s=t.data??t,n=t.i??0,a=t.x??0,o=t.y??0;switch(e){case"Circle":{const e=Number(Wi(i.r,s,n)??0);return{geom:{type:"circle",cx:a,cy:o,r:e},aes:{r:e}}}case"Rect":{const e=Number(Wi(i.width,s,n)??0),t=Number(Wi(i.height,s,n)??0);return{geom:{type:"rect",x:a-e/2,y:o-t/2,width:e,height:t},aes:{width:e,height:t}}}case"Path":return{geom:{type:"path",d:String(Wi(i.d,s,n)??"")},aes:{}};default:return null}}const ia={name:"Tree",features:[ee,Q,Z,ne],layoutStage:ea,emit:({viz:e})=>{const t=e.ctx.linksData,i=e.ctx.linkD,s=e.ctx.shapeGroups,n=e.ctx.shapeConfig;if(!s||!n)return[];const a=[];
3819
4020
  // Links (Path nodes between parent and child).
3820
- if(t&&t.length&&i){const s=Ei(e,"Path");for(let n=0;n<t.length;n++){const o=t[n],r=o.data??o,c=Li(s,r,n),h=e._ids(r,n)[(o.depth??1)-1],l=o.x??0,d=o.y??0;a.push({type:"path",key:`tree-link-${h}`,d:i(o),datum:r,paint:c,transform:{x:l,y:d}})}}
4021
+ if(t&&t.length&&i){const s=Hi(e,"Path");for(let n=0;n<t.length;n++){const o=t[n],r=o.data??o,c=Ni(s,r,n),h=e._ids(r,n)[(o.depth??1)-1],l=o.x??0,d=o.y??0;a.push({type:"path",key:`tree-link-${h}`,d:i(o),datum:r,paint:c,transform:{x:l,y:d}})}}
3821
4022
  // Per-shape-kind node groups.
3822
- for(const{key:t,values:i}of s){if(!i.length)continue;const s={...Ei(e,t),...n},o=i;
4023
+ for(const{key:t,values:i}of s){if(!i.length)continue;const s={...Hi(e,t),...n},o=i;
3823
4024
  // Chart-specific shapeConfig overrides (label, labelBounds, etc.).
3824
- for(let e=0;e<o.length;e++){const i=o[e],r=i.data??i,c=Hn(t,i,s);if(!c)continue;const h=n.id(i,e),l=Li(s,r,e);a.push({...c.geom,key:`tree-${t}-${h}`,datum:r,paint:l})}
4025
+ for(let e=0;e<o.length;e++){const i=o[e],r=i.data??i,c=ta(t,i,s);if(!c)continue;const h=n.id(i,e),l=Ni(s,r,e);a.push({...c.geom,key:`tree-${t}-${h}`,datum:r,paint:l})}
3825
4026
  // Labels via the chart-specific labelBounds/label/labelConfig.
3826
- const r=Rs({data:o,label:(e,t)=>n.label(e,t),x:e=>e.x??0,y:e=>e.y??0,aes:e=>Hn(t,e,s)?.aes??{},rotate:L(0),id:(e,t)=>n.id(e,t),labelBounds:(e,t,i)=>n.labelBounds(e,t,i),labelConfig:n.labelConfig});a.push(...r)}return a},ctx:{tree:M.tree(),previousShapes:[]},fields:[{key:"orient",default:"vertical"},{key:"separation",default:(e,t)=>e.parent===t.parent?1:2},{key:"shape",default:L("Circle")},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,i)=>(e.ctx.linksData&&e._chartScene,e._drawLabel(t,i)),labelConfig:{fontColor:()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return u.colorContrast(t)}},Path:{fill:"none",stroke:u.colorDefaults.missing,strokeWidth:2},r:L(7),width:L(12),height:L(12)})},{key:"tooltipConfig",merge:!0,factory:e=>({
4027
+ const r=Xs({data:o,label:(e,t)=>n.label(e,t),x:e=>e.x??0,y:e=>e.y??0,aes:e=>ta(t,e,s)?.aes??{},rotate:L(0),id:(e,t)=>n.id(e,t),labelBounds:(e,t,i)=>n.labelBounds(e,t,i),labelConfig:n.labelConfig});a.push(...r)}return a},ctx:{tree:M.tree(),previousShapes:[]},fields:[{key:"orient",default:"vertical"},{key:"separation",default:(e,t)=>e.parent===t.parent?1:2},{key:"shape",default:L("Circle"),coerce:"const"},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,i)=>(e.ctx.linksData&&e._chartScene,e._drawLabel(t,i)),labelConfig:{fontColor:()=>{const t=e._select?n.backgroundColor(e._select.node()):"rgb(255, 255, 255)";return u.colorContrast(t)}},Path:{fill:"none",stroke:u.colorDefaults.missing,strokeWidth:2},r:L(7),width:L(12),height:L(12)})},{key:"tooltipConfig",merge:!0,factory:e=>({
3827
4028
  // The Tooltip calls `title(d, i)` with the bound row; the node's
3828
4029
  // hierarchy depth is stamped onto that row in applyTreeLayout, so the
3829
4030
  // label resolves at the node's own level rather than the leaf level.
3830
- title:(t,i)=>e._drawLabel(t,i,(t.depth??1)-1)})},{key:"legendTooltip",merge:!0,factory:e=>({title:Ut.bind(e)})}]};
4031
+ title:(t,i)=>e._drawLabel(t,i,(t.depth??1)-1)})},{key:"legendTooltip",merge:!0,factory:e=>({title:ei.bind(e)})}]};
3831
4032
  /**
3832
4033
  Uses d3's tree layout to create a tidy tree chart based on an array of data.
3833
4034
  */
3834
- var Gn=Bi(jn);const In=({viz:e})=>{const t=e._filteredData;if(!t||!t.length)return{shapeData:[]};const{width:i,height:n}=le(e),a=s.nestGroups(t,e.schema.groupBy.slice(0,e._drawDepth+1)),o=M.hierarchy({values:a},e=>e.values).sum(e.schema.sum).sort(e.schema.sort),r=e.ctx.treemap.padding(e.schema.layoutPadding).size([i,n]).tile(e.schema.tile)(o),c=[];r.children&&function i(n){for(const a of n){if(a.depth<=e._drawDepth){i(a.children??[]);continue}const n=a.data,o=n.values??[],r=1===o.length?t.indexOf(o[0]):void 0,h=a;h.__d3plus__=!0,h.id=n.key,h.i=void 0!==r&&r>-1?r:void 0,
4035
+ var sa=Ri(ia);const na=({viz:e})=>{const t=e._filteredData;if(!t||!t.length)return{shapeData:[]};const{width:i,height:n}=le(e),a=s.nestGroups(t,e.schema.groupBy.slice(0,e._drawDepth+1)),o=M.hierarchy({values:a},e=>e.values).sum(e.schema.sum).sort(e.schema.sort),r=e.ctx.treemap.padding(e.schema.layoutPadding).size([i,n]).tile(e.schema.tile)(o),c=[];r.children&&function i(n){for(const a of n){if(a.depth<=e._drawDepth){i(a.children??[]);continue}const n=a.data,o=n.values??[],r=1===o.length?t.indexOf(o[0]):void 0,h=a;h.__d3plus__=!0,h.id=n.key,h.i=void 0!==r&&r>-1?r:void 0,
3835
4036
  // Replace the wrapper branch with the merged source datum.
3836
4037
  h.data=s.merge(o,e.schema.aggs),h.x=a.x0+(a.x1-a.x0)/2,h.y=a.y0+(a.y1-a.y0)/2,c.push(h)}}(r.children);
3837
4038
  // Per-record rank — attached to the source datum so `ariaLabel` reads
3838
4039
  // `d.rank` directly instead of indexOf'ing a viz-level array.
3839
- const h=e.schema.sort;c.slice().sort(h).forEach((e,t)=>{e.data.rank=t});const l=r.value,d=e.schema.sum;return c.forEach(e=>{const t=d(e.data)/l;e.share=t,e.data.share=t}),{shapeData:c}};function qn(e,t,i){return"function"==typeof e?e(t,i):e}
4040
+ const h=e.schema.sort;c.slice().sort(h).forEach((e,t)=>{e.data.rank=t});const l=r.value,d=e.schema.sum;return c.forEach(e=>{const t=d(e.data)/l;e.share=t,e.data.share=t}),{shapeData:c}};function aa(e,t,i){return"function"==typeof e?e(t,i):e}
3840
4041
  /**
3841
4042
  Walks `data` to `drawDepth` and merges entries whose `thresholdKey`
3842
4043
  value falls below `threshold(branchData) * totalSum` into a single
3843
4044
  aggregated row at that depth. Returns the kept set; original `data`
3844
4045
  is not mutated.
3845
4046
  */
3846
- function Yn(e,i){const{aggs:n,drawDepth:a,groupBy:o,threshold:r,thresholdKey:c}=i,h=t.sum(e,c);if(!r||!c)return e;
4047
+ function oa(e,i){const{aggs:n,drawDepth:a,groupBy:o,threshold:r,thresholdKey:c}=i,h=t.sum(e,c);if(!r||!c)return e;
3847
4048
  /**
3848
4049
  Explores the data tree recursively and merges elements under
3849
4050
  the indicated threshold.
3850
4051
  */return function e(i,l){if(l<a)return[...t.group(i,o[l])].reduce((t,[,i])=>{const s=e(i,l+1)??[];return t.concat(s)},[]);if(l===a){const e=Math.min(1,Math.max(0,r(i)));if(!isFinite(e)||isNaN(e))return null;
3851
4052
  // Single-pass O(N) partition into kept + removed bucket.
3852
- const t=[],a=[],o=e*h;for(let e=0;e<i.length;e++){const s=i[e];c(s)<o?t.push(s):a.push(s)}if(t.length>0){const i=s.merge(t,n);i._isAggregation=!0,i._threshold=e,a.push(i)}return a}throw new Error("Depth is higher than the amount of grouping levels.")}(e,0)??e}const Kn={treemapBinary:M.treemapBinary,treemapDice:M.treemapDice,treemapResquarify:M.treemapResquarify,treemapSlice:M.treemapSlice,treemapSliceDice:M.treemapSliceDice,treemapSquarify:M.treemapSquarify},Xn=e=>!!e.children&&1===e.children.length&&!0===e.children[0].data._isAggregation,Vn={name:"Treemap",features:[ee,Q,Z,ne],layoutStage:In,emit:({viz:e,shapeData:t})=>{const i=t??[];if(!i.length)return[];const s=e.schema.locale,n=e._drawLabel,a=e.schema.shapeConfig??{};return[...i.map(t=>{const i=qn(a.fill,t.data,t.i),o=qn(a.stroke,t.data,t.i),r=qn(a.opacity,t.data,t.i),c=qn(a.strokeWidth,t.data,t.i);return{type:"rect",key:`treemap-${t.id}`,x:t.x0,y:t.y0,width:t.x1-t.x0,height:t.y1-t.y0,datum:t.data,paint:{fill:"string"==typeof i?i:void 0,stroke:"string"==typeof o||null==o?o:String(o),opacity:r,strokeWidth:c},aria:{label:`${n(t.data,t.i??0)}, ${e.schema.sum(t.data)}, ${m.formatAbbreviate(100*t.share,s)}%`}}}),...Rs({data:i,label:e=>{const t=e;return[n(t.data,t.i??0),`${m.formatAbbreviate(100*t.share,s)}%`]},x:e=>{const t=e;return t.x0+(t.x1-t.x0)/2},y:e=>{const t=e;return t.y0+(t.y1-t.y0)/2},aes:e=>{const t=e;return{width:t.x1-t.x0,height:t.y1-t.y0}},rotate:L(0),id:e=>e.id,labelBounds:(e,t,i)=>{const{width:s,height:n}=i;let a=Math.min(32,.5*(n-10));return a<8&&(a=0),[{width:s,height:n-a,x:-s/2,y:-n/2},{width:s,height:a+10,x:-s/2,y:n/2-a-10}]},labelConfig:{fontMax:32,textAnchor:e=>e&&0===e.l?"start":"middle",verticalAlign:e=>e&&0===e.l?"top":"bottom",fontColor:e=>{const t=e&&e.data?e.data:e,i=qn(a.fill,t,t.i);return"string"==typeof i?u.colorContrast(i):void 0}}})]},thresholdFunction:(e,t)=>Yn(t,{aggs:e.schema.aggs,drawDepth:e._drawDepth,groupBy:e.schema.groupBy,threshold:e.schema.threshold,thresholdKey:e.schema.thresholdKey}),ctx:{treemap:M.treemap().round(!0)},fields:[{key:"layoutPadding",default:1},{key:"sort",default:(e,t)=>(t.value??0)-(e.value??0),decorate:(e,t)=>{const i=t;return(e,t)=>{const s=Xn(e),n=Xn(t);return s&&!n?1:!s&&n?-1:i(e,t)}}},{key:"sum",default:F("value"),coerce:e=>"function"==typeof e?e:F(e),onSet:(e,t)=>{e.schema.thresholdKey=t}},{key:"tile",default:M.treemapSquarify,coerce:e=>{if("string"!=typeof e)return e;const t=`treemap${e.charAt(0).toUpperCase()}${e.slice(1)}`;return Kn[t]??M.treemapSquarify}},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,i)=>{const s="number"==typeof t.rank?`${t.rank+1}. `:"",n=e.schema.sum;return`${s}${e._drawLabel(t,i)}, ${n(t,i)}.`},labelConfig:{fontMax:32,fontMin:8,fontResize:!0,padding:5}})},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:[[()=>e.schema.translate("Share"),(t,i,s)=>{
4053
+ const t=[],a=[],o=e*h;for(let e=0;e<i.length;e++){const s=i[e];c(s)<o?t.push(s):a.push(s)}if(t.length>0){const i=s.merge(t,n);i._isAggregation=!0,i._threshold=e,a.push(i)}return a}throw new Error("Depth is higher than the amount of grouping levels.")}(e,0)??e}const ra={treemapBinary:M.treemapBinary,treemapDice:M.treemapDice,treemapResquarify:M.treemapResquarify,treemapSlice:M.treemapSlice,treemapSliceDice:M.treemapSliceDice,treemapSquarify:M.treemapSquarify},ca=e=>!!e.children&&1===e.children.length&&!0===e.children[0].data._isAggregation,ha={name:"Treemap",features:[ee,Q,Z,ne],layoutStage:na,emit:({viz:e,shapeData:t})=>{const i=t??[];if(!i.length)return[];const s=e.schema.locale,n=e._drawLabel,a=e.schema.shapeConfig??{};return[...i.map(t=>{const i=aa(a.fill,t.data,t.i),o=aa(a.stroke,t.data,t.i),r=aa(a.opacity,t.data,t.i),c=aa(a.strokeWidth,t.data,t.i);return{type:"rect",key:`treemap-${t.id}`,x:t.x0,y:t.y0,width:t.x1-t.x0,height:t.y1-t.y0,datum:t.data,paint:{fill:"string"==typeof i?i:void 0,stroke:"string"==typeof o||null==o?o:String(o),opacity:r,strokeWidth:c},aria:{label:`${n(t.data,t.i??0)}, ${e.schema.sum(t.data)}, ${m.formatAbbreviate(100*t.share,s)}%`}}}),...Xs({data:i,label:e=>{const t=e;return[n(t.data,t.i??0),`${m.formatAbbreviate(100*t.share,s)}%`]},x:e=>{const t=e;return t.x0+(t.x1-t.x0)/2},y:e=>{const t=e;return t.y0+(t.y1-t.y0)/2},aes:e=>{const t=e;return{width:t.x1-t.x0,height:t.y1-t.y0}},rotate:L(0),id:e=>e.id,labelBounds:(e,t,i)=>{const{width:s,height:n}=i;let a=Math.min(32,.5*(n-10));return a<8&&(a=0),[{width:s,height:n-a,x:-s/2,y:-n/2},{width:s,height:a+10,x:-s/2,y:n/2-a-10}]},labelConfig:{fontMax:32,textAnchor:e=>e&&0===e.l?"start":"middle",verticalAlign:e=>e&&0===e.l?"top":"bottom",fontColor:e=>{const t=e&&e.data?e.data:e,i=aa(a.fill,t,t.i);return"string"==typeof i?u.colorContrast(i):void 0}}})]},thresholdFunction:(e,t)=>oa(t,{aggs:e.schema.aggs,drawDepth:e._drawDepth,groupBy:e.schema.groupBy,threshold:e.schema.threshold,thresholdKey:e.schema.thresholdKey}),ctx:{treemap:M.treemap().round(!0)},fields:[{key:"layoutPadding",default:1},{key:"sort",default:(e,t)=>(t.value??0)-(e.value??0),decorate:(e,t)=>{const i=t;return(e,t)=>{const s=ca(e),n=ca(t);return s&&!n?1:!s&&n?-1:i(e,t)}}},{key:"sum",default:F("value"),coerce:e=>"function"==typeof e?e:F(e),onSet:(e,t)=>{e.schema.thresholdKey=t}},{key:"tile",default:M.treemapSquarify,coerce:e=>{if("string"!=typeof e)return e;const t=`treemap${e.charAt(0).toUpperCase()}${e.slice(1)}`;return ra[t]??M.treemapSquarify}},{key:"shapeConfig",merge:!0,factory:e=>({ariaLabel:(t,i)=>{const s="number"==typeof t.rank?`${t.rank+1}. `:"",n=e.schema.sum;return`${s}${e._drawLabel(t,i)}, ${n(t,i)}.`},labelConfig:{fontMax:32,fontMin:8,fontResize:!0,padding:5}})},{key:"tooltipConfig",merge:!0,factory:e=>({tbody:[[()=>e.schema.translate("Share"),(t,i,s)=>{
3853
4054
  // A ColorScale range swatch carries no per-row share, so sum the
3854
4055
  // share of every datum that falls in its color range.
3855
4056
  if(s._isColorScaleBucket){const t=ye(e,s.color,e.schema.sum);return null==t?"":`${m.formatAbbreviate(100*t,e.schema.locale)}%`}
3856
4057
  // A Legend bucket aggregates multiple rows, so `share` arrives
3857
4058
  // as an array of the members' shares — sum it; a single cell's
3858
4059
  // share is a plain number.
3859
- const n=Array.isArray(s.share)?s.share.reduce((e,t)=>e+t,0):s.share;return Number.isFinite(n)?`${m.formatAbbreviate(100*n,e.schema.locale)}%`:""}]]})},{key:"legendTooltip",merge:!0,factory:()=>({tbody:[]})},{key:"legendSort",factory:e=>{const t=e.schema.sum;return(e,i)=>t(i)-t(e)}},{key:"legend",factory:e=>{const t=e.schema.legend;return(i,s)=>s.length!==e._filteredData.length&&t.call(e,i,s)}}]};
4060
+ const n=Array.isArray(s.share)?s.share.reduce((e,t)=>e+t,0):s.share;return Number.isFinite(n)?`${m.formatAbbreviate(100*n,e.schema.locale)}%`:""}]]})},{key:"legendTooltip",merge:!0,factory:()=>({tbody:[]})},{key:"legendSort",factory:e=>{const t=e.schema.sum;return(e,i)=>t(i)-t(e)}},{key:"legend",coerce:"const",factory:e=>{const t=e.schema.legend;return(i,s)=>s.length!==e._filteredData.length&&t.call(e,i,s)}}]};
3860
4061
  /**
3861
4062
  Uses the d3 treemap layout to create SVG rectangles based on an array of data.
3862
4063
  */
3863
- var Un=Bi(Vn);e.Area=Ge,e.AreaPlot=Ms,e.Axis=xt,e.AxisBottom=bt,e.AxisLeft=kt,e.AxisRight=vt,e.AxisTop=Ct,e.Bar=qe,e.BarChart=As,e.BaseClass=j,e.Box=at,e.BoxWhisker=$s,e.BumpChart=Ps,e.Circle=Ke,e.ColorScale=Bt,e.Donut=Ws,e.Geomap=Xs,e.Image=Re,e.Legend=zt,e.Line=Je,e.LinePlot=Vs,e.Matrix=sn,e.Message=Pt,e.Network=hn,e.Pack=fn,e.Path=rt,e.Pie=Fs,e.Plot=Ds,e.Priestley=_n,e.RESET=W,e.Radar=vn,e.RadialMatrix=Mn,e.Rect=Ve,e.Rings=Pn,e.Sankey=Ln,e.Shape=He,e.StackedArea=En,e.TextBox=Wt,e.Timeline=Gt,e.Tooltip=Vt,e.Tree=Gn,e.Treemap=Un,e.Viz=$i,e.Whisker=et,e.accessor=F,e.applyGeomapLayout=Gs,e.applyMatrixLayout=Js,e.applyNetworkLayout=an,e.applyPackLayout=ln,e.applyPieLayout=Ts,e.applyPriestleyLayout=gn,e.applyRadarLayout=bn,e.applyRadialMatrixLayout=Sn,e.applyRingsLayout=$n,e.applySankeyLayout=Tn,e.applyTreeLayout=Nn,e.applyTreemapLayout=In,e.backFeature=ee,e.colorScaleFeature=ie,e.computeAxisLayout=function(e){
4064
+ var la=Ri(ha);e.Area=qe,e.AreaPlot=js,e.Axis=Ct,e.AxisBottom=St,e.AxisLeft=wt,e.AxisRight=zt,e.AxisTop=Dt,e.Bar=Ke,e.BarChart=Gs,e.BaseClass=j,e.Box=rt,e.BoxWhisker=Is,e.BumpChart=Ys,e.Circle=Xe,e.ColorScale=Rt,e.Donut=Zs,e.Geomap=hn,e.Image=ht,e.Legend=$t,e.Line=Ze,e.LinePlot=ln,e.Matrix=yn,e.Message=Lt,e.Network=Cn,e.Pack=Mn,e.Path=dt,e.Pie=Qs,e.Plot=Hs,e.Priestley=Pn,e.RESET=W,e.Radar=Ln,e.RadialMatrix=jn,e.Rect=Je,e.Rings=Yn,e.Sankey=Un,e.Shape=Ge,e.StackedArea=Jn,e.TextBox=Gt,e.Timeline=Kt,e.Tooltip=Zt,e.Tree=sa,e.Treemap=la,e.Viz=Oi,e.Whisker=it,e.accessor=F,e.applyGeomapLayout=nn,e.applyMatrixLayout=un,e.applyNetworkLayout=xn,e.applyPackLayout=Sn,e.applyPieLayout=Ks,e.applyPriestleyLayout=An,e.applyRadarLayout=On,e.applyRadialMatrixLayout=Fn,e.applyRingsLayout=In,e.applySankeyLayout=Kn,e.applyTreeLayout=ea,e.applyTreemapLayout=na,e.backFeature=ee,e.colorScaleFeature=ie,e.computeAxisLayout=function(e){
3864
4065
  // Free function from axisLayout.ts. Mutates `axis` (so instance-slot
3865
4066
  // readers stay in sync) and returns the layout artifacts; we re-shape
3866
4067
  // its result + the mutated instance fields into the stable `AxisLayout` API.
3867
- return Pe(e),{bounds:e._outerBounds,d3Scale:e._d3Scale,d3ScaleNegative:e._d3ScaleNegative,getPosition:t=>e._getPosition(t),availableTicks:e._availableTicks,visibleTicks:e._visibleTicks,margin:e._margin}},e.configPrep=G,e.constant=L,e.createFluent=function(e,t={}){const i=new Map(e.map(e=>[e.key,e])),s={};for(const i of e)i.key in t&&(s[i.key]=oe(i,t[i.key]));const n={};for(const t of e)n[t.key]=function(...e){return e.length?(s[t.key]=oe(t,e[0]),n):s[t.key]};return n.config=function(...e){if(!e.length)return{...s};const t=e[0];for(const e in t){if(!Object.prototype.hasOwnProperty.call(t,e))continue;const n=i.get(e);s[e]=n?oe(n,t[e]):t[e]}return n},n},e.geomapDef=Ks,e.installFluent=re,e.legendFeature=K,e.matrixDef=tn,e.measureAxis=Pe,e.networkDef=cn,e.packDef=mn,e.pieDef=Es,e.plotEmit=bs,e.plotPaint=ks,e.priestleyDef=yn,e.radarDef=kn,e.radialMatrixDef=Dn,e.renderAxes=Ui,e.resolveSpec=E,e.ringsDef=Bn,e.runLayout=U,e.runStages=he,e.runVizPipeline=_i,e.sankeyDef=Rn,e.subtitleFeature=Z,e.timelineFeature=te,e.titleFeature=Q,e.totalFeature=ne,e.treeDef=jn,e.treemapDef=Vn,e.vizDraw=Si,e.vizDrawPure=Ci,e.vizPostThresholdCtx=Di,e.vizPreDraw=Mi,e.vizPreDrawPure=zi});
4068
+ return Pe(e),{bounds:e._outerBounds,d3Scale:e._d3Scale,d3ScaleNegative:e._d3ScaleNegative,getPosition:t=>e._getPosition(t),availableTicks:e._availableTicks,visibleTicks:e._visibleTicks,margin:e._margin}},e.configPrep=G,e.constant=L,e.createFluent=function(e,t={}){const i=new Map(e.map(e=>[e.key,e])),s={};for(const i of e)i.key in t&&(s[i.key]=oe(i,t[i.key]));const n={};for(const t of e)n[t.key]=function(...e){return e.length?(s[t.key]=oe(t,e[0]),n):s[t.key]};return n.config=function(...e){if(!e.length)return{...s};const t=e[0];for(const e in t){if(!Object.prototype.hasOwnProperty.call(t,e))continue;const n=i.get(e);s[e]=n?oe(n,t[e]):t[e]}return n},n},e.geomapDef=cn,e.installFluent=re,e.legendFeature=K,e.matrixDef=pn,e.measureAxis=Pe,e.networkDef=vn,e.packDef=Dn,e.pieDef=Js,e.plotEmit=Os,e.plotPaint=Rs,e.priestleyDef=Bn,e.radarDef=Rn,e.radialMatrixDef=Hn,e.renderAxes=is,e.resolveSpec=E,e.ringsDef=qn,e.runLayout=U,e.runStages=he,e.runVizPipeline=vi,e.sankeyDef=Xn,e.subtitleFeature=Z,e.timelineFeature=te,e.titleFeature=Q,e.totalFeature=ne,e.treeDef=ia,e.treemapDef=ha,e.vizDraw=Mi,e.vizDrawPure=Di,e.vizPostThresholdCtx=Bi,e.vizPreDraw=Pi,e.vizPreDrawPure=$i});
3868
4069
  //# sourceMappingURL=d3plus-core.js.map