{"version":3,"file":"index.cjs","names":[],"sources":["../../src/charts/buildOption/shared.ts","../../src/charts/buildOption/cartesian.ts","../../src/charts/buildOption/partToWhole.ts","../../src/charts/buildOption/matrix.ts","../../src/charts/buildOption/flow.ts","../../src/charts/useChartOption.ts","../../src/charts/buildOption/accessibleName.ts","../../src/charts/ChartSurface.tsx","../../src/charts/Chart.tsx","../../src/charts/BarChart.tsx","../../src/charts/LineChart.tsx","../../src/charts/AreaChart.tsx","../../src/charts/PieChart.tsx","../../src/charts/ScatterChart.tsx","../../src/charts/HeatmapChart.tsx","../../src/charts/SankeyChart.tsx","../../src/charts/Chart.meta.ts"],"sourcesContent":["/**\n * The option scaffolding every chart family shares: surface, ink, legend,\n * tooltip, and the accessibility layer.\n *\n * `EChartsOption` is imported as a type only — that emits no runtime import, so\n * this module stays free of the echarts runtime. Only `ChartSurface` imports it\n * for real, which is what keeps the builders testable in the node project and\n * keeps the leak guard satisfied.\n */\nimport type { EChartsOption } from 'echarts';\nimport { chartTokens, type ChartMedia, type ChartMode } from '@/tokens/chart';\nimport type { ChartConfig, SeriesConfig } from '../types';\n\n/**\n * Categorical slots are assigned in fixed order and never generated. Past the\n * last slot we wrap rather than invent a hue: a chart with more series than\n * slots should fold the tail into \"Other\" or facet instead.\n */\nexport function seriesColor(index: number, series: SeriesConfig, mode: ChartMode): string {\n  if (series.color) return series.color;\n  const slots = chartTokens[mode].series;\n  return slots[index % slots.length];\n}\n\n/** Whether a legend is drawn, and where — needed by both the legend and the grid. */\nfunction legendPlacement(config: ChartConfig): {\n  show: boolean;\n  position: 'top' | 'bottom' | 'left' | 'right';\n} {\n  const visible = config.series.filter((s) => !s.hidden);\n  // A single series is already named by the title; a legend box adds noise\n  // without adding identity.\n  return {\n    show: config.legend?.show ?? visible.length > 1,\n    position: config.legend?.position ?? 'bottom',\n  };\n}\n\nexport function resolveLegend(config: ChartConfig, mode: ChartMode): EChartsOption['legend'] {\n  const { show, position } = legendPlacement(config);\n  const tokens = chartTokens[mode];\n\n  return {\n    show,\n    textStyle: { color: tokens.ink.label },\n    ...(position === 'left' || position === 'right'\n      ? { orient: 'vertical' as const, [position]: 0 }\n      : { orient: 'horizontal' as const, [position]: 0 }),\n  };\n}\n\n/** Space reserved for the legend on the edge it occupies, in pixels. */\nconst LEGEND_INSET = 32;\n\n/**\n * Plot insets.\n *\n * `containLabel` reserves room for axis labels but knows nothing about the\n * legend, so without an explicit inset a bottom legend lands on top of the\n * category labels. Each edge therefore adds room only when the legend actually\n * sits there.\n */\nexport function resolveGrid(config: ChartConfig): EChartsOption['grid'] {\n  const { show, position } = legendPlacement(config);\n  const legendRoom = (edge: typeof position): number => (show && position === edge ? LEGEND_INSET : 0);\n\n  return {\n    left: 8 + legendRoom('left'),\n    right: 16 + legendRoom('right'),\n    top: (config.title ? 44 : 16) + legendRoom('top'),\n    bottom: 8 + legendRoom('bottom'),\n    containLabel: true,\n  };\n}\n\nexport function baseOption(\n  config: ChartConfig,\n  mode: ChartMode,\n  media: ChartMedia,\n): EChartsOption {\n  const tokens = chartTokens[mode];\n  const interactive = media === 'screen';\n  const partToWhole = config.chartType === 'pie' || config.chartType === 'donut';\n\n  return {\n    backgroundColor: tokens.surface,\n    color: [...tokens.series],\n    animation: interactive,\n    textStyle: { color: tokens.ink.label, fontSize: 12 },\n    title: config.title\n      ? {\n          text: config.title,\n          subtext: config.subtitle,\n          left: 0,\n          textStyle: { color: tokens.ink.label, fontSize: 14, fontWeight: 600 },\n          subtextStyle: { color: tokens.ink.label, fontSize: 12 },\n        }\n      : undefined,\n    grid: resolveGrid(config),\n    legend: resolveLegend(config, mode),\n    tooltip: interactive\n      ? {\n          // A pie has no axis to trigger against.\n          trigger: partToWhole ? 'item' : 'axis',\n          backgroundColor: tokens.ink.tooltipBg,\n          borderColor: tokens.ink.tooltipBorder,\n          borderWidth: 1,\n          textStyle: { color: tokens.ink.tooltipText, fontSize: 12 },\n        }\n      : { show: false },\n    aria: {\n      // The generated description is the table-equivalent for screen readers.\n      // It costs nothing visually, so it is always on.\n      enabled: true,\n      // Decals are the opposite trade: a real visual change to every mark, so\n      // they are opt-in via `config.decals` rather than a default. Note this\n      // means hue is the sole identity channel unless a consumer opts in — see\n      // the `decals` docs in `types.ts`.\n      decal: { show: config.decals === true },\n    },\n  };\n}\n","/**\n * Cartesian chart families: line, area, bar, stackedBar, horizontalBar, scatter.\n *\n * A series whose declared field is absent from the data is skipped with a\n * development warning instead of plotting NaN. That silent-coercion failure is\n * exactly what the downstream `extractValue`/`extractLabel` guesswork was\n * papering over.\n */\nimport type { EChartsOption } from 'echarts';\nimport { chartTokens, type ChartMedia, type ChartMode } from '@/tokens/chart';\nimport type { ChartConfig, ChartRow, SeriesConfig } from '../types';\nimport { baseOption, seriesColor } from './shared';\n\nconst STACK_ID = 'total';\n\nconst MARK: Record<string, 'line' | 'bar' | 'scatter'> = {\n  line: 'line',\n  area: 'line',\n  bar: 'bar',\n  stackedBar: 'bar',\n  horizontalBar: 'bar',\n  scatter: 'scatter',\n};\n\nconst toNumber = (value: unknown): number => {\n  const n = typeof value === 'number' ? value : Number(value);\n  return Number.isFinite(n) ? n : 0;\n};\n\nfunction hasField(data: readonly ChartRow[], field: string | undefined): field is string {\n  return typeof field === 'string' && data.length > 0 && field in data[0];\n}\n\nexport function buildCartesianOption(\n  config: ChartConfig,\n  data: readonly ChartRow[],\n  mode: ChartMode,\n  media: ChartMedia,\n): EChartsOption {\n  const tokens = chartTokens[mode];\n  const mark = MARK[config.chartType] ?? 'line';\n  const horizontal = config.chartType === 'horizontalBar';\n  const stacked = config.chartType === 'stackedBar';\n\n  const visible = config.series.filter((series) => !series.hidden);\n  const usable = visible.filter((series) => {\n    const ok = hasField(data, series.fields.x) && hasField(data, series.fields.y);\n    if (!ok && data.length > 0) {\n      console.warn(\n        `[octopus-ui/chart] series \"${series.name}\" references fields ` +\n          `x=\"${series.fields.x}\" y=\"${series.fields.y}\" which are not present in the data; ` +\n          'skipping this series.',\n      );\n    }\n    return ok;\n  });\n\n  const categories = usable.length\n    ? data.map((row) => String(row[usable[0].fields.x as string]))\n    : [];\n\n  const categoryAxis = {\n    type: 'category' as const,\n    data: categories,\n    axisLine: { lineStyle: { color: tokens.ink.axis } },\n    axisTick: { show: false },\n    axisLabel: { color: tokens.ink.label },\n    splitLine: { show: false },\n  };\n\n  const valueAxis = {\n    type: 'value' as const,\n    axisLine: { show: false },\n    axisTick: { show: false },\n    axisLabel: { color: tokens.ink.label },\n    splitLine: { lineStyle: { color: tokens.ink.grid } },\n  };\n\n  const series = usable.map((entry: SeriesConfig, index: number) => {\n    const color = seriesColor(index, entry, mode);\n    const values = data.map((row) => toNumber(row[entry.fields.y as string]));\n\n    return {\n      id: entry.id,\n      name: entry.name,\n      type: mark,\n      itemStyle: {\n        color,\n        ...(mark === 'bar'\n          ? { borderRadius: horizontal ? [0, 4, 4, 0] : [4, 4, 0, 0] }\n          : {}),\n      },\n      ...(mark === 'line'\n        ? {\n            smooth: true,\n            showSymbol: false,\n            lineStyle: { color, width: 2 },\n            ...(config.chartType === 'area'\n              ? { areaStyle: { color, opacity: tokens.ink.areaOpacity } }\n              : {}),\n          }\n        : {}),\n      ...(mark === 'bar'\n        ? {\n            // A visible surface gap between adjacent fills is the mandated\n            // secondary encoding for colour-vision separation.\n            barCategoryGap: '30%',\n            barGap: '8%',\n            ...(stacked ? { stack: STACK_ID } : {}),\n          }\n        : {}),\n      data:\n        mark === 'scatter'\n          ? data.map((row) => [\n              row[entry.fields.x as string],\n              toNumber(row[entry.fields.y as string]),\n            ])\n          : values,\n    };\n  });\n\n  return {\n    ...baseOption(config, mode, media),\n    xAxis: horizontal ? valueAxis : categoryAxis,\n    yAxis: horizontal ? categoryAxis : valueAxis,\n    series,\n  } as EChartsOption;\n}\n","/**\n * Part-to-whole families: pie and donut.\n *\n * Slices carry a surface-coloured border, which is the gap between adjacent\n * fills that the mark spec requires as secondary encoding.\n */\nimport type { EChartsOption } from 'echarts';\nimport { chartTokens, type ChartMedia, type ChartMode } from '@/tokens/chart';\nimport type { ChartConfig, ChartRow } from '../types';\nimport { baseOption, seriesColor } from './shared';\n\nconst toNumber = (value: unknown): number => {\n  const n = typeof value === 'number' ? value : Number(value);\n  return Number.isFinite(n) ? n : 0;\n};\n\nexport function buildPartToWholeOption(\n  config: ChartConfig,\n  data: readonly ChartRow[],\n  mode: ChartMode,\n  media: ChartMedia,\n): EChartsOption {\n  const tokens = chartTokens[mode];\n  const entry = config.series.find((s) => !s.hidden);\n  const nameField = entry?.fields.x;\n  const valueField = entry?.fields.y ?? entry?.fields.value;\n\n  const usable =\n    entry &&\n    nameField &&\n    valueField &&\n    data.length > 0 &&\n    nameField in data[0] &&\n    valueField in data[0];\n\n  if (!usable) {\n    if (entry && data.length > 0) {\n      console.warn(\n        `[octopus-ui/chart] series \"${entry.name}\" references fields not present in the data; ` +\n          'nothing to render.',\n      );\n    }\n    return { ...baseOption(config, mode, media), series: [] } as EChartsOption;\n  }\n\n  return {\n    ...baseOption(config, mode, media),\n    series: [\n      {\n        id: entry.id,\n        name: entry.name,\n        type: 'pie',\n        radius: config.chartType === 'donut' ? ['48%', '70%'] : '65%',\n        itemStyle: { borderColor: tokens.surface, borderWidth: 2 },\n        label: { color: tokens.ink.label },\n        labelLine: { lineStyle: { color: tokens.ink.axis } },\n        data: data.map((row, index) => ({\n          name: String(row[nameField]),\n          value: toNumber(row[valueField]),\n          itemStyle: { color: seriesColor(index, entry, mode) },\n        })),\n      },\n    ],\n  } as EChartsOption;\n}\n","/**\n * Matrix family: heatmap.\n *\n * Magnitude is a sequential job, so cells take the single-hue sequential ramp,\n * never the categorical slots — those encode identity, which a heatmap cell\n * does not have.\n */\nimport type { EChartsOption } from 'echarts';\nimport { chartTokens, type ChartMedia, type ChartMode } from '@/tokens/chart';\nimport type { ChartConfig, ChartRow } from '../types';\nimport { baseOption } from './shared';\n\nconst toNumber = (value: unknown): number => {\n  const n = typeof value === 'number' ? value : Number(value);\n  return Number.isFinite(n) ? n : 0;\n};\n\nconst uniqueInOrder = (values: readonly string[]): string[] => [...new Set(values)];\n\n/** Room below the plot for the horizontal visualMap scale. */\nconst VISUAL_MAP_INSET = 48;\n\nexport function buildMatrixOption(\n  config: ChartConfig,\n  data: readonly ChartRow[],\n  mode: ChartMode,\n  media: ChartMedia,\n): EChartsOption {\n  const tokens = chartTokens[mode];\n  const entry = config.series.find((s) => !s.hidden);\n  const xField = entry?.fields.x;\n  const yField = entry?.fields.y;\n  const valueField = entry?.fields.value;\n\n  const usable =\n    entry &&\n    xField &&\n    yField &&\n    valueField &&\n    data.length > 0 &&\n    xField in data[0] &&\n    yField in data[0] &&\n    valueField in data[0];\n\n  if (!usable) {\n    if (entry && data.length > 0) {\n      console.warn(\n        `[octopus-ui/chart] heatmap series \"${entry.name}\" references fields not present in ` +\n          'the data; nothing to render.',\n      );\n    }\n    return { ...baseOption(config, mode, media), series: [] } as EChartsOption;\n  }\n\n  const xs = uniqueInOrder(data.map((row) => String(row[xField])));\n  const ys = uniqueInOrder(data.map((row) => String(row[yField])));\n  const cells = data.map((row) => [\n    xs.indexOf(String(row[xField])),\n    ys.indexOf(String(row[yField])),\n    toNumber(row[valueField]),\n  ]);\n  const values = cells.map((cell) => cell[2]);\n\n  const axis = (categories: string[]) => ({\n    type: 'category' as const,\n    data: categories,\n    axisLine: { lineStyle: { color: tokens.ink.axis } },\n    axisTick: { show: false },\n    axisLabel: { color: tokens.ink.label },\n    // The cells themselves carry the visual; alternating split bands behind\n    // them would compete with the sequential ramp.\n    splitArea: { show: false },\n  });\n\n  const base = baseOption(config, mode, media);\n\n  return {\n    ...base,\n    // The visualMap sits along the bottom edge and, like the legend, is invisible\n    // to `containLabel` — without extra room it lands on the category labels.\n    grid: { ...(base.grid as object), bottom: VISUAL_MAP_INSET },\n    aria: {\n      ...(base.aria as object),\n      // Decals are secondary encoding for categorical *identity*. A heatmap\n      // encodes magnitude through lightness, so hatching every cell competes\n      // with the only channel that carries meaning here.\n      decal: { show: false },\n    },\n    xAxis: axis(xs),\n    yAxis: axis(ys),\n    visualMap: {\n      min: Math.min(...values),\n      max: Math.max(...values),\n      calculable: media === 'screen',\n      orient: 'horizontal',\n      left: 'center',\n      bottom: 0,\n      textStyle: { color: tokens.ink.label },\n      inRange: { color: [...tokens.sequential] },\n    },\n    series: [\n      {\n        id: entry.id,\n        name: entry.name,\n        type: 'heatmap',\n        data: cells,\n        itemStyle: { borderColor: tokens.surface, borderWidth: 2 },\n      },\n    ],\n  } as EChartsOption;\n}\n","/**\n * Flow family: sankey.\n *\n * Nodes are derived from both endpoints of every link and deduplicated in\n * first-seen order, so colour assignment is stable across renders rather than\n * shifting when a link is added.\n */\nimport type { EChartsOption } from 'echarts';\nimport { chartTokens, type ChartMedia, type ChartMode } from '@/tokens/chart';\nimport type { ChartConfig, ChartRow } from '../types';\nimport { baseOption } from './shared';\n\nconst toNumber = (value: unknown): number => {\n  const n = typeof value === 'number' ? value : Number(value);\n  return Number.isFinite(n) ? n : 0;\n};\n\nexport function buildFlowOption(\n  config: ChartConfig,\n  data: readonly ChartRow[],\n  mode: ChartMode,\n  media: ChartMedia,\n): EChartsOption {\n  const tokens = chartTokens[mode];\n  const entry = config.series.find((s) => !s.hidden);\n  const sourceField = entry?.fields.x;\n  const targetField = entry?.fields.target;\n  const valueField = entry?.fields.value;\n\n  const usable =\n    entry &&\n    sourceField &&\n    targetField &&\n    valueField &&\n    data.length > 0 &&\n    sourceField in data[0] &&\n    targetField in data[0] &&\n    valueField in data[0];\n\n  if (!usable) {\n    if (entry && data.length > 0) {\n      console.warn(\n        `[octopus-ui/chart] sankey series \"${entry.name}\" references fields not present in ` +\n          'the data; nothing to render.',\n      );\n    }\n    return { ...baseOption(config, mode, media), series: [] } as EChartsOption;\n  }\n\n  const names: string[] = [];\n  for (const row of data) {\n    for (const field of [sourceField, targetField]) {\n      const name = String(row[field]);\n      if (!names.includes(name)) names.push(name);\n    }\n  }\n\n  return {\n    ...baseOption(config, mode, media),\n    series: [\n      {\n        id: entry.id,\n        name: entry.name,\n        type: 'sankey',\n        emphasis: { focus: 'adjacency' },\n        label: { color: tokens.ink.label },\n        lineStyle: { color: 'gradient', opacity: 0.35 },\n        data: names.map((name, index) => ({\n          name,\n          itemStyle: { color: tokens.series[index % tokens.series.length] },\n        })),\n        links: data.map((row) => ({\n          source: String(row[sourceField]),\n          target: String(row[targetField]),\n          value: toNumber(row[valueField]),\n        })),\n      },\n    ],\n  } as EChartsOption;\n}\n","/**\n * The single option-building path.\n *\n * Every tier funnels through here: tier-2 components build a `ChartConfig` and\n * delegate, tier 3 accepts one directly. Keeping this pure (and separate from\n * `ChartSurface`) is what lets the builders be unit-tested in the node project\n * without a browser or the echarts runtime.\n */\nimport { useMemo } from 'react';\nimport type { EChartsOption } from 'echarts';\nimport type { ChartMedia, ChartMode } from '@/tokens/chart';\nimport type { ChartConfig, ChartRow, ChartType } from './types';\nimport { baseOption } from './buildOption/shared';\nimport { buildCartesianOption } from './buildOption/cartesian';\nimport { buildPartToWholeOption } from './buildOption/partToWhole';\nimport { buildMatrixOption } from './buildOption/matrix';\nimport { buildFlowOption } from './buildOption/flow';\n\ntype Family = 'cartesian' | 'partToWhole' | 'matrix' | 'flow' | 'none';\n\n/**\n * A mapped type over ChartType keeps this exhaustive: adding a chart type is a\n * compile error until it is routed here.\n */\nconst FAMILY: { [K in ChartType]: Family } = {\n  line: 'cartesian',\n  area: 'cartesian',\n  bar: 'cartesian',\n  stackedBar: 'cartesian',\n  horizontalBar: 'cartesian',\n  scatter: 'cartesian',\n  pie: 'partToWhole',\n  donut: 'partToWhole',\n  heatmap: 'matrix',\n  sankey: 'flow',\n  // Rendered by StatTile and the Table organism respectively — not ECharts\n  // instances, so they produce an empty option here.\n  kpi: 'none',\n  table: 'none',\n};\n\nexport function buildChartOption(\n  config: ChartConfig,\n  data: readonly ChartRow[],\n  mode: ChartMode,\n  media: ChartMedia,\n): EChartsOption {\n  switch (FAMILY[config.chartType]) {\n    case 'cartesian':\n      return buildCartesianOption(config, data, mode, media);\n    case 'partToWhole':\n      return buildPartToWholeOption(config, data, mode, media);\n    case 'matrix':\n      return buildMatrixOption(config, data, mode, media);\n    case 'flow':\n      return buildFlowOption(config, data, mode, media);\n    case 'none':\n    default:\n      return { ...baseOption(config, mode, media), series: [] } as EChartsOption;\n  }\n}\n\nexport function useChartOption(\n  config: ChartConfig,\n  data: readonly ChartRow[],\n  mode: ChartMode,\n  media: ChartMedia,\n): EChartsOption {\n  return useMemo(() => buildChartOption(config, data, mode, media), [config, data, mode, media]);\n}\n","/**\n * Makes a caller-supplied accessible name authoritative over the one ECharts\n * generates for itself.\n *\n * `ChartSurface` renders `<div role=\"img\" aria-label={label}>` and then hands\n * that same element to `echarts.init()`. ECharts owns the element from then on,\n * and its own accessibility pass writes an `aria-label` describing the whole\n * dataset — \"This is a chart about \"Alerts and cases by day\". It consists of 2\n * series count…\" — straight over the React-rendered attribute.\n *\n * Which name a screen reader (or a test) observes therefore depends on whether\n * ECharts' update has landed yet, and that update is deferred by `lazyUpdate`.\n * The result is an accessible name that is racy rather than wrong-but-stable:\n * it passed locally and failed on a slower CI runner, on identical code.\n *\n * Rather than fight ECharts for the attribute — disabling its aria support\n * would also discard the data description, which is genuinely useful — this\n * tells ECharts what to write. `aria.label.description` replaces the generated\n * text, so ECharts sets exactly the caller's label and both writers agree.\n *\n * With no label supplied there is nothing to preserve, so ECharts' generated\n * description is left alone as the better default.\n */\nimport type { EChartsOption } from 'echarts';\n\nexport function withAccessibleName(option: EChartsOption, label: string | undefined): EChartsOption {\n  if (label === undefined || label === '') return option;\n\n  return {\n    ...option,\n    aria: {\n      ...option.aria,\n      enabled: true,\n      label: {\n        ...option.aria?.label,\n        enabled: true,\n        description: label,\n      },\n    },\n  };\n}\n","/**\n * ChartSurface\n * Classification: third-party-wrapper\n *\n * The ECharts lifecycle host, and the ONLY module importing the echarts\n * runtime. Everything else in `src/charts/` deals in plain option objects,\n * which is what keeps them testable in the node project.\n *\n * Also the tier-4 escape hatch: pass a raw `option` for anything the config\n * schema does not yet model (geo maps, custom series).\n */\nimport { useEffect, useRef, type CSSProperties } from 'react';\nimport * as echarts from 'echarts';\nimport type { EChartsOption } from 'echarts';\nimport { useTheme } from '@mui/material/styles';\nimport type { ChartMedia, ChartMode } from '@/tokens/chart';\nimport type { ChartPoint, ChartRow } from './types';\nimport { withAccessibleName } from './buildOption/accessibleName';\n\nexport interface ChartSurfaceProps {\n  option: EChartsOption;\n  mode?: ChartMode;\n  media?: ChartMedia;\n  height?: number | string;\n  style?: CSSProperties;\n  onPointClick?: (point: ChartPoint) => void;\n  /** Accessible name for the chart region. */\n  label?: string;\n}\n\n/**\n * `echarts` is an OPTIONAL peer dependency, so it can legitimately be absent.\n *\n * If it is not installed at all, the module specifier fails to resolve and the\n * bundler or runtime raises its own error — which already names `echarts`, so\n * there is nothing useful to add. What this guards is the nastier case: the\n * module resolves but is not a usable ECharts build (a version mismatch, a\n * mangled optional-dependency install, or a test environment that stubbed it).\n * Without this the failure surfaces as `echarts.init is not a function` deep in\n * an effect, with no indication that a peer dependency is the cause.\n */\nfunction assertEChartsAvailable(): void {\n  if (typeof echarts?.init !== 'function') {\n    throw new Error(\n      'Charts from `@aistrike-dev/ui/charts` require the optional peer dependency ' +\n        '`echarts@^6.1.0`, which resolved but does not expose `init()`. Install or ' +\n        'repair it with `npm install echarts@^6.1.0`. Components that need no chart ' +\n        'library (Sparkline, Meter, SplitBar, StatTile) ship from `@aistrike-dev/ui` ' +\n        'instead and do not require this dependency.',\n    );\n  }\n}\n\ninterface EChartsClickParams {\n  seriesId?: string;\n  seriesName?: string;\n  name?: string;\n  value?: unknown;\n  data?: unknown;\n}\n\nexport function ChartSurface({\n  option,\n  mode,\n  media = 'screen',\n  height = 320,\n  style,\n  onPointClick,\n  label,\n}: ChartSurfaceProps) {\n  const theme = useTheme();\n  const resolvedMode: ChartMode = mode ?? (theme.palette.mode === 'light' ? 'light' : 'dark');\n  const hostRef = useRef<HTMLDivElement>(null);\n  const chartRef = useRef<echarts.ECharts | null>(null);\n  // Held in a ref so a changing callback identity never tears down the chart.\n  // Synced in an effect rather than during render: mutating a ref while\n  // rendering is unsafe once concurrent rendering can discard the pass.\n  const clickRef = useRef(onPointClick);\n  useEffect(() => {\n    clickRef.current = onPointClick;\n  }, [onPointClick]);\n\n  // Init and teardown. The renderer is fixed for an instance's lifetime, so a\n  // media change must dispose and re-init — hence `media` in the dependencies.\n  useEffect(() => {\n    const host = hostRef.current;\n    if (!host) return undefined;\n\n    assertEChartsAvailable();\n\n    const instance = echarts.init(host, undefined, {\n      renderer: media === 'export' ? 'svg' : 'canvas',\n    });\n    chartRef.current = instance;\n\n    instance.on('click', (params: unknown) => {\n      const p = params as EChartsClickParams;\n      const numeric = typeof p.value === 'number' ? p.value : Number(p.value);\n      clickRef.current?.({\n        seriesId: p.seriesId ?? '',\n        seriesName: p.seriesName ?? '',\n        x: p.name ?? '',\n        y: Number.isFinite(numeric) ? numeric : 0,\n        row: (p.data ?? {}) as ChartRow,\n      });\n    });\n\n    // Export renders once at a known size for a headless capture; observing\n    // resize there would only add nondeterminism.\n    let observer: ResizeObserver | undefined;\n    if (media === 'screen') {\n      // Charts often mount before their container has its final size — this is\n      // required inside grid layouts, where a one-shot init leaves them tiny.\n      observer = new ResizeObserver(() => instance.resize());\n      observer.observe(host);\n    }\n\n    return () => {\n      observer?.disconnect();\n      instance.dispose();\n      chartRef.current = null;\n    };\n  }, [media, resolvedMode]);\n\n  // `label` participates because ECharts writes the host's `aria-label` itself;\n  // see `withAccessibleName` for why it has to be told the name rather than\n  // left to generate one over the top of React's attribute.\n  useEffect(() => {\n    chartRef.current?.setOption(withAccessibleName(option, label), {\n      notMerge: true,\n      lazyUpdate: media === 'screen',\n    });\n  }, [option, media, label]);\n\n  return (\n    <div\n      ref={hostRef}\n      role=\"img\"\n      aria-label={label}\n      style={{ width: '100%', height, minHeight: 0, ...style }}\n    />\n  );\n}\n","/**\n * Chart\n * Classification: third-party-wrapper\n *\n * Tier 3: the config-driven entry point. A `ChartConfig` is serialisable, so a\n * user-built dashboard can persist one and render it here.\n *\n * `kpi` and `table` are deliberately part of the same union: a dashboard\n * builder keeps one config -> one component with no call-site special-casing,\n * even though neither renders as an ECharts instance.\n */\nimport { useMemo } from 'react';\nimport type { EChartsOption } from 'echarts';\nimport { useTheme } from '@mui/material/styles';\nimport { Skeleton } from '@/atoms/Skeleton';\nimport { EmptyState } from '@/organisms/EmptyState';\nimport { StatTile } from '@/molecules/StatTile';\nimport type { ChartMedia, ChartMode } from '@/tokens/chart';\nimport type { ChartConfig, ChartPoint, ChartRow, ChartState } from './types';\nimport { useChartOption } from './useChartOption';\nimport { ChartSurface } from './ChartSurface';\n\nexport interface ChartBaseProps {\n  data: readonly ChartRow[];\n  /** Defaults to the surrounding MUI theme's palette mode. */\n  mode?: ChartMode;\n  /** `export` renders SVG, static and non-interactive, for PDF capture. */\n  media?: ChartMedia;\n  height?: number | string;\n  /**\n   * Only conditions the component cannot observe. Emptiness is derived from\n   * `data`, so it is deliberately not expressible here.\n   */\n  state?: ChartState;\n  onPointClick?: (point: ChartPoint) => void;\n  /** Last-resort hook for options the config schema does not model. */\n  transformOption?: (option: EChartsOption) => EChartsOption;\n  /** Accessible name. Falls back to the config title. */\n  label?: string;\n  /**\n   * Overlays decal textures on every mark as a second identity channel beyond\n   * hue. Off by default — see `ChartConfig.decals`.\n   *\n   * Exists as a prop as well as a config field because the tier-2 adapters\n   * (`BarChart` and friends) build their own config and never expose one. When\n   * both are given, this wins, so a caller can flip it per render without\n   * rewriting a persisted config.\n   */\n  decals?: boolean;\n}\n\nexport interface ChartProps extends ChartBaseProps {\n  config: ChartConfig;\n}\n\nexport function Chart({\n  config,\n  data,\n  mode,\n  media = 'screen',\n  height = 320,\n  state,\n  onPointClick,\n  transformOption,\n  label,\n  decals,\n}: ChartProps) {\n  const theme = useTheme();\n  const resolvedMode: ChartMode = mode ?? (theme.palette.mode === 'light' ? 'light' : 'dark');\n  // Memoized, and passed through untouched when the prop is absent: spreading\n  // a fresh object every render would defeat `useChartOption`'s memo and push a\n  // new option into `ChartSurface.setOption` on every render.\n  const resolvedConfig = useMemo(\n    () => (decals === undefined ? config : { ...config, decals }),\n    [config, decals],\n  );\n  const built = useChartOption(resolvedConfig, data, resolvedMode, media);\n  const option = transformOption ? transformOption(built) : built;\n  const name = label ?? config.title ?? 'Chart';\n\n  if (state === 'error') {\n    return <EmptyState title=\"Chart unavailable\" description=\"This data could not be loaded.\" />;\n  }\n  if (state === 'loading') {\n    return <Skeleton variant=\"rectangular\" height={height} aria-label={`${name} loading`} />;\n  }\n  // Emptiness is derived, never passed — a caller cannot contradict the data.\n  if (data.length === 0) {\n    return (\n      <EmptyState title=\"No data\" description=\"There is nothing to show for this selection.\" />\n    );\n  }\n\n  if (config.chartType === 'kpi') {\n    const entry = config.series.find((s) => !s.hidden);\n    const field = entry?.fields.y ?? entry?.fields.value;\n    const last = field ? data[data.length - 1]?.[field] : undefined;\n    return (\n      <StatTile\n        value={String(last ?? '—')}\n        label={config.title ?? entry?.name ?? 'Value'}\n        caption={config.subtitle}\n      />\n    );\n  }\n\n  if (config.chartType === 'table') {\n    // Rendering a result set as a table is the Table organism's job; doing it\n    // here would duplicate sorting, virtualisation and column sizing.\n    return (\n      <EmptyState\n        title=\"Table view\"\n        description=\"Render this result set with the Table organism from @aistrike-dev/ui.\"\n      />\n    );\n  }\n\n  return (\n    <ChartSurface\n      option={option}\n      mode={resolvedMode}\n      media={media}\n      height={height}\n      onPointClick={onPointClick}\n      label={name}\n    />\n  );\n}\n","/**\n * BarChart — tier-2 adapter. Covers vertical, horizontal and stacked bars,\n * which downstream were three separate Highcharts call patterns.\n */\nimport { useMemo } from 'react';\nimport { Chart, type ChartBaseProps } from './Chart';\nimport type { ChartConfig } from './types';\n\nexport interface BarSeries {\n  /** Field name holding this series' measure. */\n  key: string;\n  name: string;\n  color?: string;\n}\n\nexport interface BarChartProps extends ChartBaseProps {\n  /** Field name holding the category label. */\n  xKey: string;\n  series: readonly BarSeries[];\n  orientation?: 'vertical' | 'horizontal';\n  stacked?: boolean;\n  title?: string;\n}\n\nexport function BarChart({\n  xKey,\n  series,\n  orientation = 'vertical',\n  stacked = false,\n  title,\n  ...rest\n}: BarChartProps) {\n  const config: ChartConfig = useMemo(\n    () => ({\n      title,\n      chartType: stacked ? 'stackedBar' : orientation === 'horizontal' ? 'horizontalBar' : 'bar',\n      series: series.map((s) => ({\n        id: s.key,\n        name: s.name,\n        color: s.color,\n        fields: { x: xKey, y: s.key },\n      })),\n    }),\n    [xKey, series, orientation, stacked, title],\n  );\n  return <Chart config={config} {...rest} />;\n}\n","/** LineChart — tier-2 adapter. */\nimport { useMemo } from 'react';\nimport { Chart, type ChartBaseProps } from './Chart';\nimport type { ChartConfig } from './types';\n\nexport interface LineSeries {\n  /** Field name holding this series' measure. */\n  key: string;\n  name: string;\n  color?: string;\n}\n\nexport interface LineChartProps extends ChartBaseProps {\n  /** Field name holding the category or time label. */\n  xKey: string;\n  series: readonly LineSeries[];\n  title?: string;\n}\n\nexport function LineChart({ xKey, series, title, ...rest }: LineChartProps) {\n  const config: ChartConfig = useMemo(\n    () => ({\n      title,\n      chartType: 'line',\n      series: series.map((s) => ({\n        id: s.key,\n        name: s.name,\n        color: s.color,\n        fields: { x: xKey, y: s.key },\n      })),\n    }),\n    [xKey, series, title],\n  );\n  return <Chart config={config} {...rest} />;\n}\n","/** AreaChart — tier-2 adapter. */\nimport { useMemo } from 'react';\nimport { Chart, type ChartBaseProps } from './Chart';\nimport type { ChartConfig } from './types';\n\nexport interface AreaSeries {\n  /** Field name holding this series' measure. */\n  key: string;\n  name: string;\n  color?: string;\n}\n\nexport interface AreaChartProps extends ChartBaseProps {\n  /** Field name holding the category or time label. */\n  xKey: string;\n  series: readonly AreaSeries[];\n  title?: string;\n}\n\nexport function AreaChart({ xKey, series, title, ...rest }: AreaChartProps) {\n  const config: ChartConfig = useMemo(\n    () => ({\n      title,\n      chartType: 'area',\n      series: series.map((s) => ({\n        id: s.key,\n        name: s.name,\n        color: s.color,\n        fields: { x: xKey, y: s.key },\n      })),\n    }),\n    [xKey, series, title],\n  );\n  return <Chart config={config} {...rest} />;\n}\n","/** PieChart — tier-2 adapter. `variant=\"donut\"` adds the inner radius. */\nimport { useMemo } from 'react';\nimport { Chart, type ChartBaseProps } from './Chart';\nimport type { ChartConfig } from './types';\n\nexport interface PieChartProps extends ChartBaseProps {\n  /** Field name holding the slice label. */\n  nameKey: string;\n  /** Field name holding the slice value. */\n  valueKey: string;\n  variant?: 'pie' | 'donut';\n  title?: string;\n}\n\nexport function PieChart({ nameKey, valueKey, variant = 'pie', title, ...rest }: PieChartProps) {\n  const config: ChartConfig = useMemo(\n    () => ({\n      title,\n      chartType: variant,\n      series: [{ id: valueKey, name: title ?? valueKey, fields: { x: nameKey, y: valueKey } }],\n    }),\n    [nameKey, valueKey, variant, title],\n  );\n  return <Chart config={config} {...rest} />;\n}\n","/**\n * ScatterChart — tier-2 adapter.\n *\n * Scatter is an all-pairs form: any two marks can end up neighbours, so it\n * carries the documented series cap rather than the adjacent-pairs one.\n */\nimport { useMemo } from 'react';\nimport { ALL_PAIRS_SERIES_CAP } from '@/tokens/chart';\nimport { Chart, type ChartBaseProps } from './Chart';\nimport type { ChartConfig } from './types';\n\nexport interface ScatterSeries {\n  /** Field name holding this series' measure. */\n  key: string;\n  name: string;\n  color?: string;\n}\n\nexport interface ScatterChartProps extends ChartBaseProps {\n  xKey: string;\n  series: readonly ScatterSeries[];\n  title?: string;\n}\n\nexport function ScatterChart({ xKey, series, title, ...rest }: ScatterChartProps) {\n  if (process.env.NODE_ENV !== 'production' && series.length > ALL_PAIRS_SERIES_CAP) {\n    console.warn(\n      `[octopus-ui/chart] ScatterChart received ${series.length} series, above the ` +\n        `all-pairs cap of ${ALL_PAIRS_SERIES_CAP}. Any two marks can be neighbours in a ` +\n        'scatter plot, and no palette keeps more than that many hues mutually ' +\n        'distinguishable under colour-vision simulation. Fold the tail into \"Other\" or ' +\n        'facet into small multiples.',\n    );\n  }\n\n  const config: ChartConfig = useMemo(\n    () => ({\n      title,\n      chartType: 'scatter',\n      series: series.map((s) => ({\n        id: s.key,\n        name: s.name,\n        color: s.color,\n        fields: { x: xKey, y: s.key },\n      })),\n    }),\n    [xKey, series, title],\n  );\n  return <Chart config={config} {...rest} />;\n}\n","/** HeatmapChart — tier-2 adapter. Magnitude uses the sequential ramp. */\nimport { useMemo } from 'react';\nimport { Chart, type ChartBaseProps } from './Chart';\nimport type { ChartConfig } from './types';\n\nexport interface HeatmapChartProps extends ChartBaseProps {\n  /** Field name for the column axis. */\n  xKey: string;\n  /** Field name for the row axis. */\n  yKey: string;\n  /** Field name holding the cell magnitude. */\n  valueKey: string;\n  title?: string;\n}\n\nexport function HeatmapChart({ xKey, yKey, valueKey, title, ...rest }: HeatmapChartProps) {\n  const config: ChartConfig = useMemo(\n    () => ({\n      title,\n      chartType: 'heatmap',\n      series: [\n        { id: valueKey, name: title ?? valueKey, fields: { x: xKey, y: yKey, value: valueKey } },\n      ],\n    }),\n    [xKey, yKey, valueKey, title],\n  );\n  return <Chart config={config} {...rest} />;\n}\n","/** SankeyChart — tier-2 adapter. */\nimport { useMemo } from 'react';\nimport { Chart, type ChartBaseProps } from './Chart';\nimport type { ChartConfig } from './types';\n\nexport interface SankeyChartProps extends ChartBaseProps {\n  /** Field name holding the link's source node. */\n  sourceKey: string;\n  /** Field name holding the link's target node. */\n  targetKey: string;\n  /** Field name holding the link weight. */\n  valueKey: string;\n  title?: string;\n}\n\nexport function SankeyChart({\n  sourceKey,\n  targetKey,\n  valueKey,\n  title,\n  ...rest\n}: SankeyChartProps) {\n  const config: ChartConfig = useMemo(\n    () => ({\n      title,\n      chartType: 'sankey',\n      series: [\n        {\n          id: valueKey,\n          name: title ?? valueKey,\n          fields: { x: sourceKey, target: targetKey, value: valueKey },\n        },\n      ],\n    }),\n    [sourceKey, targetKey, valueKey, title],\n  );\n  return <Chart config={config} {...rest} />;\n}\n","import { defineMeta } from '@/registry/types';\n\nexport const chartMeta = defineMeta({\n  name: 'Chart',\n  level: 'organism',\n  category: 'data-display',\n  classification: 'third-party-wrapper',\n  description:\n    'Config-driven chart. Accepts a serialisable ChartConfig so user-built dashboards can persist and replay a chart definition. Typed per-type components (BarChart, LineChart, PieChart, ScatterChart, HeatmapChart, SankeyChart) are thin adapters over this.',\n  baseLibrary: 'echarts',\n  importPath: '@/charts',\n  packageImport: '@aistrike-dev/ui/charts',\n  requiredProps: ['config', 'data'],\n  optionalProps: [\n    'mode',\n    'media',\n    'height',\n    'state',\n    'onPointClick',\n    'transformOption',\n    'label',\n    'decals',\n  ],\n  customVariants: ['screen', 'export'],\n  supportedStates: ['default', 'loading', 'empty', 'error'],\n  designTokens: ['chart', 'severity'],\n  accessibility: [\n    'ECharts aria description is enabled, giving screen readers a text equivalent of the plot.',\n    'Decal textures are available via `decals` for a secondary encoding beyond hue, but are off by default — hue alone carries series identity unless enabled.',\n    'A legend appears automatically for two or more series; a single series is named by the title instead.',\n  ],\n  usageExamples: [\n    '<BarChart xKey=\"day\" series={[{ key: \"alerts\", name: \"Alerts\" }]} data={rows} />',\n    '<Chart config={savedConfig} data={rows} media=\"export\" mode=\"light\" />',\n  ],\n  antiPatterns: [\n    'Do not use severity colours as a series palette — severity encodes status, not identity.',\n    'Do not exceed three series in scatter or bubble forms; fold the tail into \"Other\" or facet.',\n    'Never render two measures of different scale on two y-axes; use two charts or index to a common base.',\n  ],\n  llmSafe: true,\n  whenToUse: ['Any multi-point data visualisation, on screen or in an exported report'],\n  whenNotToUse: [\n    'A single headline number (use StatTile)',\n    'A row-level trend (use Sparkline)',\n    'A tabular result set (use the Table organism)',\n  ],\n});\n\nexport default chartMeta;\n"],"mappings":"2XAkBA,SAAgB,EAAY,EAAe,EAAsB,EAAyB,CACxF,GAAI,EAAO,MAAO,OAAO,EAAO,MAChC,IAAM,EAAQ,EAAA,EAAY,GAAM,OAChC,OAAO,EAAM,EAAQ,EAAM,OAC7B,CAGA,SAAS,EAAgB,EAGvB,CACA,IA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