@automattic/charts 1.1.0 → 1.1.1

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.
package/dist/index.js CHANGED
@@ -474,7 +474,7 @@ import clsx3 from "clsx";
474
474
  import { useCallback as useCallback7, useContext as useContext9, useState as useState6, useRef as useRef7, useMemo as useMemo15 } from "react";
475
475
 
476
476
  // src/components/legend/legend.tsx
477
- import { useContext as useContext5, useMemo as useMemo9, forwardRef as forwardRef2 } from "react";
477
+ import { useContext as useContext6, useMemo as useMemo10, forwardRef as forwardRef3 } from "react";
478
478
 
479
479
  // src/charts/private/single-chart-context/single-chart-context.tsx
480
480
  import { createContext } from "react";
@@ -1629,1237 +1629,1242 @@ var useGlobalChartsTheme = () => {
1629
1629
  import { Group } from "@visx/group";
1630
1630
  import { LegendItem, LegendLabel, LegendOrdinal, LegendShape } from "@visx/legend";
1631
1631
  import { scaleOrdinal } from "@visx/scale";
1632
- import clsx from "clsx";
1633
- import { forwardRef, useCallback as useCallback4, useContext as useContext4 } from "react";
1634
1632
 
1635
- // src/components/legend/utils/value-or-identity.ts
1636
- function valueOrIdentity(_) {
1637
- if (_ && typeof _ === "object" && "value" in _ && typeof _.value !== "undefined")
1638
- return _.value;
1639
- return _;
1633
+ // ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/useRefWithInit.js
1634
+ import * as React from "react";
1635
+ var UNINITIALIZED = {};
1636
+ function useRefWithInit(init, initArg) {
1637
+ const ref = React.useRef(UNINITIALIZED);
1638
+ if (ref.current === UNINITIALIZED) {
1639
+ ref.current = init(initArg);
1640
+ }
1641
+ return ref;
1640
1642
  }
1641
- function valueOrIdentityString(_) {
1642
- return String(valueOrIdentity(_));
1643
+
1644
+ // ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/warn.js
1645
+ var set;
1646
+ if (process.env.NODE_ENV !== "production") {
1647
+ set = /* @__PURE__ */ new Set();
1648
+ }
1649
+ function warn(...messages) {
1650
+ if (process.env.NODE_ENV !== "production") {
1651
+ const messageKey = messages.join(" ");
1652
+ if (!set.has(messageKey)) {
1653
+ set.add(messageKey);
1654
+ console.warn(`Base UI: ${messageKey}`);
1655
+ }
1656
+ }
1643
1657
  }
1644
1658
 
1645
- // src/components/legend/utils/label-transform-factory.ts
1646
- function labelTransformFactory({
1647
- scale,
1648
- labelFormat
1649
- }) {
1650
- return (d, i) => ({
1651
- datum: d,
1652
- index: i,
1653
- text: `${labelFormat(d, i)}`,
1654
- value: scale(d)
1655
- });
1659
+ // ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/formatErrorMessage.js
1660
+ function createFormatErrorMessage(baseUrl, prefix2) {
1661
+ return function formatErrorMessage2(code, ...args) {
1662
+ const url = new URL(baseUrl);
1663
+ url.searchParams.set("code", code.toString());
1664
+ args.forEach((arg) => url.searchParams.append("args[]", arg));
1665
+ return `${prefix2} error #${code}; visit ${url} for the full message.`;
1666
+ };
1656
1667
  }
1668
+ var formatErrorMessage = createFormatErrorMessage("https://base-ui.com/production-error", "Base UI");
1669
+ var formatErrorMessage_default = formatErrorMessage;
1657
1670
 
1658
- // src/components/legend/private/base-legend.module.scss
1659
- var base_legend_module_default = {
1660
- "legend": "a8ccharts-89ApsU",
1661
- "legend--horizontal": "a8ccharts-AELBvX",
1662
- "legend--vertical": "a8ccharts-fX8uQe",
1663
- "legend--alignment-start": "a8ccharts-DEe0wg",
1664
- "legend--alignment-center": "a8ccharts-WBKF9I",
1665
- "legend--alignment-end": "a8ccharts-JfwMng",
1666
- "legend-item": "a8ccharts-Vflwq8",
1667
- "legend-item--interactive": "a8ccharts-qGsavM",
1668
- "legend-item--inactive": "a8ccharts-ZtDY-Q",
1669
- "legend-item-label": "a8ccharts-2H65Kr",
1670
- "legend-item-text--wrap": "a8ccharts-faSDBI",
1671
- "legend-item-text--ellipsis": "a8ccharts-FISUIO",
1672
- "legend-item-value": "a8ccharts-DTZlT-"
1673
- };
1671
+ // ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/useRenderElement.js
1672
+ import * as React4 from "react";
1674
1673
 
1675
- // src/components/legend/private/base-legend.tsx
1676
- import { jsx as _jsx2, jsxs as _jsxs } from "react/jsx-runtime";
1677
- var orientationToFlexDirection = {
1678
- horizontal: "row",
1679
- vertical: "column"
1680
- };
1681
- var LegendText = ({
1682
- text,
1683
- textOverflow,
1684
- maxWidth
1685
- }) => {
1686
- const isEllipsis = maxWidth != null && textOverflow === "ellipsis";
1687
- const [textRef, isTruncated] = useTextTruncation(Boolean(isEllipsis));
1688
- return /* @__PURE__ */ _jsx2("span", {
1689
- ref: textRef,
1690
- className: clsx(base_legend_module_default["legend-item-text"], maxWidth != null && base_legend_module_default[`legend-item-text--${textOverflow}`]),
1691
- style: {
1692
- ...maxWidth != null && {
1693
- maxWidth,
1694
- minWidth: 0
1695
- }
1696
- },
1697
- title: isEllipsis && isTruncated ? text : void 0,
1698
- children: text
1699
- });
1700
- };
1701
- var BaseLegend = /* @__PURE__ */ forwardRef(({
1702
- items,
1703
- className,
1704
- orientation = "horizontal",
1705
- alignment = "center",
1706
- shape = "rect",
1707
- fill = valueOrIdentityString,
1708
- size = valueOrIdentityString,
1709
- labelFormat = valueOrIdentity,
1710
- labelTransform = labelTransformFactory,
1711
- itemStyles,
1712
- itemClassName,
1713
- labelStyles,
1714
- labelClassName,
1715
- shapeStyles,
1716
- render,
1717
- interactive = false,
1718
- chartId
1719
- }, ref) => {
1720
- const {
1721
- margin: itemMargin = "0",
1722
- flexDirection: itemDirection = "row"
1723
- } = itemStyles ?? {};
1724
- const {
1725
- justifyContent: labelJustifyContent = "flex-start",
1726
- flex: labelFlex = "0 0 auto",
1727
- margin: labelMargin = "0 4px",
1728
- maxWidth,
1729
- textOverflow = "wrap"
1730
- } = labelStyles ?? {};
1731
- const {
1732
- width: shapeWidth = 16,
1733
- height: shapeHeight = 16,
1734
- margin: shapeMargin = "2px 4px 2px 0"
1735
- } = shapeStyles ?? {};
1736
- const theme = useGlobalChartsTheme();
1737
- const context = useContext4(GlobalChartsContext);
1738
- const legendScale = scaleOrdinal({
1739
- domain: items.map((item) => item.label),
1740
- range: items.map((item) => item.color)
1741
- });
1742
- const domain = legendScale.domain();
1743
- const getShapeStyle = useCallback4(({
1744
- index
1745
- }) => items[index]?.shapeStyle, [items]);
1746
- const handleLegendClick = useCallback4((seriesLabel) => {
1747
- if (interactive && chartId && context) {
1748
- context.toggleSeriesVisibility(chartId, seriesLabel);
1749
- }
1750
- }, [interactive, chartId, context]);
1751
- const isSeriesVisible = useCallback4((seriesLabel) => {
1752
- if (!interactive || !chartId || !context) {
1753
- return true;
1754
- }
1755
- return context.isSeriesVisible(chartId, seriesLabel);
1756
- }, [interactive, chartId, context]);
1757
- const createClickHandler = useCallback4((labelText) => {
1758
- if (!interactive) {
1759
- return void 0;
1760
- }
1761
- return () => handleLegendClick(labelText);
1762
- }, [interactive, handleLegendClick]);
1763
- const createKeyDownHandler = useCallback4((labelText) => {
1764
- if (!interactive) {
1765
- return void 0;
1674
+ // ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/useMergedRefs.js
1675
+ function useMergedRefs(a, b, c, d) {
1676
+ const forkRef = useRefWithInit(createForkRef).current;
1677
+ if (didChange(forkRef, a, b, c, d)) {
1678
+ update(forkRef, [a, b, c, d]);
1679
+ }
1680
+ return forkRef.callback;
1681
+ }
1682
+ function useMergedRefsN(refs) {
1683
+ const forkRef = useRefWithInit(createForkRef).current;
1684
+ if (didChangeN(forkRef, refs)) {
1685
+ update(forkRef, refs);
1686
+ }
1687
+ return forkRef.callback;
1688
+ }
1689
+ function createForkRef() {
1690
+ return {
1691
+ callback: null,
1692
+ cleanup: null,
1693
+ refs: []
1694
+ };
1695
+ }
1696
+ function didChange(forkRef, a, b, c, d) {
1697
+ return forkRef.refs[0] !== a || forkRef.refs[1] !== b || forkRef.refs[2] !== c || forkRef.refs[3] !== d;
1698
+ }
1699
+ function didChangeN(forkRef, newRefs) {
1700
+ return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index) => ref !== newRefs[index]);
1701
+ }
1702
+ function update(forkRef, refs) {
1703
+ forkRef.refs = refs;
1704
+ if (refs.every((ref) => ref == null)) {
1705
+ forkRef.callback = null;
1706
+ return;
1707
+ }
1708
+ forkRef.callback = (instance) => {
1709
+ if (forkRef.cleanup) {
1710
+ forkRef.cleanup();
1711
+ forkRef.cleanup = null;
1766
1712
  }
1767
- return (event) => {
1768
- if (event.key === "Enter" || event.key === " ") {
1769
- event.preventDefault();
1770
- handleLegendClick(labelText);
1713
+ if (instance != null) {
1714
+ const cleanupCallbacks = Array(refs.length).fill(null);
1715
+ for (let i = 0; i < refs.length; i += 1) {
1716
+ const ref = refs[i];
1717
+ if (ref == null) {
1718
+ continue;
1719
+ }
1720
+ switch (typeof ref) {
1721
+ case "function": {
1722
+ const refCleanup = ref(instance);
1723
+ if (typeof refCleanup === "function") {
1724
+ cleanupCallbacks[i] = refCleanup;
1725
+ }
1726
+ break;
1727
+ }
1728
+ case "object": {
1729
+ ref.current = instance;
1730
+ break;
1731
+ }
1732
+ default:
1733
+ }
1771
1734
  }
1772
- };
1773
- }, [interactive, handleLegendClick]);
1774
- return render ? render(items) : /* @__PURE__ */ _jsx2(LegendOrdinal, {
1775
- scale: legendScale,
1776
- labelFormat,
1777
- labelTransform,
1778
- children: (labels) => /* @__PURE__ */ _jsx2("div", {
1779
- ref,
1780
- role: "list",
1781
- className: clsx(base_legend_module_default.legend, base_legend_module_default[`legend--${orientation}`], base_legend_module_default[`legend--alignment-${alignment}`], className),
1782
- style: {
1783
- flexDirection: orientationToFlexDirection[orientation],
1784
- ...theme.legend?.containerStyles
1785
- },
1786
- children: labels.map((label, i) => {
1787
- const visible = isSeriesVisible(label.text);
1788
- const handleClick = createClickHandler(label.text);
1789
- const handleKeyDown = createKeyDownHandler(label.text);
1790
- const matchedItem = items[i];
1791
- return /* @__PURE__ */ _jsxs(LegendItem, {
1792
- className: clsx("visx-legend-item", base_legend_module_default["legend-item"], interactive && base_legend_module_default["legend-item--interactive"], !visible && base_legend_module_default["legend-item--inactive"], itemClassName),
1793
- margin: itemMargin,
1794
- flexDirection: orientation === "vertical" && alignment === "end" ? "row-reverse" : itemDirection,
1795
- onClick: handleClick,
1796
- onKeyDown: handleKeyDown,
1797
- role: interactive ? "button" : void 0,
1798
- tabIndex: interactive ? 0 : void 0,
1799
- "aria-pressed": interactive ? visible : void 0,
1800
- "aria-label": interactive ? `${label.text}: ${visible ? "visible" : "hidden"}. Toggle visibility.` : void 0,
1801
- children: [items[i]?.renderGlyph ? /* @__PURE__ */ _jsx2("svg", {
1802
- width: items[i]?.glyphSize * 2,
1803
- height: items[i]?.glyphSize * 2,
1804
- children: /* @__PURE__ */ _jsx2(Group, {
1805
- children: items[i]?.renderGlyph({
1806
- key: `legend-glyph-${label.text}`,
1807
- datum: {},
1808
- index: i,
1809
- color: fill(label),
1810
- size: items[i]?.glyphSize,
1811
- x: items[i]?.glyphSize,
1812
- y: items[i]?.glyphSize
1813
- })
1814
- })
1815
- }) : /* @__PURE__ */ _jsx2(LegendShape, {
1816
- shape,
1817
- height: shapeHeight,
1818
- width: shapeWidth,
1819
- margin: shapeMargin,
1820
- item: domain[i],
1821
- itemIndex: i,
1822
- label,
1823
- fill,
1824
- size,
1825
- shapeStyle: getShapeStyle
1826
- }), /* @__PURE__ */ _jsxs(LegendLabel, {
1827
- className: clsx("visx-legend-label", base_legend_module_default["legend-item-label"], labelClassName),
1828
- style: {
1829
- justifyContent: labelJustifyContent,
1830
- flex: labelFlex,
1831
- margin: labelMargin,
1832
- ...theme.legend?.labelStyles
1833
- },
1834
- children: [/* @__PURE__ */ _jsx2(LegendText, {
1835
- text: label.text,
1836
- textOverflow,
1837
- maxWidth
1838
- }), matchedItem?.value != null && matchedItem.value !== "" && /* @__PURE__ */ _jsxs("span", {
1839
- className: base_legend_module_default["legend-item-value"],
1840
- children: ["\xA0", matchedItem.value]
1841
- })]
1842
- })]
1843
- }, `legend-${label.text}-${i}`);
1844
- })
1845
- })
1846
- });
1847
- });
1735
+ forkRef.cleanup = () => {
1736
+ for (let i = 0; i < refs.length; i += 1) {
1737
+ const ref = refs[i];
1738
+ if (ref == null) {
1739
+ continue;
1740
+ }
1741
+ switch (typeof ref) {
1742
+ case "function": {
1743
+ const cleanupCallback = cleanupCallbacks[i];
1744
+ if (typeof cleanupCallback === "function") {
1745
+ cleanupCallback();
1746
+ } else {
1747
+ ref(null);
1748
+ }
1749
+ break;
1750
+ }
1751
+ case "object": {
1752
+ ref.current = null;
1753
+ break;
1754
+ }
1755
+ default:
1756
+ }
1757
+ }
1758
+ };
1759
+ }
1760
+ };
1761
+ }
1848
1762
 
1849
- // src/components/legend/legend.tsx
1850
- import { jsx as _jsx3 } from "react/jsx-runtime";
1851
- var defaultShapeByChartType = {
1852
- line: "line",
1853
- bar: "rect",
1854
- pie: "circle",
1855
- "pie-semi-circle": "circle",
1856
- leaderboard: "circle"
1857
- };
1858
- var Legend = /* @__PURE__ */ forwardRef2(({
1859
- chartId,
1860
- items,
1861
- shape,
1862
- ...props
1863
- }, ref) => {
1864
- const context = useContext5(GlobalChartsContext);
1865
- const singleChartContext = useContext5(SingleChartContext);
1866
- const contextChartId = chartId ?? singleChartContext?.chartId;
1867
- const chartData = useMemo9(() => contextChartId && context ? context.getChartData(contextChartId) : void 0, [contextChartId, context]);
1868
- const contextItems = chartData?.legendItems;
1869
- const resolvedShape = shape ?? (chartData?.chartType ? defaultShapeByChartType[chartData.chartType] : void 0);
1870
- const legendItems = items || contextItems;
1871
- if (!legendItems) {
1763
+ // ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/getReactElementRef.js
1764
+ import * as React3 from "react";
1765
+
1766
+ // ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/reactVersion.js
1767
+ import * as React2 from "react";
1768
+ var majorVersion = parseInt(React2.version, 10);
1769
+ function isReactVersionAtLeast(reactVersionToCheck) {
1770
+ return majorVersion >= reactVersionToCheck;
1771
+ }
1772
+
1773
+ // ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/getReactElementRef.js
1774
+ function getReactElementRef(element) {
1775
+ if (!/* @__PURE__ */ React3.isValidElement(element)) {
1872
1776
  return null;
1873
1777
  }
1874
- return /* @__PURE__ */ _jsx3(BaseLegend, {
1875
- ref,
1876
- items: legendItems,
1877
- shape: resolvedShape,
1878
- ...props,
1879
- chartId: contextChartId
1880
- });
1881
- });
1778
+ const reactElement = element;
1779
+ const propsWithRef = reactElement.props;
1780
+ return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1781
+ }
1882
1782
 
1883
- // src/components/legend/hooks/use-chart-legend-items.ts
1884
- import { formatNumber as formatNumber3 } from "@automattic/number-formatters";
1885
- import { useMemo as useMemo10 } from "react";
1886
- function formatPointValue(point, showValues, legendValueDisplay = "percentage") {
1887
- if (!showValues || legendValueDisplay === "none") {
1888
- return "";
1783
+ // ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/mergeObjects.js
1784
+ function mergeObjects(a, b) {
1785
+ if (a && !b) {
1786
+ return a;
1889
1787
  }
1890
- if ("percentage" in point) {
1891
- switch (legendValueDisplay) {
1892
- case "percentage":
1893
- return formatPercentage(point.percentage);
1894
- case "value":
1895
- return formatNumber3(point.value);
1896
- case "valueDisplay":
1897
- return point.valueDisplay || formatNumber3(point.value);
1898
- default:
1899
- return "";
1900
- }
1788
+ if (!a && b) {
1789
+ return b;
1901
1790
  }
1902
- if ("value" in point) {
1903
- return point.value !== null ? formatNumber3(point.value) : "";
1791
+ if (a || b) {
1792
+ return {
1793
+ ...a,
1794
+ ...b
1795
+ };
1904
1796
  }
1905
- return "";
1797
+ return void 0;
1906
1798
  }
1907
- function applyGlyphToLegendItem(baseItem, withGlyph, glyph, renderGlyph, glyphSize) {
1908
- if (withGlyph) {
1909
- const glyphToUse = glyph || renderGlyph;
1910
- if (glyphToUse) {
1911
- return {
1912
- ...baseItem,
1913
- glyphSize,
1914
- renderGlyph: glyphToUse
1915
- };
1799
+
1800
+ // ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/getStateAttributesProps.js
1801
+ function getStateAttributesProps(state, customMapping) {
1802
+ const props = {};
1803
+ for (const key in state) {
1804
+ const value = state[key];
1805
+ if (customMapping?.hasOwnProperty(key)) {
1806
+ const customProps = customMapping[key](value);
1807
+ if (customProps != null) {
1808
+ Object.assign(props, customProps);
1809
+ }
1810
+ continue;
1811
+ }
1812
+ if (value === true) {
1813
+ props[`data-${key.toLowerCase()}`] = "";
1814
+ } else if (value) {
1815
+ props[`data-${key.toLowerCase()}`] = value.toString();
1916
1816
  }
1917
1817
  }
1918
- return baseItem;
1818
+ return props;
1919
1819
  }
1920
- function processSeriesData(seriesData, getElementStyles, showValues, withGlyph, glyphSize, renderGlyph, legendShape) {
1921
- const mapper = (series, index) => {
1922
- const { color, glyph, shapeStyles } = getElementStyles({
1923
- data: series,
1924
- index,
1925
- legendShape
1926
- });
1927
- const baseItem = {
1928
- label: series.label,
1929
- value: showValues ? series.data?.length?.toString() || "0" : "",
1930
- color,
1931
- shapeStyle: shapeStyles
1932
- };
1933
- return applyGlyphToLegendItem(baseItem, withGlyph, glyph, renderGlyph, glyphSize);
1820
+
1821
+ // ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/resolveClassName.js
1822
+ function resolveClassName(className, state) {
1823
+ return typeof className === "function" ? className(state) : className;
1824
+ }
1825
+
1826
+ // ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/resolveStyle.js
1827
+ function resolveStyle(style, state) {
1828
+ return typeof style === "function" ? style(state) : style;
1829
+ }
1830
+
1831
+ // ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/merge-props/mergeProps.js
1832
+ var EMPTY_PROPS = {};
1833
+ function mergeProps(a, b, c, d, e) {
1834
+ let merged = {
1835
+ ...resolvePropsGetter(a, EMPTY_PROPS)
1934
1836
  };
1935
- return seriesData.map(mapper);
1837
+ if (b) {
1838
+ merged = mergeOne(merged, b);
1839
+ }
1840
+ if (c) {
1841
+ merged = mergeOne(merged, c);
1842
+ }
1843
+ if (d) {
1844
+ merged = mergeOne(merged, d);
1845
+ }
1846
+ if (e) {
1847
+ merged = mergeOne(merged, e);
1848
+ }
1849
+ return merged;
1936
1850
  }
1937
- function processPointData(pointData, getElementStyles, showValues, legendValueDisplay, withGlyph, glyphSize, renderGlyph, legendShape) {
1938
- const mapper = (point, index) => {
1939
- const { color, glyph, shapeStyles } = getElementStyles({
1940
- data: point,
1941
- index,
1942
- legendShape
1943
- });
1944
- const baseItem = {
1945
- label: point.label,
1946
- value: formatPointValue(point, showValues, legendValueDisplay),
1947
- color,
1948
- shapeStyle: shapeStyles
1949
- };
1950
- return applyGlyphToLegendItem(baseItem, withGlyph, glyph, renderGlyph, glyphSize);
1851
+ function mergePropsN(props) {
1852
+ if (props.length === 0) {
1853
+ return EMPTY_PROPS;
1854
+ }
1855
+ if (props.length === 1) {
1856
+ return resolvePropsGetter(props[0], EMPTY_PROPS);
1857
+ }
1858
+ let merged = {
1859
+ ...resolvePropsGetter(props[0], EMPTY_PROPS)
1951
1860
  };
1952
- return pointData.map(mapper);
1861
+ for (let i = 1; i < props.length; i += 1) {
1862
+ merged = mergeOne(merged, props[i]);
1863
+ }
1864
+ return merged;
1953
1865
  }
1954
- function useChartLegendItems(data, options = {}, legendShape) {
1955
- const {
1956
- showValues = false,
1957
- legendValueDisplay = "percentage",
1958
- withGlyph = false,
1959
- glyphSize = 8,
1960
- renderGlyph
1961
- } = options;
1962
- const { getElementStyles } = useGlobalChartsContext();
1963
- return useMemo10(() => {
1964
- if (!data || !Array.isArray(data) || data.length === 0) {
1965
- return [];
1866
+ function mergeOne(merged, inputProps) {
1867
+ if (isPropsGetter(inputProps)) {
1868
+ return inputProps(merged);
1869
+ }
1870
+ return mutablyMergeInto(merged, inputProps);
1871
+ }
1872
+ function mutablyMergeInto(mergedProps, externalProps) {
1873
+ if (!externalProps) {
1874
+ return mergedProps;
1875
+ }
1876
+ for (const propName in externalProps) {
1877
+ const externalPropValue = externalProps[propName];
1878
+ switch (propName) {
1879
+ case "style": {
1880
+ mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1881
+ break;
1882
+ }
1883
+ case "className": {
1884
+ mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1885
+ break;
1886
+ }
1887
+ default: {
1888
+ if (isEventHandler(propName, externalPropValue)) {
1889
+ mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1890
+ } else {
1891
+ mergedProps[propName] = externalPropValue;
1892
+ }
1893
+ }
1966
1894
  }
1967
- if ("data" in data[0]) {
1968
- return processSeriesData(
1969
- data,
1970
- getElementStyles,
1971
- showValues,
1972
- withGlyph,
1973
- glyphSize,
1974
- renderGlyph,
1975
- legendShape
1976
- );
1895
+ }
1896
+ return mergedProps;
1897
+ }
1898
+ function isEventHandler(key, value) {
1899
+ const code0 = key.charCodeAt(0);
1900
+ const code1 = key.charCodeAt(1);
1901
+ const code2 = key.charCodeAt(2);
1902
+ return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1903
+ }
1904
+ function isPropsGetter(inputProps) {
1905
+ return typeof inputProps === "function";
1906
+ }
1907
+ function resolvePropsGetter(inputProps, previousProps) {
1908
+ if (isPropsGetter(inputProps)) {
1909
+ return inputProps(previousProps);
1910
+ }
1911
+ return inputProps ?? EMPTY_PROPS;
1912
+ }
1913
+ function mergeEventHandlers(ourHandler, theirHandler) {
1914
+ if (!theirHandler) {
1915
+ return ourHandler;
1916
+ }
1917
+ if (!ourHandler) {
1918
+ return theirHandler;
1919
+ }
1920
+ return (event) => {
1921
+ if (isSyntheticEvent(event)) {
1922
+ const baseUIEvent = event;
1923
+ makeEventPreventable(baseUIEvent);
1924
+ const result2 = theirHandler(baseUIEvent);
1925
+ if (!baseUIEvent.baseUIHandlerPrevented) {
1926
+ ourHandler?.(baseUIEvent);
1927
+ }
1928
+ return result2;
1977
1929
  }
1978
- return processPointData(
1979
- data,
1980
- getElementStyles,
1981
- showValues,
1982
- legendValueDisplay,
1983
- withGlyph,
1984
- glyphSize,
1985
- renderGlyph,
1986
- legendShape
1987
- );
1988
- }, [
1989
- data,
1990
- getElementStyles,
1991
- showValues,
1992
- legendValueDisplay,
1993
- withGlyph,
1994
- glyphSize,
1995
- renderGlyph,
1996
- legendShape
1997
- ]);
1930
+ const result = theirHandler(event);
1931
+ ourHandler?.(event);
1932
+ return result;
1933
+ };
1934
+ }
1935
+ function makeEventPreventable(event) {
1936
+ event.preventBaseUIHandler = () => {
1937
+ event.baseUIHandlerPrevented = true;
1938
+ };
1939
+ return event;
1940
+ }
1941
+ function mergeClassNames(ourClassName, theirClassName) {
1942
+ if (theirClassName) {
1943
+ if (ourClassName) {
1944
+ return theirClassName + " " + ourClassName;
1945
+ }
1946
+ return theirClassName;
1947
+ }
1948
+ return ourClassName;
1949
+ }
1950
+ function isSyntheticEvent(event) {
1951
+ return event != null && typeof event === "object" && "nativeEvent" in event;
1998
1952
  }
1999
1953
 
2000
- // src/components/tooltip/base-tooltip.tsx
2001
- import { formatNumber as formatNumber4 } from "@automattic/number-formatters";
1954
+ // ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/empty.js
1955
+ var EMPTY_ARRAY = Object.freeze([]);
1956
+ var EMPTY_OBJECT = Object.freeze({});
2002
1957
 
2003
- // src/components/tooltip/base-tooltip.module.scss
2004
- var base_tooltip_module_default = {
2005
- "tooltip": "a8ccharts-OfX6nd"
2006
- };
1958
+ // ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/constants.js
1959
+ var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
1960
+ var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
1961
+ var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
1962
+ var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
2007
1963
 
2008
- // src/components/tooltip/base-tooltip.tsx
2009
- import { Fragment as _Fragment, jsxs as _jsxs2, jsx as _jsx4 } from "react/jsx-runtime";
2010
- var DefaultTooltipContent = ({
2011
- data
2012
- }) => /* @__PURE__ */ _jsxs2(_Fragment, {
2013
- children: [data?.label, ": ", data?.valueDisplay || formatNumber4(data?.value)]
2014
- });
2015
- var BaseTooltip = ({
2016
- data,
2017
- top,
2018
- left,
2019
- component: Component2 = DefaultTooltipContent,
2020
- children,
2021
- className,
2022
- style,
2023
- renderContainer = true
2024
- }) => {
2025
- const content = children || data && /* @__PURE__ */ _jsx4(Component2, {
2026
- data,
2027
- className
2028
- });
2029
- if (!renderContainer) {
2030
- return content;
1964
+ // ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/useRenderElement.js
1965
+ import { createElement as _createElement } from "react";
1966
+ function useRenderElement(element, componentProps, params = {}) {
1967
+ const renderProp = componentProps.render;
1968
+ const outProps = useRenderElementProps(componentProps, params);
1969
+ if (params.enabled === false) {
1970
+ return null;
2031
1971
  }
2032
- return /* @__PURE__ */ _jsx4("div", {
2033
- className: base_tooltip_module_default.tooltip,
2034
- style: {
2035
- top,
2036
- left,
2037
- ...style
2038
- },
2039
- role: "tooltip",
2040
- children: content
2041
- });
2042
- };
2043
-
2044
- // src/components/tooltip/accessible-tooltip.tsx
2045
- import { Tooltip, TooltipContext } from "@visx/xychart";
2046
- import { useContext as useContext6, useEffect as useEffect5, useCallback as useCallback5, useMemo as useMemo11 } from "react";
2047
- import { jsx as _jsx5 } from "react/jsx-runtime";
2048
- var AccessibleTooltip = ({
2049
- renderTooltip,
2050
- selectedIndex,
2051
- tooltipRef,
2052
- keyboardFocusedClassName,
2053
- series = [],
2054
- mode = "group",
2055
- ...props
2056
- }) => {
2057
- const tooltipContext = useContext6(TooltipContext);
2058
- const tooltipData = useMemo11(() => {
2059
- if (mode !== "individual") return [];
2060
- if (series.length === 0) return [];
2061
- const maxDataPoints = Math.max(...series.map((s) => s.data.length));
2062
- const flattened = [];
2063
- for (let dataPointIndex = 0; dataPointIndex < maxDataPoints; dataPointIndex++) {
2064
- for (let seriesIndex = 0; seriesIndex < series.length; seriesIndex++) {
2065
- const seriesData = series[seriesIndex];
2066
- if (dataPointIndex < seriesData.data.length) {
2067
- flattened.push({
2068
- datum: seriesData.data[dataPointIndex],
2069
- seriesLabel: seriesData.label,
2070
- seriesIndex,
2071
- dataPointIndex
2072
- });
2073
- }
1972
+ const state = params.state ?? EMPTY_OBJECT;
1973
+ return evaluateRenderProp(element, renderProp, outProps, state);
1974
+ }
1975
+ function useRenderElementProps(componentProps, params = {}) {
1976
+ const {
1977
+ className: classNameProp,
1978
+ style: styleProp,
1979
+ render: renderProp
1980
+ } = componentProps;
1981
+ const {
1982
+ state = EMPTY_OBJECT,
1983
+ ref,
1984
+ props,
1985
+ stateAttributesMapping,
1986
+ enabled = true
1987
+ } = params;
1988
+ const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1989
+ const style = enabled ? resolveStyle(styleProp, state) : void 0;
1990
+ const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping) : EMPTY_OBJECT;
1991
+ const outProps = enabled ? mergeObjects(stateProps, Array.isArray(props) ? mergePropsN(props) : props) ?? EMPTY_OBJECT : EMPTY_OBJECT;
1992
+ if (typeof document !== "undefined") {
1993
+ if (!enabled) {
1994
+ useMergedRefs(null, null);
1995
+ } else if (Array.isArray(ref)) {
1996
+ outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
1997
+ } else {
1998
+ outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1999
+ }
2000
+ }
2001
+ if (!enabled) {
2002
+ return EMPTY_OBJECT;
2003
+ }
2004
+ if (className !== void 0) {
2005
+ outProps.className = mergeClassNames(outProps.className, className);
2006
+ }
2007
+ if (style !== void 0) {
2008
+ outProps.style = mergeObjects(outProps.style, style);
2009
+ }
2010
+ return outProps;
2011
+ }
2012
+ var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
2013
+ function evaluateRenderProp(element, render, props, state) {
2014
+ if (render) {
2015
+ if (typeof render === "function") {
2016
+ if (process.env.NODE_ENV !== "production") {
2017
+ warnIfRenderPropLooksLikeComponent(render);
2074
2018
  }
2019
+ return render(props, state);
2075
2020
  }
2076
- return flattened;
2077
- }, [series, mode]);
2078
- useEffect5(() => {
2079
- if (selectedIndex === void 0) {
2080
- tooltipContext?.hideTooltip();
2081
- return;
2021
+ const mergedProps = mergeProps(props, render.props);
2022
+ mergedProps.ref = props.ref;
2023
+ let newElement = render;
2024
+ if (newElement?.$$typeof === REACT_LAZY_TYPE) {
2025
+ const children = React4.Children.toArray(render);
2026
+ newElement = children[0];
2082
2027
  }
2083
- if (mode === "group") {
2084
- series.forEach((s, index) => {
2085
- if (selectedIndex < s.data.length) {
2086
- const datum = s.data[selectedIndex];
2087
- tooltipContext?.showTooltip({
2088
- datum,
2089
- key: s.label,
2090
- index
2091
- });
2092
- }
2093
- });
2094
- } else if (mode === "individual") {
2095
- if (selectedIndex < tooltipData.length) {
2096
- const tooltipItem = tooltipData[selectedIndex];
2097
- tooltipContext?.showTooltip({
2098
- datum: tooltipItem.datum,
2099
- key: tooltipItem.seriesLabel,
2100
- index: tooltipItem.seriesIndex
2101
- });
2028
+ if (process.env.NODE_ENV !== "production") {
2029
+ if (!/* @__PURE__ */ React4.isValidElement(newElement)) {
2030
+ throw new Error(["Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.", "A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.", "https://base-ui.com/r/invalid-render-prop"].join("\n"));
2102
2031
  }
2103
2032
  }
2104
- }, [selectedIndex, tooltipData, series]);
2105
- const focusableRenderTooltip = useMemo11(() => {
2106
- if (!renderTooltip) return void 0;
2107
- return (params) => {
2108
- const tooltipContent = renderTooltip(params);
2109
- if (selectedIndex !== void 0) {
2110
- return /* @__PURE__ */ _jsx5("div", {
2111
- ref: tooltipRef,
2112
- tabIndex: -1,
2113
- role: "tooltip",
2114
- "aria-atomic": "true",
2115
- className: keyboardFocusedClassName,
2116
- children: tooltipContent
2117
- }, `chart-tooltip-${selectedIndex}`);
2118
- }
2119
- return /* @__PURE__ */ _jsx5("div", {
2120
- role: "tooltip",
2121
- "aria-live": "polite",
2122
- children: tooltipContent
2123
- });
2124
- };
2125
- }, [renderTooltip, selectedIndex, tooltipRef, keyboardFocusedClassName]);
2126
- return /* @__PURE__ */ _jsx5(Tooltip, {
2127
- ...props,
2128
- renderTooltip: focusableRenderTooltip
2129
- });
2130
- };
2131
- var useKeyboardNavigation = ({
2132
- selectedIndex,
2133
- setSelectedIndex,
2134
- isNavigating,
2135
- setIsNavigating,
2136
- chartRef,
2137
- totalPoints
2138
- }) => {
2139
- const tooltipRef = useCallback5((element) => {
2140
- if (element && selectedIndex !== void 0) {
2141
- element.focus();
2142
- }
2143
- }, [selectedIndex]);
2144
- const onChartFocus = useCallback5(() => {
2145
- if (!isNavigating && selectedIndex !== void 0) {
2146
- setSelectedIndex(0);
2147
- }
2148
- }, [isNavigating, selectedIndex, setSelectedIndex]);
2149
- const onChartBlur = useCallback5(() => {
2150
- setIsNavigating(false);
2151
- }, [setIsNavigating]);
2152
- const onChartKeyDown = useCallback5((event) => {
2153
- if (totalPoints === 0) return;
2154
- if (event.key === "Tab") {
2155
- chartRef.current?.focus();
2156
- setSelectedIndex(void 0);
2157
- setIsNavigating(false);
2158
- return;
2159
- }
2160
- const currentSelectedIndex = selectedIndex === void 0 ? -1 : selectedIndex;
2161
- if (currentSelectedIndex + 1 >= totalPoints && ["ArrowRight"].includes(event.key)) {
2162
- chartRef.current?.focus();
2163
- setSelectedIndex(void 0);
2164
- setIsNavigating(false);
2165
- return;
2166
- }
2167
- event.preventDefault();
2168
- if (["ArrowRight"].includes(event.key)) {
2169
- setIsNavigating(true);
2170
- setSelectedIndex((currentSelectedIndex + 1) % totalPoints);
2171
- } else if (["ArrowLeft"].includes(event.key)) {
2172
- setIsNavigating(true);
2173
- setSelectedIndex((currentSelectedIndex - 1 + totalPoints) % totalPoints);
2174
- } else if (event.key === "Escape") {
2175
- setSelectedIndex(void 0);
2176
- setIsNavigating(false);
2177
- chartRef.current?.focus();
2033
+ return /* @__PURE__ */ React4.cloneElement(newElement, mergedProps);
2034
+ }
2035
+ if (element) {
2036
+ if (typeof element === "string") {
2037
+ return renderTag(element, props);
2178
2038
  }
2179
- }, [totalPoints, selectedIndex, setSelectedIndex, setIsNavigating, chartRef]);
2180
- return {
2181
- tooltipRef,
2182
- onChartFocus,
2183
- onChartBlur,
2184
- onChartKeyDown
2185
- };
2186
- };
2187
-
2188
- // src/charts/private/chart-composition/chart-svg.tsx
2189
- import { Fragment as _Fragment2, jsx as _jsx6 } from "react/jsx-runtime";
2190
- var ChartSVG = ({
2191
- children
2192
- }) => {
2193
- return /* @__PURE__ */ _jsx6(_Fragment2, {
2194
- children
2195
- });
2196
- };
2197
- ChartSVG.displayName = "Chart.SVG";
2198
-
2199
- // src/charts/private/chart-composition/chart-html.tsx
2200
- import { Fragment as _Fragment3, jsx as _jsx7 } from "react/jsx-runtime";
2201
- var ChartHTML = ({
2202
- children
2203
- }) => {
2204
- return /* @__PURE__ */ _jsx7(_Fragment3, {
2205
- children
2206
- });
2207
- };
2208
- ChartHTML.displayName = "Chart.HTML";
2209
-
2210
- // src/charts/private/chart-composition/render-legend-slot.ts
2211
- import { createElement, Fragment } from "react";
2212
- function renderLegendSlot(legendChildren, position2) {
2213
- return legendChildren.filter((l) => l.position === position2).map(
2214
- (l, i) => createElement(Fragment, { key: `legend-${position2}-${i}` }, l.element)
2215
- );
2039
+ }
2040
+ throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
2216
2041
  }
2217
-
2218
- // src/charts/private/chart-composition/use-chart-children.ts
2219
- import { Group as Group2 } from "@visx/group";
2220
- import { useMemo as useMemo12, Children, isValidElement } from "react";
2221
- function useChartChildren(children, chartType) {
2222
- return useMemo12(() => {
2223
- const svg = [];
2224
- const html = [];
2225
- const legend = [];
2226
- const other = [];
2227
- const nonLegend = [];
2228
- Children.forEach(children, (child) => {
2229
- if (isValidElement(child)) {
2230
- if (child.type === Legend) {
2231
- const rawPosition = child.props?.position;
2232
- const position2 = rawPosition === "top" || rawPosition === "bottom" ? rawPosition : "bottom";
2233
- legend.push({ element: child, position: position2 });
2234
- return;
2235
- }
2236
- const childType = child.type;
2237
- const displayName = childType?.displayName;
2238
- if (displayName === `${chartType}.SVG` || displayName === "Chart.SVG") {
2239
- if (child.props?.children) {
2240
- Children.forEach(child.props.children, (svgChild) => {
2241
- svg.push(svgChild);
2242
- });
2243
- }
2244
- } else if (displayName === `${chartType}.HTML` || displayName === "Chart.HTML") {
2245
- if (child.props?.children) {
2246
- Children.forEach(child.props.children, (htmlChild) => {
2247
- html.push(htmlChild);
2248
- });
2249
- }
2250
- } else if (child.type === Group2) {
2251
- svg.push(child);
2252
- } else {
2253
- other.push(child);
2254
- }
2255
- }
2256
- nonLegend.push(child);
2042
+ function warnIfRenderPropLooksLikeComponent(renderFn) {
2043
+ const functionName = renderFn.name;
2044
+ if (functionName.length === 0) {
2045
+ return;
2046
+ }
2047
+ const firstCharacterCode = functionName.charCodeAt(0);
2048
+ if (firstCharacterCode < 65 || firstCharacterCode > 90) {
2049
+ return;
2050
+ }
2051
+ warn(`The \`render\` prop received a function named \`${functionName}\` that starts with an uppercase letter.`, "This usually means a React component was passed directly as `render={Component}`.", "Base UI calls `render` as a plain function, which can break the Rules of Hooks during reconciliation.", "If this is an intentional render callback, rename it to start with a lowercase letter.", "Use `render={<Component />}` or `render={(props) => <Component {...props} />}` instead.", "https://base-ui.com/r/invalid-render-prop");
2052
+ }
2053
+ function renderTag(Tag, props) {
2054
+ if (Tag === "button") {
2055
+ return /* @__PURE__ */ _createElement("button", {
2056
+ type: "button",
2057
+ ...props,
2058
+ key: props.key
2257
2059
  });
2258
- return {
2259
- svgChildren: svg,
2260
- htmlChildren: html,
2261
- legendChildren: legend,
2262
- otherChildren: other,
2263
- nonLegendChildren: nonLegend
2264
- };
2265
- }, [children, chartType]);
2060
+ }
2061
+ if (Tag === "img") {
2062
+ return /* @__PURE__ */ _createElement("img", {
2063
+ alt: "",
2064
+ ...props,
2065
+ key: props.key
2066
+ });
2067
+ }
2068
+ return /* @__PURE__ */ React4.createElement(Tag, props);
2266
2069
  }
2267
2070
 
2268
- // ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/useRefWithInit.js
2269
- import * as React from "react";
2270
- var UNINITIALIZED = {};
2271
- function useRefWithInit(init, initArg) {
2272
- const ref = React.useRef(UNINITIALIZED);
2273
- if (ref.current === UNINITIALIZED) {
2274
- ref.current = init(initArg);
2275
- }
2276
- return ref;
2071
+ // ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/use-render/useRender.js
2072
+ function useRender(params) {
2073
+ return useRenderElement(params.defaultTagName ?? "div", params, params);
2277
2074
  }
2278
2075
 
2279
- // ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/warn.js
2280
- var set;
2281
- if (process.env.NODE_ENV !== "production") {
2282
- set = /* @__PURE__ */ new Set();
2076
+ // ../../../node_modules/.pnpm/@wordpress+element@6.43.0/node_modules/@wordpress/element/build-module/react.mjs
2077
+ import {
2078
+ Children as Children2,
2079
+ cloneElement as cloneElement2,
2080
+ Component,
2081
+ createContext as createContext3,
2082
+ createElement as createElement2,
2083
+ createRef,
2084
+ forwardRef,
2085
+ Fragment,
2086
+ isValidElement as isValidElement3,
2087
+ memo,
2088
+ PureComponent,
2089
+ StrictMode,
2090
+ useCallback as useCallback4,
2091
+ useContext as useContext4,
2092
+ useDebugValue,
2093
+ useDeferredValue,
2094
+ useEffect as useEffect5,
2095
+ useId as useId2,
2096
+ useMemo as useMemo9,
2097
+ useImperativeHandle,
2098
+ useInsertionEffect,
2099
+ useLayoutEffect as useLayoutEffect2,
2100
+ useReducer,
2101
+ useRef as useRef6,
2102
+ useState as useState5,
2103
+ useSyncExternalStore,
2104
+ useTransition,
2105
+ startTransition,
2106
+ lazy,
2107
+ Suspense
2108
+ } from "react";
2109
+
2110
+ // ../../../node_modules/.pnpm/is-plain-object@5.0.0/node_modules/is-plain-object/dist/is-plain-object.mjs
2111
+ function isObject(o) {
2112
+ return Object.prototype.toString.call(o) === "[object Object]";
2283
2113
  }
2284
- function warn(...messages) {
2285
- if (process.env.NODE_ENV !== "production") {
2286
- const messageKey = messages.join(" ");
2287
- if (!set.has(messageKey)) {
2288
- set.add(messageKey);
2289
- console.warn(`Base UI: ${messageKey}`);
2290
- }
2114
+ function isPlainObject(o) {
2115
+ var ctor, prot;
2116
+ if (isObject(o) === false) return false;
2117
+ ctor = o.constructor;
2118
+ if (ctor === void 0) return true;
2119
+ prot = ctor.prototype;
2120
+ if (isObject(prot) === false) return false;
2121
+ if (prot.hasOwnProperty("isPrototypeOf") === false) {
2122
+ return false;
2291
2123
  }
2124
+ return true;
2292
2125
  }
2293
2126
 
2294
- // ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/formatErrorMessage.js
2295
- function createFormatErrorMessage(baseUrl, prefix2) {
2296
- return function formatErrorMessage2(code, ...args) {
2297
- const url = new URL(baseUrl);
2298
- url.searchParams.set("code", code.toString());
2299
- args.forEach((arg) => url.searchParams.append("args[]", arg));
2300
- return `${prefix2} error #${code}; visit ${url} for the full message.`;
2301
- };
2127
+ // ../../../node_modules/.pnpm/lower-case@2.0.2/node_modules/lower-case/dist.es2015/index.js
2128
+ function lowerCase(str) {
2129
+ return str.toLowerCase();
2302
2130
  }
2303
- var formatErrorMessage = createFormatErrorMessage("https://base-ui.com/production-error", "Base UI");
2304
- var formatErrorMessage_default = formatErrorMessage;
2305
-
2306
- // ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/useRenderElement.js
2307
- import * as React4 from "react";
2308
2131
 
2309
- // ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/useMergedRefs.js
2310
- function useMergedRefs(a, b, c, d) {
2311
- const forkRef = useRefWithInit(createForkRef).current;
2312
- if (didChange(forkRef, a, b, c, d)) {
2313
- update(forkRef, [a, b, c, d]);
2314
- }
2315
- return forkRef.callback;
2132
+ // ../../../node_modules/.pnpm/no-case@3.0.4/node_modules/no-case/dist.es2015/index.js
2133
+ var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
2134
+ var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
2135
+ function noCase(input, options) {
2136
+ if (options === void 0) {
2137
+ options = {};
2138
+ }
2139
+ var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter2 = _d === void 0 ? " " : _d;
2140
+ var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
2141
+ var start = 0;
2142
+ var end = result.length;
2143
+ while (result.charAt(start) === "\0")
2144
+ start++;
2145
+ while (result.charAt(end - 1) === "\0")
2146
+ end--;
2147
+ return result.slice(start, end).split("\0").map(transform).join(delimiter2);
2316
2148
  }
2317
- function useMergedRefsN(refs) {
2318
- const forkRef = useRefWithInit(createForkRef).current;
2319
- if (didChangeN(forkRef, refs)) {
2320
- update(forkRef, refs);
2149
+ function replace(input, re, value) {
2150
+ if (re instanceof RegExp)
2151
+ return input.replace(re, value);
2152
+ return re.reduce(function(input2, re2) {
2153
+ return input2.replace(re2, value);
2154
+ }, input);
2155
+ }
2156
+
2157
+ // ../../../node_modules/.pnpm/dot-case@3.0.4/node_modules/dot-case/dist.es2015/index.js
2158
+ import { __assign } from "tslib";
2159
+ function dotCase(input, options) {
2160
+ if (options === void 0) {
2161
+ options = {};
2321
2162
  }
2322
- return forkRef.callback;
2163
+ return noCase(input, __assign({ delimiter: "." }, options));
2323
2164
  }
2324
- function createForkRef() {
2325
- return {
2326
- callback: null,
2327
- cleanup: null,
2328
- refs: []
2329
- };
2165
+
2166
+ // ../../../node_modules/.pnpm/param-case@3.0.4/node_modules/param-case/dist.es2015/index.js
2167
+ import { __assign as __assign2 } from "tslib";
2168
+ function paramCase(input, options) {
2169
+ if (options === void 0) {
2170
+ options = {};
2171
+ }
2172
+ return dotCase(input, __assign2({ delimiter: "-" }, options));
2330
2173
  }
2331
- function didChange(forkRef, a, b, c, d) {
2332
- return forkRef.refs[0] !== a || forkRef.refs[1] !== b || forkRef.refs[2] !== c || forkRef.refs[3] !== d;
2174
+
2175
+ // ../../../node_modules/.pnpm/@wordpress+ui@0.10.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1_stylelint@17.7.0/node_modules/@wordpress/ui/build-module/text/text.mjs
2176
+ import clsx from "clsx";
2177
+ if (typeof document !== "undefined" && process.env.NODE_ENV !== "test" && !document.head.querySelector("style[data-wp-hash='8bc43893d6']")) {
2178
+ const style = document.createElement("style");
2179
+ style.setAttribute("data-wp-hash", "8bc43893d6");
2180
+ style.appendChild(document.createTextNode('@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._14437cfb77831647__heading-2xl{font-size:var(--wpds-font-size-2xl,32px);line-height:var(--wpds-font-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-font-weight-medium,499)}._3c78b7fa9b4072dd__heading-xl{font-size:var(--wpds-font-size-xl,20px);line-height:var(--wpds-font-line-height-md,24px)}.aa58f227716bcde2__heading-lg{font-size:var(--wpds-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-font-weight-medium,499);line-height:var(--wpds-font-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{font-size:var(--wpds-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{font-family:var(--wpds-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-font-size-xs,11px);font-weight:var(--wpds-font-weight-medium,499);line-height:var(--wpds-font-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{font-size:var(--wpds-font-size-xl,20px);line-height:var(--wpds-font-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-font-weight-regular,400)}.ca1aa3fc2029e958__body-lg{font-size:var(--wpds-font-size-lg,15px);line-height:var(--wpds-font-line-height-md,24px)}._131101940be12424__body-md{font-size:var(--wpds-font-size-md,13px);line-height:var(--wpds-font-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-font-weight-regular,400)}._0e8d87a42c1f75fa__body-sm{font-size:var(--wpds-font-size-sm,12px);line-height:var(--wpds-font-line-height-xs,16px)}}'));
2181
+ document.head.appendChild(style);
2333
2182
  }
2334
- function didChangeN(forkRef, newRefs) {
2335
- return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index) => ref !== newRefs[index]);
2183
+ var style_default = { "heading-2xl": "_14437cfb77831647__heading-2xl", "heading-xl": "_3c78b7fa9b4072dd__heading-xl", "heading-lg": "aa58f227716bcde2__heading-lg", "heading-md": "fc4da56d8dfe52c4__heading-md", "heading-sm": "a9b78c7c82e8dff7__heading-sm", "body-xl": "_305ff559e52180d5__body-xl", "body-lg": "ca1aa3fc2029e958__body-lg", "body-md": "_131101940be12424__body-md", "body-sm": "_0e8d87a42c1f75fa__body-sm" };
2184
+ var Text = forwardRef(function Text2({ variant = "body-md", render, className, ...props }, ref) {
2185
+ const element = useRender({
2186
+ render,
2187
+ defaultTagName: "span",
2188
+ ref,
2189
+ props: mergeProps(props, {
2190
+ className: clsx(style_default[variant], className)
2191
+ })
2192
+ });
2193
+ return element;
2194
+ });
2195
+
2196
+ // ../../../node_modules/.pnpm/@wordpress+ui@0.10.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1_stylelint@17.7.0/node_modules/@wordpress/ui/build-module/stack/stack.mjs
2197
+ if (typeof document !== "undefined" && process.env.NODE_ENV !== "test" && !document.head.querySelector("style[data-wp-hash='b51ff41489']")) {
2198
+ const style = document.createElement("style");
2199
+ style.setAttribute("data-wp-hash", "b51ff41489");
2200
+ style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._19ce0419607e1896__stack{display:flex}}"));
2201
+ document.head.appendChild(style);
2336
2202
  }
2337
- function update(forkRef, refs) {
2338
- forkRef.refs = refs;
2339
- if (refs.every((ref) => ref == null)) {
2340
- forkRef.callback = null;
2341
- return;
2342
- }
2343
- forkRef.callback = (instance) => {
2344
- if (forkRef.cleanup) {
2345
- forkRef.cleanup();
2346
- forkRef.cleanup = null;
2347
- }
2348
- if (instance != null) {
2349
- const cleanupCallbacks = Array(refs.length).fill(null);
2350
- for (let i = 0; i < refs.length; i += 1) {
2351
- const ref = refs[i];
2352
- if (ref == null) {
2353
- continue;
2354
- }
2355
- switch (typeof ref) {
2356
- case "function": {
2357
- const refCleanup = ref(instance);
2358
- if (typeof refCleanup === "function") {
2359
- cleanupCallbacks[i] = refCleanup;
2360
- }
2361
- break;
2362
- }
2363
- case "object": {
2364
- ref.current = instance;
2365
- break;
2366
- }
2367
- default:
2368
- }
2369
- }
2370
- forkRef.cleanup = () => {
2371
- for (let i = 0; i < refs.length; i += 1) {
2372
- const ref = refs[i];
2373
- if (ref == null) {
2374
- continue;
2375
- }
2376
- switch (typeof ref) {
2377
- case "function": {
2378
- const cleanupCallback = cleanupCallbacks[i];
2379
- if (typeof cleanupCallback === "function") {
2380
- cleanupCallback();
2381
- } else {
2382
- ref(null);
2383
- }
2384
- break;
2385
- }
2386
- case "object": {
2387
- ref.current = null;
2388
- break;
2389
- }
2390
- default:
2391
- }
2392
- }
2393
- };
2394
- }
2203
+ var style_default2 = { "stack": "_19ce0419607e1896__stack" };
2204
+ var gapTokens = {
2205
+ xs: "var(--wpds-dimension-gap-xs, 4px)",
2206
+ sm: "var(--wpds-dimension-gap-sm, 8px)",
2207
+ md: "var(--wpds-dimension-gap-md, 12px)",
2208
+ lg: "var(--wpds-dimension-gap-lg, 16px)",
2209
+ xl: "var(--wpds-dimension-gap-xl, 24px)",
2210
+ "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
2211
+ "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
2212
+ };
2213
+ var Stack = forwardRef(function Stack2({ direction, gap, align, justify, wrap, render, ...props }, ref) {
2214
+ const style = {
2215
+ gap: gap && gapTokens[gap],
2216
+ alignItems: align,
2217
+ justifyContent: justify,
2218
+ flexDirection: direction,
2219
+ flexWrap: wrap
2395
2220
  };
2396
- }
2221
+ const element = useRender({
2222
+ render,
2223
+ ref,
2224
+ props: mergeProps(props, { style, className: style_default2.stack })
2225
+ });
2226
+ return element;
2227
+ });
2397
2228
 
2398
- // ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/getReactElementRef.js
2399
- import * as React3 from "react";
2229
+ // src/components/legend/private/base-legend.tsx
2230
+ import clsx2 from "clsx";
2231
+ import { forwardRef as forwardRef2, useCallback as useCallback5, useContext as useContext5 } from "react";
2400
2232
 
2401
- // ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/reactVersion.js
2402
- import * as React2 from "react";
2403
- var majorVersion = parseInt(React2.version, 10);
2404
- function isReactVersionAtLeast(reactVersionToCheck) {
2405
- return majorVersion >= reactVersionToCheck;
2233
+ // src/components/legend/utils/value-or-identity.ts
2234
+ function valueOrIdentity(_) {
2235
+ if (_ && typeof _ === "object" && "value" in _ && typeof _.value !== "undefined")
2236
+ return _.value;
2237
+ return _;
2238
+ }
2239
+ function valueOrIdentityString(_) {
2240
+ return String(valueOrIdentity(_));
2406
2241
  }
2407
2242
 
2408
- // ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/getReactElementRef.js
2409
- function getReactElementRef(element) {
2410
- if (!/* @__PURE__ */ React3.isValidElement(element)) {
2243
+ // src/components/legend/utils/label-transform-factory.ts
2244
+ function labelTransformFactory({
2245
+ scale,
2246
+ labelFormat
2247
+ }) {
2248
+ return (d, i) => ({
2249
+ datum: d,
2250
+ index: i,
2251
+ text: `${labelFormat(d, i)}`,
2252
+ value: scale(d)
2253
+ });
2254
+ }
2255
+
2256
+ // src/components/legend/private/base-legend.module.scss
2257
+ var base_legend_module_default = {
2258
+ "legend": "a8ccharts-89ApsU",
2259
+ "legend-item": "a8ccharts-Vflwq8",
2260
+ "legend-item--interactive": "a8ccharts-qGsavM",
2261
+ "legend-item--inactive": "a8ccharts-ZtDY-Q",
2262
+ "legend-item-label": "a8ccharts-2H65Kr",
2263
+ "legend-item-text--wrap": "a8ccharts-faSDBI",
2264
+ "legend-item-text--ellipsis": "a8ccharts-FISUIO",
2265
+ "legend-item-value": "a8ccharts-DTZlT-"
2266
+ };
2267
+
2268
+ // src/components/legend/private/base-legend.tsx
2269
+ import { jsx as _jsx2, jsxs as _jsxs } from "react/jsx-runtime";
2270
+ var ALIGNMENT_TO_FLEX = {
2271
+ start: "flex-start",
2272
+ center: "center",
2273
+ end: "flex-end"
2274
+ };
2275
+ var LegendText = ({
2276
+ text,
2277
+ textOverflow,
2278
+ maxWidth
2279
+ }) => {
2280
+ const isEllipsis = maxWidth != null && textOverflow === "ellipsis";
2281
+ const [textRef, isTruncated] = useTextTruncation(Boolean(isEllipsis));
2282
+ return /* @__PURE__ */ _jsx2("span", {
2283
+ ref: textRef,
2284
+ className: clsx2(base_legend_module_default["legend-item-text"], maxWidth != null && base_legend_module_default[`legend-item-text--${textOverflow}`]),
2285
+ style: {
2286
+ ...maxWidth != null && {
2287
+ maxWidth,
2288
+ minWidth: 0
2289
+ }
2290
+ },
2291
+ title: isEllipsis && isTruncated ? text : void 0,
2292
+ children: text
2293
+ });
2294
+ };
2295
+ var BaseLegend = /* @__PURE__ */ forwardRef2(({
2296
+ items,
2297
+ className,
2298
+ orientation = "horizontal",
2299
+ alignment = "center",
2300
+ shape = "rect",
2301
+ fill = valueOrIdentityString,
2302
+ size = valueOrIdentityString,
2303
+ labelFormat = valueOrIdentity,
2304
+ labelTransform = labelTransformFactory,
2305
+ itemStyles,
2306
+ itemClassName,
2307
+ labelStyles,
2308
+ labelClassName,
2309
+ shapeStyles,
2310
+ render,
2311
+ interactive = false,
2312
+ chartId
2313
+ }, ref) => {
2314
+ const {
2315
+ margin: itemMargin = "0",
2316
+ flexDirection: itemDirection = "row"
2317
+ } = itemStyles ?? {};
2318
+ const {
2319
+ justifyContent: labelJustifyContent = "flex-start",
2320
+ flex: labelFlex = "0 0 auto",
2321
+ margin: labelMargin = "0 4px",
2322
+ maxWidth,
2323
+ textOverflow = "wrap"
2324
+ } = labelStyles ?? {};
2325
+ const {
2326
+ width: shapeWidth = 16,
2327
+ height: shapeHeight = 16,
2328
+ margin: shapeMargin = "2px 4px 2px 0"
2329
+ } = shapeStyles ?? {};
2330
+ const theme = useGlobalChartsTheme();
2331
+ const context = useContext5(GlobalChartsContext);
2332
+ const legendScale = scaleOrdinal({
2333
+ domain: items.map((item) => item.label),
2334
+ range: items.map((item) => item.color)
2335
+ });
2336
+ const domain = legendScale.domain();
2337
+ const getShapeStyle = useCallback5(({
2338
+ index
2339
+ }) => items[index]?.shapeStyle, [items]);
2340
+ const handleLegendClick = useCallback5((seriesLabel) => {
2341
+ if (interactive && chartId && context) {
2342
+ context.toggleSeriesVisibility(chartId, seriesLabel);
2343
+ }
2344
+ }, [interactive, chartId, context]);
2345
+ const isSeriesVisible = useCallback5((seriesLabel) => {
2346
+ if (!interactive || !chartId || !context) {
2347
+ return true;
2348
+ }
2349
+ return context.isSeriesVisible(chartId, seriesLabel);
2350
+ }, [interactive, chartId, context]);
2351
+ const createClickHandler = useCallback5((labelText) => {
2352
+ if (!interactive) {
2353
+ return void 0;
2354
+ }
2355
+ return () => handleLegendClick(labelText);
2356
+ }, [interactive, handleLegendClick]);
2357
+ const createKeyDownHandler = useCallback5((labelText) => {
2358
+ if (!interactive) {
2359
+ return void 0;
2360
+ }
2361
+ return (event) => {
2362
+ if (event.key === "Enter" || event.key === " ") {
2363
+ event.preventDefault();
2364
+ handleLegendClick(labelText);
2365
+ }
2366
+ };
2367
+ }, [interactive, handleLegendClick]);
2368
+ const flexAlignment = ALIGNMENT_TO_FLEX[alignment] ?? "center";
2369
+ return render ? render(items) : /* @__PURE__ */ _jsx2(LegendOrdinal, {
2370
+ scale: legendScale,
2371
+ labelFormat,
2372
+ labelTransform,
2373
+ children: (labels) => /* @__PURE__ */ _jsx2(Stack, {
2374
+ ref,
2375
+ direction: orientation === "vertical" ? "column" : "row",
2376
+ gap: orientation === "vertical" ? "sm" : "lg",
2377
+ align: orientation === "vertical" ? flexAlignment : void 0,
2378
+ justify: orientation === "horizontal" ? flexAlignment : void 0,
2379
+ wrap: orientation === "horizontal" ? "wrap" : void 0,
2380
+ role: "list",
2381
+ className: clsx2(base_legend_module_default.legend, className),
2382
+ style: theme.legend?.containerStyles,
2383
+ children: labels.map((label, i) => {
2384
+ const visible = isSeriesVisible(label.text);
2385
+ const handleClick = createClickHandler(label.text);
2386
+ const handleKeyDown = createKeyDownHandler(label.text);
2387
+ const matchedItem = items[i];
2388
+ return /* @__PURE__ */ _jsxs(LegendItem, {
2389
+ className: clsx2("visx-legend-item", base_legend_module_default["legend-item"], interactive && base_legend_module_default["legend-item--interactive"], !visible && base_legend_module_default["legend-item--inactive"], itemClassName),
2390
+ margin: itemMargin,
2391
+ flexDirection: orientation === "vertical" && alignment === "end" ? "row-reverse" : itemDirection,
2392
+ onClick: handleClick,
2393
+ onKeyDown: handleKeyDown,
2394
+ role: interactive ? "button" : void 0,
2395
+ tabIndex: interactive ? 0 : void 0,
2396
+ "aria-pressed": interactive ? visible : void 0,
2397
+ "aria-label": interactive ? `${label.text}: ${visible ? "visible" : "hidden"}. Toggle visibility.` : void 0,
2398
+ children: [items[i]?.renderGlyph ? /* @__PURE__ */ _jsx2("svg", {
2399
+ width: items[i]?.glyphSize * 2,
2400
+ height: items[i]?.glyphSize * 2,
2401
+ children: /* @__PURE__ */ _jsx2(Group, {
2402
+ children: items[i]?.renderGlyph({
2403
+ key: `legend-glyph-${label.text}`,
2404
+ datum: {},
2405
+ index: i,
2406
+ color: fill(label),
2407
+ size: items[i]?.glyphSize,
2408
+ x: items[i]?.glyphSize,
2409
+ y: items[i]?.glyphSize
2410
+ })
2411
+ })
2412
+ }) : /* @__PURE__ */ _jsx2(LegendShape, {
2413
+ shape,
2414
+ height: shapeHeight,
2415
+ width: shapeWidth,
2416
+ margin: shapeMargin,
2417
+ item: domain[i],
2418
+ itemIndex: i,
2419
+ label,
2420
+ fill,
2421
+ size,
2422
+ shapeStyle: getShapeStyle
2423
+ }), /* @__PURE__ */ _jsx2(LegendLabel, {
2424
+ className: clsx2("visx-legend-label", base_legend_module_default["legend-item-label"], labelClassName),
2425
+ style: {
2426
+ flex: labelFlex,
2427
+ margin: labelMargin,
2428
+ ...theme.legend?.labelStyles
2429
+ },
2430
+ children: /* @__PURE__ */ _jsxs(Stack, {
2431
+ align: "center",
2432
+ gap: "sm",
2433
+ justify: labelJustifyContent,
2434
+ children: [/* @__PURE__ */ _jsx2(LegendText, {
2435
+ text: label.text,
2436
+ textOverflow,
2437
+ maxWidth
2438
+ }), matchedItem?.value != null && matchedItem.value !== "" && /* @__PURE__ */ _jsxs("span", {
2439
+ className: base_legend_module_default["legend-item-value"],
2440
+ children: ["\xA0", matchedItem.value]
2441
+ })]
2442
+ })
2443
+ })]
2444
+ }, `legend-${label.text}-${i}`);
2445
+ })
2446
+ })
2447
+ });
2448
+ });
2449
+
2450
+ // src/components/legend/legend.tsx
2451
+ import { jsx as _jsx3 } from "react/jsx-runtime";
2452
+ var defaultShapeByChartType = {
2453
+ line: "line",
2454
+ bar: "rect",
2455
+ pie: "circle",
2456
+ "pie-semi-circle": "circle",
2457
+ leaderboard: "circle"
2458
+ };
2459
+ var Legend = /* @__PURE__ */ forwardRef3(({
2460
+ chartId,
2461
+ items,
2462
+ shape,
2463
+ ...props
2464
+ }, ref) => {
2465
+ const context = useContext6(GlobalChartsContext);
2466
+ const singleChartContext = useContext6(SingleChartContext);
2467
+ const contextChartId = chartId ?? singleChartContext?.chartId;
2468
+ const chartData = useMemo10(() => contextChartId && context ? context.getChartData(contextChartId) : void 0, [contextChartId, context]);
2469
+ const contextItems = chartData?.legendItems;
2470
+ const resolvedShape = shape ?? (chartData?.chartType ? defaultShapeByChartType[chartData.chartType] : void 0);
2471
+ const legendItems = items || contextItems;
2472
+ if (!legendItems) {
2411
2473
  return null;
2412
2474
  }
2413
- const reactElement = element;
2414
- const propsWithRef = reactElement.props;
2415
- return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
2416
- }
2475
+ return /* @__PURE__ */ _jsx3(BaseLegend, {
2476
+ ref,
2477
+ items: legendItems,
2478
+ shape: resolvedShape,
2479
+ ...props,
2480
+ chartId: contextChartId
2481
+ });
2482
+ });
2417
2483
 
2418
- // ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/mergeObjects.js
2419
- function mergeObjects(a, b) {
2420
- if (a && !b) {
2421
- return a;
2422
- }
2423
- if (!a && b) {
2424
- return b;
2425
- }
2426
- if (a || b) {
2427
- return {
2428
- ...a,
2429
- ...b
2430
- };
2484
+ // src/components/legend/hooks/use-chart-legend-items.ts
2485
+ import { formatNumber as formatNumber3 } from "@automattic/number-formatters";
2486
+ import { useMemo as useMemo11 } from "react";
2487
+ function formatPointValue(point, showValues, legendValueDisplay = "percentage") {
2488
+ if (!showValues || legendValueDisplay === "none") {
2489
+ return "";
2431
2490
  }
2432
- return void 0;
2433
- }
2434
-
2435
- // ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/getStateAttributesProps.js
2436
- function getStateAttributesProps(state, customMapping) {
2437
- const props = {};
2438
- for (const key in state) {
2439
- const value = state[key];
2440
- if (customMapping?.hasOwnProperty(key)) {
2441
- const customProps = customMapping[key](value);
2442
- if (customProps != null) {
2443
- Object.assign(props, customProps);
2444
- }
2445
- continue;
2446
- }
2447
- if (value === true) {
2448
- props[`data-${key.toLowerCase()}`] = "";
2449
- } else if (value) {
2450
- props[`data-${key.toLowerCase()}`] = value.toString();
2491
+ if ("percentage" in point) {
2492
+ switch (legendValueDisplay) {
2493
+ case "percentage":
2494
+ return formatPercentage(point.percentage);
2495
+ case "value":
2496
+ return formatNumber3(point.value);
2497
+ case "valueDisplay":
2498
+ return point.valueDisplay || formatNumber3(point.value);
2499
+ default:
2500
+ return "";
2451
2501
  }
2452
2502
  }
2453
- return props;
2454
- }
2455
-
2456
- // ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/resolveClassName.js
2457
- function resolveClassName(className, state) {
2458
- return typeof className === "function" ? className(state) : className;
2459
- }
2460
-
2461
- // ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/resolveStyle.js
2462
- function resolveStyle(style, state) {
2463
- return typeof style === "function" ? style(state) : style;
2464
- }
2465
-
2466
- // ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/merge-props/mergeProps.js
2467
- var EMPTY_PROPS = {};
2468
- function mergeProps(a, b, c, d, e) {
2469
- let merged = {
2470
- ...resolvePropsGetter(a, EMPTY_PROPS)
2471
- };
2472
- if (b) {
2473
- merged = mergeOne(merged, b);
2474
- }
2475
- if (c) {
2476
- merged = mergeOne(merged, c);
2477
- }
2478
- if (d) {
2479
- merged = mergeOne(merged, d);
2480
- }
2481
- if (e) {
2482
- merged = mergeOne(merged, e);
2483
- }
2484
- return merged;
2485
- }
2486
- function mergePropsN(props) {
2487
- if (props.length === 0) {
2488
- return EMPTY_PROPS;
2489
- }
2490
- if (props.length === 1) {
2491
- return resolvePropsGetter(props[0], EMPTY_PROPS);
2492
- }
2493
- let merged = {
2494
- ...resolvePropsGetter(props[0], EMPTY_PROPS)
2495
- };
2496
- for (let i = 1; i < props.length; i += 1) {
2497
- merged = mergeOne(merged, props[i]);
2498
- }
2499
- return merged;
2500
- }
2501
- function mergeOne(merged, inputProps) {
2502
- if (isPropsGetter(inputProps)) {
2503
- return inputProps(merged);
2503
+ if ("value" in point) {
2504
+ return point.value !== null ? formatNumber3(point.value) : "";
2504
2505
  }
2505
- return mutablyMergeInto(merged, inputProps);
2506
+ return "";
2506
2507
  }
2507
- function mutablyMergeInto(mergedProps, externalProps) {
2508
- if (!externalProps) {
2509
- return mergedProps;
2510
- }
2511
- for (const propName in externalProps) {
2512
- const externalPropValue = externalProps[propName];
2513
- switch (propName) {
2514
- case "style": {
2515
- mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
2516
- break;
2517
- }
2518
- case "className": {
2519
- mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
2520
- break;
2521
- }
2522
- default: {
2523
- if (isEventHandler(propName, externalPropValue)) {
2524
- mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
2525
- } else {
2526
- mergedProps[propName] = externalPropValue;
2527
- }
2528
- }
2508
+ function applyGlyphToLegendItem(baseItem, withGlyph, glyph, renderGlyph, glyphSize) {
2509
+ if (withGlyph) {
2510
+ const glyphToUse = glyph || renderGlyph;
2511
+ if (glyphToUse) {
2512
+ return {
2513
+ ...baseItem,
2514
+ glyphSize,
2515
+ renderGlyph: glyphToUse
2516
+ };
2529
2517
  }
2530
2518
  }
2531
- return mergedProps;
2532
- }
2533
- function isEventHandler(key, value) {
2534
- const code0 = key.charCodeAt(0);
2535
- const code1 = key.charCodeAt(1);
2536
- const code2 = key.charCodeAt(2);
2537
- return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
2538
- }
2539
- function isPropsGetter(inputProps) {
2540
- return typeof inputProps === "function";
2541
- }
2542
- function resolvePropsGetter(inputProps, previousProps) {
2543
- if (isPropsGetter(inputProps)) {
2544
- return inputProps(previousProps);
2545
- }
2546
- return inputProps ?? EMPTY_PROPS;
2519
+ return baseItem;
2547
2520
  }
2548
- function mergeEventHandlers(ourHandler, theirHandler) {
2549
- if (!theirHandler) {
2550
- return ourHandler;
2551
- }
2552
- if (!ourHandler) {
2553
- return theirHandler;
2554
- }
2555
- return (event) => {
2556
- if (isSyntheticEvent(event)) {
2557
- const baseUIEvent = event;
2558
- makeEventPreventable(baseUIEvent);
2559
- const result2 = theirHandler(baseUIEvent);
2560
- if (!baseUIEvent.baseUIHandlerPrevented) {
2561
- ourHandler?.(baseUIEvent);
2562
- }
2563
- return result2;
2564
- }
2565
- const result = theirHandler(event);
2566
- ourHandler?.(event);
2567
- return result;
2521
+ function processSeriesData(seriesData, getElementStyles, showValues, withGlyph, glyphSize, renderGlyph, legendShape) {
2522
+ const mapper = (series, index) => {
2523
+ const { color, glyph, shapeStyles } = getElementStyles({
2524
+ data: series,
2525
+ index,
2526
+ legendShape
2527
+ });
2528
+ const baseItem = {
2529
+ label: series.label,
2530
+ value: showValues ? series.data?.length?.toString() || "0" : "",
2531
+ color,
2532
+ shapeStyle: shapeStyles
2533
+ };
2534
+ return applyGlyphToLegendItem(baseItem, withGlyph, glyph, renderGlyph, glyphSize);
2568
2535
  };
2536
+ return seriesData.map(mapper);
2569
2537
  }
2570
- function makeEventPreventable(event) {
2571
- event.preventBaseUIHandler = () => {
2572
- event.baseUIHandlerPrevented = true;
2538
+ function processPointData(pointData, getElementStyles, showValues, legendValueDisplay, withGlyph, glyphSize, renderGlyph, legendShape) {
2539
+ const mapper = (point, index) => {
2540
+ const { color, glyph, shapeStyles } = getElementStyles({
2541
+ data: point,
2542
+ index,
2543
+ legendShape
2544
+ });
2545
+ const baseItem = {
2546
+ label: point.label,
2547
+ value: formatPointValue(point, showValues, legendValueDisplay),
2548
+ color,
2549
+ shapeStyle: shapeStyles
2550
+ };
2551
+ return applyGlyphToLegendItem(baseItem, withGlyph, glyph, renderGlyph, glyphSize);
2573
2552
  };
2574
- return event;
2553
+ return pointData.map(mapper);
2575
2554
  }
2576
- function mergeClassNames(ourClassName, theirClassName) {
2577
- if (theirClassName) {
2578
- if (ourClassName) {
2579
- return theirClassName + " " + ourClassName;
2555
+ function useChartLegendItems(data, options = {}, legendShape) {
2556
+ const {
2557
+ showValues = false,
2558
+ legendValueDisplay = "percentage",
2559
+ withGlyph = false,
2560
+ glyphSize = 8,
2561
+ renderGlyph
2562
+ } = options;
2563
+ const { getElementStyles } = useGlobalChartsContext();
2564
+ return useMemo11(() => {
2565
+ if (!data || !Array.isArray(data) || data.length === 0) {
2566
+ return [];
2567
+ }
2568
+ if ("data" in data[0]) {
2569
+ return processSeriesData(
2570
+ data,
2571
+ getElementStyles,
2572
+ showValues,
2573
+ withGlyph,
2574
+ glyphSize,
2575
+ renderGlyph,
2576
+ legendShape
2577
+ );
2580
2578
  }
2581
- return theirClassName;
2582
- }
2583
- return ourClassName;
2584
- }
2585
- function isSyntheticEvent(event) {
2586
- return event != null && typeof event === "object" && "nativeEvent" in event;
2579
+ return processPointData(
2580
+ data,
2581
+ getElementStyles,
2582
+ showValues,
2583
+ legendValueDisplay,
2584
+ withGlyph,
2585
+ glyphSize,
2586
+ renderGlyph,
2587
+ legendShape
2588
+ );
2589
+ }, [
2590
+ data,
2591
+ getElementStyles,
2592
+ showValues,
2593
+ legendValueDisplay,
2594
+ withGlyph,
2595
+ glyphSize,
2596
+ renderGlyph,
2597
+ legendShape
2598
+ ]);
2587
2599
  }
2588
2600
 
2589
- // ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/empty.js
2590
- var EMPTY_ARRAY = Object.freeze([]);
2591
- var EMPTY_OBJECT = Object.freeze({});
2601
+ // src/components/tooltip/base-tooltip.tsx
2602
+ import { formatNumber as formatNumber4 } from "@automattic/number-formatters";
2592
2603
 
2593
- // ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/constants.js
2594
- var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
2595
- var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
2596
- var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
2597
- var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
2604
+ // src/components/tooltip/base-tooltip.module.scss
2605
+ var base_tooltip_module_default = {
2606
+ "tooltip": "a8ccharts-OfX6nd"
2607
+ };
2598
2608
 
2599
- // ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/useRenderElement.js
2600
- import { createElement as _createElement } from "react";
2601
- function useRenderElement(element, componentProps, params = {}) {
2602
- const renderProp = componentProps.render;
2603
- const outProps = useRenderElementProps(componentProps, params);
2604
- if (params.enabled === false) {
2605
- return null;
2606
- }
2607
- const state = params.state ?? EMPTY_OBJECT;
2608
- return evaluateRenderProp(element, renderProp, outProps, state);
2609
- }
2610
- function useRenderElementProps(componentProps, params = {}) {
2611
- const {
2612
- className: classNameProp,
2613
- style: styleProp,
2614
- render: renderProp
2615
- } = componentProps;
2616
- const {
2617
- state = EMPTY_OBJECT,
2618
- ref,
2619
- props,
2620
- stateAttributesMapping,
2621
- enabled = true
2622
- } = params;
2623
- const className = enabled ? resolveClassName(classNameProp, state) : void 0;
2624
- const style = enabled ? resolveStyle(styleProp, state) : void 0;
2625
- const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping) : EMPTY_OBJECT;
2626
- const outProps = enabled ? mergeObjects(stateProps, Array.isArray(props) ? mergePropsN(props) : props) ?? EMPTY_OBJECT : EMPTY_OBJECT;
2627
- if (typeof document !== "undefined") {
2628
- if (!enabled) {
2629
- useMergedRefs(null, null);
2630
- } else if (Array.isArray(ref)) {
2631
- outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
2632
- } else {
2633
- outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
2634
- }
2635
- }
2636
- if (!enabled) {
2637
- return EMPTY_OBJECT;
2638
- }
2639
- if (className !== void 0) {
2640
- outProps.className = mergeClassNames(outProps.className, className);
2641
- }
2642
- if (style !== void 0) {
2643
- outProps.style = mergeObjects(outProps.style, style);
2609
+ // src/components/tooltip/base-tooltip.tsx
2610
+ import { Fragment as _Fragment, jsxs as _jsxs2, jsx as _jsx4 } from "react/jsx-runtime";
2611
+ var DefaultTooltipContent = ({
2612
+ data
2613
+ }) => /* @__PURE__ */ _jsxs2(_Fragment, {
2614
+ children: [data?.label, ": ", data?.valueDisplay || formatNumber4(data?.value)]
2615
+ });
2616
+ var BaseTooltip = ({
2617
+ data,
2618
+ top,
2619
+ left,
2620
+ component: Component2 = DefaultTooltipContent,
2621
+ children,
2622
+ className,
2623
+ style,
2624
+ renderContainer = true
2625
+ }) => {
2626
+ const content = children || data && /* @__PURE__ */ _jsx4(Component2, {
2627
+ data,
2628
+ className
2629
+ });
2630
+ if (!renderContainer) {
2631
+ return content;
2644
2632
  }
2645
- return outProps;
2646
- }
2647
- var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
2648
- function evaluateRenderProp(element, render, props, state) {
2649
- if (render) {
2650
- if (typeof render === "function") {
2651
- if (process.env.NODE_ENV !== "production") {
2652
- warnIfRenderPropLooksLikeComponent(render);
2633
+ return /* @__PURE__ */ _jsx4("div", {
2634
+ className: base_tooltip_module_default.tooltip,
2635
+ style: {
2636
+ top,
2637
+ left,
2638
+ ...style
2639
+ },
2640
+ role: "tooltip",
2641
+ children: content
2642
+ });
2643
+ };
2644
+
2645
+ // src/components/tooltip/accessible-tooltip.tsx
2646
+ import { Tooltip, TooltipContext } from "@visx/xychart";
2647
+ import { useContext as useContext7, useEffect as useEffect6, useCallback as useCallback6, useMemo as useMemo12 } from "react";
2648
+ import { jsx as _jsx5 } from "react/jsx-runtime";
2649
+ var AccessibleTooltip = ({
2650
+ renderTooltip,
2651
+ selectedIndex,
2652
+ tooltipRef,
2653
+ keyboardFocusedClassName,
2654
+ series = [],
2655
+ mode = "group",
2656
+ ...props
2657
+ }) => {
2658
+ const tooltipContext = useContext7(TooltipContext);
2659
+ const tooltipData = useMemo12(() => {
2660
+ if (mode !== "individual") return [];
2661
+ if (series.length === 0) return [];
2662
+ const maxDataPoints = Math.max(...series.map((s) => s.data.length));
2663
+ const flattened = [];
2664
+ for (let dataPointIndex = 0; dataPointIndex < maxDataPoints; dataPointIndex++) {
2665
+ for (let seriesIndex = 0; seriesIndex < series.length; seriesIndex++) {
2666
+ const seriesData = series[seriesIndex];
2667
+ if (dataPointIndex < seriesData.data.length) {
2668
+ flattened.push({
2669
+ datum: seriesData.data[dataPointIndex],
2670
+ seriesLabel: seriesData.label,
2671
+ seriesIndex,
2672
+ dataPointIndex
2673
+ });
2674
+ }
2653
2675
  }
2654
- return render(props, state);
2655
2676
  }
2656
- const mergedProps = mergeProps(props, render.props);
2657
- mergedProps.ref = props.ref;
2658
- let newElement = render;
2659
- if (newElement?.$$typeof === REACT_LAZY_TYPE) {
2660
- const children = React4.Children.toArray(render);
2661
- newElement = children[0];
2677
+ return flattened;
2678
+ }, [series, mode]);
2679
+ useEffect6(() => {
2680
+ if (selectedIndex === void 0) {
2681
+ tooltipContext?.hideTooltip();
2682
+ return;
2662
2683
  }
2663
- if (process.env.NODE_ENV !== "production") {
2664
- if (!/* @__PURE__ */ React4.isValidElement(newElement)) {
2665
- throw new Error(["Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.", "A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.", "https://base-ui.com/r/invalid-render-prop"].join("\n"));
2684
+ if (mode === "group") {
2685
+ series.forEach((s, index) => {
2686
+ if (selectedIndex < s.data.length) {
2687
+ const datum = s.data[selectedIndex];
2688
+ tooltipContext?.showTooltip({
2689
+ datum,
2690
+ key: s.label,
2691
+ index
2692
+ });
2693
+ }
2694
+ });
2695
+ } else if (mode === "individual") {
2696
+ if (selectedIndex < tooltipData.length) {
2697
+ const tooltipItem = tooltipData[selectedIndex];
2698
+ tooltipContext?.showTooltip({
2699
+ datum: tooltipItem.datum,
2700
+ key: tooltipItem.seriesLabel,
2701
+ index: tooltipItem.seriesIndex
2702
+ });
2666
2703
  }
2667
2704
  }
2668
- return /* @__PURE__ */ React4.cloneElement(newElement, mergedProps);
2669
- }
2670
- if (element) {
2671
- if (typeof element === "string") {
2672
- return renderTag(element, props);
2705
+ }, [selectedIndex, tooltipData, series]);
2706
+ const focusableRenderTooltip = useMemo12(() => {
2707
+ if (!renderTooltip) return void 0;
2708
+ return (params) => {
2709
+ const tooltipContent = renderTooltip(params);
2710
+ if (selectedIndex !== void 0) {
2711
+ return /* @__PURE__ */ _jsx5("div", {
2712
+ ref: tooltipRef,
2713
+ tabIndex: -1,
2714
+ role: "tooltip",
2715
+ "aria-atomic": "true",
2716
+ className: keyboardFocusedClassName,
2717
+ children: tooltipContent
2718
+ }, `chart-tooltip-${selectedIndex}`);
2719
+ }
2720
+ return /* @__PURE__ */ _jsx5("div", {
2721
+ role: "tooltip",
2722
+ "aria-live": "polite",
2723
+ children: tooltipContent
2724
+ });
2725
+ };
2726
+ }, [renderTooltip, selectedIndex, tooltipRef, keyboardFocusedClassName]);
2727
+ return /* @__PURE__ */ _jsx5(Tooltip, {
2728
+ ...props,
2729
+ renderTooltip: focusableRenderTooltip
2730
+ });
2731
+ };
2732
+ var useKeyboardNavigation = ({
2733
+ selectedIndex,
2734
+ setSelectedIndex,
2735
+ isNavigating,
2736
+ setIsNavigating,
2737
+ chartRef,
2738
+ totalPoints
2739
+ }) => {
2740
+ const tooltipRef = useCallback6((element) => {
2741
+ if (element && selectedIndex !== void 0) {
2742
+ element.focus();
2743
+ }
2744
+ }, [selectedIndex]);
2745
+ const onChartFocus = useCallback6(() => {
2746
+ if (!isNavigating && selectedIndex !== void 0) {
2747
+ setSelectedIndex(0);
2748
+ }
2749
+ }, [isNavigating, selectedIndex, setSelectedIndex]);
2750
+ const onChartBlur = useCallback6(() => {
2751
+ setIsNavigating(false);
2752
+ }, [setIsNavigating]);
2753
+ const onChartKeyDown = useCallback6((event) => {
2754
+ if (totalPoints === 0) return;
2755
+ if (event.key === "Tab") {
2756
+ chartRef.current?.focus();
2757
+ setSelectedIndex(void 0);
2758
+ setIsNavigating(false);
2759
+ return;
2760
+ }
2761
+ const currentSelectedIndex = selectedIndex === void 0 ? -1 : selectedIndex;
2762
+ if (currentSelectedIndex + 1 >= totalPoints && ["ArrowRight"].includes(event.key)) {
2763
+ chartRef.current?.focus();
2764
+ setSelectedIndex(void 0);
2765
+ setIsNavigating(false);
2766
+ return;
2673
2767
  }
2674
- }
2675
- throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
2676
- }
2677
- function warnIfRenderPropLooksLikeComponent(renderFn) {
2678
- const functionName = renderFn.name;
2679
- if (functionName.length === 0) {
2680
- return;
2681
- }
2682
- const firstCharacterCode = functionName.charCodeAt(0);
2683
- if (firstCharacterCode < 65 || firstCharacterCode > 90) {
2684
- return;
2685
- }
2686
- warn(`The \`render\` prop received a function named \`${functionName}\` that starts with an uppercase letter.`, "This usually means a React component was passed directly as `render={Component}`.", "Base UI calls `render` as a plain function, which can break the Rules of Hooks during reconciliation.", "If this is an intentional render callback, rename it to start with a lowercase letter.", "Use `render={<Component />}` or `render={(props) => <Component {...props} />}` instead.", "https://base-ui.com/r/invalid-render-prop");
2687
- }
2688
- function renderTag(Tag, props) {
2689
- if (Tag === "button") {
2690
- return /* @__PURE__ */ _createElement("button", {
2691
- type: "button",
2692
- ...props,
2693
- key: props.key
2694
- });
2695
- }
2696
- if (Tag === "img") {
2697
- return /* @__PURE__ */ _createElement("img", {
2698
- alt: "",
2699
- ...props,
2700
- key: props.key
2701
- });
2702
- }
2703
- return /* @__PURE__ */ React4.createElement(Tag, props);
2704
- }
2705
-
2706
- // ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/use-render/useRender.js
2707
- function useRender(params) {
2708
- return useRenderElement(params.defaultTagName ?? "div", params, params);
2709
- }
2710
-
2711
- // ../../../node_modules/.pnpm/@wordpress+element@6.43.0/node_modules/@wordpress/element/build-module/react.mjs
2712
- import {
2713
- Children as Children3,
2714
- cloneElement as cloneElement2,
2715
- Component,
2716
- createContext as createContext3,
2717
- createElement as createElement3,
2718
- createRef,
2719
- forwardRef as forwardRef3,
2720
- Fragment as Fragment2,
2721
- isValidElement as isValidElement4,
2722
- memo,
2723
- PureComponent,
2724
- StrictMode,
2725
- useCallback as useCallback6,
2726
- useContext as useContext7,
2727
- useDebugValue,
2728
- useDeferredValue,
2729
- useEffect as useEffect6,
2730
- useId as useId2,
2731
- useMemo as useMemo13,
2732
- useImperativeHandle,
2733
- useInsertionEffect,
2734
- useLayoutEffect as useLayoutEffect2,
2735
- useReducer,
2736
- useRef as useRef6,
2737
- useState as useState5,
2738
- useSyncExternalStore,
2739
- useTransition,
2740
- startTransition,
2741
- lazy,
2742
- Suspense
2743
- } from "react";
2744
-
2745
- // ../../../node_modules/.pnpm/is-plain-object@5.0.0/node_modules/is-plain-object/dist/is-plain-object.mjs
2746
- function isObject(o) {
2747
- return Object.prototype.toString.call(o) === "[object Object]";
2748
- }
2749
- function isPlainObject(o) {
2750
- var ctor, prot;
2751
- if (isObject(o) === false) return false;
2752
- ctor = o.constructor;
2753
- if (ctor === void 0) return true;
2754
- prot = ctor.prototype;
2755
- if (isObject(prot) === false) return false;
2756
- if (prot.hasOwnProperty("isPrototypeOf") === false) {
2757
- return false;
2758
- }
2759
- return true;
2760
- }
2761
-
2762
- // ../../../node_modules/.pnpm/lower-case@2.0.2/node_modules/lower-case/dist.es2015/index.js
2763
- function lowerCase(str) {
2764
- return str.toLowerCase();
2765
- }
2766
-
2767
- // ../../../node_modules/.pnpm/no-case@3.0.4/node_modules/no-case/dist.es2015/index.js
2768
- var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
2769
- var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
2770
- function noCase(input, options) {
2771
- if (options === void 0) {
2772
- options = {};
2773
- }
2774
- var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter2 = _d === void 0 ? " " : _d;
2775
- var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
2776
- var start = 0;
2777
- var end = result.length;
2778
- while (result.charAt(start) === "\0")
2779
- start++;
2780
- while (result.charAt(end - 1) === "\0")
2781
- end--;
2782
- return result.slice(start, end).split("\0").map(transform).join(delimiter2);
2783
- }
2784
- function replace(input, re, value) {
2785
- if (re instanceof RegExp)
2786
- return input.replace(re, value);
2787
- return re.reduce(function(input2, re2) {
2788
- return input2.replace(re2, value);
2789
- }, input);
2790
- }
2768
+ event.preventDefault();
2769
+ if (["ArrowRight"].includes(event.key)) {
2770
+ setIsNavigating(true);
2771
+ setSelectedIndex((currentSelectedIndex + 1) % totalPoints);
2772
+ } else if (["ArrowLeft"].includes(event.key)) {
2773
+ setIsNavigating(true);
2774
+ setSelectedIndex((currentSelectedIndex - 1 + totalPoints) % totalPoints);
2775
+ } else if (event.key === "Escape") {
2776
+ setSelectedIndex(void 0);
2777
+ setIsNavigating(false);
2778
+ chartRef.current?.focus();
2779
+ }
2780
+ }, [totalPoints, selectedIndex, setSelectedIndex, setIsNavigating, chartRef]);
2781
+ return {
2782
+ tooltipRef,
2783
+ onChartFocus,
2784
+ onChartBlur,
2785
+ onChartKeyDown
2786
+ };
2787
+ };
2791
2788
 
2792
- // ../../../node_modules/.pnpm/dot-case@3.0.4/node_modules/dot-case/dist.es2015/index.js
2793
- import { __assign } from "tslib";
2794
- function dotCase(input, options) {
2795
- if (options === void 0) {
2796
- options = {};
2797
- }
2798
- return noCase(input, __assign({ delimiter: "." }, options));
2799
- }
2789
+ // src/charts/private/chart-composition/chart-svg.tsx
2790
+ import { Fragment as _Fragment2, jsx as _jsx6 } from "react/jsx-runtime";
2791
+ var ChartSVG = ({
2792
+ children
2793
+ }) => {
2794
+ return /* @__PURE__ */ _jsx6(_Fragment2, {
2795
+ children
2796
+ });
2797
+ };
2798
+ ChartSVG.displayName = "Chart.SVG";
2800
2799
 
2801
- // ../../../node_modules/.pnpm/param-case@3.0.4/node_modules/param-case/dist.es2015/index.js
2802
- import { __assign as __assign2 } from "tslib";
2803
- function paramCase(input, options) {
2804
- if (options === void 0) {
2805
- options = {};
2806
- }
2807
- return dotCase(input, __assign2({ delimiter: "-" }, options));
2808
- }
2800
+ // src/charts/private/chart-composition/chart-html.tsx
2801
+ import { Fragment as _Fragment3, jsx as _jsx7 } from "react/jsx-runtime";
2802
+ var ChartHTML = ({
2803
+ children
2804
+ }) => {
2805
+ return /* @__PURE__ */ _jsx7(_Fragment3, {
2806
+ children
2807
+ });
2808
+ };
2809
+ ChartHTML.displayName = "Chart.HTML";
2809
2810
 
2810
- // ../../../node_modules/.pnpm/@wordpress+ui@0.9.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1_stylelint@17.5.0/node_modules/@wordpress/ui/build-module/stack/stack.mjs
2811
- if (typeof document !== "undefined" && process.env.NODE_ENV !== "test" && !document.head.querySelector("style[data-wp-hash='71d20935c2']")) {
2812
- const style = document.createElement("style");
2813
- style.setAttribute("data-wp-hash", "71d20935c2");
2814
- style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._19ce0419607e1896__stack{display:flex}}"));
2815
- document.head.appendChild(style);
2811
+ // src/charts/private/chart-composition/render-legend-slot.ts
2812
+ import { createElement as createElement3, Fragment as Fragment2 } from "react";
2813
+ function renderLegendSlot(legendChildren, position2) {
2814
+ return legendChildren.filter((l) => l.position === position2).map(
2815
+ (l, i) => createElement3(Fragment2, { key: `legend-${position2}-${i}` }, l.element)
2816
+ );
2816
2817
  }
2817
- var style_default = { "stack": "_19ce0419607e1896__stack" };
2818
- var gapTokens = {
2819
- xs: "var(--wpds-dimension-gap-xs, 4px)",
2820
- sm: "var(--wpds-dimension-gap-sm, 8px)",
2821
- md: "var(--wpds-dimension-gap-md, 12px)",
2822
- lg: "var(--wpds-dimension-gap-lg, 16px)",
2823
- xl: "var(--wpds-dimension-gap-xl, 24px)",
2824
- "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
2825
- "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
2826
- };
2827
- var Stack = forwardRef3(function Stack2({ direction, gap, align, justify, wrap, render, ...props }, ref) {
2828
- const style = {
2829
- gap: gap && gapTokens[gap],
2830
- alignItems: align,
2831
- justifyContent: justify,
2832
- flexDirection: direction,
2833
- flexWrap: wrap
2834
- };
2835
- const element = useRender({
2836
- render,
2837
- ref,
2838
- props: mergeProps(props, { style, className: style_default.stack })
2839
- });
2840
- return element;
2841
- });
2842
2818
 
2843
- // ../../../node_modules/.pnpm/@wordpress+ui@0.9.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1_stylelint@17.5.0/node_modules/@wordpress/ui/build-module/text/text.mjs
2844
- import clsx2 from "clsx";
2845
- if (typeof document !== "undefined" && process.env.NODE_ENV !== "test" && !document.head.querySelector("style[data-wp-hash='893fb81f3c']")) {
2846
- const style = document.createElement("style");
2847
- style.setAttribute("data-wp-hash", "893fb81f3c");
2848
- style.appendChild(document.createTextNode('@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._14437cfb77831647__heading-2xl{font-size:var(--wpds-font-size-2xl,32px);line-height:var(--wpds-font-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-font-weight-medium,499)}._3c78b7fa9b4072dd__heading-xl{font-size:var(--wpds-font-size-xl,20px);line-height:var(--wpds-font-line-height-md,24px)}.aa58f227716bcde2__heading-lg{font-size:var(--wpds-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-font-weight-medium,499);line-height:var(--wpds-font-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{font-size:var(--wpds-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{font-family:var(--wpds-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-font-size-xs,11px);font-weight:var(--wpds-font-weight-medium,499);line-height:var(--wpds-font-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{font-size:var(--wpds-font-size-xl,20px);line-height:var(--wpds-font-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-font-weight-regular,400)}.ca1aa3fc2029e958__body-lg{font-size:var(--wpds-font-size-lg,15px);line-height:var(--wpds-font-line-height-md,24px)}._131101940be12424__body-md{font-size:var(--wpds-font-size-md,13px);line-height:var(--wpds-font-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-font-weight-regular,400)}._0e8d87a42c1f75fa__body-sm{font-size:var(--wpds-font-size-sm,12px);line-height:var(--wpds-font-line-height-xs,16px)}}'));
2849
- document.head.appendChild(style);
2819
+ // src/charts/private/chart-composition/use-chart-children.ts
2820
+ import { Group as Group2 } from "@visx/group";
2821
+ import { useMemo as useMemo13, Children as Children3, isValidElement as isValidElement4 } from "react";
2822
+ function useChartChildren(children, chartType) {
2823
+ return useMemo13(() => {
2824
+ const svg = [];
2825
+ const html = [];
2826
+ const legend = [];
2827
+ const other = [];
2828
+ const nonLegend = [];
2829
+ Children3.forEach(children, (child) => {
2830
+ if (isValidElement4(child)) {
2831
+ if (child.type === Legend) {
2832
+ const rawPosition = child.props?.position;
2833
+ const position2 = rawPosition === "top" || rawPosition === "bottom" ? rawPosition : "bottom";
2834
+ legend.push({ element: child, position: position2 });
2835
+ return;
2836
+ }
2837
+ const childType = child.type;
2838
+ const displayName = childType?.displayName;
2839
+ if (displayName === `${chartType}.SVG` || displayName === "Chart.SVG") {
2840
+ if (child.props?.children) {
2841
+ Children3.forEach(child.props.children, (svgChild) => {
2842
+ svg.push(svgChild);
2843
+ });
2844
+ }
2845
+ } else if (displayName === `${chartType}.HTML` || displayName === "Chart.HTML") {
2846
+ if (child.props?.children) {
2847
+ Children3.forEach(child.props.children, (htmlChild) => {
2848
+ html.push(htmlChild);
2849
+ });
2850
+ }
2851
+ } else if (child.type === Group2) {
2852
+ svg.push(child);
2853
+ } else {
2854
+ other.push(child);
2855
+ }
2856
+ }
2857
+ nonLegend.push(child);
2858
+ });
2859
+ return {
2860
+ svgChildren: svg,
2861
+ htmlChildren: html,
2862
+ legendChildren: legend,
2863
+ otherChildren: other,
2864
+ nonLegendChildren: nonLegend
2865
+ };
2866
+ }, [children, chartType]);
2850
2867
  }
2851
- var style_default2 = { "heading-2xl": "_14437cfb77831647__heading-2xl", "heading-xl": "_3c78b7fa9b4072dd__heading-xl", "heading-lg": "aa58f227716bcde2__heading-lg", "heading-md": "fc4da56d8dfe52c4__heading-md", "heading-sm": "a9b78c7c82e8dff7__heading-sm", "body-xl": "_305ff559e52180d5__body-xl", "body-lg": "ca1aa3fc2029e958__body-lg", "body-md": "_131101940be12424__body-md", "body-sm": "_0e8d87a42c1f75fa__body-sm" };
2852
- var Text = forwardRef3(function Text2({ variant = "body-md", render, className, ...props }, ref) {
2853
- const element = useRender({
2854
- render,
2855
- defaultTagName: "span",
2856
- ref,
2857
- props: mergeProps(props, {
2858
- className: clsx2(style_default2[variant], className)
2859
- })
2860
- });
2861
- return element;
2862
- });
2863
2868
 
2864
2869
  // src/charts/private/chart-layout/chart-layout.tsx
2865
2870
  import { useEffect as useEffect7 } from "react";
@@ -3808,7 +3813,6 @@ var conversion_funnel_chart_module_default = {
3808
3813
  "funnel-step": "a8ccharts-VqFY0l",
3809
3814
  "funnel-step--animated": "a8ccharts-fk-hCl",
3810
3815
  "funnel-step--blurred": "a8ccharts-1zOc9c",
3811
- "step-header": "a8ccharts-2JsQiV",
3812
3816
  "step-label": "a8ccharts-6OabC4",
3813
3817
  "step-rate": "a8ccharts-9wSZ6n",
3814
3818
  "bar-container": "a8ccharts-sSmCTi",
@@ -4048,7 +4052,10 @@ var ConversionFunnelChartInternal = ({
4048
4052
  children: changeIndicator
4049
4053
  })]
4050
4054
  });
4051
- const renderDefaultTooltip2 = (step) => /* @__PURE__ */ _jsxs6(_Fragment5, {
4055
+ const renderDefaultTooltip2 = (step) => /* @__PURE__ */ _jsxs6(Stack, {
4056
+ direction: "column",
4057
+ align: "flex-start",
4058
+ gap: "xs",
4052
4059
  children: [/* @__PURE__ */ _jsx14("div", {
4053
4060
  className: conversion_funnel_chart_module_default["tooltip-title"],
4054
4061
  children: step.label
@@ -4089,6 +4096,7 @@ var ConversionFunnelChartInternal = ({
4089
4096
  return /* @__PURE__ */ _jsxs6(_Fragment5, {
4090
4097
  children: [/* @__PURE__ */ _jsxs6(Stack, {
4091
4098
  direction: "column",
4099
+ gap: "xl",
4092
4100
  ref: (node2) => {
4093
4101
  portalContainerRef(node2);
4094
4102
  chartRef.current = node2;
@@ -4103,20 +4111,27 @@ var ConversionFunnelChartInternal = ({
4103
4111
  changeIndicator,
4104
4112
  className: conversion_funnel_chart_module_default["main-metric"],
4105
4113
  changeColor
4106
- }) : /* @__PURE__ */ _jsx14("div", {
4114
+ }) : /* @__PURE__ */ _jsx14(Stack, {
4115
+ direction: "row",
4116
+ align: "baseline",
4117
+ gap: "sm",
4107
4118
  className: conversion_funnel_chart_module_default["main-metric"],
4108
4119
  children: renderDefaultMainMetric()
4109
- }), /* @__PURE__ */ _jsx14("div", {
4120
+ }), /* @__PURE__ */ _jsx14(Stack, {
4121
+ direction: "row",
4122
+ align: "flex-end",
4123
+ gap: "lg",
4110
4124
  className: conversion_funnel_chart_module_default["funnel-container"],
4111
4125
  children: steps.map((step, index) => {
4112
4126
  const barHeight = step.rate / maxRate * 100;
4113
4127
  const {
4114
4128
  isBlurred
4115
4129
  } = getStepState(step.id);
4116
- return /* @__PURE__ */ _jsxs6("div", {
4130
+ return /* @__PURE__ */ _jsxs6(Stack, {
4131
+ direction: "column",
4117
4132
  className: clsx4(conversion_funnel_chart_module_default["funnel-step"], isColorPaletteResolved && conversion_funnel_chart_module_default["funnel-step--animated"], isBlurred && conversion_funnel_chart_module_default["funnel-step--blurred"]),
4133
+ gap: "xl",
4118
4134
  children: [/* @__PURE__ */ _jsxs6("div", {
4119
- className: conversion_funnel_chart_module_default["step-header"],
4120
4135
  children: [renderStepLabel ? renderStepLabel({
4121
4136
  step,
4122
4137
  index,
@@ -4132,7 +4147,9 @@ var ConversionFunnelChartInternal = ({
4132
4147
  className: conversion_funnel_chart_module_default["step-rate"],
4133
4148
  children: formatPercentage(step.rate)
4134
4149
  })]
4135
- }), /* @__PURE__ */ _jsx14("div", {
4150
+ }), /* @__PURE__ */ _jsx14(Stack, {
4151
+ direction: "column",
4152
+ justify: "flex-end",
4136
4153
  className: conversion_funnel_chart_module_default["bar-container"],
4137
4154
  onClick: stepHandlers.get(step.id)?.onClick,
4138
4155
  onKeyDown: stepHandlers.get(step.id)?.onKeyDown,
@@ -4262,7 +4279,9 @@ var GeoChartInternal = ({
4262
4279
  backgroundColor
4263
4280
  }
4264
4281
  } = useGlobalChartsContext();
4265
- const loadingPlaceholder = /* @__PURE__ */ _jsx15("div", {
4282
+ const loadingPlaceholder = /* @__PURE__ */ _jsx15(Stack, {
4283
+ align: "center",
4284
+ justify: "center",
4266
4285
  className: clsx5("geo-chart", geo_chart_module_default.container, className),
4267
4286
  style: {
4268
4287
  width,
@@ -4330,7 +4349,9 @@ var GeoChartInternal = ({
4330
4349
  legend: "none",
4331
4350
  keepAspectRatio: true
4332
4351
  }), [region, resolution, lightColorHex, fullColorHex, backgroundColorHex, defaultFillColorHex, sanitizedData.hasHtmlTooltips]);
4333
- return /* @__PURE__ */ _jsx15("div", {
4352
+ return /* @__PURE__ */ _jsx15(Stack, {
4353
+ align: "center",
4354
+ justify: "center",
4334
4355
  className: clsx5("geo-chart", geo_chart_module_default.container, className),
4335
4356
  style: {
4336
4357
  width,
@@ -4366,14 +4387,14 @@ var GeoChartResponsive = withResponsive(GeoChartWithProvider);
4366
4387
  // ../../../node_modules/.pnpm/@wordpress+components@32.5.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/hooks/use-update-effect.mjs
4367
4388
  function useUpdateEffect(effect, deps) {
4368
4389
  const mountedRef = useRef6(false);
4369
- useEffect6(() => {
4390
+ useEffect5(() => {
4370
4391
  if (mountedRef.current) {
4371
4392
  return effect();
4372
4393
  }
4373
4394
  mountedRef.current = true;
4374
4395
  return void 0;
4375
4396
  }, deps);
4376
- useEffect6(() => () => {
4397
+ useEffect5(() => () => {
4377
4398
  mountedRef.current = false;
4378
4399
  }, []);
4379
4400
  }
@@ -5821,7 +5842,7 @@ var cache = _createEmotion.cache;
5821
5842
  var isSerializedStyles = (o) => typeof o !== "undefined" && o !== null && ["name", "styles"].every((p) => typeof o[p] !== "undefined");
5822
5843
  var useCx = () => {
5823
5844
  const cache2 = __unsafe_useEmotionCache();
5824
- const cx2 = useCallback6((...classNames) => {
5845
+ const cx2 = useCallback4((...classNames) => {
5825
5846
  if (cache2 === null) {
5826
5847
  throw new Error("The `useCx` hook should be only used within a valid Emotion Cache Context");
5827
5848
  }
@@ -6086,7 +6107,7 @@ var ComponentsContext = createContext3(
6086
6107
  {}
6087
6108
  );
6088
6109
  ComponentsContext.displayName = "ComponentsContext";
6089
- var useComponentsContext = () => useContext7(ComponentsContext);
6110
+ var useComponentsContext = () => useContext4(ComponentsContext);
6090
6111
  function useContextSystemBridge({
6091
6112
  value
6092
6113
  }) {
@@ -6101,7 +6122,7 @@ function useContextSystemBridge({
6101
6122
  globalThis.SCRIPT_DEBUG === true ? warning(`Please memoize your context: ${JSON.stringify(value)}`) : void 0;
6102
6123
  }
6103
6124
  }, [value]);
6104
- const config = useMemo13(() => {
6125
+ const config = useMemo9(() => {
6105
6126
  return deepmerge2(parentContext ?? {}, value ?? {}, {
6106
6127
  isMergeableObject: isPlainObject
6107
6128
  });
@@ -6141,7 +6162,7 @@ function contextConnect(Component2, namespace) {
6141
6162
  });
6142
6163
  }
6143
6164
  function _contextConnect(Component2, namespace, options) {
6144
- const WrappedComponent = options?.forwardsRef ? forwardRef3(Component2) : Component2;
6165
+ const WrappedComponent = options?.forwardsRef ? forwardRef(Component2) : Component2;
6145
6166
  if (typeof namespace === "undefined") {
6146
6167
  globalThis.SCRIPT_DEBUG === true ? warning("contextConnect: Please provide a namespace") : void 0;
6147
6168
  }
@@ -6373,7 +6394,7 @@ function UnforwardedView({
6373
6394
  ...restProps
6374
6395
  });
6375
6396
  }
6376
- var View = Object.assign(forwardRef3(UnforwardedView), {
6397
+ var View = Object.assign(forwardRef(UnforwardedView), {
6377
6398
  selector: ".components-view"
6378
6399
  });
6379
6400
  var component_default = View;
@@ -6390,7 +6411,7 @@ var useBreakpointIndex = (options = {}) => {
6390
6411
  throw new RangeError(`Default breakpoint index out of range. Theme has ${breakpoints.length} breakpoints, got index ${defaultIndex}`);
6391
6412
  }
6392
6413
  const [value, setValue] = useState5(defaultIndex);
6393
- useEffect6(() => {
6414
+ useEffect5(() => {
6394
6415
  const getIndex = () => breakpoints.filter((bp) => {
6395
6416
  return typeof window !== "undefined" ? window.matchMedia(`screen and (min-width: ${bp})`).matches : false;
6396
6417
  }).length;
@@ -6496,7 +6517,7 @@ function useGrid(props) {
6496
6517
  const gridTemplateColumns = templateColumns || !!columns && `repeat( ${column2}, 1fr )`;
6497
6518
  const gridTemplateRows = templateRows || !!rows && `repeat( ${row}, 1fr )`;
6498
6519
  const cx2 = useCx();
6499
- const classes = useMemo13(() => {
6520
+ const classes = useMemo9(() => {
6500
6521
  const alignmentProps = getAlignmentProps(alignment);
6501
6522
  const gridClasses = /* @__PURE__ */ css({
6502
6523
  alignItems: align,
@@ -6826,7 +6847,7 @@ var LeaderboardChartInternal = ({
6826
6847
  children: data.map((entry) => {
6827
6848
  const colorIndex = Math.sign(entry.delta) + 1;
6828
6849
  const deltaColor = deltaColors[colorIndex];
6829
- return /* @__PURE__ */ _jsxs7(Fragment2, {
6850
+ return /* @__PURE__ */ _jsxs7(Fragment, {
6830
6851
  children: [/* @__PURE__ */ _jsx19(Stack, {
6831
6852
  direction: "column",
6832
6853
  gap: labelSpacing,
@@ -6930,7 +6951,6 @@ var line_chart_module_default = {
6930
6951
  "line-chart__annotation-label-trigger-button": "a8ccharts-7mh3Cl",
6931
6952
  "line-chart__annotation-label-popover--visible": "a8ccharts-VAeVuJ",
6932
6953
  "line-chart__annotation-label-popover--safari": "a8ccharts-TEe-iV",
6933
- "line-chart__annotation-label-popover-header": "a8ccharts-LAUpx7",
6934
6954
  "line-chart__annotation-label-popover-content": "a8ccharts-b76gEu",
6935
6955
  "line-chart__annotation-label-popover-close-button": "a8ccharts-LIpFoS"
6936
6956
  };
@@ -6998,8 +7018,10 @@ var LineChartAnnotationLabelWithPopover = ({
6998
7018
  id: popoverId,
6999
7019
  popover: "auto",
7000
7020
  className: clsx7(line_chart_module_default["line-chart__annotation-label-popover"], isPositioned && line_chart_module_default["line-chart__annotation-label-popover--visible"], isBrowserSafari && line_chart_module_default["line-chart__annotation-label-popover--safari"]),
7001
- children: /* @__PURE__ */ _jsxs8("div", {
7002
- className: line_chart_module_default["line-chart__annotation-label-popover-header"],
7021
+ children: /* @__PURE__ */ _jsxs8(Stack, {
7022
+ direction: "row",
7023
+ align: "flex-start",
7024
+ justify: "space-between",
7003
7025
  children: [/* @__PURE__ */ _jsx21("div", {
7004
7026
  className: line_chart_module_default["line-chart__annotation-label-popover-content"],
7005
7027
  children: renderLabelPopover({
@@ -7442,7 +7464,10 @@ var renderDefaultTooltip = (params) => {
7442
7464
  children: [/* @__PURE__ */ _jsx24("div", {
7443
7465
  className: line_chart_module_default["line-chart__tooltip-date"],
7444
7466
  children: nearestDatum.date?.toLocaleDateString()
7445
- }), tooltipPoints.map((point) => /* @__PURE__ */ _jsxs10("div", {
7467
+ }), tooltipPoints.map((point) => /* @__PURE__ */ _jsxs10(Stack, {
7468
+ direction: "row",
7469
+ align: "center",
7470
+ justify: "space-between",
7446
7471
  className: line_chart_module_default["line-chart__tooltip-row"],
7447
7472
  children: [/* @__PURE__ */ _jsxs10("span", {
7448
7473
  className: line_chart_module_default["line-chart__tooltip-label"],