@aiconstructions/graficos 0.0.0-stage → 0.2.2

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 (267) hide show
  1. package/ALTERACOES.md +57 -0
  2. package/LICENSE-BKLIT +21 -0
  3. package/LICENSE-visx-pattern +21 -0
  4. package/README.md +189 -2
  5. package/dist/aic/cores.js +83 -0
  6. package/dist/aic/index.js +22 -0
  7. package/dist/aic/interacao.js +55 -0
  8. package/dist/charts/animation.js +55 -0
  9. package/dist/charts/arc-geometry.js +58 -0
  10. package/dist/charts/arc-path.js +15 -0
  11. package/dist/charts/area-chart-loading.js +89 -0
  12. package/dist/charts/area-chart.js +149 -0
  13. package/dist/charts/area-gradient-defs.js +90 -0
  14. package/dist/charts/area-value-label-layout.js +70 -0
  15. package/dist/charts/area-value-labels.js +211 -0
  16. package/dist/charts/area.js +272 -0
  17. package/dist/charts/background.js +198 -0
  18. package/dist/charts/band-config.js +82 -0
  19. package/dist/charts/band-geometry.js +186 -0
  20. package/dist/charts/band.js +346 -0
  21. package/dist/charts/bar-chart-loading.js +27 -0
  22. package/dist/charts/bar-chart.js +545 -0
  23. package/dist/charts/bar-depth-geometry.js +18 -0
  24. package/dist/charts/bar-depth.js +608 -0
  25. package/dist/charts/bar-lollipop.js +278 -0
  26. package/dist/charts/bar-squares-layout.js +66 -0
  27. package/dist/charts/bar-squares.js +467 -0
  28. package/dist/charts/bar-value-label-layout.js +42 -0
  29. package/dist/charts/bar-x-axis.js +133 -0
  30. package/dist/charts/bar-y-axis.js +116 -0
  31. package/dist/charts/bar.js +457 -0
  32. package/dist/charts/bollinger.js +49 -0
  33. package/dist/charts/candlestick-chart.js +370 -0
  34. package/dist/charts/candlestick.js +368 -0
  35. package/dist/charts/chart-brush-handle.js +91 -0
  36. package/dist/charts/chart-brush-layout.js +91 -0
  37. package/dist/charts/chart-brush-selection-overlay.js +87 -0
  38. package/dist/charts/chart-brush-state.js +253 -0
  39. package/dist/charts/chart-brush-track-overlay.js +103 -0
  40. package/dist/charts/chart-brush.js +517 -0
  41. package/dist/charts/chart-center-typography.js +8 -0
  42. package/dist/charts/chart-child-passthrough.js +119 -0
  43. package/dist/charts/chart-config-context.js +56 -0
  44. package/dist/charts/chart-context.js +337 -0
  45. package/dist/charts/chart-crosshair.js +262 -0
  46. package/dist/charts/chart-data-override.js +186 -0
  47. package/dist/charts/chart-defs.js +56 -0
  48. package/dist/charts/chart-formatters.js +77 -0
  49. package/dist/charts/chart-legend-hover.js +27 -0
  50. package/dist/charts/chart-legend.js +163 -0
  51. package/dist/charts/chart-loading-label.js +52 -0
  52. package/dist/charts/chart-parent-size.js +138 -0
  53. package/dist/charts/chart-phase.js +29 -0
  54. package/dist/charts/chart-reveal-clip.js +62 -0
  55. package/dist/charts/chart-scale.js +19 -0
  56. package/dist/charts/chart-stat-flow.js +72 -0
  57. package/dist/charts/choropleth/choropleth-background.js +29 -0
  58. package/dist/charts/choropleth/choropleth-camera.js +379 -0
  59. package/dist/charts/choropleth/choropleth-chart.js +644 -0
  60. package/dist/charts/choropleth/choropleth-context.js +152 -0
  61. package/dist/charts/choropleth/choropleth-dot-grid.js +293 -0
  62. package/dist/charts/choropleth/choropleth-feature.js +291 -0
  63. package/dist/charts/choropleth/choropleth-graticule.js +40 -0
  64. package/dist/charts/choropleth/choropleth-marker.js +222 -0
  65. package/dist/charts/choropleth/choropleth-projection.js +37 -0
  66. package/dist/charts/choropleth/choropleth-tooltip.js +82 -0
  67. package/dist/charts/choropleth/choropleth-zoom-matrix.js +150 -0
  68. package/dist/charts/choropleth/index.js +44 -0
  69. package/dist/charts/choropleth/use-choropleth-zoom-state.js +636 -0
  70. package/dist/charts/composed-chart.js +346 -0
  71. package/dist/charts/crosshair-store.js +49 -0
  72. package/dist/charts/dash-tail-stroke.js +58 -0
  73. package/dist/charts/date-pill-store.js +50 -0
  74. package/dist/charts/date-ranges.js +131 -0
  75. package/dist/charts/deadline.js +295 -0
  76. package/dist/charts/decimate-time-series.js +112 -0
  77. package/dist/charts/fade-edges.js +171 -0
  78. package/dist/charts/fast-path.js +78 -0
  79. package/dist/charts/filter-data-by-x-domain.js +45 -0
  80. package/dist/charts/funnel-chart.js +773 -0
  81. package/dist/charts/gauge-arc-layers.js +479 -0
  82. package/dist/charts/gauge-dial.js +329 -0
  83. package/dist/charts/gauge-label-layout.js +148 -0
  84. package/dist/charts/gauge.js +946 -0
  85. package/dist/charts/generate-chart-skeleton-data.js +27 -0
  86. package/dist/charts/gradients.js +158 -0
  87. package/dist/charts/grid-lines.js +114 -0
  88. package/dist/charts/grid.js +225 -0
  89. package/dist/charts/heatmap/generate-heatmap-skeleton-data.js +13 -0
  90. package/dist/charts/heatmap/heatmap-animation.js +128 -0
  91. package/dist/charts/heatmap/heatmap-cells.js +519 -0
  92. package/dist/charts/heatmap/heatmap-chart-loading.js +44 -0
  93. package/dist/charts/heatmap/heatmap-chart.js +548 -0
  94. package/dist/charts/heatmap/heatmap-colors.js +127 -0
  95. package/dist/charts/heatmap/heatmap-context.js +107 -0
  96. package/dist/charts/heatmap/heatmap-legend-gradient.js +97 -0
  97. package/dist/charts/heatmap/heatmap-legend-swatch.js +76 -0
  98. package/dist/charts/heatmap/heatmap-legend.js +165 -0
  99. package/dist/charts/heatmap/heatmap-pattern-defs.js +37 -0
  100. package/dist/charts/heatmap/heatmap-rect-cells.js +39 -0
  101. package/dist/charts/heatmap/heatmap-resolve-separator.js +84 -0
  102. package/dist/charts/heatmap/heatmap-separator.js +168 -0
  103. package/dist/charts/heatmap/heatmap-tooltip.js +73 -0
  104. package/dist/charts/heatmap/heatmap-utils.js +633 -0
  105. package/dist/charts/heatmap/heatmap-x-axis.js +79 -0
  106. package/dist/charts/heatmap/heatmap-y-axis.js +72 -0
  107. package/dist/charts/heatmap/index.js +208 -0
  108. package/dist/charts/highlight-segment-bounds.js +34 -0
  109. package/dist/charts/highlight-segment.js +119 -0
  110. package/dist/charts/index.js +944 -0
  111. package/dist/charts/indicator-fade.js +44 -0
  112. package/dist/charts/legend/index.js +22 -0
  113. package/dist/charts/legend/legend-context.js +47 -0
  114. package/dist/charts/legend/legend-item.js +30 -0
  115. package/dist/charts/legend/legend-label.js +14 -0
  116. package/dist/charts/legend/legend-marker.js +18 -0
  117. package/dist/charts/legend/legend-progress.js +39 -0
  118. package/dist/charts/legend/legend-value.js +31 -0
  119. package/dist/charts/legend/legend.js +69 -0
  120. package/dist/charts/line-backdrop.js +129 -0
  121. package/dist/charts/line-chart-loading.js +85 -0
  122. package/dist/charts/line-chart.js +182 -0
  123. package/dist/charts/line-loading-pulse.js +185 -0
  124. package/dist/charts/line-loading-timing.js +12 -0
  125. package/dist/charts/line-path.js +58 -0
  126. package/dist/charts/line-series-terminal-marker.js +75 -0
  127. package/dist/charts/line.js +499 -0
  128. package/dist/charts/live-line-chart.js +494 -0
  129. package/dist/charts/live-line.js +277 -0
  130. package/dist/charts/live-x-axis.js +116 -0
  131. package/dist/charts/live-y-axis.js +164 -0
  132. package/dist/charts/loading-sweep.js +344 -0
  133. package/dist/charts/local-point.js +56 -0
  134. package/dist/charts/markers/chart-markers.js +149 -0
  135. package/dist/charts/markers/index.js +14 -0
  136. package/dist/charts/markers/marker-group.js +411 -0
  137. package/dist/charts/motion-utils.js +29 -0
  138. package/dist/charts/notch-gauge-shared.js +146 -0
  139. package/dist/charts/particle-line.js +1340 -0
  140. package/dist/charts/path-stroke-utils.js +51 -0
  141. package/dist/charts/pattern-area.js +127 -0
  142. package/dist/charts/pattern-preset.js +287 -0
  143. package/dist/charts/pattern-tile.js +31 -0
  144. package/dist/charts/patterns/circles.js +62 -0
  145. package/dist/charts/patterns/constants.js +9 -0
  146. package/dist/charts/patterns/hexagons.js +38 -0
  147. package/dist/charts/patterns/index.js +16 -0
  148. package/dist/charts/patterns/lines.js +65 -0
  149. package/dist/charts/patterns/path.js +37 -0
  150. package/dist/charts/patterns/pattern.js +16 -0
  151. package/dist/charts/patterns/waves.js +40 -0
  152. package/dist/charts/pie-center-shell.js +127 -0
  153. package/dist/charts/pie-center.js +87 -0
  154. package/dist/charts/pie-chart.js +377 -0
  155. package/dist/charts/pie-context.js +116 -0
  156. package/dist/charts/pie-slice.js +394 -0
  157. package/dist/charts/pie-ticks.js +332 -0
  158. package/dist/charts/profit-loss-legend-hover.js +18 -0
  159. package/dist/charts/profit-loss-legend.js +53 -0
  160. package/dist/charts/profit-loss-line.js +162 -0
  161. package/dist/charts/profit-loss-segments.js +88 -0
  162. package/dist/charts/projection-config.js +90 -0
  163. package/dist/charts/projection-line-end-marker.js +50 -0
  164. package/dist/charts/projection-line.js +466 -0
  165. package/dist/charts/projection-utils.js +303 -0
  166. package/dist/charts/radar-area.js +192 -0
  167. package/dist/charts/radar-axis.js +41 -0
  168. package/dist/charts/radar-chart.js +184 -0
  169. package/dist/charts/radar-context.js +104 -0
  170. package/dist/charts/radar-grid.js +121 -0
  171. package/dist/charts/radar-labels.js +62 -0
  172. package/dist/charts/radial-area.js +498 -0
  173. package/dist/charts/radial-axis.js +652 -0
  174. package/dist/charts/radial-bar.js +316 -0
  175. package/dist/charts/radial-center.js +67 -0
  176. package/dist/charts/radial-chart.js +740 -0
  177. package/dist/charts/radial-dot-bar-layout.js +68 -0
  178. package/dist/charts/radial-dot-bar.js +387 -0
  179. package/dist/charts/radial-geometry.js +114 -0
  180. package/dist/charts/radial-legend.js +66 -0
  181. package/dist/charts/radial-line.js +280 -0
  182. package/dist/charts/radial-ring-bar.js +255 -0
  183. package/dist/charts/radial-scrubber.js +120 -0
  184. package/dist/charts/radial-series-color.js +10 -0
  185. package/dist/charts/reference-area-config.js +43 -0
  186. package/dist/charts/reference-area-geometry.js +76 -0
  187. package/dist/charts/reference-area-registration-context.js +10 -0
  188. package/dist/charts/reference-area.js +241 -0
  189. package/dist/charts/responsive-chart-label-count.js +18 -0
  190. package/dist/charts/ring-center.js +78 -0
  191. package/dist/charts/ring-chart.js +362 -0
  192. package/dist/charts/ring-context.js +122 -0
  193. package/dist/charts/ring-grid.js +175 -0
  194. package/dist/charts/ring-labels.js +109 -0
  195. package/dist/charts/ring.js +237 -0
  196. package/dist/charts/sankey/index.js +22 -0
  197. package/dist/charts/sankey/sankey-chart.js +199 -0
  198. package/dist/charts/sankey/sankey-context.js +32 -0
  199. package/dist/charts/sankey/sankey-link.js +232 -0
  200. package/dist/charts/sankey/sankey-node.js +348 -0
  201. package/dist/charts/sankey/sankey-tooltip.js +94 -0
  202. package/dist/charts/scatter-chart-shell.js +279 -0
  203. package/dist/charts/scatter-chart.js +150 -0
  204. package/dist/charts/scatter-jitter.js +86 -0
  205. package/dist/charts/scatter-svg.js +17 -0
  206. package/dist/charts/scatter.js +92 -0
  207. package/dist/charts/segment.js +107 -0
  208. package/dist/charts/series-bar-layout.js +42 -0
  209. package/dist/charts/series-bar.js +241 -0
  210. package/dist/charts/series-dash-tail-overlay.js +53 -0
  211. package/dist/charts/series-highlight-layer.js +43 -0
  212. package/dist/charts/series-hover-dim.js +32 -0
  213. package/dist/charts/series-markers.js +239 -0
  214. package/dist/charts/series-path-utils.js +185 -0
  215. package/dist/charts/series-point-marker.js +150 -0
  216. package/dist/charts/sparkline-geometry.js +197 -0
  217. package/dist/charts/sparkline.js +910 -0
  218. package/dist/charts/static-chart-preview-context.js +16 -0
  219. package/dist/charts/sunburst-breadcrumb.js +33 -0
  220. package/dist/charts/sunburst-center.js +37 -0
  221. package/dist/charts/sunburst-chart.js +408 -0
  222. package/dist/charts/sunburst-context.js +140 -0
  223. package/dist/charts/sunburst-data.js +0 -0
  224. package/dist/charts/sunburst-hint.js +42 -0
  225. package/dist/charts/sunburst-labels.js +130 -0
  226. package/dist/charts/sunburst-segment.js +144 -0
  227. package/dist/charts/sunburst.js +419 -0
  228. package/dist/charts/time-series-chart-shell.js +688 -0
  229. package/dist/charts/tooltip/chart-tooltip.js +516 -0
  230. package/dist/charts/tooltip/cursor-tooltip-box.js +183 -0
  231. package/dist/charts/tooltip/date-ticker.js +376 -0
  232. package/dist/charts/tooltip/index.js +32 -0
  233. package/dist/charts/tooltip/liquid-glass.js +142 -0
  234. package/dist/charts/tooltip/tooltip-box.js +502 -0
  235. package/dist/charts/tooltip/tooltip-content.js +59 -0
  236. package/dist/charts/tooltip/tooltip-dot.js +170 -0
  237. package/dist/charts/tooltip/tooltip-indicator.js +175 -0
  238. package/dist/charts/tooltip/use-delayed-tooltip-data.js +41 -0
  239. package/dist/charts/tooltip/use-velocity-stretch.js +52 -0
  240. package/dist/charts/trend-line-utils.js +64 -0
  241. package/dist/charts/trend-line.js +318 -0
  242. package/dist/charts/use-animated-band.js +175 -0
  243. package/dist/charts/use-animated-series-path.js +208 -0
  244. package/dist/charts/use-animated-y-domains.js +192 -0
  245. package/dist/charts/use-category-slots.js +29 -0
  246. package/dist/charts/use-chart-interaction.js +296 -0
  247. package/dist/charts/use-chart-phase-orchestrator.js +183 -0
  248. package/dist/charts/use-enter-complete.js +18 -0
  249. package/dist/charts/use-grid-shimmer.js +88 -0
  250. package/dist/charts/use-highlight-segment.js +65 -0
  251. package/dist/charts/use-mount-progress.js +23 -0
  252. package/dist/charts/use-scatter-chart-interaction.js +364 -0
  253. package/dist/charts/use-scheduled-tooltip.js +84 -0
  254. package/dist/charts/visx-pattern.js +30 -0
  255. package/dist/charts/weekends.js +174 -0
  256. package/dist/charts/x-axis-hover.js +46 -0
  257. package/dist/charts/x-axis.js +523 -0
  258. package/dist/charts/y-axis-scales.js +71 -0
  259. package/dist/charts/y-axis-ticks.js +22 -0
  260. package/dist/charts/y-axis.js +233 -0
  261. package/dist/charts/y-domain-utils.js +189 -0
  262. package/dist/index.d.ts +7346 -0
  263. package/dist/index.js +2 -0
  264. package/dist/lib/utils.js +8 -0
  265. package/dist/shimmering-text.js +54 -0
  266. package/package.json +78 -4
  267. package/tema.css +202 -0
@@ -0,0 +1,608 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { m } from "motion/react";
4
+ import {
5
+ createContext,
6
+ useContext,
7
+ useId,
8
+ useMemo
9
+ } from "react";
10
+ import { barDepthAndRise, barDepthMaxDepth } from "./bar-depth-geometry";
11
+ import { useChartHover, useChartStable } from "./chart-context";
12
+ import { transitionWithDelay } from "./motion-utils";
13
+ const BAR_DEPTH_MIN_PX = 0.5;
14
+ const BAR_FADED_OPACITY = 0.3;
15
+ const DEFAULT_BAR_COLOR = "var(--chart-line-primary)";
16
+ const DEFAULT_GROUND_SHADOW = 0.26;
17
+ const GLASS_TIP_OPACITY = 0.2;
18
+ const PULSE_WAVE_HEIGHT_RATIO = 0.55;
19
+ const PULSE_WAVE_HEIGHT_MIN_PX = 36;
20
+ const PULSE_WAVE_DURATION_S = 2.4;
21
+ const PULSE_WAVE_PEAK_OPACITY = 0.85;
22
+ const BAR_HOVER_TRANSITION = { duration: 0.15, ease: "easeOut" };
23
+ function resolveColor(datum, index, color, colorAccessor) {
24
+ return colorAccessor?.(datum, index) ?? color;
25
+ }
26
+ function sideFacePath(e, topEdge, bottomEdge) {
27
+ const rise = e.perspectiveRise;
28
+ if (e.isRightOfCenter) {
29
+ const x2 = e.bandX;
30
+ return `M ${x2} ${topEdge} L ${x2 - e.depth} ${topEdge - rise} L ${x2 - e.depth} ${bottomEdge - rise} L ${x2} ${bottomEdge} Z`;
31
+ }
32
+ const x = e.bandX + e.bandWidth;
33
+ return `M ${x} ${topEdge} L ${x + e.depth} ${topEdge - rise} L ${x + e.depth} ${bottomEdge - rise} L ${x} ${bottomEdge} Z`;
34
+ }
35
+ function lidFacePath(e) {
36
+ const rise = e.perspectiveRise;
37
+ const left = e.bandX;
38
+ const right = e.bandX + e.bandWidth;
39
+ if (e.isRightOfCenter) {
40
+ return `M ${left} ${e.topY} L ${right} ${e.topY} L ${right - e.depth} ${e.topY - rise} L ${left - e.depth} ${e.topY - rise} Z`;
41
+ }
42
+ return `M ${left} ${e.topY} L ${right} ${e.topY} L ${right + e.depth} ${e.topY - rise} L ${left + e.depth} ${e.topY - rise} Z`;
43
+ }
44
+ function buildSidePieces(e, visibleSegments, baseColor) {
45
+ if (!(visibleSegments && visibleSegments.length > 0)) {
46
+ return [{ path: sideFacePath(e, e.topY, e.bottomY), color: baseColor }];
47
+ }
48
+ const totalValue = visibleSegments.reduce((sum, s) => sum + s.value, 0);
49
+ const pieces = [];
50
+ let cursorY = e.bottomY;
51
+ for (let i = 0; i < visibleSegments.length; i++) {
52
+ const seg = visibleSegments[i];
53
+ if (!seg) {
54
+ continue;
55
+ }
56
+ const isTopmost = i === visibleSegments.length - 1;
57
+ const segScaledHeight = seg.value / totalValue * e.naturalHeight;
58
+ const segHeight = isTopmost ? Math.max(0, segScaledHeight - e.topYTrim) : segScaledHeight;
59
+ const segBottomY = cursorY;
60
+ const segTopY = cursorY - segHeight;
61
+ cursorY = segTopY;
62
+ pieces.push({
63
+ path: sideFacePath(e, segTopY, segBottomY),
64
+ color: seg.color
65
+ });
66
+ }
67
+ return pieces;
68
+ }
69
+ const BarDepthContext = createContext({});
70
+ function BarDepthProvider({
71
+ segmentsAccessor,
72
+ groundShadow,
73
+ minBarHeight,
74
+ children
75
+ }) {
76
+ const value = useMemo(
77
+ () => ({ segmentsAccessor, groundShadow, minBarHeight }),
78
+ [segmentsAccessor, groundShadow, minBarHeight]
79
+ );
80
+ return /* @__PURE__ */ jsx(BarDepthContext.Provider, { value, children });
81
+ }
82
+ BarDepthProvider.displayName = "BarDepthProvider";
83
+ function buildPosBarStops(groundShadow) {
84
+ return [
85
+ { offset: "0%", color: "white", opacity: String(GLASS_TIP_OPACITY) },
86
+ { offset: "3%", color: "white", opacity: "0.09" },
87
+ { offset: "8%", color: "white", opacity: "0.02" },
88
+ { offset: "55%", color: "white", opacity: "0" },
89
+ { offset: "100%", color: "black", opacity: String(groundShadow) }
90
+ ];
91
+ }
92
+ function buildNegBarStops(groundShadow) {
93
+ return [
94
+ { offset: "0%", color: "black", opacity: String(groundShadow) },
95
+ { offset: "45%", color: "white", opacity: "0" },
96
+ { offset: "92%", color: "white", opacity: "0.02" },
97
+ { offset: "97%", color: "white", opacity: "0.09" },
98
+ { offset: "100%", color: "white", opacity: String(GLASS_TIP_OPACITY) }
99
+ ];
100
+ }
101
+ function useGlassStops() {
102
+ const { groundShadow = DEFAULT_GROUND_SHADOW } = useContext(BarDepthContext);
103
+ return useMemo(
104
+ () => ({
105
+ posStops: buildPosBarStops(groundShadow),
106
+ negStops: buildNegBarStops(groundShadow)
107
+ }),
108
+ [groundShadow]
109
+ );
110
+ }
111
+ function readBarValue(d, key) {
112
+ const v = key ? d[key] : void 0;
113
+ return typeof v === "number" ? v : 0;
114
+ }
115
+ function useBarDepthEntries(dataKey, activeIndex) {
116
+ const {
117
+ data,
118
+ barScale,
119
+ bandWidth,
120
+ yScale,
121
+ innerHeight,
122
+ innerWidth,
123
+ barXAccessor
124
+ } = useChartStable();
125
+ const { segmentsAccessor, minBarHeight = 0 } = useContext(BarDepthContext);
126
+ return useMemo(() => {
127
+ if (!(barScale && bandWidth && barXAccessor)) {
128
+ return [];
129
+ }
130
+ const centerX = innerWidth / 2;
131
+ const zeroY = yScale(0) ?? innerHeight;
132
+ const step = barScale.step?.() ?? bandWidth;
133
+ const maxDepth = barDepthMaxDepth(step, bandWidth);
134
+ return data.flatMap((d, dataIndex) => {
135
+ const visibleSegs = segmentsAccessor?.(d)?.filter((s) => s.value > 0) ?? null;
136
+ const value = visibleSegs && visibleSegs.length > 0 ? visibleSegs.reduce((sum, s) => sum + s.value, 0) : readBarValue(d, dataKey);
137
+ const isActive = activeIndex != null && dataIndex === activeIndex;
138
+ const isNegative = value < 0;
139
+ const label = barXAccessor(d);
140
+ const bandX = barScale(label) ?? 0;
141
+ const cx = bandX + bandWidth / 2;
142
+ const valuePos = yScale(value) ?? innerHeight;
143
+ const rawHeight = Math.abs(zeroY - valuePos);
144
+ const naturalHeight = isNegative ? rawHeight : Math.max(rawHeight, minBarHeight);
145
+ if (naturalHeight <= 0) {
146
+ return [];
147
+ }
148
+ const isFloored = !isNegative && rawHeight < naturalHeight;
149
+ const offsetFromCenter = centerX > 0 ? (cx - centerX) / centerX : 0;
150
+ const isRightOfCenter = offsetFromCenter > 0;
151
+ const absOffset = Math.min(1, Math.abs(offsetFromCenter));
152
+ const { depth, perspectiveRise: rawRise } = barDepthAndRise(
153
+ absOffset,
154
+ naturalHeight,
155
+ maxDepth
156
+ );
157
+ const perspectiveRise = isNegative ? 0 : rawRise;
158
+ let trimClampReference = naturalHeight;
159
+ if (visibleSegs && visibleSegs.length > 0) {
160
+ const segTotal = visibleSegs.reduce((sum, s) => sum + s.value, 0);
161
+ const topmost = visibleSegs.at(-1);
162
+ if (segTotal > 0 && topmost) {
163
+ trimClampReference = topmost.value / segTotal * naturalHeight;
164
+ }
165
+ }
166
+ const isValueBar = naturalHeight > 0 && !isNegative && !isFloored;
167
+ const topYTrim = isValueBar ? Math.min(perspectiveRise, Math.max(0, trimClampReference - 1)) : 0;
168
+ const topY = isNegative ? zeroY : zeroY - naturalHeight + topYTrim;
169
+ const bottomY = isNegative ? zeroY + naturalHeight : zeroY;
170
+ const barHeight = bottomY - topY;
171
+ return [
172
+ {
173
+ label,
174
+ dataIndex,
175
+ datum: d,
176
+ isActive,
177
+ isNegative,
178
+ baselineY: zeroY,
179
+ bandX,
180
+ bandWidth,
181
+ topY,
182
+ bottomY,
183
+ barHeight,
184
+ naturalHeight,
185
+ topYTrim,
186
+ depth,
187
+ perspectiveRise,
188
+ isRightOfCenter
189
+ }
190
+ ];
191
+ });
192
+ }, [
193
+ data,
194
+ barScale,
195
+ bandWidth,
196
+ yScale,
197
+ innerHeight,
198
+ innerWidth,
199
+ barXAccessor,
200
+ segmentsAccessor,
201
+ minBarHeight,
202
+ dataKey,
203
+ activeIndex
204
+ ]);
205
+ }
206
+ function useBarDepthStagger() {
207
+ const { data, animationDuration } = useChartStable();
208
+ const total = animationDuration || 1100;
209
+ return data.length > 1 ? total * 0.4 / 1e3 / data.length : 0;
210
+ }
211
+ function BarDepthBack({
212
+ dataKey,
213
+ color = DEFAULT_BAR_COLOR,
214
+ colorAccessor
215
+ }) {
216
+ const { isLoaded, enterTransition, revealEpoch = 0 } = useChartStable();
217
+ const { hoveredBarIndex } = useChartHover();
218
+ const { segmentsAccessor } = useContext(BarDepthContext);
219
+ const entries = useBarDepthEntries(dataKey);
220
+ const stagger = useBarDepthStagger();
221
+ const { posStops: glassStops, negStops: glassNegStops } = useGlassStops();
222
+ const idPrefix = useId().replace(/[^a-z0-9]/gi, "_");
223
+ const sideShadeRtl = `bdb-side-rtl-${idPrefix}`;
224
+ const sideShadeLtr = `bdb-side-ltr-${idPrefix}`;
225
+ const topShade = `bdb-top-${idPrefix}`;
226
+ const sideGlass = `bdb-glass-${idPrefix}`;
227
+ const sideGlassNeg = `bdb-glass-neg-${idPrefix}`;
228
+ return /* @__PURE__ */ jsxs("g", { className: "bar-depth-back", pointerEvents: "none", children: [
229
+ /* @__PURE__ */ jsxs("defs", { children: [
230
+ /* @__PURE__ */ jsxs("linearGradient", { id: sideShadeRtl, x1: "1", x2: "0", y1: "0", y2: "1", children: [
231
+ /* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: "black", stopOpacity: "0.05" }),
232
+ /* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: "black", stopOpacity: "0.55" })
233
+ ] }),
234
+ /* @__PURE__ */ jsxs("linearGradient", { id: sideShadeLtr, x1: "0", x2: "1", y1: "0", y2: "1", children: [
235
+ /* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: "black", stopOpacity: "0.05" }),
236
+ /* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: "black", stopOpacity: "0.55" })
237
+ ] }),
238
+ /* @__PURE__ */ jsxs("linearGradient", { id: topShade, x1: "0", x2: "0", y1: "1", y2: "0", children: [
239
+ /* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: "black", stopOpacity: "0" }),
240
+ /* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: "black", stopOpacity: "0.18" })
241
+ ] }),
242
+ /* @__PURE__ */ jsx("linearGradient", { id: sideGlass, x1: "0", x2: "0", y1: "0", y2: "1", children: glassStops.map((stop) => /* @__PURE__ */ jsx(
243
+ "stop",
244
+ {
245
+ offset: stop.offset,
246
+ stopColor: stop.color,
247
+ stopOpacity: stop.opacity
248
+ },
249
+ `${stop.offset}-${stop.opacity}`
250
+ )) }),
251
+ /* @__PURE__ */ jsx("linearGradient", { id: sideGlassNeg, x1: "0", x2: "0", y1: "0", y2: "1", children: glassNegStops.map((stop) => /* @__PURE__ */ jsx(
252
+ "stop",
253
+ {
254
+ offset: stop.offset,
255
+ stopColor: stop.color,
256
+ stopOpacity: stop.opacity
257
+ },
258
+ `${stop.offset}-${stop.opacity}`
259
+ )) })
260
+ ] }),
261
+ entries.map((e) => {
262
+ if (e.depth < BAR_DEPTH_MIN_PX) {
263
+ return null;
264
+ }
265
+ const rawSegments = segmentsAccessor?.(e.datum);
266
+ const visibleSegments = rawSegments?.filter((s) => s.value > 0) ?? null;
267
+ const baseColor = resolveColor(
268
+ e.datum,
269
+ e.dataIndex,
270
+ color,
271
+ colorAccessor
272
+ );
273
+ const sidePieces = buildSidePieces(e, visibleSegments, baseColor);
274
+ const fullSidePath = sideFacePath(e, e.topY, e.bottomY);
275
+ const topPath = lidFacePath(e);
276
+ const topColor = visibleSegments?.at(-1)?.color ?? baseColor;
277
+ const delay = e.dataIndex * stagger;
278
+ const growTransition = isLoaded ? { duration: 0.3, ease: "easeOut" } : transitionWithDelay(enterTransition, delay);
279
+ const isFaded = hoveredBarIndex != null && hoveredBarIndex !== e.dataIndex;
280
+ const sideShadeId = e.isRightOfCenter ? sideShadeRtl : sideShadeLtr;
281
+ const safeId = e.label.replace(/[^a-z0-9]/gi, "_");
282
+ const clipId = `bdb-clip-${idPrefix}-${safeId}`;
283
+ let lidEntrance = {
284
+ initial: false,
285
+ animate: { y: 0 },
286
+ transition: { y: growTransition }
287
+ };
288
+ if (!isLoaded && e.isNegative) {
289
+ lidEntrance = {
290
+ initial: { y: 0, opacity: 0 },
291
+ animate: { y: 0, opacity: 1 },
292
+ transition: { y: growTransition, opacity: growTransition }
293
+ };
294
+ } else if (!isLoaded) {
295
+ lidEntrance = {
296
+ initial: { y: e.barHeight },
297
+ animate: { y: 0 },
298
+ transition: { y: growTransition }
299
+ };
300
+ }
301
+ return (
302
+ // Single hover-dim group for the whole back surface — side AND lid
303
+ // share this one opacity so they always fade in lockstep (mirrors
304
+ // `<Bar>`, which puts grow on the inner rect and hover-dim on a
305
+ // wrapping group). Entrance animations live on the inner groups.
306
+ /* @__PURE__ */ jsxs(
307
+ m.g,
308
+ {
309
+ animate: { opacity: isFaded ? BAR_FADED_OPACITY : 1 },
310
+ initial: false,
311
+ transition: BAR_HOVER_TRANSITION,
312
+ children: [
313
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("clipPath", { id: clipId, children: /* @__PURE__ */ jsx(
314
+ m.rect,
315
+ {
316
+ animate: {
317
+ y: e.topY - e.perspectiveRise,
318
+ height: e.barHeight + e.perspectiveRise
319
+ },
320
+ initial: isLoaded ? false : { y: e.baselineY, height: 0 },
321
+ transition: growTransition,
322
+ width: e.bandWidth + 2 * e.depth + 2,
323
+ x: e.bandX - e.depth - 1
324
+ },
325
+ `${clipId}-${revealEpoch}-${isLoaded}`
326
+ ) }) }),
327
+ /* @__PURE__ */ jsxs("g", { clipPath: `url(#${clipId})`, children: [
328
+ sidePieces.map((piece) => /* @__PURE__ */ jsx("path", { d: piece.path, fill: piece.color }, piece.path)),
329
+ /* @__PURE__ */ jsx("path", { d: fullSidePath, fill: `url(#${sideShadeId})` }),
330
+ /* @__PURE__ */ jsx(
331
+ "path",
332
+ {
333
+ d: fullSidePath,
334
+ fill: `url(#${e.isNegative ? sideGlassNeg : sideGlass})`
335
+ }
336
+ )
337
+ ] }),
338
+ /* @__PURE__ */ jsxs(
339
+ m.g,
340
+ {
341
+ animate: lidEntrance.animate,
342
+ initial: lidEntrance.initial,
343
+ transition: lidEntrance.transition,
344
+ children: [
345
+ /* @__PURE__ */ jsx("path", { d: topPath, fill: topColor }),
346
+ /* @__PURE__ */ jsx("path", { d: topPath, fill: "white", fillOpacity: GLASS_TIP_OPACITY }),
347
+ /* @__PURE__ */ jsx("path", { d: topPath, fill: `url(#${topShade})` })
348
+ ]
349
+ },
350
+ `lid-${safeId}-${revealEpoch}-${isLoaded}`
351
+ )
352
+ ]
353
+ },
354
+ e.label
355
+ )
356
+ );
357
+ })
358
+ ] });
359
+ }
360
+ BarDepthBack.displayName = "BarDepthBack";
361
+ BarDepthBack.__isBarDepthLayer = true;
362
+ function BarDepthFront({ dataKey }) {
363
+ const { isLoaded, enterTransition, revealEpoch = 0 } = useChartStable();
364
+ const { hoveredBarIndex } = useChartHover();
365
+ const entries = useBarDepthEntries(dataKey);
366
+ const stagger = useBarDepthStagger();
367
+ const { posStops: glassStops, negStops: glassNegStops } = useGlassStops();
368
+ const idPrefix = useId().replace(/[^a-z0-9]/gi, "_");
369
+ const glassId = `bdf-glass-${idPrefix}`;
370
+ const glassIdNeg = `bdf-glass-neg-${idPrefix}`;
371
+ return /* @__PURE__ */ jsxs("g", { className: "bar-depth-front", pointerEvents: "none", children: [
372
+ /* @__PURE__ */ jsxs("defs", { children: [
373
+ /* @__PURE__ */ jsx("linearGradient", { id: glassId, x1: "0", x2: "0", y1: "0", y2: "1", children: glassStops.map((stop) => /* @__PURE__ */ jsx(
374
+ "stop",
375
+ {
376
+ offset: stop.offset,
377
+ stopColor: stop.color,
378
+ stopOpacity: stop.opacity
379
+ },
380
+ `${stop.offset}-${stop.opacity}`
381
+ )) }),
382
+ /* @__PURE__ */ jsx("linearGradient", { id: glassIdNeg, x1: "0", x2: "0", y1: "0", y2: "1", children: glassNegStops.map((stop) => /* @__PURE__ */ jsx(
383
+ "stop",
384
+ {
385
+ offset: stop.offset,
386
+ stopColor: stop.color,
387
+ stopOpacity: stop.opacity
388
+ },
389
+ `${stop.offset}-${stop.opacity}`
390
+ )) })
391
+ ] }),
392
+ entries.map((e) => {
393
+ const delay = e.dataIndex * stagger;
394
+ const baseTransition = isLoaded ? { duration: 0.3, ease: "easeOut" } : transitionWithDelay(enterTransition, delay);
395
+ const isFaded = hoveredBarIndex != null && hoveredBarIndex !== e.dataIndex;
396
+ return /* @__PURE__ */ jsx(
397
+ m.rect,
398
+ {
399
+ animate: {
400
+ y: e.topY,
401
+ height: e.barHeight,
402
+ opacity: isFaded ? BAR_FADED_OPACITY : 1
403
+ },
404
+ fill: `url(#${e.isNegative ? glassIdNeg : glassId})`,
405
+ initial: isLoaded ? false : { y: e.baselineY, height: 0, opacity: 1 },
406
+ transition: { ...baseTransition, opacity: BAR_HOVER_TRANSITION },
407
+ width: e.bandWidth,
408
+ x: e.bandX
409
+ },
410
+ `${e.label}-${revealEpoch}-${isLoaded}`
411
+ );
412
+ })
413
+ ] });
414
+ }
415
+ BarDepthFront.displayName = "BarDepthFront";
416
+ BarDepthFront.__isBarDepthLayer = true;
417
+ function buildBarSilhouettePath(e) {
418
+ const {
419
+ bandX,
420
+ bandWidth,
421
+ topY,
422
+ bottomY,
423
+ depth,
424
+ perspectiveRise,
425
+ isRightOfCenter
426
+ } = e;
427
+ if (depth <= 0) {
428
+ return [
429
+ `M ${bandX} ${topY}`,
430
+ `L ${bandX + bandWidth} ${topY}`,
431
+ `L ${bandX + bandWidth} ${bottomY}`,
432
+ `L ${bandX} ${bottomY}`,
433
+ "Z"
434
+ ].join(" ");
435
+ }
436
+ if (isRightOfCenter) {
437
+ return [
438
+ `M ${bandX - depth} ${topY - perspectiveRise}`,
439
+ `L ${bandX + bandWidth - depth} ${topY - perspectiveRise}`,
440
+ `L ${bandX + bandWidth} ${topY}`,
441
+ `L ${bandX + bandWidth} ${bottomY}`,
442
+ `L ${bandX} ${bottomY}`,
443
+ `L ${bandX - depth} ${bottomY - perspectiveRise}`,
444
+ "Z"
445
+ ].join(" ");
446
+ }
447
+ return [
448
+ `M ${bandX} ${topY}`,
449
+ `L ${bandX + depth} ${topY - perspectiveRise}`,
450
+ `L ${bandX + bandWidth + depth} ${topY - perspectiveRise}`,
451
+ `L ${bandX + bandWidth + depth} ${bottomY - perspectiveRise}`,
452
+ `L ${bandX + bandWidth} ${bottomY}`,
453
+ `L ${bandX} ${bottomY}`,
454
+ "Z"
455
+ ].join(" ");
456
+ }
457
+ function BarPulse({ dataKey, activeIndex, pulsePaused }) {
458
+ const { isLoaded } = useChartStable();
459
+ const { hoveredBarIndex } = useChartHover();
460
+ const entries = useBarDepthEntries(dataKey, activeIndex);
461
+ const idPrefix = useId().replace(/[^a-z0-9]/gi, "_");
462
+ const activeEntries = useMemo(
463
+ () => entries.filter((e) => e.isActive),
464
+ [entries]
465
+ );
466
+ if (activeEntries.length === 0 || pulsePaused) {
467
+ return null;
468
+ }
469
+ if (!isLoaded) {
470
+ return null;
471
+ }
472
+ return /* @__PURE__ */ jsxs("g", { className: "bar-pulse", pointerEvents: "none", children: [
473
+ /* @__PURE__ */ jsx("defs", { children: activeEntries.flatMap((e) => {
474
+ const safeId = e.label.replace(/[^a-z0-9]/gi, "_");
475
+ const clipId = `bar-pulse-clip-${idPrefix}-${safeId}`;
476
+ const gradId = `bar-pulse-grad-${idPrefix}-${safeId}`;
477
+ return [
478
+ /* @__PURE__ */ jsx("clipPath", { id: clipId, children: /* @__PURE__ */ jsx("path", { d: buildBarSilhouettePath(e) }) }, `clip-${safeId}`),
479
+ // Vertical gradient with a centered bright band shaped into a soft
480
+ // bell curve. y1=1, y2=0 makes offset 50% the rect's center, so the
481
+ // brightest pixel sits mid-rect during travel.
482
+ /* @__PURE__ */ jsxs(
483
+ "linearGradient",
484
+ {
485
+ id: gradId,
486
+ x1: "0",
487
+ x2: "0",
488
+ y1: "1",
489
+ y2: "0",
490
+ children: [
491
+ /* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: "white", stopOpacity: "0" }),
492
+ /* @__PURE__ */ jsx("stop", { offset: "10%", stopColor: "white", stopOpacity: "0" }),
493
+ /* @__PURE__ */ jsx(
494
+ "stop",
495
+ {
496
+ offset: "22%",
497
+ stopColor: "white",
498
+ stopOpacity: PULSE_WAVE_PEAK_OPACITY * 0.18
499
+ }
500
+ ),
501
+ /* @__PURE__ */ jsx(
502
+ "stop",
503
+ {
504
+ offset: "34%",
505
+ stopColor: "white",
506
+ stopOpacity: PULSE_WAVE_PEAK_OPACITY * 0.5
507
+ }
508
+ ),
509
+ /* @__PURE__ */ jsx(
510
+ "stop",
511
+ {
512
+ offset: "44%",
513
+ stopColor: "white",
514
+ stopOpacity: PULSE_WAVE_PEAK_OPACITY * 0.85
515
+ }
516
+ ),
517
+ /* @__PURE__ */ jsx(
518
+ "stop",
519
+ {
520
+ offset: "50%",
521
+ stopColor: "white",
522
+ stopOpacity: PULSE_WAVE_PEAK_OPACITY
523
+ }
524
+ ),
525
+ /* @__PURE__ */ jsx(
526
+ "stop",
527
+ {
528
+ offset: "56%",
529
+ stopColor: "white",
530
+ stopOpacity: PULSE_WAVE_PEAK_OPACITY * 0.85
531
+ }
532
+ ),
533
+ /* @__PURE__ */ jsx(
534
+ "stop",
535
+ {
536
+ offset: "66%",
537
+ stopColor: "white",
538
+ stopOpacity: PULSE_WAVE_PEAK_OPACITY * 0.5
539
+ }
540
+ ),
541
+ /* @__PURE__ */ jsx(
542
+ "stop",
543
+ {
544
+ offset: "78%",
545
+ stopColor: "white",
546
+ stopOpacity: PULSE_WAVE_PEAK_OPACITY * 0.18
547
+ }
548
+ ),
549
+ /* @__PURE__ */ jsx("stop", { offset: "90%", stopColor: "white", stopOpacity: "0" }),
550
+ /* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: "white", stopOpacity: "0" })
551
+ ]
552
+ },
553
+ `grad-${safeId}`
554
+ )
555
+ ];
556
+ }) }),
557
+ activeEntries.map((e) => {
558
+ const safeId = e.label.replace(/[^a-z0-9]/gi, "_");
559
+ const clipId = `bar-pulse-clip-${idPrefix}-${safeId}`;
560
+ const gradId = `bar-pulse-grad-${idPrefix}-${safeId}`;
561
+ const waveHeight = Math.max(
562
+ e.barHeight * PULSE_WAVE_HEIGHT_RATIO,
563
+ PULSE_WAVE_HEIGHT_MIN_PX
564
+ );
565
+ const yAboveLid = e.topY - e.perspectiveRise - waveHeight;
566
+ const yBelowFloor = e.bottomY;
567
+ const yStart = e.isNegative ? yAboveLid : yBelowFloor;
568
+ const yEnd = e.isNegative ? yBelowFloor : yAboveLid;
569
+ const isFaded = hoveredBarIndex != null && hoveredBarIndex !== e.dataIndex;
570
+ return /* @__PURE__ */ jsx(
571
+ m.g,
572
+ {
573
+ animate: { opacity: isFaded ? BAR_FADED_OPACITY : 1 },
574
+ clipPath: `url(#${clipId})`,
575
+ initial: false,
576
+ transition: BAR_HOVER_TRANSITION,
577
+ children: /* @__PURE__ */ jsx(
578
+ m.rect,
579
+ {
580
+ animate: { y: yEnd },
581
+ fill: `url(#${gradId})`,
582
+ height: waveHeight,
583
+ initial: { y: yStart },
584
+ transition: {
585
+ duration: PULSE_WAVE_DURATION_S,
586
+ ease: "easeInOut",
587
+ repeat: Number.POSITIVE_INFINITY,
588
+ repeatType: "loop"
589
+ },
590
+ width: e.bandWidth + 2 * e.depth + 2,
591
+ x: e.bandX - e.depth - 1
592
+ }
593
+ )
594
+ },
595
+ e.label
596
+ );
597
+ })
598
+ ] });
599
+ }
600
+ BarPulse.displayName = "BarPulse";
601
+ BarPulse.__isBarDepthLayer = true;
602
+ export {
603
+ BarDepthBack,
604
+ BarDepthFront,
605
+ BarDepthProvider,
606
+ BarPulse,
607
+ useBarDepthEntries
608
+ };