{"version":3,"file":"live.cjs","names":["SvgPath","polarToCartesian","SvgPath","namespaces","sampleEasing","keySplinesOf","namespaces","domRenderer","renderElement"],"sources":["../src/live/keyframes.ts","../src/live/animations.ts","../src/live/diff.ts","../src/live/adopt.ts","../src/live/renderer.ts"],"sourcesContent":["/**\n * The keyframes `smilAnimations()` brings for the built-in nodes that\n * don't move well number by number: lines, areas and bands whose values\n * change their keys or count, and pie slices and their labels.\n */\nimport {\n  polarToCartesian,\n  SvgPath,\n  type CurveParams,\n  type Keyframes,\n  type LineInterpolation,\n  type PathCommand,\n  type SceneNode,\n  type SegmentData\n} from '../index';\nimport type { LiveAnimationContext } from './types';\n\ninterface Point {\n  readonly x: number;\n  readonly y: number;\n}\n\n/** A point of a path through values, with the data of its value. */\ninterface Vertex extends Point {\n  readonly data: SegmentData;\n}\n\n/**\n * A line, area or band read back into its values: one edge for lines and\n * areas, the upper and the lower edge for bands, each by value index.\n */\ninterface Outline {\n  readonly edges: readonly (readonly Vertex[])[];\n  /** The area's baseline, in px. */\n  readonly base: number;\n  readonly smoothing: LineInterpolation;\n}\n\ntype PathNode = Extract<SceneNode, { role: 'line' | 'area' | 'band' }>;\n\nconst lerp = (from: number, to: number, progress: number) =>\n  (1 - progress) * from + progress * to;\n\nconst between = (from: Point, to: Point, progress: number): Point => ({\n  x: lerp(from.x, to.x, progress),\n  y: lerp(from.y, to.y, progress)\n});\n\n/**\n * The vertices of a path: one per run of commands that share their\n * value's data. A step line draws a corner and the point with the same\n * data, so the point is the first or the last command of its run.\n */\nfunction verticesOf(commands: readonly PathCommand[], last: boolean): Vertex[] {\n  const vertices: Vertex[] = [];\n  let previous: SegmentData | undefined;\n  for (const { x, y, data } of commands) {\n    if (data && data !== previous) {\n      vertices.push({ x, y, data });\n    } else if (data && last) {\n      vertices[vertices.length - 1] = { x, y, data };\n    }\n    previous = data;\n  }\n  return vertices;\n}\n\n/**\n * Draws a path through points with the interpolation the layer used, a\n * hole between values whose indexes aren't next to each other.\n */\nfunction draw(\n  smoothing: LineInterpolation,\n  vertices: readonly Vertex[],\n  points: readonly Point[]\n): SvgPath {\n  const coordinates: number[] = [];\n  const data: SegmentData[] = [];\n  vertices.forEach((vertex, index) => {\n    const valueIndex = vertex.data.valueIndex;\n    if (index && valueIndex - vertices[index - 1].data.valueIndex > 1) {\n      coordinates.push(0, 0);\n      data.push({ value: undefined, valueIndex: valueIndex - 1 });\n    }\n    coordinates.push(points[index].x, points[index].y);\n    data.push(vertex.data);\n  });\n  return smoothing(coordinates, data);\n}\n\n/** Draws an outline as the line, area and band layers do. */\nfunction drawOutline(\n  role: PathNode['role'],\n  { edges, smoothing }: Outline,\n  points: readonly (readonly Point[])[],\n  base: number\n): string {\n  const [first, second] = edges.map((edge, index) =>\n    draw(smoothing, edge, points[index])\n  );\n  const commands = first.pathElements;\n  const start = commands[0];\n  const end = commands[commands.length - 1];\n  if (role === 'area') {\n    return first\n      .clone(true)\n      .position(0)\n      .remove(1)\n      .move(start.x, base)\n      .line(start.x, start.y, false, start.data)\n      .position(commands.length + 1)\n      .line(end.x, base)\n      .stringify();\n  }\n  if (role === 'band') {\n    // The lower edge traced backward, from its end to its start.\n    const lower = second.pathElements;\n    const last = lower[lower.length - 1];\n    const back = new SvgPath().line(last.x, last.y, false, last.data);\n    for (let index = lower.length - 1; index > 0; index--) {\n      const command = lower[index] as PathCommand<CurveParams>;\n      const target = lower[index - 1];\n      if (command.command === 'C') {\n        back.curve(\n          command.x2,\n          command.y2,\n          command.x1,\n          command.y1,\n          target.x,\n          target.y,\n          false,\n          target.data\n        );\n      } else {\n        back.line(target.x, target.y, false, target.data);\n      }\n    }\n    return SvgPath.join([first, back], true).stringify();\n  }\n  return first.stringify();\n}\n\n/**\n * Reads a line, area or band back into its values, when drawing them\n * again gives the node's `d`: nothing for paths a listener changed or an\n * interpolation that can't be read back.\n */\nfunction outlineOf(node: PathNode): Outline | undefined {\n  const { path, smoothing } = node.ctx;\n  const commands = path.pathElements;\n  for (const last of [false, true]) {\n    const vertices = verticesOf(\n      node.role === 'area' ? commands.slice(1, -1) : commands,\n      last\n    );\n    const half = vertices.length / 2;\n    const outline: Outline = {\n      edges:\n        node.role !== 'band'\n          ? [vertices]\n          : Number.isInteger(half)\n            ? [vertices.slice(0, half), vertices.slice(half).reverse()]\n            : [],\n      base: commands[0]?.y ?? 0,\n      smoothing\n    };\n    if (\n      outline.edges.length &&\n      outline.edges.every(edge => edge.length) &&\n      drawOutline(node.role, outline, outline.edges, outline.base) ===\n        String(node.attrs.d)\n    ) {\n      return outline;\n    }\n  }\n  return undefined;\n}\n\n/** The series a node's values belong to; for a band, the one it follows. */\nfunction seriesIndexOf(node: PathNode): number {\n  if (node.role !== 'band') {\n    return node.ctx.seriesIndex;\n  }\n  const edge = node.ctx.high ?? node.ctx.low;\n  return edge && 'seriesIndex' in edge\n    ? edge.seriesIndex\n    : (node.ctx.series?.[0] ?? 0);\n}\n\n/** The value keys of each edge, a repeated key numbered in its order. */\nfunction keysOf(\n  node: PathNode,\n  { edges }: Outline,\n  context: LiveAnimationContext,\n  scene: 'previous' | 'next'\n): string[][] {\n  const seriesIndex = seriesIndexOf(node);\n  return edges.map(edge => {\n    const seen = new Map<string, number>();\n    return edge.map(({ data }) => {\n      const key = context.valueKey(\n        {\n          seriesIndex,\n          valueIndex: data.valueIndex,\n          value: data.value,\n          meta: data.meta\n        },\n        scene\n      );\n      const count = (seen.get(key) ?? 0) + 1;\n      seen.set(key, count);\n      return count > 1 ? `${key}#${count}` : key;\n    });\n  });\n}\n\n/**\n * Keeps the direction of X between neighbors as in the new path, so\n * interpolations that break the line where X turns back (monotone cubic)\n * draw every frame with the new path's commands.\n */\nfunction keepDirection(points: Point[], edge: readonly Vertex[]): Point[] {\n  for (let index = 1; index < points.length; index++) {\n    const direction = Math.sign(edge[index].x - edge[index - 1].x);\n    const previous = points[index - 1].x;\n    if (Math.sign(points[index].x - previous) !== direction) {\n      points[index] = { x: previous + direction / 1000, y: points[index].y };\n    }\n  }\n  return points;\n}\n\n/**\n * Lines, areas and bands whose values changed keys or count: each value\n * starts where its key was, a new one where its nearest kept neighbor was\n * (the one before it, if any), and every frame is drawn through the\n * layer's interpolation.\n */\nfunction pathKeyframes(\n  previous: PathNode,\n  next: PathNode,\n  progress: readonly number[],\n  context: LiveAnimationContext\n): Keyframes | undefined {\n  const from = outlineOf(previous);\n  const to = outlineOf(next);\n  if (!from || !to || from.edges.length !== to.edges.length) {\n    return undefined;\n  }\n  let fromKeys: string[][];\n  let toKeys: string[][];\n  try {\n    fromKeys = keysOf(previous, from, context, 'previous');\n    toKeys = keysOf(next, to, context, 'next');\n  } catch {\n    // A key function that can't key these values.\n    return undefined;\n  }\n  if (fromKeys.join('\\n') === toKeys.join('\\n')) {\n    return undefined;\n  }\n\n  const starts: Point[][] = [];\n  for (const [edgeIndex, keys] of toKeys.entries()) {\n    const positions = new Map(\n      fromKeys[edgeIndex].map((key, index) => [\n        key,\n        from.edges[edgeIndex][index]\n      ])\n    );\n    const kept = keys.map(key => positions.get(key));\n    const edgeStarts: Point[] = [];\n    for (let index = 0; index < keys.length; index++) {\n      let start: Point | undefined;\n      for (let before = index; before >= 0 && !start; before--) {\n        start = kept[before];\n      }\n      for (let after = index + 1; after < keys.length && !start; after++) {\n        start = kept[after];\n      }\n      if (!start) {\n        return undefined;\n      }\n      edgeStarts.push(start);\n    }\n    starts.push(edgeStarts);\n  }\n\n  return progress.map(at => ({\n    d: drawOutline(\n      next.role,\n      to,\n      to.edges.map((edge, edgeIndex) =>\n        keepDirection(\n          edge.map((vertex, index) =>\n            between(starts[edgeIndex][index], vertex, at)\n          ),\n          edge\n        )\n      ),\n      lerp(from.base, to.base, at)\n    )\n  }));\n}\n\n/** The angle of a point around a center, in degrees clockwise from the top. */\nconst angleOf = (center: Point, point: Point) =>\n  (Math.atan2(point.y - center.y, point.x - center.x) * 180) / Math.PI + 90;\n\ntype SliceNode = Extract<SceneNode, { role: 'slice' }>;\n\n/**\n * A slice at interpolated angles, center and radius, drawn in the pie\n * layer's command layout: from its end around to its start, to the center\n * for a pie. The slice's overlap with the one before it is read from its\n * path.\n */\nfunction sliceKeyframes(\n  previous: SliceNode,\n  next: SliceNode,\n  progress: readonly number[]\n): Keyframes {\n  const { center, radius, startAngle, endAngle, path } = next.ctx;\n  const pie = String(next.attrs.d).endsWith('Z');\n  const commands = path.pathElements;\n  const delta =\n    startAngle - angleOf(center, commands[commands.length - 1 - +pie]);\n  const overlap = (((delta % 360) + 540) % 360) - 180;\n  return progress.map(at => {\n    const middle = between(previous.ctx.center, center, at);\n    const r = lerp(previous.ctx.radius, radius, at);\n    const start = lerp(previous.ctx.startAngle, startAngle, at);\n    const end = lerp(previous.ctx.endAngle, endAngle, at);\n    const overlappingStart = Math.max(0, start - overlap);\n    const fullCircle = end - start >= 359.99;\n    const arcEnd = Math.min(end, overlappingStart + 359.99);\n    const from = polarToCartesian(middle.x, middle.y, r, overlappingStart);\n    const frame = new SvgPath(pie);\n    if (fullCircle) {\n      const opposite = polarToCartesian(\n        middle.x,\n        middle.y,\n        r,\n        overlappingStart + 180\n      );\n      frame.move(from.x, from.y).arc(r, r, 0, 0, 0, opposite.x, opposite.y);\n    } else {\n      const to = polarToCartesian(middle.x, middle.y, r, arcEnd);\n      frame.move(to.x, to.y);\n    }\n    frame.arc(\n      r,\n      r,\n      0,\n      Number(!fullCircle && end - start > 180),\n      0,\n      from.x,\n      from.y\n    );\n    if (pie) {\n      frame.line(middle.x, middle.y);\n    }\n    return { d: frame.stringify() };\n  });\n}\n\n/** The slice with the label's key, in a scene. */\nfunction sliceOf(\n  scene: SceneNode,\n  key: string | undefined\n): SliceNode | undefined {\n  if (scene.role === 'slice' && scene.key === key) {\n    return scene;\n  }\n  for (const child of scene.children) {\n    const slice = sliceOf(child, key);\n    if (slice) {\n      return slice;\n    }\n  }\n  return undefined;\n}\n\ntype LabelNode = Extract<SceneNode, { role: 'label' }>;\n\n/**\n * A pie label moving around the pie with its slice: at the interpolated\n * middle angle of the slice, its distance from the center interpolated,\n * and a label moved away from that spot (to keep labels apart) moved by\n * as much.\n */\nfunction labelKeyframes(\n  previous: LabelNode,\n  next: LabelNode,\n  progress: readonly number[],\n  context: LiveAnimationContext\n): Keyframes | undefined {\n  const fromSlice = sliceOf(context.update.previousScene, previous.key);\n  const toSlice = sliceOf(context.scene, next.key);\n  if (\n    !fromSlice ||\n    !toSlice ||\n    previous.ctx.kind !== 'pie' ||\n    next.ctx.kind !== 'pie'\n  ) {\n    return undefined;\n  }\n  const place = ({ ctx }: SliceNode, label: Point) => {\n    const angle = (ctx.startAngle + ctx.endAngle) / 2;\n    const radius = Math.hypot(label.x - ctx.center.x, label.y - ctx.center.y);\n    const spot = polarToCartesian(ctx.center.x, ctx.center.y, radius, angle);\n    return {\n      angle,\n      radius,\n      center: ctx.center,\n      shift: { x: label.x - spot.x, y: label.y - spot.y }\n    };\n  };\n  const from = place(fromSlice, previous.ctx);\n  const to = place(toSlice, next.ctx);\n  return progress.map(at => {\n    const center = between(from.center, to.center, at);\n    const shift = between(from.shift, to.shift, at);\n    const spot = polarToCartesian(\n      center.x,\n      center.y,\n      lerp(from.radius, to.radius, at),\n      lerp(from.angle, to.angle, at)\n    );\n    const frame: Record<string, number> = {};\n    for (const name of ['x', 'y', 'dx', 'dy'] as const) {\n      const value = next.attrs[name as keyof typeof next.attrs];\n      if (typeof value === 'number') {\n        const axis = name.endsWith('x') ? 'x' : 'y';\n        frame[name] = value + spot[axis] + shift[axis] - next.ctx[axis];\n      }\n    }\n    return frame;\n  });\n}\n\n/**\n * The built-in keyframes of an updated node, or nothing when it moves\n * well number by number.\n */\nexport function builtInKeyframes(\n  previous: SceneNode,\n  next: SceneNode,\n  progress: readonly number[],\n  context: LiveAnimationContext\n): Keyframes | undefined {\n  if (previous.role !== next.role) {\n    return undefined;\n  }\n  switch (next.role) {\n    case 'line':\n    case 'area':\n    case 'band':\n      return pathKeyframes(previous as PathNode, next, progress, context);\n    case 'slice':\n      return sliceKeyframes(previous as SliceNode, next, progress);\n    case 'label':\n      return labelKeyframes(previous as LabelNode, next, progress, context);\n    default:\n      return undefined;\n  }\n}\n","import {\n  keySplinesOf,\n  namespaces,\n  sampleEasing,\n  SvgPath,\n  type AttrValue,\n  type Keyframes,\n  type UpdateAnimation\n} from '../index';\nimport { builtInKeyframes } from './keyframes';\nimport type { LiveAnimations } from './types';\n\n/** The class of the `animate` elements of update animations. */\nconst ANIMATION_CLASS = 'ct-update-animation';\n\nconst NUMBER = /-?(?:\\d+\\.?\\d*|\\.\\d+)(?:e[-+]?\\d+)?/gi;\n\n/** The CSS easings `--ct-update-easing` takes; anything else is `ease-out`. */\nconst CSS_EASING =\n  /^(linear|ease(-in|-out|-in-out)?|(cubic-bezier|linear|steps)\\(.*\\))$/;\n\n/** How a render's animations run. */\ninterface Timing extends UpdateAnimation {\n  /** The eased progress of sampled frames. */\n  readonly progress: readonly number[];\n  /** The `keySplines` of the easing, when SMIL can express it. */\n  readonly splines?: string;\n  /** `discrete` for `steps()`, else `linear`. */\n  readonly calcMode: string;\n}\n\n/** A value's numbers and the text around them, `#` for each number. */\ninterface Shape {\n  readonly text: string;\n  readonly numbers: readonly number[];\n}\n\n/** Without a duration in the CSS, updates take this long, in ms. */\nconst DEFAULT_DURATION = 300;\n\n/** A CSS time (`400ms`, `0.4s`) in ms; the default for anything else. */\nfunction durationOf(value: string | undefined): number {\n  const [, amount, unit] =\n    value?.trim().match(/^(\\d*\\.?\\d+(?:e[-+]?\\d+)?)(m?s)$/i) ?? [];\n  return unit\n    ? Number(amount) * (unit.toLowerCase() === 's' ? 1000 : 1)\n    : DEFAULT_DURATION;\n}\n\n/** A path's `d` with absolute commands, unrounded. */\nfunction absolutePath(d: string): string {\n  const path = new SvgPath(false, { accuracy: false }).parse(d);\n  let x = 0;\n  let y = 0;\n  let startX = 0;\n  let startY = 0;\n  for (const command of path.pathElements as unknown as Record<\n    string,\n    number | string\n  >[]) {\n    const letter = String(command.command);\n    if (letter !== letter.toUpperCase()) {\n      for (const name of Object.keys(command)) {\n        if (name[0] === 'x' && name !== 'xAr') {\n          command[name] = Number(command[name]) + x;\n        } else if (name[0] === 'y') {\n          command[name] = Number(command[name]) + y;\n        }\n      }\n    }\n    command.command = letter.toUpperCase();\n    if (command.command === 'Z') {\n      x = startX;\n      y = startY;\n    } else {\n      x = 'x' in command ? Number(command.x) : x;\n      y = 'y' in command ? Number(command.y) : y;\n    }\n    if (command.command === 'M') {\n      startX = x;\n      startY = y;\n    }\n  }\n  return path.stringify() + (/z\\s*$/i.test(d) ? 'Z' : '');\n}\n\n/**\n * The shape of an attribute's value, for a number or a path's `d`;\n * nothing for other values.\n */\nfunction shapeOf(\n  name: string,\n  value: AttrValue | undefined\n): Shape | undefined {\n  let text = String(value);\n  if (name === 'd') {\n    try {\n      text = absolutePath(text);\n    } catch {\n      return undefined;\n    }\n  } else if (value === undefined || !text.trim() || !isFinite(Number(text))) {\n    return undefined;\n  }\n  return {\n    text: text.replace(NUMBER, '#'),\n    numbers: (text.match(NUMBER) ?? []).map(Number)\n  };\n}\n\n/** A shape's text with the given numbers, rounded to 3 decimals. */\nfunction fill(text: string, numbers: readonly number[]): string {\n  let index = 0;\n  return text.replace(\n    /#/g,\n    () => `${Math.round(numbers[index++] * 1000) / 1000}`\n  );\n}\n\n/**\n * Whether an attribute can animate as an offset added to its value: a\n * number, or a path with absolute commands and no arcs, whose flags\n * can't be added.\n */\nconst isAdditive = (name: string, value: AttrValue, shape: Shape) =>\n  name !== 'd' ||\n  (!/[mlhvcsqtaz]/.test(String(value)) && !shape.text.includes('A'));\n\n/** Removes an element's update animations that have ended. */\nfunction removeEnded(element: Element) {\n  for (const child of Array.from(element.children)) {\n    if (child.classList.contains(ANIMATION_CLASS)) {\n      const animation = child as SVGAnimationElement;\n      try {\n        if (\n          animation.getStartTime() + animation.getSimpleDuration() <=\n          animation.getCurrentTime()\n        ) {\n          child.remove();\n        }\n      } catch {\n        // Without a current interval it has ended, unless the browser\n        // has no SMIL timing (jsdom).\n        if (typeof animation.getStartTime === 'function') {\n          child.remove();\n        }\n      }\n    }\n  }\n}\n\n/** Adds an `animate` element to an element and starts it. */\nfunction write(\n  element: Element,\n  name: string,\n  values: readonly string[],\n  additive: boolean,\n  timing: Timing,\n  splines?: string\n) {\n  const animate = element.ownerDocument.createElementNS(\n    namespaces.svg,\n    'animate'\n  ) as SVGAnimateElement;\n  const attributes: Record<string, string | undefined> = {\n    class: ANIMATION_CLASS,\n    attributeName: name,\n    begin: 'indefinite',\n    dur: `${timing.duration}ms`,\n    fill: 'remove',\n    values: values.join(';'),\n    keyTimes: values\n      .map((_, index) => Math.round((index / (values.length - 1)) * 1e4) / 1e4)\n      .join(';'),\n    calcMode: splines ? 'spline' : timing.calcMode,\n    keySplines: splines,\n    additive: additive ? 'sum' : undefined\n  };\n  for (const [attribute, value] of Object.entries(attributes)) {\n    if (value !== undefined) {\n      animate.setAttribute(attribute, value);\n    }\n  }\n  animate.addEventListener('endEvent', () => animate.remove());\n  element.appendChild(animate);\n  try {\n    animate.beginElement();\n    // Throws when the animation didn't start: Firefox doesn't run\n    // animations inside a `foreignObject` (HTML labels), which would\n    // never end.\n    animate.getStartTime();\n  } catch {\n    // Without SMIL timing (jsdom), the attribute holds the new value\n    // anyway.\n    if (typeof animate.getStartTime === 'function') {\n      animate.remove();\n    }\n  }\n}\n\n/**\n * Animates an attribute number by number from its previous value: an\n * offset from `previous − next` to 0 when it can be added, else the\n * values themselves. Paths with different commands, or with arcs, don't\n * animate.\n */\nfunction animateNumbers(\n  element: Element,\n  name: string,\n  previous: AttrValue,\n  next: AttrValue,\n  timing: Timing\n) {\n  const from = shapeOf(name, previous);\n  const to = shapeOf(name, next);\n  if (!from || !to || from.text !== to.text || to.text.includes('A')) {\n    return;\n  }\n  const additive = isAdditive(name, next, to);\n  const at = (progress: number) =>\n    fill(\n      to.text,\n      to.numbers.map((value, index) =>\n        additive\n          ? (from.numbers[index] - value) * (1 - progress)\n          : (1 - progress) * from.numbers[index] + progress * value\n      )\n    );\n  const progress = timing.splines ? [0, 1] : timing.progress;\n  write(element, name, progress.map(at), additive, timing, timing.splines);\n}\n\n/**\n * Animates an attribute through keyframes: as offsets from the new value\n * when every frame has its shape, so an interruption continues from where\n * the element is drawn, else as the frames' values.\n */\nfunction animateFrames(\n  element: Element,\n  name: string,\n  frames: readonly AttrValue[],\n  next: AttrValue | undefined,\n  timing: Timing\n) {\n  const to = shapeOf(name, next);\n  const offsets: string[] = [];\n  if (to && isAdditive(name, String(next), to)) {\n    for (const frame of frames) {\n      const shape = shapeOf(name, frame);\n      if (shape?.text !== to.text) {\n        break;\n      }\n      offsets.push(\n        fill(\n          to.text,\n          shape.numbers.map((value, index) => value - to.numbers[index])\n        )\n      );\n    }\n  }\n  const additive = offsets.length === frames.length;\n  write(\n    element,\n    name,\n    additive ? offsets : frames.map(String),\n    additive,\n    timing\n  );\n}\n\n/**\n * Animates the changes of an update with SMIL, timed by the chart's CSS:\n * each updated node's changed numbers and paths move from their previous\n * value to their new one over `--ct-update-duration` (a CSS time, 300 ms\n * by default; `0s` turns the animations off) with the easing in\n * `--ct-update-easing` (a CSS easing, `ease-out` by default). The\n * attributes hold their new values from the start, and an update during an\n * animation continues from where each element is drawn.\n *\n * It animates updates (`update()`, `setOptions()`) and changes of the\n * matching `responsive` options, not resizes, and nothing while the\n * visitor's system asks for reduced motion. Lines and areas follow their\n * values' keys, and pie slices turn around the pie; layers and plugins can\n * give keyframes of their own.\n *\n * @example\n * ```ts\n * import { lineChart } from 'chartist';\n * import { liveDomRenderer, smilAnimations } from 'chartist/live';\n *\n * // 300 ms with ease-out, unless the CSS sets --ct-update-duration\n * // and --ct-update-easing.\n * const chart = lineChart(\n *   '#chart',\n *   { labels: ['Mon', 'Tue', 'Wed'], series: [[5, 2, 4]] },\n *   { renderer: liveDomRenderer({ animations: smilAnimations() }) }\n * );\n *\n * chart.update({ data: { labels: ['Mon', 'Tue', 'Wed'], series: [[3, 6, 1]] } });\n * ```\n * @returns The animations, for `liveDomRenderer({ animations })`\n * @experimental\n */\nexport function smilAnimations(): LiveAnimations {\n  return {\n    animate(context) {\n      const { update, container, measureStyle } = context;\n      const options = {\n        container,\n        rootClass: context.scene.classes.join(' ')\n      };\n      const duration = durationOf(\n        measureStyle?.('--ct-update-duration', options)\n      );\n      if (\n        (update.cause !== 'update' && update.cause !== 'responsive') ||\n        !(duration > 0) ||\n        container.ownerDocument.defaultView?.matchMedia?.(\n          '(prefers-reduced-motion: reduce)'\n        ).matches\n      ) {\n        return undefined;\n      }\n      const css = measureStyle?.('--ct-update-easing', options)?.trim() ?? '';\n      const easing = CSS_EASING.test(css) ? css : 'ease-out';\n      const timing: Timing = {\n        duration,\n        easing,\n        progress: sampleEasing(easing, duration),\n        splines: keySplinesOf(easing),\n        calcMode: easing.startsWith('steps(') ? 'discrete' : 'linear'\n      };\n\n      for (const { op, node, previous } of context.changes) {\n        const element = context.elementOf(node);\n        if (op !== 'update' || !previous || !element) {\n          continue;\n        }\n        removeEnded(element);\n        const changed = Object.keys(node.attrs).filter(\n          name =>\n            !name.includes(':') &&\n            previous.attrs[name] !== undefined &&\n            String(previous.attrs[name]) !== String(node.attrs[name])\n        );\n        if (!changed.length) {\n          continue;\n        }\n        const frames: Keyframes =\n          update.keyframes(previous, node, timing.progress) ??\n          builtInKeyframes(previous, node, timing.progress, context) ??\n          [];\n        const framed = Object.keys(frames[0] ?? {}).filter(name =>\n          frames.every(frame => frame[name] !== undefined)\n        );\n        for (const name of framed) {\n          animateFrames(\n            element,\n            name,\n            frames.map(frame => frame[name]),\n            node.attrs[name],\n            timing\n          );\n        }\n        for (const name of changed) {\n          if (!framed.includes(name)) {\n            animateNumbers(\n              element,\n              name,\n              previous.attrs[name],\n              node.attrs[name],\n              timing\n            );\n          }\n        }\n      }\n      return { duration, easing };\n    }\n  };\n}\n","import type { SceneChange, SceneNode } from '../index';\nimport type { DiffOptions, ValueKeyContext } from './types';\n\n/**\n * The value key of a value, as the `key` option says. `index` is the\n * position the `index` mode uses: the value's index, or a slice's series.\n */\nexport type ValueKeyOf = (value: ValueKeyContext, index?: number) => string;\n\n/** The changes of two scenes, and the previous node of each kept node. */\nexport interface SceneMatch {\n  readonly changes: SceneChange[];\n  /** The previous node of each node of the new scene that was kept. */\n  readonly matched: Map<SceneNode, SceneNode>;\n}\n\n/** The value key function of a `key` option. */\nexport function valueKeyOf(key: DiffOptions['key'] = 'index'): ValueKeyOf {\n  return key === 'index'\n    ? (value, index = value.valueIndex) => String(index)\n    : key === 'label'\n      ? ({ label }) => String(label)\n      : value => String(key(value));\n}\n\n/** The context fields identities are made of. */\ninterface IdentityFields {\n  readonly seriesIndex?: unknown;\n  readonly valueIndex?: unknown;\n  readonly value?: unknown;\n  readonly meta?: unknown;\n  readonly kind?: unknown;\n  readonly index?: unknown;\n  readonly axis?: {\n    readonly id?: string;\n    readonly dimension: string;\n    readonly ticks: readonly unknown[];\n  };\n}\n\n/** What a node stands for, before repeats among its siblings are counted. */\nfunction identityOf(\n  current: SceneNode,\n  valueKey: ValueKeyOf,\n  labels: readonly unknown[]\n): string {\n  const ctx = (current.ctx ?? {}) as IdentityFields;\n  const { seriesIndex, valueIndex, axis, index } = ctx;\n  const role = current.role ?? current.name;\n  if (typeof seriesIndex === 'number') {\n    // The layer is the first part of the pipeline key (`layer/…`).\n    const own = current.key ?? '';\n    const end = own.indexOf('/');\n    const layer = end < 0 ? own : own.slice(0, end);\n    // In flat pie data, every value is a series: a slice, its series\n    // group and its label are keyed by the slice's label and position.\n    const slice =\n      current.role === 'slice' || ctx.kind === 'pie'\n        ? ctx\n        : current.role === 'series' &&\n            current.children.length === 1 &&\n            current.children[0].role === 'slice'\n          ? (current.children[0].ctx as IdentityFields)\n          : undefined;\n    if (slice) {\n      const key = valueKey(\n        {\n          seriesIndex,\n          valueIndex: 0,\n          value: slice.value,\n          label: labels[seriesIndex],\n          meta: slice.meta\n        },\n        seriesIndex\n      );\n      return `v:${layer}/pie/${key}:${role}`;\n    }\n    if (typeof valueIndex !== 'number') {\n      return `s:${layer}/${seriesIndex}:${role}`;\n    }\n    const key = valueKey({\n      seriesIndex,\n      valueIndex,\n      value: ctx.value,\n      label: labels[valueIndex],\n      meta: ctx.meta\n    });\n    return `v:${layer}/${seriesIndex}/${key}:${role}`;\n  }\n  if (axis && typeof index === 'number') {\n    return `t:${axis.id ?? axis.dimension}:${role}:${String(axis.ticks[index])}`;\n  }\n  if (current.key !== undefined) {\n    return `k:${current.key}`;\n  }\n  return `p:${current.name}.${current.classes[0] ?? ''}`;\n}\n\n/** The identities of sibling nodes, with `#2`, `#3` for repeats. */\nfunction identities(\n  nodes: readonly SceneNode[],\n  valueKey: ValueKeyOf,\n  labels: readonly unknown[]\n): string[] {\n  const seen = new Map<string, number>();\n  return nodes.map(current => {\n    const identity = identityOf(current, valueKey, labels);\n    const count = (seen.get(identity) ?? 0) + 1;\n    seen.set(identity, count);\n    return count > 1 ? `${identity}#${count}` : identity;\n  });\n}\n\n/** Whether a node's classes, attributes or text changed. */\nfunction differs(previous: SceneNode, next: SceneNode) {\n  if (\n    previous.content !== next.content ||\n    previous.classes.length !== next.classes.length ||\n    previous.classes.some((name, i) => next.classes[i] !== name)\n  ) {\n    return true;\n  }\n  const names = Object.keys(next.attrs);\n  return (\n    names.length !== Object.keys(previous.attrs).length ||\n    names.some(name => previous.attrs[name] !== next.attrs[name])\n  );\n}\n\n/** Lists a node and every node below it, in document order. */\nfunction every(\n  op: 'add' | 'remove',\n  current: SceneNode,\n  changes: SceneChange[]\n) {\n  changes.push({ op, node: current });\n  current.children.forEach(child => every(op, child, changes));\n}\n\n/**\n * Matches two scenes per parent and lists the changes in the new scene's\n * document order, `remove` entries after their former parent's kept\n * children. Roots with different element names aren't matched.\n */\nexport function matchScenes(\n  previous: SceneNode,\n  next: SceneNode,\n  options: DiffOptions = {}\n): SceneMatch {\n  const valueKey = valueKeyOf(options.key);\n  const labels = options.labels ?? [];\n  const previousLabels = options.previousLabels ?? labels;\n  const changes: SceneChange[] = [];\n  const matched = new Map<SceneNode, SceneNode>();\n\n  const visit = (before: SceneNode, after: SceneNode) => {\n    matched.set(after, before);\n    if (differs(before, after)) {\n      changes.push({ op: 'update', node: after, previous: before });\n    }\n    const kept = new Map<string, SceneNode>();\n    identities(before.children, valueKey, previousLabels).forEach(\n      (identity, i) => kept.set(identity, before.children[i])\n    );\n    const removed = new Set(before.children);\n    identities(after.children, valueKey, labels).forEach((identity, i) => {\n      const child = after.children[i];\n      const match = kept.get(identity);\n      if (match && match.name === child.name) {\n        removed.delete(match);\n        visit(match, child);\n      } else {\n        every('add', child, changes);\n      }\n    });\n    removed.forEach(child => every('remove', child, changes));\n  };\n\n  if (previous.name === next.name) {\n    visit(previous, next);\n  } else {\n    every('add', next, changes);\n    every('remove', previous, changes);\n  }\n  return { changes, matched };\n}\n\n/**\n * The changes between two scenes, matched by what each node stands for:\n * `add`, `update` (with the previous node) and `remove`, in the new\n * scene's document order, with the `remove` entries after their former\n * parent's kept children. Every node of an added or removed subtree has\n * its own entry. The live renderer patches its SVG with them; other\n * renderers that change their output in place can use them too.\n *\n * Nodes are matched among the children of matched parents: values by\n * their layer, series and key (see `key`), series by layer and index,\n * grid lines and axis labels by axis and tick, nodes with their own\n * `key` by it, and the rest by element name and first class, in order.\n *\n * @example\n * ```ts\n * import { lineChartConfig, toScene } from 'chartist';\n * import { diffScenes } from 'chartist/live';\n *\n * const size = { width: 600, height: 300 };\n * const labels = ['Mo', 'Tu', 'We'];\n * const before = toScene(lineChartConfig({ labels, series: [[1, 2, 3]] }), size);\n * const after = toScene(lineChartConfig({ labels, series: [[1, 5, 3]] }), size);\n *\n * for (const { op, node } of diffScenes(before, after, { labels })) {\n *   console.log(op, node.role, node.key);\n * }\n * ```\n * @param previous The previous scene\n * @param next The new scene\n * @param options How values are identified, and the data's labels\n * @returns The changes, in the new scene's document order\n * @experimental\n */\nexport function diffScenes(\n  previous: SceneNode,\n  next: SceneNode,\n  options: DiffOptions = {}\n): SceneChange[] {\n  return matchScenes(previous, next, options).changes;\n}\n","import {\n  applyAttribute,\n  namespaces,\n  type DomRenderOutput,\n  type LabelMode,\n  type Renderer,\n  type SceneNode\n} from '../index';\n\n/** What {@link adoptMarkup} returns when the markup matches the scene. */\nexport interface AdoptedOutput extends DomRenderOutput {\n  /** Attributes, classes and texts that differed and were set. */\n  readonly repaired: number;\n}\n\n/** Thrown inside the walk; turned into a warning and `undefined`. */\nclass Mismatch extends Error {}\n\n/**\n * The root attribute `renderForHydration()` records the layout in, which\n * `chart()` removes once it laid the chart out at the real size.\n */\nconst MARKER = 'data-ct-hydrate';\n\n/** What a marker of version 1 records (others aren't taken over). */\ninterface Marker {\n  readonly v: 1;\n  readonly width: number;\n  readonly height: number;\n  readonly labels: LabelMode;\n  /** Whether the root's `viewBox` only scales until the chart lays out. */\n  readonly scale: boolean;\n}\n\n/** The marker of server markup, if it's one this version reads. */\nfunction readMarker(svg: Element): Marker | undefined {\n  try {\n    const marker = JSON.parse(svg.getAttribute(MARKER)!) as Marker;\n    if (marker.v === 1 && marker.width > 0 && marker.height > 0) {\n      return marker;\n    }\n  } catch {\n    // Warned below.\n  }\n  // eslint-disable-next-line no-console\n  console.warn(\n    `Chartist: the server markup's ${MARKER} attribute isn't one this version of Chartist reads, so the chart draws a new svg. Render it with renderForHydration() of the same version.`\n  );\n  return undefined;\n}\n\nconst elementChildren = (element: Element) =>\n  Array.from(element.childNodes).filter(\n    (child): child is Element => child.nodeType === 1\n  );\n\nconst ownText = (element: Element) =>\n  Array.from(element.childNodes)\n    .filter(child => child.nodeType === 3)\n    .map(child => child.nodeValue)\n    .join('');\n\n/** The namespace and local name a scene attribute is set with. */\nfunction qualified(name: string) {\n  const separator = name.indexOf(':');\n  const prefix = separator > 0 ? name.slice(0, separator) : '';\n  return prefix && prefix !== 'xmlns' && namespaces[prefix]\n    ? { namespace: namespaces[prefix], local: name.slice(separator + 1) }\n    : { namespace: null, local: name };\n}\n\n/** The properties a style declaration list sets. */\nconst properties = (style: string | number | undefined) =>\n  new Set(\n    String(style ?? '')\n      .split(';')\n      .map(declaration => declaration.split(':')[0].trim().toLowerCase())\n  );\n\n/**\n * Takes over markup from `renderForHydration()`, a direct child of the\n * container: reads its marker, builds the scene for the recorded layout\n * with `replay` and binds it to the markup (see {@link adoptSvg}).\n */\nexport const adoptMarkup: NonNullable<Renderer<DomRenderOutput>['adopt']> = (\n  container,\n  replay\n) => {\n  const svg = Array.from(container.children).find(\n    (child): child is SVGSVGElement =>\n      child.localName === 'svg' && child.hasAttribute(MARKER)\n  );\n  const marker = svg && readMarker(svg);\n  return marker\n    ? adoptSvg(\n        replay({\n          width: marker.width,\n          height: marker.height,\n          labels: marker.labels\n        }),\n        svg,\n        marker.scale\n      )\n    : undefined;\n};\n\n/**\n * Binds a scene's nodes to the elements of server markup from\n * `renderForHydration()`, instead of creating new ones. The structure\n * (element names, namespaces and child element counts; text and comments\n * don't count) has to match. Everything else is made what a fresh render\n * draws: differing attributes, classes and texts are set, attributes the\n * scene doesn't have are removed, `ct:` attributes the HTML parser left\n * without a namespace get it, and the scene's styles are applied through\n * the CSSOM. A scaling `viewBox` (`scaled`) stays on the root for the\n * chart to remove. Returns `undefined`, with a warning naming the first\n * difference, when the structure doesn't match.\n */\nexport function adoptSvg(\n  scene: SceneNode,\n  svg: SVGSVGElement,\n  scaled: boolean\n): AdoptedOutput | undefined {\n  const elements = new WeakMap<SceneNode, Element>();\n  let repaired = 0;\n\n  const walk = (\n    current: SceneNode,\n    element: Element,\n    html: boolean,\n    path: string\n  ) => {\n    const namespace = html ? namespaces.xhtml : namespaces.svg;\n    if (\n      element.localName !== current.name ||\n      element.namespaceURI !== namespace\n    ) {\n      throw new Mismatch(\n        `${path}: expected <${current.name}>, found <${element.localName}>${element.namespaceURI === namespace ? '' : ` in ${element.namespaceURI}`}`\n      );\n    }\n    const children = elementChildren(element);\n    if (children.length !== current.children.length) {\n      throw new Mismatch(\n        `${path}: expected ${current.children.length} child elements, found ${children.length}`\n      );\n    }\n    // Attributes the markup carries for the scene's styles, by design.\n    const styled = properties(current.attrs.style);\n    const kept = new Set<Attr>();\n    for (const [name, value] of Object.entries(current.attrs)) {\n      const { namespace: ns, local } = qualified(name);\n      if (name === 'style') {\n        // Through the CSSOM, which a strict Content Security Policy allows.\n        applyAttribute(element, name, value);\n      } else {\n        // Parsed from HTML, `ct:value` is a plain attribute with a colon.\n        const plain = ns ? element.getAttributeNode(name) : null;\n        const before = plain?.value ?? element.getAttributeNS(ns, local);\n        if (plain) {\n          element.removeAttributeNode(plain);\n        }\n        if (before !== String(value)) {\n          repaired += before === null || !styled.has(name) ? 1 : 0;\n          applyAttribute(element, name, value);\n        } else if (plain) {\n          applyAttribute(element, name, value);\n        }\n      }\n      const attribute = element.getAttributeNodeNS(ns, local);\n      if (attribute) {\n        kept.add(attribute);\n      }\n    }\n    for (const attribute of Array.from(element.attributes)) {\n      const { name } = attribute;\n      if (\n        !kept.has(attribute) &&\n        name !== 'class' &&\n        name !== MARKER &&\n        !(scaled && element === svg && name === 'viewBox') &&\n        name !== 'xmlns' &&\n        !name.startsWith('xmlns:')\n      ) {\n        repaired += styled.has(name) ? 0 : 1;\n        element.removeAttributeNode(attribute);\n      }\n    }\n    const classes = current.classes.join(' ');\n    if ((element.getAttribute('class') ?? '') !== classes) {\n      repaired++;\n      if (classes) {\n        element.setAttribute('class', classes);\n      } else {\n        element.removeAttribute('class');\n      }\n    }\n    if (\n      !current.children.length &&\n      (current.content ?? '') !== ownText(element)\n    ) {\n      repaired++;\n      element.textContent = current.content ?? '';\n    }\n    const inner = html || current.name === 'foreignObject';\n    current.children.forEach((child, index) =>\n      walk(child, children[index], inner, `${path} > ${child.name}[${index}]`)\n    );\n    elements.set(current, element);\n  };\n\n  try {\n    walk(scene, svg, false, 'svg');\n  } catch (error) {\n    if (error instanceof Mismatch) {\n      // eslint-disable-next-line no-console\n      console.warn(\n        `Chartist: the server markup doesn't match the chart, so the chart draws a new svg. The server and the browser should draw the same data and options (${error.message}).`\n      );\n      return undefined;\n    }\n    throw error;\n  }\n  return {\n    svg,\n    elementOf: (node: SceneNode) => elements.get(node),\n    remove: () => svg.remove(),\n    repaired\n  };\n}\n","import {\n  applyAttribute,\n  domRenderer,\n  renderElement,\n  type DomRenderOutput,\n  type Renderer,\n  type SceneNode\n} from '../index';\nimport { adoptMarkup } from './adopt';\nimport { matchScenes, valueKeyOf } from './diff';\nimport type { LiveDomRendererOptions } from './types';\n\n/** Sets the text of a childless element, keeping elements a listener added. */\nfunction setText(element: Element, content: string | undefined) {\n  const text = Array.from(element.childNodes).find(\n    child => child.nodeType === 3\n  );\n  if (!content) {\n    text?.remove();\n  } else if (text) {\n    text.nodeValue = content;\n  } else {\n    element.insertBefore(\n      element.ownerDocument.createTextNode(content),\n      element.firstChild\n    );\n  }\n}\n\n/** Changes a kept element from its previous node to its new one. */\nfunction patchElement(element: Element, previous: SceneNode, next: SceneNode) {\n  for (const name of Object.keys(previous.attrs)) {\n    if (!(name in next.attrs)) {\n      element.removeAttribute(name);\n    }\n  }\n  for (const [name, value] of Object.entries(next.attrs)) {\n    if (previous.attrs[name] !== value) {\n      applyAttribute(element, name, value);\n    }\n  }\n  const removed = previous.classes.filter(name => !next.classes.includes(name));\n  const added = next.classes.filter(name => !previous.classes.includes(name));\n  if (removed.length) {\n    element.classList.remove(...removed);\n    // As rendered fresh: no empty class attribute.\n    if (!element.classList.length) {\n      element.removeAttribute('class');\n    }\n  }\n  if (added.length) {\n    element.classList.add(...added);\n  }\n  if (!next.children.length && previous.content !== next.content) {\n    setText(element, next.content);\n  }\n}\n\n/**\n * Puts the elements of a node's children in their order, from the end:\n * an element moves only when it isn't before its successor already.\n * Elements the scene doesn't know are skipped, so they stay after their\n * previous sibling.\n */\nfunction order(parent: Element, elements: readonly Element[]) {\n  const known = new Set(elements);\n  let successor: Element | null = null;\n  for (let i = elements.length - 1; i >= 0; i--) {\n    const element = elements[i];\n    let following = element.nextSibling;\n    while (following && !known.has(following as Element)) {\n      following = following.nextSibling;\n    }\n    if (element.parentNode !== parent || following !== successor) {\n      parent.insertBefore(element, successor);\n    }\n    successor = element;\n  }\n}\n\n/**\n * Creates a DOM renderer that keeps a chart's SVG and changes it in place\n * on every later render, instead of drawing a new one: elements that\n * stand for the same thing as before stay, with only their changed\n * attributes, classes and text set, elements for new nodes are created\n * and elements of nodes that are gone are removed. What listeners added\n * to kept elements stays, and `mount` gets the `changes` of the render.\n *\n * Its first render, and every render without the previous one (1.x\n * charts), draws a new SVG as {@link domRenderer} does. A chart whose\n * container holds markup from `renderForHydration()` takes that markup\n * over instead, keeping the server's elements, unless `adopt` is `false`.\n * The renderer keeps no state of its own, so one instance can serve many\n * charts.\n *\n * @example\n * ```ts\n * import { lineChart } from 'chartist';\n * import { liveDomRenderer } from 'chartist/live';\n *\n * const labels = ['Mo', 'Tu', 'We', 'Th', 'Fr'];\n * const values = [3, 5, 4, 6, 5];\n * const chart = lineChart(\n *   '#chart',\n *   { labels, series: [values] },\n *   // Points and labels follow their day as the window slides.\n *   { renderer: liveDomRenderer({ key: 'label' }) }\n * );\n *\n * let day = 0;\n * setInterval(() => {\n *   labels.push(`Day ${++day}`);\n *   labels.shift();\n *   values.push(Math.round(Math.random() * 10));\n *   values.shift();\n *   chart.update({ labels: [...labels], series: [[...values]] });\n * }, 1000);\n * ```\n * @param options How values are identified (`key`), update animations,\n *   such as `smilAnimations()`, and whether to take server markup over\n * @returns The renderer, for `renderer` in `chart()` and the presets\n * @experimental\n */\nexport function liveDomRenderer(\n  options: LiveDomRendererOptions = {}\n): Renderer<DomRenderOutput> {\n  const dom = domRenderer();\n  const { key, animations, adopt = true } = options;\n  const valueKey = valueKeyOf(key);\n  return {\n    ...dom,\n    ...(adopt && { adopt: adoptMarkup }),\n    render(scene, container, update) {\n      const svg = update?.previous.elementOf(update.previousScene);\n      if (\n        !update ||\n        !svg ||\n        svg.parentNode !== container ||\n        scene.name !== update.previousScene.name\n      ) {\n        return dom.render(scene, container);\n      }\n      const { labels, previousLabels } = update;\n      const document = container.ownerDocument;\n      const { changes, matched } = matchScenes(update.previousScene, scene, {\n        key,\n        labels,\n        previousLabels\n      });\n      const elements = new WeakMap<SceneNode, Element>();\n      const created = (current: SceneNode, element: Element) =>\n        elements.set(current, element);\n      const removed = new Set<SceneNode>();\n      for (const change of changes) {\n        if (change.op === 'remove') {\n          removed.add(change.node);\n        }\n      }\n\n      const patch = (\n        previous: SceneNode,\n        next: SceneNode,\n        element: Element,\n        html: boolean\n      ) => {\n        elements.set(next, element);\n        patchElement(element, previous, next);\n        for (const child of previous.children) {\n          if (removed.has(child)) {\n            update.previous.elementOf(child)?.remove();\n          }\n        }\n        const inner = html || next.name === 'foreignObject';\n        const children = next.children.map(child => {\n          const kept = matched.get(child);\n          const childElement = kept && update.previous.elementOf(kept);\n          if (kept && childElement) {\n            patch(kept, child, childElement, inner);\n            return childElement;\n          }\n          return renderElement(child, document, { html: inner, created });\n        });\n        order(element, children);\n      };\n      patch(update.previousScene, scene, svg, false);\n\n      const elementOf = (node: SceneNode) => elements.get(node);\n      const rootClass = scene.classes.join(' ');\n      const animation = animations?.animate({\n        changes,\n        elementOf,\n        update,\n        container,\n        scene,\n        measureStyle: (property, measure) =>\n          dom.measureStyle?.(property, { container, rootClass, ...measure }),\n        valueKey: (value, which) =>\n          valueKey({\n            ...value,\n            label: (which === 'previous' ? previousLabels : labels)[\n              value.valueIndex\n            ]\n          })\n      });\n      return {\n        svg: svg as SVGSVGElement,\n        elementOf,\n        remove: () => svg.remove(),\n        changes,\n        patched: true,\n        ...(animation && { animation })\n      };\n    }\n  };\n}\n"],"mappings":";;;;;;;;AAwCA,MAAM,QAAQ,MAAc,IAAY,cACrC,IAAI,YAAY,OAAO,WAAW;AAErC,MAAM,WAAW,MAAa,IAAW,cAA6B;CACpE,GAAG,KAAK,KAAK,GAAG,GAAG,GAAG,QAAQ;CAC9B,GAAG,KAAK,KAAK,GAAG,GAAG,GAAG,QAAQ;AAChC;;;;;;AAOA,SAAS,WAAW,UAAkC,MAAyB;CAC7E,MAAM,WAAqB,C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