@automattic/charts 0.56.3 → 0.56.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/charts/bar-chart/index.cjs +5 -5
  3. package/dist/charts/bar-chart/index.css +12 -0
  4. package/dist/charts/bar-chart/index.css.map +1 -1
  5. package/dist/charts/bar-chart/index.js +4 -4
  6. package/dist/charts/bar-list-chart/index.cjs +6 -6
  7. package/dist/charts/bar-list-chart/index.css +12 -0
  8. package/dist/charts/bar-list-chart/index.css.map +1 -1
  9. package/dist/charts/bar-list-chart/index.js +5 -5
  10. package/dist/charts/conversion-funnel-chart/index.cjs +5 -3
  11. package/dist/charts/conversion-funnel-chart/index.cjs.map +1 -1
  12. package/dist/charts/conversion-funnel-chart/index.css +14 -1
  13. package/dist/charts/conversion-funnel-chart/index.css.map +1 -1
  14. package/dist/charts/conversion-funnel-chart/index.d.cts +2 -0
  15. package/dist/charts/conversion-funnel-chart/index.d.ts +2 -0
  16. package/dist/charts/conversion-funnel-chart/index.js +4 -2
  17. package/dist/charts/geo-chart/index.cjs +4 -4
  18. package/dist/charts/geo-chart/index.css +12 -0
  19. package/dist/charts/geo-chart/index.css.map +1 -1
  20. package/dist/charts/geo-chart/index.js +3 -3
  21. package/dist/charts/leaderboard-chart/index.cjs +5 -5
  22. package/dist/charts/leaderboard-chart/index.css +12 -0
  23. package/dist/charts/leaderboard-chart/index.css.map +1 -1
  24. package/dist/charts/leaderboard-chart/index.js +4 -4
  25. package/dist/charts/line-chart/index.cjs +5 -5
  26. package/dist/charts/line-chart/index.css +12 -0
  27. package/dist/charts/line-chart/index.css.map +1 -1
  28. package/dist/charts/line-chart/index.js +4 -4
  29. package/dist/charts/pie-chart/index.cjs +7 -7
  30. package/dist/charts/pie-chart/index.css +12 -0
  31. package/dist/charts/pie-chart/index.css.map +1 -1
  32. package/dist/charts/pie-chart/index.js +6 -6
  33. package/dist/charts/pie-semi-circle-chart/index.cjs +7 -7
  34. package/dist/charts/pie-semi-circle-chart/index.css +12 -0
  35. package/dist/charts/pie-semi-circle-chart/index.css.map +1 -1
  36. package/dist/charts/pie-semi-circle-chart/index.js +6 -6
  37. package/dist/charts/sparkline/index.cjs +6 -6
  38. package/dist/charts/sparkline/index.css +12 -0
  39. package/dist/charts/sparkline/index.css.map +1 -1
  40. package/dist/charts/sparkline/index.js +5 -5
  41. package/dist/{chunk-OTZT3MC2.cjs → chunk-2A34OA5O.cjs} +19 -20
  42. package/dist/chunk-2A34OA5O.cjs.map +1 -0
  43. package/dist/{chunk-H34CJSR6.js → chunk-32ESS4MV.js} +406 -363
  44. package/dist/chunk-32ESS4MV.js.map +1 -0
  45. package/dist/{chunk-CEZGL6YP.js → chunk-6CCZL2JJ.js} +15 -7
  46. package/dist/chunk-6CCZL2JJ.js.map +1 -0
  47. package/dist/{chunk-NW3RUYK2.cjs → chunk-7QDEU3KN.cjs} +15 -22
  48. package/dist/chunk-7QDEU3KN.cjs.map +1 -0
  49. package/dist/chunk-7TQSPLIN.js +351 -0
  50. package/dist/chunk-7TQSPLIN.js.map +1 -0
  51. package/dist/{chunk-T4J6TI55.js → chunk-AFWQR3SM.js} +102 -79
  52. package/dist/chunk-AFWQR3SM.js.map +1 -0
  53. package/dist/{chunk-5XI443YP.js → chunk-BPYKWMI7.js} +72 -64
  54. package/dist/chunk-BPYKWMI7.js.map +1 -0
  55. package/dist/{chunk-TNRKEBTA.js → chunk-DBY6C4O2.js} +148 -164
  56. package/dist/{chunk-TNRKEBTA.js.map → chunk-DBY6C4O2.js.map} +1 -1
  57. package/dist/chunk-DLSUC7RN.js +1065 -0
  58. package/dist/chunk-DLSUC7RN.js.map +1 -0
  59. package/dist/{chunk-TVV7ZI7C.cjs → chunk-EJJO2QNB.cjs} +399 -356
  60. package/dist/chunk-EJJO2QNB.cjs.map +1 -0
  61. package/dist/{chunk-ODF5O5PV.cjs → chunk-FIFSYVN6.cjs} +154 -170
  62. package/dist/chunk-FIFSYVN6.cjs.map +1 -0
  63. package/dist/chunk-FY325WQ4.cjs +1065 -0
  64. package/dist/chunk-FY325WQ4.cjs.map +1 -0
  65. package/dist/{chunk-SRXJLAKG.cjs → chunk-I2276W3I.cjs} +28 -37
  66. package/dist/chunk-I2276W3I.cjs.map +1 -0
  67. package/dist/{chunk-7UJPVCMB.cjs → chunk-IHESL7H5.cjs} +265 -262
  68. package/dist/chunk-IHESL7H5.cjs.map +1 -0
  69. package/dist/chunk-JL4ZKKZU.cjs +375 -0
  70. package/dist/chunk-JL4ZKKZU.cjs.map +1 -0
  71. package/dist/chunk-KHRPRH4V.js +165 -0
  72. package/dist/chunk-KHRPRH4V.js.map +1 -0
  73. package/dist/{chunk-A3AEEGKR.js → chunk-KXRWNFQJ.js} +20 -21
  74. package/dist/chunk-KXRWNFQJ.js.map +1 -0
  75. package/dist/{chunk-2VPPTJS2.js → chunk-KXSLMOW5.js} +256 -253
  76. package/dist/chunk-KXSLMOW5.js.map +1 -0
  77. package/dist/chunk-LT4YOIMM.js +375 -0
  78. package/dist/chunk-LT4YOIMM.js.map +1 -0
  79. package/dist/chunk-LTPJPIDP.cjs +165 -0
  80. package/dist/chunk-LTPJPIDP.cjs.map +1 -0
  81. package/dist/chunk-NGHXTIUE.cjs +120 -0
  82. package/dist/chunk-NGHXTIUE.cjs.map +1 -0
  83. package/dist/chunk-PCOI2GT5.js +120 -0
  84. package/dist/chunk-PCOI2GT5.js.map +1 -0
  85. package/dist/{chunk-YYQ4IK5V.cjs → chunk-Q6G3BGCL.cjs} +103 -80
  86. package/dist/chunk-Q6G3BGCL.cjs.map +1 -0
  87. package/dist/{chunk-HIWNB5PK.cjs → chunk-RCY6XLGU.cjs} +13 -5
  88. package/dist/chunk-RCY6XLGU.cjs.map +1 -0
  89. package/dist/chunk-TKPK4RFS.cjs +351 -0
  90. package/dist/chunk-TKPK4RFS.cjs.map +1 -0
  91. package/dist/{chunk-C33AQZEC.js → chunk-TYIH5LMV.js} +16 -23
  92. package/dist/chunk-TYIH5LMV.js.map +1 -0
  93. package/dist/chunk-X6GX4QUJ.js +421 -0
  94. package/dist/chunk-X6GX4QUJ.js.map +1 -0
  95. package/dist/chunk-XCXAWMJQ.cjs +421 -0
  96. package/dist/chunk-XCXAWMJQ.cjs.map +1 -0
  97. package/dist/chunk-XWYZIFZW.js +66 -0
  98. package/dist/chunk-XWYZIFZW.js.map +1 -0
  99. package/dist/{chunk-7HROSZRS.cjs → chunk-Y3NNQMAX.cjs} +70 -62
  100. package/dist/chunk-Y3NNQMAX.cjs.map +1 -0
  101. package/dist/components/legend/index.cjs +2 -2
  102. package/dist/components/legend/index.css +12 -0
  103. package/dist/components/legend/index.css.map +1 -1
  104. package/dist/components/legend/index.js +1 -1
  105. package/dist/components/tooltip/index.cjs +2 -2
  106. package/dist/components/tooltip/index.js +1 -1
  107. package/dist/components/trend-indicator/index.cjs +2 -2
  108. package/dist/components/trend-indicator/index.js +1 -1
  109. package/dist/hooks/index.cjs +4 -2
  110. package/dist/hooks/index.cjs.map +1 -1
  111. package/dist/hooks/index.css +12 -0
  112. package/dist/hooks/index.css.map +1 -1
  113. package/dist/hooks/index.d.cts +28 -2
  114. package/dist/hooks/index.d.ts +28 -2
  115. package/dist/hooks/index.js +3 -1
  116. package/dist/index.cjs +18 -18
  117. package/dist/index.cjs.map +1 -1
  118. package/dist/index.css +14 -1
  119. package/dist/index.css.map +1 -1
  120. package/dist/index.d.cts +1 -1
  121. package/dist/index.d.ts +1 -1
  122. package/dist/index.js +17 -17
  123. package/dist/providers/index.cjs +2 -2
  124. package/dist/providers/index.css +12 -0
  125. package/dist/providers/index.css.map +1 -1
  126. package/dist/providers/index.d.cts +1 -1
  127. package/dist/providers/index.d.ts +1 -1
  128. package/dist/providers/index.js +1 -1
  129. package/dist/{themes-DQs9rbN5.d.cts → themes-BDVaIfBz.d.cts} +9 -0
  130. package/dist/{themes-CRV5fVzJ.d.ts → themes-mcS8QNkQ.d.ts} +9 -0
  131. package/package.json +6 -2
  132. package/src/charts/conversion-funnel-chart/conversion-funnel-chart.module.scss +2 -1
  133. package/src/charts/conversion-funnel-chart/conversion-funnel-chart.tsx +16 -6
  134. package/src/charts/conversion-funnel-chart/test/conversion-funnel-chart.test.tsx +34 -0
  135. package/src/charts/conversion-funnel-chart/types.ts +2 -0
  136. package/src/charts/pie-chart/pie-chart.tsx +2 -3
  137. package/src/hooks/index.ts +1 -0
  138. package/src/hooks/test/use-chart-margin.test.tsx +44 -0
  139. package/src/hooks/test/use-tooltip-portal-relocator.test.ts +216 -0
  140. package/src/hooks/use-chart-margin.tsx +92 -6
  141. package/src/hooks/use-tooltip-portal-relocator.module.scss +10 -0
  142. package/src/hooks/use-tooltip-portal-relocator.ts +177 -0
  143. package/src/providers/chart-context/global-charts-provider.tsx +18 -1
  144. package/tsup.config.ts +11 -0
  145. package/dist/chunk-2VPPTJS2.js.map +0 -1
  146. package/dist/chunk-5XI443YP.js.map +0 -1
  147. package/dist/chunk-7HROSZRS.cjs.map +0 -1
  148. package/dist/chunk-7UJPVCMB.cjs.map +0 -1
  149. package/dist/chunk-A3AEEGKR.js.map +0 -1
  150. package/dist/chunk-C33AQZEC.js.map +0 -1
  151. package/dist/chunk-CEZGL6YP.js.map +0 -1
  152. package/dist/chunk-COOC2TVQ.js +0 -167
  153. package/dist/chunk-COOC2TVQ.js.map +0 -1
  154. package/dist/chunk-EJHLLXBV.js +0 -362
  155. package/dist/chunk-EJHLLXBV.js.map +0 -1
  156. package/dist/chunk-FWMJ2FR2.js +0 -121
  157. package/dist/chunk-FWMJ2FR2.js.map +0 -1
  158. package/dist/chunk-GRYNIPWH.cjs +0 -385
  159. package/dist/chunk-GRYNIPWH.cjs.map +0 -1
  160. package/dist/chunk-H34CJSR6.js.map +0 -1
  161. package/dist/chunk-HIWNB5PK.cjs.map +0 -1
  162. package/dist/chunk-IZWC33YN.cjs +0 -357
  163. package/dist/chunk-IZWC33YN.cjs.map +0 -1
  164. package/dist/chunk-KOF32DBL.cjs +0 -1058
  165. package/dist/chunk-KOF32DBL.cjs.map +0 -1
  166. package/dist/chunk-LHWRZMF7.cjs +0 -362
  167. package/dist/chunk-LHWRZMF7.cjs.map +0 -1
  168. package/dist/chunk-MFRS2PEY.cjs +0 -121
  169. package/dist/chunk-MFRS2PEY.cjs.map +0 -1
  170. package/dist/chunk-MMDLXS6O.js +0 -75
  171. package/dist/chunk-MMDLXS6O.js.map +0 -1
  172. package/dist/chunk-NW3RUYK2.cjs.map +0 -1
  173. package/dist/chunk-ODF5O5PV.cjs.map +0 -1
  174. package/dist/chunk-OTZT3MC2.cjs.map +0 -1
  175. package/dist/chunk-SBRMWDWM.js +0 -357
  176. package/dist/chunk-SBRMWDWM.js.map +0 -1
  177. package/dist/chunk-SRXJLAKG.cjs.map +0 -1
  178. package/dist/chunk-T4J6TI55.js.map +0 -1
  179. package/dist/chunk-TVV7ZI7C.cjs.map +0 -1
  180. package/dist/chunk-XVMXWV3C.cjs +0 -167
  181. package/dist/chunk-XVMXWV3C.cjs.map +0 -1
  182. package/dist/chunk-YYQ4IK5V.cjs.map +0 -1
  183. package/dist/chunk-ZDNCF642.js +0 -1058
  184. package/dist/chunk-ZDNCF642.js.map +0 -1
  185. package/dist/chunk-ZWBUEHKF.js +0 -385
  186. package/dist/chunk-ZWBUEHKF.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/charts/bar-chart/bar-chart.tsx","../src/charts/bar-chart/bar-chart.module.scss","../src/charts/bar-chart/private/use-bar-chart-options.ts","../src/charts/bar-chart/private/truncated-tick-component.tsx"],"sourcesContent":["import { formatNumber } from '@automattic/number-formatters';\nimport { PatternLines, PatternCircles, PatternWaves, PatternHexagons } from '@visx/pattern';\nimport { Axis, BarSeries, BarGroup, Grid, XYChart } from '@visx/xychart';\nimport { __ } from '@wordpress/i18n';\nimport { Stack } from '@wordpress/ui';\nimport clsx from 'clsx';\nimport { useCallback, useContext, useState, useRef, useMemo } from 'react';\nimport { Legend, useChartLegendItems } from '../../components/legend';\nimport { AccessibleTooltip, useKeyboardNavigation } from '../../components/tooltip';\nimport { useXYChartTheme, useChartDataTransform, useZeroValueDisplay, useChartMargin, useElementHeight, useHasLegendChild, usePrefersReducedMotion } from '../../hooks';\nimport { GlobalChartsProvider, useChartId, useChartRegistration, useGlobalChartsContext, useGlobalChartsTheme, GlobalChartsContext } from '../../providers';\nimport { attachSubComponents } from '../../utils';\nimport { SingleChartContext } from '../private/single-chart-context';\nimport { withResponsive } from '../private/with-responsive';\nimport styles from './bar-chart.module.scss';\nimport { useBarChartOptions } from './private';\n\n// Base props type with optional responsive properties\n\n// Composition API types\nimport { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\n// Validation function similar to LineChart\nconst validateData = data => {\n if (!data?.length) return 'No data available';\n const hasInvalidData = data.some(series => series.data.some(point => isNaN(point.value) || point.value === null || point.value === undefined || !point.label && (!('date' in point && point.date) || isNaN(point.date.getTime()))));\n if (hasInvalidData) return 'Invalid data';\n return null;\n};\nconst getPatternId = (chartId, index) => `bar-pattern-${chartId}-${index}`;\nconst BarChartInternal = ({\n data,\n chartId: providedChartId,\n width,\n height,\n className,\n margin,\n withTooltips = false,\n showLegend = false,\n legendOrientation = 'horizontal',\n legendPosition = 'bottom',\n legendAlignment = 'center',\n legendMaxWidth,\n legendTextOverflow = 'wrap',\n legendItemClassName,\n legendShape = 'rect',\n gridVisibility: gridVisibilityProp,\n renderTooltip,\n options = {},\n orientation = 'vertical',\n withPatterns = false,\n showZeroValues = false,\n legendInteractive = false,\n animation,\n children,\n gap = 'md'\n}) => {\n const horizontal = orientation === 'horizontal';\n const chartId = useChartId(providedChartId);\n const theme = useXYChartTheme(data);\n const dataSorted = useChartDataTransform(data);\n\n // Transform data to add a small value for zero bars to make them visible\n const dataWithVisibleZeros = useZeroValueDisplay(dataSorted, {\n enabled: showZeroValues\n });\n\n // Create legend items using the reusable hook\n const legendItems = useChartLegendItems(dataSorted);\n const chartOptions = useBarChartOptions(dataWithVisibleZeros, horizontal, options);\n const defaultMargin = useChartMargin(height, chartOptions, dataSorted, theme, horizontal);\n const [svgWrapperRef, svgWrapperHeight] = useElementHeight();\n const chartRef = useRef(null);\n\n // Check if children contain a Legend component (composition pattern)\n const hasLegendChild = useHasLegendChild(children);\n\n // Use the measured SVG wrapper height, falling back to the passed height if provided.\n // When there's a legend (via prop or composition), we must wait for measurement because\n // the legend takes space and the svg-wrapper height will be less than the total height.\n const chartHeight = svgWrapperHeight > 0 ? svgWrapperHeight : height;\n const hasLegend = showLegend || hasLegendChild;\n const isWaitingForMeasurement = hasLegend ? svgWrapperHeight === 0 : !chartHeight;\n const [selectedIndex, setSelectedIndex] = useState(undefined);\n const [isNavigating, setIsNavigating] = useState(false);\n const totalPoints = Math.max(0, ...data.map(series => series.data?.length || 0)) * data.length;\n\n // Use the keyboard navigation hook\n const {\n tooltipRef,\n onChartFocus,\n onChartBlur,\n onChartKeyDown\n } = useKeyboardNavigation({\n selectedIndex,\n setSelectedIndex,\n isNavigating,\n setIsNavigating,\n chartRef,\n totalPoints\n });\n const {\n getElementStyles,\n isSeriesVisible\n } = useGlobalChartsContext();\n const providerTheme = useGlobalChartsTheme();\n\n // Add visibility information to series when using interactive legends\n const seriesWithVisibility = useMemo(() => {\n if (!chartId || !legendInteractive) {\n return dataWithVisibleZeros.map((series, index) => ({\n series,\n index,\n isVisible: true\n }));\n }\n return dataWithVisibleZeros.map((series, index) => ({\n series,\n index,\n isVisible: isSeriesVisible(chartId, series.label)\n }));\n }, [dataWithVisibleZeros, chartId, isSeriesVisible, legendInteractive]);\n\n // Check if all series are hidden\n const allSeriesHidden = useMemo(() => {\n return seriesWithVisibility.every(({\n isVisible\n }) => !isVisible);\n }, [seriesWithVisibility]);\n const getBarBackground = useCallback(index => () => withPatterns ? `url(#${getPatternId(chartId, index)})` : getElementStyles({\n data: dataSorted[index],\n index\n }).color, [withPatterns, getElementStyles, dataSorted, chartId]);\n const renderDefaultTooltip = useCallback(({\n tooltipData\n }) => {\n const nearestDatum = tooltipData?.nearestDatum?.datum;\n if (!nearestDatum) return null;\n return /*#__PURE__*/_jsxs(\"div\", {\n className: styles['bar-chart__tooltip'],\n children: [/*#__PURE__*/_jsx(\"div\", {\n className: styles['bar-chart__tooltip-header'],\n children: tooltipData?.nearestDatum?.key\n }), /*#__PURE__*/_jsxs(\"div\", {\n className: styles['bar-chart__tooltip-row'],\n children: [/*#__PURE__*/_jsxs(\"span\", {\n className: styles['bar-chart__tooltip-label'],\n children: [chartOptions.tooltip.labelFormatter(nearestDatum.label || (nearestDatum.date ? nearestDatum.date.getTime() : 0), 0, []), \":\"]\n }), /*#__PURE__*/_jsx(\"span\", {\n className: styles['bar-chart__tooltip-value'],\n children: formatNumber(nearestDatum.value)\n })]\n })]\n });\n }, [chartOptions.tooltip]);\n const renderPattern = useCallback((index, color) => {\n const patternType = index % 4;\n const id = getPatternId(chartId, index);\n const commonProps = {\n id,\n stroke: 'white',\n strokeWidth: 1,\n background: color\n };\n switch (patternType) {\n case 0:\n default:\n return /*#__PURE__*/_jsx(PatternLines, {\n ...commonProps,\n width: 5,\n height: 5,\n orientation: ['diagonal']\n }, id);\n case 1:\n return /*#__PURE__*/_jsx(PatternCircles, {\n ...commonProps,\n width: 6,\n height: 6,\n fill: \"white\"\n }, id);\n case 2:\n return /*#__PURE__*/_jsx(PatternWaves, {\n ...commonProps,\n width: 4,\n height: 4\n }, id);\n case 3:\n return /*#__PURE__*/_jsx(PatternHexagons, {\n ...commonProps,\n size: 8,\n height: 3\n }, id);\n }\n }, [chartId]);\n const createPatternBorderStyle = useCallback((index, color) => {\n const patternId = getPatternId(chartId, index);\n return `\n\t\t\t.visx-bar[fill=\"url(#${patternId})\"] {\n\t\t\t\tstroke: ${color};\n\t\t\t\tstroke-width: 1;\n\t\t\t\t}\n\t\t\t`;\n }, [chartId]);\n const createKeyboardHighlightStyle = useCallback(() => {\n if (selectedIndex === undefined) return '';\n\n // Calculate which bar should be highlighted based on selectedIndex\n // Pattern: [series1[0], series2[0], series3[0], series1[1], series2[1], series3[1], ...]\n const maxDataPoints = Math.max(...data.map(s => s.data.length));\n const dataPointIndex = Math.floor(selectedIndex / data.length);\n const seriesIndex = selectedIndex % data.length;\n\n // Only highlight if we're within valid bounds\n if (dataPointIndex >= maxDataPoints || seriesIndex >= data.length) {\n return '';\n }\n const seriesData = data[seriesIndex];\n if (dataPointIndex >= seriesData.data.length) {\n return '';\n }\n\n // Based on the DOM structure analysis:\n // - All bars are in a single .visx-bar-group\n // - Bars are ordered as: [series1[0], series1[1], series2[0], series2[1], ...]\n // - So we need to calculate the actual bar index in the DOM\n const actualBarIndex = seriesIndex * maxDataPoints + dataPointIndex;\n\n // Use a CSS class selector instead of ID since useId() generates invalid CSS ID characters\n const generatedStyles = `\n\t\t\t.bar-chart[data-chart-id=\"bar-chart-${chartId}\"] .visx-bar-group .visx-bar:nth-child(${actualBarIndex + 1}) {\n\t\t\t\tstroke: #005fcc;\n\t\t\t\tstroke-width: 2px;\n\t\t\t}\n\t\t`;\n return generatedStyles;\n }, [selectedIndex, data, chartId]);\n\n // Validate data first\n const error = validateData(dataSorted);\n const isDataValid = !error;\n\n // Memoize metadata to prevent unnecessary re-registration\n const chartMetadata = useMemo(() => ({\n orientation,\n withPatterns\n }), [orientation, withPatterns]);\n\n // Register chart with context only if data is valid\n useChartRegistration({\n chartId,\n legendItems,\n chartType: 'bar',\n isDataValid,\n metadata: chartMetadata\n });\n const prefersReducedMotion = usePrefersReducedMotion();\n if (error) {\n return /*#__PURE__*/_jsx(\"div\", {\n className: clsx('bar-chart', styles['bar-chart']),\n children: error\n });\n }\n const gridVisibility = gridVisibilityProp ?? chartOptions.gridVisibility;\n const highlightedBarStyle = createKeyboardHighlightStyle();\n const legendElement = showLegend && /*#__PURE__*/_jsx(Legend, {\n orientation: legendOrientation,\n position: legendPosition,\n alignment: legendAlignment,\n maxWidth: legendMaxWidth,\n textOverflow: legendTextOverflow,\n legendItemClassName: legendItemClassName,\n className: styles['bar-chart__legend'],\n shape: legendShape,\n chartId: chartId,\n interactive: legendInteractive\n });\n return /*#__PURE__*/_jsx(SingleChartContext.Provider, {\n value: {\n chartId,\n chartWidth: width,\n chartHeight\n },\n children: /*#__PURE__*/_jsxs(Stack, {\n direction: \"column\",\n gap: gap,\n className: clsx('bar-chart', styles['bar-chart'], {\n [styles[`bar-chart--animated${horizontal ? '-horizontal' : ''}`]]: animation && !prefersReducedMotion\n }, className),\n style: {\n width,\n height,\n visibility: isWaitingForMeasurement ? 'hidden' : 'visible'\n },\n \"data-chart-id\": `bar-chart-${chartId}`,\n children: [legendPosition === 'top' && legendElement, /*#__PURE__*/_jsx(\"div\", {\n className: styles['bar-chart__svg-wrapper'],\n ref: svgWrapperRef,\n role: \"grid\",\n \"aria-label\": __('Bar chart', 'jetpack-charts'),\n tabIndex: 0,\n onKeyDown: onChartKeyDown,\n onFocus: onChartFocus,\n onBlur: onChartBlur,\n children: !isWaitingForMeasurement && /*#__PURE__*/_jsx(\"div\", {\n ref: chartRef,\n children: /*#__PURE__*/_jsxs(XYChart, {\n theme: theme,\n width: width,\n height: chartHeight,\n margin: {\n ...defaultMargin,\n ...margin\n },\n xScale: chartOptions.xScale,\n yScale: chartOptions.yScale,\n horizontal: horizontal,\n pointerEventsDataKey: \"nearest\",\n children: [/*#__PURE__*/_jsx(Grid, {\n columns: gridVisibility.includes('y'),\n rows: gridVisibility.includes('x'),\n numTicks: 4\n }), withPatterns && /*#__PURE__*/_jsxs(_Fragment, {\n children: [/*#__PURE__*/_jsx(\"defs\", {\n children: dataSorted.map((seriesData, index) => renderPattern(index, getElementStyles({\n data: seriesData,\n index\n }).color))\n }), /*#__PURE__*/_jsx(\"style\", {\n children: dataSorted.map((seriesData, index) => createPatternBorderStyle(index, getElementStyles({\n data: seriesData,\n index\n }).color))\n })]\n }), highlightedBarStyle && /*#__PURE__*/_jsx(\"style\", {\n children: highlightedBarStyle\n }), allSeriesHidden ? /*#__PURE__*/_jsx(\"text\", {\n x: width / 2,\n y: chartHeight / 2,\n textAnchor: \"middle\",\n fill: providerTheme.gridStyles?.stroke || '#ccc',\n fontSize: \"14\",\n fontFamily: \"-apple-system,BlinkMacSystemFont,Roboto,Helvetica Neue,sans-serif\",\n children: __('All series are hidden. Click legend items to show data.', 'jetpack-charts')\n }) : null, /*#__PURE__*/_jsx(BarGroup, {\n padding: chartOptions.barGroup.padding,\n children: seriesWithVisibility.map(({\n series: seriesData,\n index,\n isVisible\n }) => {\n // Skip rendering invisible series\n if (!isVisible) {\n return null;\n }\n return /*#__PURE__*/_jsx(BarSeries, {\n dataKey: seriesData?.label,\n data: seriesData.data,\n yAccessor: chartOptions.accessors.yAccessor,\n xAccessor: chartOptions.accessors.xAccessor,\n colorAccessor: getBarBackground(index)\n }, seriesData?.label);\n })\n }), /*#__PURE__*/_jsx(Axis, {\n ...chartOptions.axis.x\n }), /*#__PURE__*/_jsx(Axis, {\n ...chartOptions.axis.y\n }), withTooltips && /*#__PURE__*/_jsx(AccessibleTooltip, {\n detectBounds: true,\n snapTooltipToDatumX: true,\n snapTooltipToDatumY: true,\n renderTooltip: renderTooltip || renderDefaultTooltip,\n selectedIndex: selectedIndex,\n tooltipRef: tooltipRef,\n keyboardFocusedClassName: styles['bar-chart__tooltip--keyboard-focused'],\n series: data,\n mode: \"individual\"\n })]\n })\n })\n }), legendPosition === 'bottom' && legendElement, children]\n })\n });\n};\nconst BarChartWithProvider = props => {\n const existingContext = useContext(GlobalChartsContext);\n\n // If we're already in a GlobalChartsProvider context, don't create a new one\n if (existingContext) {\n return /*#__PURE__*/_jsx(BarChartInternal, {\n ...props\n });\n }\n\n // Otherwise, create our own GlobalChartsProvider\n return /*#__PURE__*/_jsx(GlobalChartsProvider, {\n children: /*#__PURE__*/_jsx(BarChartInternal, {\n ...props\n })\n });\n};\nBarChartWithProvider.displayName = 'BarChart';\n\n// Create BarChart with composition API\nconst BarChart = attachSubComponents(BarChartWithProvider, {\n Legend: Legend\n});\n\n// Create responsive BarChart with composition API\nconst BarChartResponsive = attachSubComponents(withResponsive(BarChartWithProvider), {\n Legend: Legend\n});\nexport { BarChartResponsive as default, BarChart as BarChartUnresponsive };","import 'css-chunk:src/charts/bar-chart/bar-chart.module.scss';export default {\n \"bar-chart__svg-wrapper\": \"a8ccharts-9CsqC0\",\n \"bar-chart\": \"a8ccharts-3gflnB\",\n \"bar-chart--animated\": \"a8ccharts-98W-yu\",\n \"rise\": \"a8ccharts-z6AsiQ\",\n \"bar-chart--animated-horizontal\": \"a8ccharts-HFA3FF\",\n \"stretch\": \"a8ccharts-DQp37O\"\n};","import { formatNumberCompact } from '@automattic/number-formatters';\nimport { useMemo } from 'react';\nimport { TruncatedXTickComponent, TruncatedYTickComponent } from './truncated-tick-component';\nimport type { EnhancedDataPoint } from '../../../hooks/use-zero-value-display';\nimport type { DataPointDate, BaseChartProps, SeriesData } from '../../../types';\nimport type { TickFormatter } from '@visx/axis';\n\nconst formatDateTick = ( timestamp: number ) => {\n\tconst date = new Date( timestamp );\n\treturn date.toLocaleDateString( undefined, {\n\t\tmonth: 'short',\n\t\tday: 'numeric',\n\t} );\n};\n\n/**\n * Get the group padding of a scale.\n *\n * @param scale - The scale to get the group padding of.\n * @return The group padding of the scale.\n */\nconst getGroupPadding = ( scale: Record< string, unknown > ): number => {\n\treturn typeof scale.paddingInner === 'number' ? ( scale.paddingInner as number ) : 0;\n};\n\n/**\n * Returns the merged options for the bar chart, including axis and scale configuration based on the orientation.\n *\n * @param data - The data to be displayed in the chart.\n * @param horizontal - Whether the chart is horizontal or vertical.\n * @param options - The options for the chart.\n * @return The merged options for the chart.\n */\nexport function useBarChartOptions(\n\tdata: SeriesData[],\n\thorizontal: boolean,\n\toptions: BaseChartProps[ 'options' ] = {}\n) {\n\tconst defaultOptions = useMemo( () => {\n\t\tconst bandScale = {\n\t\t\ttype: 'band' as const,\n\t\t\tpadding: 0.2,\n\t\t\tpaddingInner: 0.1,\n\t\t};\n\t\tconst linearScale = {\n\t\t\ttype: 'linear' as const,\n\t\t\tnice: true,\n\t\t\tzero: false,\n\t\t};\n\n\t\tconst labelFormatter = data?.[ 0 ]?.data?.[ 0 ]?.label\n\t\t\t? ( label: string ) => label\n\t\t\t: formatDateTick;\n\t\tconst valueFormatter = formatNumberCompact as TickFormatter< unknown >;\n\n\t\tconst labelAccessor = ( d: DataPointDate ) => d?.label || d?.date;\n\t\tconst valueAccessor = ( d: DataPointDate | EnhancedDataPoint ) => {\n\t\t\t// Use visualValue for bar rendering if available (for zero values), otherwise use value\n\t\t\tconst enhancedPoint = d as EnhancedDataPoint;\n\t\t\treturn enhancedPoint?.visualValue !== undefined ? enhancedPoint.visualValue : d?.value;\n\t\t};\n\n\t\treturn {\n\t\t\tvertical: {\n\t\t\t\txTickFormat: labelFormatter,\n\t\t\t\tyTickFormat: valueFormatter,\n\t\t\t\ttooltipLabelFormatter: labelFormatter,\n\t\t\t\txAccessor: labelAccessor,\n\t\t\t\tyAccessor: valueAccessor,\n\t\t\t\tgridVisibility: 'x',\n\t\t\t\txScale: bandScale,\n\t\t\t\tyScale: linearScale,\n\t\t\t},\n\t\t\thorizontal: {\n\t\t\t\txTickFormat: valueFormatter,\n\t\t\t\tyTickFormat: labelFormatter,\n\t\t\t\ttooltipLabelFormatter: labelFormatter,\n\t\t\t\txAccessor: valueAccessor,\n\t\t\t\tyAccessor: labelAccessor,\n\t\t\t\tgridVisibility: 'y',\n\t\t\t\txScale: linearScale,\n\t\t\t\tyScale: bandScale,\n\t\t\t},\n\t\t};\n\t}, [ data ] );\n\n\treturn useMemo( () => {\n\t\tconst orientationKey = horizontal ? 'horizontal' : 'vertical';\n\t\tconst {\n\t\t\txTickFormat,\n\t\t\tyTickFormat,\n\t\t\ttooltipLabelFormatter: defaultTooltipLabelFormatter,\n\t\t\txAccessor,\n\t\t\tyAccessor,\n\t\t\tgridVisibility,\n\t\t\txScale: baseXScale,\n\t\t\tyScale: baseYScale,\n\t\t} = defaultOptions[ orientationKey ];\n\n\t\tconst xScale = { ...baseXScale, ...( options.xScale || {} ) };\n\t\tconst yScale = { ...baseYScale, ...( options.yScale || {} ) };\n\t\tconst providedToolTipLabelFormatter = horizontal\n\t\t\t? options.axis?.y?.tickFormat\n\t\t\t: options.axis?.x?.tickFormat;\n\n\t\tconst { labelOverflow: xLabelOverflow, ...xAxisOptions } = options.axis?.x || {};\n\t\tconst { labelOverflow: yLabelOverflow, ...yAxisOptions } = options.axis?.y || {};\n\n\t\treturn {\n\t\t\tgridVisibility,\n\t\t\txScale,\n\t\t\tyScale,\n\t\t\taccessors: {\n\t\t\t\txAccessor,\n\t\t\t\tyAccessor,\n\t\t\t},\n\t\t\taxis: {\n\t\t\t\tx: {\n\t\t\t\t\torientation: 'bottom' as const,\n\t\t\t\t\tnumTicks: 4,\n\t\t\t\t\ttickFormat: xTickFormat,\n\t\t\t\t\t...( xLabelOverflow === 'ellipsis' ? { tickComponent: TruncatedXTickComponent } : {} ),\n\t\t\t\t\t...xAxisOptions,\n\t\t\t\t},\n\t\t\t\ty: {\n\t\t\t\t\torientation: 'left' as const,\n\t\t\t\t\tnumTicks: 4,\n\t\t\t\t\ttickFormat: yTickFormat,\n\t\t\t\t\t...( yLabelOverflow === 'ellipsis' ? { tickComponent: TruncatedYTickComponent } : {} ),\n\t\t\t\t\t...yAxisOptions,\n\t\t\t\t},\n\t\t\t},\n\t\t\tbarGroup: {\n\t\t\t\tpadding: getGroupPadding( horizontal ? yScale : xScale ),\n\t\t\t},\n\t\t\ttooltip: {\n\t\t\t\tlabelFormatter: providedToolTipLabelFormatter || defaultTooltipLabelFormatter,\n\t\t\t},\n\t\t};\n\t}, [ defaultOptions, options, horizontal ] );\n}\n","import { DataContext } from '@visx/xychart';\nimport { useContext } from 'react';\nimport { isSafari } from '../../../utils';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\n/**\n * Get the bandwidth of a scale\n *\n * @param scale - The scale to get the bandwidth of\n * @return The bandwidth of the scale\n */\nconst getScaleBandwidth = scale => {\n return scale && 'bandwidth' in scale ? scale.bandwidth() ?? 0 : 0;\n};\n/**\n * Minimum width in pixels for tick labels when scale bandwidth is very small.\n * Prevents labels from collapsing to unreadable widths on dense charts.\n *\n * Trade-off: When bandwidth is less than this minimum (e.g., many bars in a narrow chart),\n * adjacent labels may overlap since each label uses this minimum width regardless of\n * available space. This prioritizes label readability over preventing overlap.\n *\n * For very dense charts where overlap occurs, consider:\n * - Using `numTicks` option to reduce the number of displayed labels\n * - Using `tickFormat` to abbreviate label text\n * - Increasing chart width or reducing data points\n */\nconst MIN_TICK_LABEL_WIDTH = 20;\n\n/**\n * A tick component that renders labels with text truncation (ellipsis) when they exceed\n * the available bandwidth. Shows the full text on hover via native title attribute.\n *\n * Uses foreignObject to embed HTML within SVG, enabling CSS text-overflow: ellipsis.\n * Inherits text styles from tickLabelProps passed by visx Axis component.\n *\n * Note: A minimum label width (MIN_TICK_LABEL_WIDTH) is enforced to keep labels readable.\n * On very dense charts where bandwidth < 20px, this may cause label overlap.\n * See MIN_TICK_LABEL_WIDTH documentation for mitigation strategies.\n *\n * @param props - The props for the truncated tick component\n * @param props.x - The x position of the tick\n * @param props.y - The y position of the tick\n * @param props.formattedValue - The formatted value of the tick\n * @param props.axis - The axis this tick belongs to\n * @param props.textAnchor - The text anchor of the tick\n * @param props.fill - The fill color of the tick\n * @param props.dy - The dy offset of the tick\n *\n * @return The truncated tick component\n */\nexport const TruncatedTickComponent = ({\n x,\n y,\n formattedValue,\n axis,\n textAnchor,\n fill,\n dy,\n ...textProps\n}) => {\n // Get max width of the tick label\n const {\n xScale,\n yScale\n } = useContext(DataContext) || {};\n const scale = axis === 'x' ? xScale : yScale;\n const bandwidth = getScaleBandwidth(scale);\n const maxWidth = Math.max(bandwidth, MIN_TICK_LABEL_WIDTH);\n\n // Map SVG textAnchor to CSS textAlign\n let textAlign = 'center';\n if (textAnchor === 'start') {\n textAlign = 'left';\n } else if (textAnchor === 'end') {\n textAlign = 'right';\n } else if (textAnchor === 'middle') {\n textAlign = 'center';\n }\n\n // Calculate x offset based on text alignment\n let xOffset = 0;\n if (textAlign === 'center') {\n xOffset = -maxWidth / 2;\n } else if (textAlign === 'right') {\n xOffset = -maxWidth;\n }\n\n // Extract compatible style properties from SVG text props\n const {\n fontSize,\n fontFamily,\n fontWeight,\n fontStyle,\n letterSpacing,\n opacity\n } = textProps;\n const textStyles = {\n /**\n * SVG <text> elements are vertically aligned to the baseline by default, but HTML <div> elements inside <foreignObject>\n * are positioned relative to the top-left corner. To visually align the tick label like SVG text,\n * we shift the div up by 100% of its height and adjust by twice the SVG dy value (from visx) to approximate original placement.\n */\n transform: `translateY(calc(-100% + ${dy ?? '0'} * 2))`,\n // Safari doesn't work well with foreignObject positioning. Use position: fixed as a workaround.\n ...(isSafari() ? {\n position: 'fixed'\n } : {}),\n // Apply compatible SVG text styles\n fontSize,\n fontFamily,\n fontWeight,\n fontStyle,\n letterSpacing,\n opacity,\n // Convert svg text styles to CSS styles for the div\n color: fill ?? 'inherit',\n textAlign,\n // Ensure text is truncated with ellipsis, remains on one line, and shows the full value in a tooltip on hover.\n // The surrounding div uses CSS to handle overflow, and the 'title' attribute is set for accessibility.\n width: maxWidth,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n cursor: 'default',\n pointerEvents: 'auto'\n };\n return /*#__PURE__*/_jsx(\"foreignObject\", {\n x: x + xOffset,\n y: y,\n width: maxWidth,\n height: 0,\n overflow: \"visible\",\n children: /*#__PURE__*/_jsx(\"div\", {\n style: textStyles,\n title: formattedValue,\n children: formattedValue\n })\n });\n};\n\n/**\n * Factory function to create a truncated tick component for a specific axis.\n * Returns a component that can be passed to visx's tickComponent prop.\n *\n * @param axis - The axis this tick component is for ('x' or 'y')\n * @return A tick component function compatible with visx's TickRendererProps\n */\nconst createTruncatedTickComponent = axis => props => {\n return /*#__PURE__*/_jsx(TruncatedTickComponent, {\n ...props,\n axis: axis\n });\n};\n\n/**\n * Pre-created tick components for x and y axes.\n * These functions are created once at module initialization and reused,\n * avoiding repeated factory calls when configuring axes.\n */\nexport const TruncatedXTickComponent = createTruncatedTickComponent('x');\nexport const TruncatedYTickComponent = createTruncatedTickComponent('y');"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,oBAAoB;AAC7B,SAAS,cAAc,gBAAgB,cAAc,uBAAuB;AAC5E,SAAS,MAAM,WAAW,UAAU,MAAM,eAAe;AACzD,SAAS,UAAU;AAEnB,OAAO,UAAU;AACjB,SAAS,aAAa,cAAAA,aAAY,UAAU,QAAQ,WAAAC,gBAAe;;;ACNL,IAAO,2BAAQ;AAAA,EAC3E,0BAA0B;AAAA,EAC1B,aAAa;AAAA,EACb,uBAAuB;AAAA,EACvB,QAAQ;AAAA,EACR,kCAAkC;AAAA,EAClC,WAAW;AACb;;;ACPA,SAAS,2BAA2B;AACpC,SAAS,eAAe;;;ACDxB,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAE3B,SAAS,OAAO,YAAY;AAO5B,IAAM,oBAAoB,WAAS;AACjC,SAAO,SAAS,eAAe,QAAQ,MAAM,UAAU,KAAK,IAAI;AAClE;AAcA,IAAM,uBAAuB;AAwBtB,IAAM,yBAAyB,CAAC;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AAEJ,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,EACF,IAAI,WAAW,WAAW,KAAK,CAAC;AAChC,QAAM,QAAQ,SAAS,MAAM,SAAS;AACtC,QAAM,YAAY,kBAAkB,KAAK;AACzC,QAAM,WAAW,KAAK,IAAI,WAAW,oBAAoB;AAGzD,MAAI,YAAY;AAChB,MAAI,eAAe,SAAS;AAC1B,gBAAY;AAAA,EACd,WAAW,eAAe,OAAO;AAC/B,gBAAY;AAAA,EACd,WAAW,eAAe,UAAU;AAClC,gBAAY;AAAA,EACd;AAGA,MAAI,U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,CAAC;AACH;AACA,qBAAqB,cAAc;AAGnC,IAAM,WAAW,oBAAoB,sBAAsB;AAAA,EACzD;AACF,CAAC;AAGD,IAAM,qBAAqB,oBAAoB,eAAe,oBAAoB,GAAG;AAAA,EACnF;AACF,CAAC;","names":["useContext","useMemo","_jsx","useMemo","useContext"]}
@@ -0,0 +1,375 @@
1
+ import {
2
+ getStringWidth
3
+ } from "./chunk-NFRB2POF.js";
4
+ import {
5
+ radial_wipe_animation_default
6
+ } from "./chunk-KXRWNFQJ.js";
7
+ import {
8
+ ChartHTML,
9
+ ChartSVG,
10
+ useChartChildren
11
+ } from "./chunk-6CCZL2JJ.js";
12
+ import {
13
+ BaseTooltip
14
+ } from "./chunk-BPYKWMI7.js";
15
+ import {
16
+ withResponsive
17
+ } from "./chunk-TYIH5LMV.js";
18
+ import {
19
+ GlobalChartsContext,
20
+ GlobalChartsProvider,
21
+ Legend,
22
+ SingleChartContext,
23
+ useChartId,
24
+ useChartLegendItems,
25
+ useChartRegistration,
26
+ useElementHeight,
27
+ useGlobalChartsContext,
28
+ useGlobalChartsTheme,
29
+ useInteractiveLegendData,
30
+ usePrefersReducedMotion
31
+ } from "./chunk-32ESS4MV.js";
32
+ import {
33
+ attachSubComponents
34
+ } from "./chunk-TE63Y5PX.js";
35
+
36
+ // src/charts/pie-chart/pie-chart.tsx
37
+ import { Group } from "@visx/group";
38
+ import { Pie } from "@visx/shape";
39
+ import { useTooltip, useTooltipInPortal } from "@visx/tooltip";
40
+ import { __ } from "@wordpress/i18n";
41
+ import clsx from "clsx";
42
+ import { useCallback, useContext, useMemo } from "react";
43
+
44
+ // src/charts/pie-chart/pie-chart.module.scss
45
+ var pie_chart_module_default = {
46
+ "pie-chart": "a8ccharts-C-n-Gu",
47
+ "pie-chart--legend-top": "a8ccharts-Mu0uxl"
48
+ };
49
+
50
+ // src/charts/pie-chart/pie-chart.tsx
51
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
52
+ var renderDefaultPieTooltip = ({
53
+ tooltipData
54
+ }) => {
55
+ return /* @__PURE__ */ _jsx(BaseTooltip, {
56
+ data: tooltipData,
57
+ top: 0,
58
+ left: 0,
59
+ renderContainer: false
60
+ });
61
+ };
62
+ var validateData = (data) => {
63
+ if (!data.length) {
64
+ return {
65
+ isValid: false,
66
+ message: "No data available"
67
+ };
68
+ }
69
+ const hasNegativeValues = data.some((item) => item.percentage < 0 || item.value < 0);
70
+ if (hasNegativeValues) {
71
+ return {
72
+ isValid: false,
73
+ message: "Invalid data: Negative values are not allowed"
74
+ };
75
+ }
76
+ const totalPercentage = data.reduce((sum, item) => sum + item.percentage, 0);
77
+ if (Math.abs(totalPercentage - 100) > 0.01) {
78
+ return {
79
+ isValid: false,
80
+ message: "Invalid percentage total: Must equal 100"
81
+ };
82
+ }
83
+ return {
84
+ isValid: true,
85
+ message: ""
86
+ };
87
+ };
88
+ var PieChartInternal = ({
89
+ data,
90
+ chartId: providedChartId,
91
+ withTooltips = false,
92
+ className,
93
+ showLegend = false,
94
+ legendOrientation = "horizontal",
95
+ legendPosition = "bottom",
96
+ legendAlignment = "center",
97
+ legendMaxWidth,
98
+ legendTextOverflow = "wrap",
99
+ legendItemClassName,
100
+ legendShape = "circle",
101
+ size,
102
+ animation,
103
+ thickness = 1,
104
+ padding = 0,
105
+ gapScale = 0,
106
+ cornerScale = 0,
107
+ showLabels = true,
108
+ legendValueDisplay = "percentage",
109
+ legendInteractive = false,
110
+ children = null,
111
+ tooltipOffsetX = 0,
112
+ tooltipOffsetY = -15,
113
+ renderTooltip = renderDefaultPieTooltip
114
+ }) => {
115
+ const providerTheme = useGlobalChartsTheme();
116
+ const chartId = useChartId(providedChartId);
117
+ const [legendRef, legendHeight] = useElementHeight();
118
+ const {
119
+ tooltipOpen,
120
+ tooltipLeft,
121
+ tooltipTop,
122
+ tooltipData,
123
+ hideTooltip,
124
+ showTooltip
125
+ } = useTooltip();
126
+ const {
127
+ containerRef,
128
+ TooltipInPortal,
129
+ containerBounds
130
+ } = useTooltipInPortal({
131
+ detectBounds: true,
132
+ scroll: true,
133
+ debounce: 0
134
+ });
135
+ const onMouseLeave = useCallback(() => {
136
+ if (!withTooltips) {
137
+ return;
138
+ }
139
+ hideTooltip();
140
+ }, [withTooltips, hideTooltip]);
141
+ const {
142
+ getElementStyles,
143
+ isSeriesVisible
144
+ } = useGlobalChartsContext();
145
+ const {
146
+ visibleData,
147
+ allSegmentsHidden,
148
+ legendData
149
+ } = useInteractiveLegendData({
150
+ data,
151
+ chartId,
152
+ legendInteractive,
153
+ isSeriesVisible
154
+ });
155
+ const legendOptions = useMemo(() => ({
156
+ showValues: true,
157
+ legendValueDisplay
158
+ }), [legendValueDisplay]);
159
+ const legendItems = useChartLegendItems(legendData, legendOptions);
160
+ const {
161
+ isValid,
162
+ message
163
+ } = validateData(data);
164
+ const {
165
+ svgChildren,
166
+ htmlChildren,
167
+ otherChildren
168
+ } = useChartChildren(children, "PieChart");
169
+ const chartMetadata = useMemo(() => ({
170
+ thickness,
171
+ gapScale,
172
+ cornerScale
173
+ }), [thickness, gapScale, cornerScale]);
174
+ useChartRegistration({
175
+ chartId,
176
+ legendItems,
177
+ chartType: "pie",
178
+ isDataValid: isValid,
179
+ metadata: chartMetadata
180
+ });
181
+ const prefersReducedMotion = usePrefersReducedMotion();
182
+ if (!isValid) {
183
+ return /* @__PURE__ */ _jsx("div", {
184
+ className: clsx("pie-chart", pie_chart_module_default["pie-chart"], className),
185
+ children: /* @__PURE__ */ _jsx("div", {
186
+ className: pie_chart_module_default["error-message"],
187
+ children: message
188
+ })
189
+ });
190
+ }
191
+ const width = size;
192
+ const height = size;
193
+ const adjustedHeight = showLegend && legendPosition === "top" ? height - legendHeight : height;
194
+ const radius = Math.min(width, adjustedHeight) / 2;
195
+ const centerX = width / 2;
196
+ const centerY = adjustedHeight / 2;
197
+ const padAngle = gapScale * (2 * Math.PI / data.length);
198
+ const outerRadius = radius - padding;
199
+ const innerRadius = thickness === 0 ? 0 : outerRadius * (1 - thickness);
200
+ const maxCornerRadius = (outerRadius - innerRadius) / 2;
201
+ const cornerRadius = cornerScale ? Math.min(cornerScale * outerRadius, maxCornerRadius) : 0;
202
+ const dataWithIndex = visibleData.map((d) => {
203
+ const originalIndex = data.findIndex((item) => item.label === d.label);
204
+ return {
205
+ ...d,
206
+ index: originalIndex >= 0 ? originalIndex : 0
207
+ };
208
+ });
209
+ const accessors = {
210
+ value: (d) => d.value,
211
+ fill: (d) => {
212
+ return getElementStyles({
213
+ data: d,
214
+ index: d.index
215
+ }).color;
216
+ }
217
+ };
218
+ return /* @__PURE__ */ _jsx(SingleChartContext.Provider, {
219
+ value: {
220
+ chartId,
221
+ chartWidth: width,
222
+ chartHeight: adjustedHeight
223
+ },
224
+ children: /* @__PURE__ */ _jsxs("div", {
225
+ ref: containerRef,
226
+ className: clsx("pie-chart", pie_chart_module_default["pie-chart"], {
227
+ [pie_chart_module_default["pie-chart--legend-top"]]: showLegend && legendPosition === "top"
228
+ }, className),
229
+ children: [/* @__PURE__ */ _jsxs("svg", {
230
+ viewBox: `0 0 ${width} ${adjustedHeight}`,
231
+ preserveAspectRatio: "xMidYMid meet",
232
+ width,
233
+ height: adjustedHeight,
234
+ children: [/* @__PURE__ */ _jsx("defs", {
235
+ children: /* @__PURE__ */ _jsx(radial_wipe_animation_default, {
236
+ id: `radial-wipe-${chartId}`,
237
+ radius: outerRadius,
238
+ innerRadius
239
+ })
240
+ }), /* @__PURE__ */ _jsxs(Group, {
241
+ top: centerY,
242
+ left: centerX,
243
+ mask: animation && !prefersReducedMotion ? `url(#radial-wipe-${chartId})` : null,
244
+ children: [allSegmentsHidden ? /* @__PURE__ */ _jsx("text", {
245
+ textAnchor: "middle",
246
+ dy: ".33em",
247
+ fill: providerTheme.gridColor || "#ccc",
248
+ fontSize: "14",
249
+ fontFamily: "-apple-system,BlinkMacSystemFont,Roboto,Helvetica Neue,sans-serif",
250
+ children: __("All segments are hidden. Click legend items to show data.", "jetpack-charts")
251
+ }) : /* @__PURE__ */ _jsx(Pie, {
252
+ data: dataWithIndex,
253
+ pieValue: accessors.value,
254
+ outerRadius,
255
+ innerRadius,
256
+ padAngle,
257
+ cornerRadius,
258
+ children: (pie) => {
259
+ return pie.arcs.map((arc, index) => {
260
+ const [centroidX, centroidY] = pie.path.centroid(arc);
261
+ const hasSpaceForLabel = arc.endAngle - arc.startAngle >= 0.25;
262
+ const handleMouseMove = (event) => {
263
+ if (!withTooltips) {
264
+ return;
265
+ }
266
+ if (containerBounds.width === 0 || containerBounds.height === 0) {
267
+ return;
268
+ }
269
+ showTooltip({
270
+ tooltipData: arc.data,
271
+ tooltipLeft: event.clientX - containerBounds.left + tooltipOffsetX,
272
+ tooltipTop: event.clientY - containerBounds.top + tooltipOffsetY
273
+ });
274
+ };
275
+ const pathProps = {
276
+ d: pie.path(arc) || "",
277
+ fill: accessors.fill(arc.data)
278
+ };
279
+ const groupProps = {};
280
+ if (withTooltips) {
281
+ groupProps.onMouseMove = handleMouseMove;
282
+ groupProps.onMouseLeave = onMouseLeave;
283
+ }
284
+ const fontSize = 12;
285
+ const estimatedTextWidth = getStringWidth(arc.data.label, {
286
+ fontSize
287
+ });
288
+ const labelPadding = 6;
289
+ const backgroundWidth = estimatedTextWidth + labelPadding * 2;
290
+ const backgroundHeight = fontSize + labelPadding * 2;
291
+ return /* @__PURE__ */ _jsxs("g", {
292
+ ...groupProps,
293
+ children: [/* @__PURE__ */ _jsx("path", {
294
+ ...pathProps
295
+ }), showLabels && hasSpaceForLabel && /* @__PURE__ */ _jsxs("g", {
296
+ children: [providerTheme.labelBackgroundColor && /* @__PURE__ */ _jsx("rect", {
297
+ x: centroidX - backgroundWidth / 2,
298
+ y: centroidY - backgroundHeight / 2,
299
+ width: backgroundWidth,
300
+ height: backgroundHeight,
301
+ fill: providerTheme.labelBackgroundColor,
302
+ rx: 4,
303
+ ry: 4,
304
+ pointerEvents: "none"
305
+ }), /* @__PURE__ */ _jsx("text", {
306
+ x: centroidX,
307
+ y: centroidY,
308
+ dy: ".33em",
309
+ fill: providerTheme.labelTextColor || "#333",
310
+ fontSize,
311
+ textAnchor: "middle",
312
+ pointerEvents: "none",
313
+ children: arc.data.label
314
+ })]
315
+ })]
316
+ }, `arc-${index}`);
317
+ });
318
+ }
319
+ }), !allSegmentsHidden && svgChildren]
320
+ })]
321
+ }), showLegend && /* @__PURE__ */ _jsx(Legend, {
322
+ orientation: legendOrientation,
323
+ position: legendPosition,
324
+ alignment: legendAlignment,
325
+ maxWidth: legendMaxWidth,
326
+ textOverflow: legendTextOverflow,
327
+ legendItemClassName,
328
+ className: pie_chart_module_default["pie-chart-legend"],
329
+ shape: legendShape,
330
+ ref: legendRef,
331
+ chartId,
332
+ interactive: legendInteractive
333
+ }), withTooltips && tooltipOpen && tooltipData && /* @__PURE__ */ _jsx(TooltipInPortal, {
334
+ top: tooltipTop || 0,
335
+ left: tooltipLeft || 0,
336
+ children: /* @__PURE__ */ _jsx("div", {
337
+ role: "tooltip",
338
+ children: renderTooltip({
339
+ tooltipData
340
+ })
341
+ })
342
+ }), htmlChildren, otherChildren]
343
+ })
344
+ });
345
+ };
346
+ var PieChartWithProvider = (props) => {
347
+ const existingContext = useContext(GlobalChartsContext);
348
+ if (existingContext) {
349
+ return /* @__PURE__ */ _jsx(PieChartInternal, {
350
+ ...props
351
+ });
352
+ }
353
+ return /* @__PURE__ */ _jsx(GlobalChartsProvider, {
354
+ children: /* @__PURE__ */ _jsx(PieChartInternal, {
355
+ ...props
356
+ })
357
+ });
358
+ };
359
+ PieChartWithProvider.displayName = "PieChart";
360
+ var PieChart = attachSubComponents(PieChartWithProvider, {
361
+ Legend,
362
+ SVG: ChartSVG,
363
+ HTML: ChartHTML
364
+ });
365
+ var PieChartResponsive = attachSubComponents(withResponsive(PieChartWithProvider), {
366
+ Legend,
367
+ SVG: ChartSVG,
368
+ HTML: ChartHTML
369
+ });
370
+
371
+ export {
372
+ PieChart,
373
+ PieChartResponsive
374
+ };
375
+ //# sourceMappingURL=chunk-LT4YOIMM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/charts/pie-chart/pie-chart.tsx","../src/charts/pie-chart/pie-chart.module.scss"],"sourcesContent":["import { Group } from '@visx/group';\nimport { Pie } from '@visx/shape';\nimport { useTooltip, useTooltipInPortal } from '@visx/tooltip';\nimport { __ } from '@wordpress/i18n';\nimport clsx from 'clsx';\nimport { useCallback, useContext, useMemo } from 'react';\nimport { Legend, useChartLegendItems } from '../../components/legend';\nimport { BaseTooltip } from '../../components/tooltip';\nimport { useElementHeight, useInteractiveLegendData, usePrefersReducedMotion } from '../../hooks';\nimport { GlobalChartsProvider, useChartId, useChartRegistration, useGlobalChartsContext, useGlobalChartsTheme, GlobalChartsContext } from '../../providers';\nimport { attachSubComponents } from '../../utils';\nimport { getStringWidth } from '../../visx/text';\nimport { ChartSVG, ChartHTML, useChartChildren } from '../private/chart-composition';\nimport { RadialWipeAnimation } from '../private/radial-wipe-animation/';\nimport { SingleChartContext } from '../private/single-chart-context';\nimport { withResponsive } from '../private/with-responsive';\nimport styles from './pie-chart.module.scss';\n\n/**\n * Parameters passed to the renderTooltip function for pie charts.\n */\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\n/**\n * Default tooltip renderer for pie charts.\n * Renders a BaseTooltip with the hovered segment's data.\n *\n * @param {PieChartRenderTooltipParams} params - The tooltip parameters containing the hovered data point\n * @return {ReactNode} The rendered tooltip content\n */\nconst renderDefaultPieTooltip = ({\n tooltipData\n}) => {\n return /*#__PURE__*/_jsx(BaseTooltip, {\n data: tooltipData,\n top: 0,\n left: 0,\n renderContainer: false\n });\n};\n\n// Base props type with optional responsive properties\n\n// Composition API types\n\n/**\n * Validates the pie chart data\n * @param data - The data to validate\n * @return Object containing validation result and error message\n */\nconst validateData = data => {\n if (!data.length) {\n return {\n isValid: false,\n message: 'No data available'\n };\n }\n\n // Check for negative values\n const hasNegativeValues = data.some(item => item.percentage < 0 || item.value < 0);\n if (hasNegativeValues) {\n return {\n isValid: false,\n message: 'Invalid data: Negative values are not allowed'\n };\n }\n\n // Validate total percentage\n const totalPercentage = data.reduce((sum, item) => sum + item.percentage, 0);\n if (Math.abs(totalPercentage - 100) > 0.01) {\n // Using small epsilon for floating point comparison\n return {\n isValid: false,\n message: 'Invalid percentage total: Must equal 100'\n };\n }\n return {\n isValid: true,\n message: ''\n };\n};\n\n/**\n * Renders a pie or donut chart using the provided data.\n *\n * @param {PieChartProps} props - Component props\n * @return {JSX.Element} The rendered chart component\n */\nconst PieChartInternal = ({\n data,\n chartId: providedChartId,\n withTooltips = false,\n className,\n showLegend = false,\n legendOrientation = 'horizontal',\n legendPosition = 'bottom',\n legendAlignment = 'center',\n legendMaxWidth,\n legendTextOverflow = 'wrap',\n legendItemClassName,\n legendShape = 'circle',\n size,\n animation,\n thickness = 1,\n padding = 0,\n gapScale = 0,\n cornerScale = 0,\n showLabels = true,\n legendValueDisplay = 'percentage',\n legendInteractive = false,\n children = null,\n tooltipOffsetX = 0,\n tooltipOffsetY = -15,\n renderTooltip = renderDefaultPieTooltip\n}) => {\n const providerTheme = useGlobalChartsTheme();\n const chartId = useChartId(providedChartId);\n const [legendRef, legendHeight] = useElementHeight();\n const {\n tooltipOpen,\n tooltipLeft,\n tooltipTop,\n tooltipData,\n hideTooltip,\n showTooltip\n } = useTooltip();\n\n // Set up portal tooltip for better z-index handling\n // We get containerBounds to cancel out stale offsets in the position calculation\n const {\n containerRef,\n TooltipInPortal,\n containerBounds\n } = useTooltipInPortal({\n detectBounds: true,\n scroll: true,\n debounce: 0\n });\n const onMouseLeave = useCallback(() => {\n if (!withTooltips) {\n return;\n }\n hideTooltip();\n }, [withTooltips, hideTooltip]);\n const {\n getElementStyles,\n isSeriesVisible\n } = useGlobalChartsContext();\n\n // Filter and recalculate data for interactive legends\n const {\n visibleData,\n allSegmentsHidden,\n legendData\n } = useInteractiveLegendData({\n data,\n chartId,\n legendInteractive,\n isSeriesVisible\n });\n\n // Memoize legend options to prevent unnecessary re-calculations\n const legendOptions = useMemo(() => ({\n showValues: true,\n legendValueDisplay\n }), [legendValueDisplay]);\n\n // Create legend items using legendData (has recalculated percentages for visible items)\n const legendItems = useChartLegendItems(legendData, legendOptions);\n const {\n isValid,\n message\n } = validateData(data);\n\n // Process children to extract compound components\n const {\n svgChildren,\n htmlChildren,\n otherChildren\n } = useChartChildren(children, 'PieChart');\n\n // Memoize metadata to prevent unnecessary re-registration\n const chartMetadata = useMemo(() => ({\n thickness,\n gapScale,\n cornerScale\n }), [thickness, gapScale, cornerScale]);\n\n // Register chart with context only if data is valid\n useChartRegistration({\n chartId,\n legendItems,\n chartType: 'pie',\n isDataValid: isValid,\n metadata: chartMetadata\n });\n const prefersReducedMotion = usePrefersReducedMotion();\n if (!isValid) {\n return /*#__PURE__*/_jsx(\"div\", {\n className: clsx('pie-chart', styles['pie-chart'], className),\n children: /*#__PURE__*/_jsx(\"div\", {\n className: styles['error-message'],\n children: message\n })\n });\n }\n const width = size;\n const height = size;\n const adjustedHeight = showLegend && legendPosition === 'top' ? height - legendHeight : height;\n\n // Calculate radius based on width/height\n const radius = Math.min(width, adjustedHeight) / 2;\n\n // Center the chart in the available space\n const centerX = width / 2;\n const centerY = adjustedHeight / 2;\n\n // Calculate the angle between each (use original data length for consistent spacing)\n const padAngle = gapScale * (2 * Math.PI / data.length);\n const outerRadius = radius - padding;\n const innerRadius = thickness === 0 ? 0 : outerRadius * (1 - thickness);\n const maxCornerRadius = (outerRadius - innerRadius) / 2;\n const cornerRadius = cornerScale ? Math.min(cornerScale * outerRadius, maxCornerRadius) : 0;\n\n // Map the data to include index for color assignment\n // When interactive, we need to find the original index to maintain consistent colors\n const dataWithIndex = visibleData.map(d => {\n const originalIndex = data.findIndex(item => item.label === d.label);\n return {\n ...d,\n index: originalIndex >= 0 ? originalIndex : 0\n };\n });\n const accessors = {\n value: d => d.value,\n fill: d => {\n return getElementStyles({\n data: d,\n index: d.index\n }).color;\n }\n };\n return /*#__PURE__*/_jsx(SingleChartContext.Provider, {\n value: {\n chartId,\n chartWidth: width,\n chartHeight: adjustedHeight\n },\n children: /*#__PURE__*/_jsxs(\"div\", {\n ref: containerRef,\n className: clsx('pie-chart', styles['pie-chart'], {\n [styles['pie-chart--legend-top']]: showLegend && legendPosition === 'top'\n }, className),\n children: [/*#__PURE__*/_jsxs(\"svg\", {\n viewBox: `0 0 ${width} ${adjustedHeight}`,\n preserveAspectRatio: \"xMidYMid meet\",\n width: width,\n height: adjustedHeight,\n children: [/*#__PURE__*/_jsx(\"defs\", {\n children: /*#__PURE__*/_jsx(RadialWipeAnimation, {\n id: `radial-wipe-${chartId}`,\n radius: outerRadius,\n innerRadius: innerRadius\n })\n }), /*#__PURE__*/_jsxs(Group, {\n top: centerY,\n left: centerX,\n mask: animation && !prefersReducedMotion ? `url(#radial-wipe-${chartId})` : null,\n children: [allSegmentsHidden ? /*#__PURE__*/_jsx(\"text\", {\n textAnchor: \"middle\",\n dy: \".33em\",\n fill: providerTheme.gridColor || '#ccc',\n fontSize: \"14\",\n fontFamily: \"-apple-system,BlinkMacSystemFont,Roboto,Helvetica Neue,sans-serif\",\n children: __('All segments are hidden. Click legend items to show data.', 'jetpack-charts')\n }) : /*#__PURE__*/_jsx(Pie, {\n data: dataWithIndex,\n pieValue: accessors.value,\n outerRadius: outerRadius,\n innerRadius: innerRadius,\n padAngle: padAngle,\n cornerRadius: cornerRadius,\n children: pie => {\n return pie.arcs.map((arc, index) => {\n const [centroidX, centroidY] = pie.path.centroid(arc);\n const hasSpaceForLabel = arc.endAngle - arc.startAngle >= 0.25;\n const handleMouseMove = event => {\n if (!withTooltips) {\n return;\n }\n\n // Don't show tooltip until container bounds are measured\n if (containerBounds.width === 0 || containerBounds.height === 0) {\n return;\n }\n\n // Use clientX/Y and subtract containerBounds to cancel out any stale offset.\n // TooltipInPortal calculates: tooltipLeft + containerBounds.left + scrollX\n // By passing (clientX - containerBounds.left), we get:\n // (clientX - containerBounds.left) + containerBounds.left + scrollX = clientX + scrollX\n // This gives correct page coordinates regardless of stale bounds.\n showTooltip({\n tooltipData: arc.data,\n tooltipLeft: event.clientX - containerBounds.left + tooltipOffsetX,\n tooltipTop: event.clientY - containerBounds.top + tooltipOffsetY\n });\n };\n const pathProps = {\n d: pie.path(arc) || '',\n fill: accessors.fill(arc.data)\n };\n const groupProps = {};\n if (withTooltips) {\n groupProps.onMouseMove = handleMouseMove;\n groupProps.onMouseLeave = onMouseLeave;\n }\n\n // Estimate text width more accurately for background sizing\n const fontSize = 12;\n const estimatedTextWidth = getStringWidth(arc.data.label, {\n fontSize\n });\n const labelPadding = 6;\n const backgroundWidth = estimatedTextWidth + labelPadding * 2;\n const backgroundHeight = fontSize + labelPadding * 2;\n return /*#__PURE__*/_jsxs(\"g\", {\n ...groupProps,\n children: [/*#__PURE__*/_jsx(\"path\", {\n ...pathProps\n }), showLabels && hasSpaceForLabel && /*#__PURE__*/_jsxs(\"g\", {\n children: [providerTheme.labelBackgroundColor && /*#__PURE__*/_jsx(\"rect\", {\n x: centroidX - backgroundWidth / 2,\n y: centroidY - backgroundHeight / 2,\n width: backgroundWidth,\n height: backgroundHeight,\n fill: providerTheme.labelBackgroundColor,\n rx: 4,\n ry: 4,\n pointerEvents: \"none\"\n }), /*#__PURE__*/_jsx(\"text\", {\n x: centroidX,\n y: centroidY,\n dy: \".33em\",\n fill: providerTheme.labelTextColor || '#333',\n fontSize: fontSize,\n textAnchor: \"middle\",\n pointerEvents: \"none\",\n children: arc.data.label\n })]\n })]\n }, `arc-${index}`);\n });\n }\n }), !allSegmentsHidden && svgChildren]\n })]\n }), showLegend && /*#__PURE__*/_jsx(Legend, {\n orientation: legendOrientation,\n position: legendPosition,\n alignment: legendAlignment,\n maxWidth: legendMaxWidth,\n textOverflow: legendTextOverflow,\n legendItemClassName: legendItemClassName,\n className: styles['pie-chart-legend'],\n shape: legendShape,\n ref: legendRef,\n chartId: chartId,\n interactive: legendInteractive\n }), withTooltips && tooltipOpen && tooltipData && /*#__PURE__*/_jsx(TooltipInPortal, {\n top: tooltipTop || 0,\n left: tooltipLeft || 0,\n children: /*#__PURE__*/_jsx(\"div\", {\n role: \"tooltip\",\n children: renderTooltip({\n tooltipData\n })\n })\n }), htmlChildren, otherChildren]\n })\n });\n};\nconst PieChartWithProvider = props => {\n const existingContext = useContext(GlobalChartsContext);\n\n // If we're already in a GlobalChartsProvider context, don't create a new one\n if (existingContext) {\n return /*#__PURE__*/_jsx(PieChartInternal, {\n ...props\n });\n }\n\n // Otherwise, create our own GlobalChartsProvider\n return /*#__PURE__*/_jsx(GlobalChartsProvider, {\n children: /*#__PURE__*/_jsx(PieChartInternal, {\n ...props\n })\n });\n};\nPieChartWithProvider.displayName = 'PieChart';\n\n// Create PieChart with composition API\nconst PieChart = attachSubComponents(PieChartWithProvider, {\n Legend: Legend,\n SVG: ChartSVG,\n HTML: ChartHTML\n});\n\n// Create responsive PieChart with composition API\nconst PieChartResponsive = attachSubComponents(withResponsive(PieChartWithProvider), {\n Legend: Legend,\n SVG: ChartSVG,\n HTML: ChartHTML\n});\nexport { PieChartResponsive as default, PieChart as PieChartUnresponsive };","import 'css-chunk:src/charts/pie-chart/pie-chart.module.scss';export default {\n \"pie-chart\": \"a8ccharts-C-n-Gu\",\n \"pie-chart--legend-top\": \"a8ccharts-Mu0uxl\"\n};"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,aAAa;AACtB,SAAS,WAAW;AACpB,SAAS,YAAY,0BAA0B;AAC/C,SAAS,UAAU;AACnB,OAAO,UAAU;AACjB,SAAS,aAAa,YAAY,eAAe;;;ACLa,IAAO,2BAAQ;AAAA,EAC3E,aAAa;AAAA,EACb,yBAAyB;AAC3B;;;ADkBA,SAAS,OAAO,MAAM,QAAQ,aAAa;AAQ3C,IAAM,0BAA0B,CAAC;AAAA,EAC/B;AACF,MAAM;AACJ,SAAoB,qBAAK,aAAa;AAAA,IACpC,MAAM;AAAA,IACN,KAAK;AAAA,IACL,MAAM;AAAA,IACN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