{"version":3,"file":"index.cjs","names":["textAscent","node","getMultiValue","CLASS_NAMES","node","textAscent","isDataHoleValue","getMultiValue","node","alphaNumerate","findAll","textAscent","node"],"sources":["../src/axisTitle.ts","../src/logAxis.ts","../src/targetLine.ts","../src/centerShift.ts","../src/trendLine.ts","../src/valueLabels.ts"],"sourcesContent":["import {\n  node,\n  textAscent,\n  type AxisSide,\n  type InsetContext,\n  type Layer,\n  type LayerContext\n} from 'chartist';\n\ndeclare module 'chartist' {\n  interface NodeRoles {\n    /** An axis title of {@link axisTitle}: a `text` (class `ct-axis-title`). */\n    axisTitle: {\n      ctx: {\n        /** The id of the axis the title names. */\n        readonly axis: string;\n        /** The side of the chart the axis is on. */\n        readonly side: AxisSide;\n        /** The title's text. */\n        readonly text: string;\n        /** Where the text is anchored, in px in the SVG. */\n        readonly x: number;\n        readonly y: number;\n      };\n      attrs: { readonly x: number; readonly y: number };\n    };\n  }\n}\n\n/** Options of {@link axisTitle}. */\nexport interface AxisTitleOptions {\n  /**\n   * The id of the axis the title names: `x` or `y` on the presets, the ids\n   * you gave in `cartesianAxes()` in composed charts.\n   */\n  readonly axis: string;\n  /** The title's text; an empty text draws nothing and takes no room. */\n  readonly text: string;\n  /**\n   * Where along the axis the title sits: at the start (left on X axes, the\n   * bottom on Y axes), in the middle or at the end.\n   */\n  readonly align?: 'start' | 'middle' | 'end';\n  /**\n   * Turns titles of left and right axes to read from top to bottom instead\n   * of from bottom to top. Titles of top and bottom axes don't change.\n   */\n  readonly flip?: boolean;\n  /** Space between the title and the axis labels, in px. */\n  readonly gap?: number;\n  /** Extra class names for the title, e.g. `ct-series-b` for a color. */\n  readonly className?: string;\n  /** Replaces the default class: `title` instead of `ct-axis-title`. */\n  readonly classNames?: { readonly title?: string };\n}\n\nconst ANCHORS = { start: 'start', middle: 'middle', end: 'end' } as const;\nconst FLIPPED = { start: 'end', middle: 'middle', end: 'start' } as const;\n\n/**\n * Names an axis with a title next to its labels, on any side of the chart.\n * The layer reserves the room the title needs, so the drawing area shrinks\n * and the title never overlaps the labels, whatever font size the\n * stylesheet gives it. One layer draws one title; give each axis its own.\n * Titles on the same side stack outward in the order of `layers`.\n *\n * The title is an SVG `text` with the classes `ct-axis-title`,\n * `ct-horizontal` or `ct-vertical` and `ct-start` or `ct-end`, styled with\n * `--ct-axis-title-color` and `--ct-axis-title-size` from\n * `@chartist-js/essentials/styles.css`.\n *\n * @example\n * ```ts\n * import { lineChart } from 'chartist';\n * import { axisTitle } from '@chartist-js/essentials';\n * import 'chartist/styles.css';\n * import '@chartist-js/essentials/styles.css';\n *\n * lineChart(\n *   '#chart',\n *   { labels: ['Mon', 'Tue', 'Wed'], series: [[12, 9, 7]] },\n *   {\n *     layers: {\n *       above: [\n *         axisTitle({ axis: 'x', text: 'Day' }),\n *         axisTitle({ axis: 'y', text: 'Visits' })\n *       ]\n *     }\n *   }\n * );\n * ```\n */\nexport function axisTitle(options: AxisTitleOptions): Layer {\n  const { axis, text, align = 'middle', flip = false, gap = 4 } = options;\n  const extra = options.className ? ` ${options.className}` : '';\n  const title = options.classNames?.title ?? 'ct-axis-title';\n\n  const sideOf = (axes: InsetContext['axes']): AxisSide => {\n    const definition = axes.find(candidate => candidate.id === axis);\n    if (!definition) {\n      throw new Error(`Chartist: unknown axis \"${axis}\" in layer \"axisTitle\"`);\n    }\n    return definition.side;\n  };\n  const classesOf = (side: AxisSide) =>\n    `${title} ${side === 'top' || side === 'bottom' ? 'ct-horizontal' : 'ct-vertical'} ${\n      side === 'top' || side === 'left' ? 'ct-start' : 'ct-end'\n    }${extra}`;\n  const measure = (measureText: LayerContext['measureText'], side: AxisSide) =>\n    measureText(text, { classes: classesOf(side).split(' ') });\n\n  return {\n    type: 'axisTitle',\n    coordinates: ['cartesian'],\n    series: [],\n    inset({ axes, measureText }) {\n      const side = sideOf(axes);\n      return text === ''\n        ? undefined\n        : { [side]: measure(measureText, side).height + gap };\n    },\n    compose({ insetArea, measureText }) {\n      const [entry] = Object.entries(insetArea ?? {});\n      if (!entry) {\n        return [];\n      }\n      const [side, box] = entry as [\n        AxisSide,\n        NonNullable<typeof insetArea>[AxisSide] & object\n      ];\n      const metrics = measure(measureText, side);\n      const ascent = textAscent * (metrics.fontSize ?? 12);\n      const horizontal = side === 'top' || side === 'bottom';\n      // The title's line: across the box, leaving the gap on the axis side.\n      const near = side === 'top' || side === 'left';\n      const from = (horizontal ? box.y2 : box.x1) + (near ? 0 : gap);\n      const to = (horizontal ? box.y1 : box.x2) - (near ? gap : 0);\n      let x: number;\n      let y: number;\n      let anchor: 'start' | 'middle' | 'end';\n      let transform: string | undefined;\n      if (horizontal) {\n        x = { start: box.x1, middle: (box.x1 + box.x2) / 2, end: box.x2 }[\n          align\n        ];\n        y = from + ascent;\n        anchor = ANCHORS[align];\n      } else {\n        // Read from bottom to top (−90°), or flipped from top to bottom.\n        x = flip ? to - ascent : from + ascent;\n        y = { start: box.y1, middle: (box.y1 + box.y2) / 2, end: box.y2 }[\n          align\n        ];\n        anchor = (flip ? FLIPPED : ANCHORS)[align];\n        transform = `rotate(${flip ? 90 : -90} ${x} ${y})`;\n      }\n      return [\n        node(\n          'text',\n          { x, y, 'text-anchor': anchor, transform },\n          classesOf(side),\n          { role: 'axisTitle', ctx: { axis, side, text, x, y } }\n        ).text(text)\n      ];\n    }\n  };\n}\n","import {\n  getMultiValue,\n  type AxisContext,\n  type AxisFactory,\n  type AxisTransform,\n  type NormalizedSeriesPrimitiveValue,\n  type ScaleAxis\n} from 'chartist';\n\n/** Options of {@link logAxis}. */\nexport interface LogAxisOptions {\n  /**\n   * The base of the logarithm: the ticks are its powers. Any finite number\n   * above 1, such as 2 for a scale that doubles; default 10.\n   */\n  readonly base?: number;\n  /**\n   * Draws minor grid lines between the ticks, without labels: at 2 to 9\n   * times each power for base 10, or at the powers left out when the ticks\n   * skip some. Style them with `--ct-grid-minor-*`.\n   */\n  readonly minorTicks?: boolean;\n}\n\n/** A number without float noise: `0.30000000000000004` is `0.3`. */\nconst exact = (value: number) => Number(value.toPrecision(15));\n\n/**\n * The exponent of a value in a base, snapped to a whole number when it's\n * one but for float noise (log10(1000) is 2.9999999999999996).\n * @internal\n */\nexport function exponentOf(value: number, base: number): number {\n  const exponent = Math.log(value) / Math.log(base);\n  const whole = Math.round(exponent);\n  return Math.abs(exponent - whole) < 1e-9 ? whole : exponent;\n}\n\n/**\n * The range of a log axis without `low` and `high`: from the largest power\n * at or below the smallest value to the smallest power at or above the\n * largest, one power further each way when both are the same, and 1 to\n * the base without values. `values` are positive.\n * @internal\n */\nexport function logRange(\n  values: readonly number[],\n  base: number\n): { min: number; max: number } {\n  if (values.length === 0) {\n    return { min: 1, max: base };\n  }\n  let low = Math.floor(exponentOf(Math.min(...values), base));\n  let high = Math.ceil(exponentOf(Math.max(...values), base));\n  if (low === high) {\n    low -= 1;\n    high += 1;\n  }\n  return { min: exact(base ** low), max: exact(base ** high) };\n}\n\n/**\n * The ticks and minor ticks of a log axis from `min` to `max`, `length` px\n * long: the powers of the base, every nth when they're closer than\n * `minSpace`, at the exponents divisible by n; the whole multiples of the\n * powers when the range holds fewer than two powers. Minor ticks are the\n * multiples between the powers, or the powers left out.\n * @internal\n */\nexport function logTicks(\n  min: number,\n  max: number,\n  base: number,\n  length: number,\n  minSpace: number\n): { ticks: number[]; minor: number[] } {\n  const span = Math.log(max / min);\n  const px = (value: number) => (length * Math.log(value / min)) / span;\n  const inside = (value: number) =>\n    value >= min * (1 - 1e-12) && value <= max * (1 + 1e-12);\n  const first = Math.floor(exponentOf(min, base));\n  const last = Math.ceil(exponentOf(max, base));\n  // Whole multiples of each power in range, the power itself included.\n  const multiples: number[] = [];\n  for (let k = first; k <= last; k++) {\n    for (let m = 1; m < base; m++) {\n      const value = exact(m * base ** k);\n      if (inside(value)) {\n        multiples.push(value);\n      }\n    }\n  }\n  const powers = multiples.filter(value =>\n    Number.isInteger(exponentOf(value, base))\n  );\n\n  if (powers.length < 2) {\n    // Inside a power: multiples, each at least minSpace px after the last.\n    const ticks: number[] = [];\n    const minor: number[] = [];\n    for (const value of multiples) {\n      const previous = ticks[ticks.length - 1];\n      (previous === undefined || px(value) - px(previous) >= minSpace\n        ? ticks\n        : minor\n      ).push(value);\n    }\n    return { ticks, minor };\n  }\n\n  const every = Math.max(\n    1,\n    Math.ceil(minSpace / ((length * Math.log(base)) / span))\n  );\n  if (every === 1) {\n    return {\n      ticks: powers,\n      minor: multiples.filter(value => !powers.includes(value))\n    };\n  }\n  const shown = (value: number) => exponentOf(value, base) % every === 0;\n  return {\n    ticks: powers.filter(shown),\n    minor: powers.filter(value => !shown(value))\n  };\n}\n\n/**\n * Creates a logarithmic axis, for values that span several orders of\n * magnitude: each power of the base (1, 10, 100, … for base 10) is the\n * same distance from the next, so growth by a factor looks the same\n * everywhere. It goes in the `type` of a preset's `axisX` or `axisY`, or\n * of an axis of `cartesianAxes()`.\n *\n * Without `low` and `high`, the range runs from the power at or below the\n * smallest value to the power at or above the largest; the axis's own\n * `low` and `high` set it exactly. The ticks are the powers, every second\n * or third when they'd be closer than `scaleMinSpace`; the axis's `ticks`\n * replace them. Zero and negative values have no place on a log scale:\n * they don't count towards the range and are drawn at the start of the\n * axis, so a bar for zero has no length. Use `null` for a gap.\n *\n * Trend lines on a log axis are fitted to the logarithms of the values,\n * so they're straight on the axis: an exponential trend on a log Y axis.\n *\n * @example\n * ```ts\n * import { lineChart } from 'chartist';\n * import { logAxis } from '@chartist-js/essentials';\n *\n * lineChart(\n *   '#chart',\n *   {\n *     labels: ['2019', '2020', '2021', '2022', '2023', '2024'],\n *     series: [[120, 980, 4100, 36000, 210000, 850000]]\n *   },\n *   {\n *     axisY: {\n *       type: logAxis({ minorTicks: true }),\n *       labelTransform: value => value.toLocaleString('en-US')\n *     }\n *   }\n * );\n * ```\n * @param options The base and whether to draw minor grid lines.\n */\nexport function logAxis(options: LogAxisOptions = {}): AxisFactory {\n  const { base = 10, minorTicks = false } = options;\n  if (!Number.isFinite(base) || base <= 1) {\n    throw new Error(\n      `Chartist: logAxis needs a base that's a finite number above 1, not ${base}`\n    );\n  }\n  const ln = Math.log(base);\n  const transform: AxisTransform = {\n    forward: value => Math.log(value) / ln,\n    inverse: value => base ** value\n  };\n\n  const create = (context: AxisContext): ScaleAxis => {\n    const { dimension, series, area, extent } = context;\n    const axisOptions = context.options;\n    for (const name of ['low', 'high'] as const) {\n      const value = axisOptions[name];\n      if (value !== undefined && !(value > 0)) {\n        throw new Error(\n          `Chartist: logAxis needs a ${name} above 0, not ${value}`\n        );\n      }\n    }\n    const values = [\n      ...series.flatMap(seriesValues =>\n        seriesValues.map(value =>\n          getMultiValue(value as NormalizedSeriesPrimitiveValue, dimension)\n        )\n      ),\n      extent?.low,\n      extent?.high,\n      axisOptions.highLow?.low,\n      axisOptions.highLow?.high\n    ].filter(\n      (value): value is number =>\n        typeof value === 'number' && value > 0 && Number.isFinite(value)\n    );\n    const fitted = logRange(values, base);\n    const min = axisOptions.low ?? fitted.min;\n    let max = axisOptions.high ?? fitted.max;\n    if (max <= min) {\n      max = exact(min * base);\n    }\n    const length = dimension === 'x' ? area.x2 - area.x1 : area.y1 - area.y2;\n    const span = Math.log(max / min);\n    const computed = logTicks(\n      min,\n      max,\n      base,\n      length,\n      axisOptions.scaleMinSpace || 20\n    );\n    const ticks = axisOptions.ticks\n      ? axisOptions.ticks.filter(tick => Number(tick) > 0)\n      : computed.ticks;\n    return {\n      dimension,\n      kind: 'log',\n      transform,\n      ticks,\n      ...(minorTicks && {\n        minorTicks: computed.minor.filter(value => !ticks.includes(value))\n      }),\n      range: { min, max },\n      length,\n      project: value => {\n        const number = Number(\n          getMultiValue(value as NormalizedSeriesPrimitiveValue, dimension)\n        );\n        return number > 0 ? (length * Math.log(number / min)) / span : 0;\n      }\n    };\n  };\n\n  return { kind: 'log', transform, create };\n}\n","/**\n * Target line layer: a line across the chart area at a constant value on\n * one axis, such as a goal, a limit or an average, with an optional label.\n */\nimport { node, textAscent, type Layer } from 'chartist';\n\n/**\n * The options of the {@link targetLine} layer: the line's value, its\n * label and class, and the axis it's on. For several lines, add a layer\n * per line.\n */\nexport interface TargetLineOptions {\n  /**\n   * The value the line is drawn at, on the layer's axis. On a step axis,\n   * the position by index, as for the axis's ticks.\n   */\n  readonly value: number;\n  /** The text drawn next to the line; no label without it. */\n  readonly label?: string;\n  /** Extra classes for the line and its label, e.g. `ct-series-b`. */\n  readonly className?: string;\n  /**\n   * The id of the axis the value is on: a Y axis draws a horizontal line,\n   * an X axis a vertical one. Default: the first Y axis.\n   */\n  readonly axis?: string;\n  /**\n   * Where the label sits along the line: at the `end` (right, or top for\n   * a vertical line) or the `start` (left, or bottom).\n   */\n  readonly labelPosition?: 'start' | 'end';\n  /**\n   * Replaces the classes of what the layer draws: `line`\n   * (`ct-target-line`) and `label` (`ct-target-label`).\n   */\n  readonly classNames?: {\n    readonly line?: string;\n    readonly label?: string;\n  };\n}\n\nconst CLASS_NAMES = {\n  line: 'ct-target-line',\n  label: 'ct-target-label'\n};\n\n/** The distance in px between a label and its line or the area's edge. */\nconst LABEL_INSET = 4;\n\n/**\n * Creates a layer that draws a line across the chart area at a constant\n * value on one axis, such as a goal or a limit (`line.ct-target-line`).\n * On a Y axis the line is horizontal, on an X axis vertical. It can have\n * a label, drawn as SVG text (`text.ct-target-label`) next to it inside\n * the chart area, and a class, e.g. `ct-series-b` for a series' color.\n * The axis widens to include the value, unless its own `low` or `high`\n * leave it out; a line outside the axis isn't drawn. For several lines,\n * add a layer per line.\n *\n * @example\n * ```ts\n * import { lineChart } from 'chartist';\n * import { targetLine } from '@chartist-js/essentials';\n * import 'chartist/styles.css';\n * import '@chartist-js/essentials/styles.css';\n *\n * lineChart(\n *   '#chart',\n *   { labels: ['Jan', 'Feb', 'Mar', 'Apr'], series: [[620, 810, 740, 930]] },\n *   {\n *     low: 0,\n *     layers: {\n *       above: [\n *         targetLine({ value: 700, label: 'Min' }),\n *         targetLine({ value: 1000, label: 'Goal', className: 'ct-series-b' })\n *       ]\n *     }\n *   }\n * );\n * ```\n */\nexport function targetLine(options: TargetLineOptions): Layer {\n  const { value, label, className } = options;\n  if (!Number.isFinite(value)) {\n    throw new Error('Layer \"targetLine\" needs a value');\n  }\n  const classNames = { ...CLASS_NAMES, ...options.classNames };\n  const atStart = options.labelPosition === 'start';\n  return {\n    type: 'targetLine',\n    coordinates: ['cartesian'],\n    // The layer draws no series, so the data shapes no axis range for it.\n    series: [],\n    extent({ axes }) {\n      const id = options.axis ?? axes.y;\n      return id === undefined ? {} : { [id]: { low: value, high: value } };\n    },\n    compose({ area, axes, measureText }) {\n      const all = axes.all ?? [];\n      const axis =\n        options.axis === undefined\n          ? all.find(candidate => candidate.dimension === 'y')\n          : all.find(candidate => candidate.id === options.axis);\n      if (!axis) {\n        throw new Error(\n          options.axis === undefined\n            ? 'Layer \"targetLine\" needs a y axis'\n            : `Chartist: unknown axis \"${options.axis}\" in layer \"targetLine\"`\n        );\n      }\n      const horizontal = axis.dimension === 'y';\n\n      const relative = axis.project(value, value);\n      // Values outside the axis (its own low and high win) draw nothing.\n      if (\n        !Number.isFinite(relative) ||\n        relative < -1e-9 ||\n        relative > axis.length + 1e-9\n      ) {\n        return [];\n      }\n      const ends = horizontal\n        ? {\n            x1: area.x1,\n            y1: area.y1 - relative,\n            x2: area.x2,\n            y2: area.y1 - relative\n          }\n        : {\n            x1: area.x1 + relative,\n            y1: area.y2,\n            x2: area.x1 + relative,\n            y2: area.y1\n          };\n      const extra = className ? ` ${className}` : '';\n      const lineNode = node('line', ends, `${classNames.line}${extra}`, {\n        role: 'targetLine',\n        ctx: {\n          axis,\n          value,\n          ...(label !== undefined && { label }),\n          ...ends\n        }\n      });\n      if (label === undefined || label === '') {\n        return [lineNode];\n      }\n\n      const labelClasses = `${classNames.label}${extra}`;\n      let position: { x: number; y: number; anchor: 'start' | 'end' };\n      if (horizontal) {\n        // Just above the line, inset from the area's edge.\n        position = {\n          x: atStart ? area.x1 + LABEL_INSET : area.x2 - LABEL_INSET,\n          y: ends.y1 - LABEL_INSET,\n          anchor: atStart ? 'start' : 'end'\n        };\n      } else {\n        // Just right of the line, at its top (end) or bottom (start).\n        const fontSize =\n          measureText(label, { classes: labelClasses.split(' ') }).fontSize ??\n          12;\n        position = {\n          x: ends.x1 + LABEL_INSET,\n          y: atStart\n            ? area.y1 - LABEL_INSET\n            : area.y2 + LABEL_INSET + textAscent * fontSize,\n          anchor: 'start'\n        };\n      }\n      const labelNode = node(\n        'text',\n        { x: position.x, y: position.y, 'text-anchor': position.anchor },\n        labelClasses,\n        {\n          role: 'targetLabel',\n          ctx: {\n            axis,\n            value,\n            text: label,\n            x: position.x,\n            y: position.y\n          }\n        }\n      ).text(label);\n      return [lineNode, labelNode];\n    }\n  };\n}\n","import type { ScaleAxis } from 'chartist';\n\n/**\n * How far a line's ends move right on a step axis with `align: 'center'`:\n * half a step, so they sit where bars are centered. The line and band\n * layers of the core place their points the same way.\n */\nexport function centerShift(\n  axisX: ScaleAxis,\n  align: 'start' | 'center' | undefined\n): number {\n  return align === 'center' && axisX.kind === 'step' && !axisX.stretch\n    ? (axisX.step ?? 0) / 2\n    : 0;\n}\n","/**\n * Trend line layer: a least-squares straight line through each series'\n * values, drawn in the series' color.\n */\nimport {\n  alphaNumerate,\n  getMultiValue,\n  isDataHoleValue,\n  node,\n  type AxisTransform,\n  type Layer,\n  type NormalizedSeries\n} from 'chartist';\nimport { centerShift } from './centerShift.ts';\n\n/**\n * The options of the {@link trendLine} layer. Without them, it draws a\n * trend line for every series, on the first X and Y axis.\n */\nexport interface TrendLineOptions {\n  /** Series to draw a trend line for, by index or name; default: all series. */\n  readonly series?: readonly (number | string)[];\n  /** The id of the X axis to draw on; default: the first X axis. */\n  readonly x?: string;\n  /** The id of the Y axis to draw on; default: the first Y axis. */\n  readonly y?: string;\n  /**\n   * Where the line's ends sit on a step axis: at the `start` of their\n   * steps, as the points of `line()`, or at the `center`, where bars\n   * are centered.\n   */\n  readonly align?: 'start' | 'center';\n  /**\n   * Replaces the classes of what the layer draws: `series` (`ct-series`)\n   * and `line` (`ct-trend-line`).\n   */\n  readonly classNames?: {\n    readonly series?: string;\n    readonly line?: string;\n  };\n}\n\nconst CLASS_NAMES = {\n  series: 'ct-series',\n  line: 'ct-trend-line'\n};\n\n/**\n * A fitted line `y = slope * x + intercept`, from `x1` to `x2`, in the\n * axes' transformed values when they have transforms.\n */\ninterface Fit {\n  readonly slope: number;\n  readonly intercept: number;\n  /** Pearson's r of the values; absent when they're all equal. */\n  readonly correlation?: number;\n  readonly x1: number;\n  readonly x2: number;\n}\n\n/**\n * Fits a straight line through a series' values by least squares: X is\n * the value's index (`byIndex`, for step axes) or its `x`, and both go\n * through their axis's transform when it has one, so the line is straight\n * on that axis. Holes and values without a finite number for X or Y are\n * skipped. Fewer than two values, or values that all share one X, fit no\n * line.\n */\nfunction fit(\n  values: NormalizedSeries,\n  byIndex: boolean,\n  tx?: AxisTransform,\n  ty?: AxisTransform\n): Fit | undefined {\n  const xs: number[] = [];\n  const ys: number[] = [];\n  values.forEach((value, index) => {\n    let y = isDataHoleValue(value) ? NaN : getMultiValue(value, 'y');\n    let x = byIndex ? index : getMultiValue(value, 'x');\n    if (typeof x === 'number' && typeof y === 'number') {\n      x = tx && !byIndex ? tx.forward(x) : x;\n      y = ty ? ty.forward(y) : y;\n      if (Number.isFinite(x) && Number.isFinite(y)) {\n        xs.push(x);\n        ys.push(y);\n      }\n    }\n  });\n  if (xs.length < 2) {\n    return undefined;\n  }\n  const mean = (list: number[]) =>\n    list.reduce((sum, value) => sum + value, 0) / list.length;\n  const meanX = mean(xs);\n  const meanY = mean(ys);\n  let covariance = 0;\n  let variance = 0;\n  let varianceY = 0;\n  xs.forEach((x, i) => {\n    covariance += (x - meanX) * (ys[i] - meanY);\n    variance += (x - meanX) ** 2;\n    varianceY += (ys[i] - meanY) ** 2;\n  });\n  if (variance === 0) {\n    return undefined;\n  }\n  const slope = covariance / variance;\n  return {\n    slope,\n    intercept: meanY - slope * meanX,\n    // Undefined for values that are all equal (0 / 0): left out.\n    ...(varianceY > 0 && {\n      correlation: covariance / Math.sqrt(variance * varianceY)\n    }),\n    x1: Math.min(...xs),\n    x2: Math.max(...xs)\n  };\n}\n\n/** A fitted number as a value on its axis. */\nconst valueOf = (transform: AxisTransform | undefined, value: number) =>\n  transform ? transform.inverse(value) : value;\n\n/** True when every value that isn't a hole has a number for X. */\nfunction hasX(values: NormalizedSeries): boolean {\n  const present = values.filter(value => !isDataHoleValue(value));\n  return (\n    present.length > 0 &&\n    present.every(value => typeof getMultiValue(value, 'x') === 'number')\n  );\n}\n\n/**\n * Creates a layer that draws a trend line for each series: the straight\n * line that fits its values best (least squares), from its smallest to its\n * largest X, as a `line.ct-trend-line` in a series group\n * (`g.ct-series.ct-series-a`), so it takes the series' color. On a step\n * axis X is the value's index, on a scale axis the value's `x`. Holes are\n * skipped, and a series with fewer than two values gets no line. The Y\n * axis widens to include the line's ends. On an axis with a transform,\n * such as a log axis, the line is fitted to the transformed values, so\n * it's straight on that axis: an exponential trend on a log Y axis. Add\n * it next to the `line()` or `bar()` layer that draws the values.\n *\n * @example\n * ```ts\n * import { lineChart } from 'chartist';\n * import { trendLine } from '@chartist-js/essentials';\n * import 'chartist/styles.css';\n * import '@chartist-js/essentials/styles.css';\n *\n * lineChart(\n *   '#chart',\n *   {\n *     labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],\n *     series: [{ name: 'sales', data: [620, 810, 740, 930, 880, 1020] }]\n *   },\n *   { layers: { above: [trendLine()] } }\n * );\n * ```\n */\nexport function trendLine(options: TrendLineOptions = {}): Layer {\n  const classNames = { ...CLASS_NAMES, ...options.classNames };\n  return {\n    type: 'trendLine',\n    coordinates: ['cartesian'],\n    axes: { x: options.x, y: options.y },\n    series: options.series,\n    extent({ normalized, axes, transforms: { x: tx, y: ty } = {} }) {\n      if (axes.y === undefined) {\n        return {};\n      }\n      // The axes don't exist yet: values with an `x` are read as on a\n      // scale axis, others by index, as a step axis places them.\n      const ends = normalized.series.flatMap(values => {\n        const fitted = fit(values, !hasX(values), tx, ty);\n        return fitted\n          ? [fitted.x1, fitted.x2].map(x =>\n              valueOf(ty, fitted.slope * x + fitted.intercept)\n            )\n          : [];\n      });\n      return ends.length > 0\n        ? { [axes.y]: { low: Math.min(...ends), high: Math.max(...ends) } }\n        : {};\n    },\n    compose({ data, area, axes, normalized, seriesIndexes }) {\n      const { x: axisX, y: axisY } = axes;\n      if (!axisX || !axisY || !normalized) {\n        throw new Error('Layer \"trendLine\" needs an x and a y axis');\n      }\n      const byIndex = axisX.kind === 'step';\n      const shift = centerShift(axisX, options.align);\n      const tx = byIndex ? undefined : axisX.transform;\n      const ty = axisY.transform;\n\n      return data.series.flatMap((series, localIndex) => {\n        const fitted = fit(normalized.series[localIndex], byIndex, tx, ty);\n        if (!fitted) {\n          return [];\n        }\n        const seriesIndex = seriesIndexes?.[localIndex] ?? localIndex;\n        const { slope, intercept, correlation } = fitted;\n        const at = (x: number) => ({\n          x: area.x1 + shift + axisX.project(valueOf(tx, x), x),\n          y: area.y1 - axisY.project(valueOf(ty, slope * x + intercept))\n        });\n        const start = at(fitted.x1);\n        const end = at(fitted.x2);\n        const ends = { x1: start.x, y1: start.y, x2: end.x, y2: end.y };\n        const rawSeries = {\n          name: series.name,\n          className: series.className,\n          meta: series.meta,\n          data: series.values\n        };\n        const seriesContext = {\n          series: rawSeries,\n          seriesIndex,\n          meta: series.meta\n        };\n        const group = node(\n          'g',\n          {},\n          `${classNames.series} ${\n            series.className ||\n            `${classNames.series}-${alphaNumerate(seriesIndex)}`\n          }`,\n          { role: 'series', ctx: seriesContext }\n        );\n        return [\n          group.append(\n            node('line', ends, classNames.line, {\n              role: 'trendLine',\n              ctx: {\n                seriesIndex,\n                slope,\n                intercept,\n                ...(correlation !== undefined && { correlation }),\n                ...ends\n              }\n            })\n          )\n        ];\n      });\n    }\n  };\n}\n","import {\n  findAll,\n  node,\n  textAscent,\n  type Area,\n  type ChartPadding,\n  type Layer,\n  type LayerContext,\n  type MeasureText,\n  type NodeRoles,\n  type SceneNode\n} from 'chartist';\n\n/** The roles whose nodes get labels. */\nexport type ValueLabelRole = 'point' | 'bar';\n\n/** Where a point's label sits. */\nexport type PointLabelPosition =\n  | 'above'\n  | 'below'\n  | 'left'\n  | 'right'\n  | 'center';\n\n/**\n * Where a bar's label sits, from the bar's base to its value: past its\n * end, inside its end, in its middle or inside its base.\n */\nexport type BarLabelPosition = 'end' | 'inside-end' | 'center' | 'inside-base';\n\n/**\n * The value a label is about: what `format` gets. It has the fields of\n * the item `@chartist-js/tooltips` gives its `format`, under the same\n * names, so a function written for one mostly works for the other.\n * Checking `item.role` narrows `item.context` to that role's context.\n */\nexport type ValueLabelItem<R extends ValueLabelRole = ValueLabelRole> = {\n  [K in R]: {\n    /** The role of the labeled node: `point` or `bar`. */\n    readonly role: K;\n    /** The series' index in the chart's data. */\n    readonly seriesIndex: number;\n    /** The value's index in its series. */\n    readonly valueIndex: number;\n    /** The value: a number, or `{ x, y }` when it has both. */\n    readonly value: number | { readonly x: number; readonly y: number };\n    /** The value's `meta`. */\n    readonly meta: unknown;\n    /** The series as given in the data. */\n    readonly series: unknown;\n    /** The series' `name`, when it has one. */\n    readonly seriesName?: string;\n    /** The chart's label at the value's index. */\n    readonly label?: string;\n    /** The labeled node's data context. */\n    readonly context: NodeRoles[K]['ctx'];\n  };\n}[R];\n\n/** The context of a `valueLabel` node. */\nexport interface ValueLabelContext {\n  /** The role of the node the label is for. */\n  readonly role: ValueLabelRole;\n  /** The series' index in the chart's data. */\n  readonly seriesIndex: number;\n  /** The value's index in its series. */\n  readonly valueIndex: number;\n  /** The labeled value, as the node has it. */\n  readonly value: unknown;\n  /** The value's `meta`. */\n  readonly meta: unknown;\n  /** The series as given in the data. */\n  readonly series: unknown;\n  /** The label's text. */\n  readonly text: string;\n  /** Where the label ended up, after fitting. */\n  readonly position: PointLabelPosition | BarLabelPosition;\n  /** Px from the left edge of the SVG: where the text is anchored. */\n  readonly x: number;\n  /** Px from the top edge of the SVG: the first line's baseline. */\n  readonly y: number;\n}\n\ndeclare module 'chartist' {\n  interface NodeRoles {\n    /**\n     * A label of the `valueLabels()` layer: SVG `text`, or a\n     * `foreignObject` with a `span` (class `ct-value-label`).\n     */\n    valueLabel: { ctx: ValueLabelContext; attrs: object };\n  }\n}\n\n/** Options of {@link valueLabels}. */\nexport interface ValueLabelsOptions<R extends ValueLabelRole = ValueLabelRole> {\n  /** The nodes that get labels: `point`, `bar` or both (the default). */\n  readonly roles?: readonly R[];\n  /** The series to label, by index or name; default: all of them. */\n  readonly series?: readonly (number | string)[];\n  /** Where point labels sit; default `above`. */\n  readonly pointPosition?: PointLabelPosition;\n  /**\n   * Where bar labels sit; default `end`, and `center` for segments of\n   * stacked bars.\n   */\n  readonly barPosition?: BarLabelPosition;\n  /**\n   * The gap in px between a point's center, or a bar's end or base, and\n   * the label's nearest edge; default 8 for points and 4 for bars.\n   */\n  readonly offset?: number;\n  /**\n   * The label's text for a value: a string or a number. `undefined` keeps\n   * the default text, `null` or `''` draw no label, and `\\n` starts a new\n   * line.\n   */\n  readonly format?: (\n    item: ValueLabelItem<R>\n  ) => string | number | null | undefined;\n  /** `Intl.NumberFormat` options for the default text. */\n  readonly numberFormat?: Intl.NumberFormatOptions;\n  /**\n   * The locale of the default text; default: the runtime's. Set it when\n   * charts render on a server, so the text doesn't depend on its locale.\n   */\n  readonly locale?: string | readonly string[];\n  /**\n   * `fit` (the default) moves labels that don't fit their bar or would\n   * leave the chart; `show` draws every label where its position puts it.\n   */\n  readonly overflow?: 'fit' | 'show';\n  /** SVG `text` (the default) or HTML in a `foreignObject`. */\n  readonly labels?: 'svg' | 'html';\n  /**\n   * Replace the classes: `group` (`ct-value-labels`), `label`\n   * (`ct-value-label`) and `inside` (`ct-value-label-inside`).\n   */\n  readonly classNames?: {\n    readonly group?: string;\n    readonly label?: string;\n    readonly inside?: string;\n  };\n}\n\nconst POINT_POSITIONS = ['above', 'below', 'left', 'right', 'center'];\nconst BAR_POSITIONS = ['end', 'inside-end', 'center', 'inside-base'];\n\n/** A label's box in px, and where its text is anchored across it. */\ninterface Box {\n  readonly left: number;\n  readonly top: number;\n  readonly width: number;\n  readonly height: number;\n  readonly anchor: 'start' | 'middle' | 'end';\n}\n\n/** What a label is drawn for: a value at a point or along a bar. */\ninterface Source {\n  readonly role: ValueLabelRole;\n  readonly ctx: Record<string, unknown> & {\n    readonly seriesIndex: number;\n    readonly valueIndex: number;\n  };\n  readonly classes: readonly string[];\n}\n\n/** The value as `format` gets it: a number, or `{ x, y }` with both. */\nfunction plainValue(value: unknown): ValueLabelItem['value'] | undefined {\n  if (typeof value === 'number') {\n    return value;\n  }\n  const { x, y } = (value ?? {}) as { x?: unknown; y?: unknown };\n  if (typeof x === 'number' && typeof y === 'number') {\n    return { x, y };\n  }\n  return typeof y === 'number' ? y : typeof x === 'number' ? x : undefined;\n}\n\n/** The value along the value axis: X on horizontal bars, else Y. */\nfunction axisValue(value: unknown, horizontal: boolean): number | undefined {\n  if (typeof value === 'number') {\n    return Number.isFinite(value) ? value : undefined;\n  }\n  const along = (value as { x?: unknown; y?: unknown } | undefined)?.[\n    horizontal ? 'x' : 'y'\n  ];\n  return typeof along === 'number' && Number.isFinite(along)\n    ? along\n    : undefined;\n}\n\n/** The box of a label of `width` × `height` px at a point. */\nfunction pointBox(\n  x: number,\n  y: number,\n  width: number,\n  height: number,\n  position: PointLabelPosition,\n  offset: number\n): Box {\n  switch (position) {\n    case 'below':\n      return {\n        left: x - width / 2,\n        top: y + offset,\n        width,\n        height,\n        anchor: 'middle'\n      };\n    case 'left':\n      return {\n        left: x - offset - width,\n        top: y - height / 2,\n        width,\n        height,\n        anchor: 'end'\n      };\n    case 'right':\n      return {\n        left: x + offset,\n        top: y - height / 2,\n        width,\n        height,\n        anchor: 'start'\n      };\n    case 'center':\n      return {\n        left: x - width / 2,\n        top: y - height / 2,\n        width,\n        height,\n        anchor: 'middle'\n      };\n    default:\n      return {\n        left: x - width / 2,\n        top: y - offset - height,\n        width,\n        height,\n        anchor: 'middle'\n      };\n  }\n}\n\n/**\n * The box of a label along a bar from (x1, y1) to (x2, y2), in the\n * direction of its value: up and right for a value of zero or more.\n */\nfunction barBox(\n  bar: { x1: number; y1: number; x2: number; y2: number },\n  horizontal: boolean,\n  negative: boolean,\n  width: number,\n  height: number,\n  position: BarLabelPosition,\n  offset: number\n): Box {\n  // Along the bar: the label's start and end edge, as offsets from a\n  // point, in the direction the bar grows (1: right or down in px).\n  const growth = horizontal ? (negative ? -1 : 1) : negative ? 1 : -1;\n  const extent = horizontal ? width : height;\n  const base = horizontal ? bar.x1 : bar.y1;\n  const end = horizontal ? bar.x2 : bar.y2;\n  // The label's near edge, in the direction of growth, and which way the\n  // label extends from it.\n  let near: number;\n  let toward: number;\n  if (position === 'end') {\n    near = end + growth * offset;\n    toward = growth;\n  } else if (position === 'inside-end') {\n    near = end - growth * offset;\n    toward = -growth;\n  } else if (position === 'inside-base') {\n    near = base + growth * offset;\n    toward = growth;\n  } else {\n    near = (base + end) / 2 - (growth * extent) / 2;\n    toward = growth;\n  }\n  const start = toward > 0 ? near : near - extent;\n  if (horizontal) {\n    const across = (bar.y1 + bar.y2) / 2;\n    return {\n      left: start,\n      top: across - height / 2,\n      width,\n      height,\n      anchor: position === 'center' ? 'middle' : toward > 0 ? 'start' : 'end'\n    };\n  }\n  const across = (bar.x1 + bar.x2) / 2;\n  return {\n    left: across - width / 2,\n    top: start,\n    width,\n    height,\n    anchor: 'middle'\n  };\n}\n\n/** Moves a box inward by the least amount so it stays in the bounds. */\nfunction inside(box: Box, bounds: Area): Box {\n  const left = Math.max(bounds.x1, Math.min(box.left, bounds.x2 - box.width));\n  const top = Math.max(bounds.y2, Math.min(box.top, bounds.y1 - box.height));\n  return { ...box, left, top };\n}\n\nconst crosses = (box: Box, bounds: Area) =>\n  box.left < bounds.x1 ||\n  box.top < bounds.y2 ||\n  box.left + box.width > bounds.x2 ||\n  box.top + box.height > bounds.y1;\n\n/** The chart area grown by the chart's padding: where labels may go. */\nconst boundsOf = (area: Area, padding: ChartPadding): Area => {\n  const x1 = area.x1 - padding.left;\n  const x2 = area.x2 + padding.right;\n  const y2 = area.y2 - padding.top;\n  const y1 = area.y1 + padding.bottom;\n  return { x1, x2, y1, y2, width: x2 - x1, height: y1 - y2 };\n};\n\n/**\n * The points and bars in the series groups of the drawn nodes, with\n * their series' classes.\n */\nfunction sourcesOf(\n  drawn: readonly SceneNode[],\n  roles: ReadonlySet<ValueLabelRole>\n): Source[] {\n  // Series groups can sit inside other groups, as on the presets.\n  const groups = drawn.flatMap(top => findAll(top, { role: 'series' }));\n  return groups.flatMap(top => {\n    // A series group's classes after its group class: `ct-series-b`, or\n    // the series' own className.\n    const classes = top.classes.slice(1);\n    const points = roles.has('point') ? findAll(top, { role: 'point' }) : [];\n    const sources: Source[] = points.map(point => ({\n      role: 'point',\n      ctx: point.ctx as unknown as Source['ctx'],\n      classes\n    }));\n    if (roles.has('point') && points.length === 0) {\n      // A line without points: its values' positions on the line.\n      for (const line of findAll(top, { role: 'line' })) {\n        for (const element of line.ctx.path.pathElements) {\n          const data = element.data as\n            | { value?: unknown; valueIndex?: number; meta?: unknown }\n            | undefined;\n          if (data) {\n            sources.push({\n              role: 'point',\n              ctx: {\n                series: line.ctx.series,\n                seriesIndex: line.ctx.seriesIndex,\n                valueIndex: data.valueIndex ?? 0,\n                value: data.value,\n                meta: data.meta,\n                x: element.x,\n                y: element.y\n              },\n              classes\n            });\n          }\n        }\n      }\n    }\n    if (roles.has('bar')) {\n      for (const bar of findAll(top, { role: 'bar' })) {\n        sources.push({\n          role: 'bar',\n          ctx: bar.ctx as unknown as Source['ctx'],\n          classes\n        });\n      }\n    }\n    return sources;\n  });\n}\n\n/** One label's lines measured: the widest line and the lines' height. */\nfunction measureLines(\n  lines: readonly string[],\n  measureText: MeasureText,\n  classes: readonly string[]\n) {\n  const metrics = lines.map(line => measureText(line, { classes }));\n  const lineHeight = Math.max(...metrics.map(metric => metric.height));\n  return {\n    width: Math.max(...metrics.map(metric => metric.width)),\n    height: lineHeight * lines.length,\n    lineHeight,\n    fontSize: metrics[0].fontSize ?? lineHeight / 1.2\n  };\n}\n\n/**\n * Creates a layer that writes each value next to the point or bar that\n * shows it: above points, past the ends of bars, and in the middle of\n * stacked segments. It draws from where the chart's other layers drew,\n * after stacking, offsets and `compose` listeners, so add it as an extra\n * layer: `layers.above` on a preset, anywhere in a composed chart.\n *\n * The text is the value along the value axis, written with\n * `Intl.NumberFormat`; `format` gets the same item as the `format` of\n * `@chartist-js/tooltips`. Labels that don't fit their bar, or would\n * leave the chart, move to a place where they fit. They're SVG `text`, so\n * they render on servers and in the terminal, styled with\n * `--ct-value-label-color`, `--ct-value-label-inside-color` and\n * `--ct-value-label-size` from `@chartist-js/essentials/styles.css`.\n *\n * @example\n * ```ts\n * import { barChart } from 'chartist';\n * import { valueLabels } from '@chartist-js/essentials';\n * import 'chartist/styles.css';\n * import '@chartist-js/essentials/styles.css';\n *\n * barChart(\n *   '#chart',\n *   { labels: ['Q1', 'Q2', 'Q3'], series: [[1250, 1830, 1470]] },\n *   {\n *     layers: {\n *       above: [\n *         valueLabels({ format: item => `${item.value} units` })\n *       ]\n *     }\n *   }\n * );\n * ```\n */\nexport function valueLabels<R extends ValueLabelRole = ValueLabelRole>(\n  options: ValueLabelsOptions<R> = {}\n): Layer {\n  const fail = (what: string, value: unknown) => {\n    throw new Error(\n      `Chartist: layer \"valueLabels\" got ${JSON.stringify(value)} for ${what}`\n    );\n  };\n  if (\n    options.pointPosition &&\n    !POINT_POSITIONS.includes(options.pointPosition)\n  ) {\n    fail('pointPosition', options.pointPosition);\n  }\n  if (options.barPosition && !BAR_POSITIONS.includes(options.barPosition)) {\n    fail('barPosition', options.barPosition);\n  }\n  if (\n    options.overflow &&\n    options.overflow !== 'fit' &&\n    options.overflow !== 'show'\n  ) {\n    fail('overflow', options.overflow);\n  }\n  if (options.offset !== undefined && !Number.isFinite(options.offset)) {\n    fail('offset', options.offset);\n  }\n  const roles = new Set<ValueLabelRole>(options.roles ?? ['point', 'bar']);\n  const classNames = {\n    group: 'ct-value-labels',\n    label: 'ct-value-label',\n    inside: 'ct-value-label-inside',\n    ...options.classNames\n  };\n  const fit = options.overflow !== 'show';\n  const html = options.labels === 'html';\n  const numbers = new Intl.NumberFormat(\n    options.locale as string | string[] | undefined,\n    options.numberFormat\n  );\n\n  const textOf = (\n    source: Source,\n    context: LayerContext\n  ): string | undefined => {\n    const { ctx, role } = source;\n    const horizontal = role === 'bar' && Boolean(ctx.horizontal);\n    const along = axisValue(ctx.value, horizontal);\n    if (along === undefined) {\n      return undefined;\n    }\n    const series = ctx.series as { name?: unknown } | undefined;\n    const own = options.format?.({\n      role,\n      seriesIndex: ctx.seriesIndex,\n      valueIndex: ctx.valueIndex,\n      value: plainValue(ctx.value) ?? along,\n      meta: ctx.meta,\n      series: ctx.series,\n      seriesName: typeof series?.name === 'string' ? series.name : undefined,\n      label: context.data.labels?.[ctx.valueIndex] as string | undefined,\n      context: ctx\n    } as unknown as ValueLabelItem<R>);\n    if (own === null || own === '') {\n      return undefined;\n    }\n    return own === undefined ? numbers.format(along) : String(own);\n  };\n\n  const selected = (source: Source) =>\n    !options.series ||\n    options.series.some(selector =>\n      typeof selector === 'number'\n        ? selector === source.ctx.seriesIndex\n        : (source.ctx.series as { name?: unknown } | undefined)?.name ===\n          selector\n    );\n\n  const labelOf = (\n    source: Source,\n    context: LayerContext,\n    bounds: Area\n  ): SceneNode | undefined => {\n    const text = textOf(source, context);\n    if (text === undefined) {\n      return undefined;\n    }\n    const lines = text.split('\\n');\n    const classes = [classNames.label, ...source.classes];\n    const size = measureLines(lines, context.measureText, classes);\n    const { ctx } = source;\n    let position: PointLabelPosition | BarLabelPosition;\n    let box: Box;\n    if (source.role === 'point') {\n      position = options.pointPosition ?? 'above';\n      box = pointBox(\n        Number(ctx.x),\n        Number(ctx.y),\n        size.width,\n        size.height,\n        position,\n        position === 'center' ? 0 : (options.offset ?? 8)\n      );\n      if (fit) {\n        box = inside(box, bounds);\n      }\n    } else {\n      const bar = ctx as unknown as {\n        x1: number;\n        y1: number;\n        x2: number;\n        y2: number;\n        horizontal?: boolean;\n        stacked?: boolean;\n      };\n      const horizontal = Boolean(bar.horizontal);\n      const negative = (axisValue(ctx.value, horizontal) ?? 0) < 0;\n      const offset = options.offset ?? 4;\n      const place = (at: BarLabelPosition) =>\n        barBox(\n          bar,\n          horizontal,\n          negative,\n          size.width,\n          size.height,\n          at,\n          at === 'center' ? 0 : offset\n        );\n      position = options.barPosition ?? (bar.stacked ? 'center' : 'end');\n      if (fit && position !== 'end') {\n        const length = Math.abs(horizontal ? bar.x2 - bar.x1 : bar.y2 - bar.y1);\n        const room = position === 'center' ? length : length - offset;\n        if ((horizontal ? size.width : size.height) > room) {\n          if (bar.stacked) {\n            return undefined;\n          }\n          position = 'end';\n        }\n      }\n      box = place(position);\n      if (fit && position === 'end' && crosses(box, bounds)) {\n        const along = horizontal\n          ? box.left < bounds.x1 || box.left + box.width > bounds.x2\n          : box.top < bounds.y2 || box.top + box.height > bounds.y1;\n        if (along) {\n          position = 'inside-end';\n          box = place(position);\n        }\n      }\n      if (fit) {\n        box = inside(box, bounds);\n      }\n      if (position !== 'end') {\n        classes.push(classNames.inside);\n      }\n    }\n    const x =\n      box.anchor === 'start'\n        ? box.left\n        : box.anchor === 'end'\n          ? box.left + box.width\n          : box.left + box.width / 2;\n    const y = box.top + textAscent * size.fontSize;\n    const labelCtx: ValueLabelContext = {\n      role: source.role,\n      seriesIndex: ctx.seriesIndex,\n      valueIndex: ctx.valueIndex,\n      value: ctx.value,\n      meta: ctx.meta,\n      series: ctx.series,\n      text,\n      position,\n      x,\n      y\n    };\n    const className = classes.join(' ');\n    if (html) {\n      const attrs = {\n        x: box.left,\n        y: box.top,\n        width: box.width,\n        height: box.height,\n        style: 'overflow: visible;'\n      };\n      return node('foreignObject', attrs, '', {\n        role: 'valueLabel',\n        ctx: labelCtx\n      }).append(node('span', {}, className).text(text));\n    }\n    const label = node('text', { x, y, 'text-anchor': box.anchor }, className, {\n      role: 'valueLabel',\n      ctx: labelCtx\n    });\n    return lines.length === 1\n      ? label.text(text)\n      : lines.reduce(\n          (parent, line, index) =>\n            parent.append(\n              node('tspan', {\n                x,\n                ...(index > 0 && { dy: size.lineHeight })\n              }).text(line)\n            ),\n          label\n        );\n  };\n\n  return {\n    type: 'valueLabels',\n    coordinates: ['cartesian'],\n    series: [],\n    compose: () => [],\n    annotate(drawn, context) {\n      const bounds = boundsOf(context.area, context.padding);\n      const labels = sourcesOf(drawn, roles)\n        .filter(selected)\n        .flatMap(source => labelOf(source, context, bounds) ?? []);\n      return labels.length\n        ? [\n            labels.reduce(\n              (group, label) => group.append(label),\n              node('g', {}, classNames.group)\n            )\n          ]\n        : [];\n    }\n  };\n}\n"],"mappings":";;;AAwDA,MAAM,UAAU;CAAE,OAAO;CAAS,QAAQ;CAAU,KAAK;AAAM;AAC/D,MAAM,UAAU;CAAE,OAAO;CAAO,QAAQ;CAAU,KAAK;AAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmC/D,SAAgB,UAAU,SAAkC;CAC1D,MAAM,EAAE,MAAM,MAAM,QAAQ,UAAU,OAAO,OAAO,MAAM,MAAM;CAChE,MAAM,QAAQ,QAAQ,YAAY,IAAI,QAAQ,cAAc;CAC5D,MAAM,QAAQ,QAAQ,YAAY,SAAS;CAE3C,MAAM,UAAU,SAAyC;EACvD,MAAM,aAAa,KAAK,MAAK,cAAa,UAAU,OAAO,IAAI;EAC/D,IAAI,CAAC,YACH,MAAM,IAAI,MAAM,2BAA2B,KAAK,uBAAuB;EAEzE,OAAO,WAAW;CACpB;CACA,MAAM,aAAa,SACjB,GAAG,MAAM,GAAG,SAAS,SAAS,SAAS,WAAW,kBAAkB,cAAc,GAChF,SAAS,SAAS,SAAS,SAAS,aAAa,WAChD;CACL,MAAM,WAAW,aAA0C,SACzD,YAAY,MAAM,EAAE,SAAS,UAAU,IAAI,CAAC,CAAC,MAAM,GAAG,EA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