{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sankey-diagram",
  "title": "Sankey Diagram",
  "description": "A Sankey diagram of how things flow between stages: columns of nodes sized by volume, gradient ribbons whose thickness follows each flow, a layout that untangles crossings, hover highlighting of a node's paths and a tooltip with both shares.",
  "dependencies": [
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/sankey-diagram/sankey-diagram.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport type ChartTheme = \"dark\" | \"light\";\n\nexport interface SankeyNode {\n  id: string;\n  label: string;\n  /** Defaults to the theme palette. */\n  color?: string;\n}\n\nexport interface SankeyLink {\n  source: string;\n  target: string;\n  value: number;\n}\n\nexport interface SankeyDiagramProps extends Omit<\n  React.ComponentPropsWithoutRef<\"div\">,\n  \"title\"\n> {\n  theme?: ChartTheme;\n  title?: string;\n  subtitle?: string;\n  nodes?: SankeyNode[];\n  links?: SankeyLink[];\n  /** Height of the diagram, in px. */\n  height?: number;\n  /** Below this container width the diagram keeps this width and scrolls sideways. */\n  minWidth?: number;\n  formatValue?: (value: number) => string;\n}\n\nconst PALETTES = {\n  dark: {\n    card: \"#0E0E0E\",\n    border: \"rgba(255,255,255,0.08)\",\n    text: \"#F4F5F7\",\n    sub: \"rgba(255,255,255,0.55)\",\n    tip: \"rgba(20,20,20,0.96)\",\n    tipBorder: \"rgba(255,255,255,0.12)\",\n    series: [\n      \"#87FFE3\",\n      \"#8FB8FF\",\n      \"#B69CFF\",\n      \"#F2A841\",\n      \"#FF7A6B\",\n      \"#F5F4F1\",\n      \"#6EE7F9\",\n      \"#FFB3D9\",\n    ],\n  },\n  light: {\n    card: \"#FFFFFF\",\n    border: \"rgba(0,0,0,0.07)\",\n    text: \"#111317\",\n    sub: \"rgba(17,19,23,0.55)\",\n    tip: \"rgba(255,255,255,0.98)\",\n    tipBorder: \"rgba(0,0,0,0.08)\",\n    series: [\n      \"#0E9F80\",\n      \"#3B6FD8\",\n      \"#7B5CE0\",\n      \"#D9822B\",\n      \"#E5484D\",\n      \"#3F3F46\",\n      \"#0891B2\",\n      \"#DB2777\",\n    ],\n  },\n};\n\nconst DEFAULT_NODES: SankeyNode[] = [\n  { id: \"organic\", label: \"Organic search\" },\n  { id: \"paid\", label: \"Paid ads\" },\n  { id: \"social\", label: \"Social\" },\n  { id: \"referral\", label: \"Referral\" },\n  { id: \"email\", label: \"Email\" },\n  { id: \"landing\", label: \"Landing page\" },\n  { id: \"blog\", label: \"Blog\" },\n  { id: \"pricing\", label: \"Pricing page\" },\n  { id: \"signup\", label: \"Signed up\" },\n  { id: \"sales\", label: \"Contacted sales\" },\n  { id: \"bounce\", label: \"Left\" },\n];\nconst DEFAULT_LINKS: SankeyLink[] = [\n  { source: \"organic\", target: \"landing\", value: 3200 },\n  { source: \"organic\", target: \"blog\", value: 2400 },\n  { source: \"organic\", target: \"pricing\", value: 900 },\n  { source: \"paid\", target: \"landing\", value: 2600 },\n  { source: \"paid\", target: \"pricing\", value: 1100 },\n  { source: \"social\", target: \"blog\", value: 1400 },\n  { source: \"social\", target: \"landing\", value: 600 },\n  { source: \"referral\", target: \"pricing\", value: 800 },\n  { source: \"referral\", target: \"landing\", value: 500 },\n  { source: \"email\", target: \"pricing\", value: 700 },\n  { source: \"email\", target: \"landing\", value: 400 },\n  { source: \"landing\", target: \"signup\", value: 2100 },\n  { source: \"landing\", target: \"sales\", value: 900 },\n  { source: \"landing\", target: \"bounce\", value: 4300 },\n  { source: \"blog\", target: \"signup\", value: 700 },\n  { source: \"blog\", target: \"bounce\", value: 3100 },\n  { source: \"pricing\", target: \"signup\", value: 1600 },\n  { source: \"pricing\", target: \"sales\", value: 1100 },\n  { source: \"pricing\", target: \"bounce\", value: 800 },\n];\n\ntype LaidNode = {\n  i: number;\n  id: string;\n  label: string;\n  color: string;\n  depth: number;\n  value: number;\n  inV: number;\n  outV: number;\n  x: number;\n  y: number;\n  h: number;\n};\ntype LaidLink = {\n  i: number;\n  s: number;\n  t: number;\n  value: number;\n  w: number;\n  sy: number;\n  ty: number;\n};\n\nfunction useReducedMotion() {\n  return React.useSyncExternalStore(\n    (callback) => {\n      const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n      query.addEventListener(\"change\", callback);\n      return () => query.removeEventListener(\"change\", callback);\n    },\n    () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches,\n    () => false,\n  );\n}\n\nfunction useWidth(ref: React.RefObject<HTMLElement | null>) {\n  const [width, setWidth] = React.useState(0);\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const ro = new ResizeObserver(([entry]) =>\n      setWidth(entry.contentRect.width),\n    );\n    ro.observe(el);\n    return () => ro.disconnect();\n  }, [ref]);\n  return width;\n}\n\n/** 0 → 1 (linear) once the element scrolls into view; 1 straight away with reduced motion. */\nfunction useReveal(\n  ref: React.RefObject<HTMLElement | null>,\n  reduce: boolean,\n  duration = 1600,\n) {\n  const [t, setT] = React.useState(0);\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el || reduce) return;\n    let raf = 0;\n    const io = new IntersectionObserver(\n      ([entry]) => {\n        if (!entry.isIntersecting) return;\n        io.disconnect();\n        const start = performance.now();\n        const tick = (now: number) => {\n          const k = Math.min(1, (now - start) / duration);\n          setT(k);\n          if (k < 1) raf = requestAnimationFrame(tick);\n        };\n        raf = requestAnimationFrame(tick);\n      },\n      { threshold: 0.2 },\n    );\n    io.observe(el);\n    return () => {\n      io.disconnect();\n      cancelAnimationFrame(raf);\n    };\n  }, [ref, reduce, duration]);\n  return reduce ? 1 : t;\n}\n\nconst NODE_W = 10;\nconst PAD = 14;\nconst LABEL_SPACE = 132;\n\n/** A small Sankey layout: columns by longest path, node heights by flow, a few relaxation passes to cut crossings. */\nfunction layout(\n  nodes: SankeyNode[],\n  links: SankeyLink[],\n  width: number,\n  height: number,\n  palette: string[],\n) {\n  const index = new Map(nodes.map((n, i) => [n.id, i]));\n  const ls = links\n    .filter((l) => index.has(l.source) && index.has(l.target) && l.value > 0)\n    .map((l, i) => ({\n      i,\n      s: index.get(l.source)!,\n      t: index.get(l.target)!,\n      value: l.value,\n    }));\n  const depth = nodes.map(() => 0);\n  // Longest path from any source (iterate; graphs here are small and acyclic).\n  for (let pass = 0; pass < nodes.length; pass++) {\n    let changed = false;\n    for (const l of ls)\n      if (depth[l.t] < depth[l.s] + 1) {\n        depth[l.t] = depth[l.s] + 1;\n        changed = true;\n      }\n    if (!changed) break;\n  }\n  const maxDepth = Math.max(0, ...depth);\n  const inV = nodes.map((_, i) =>\n    ls.filter((l) => l.t === i).reduce((s, l) => s + l.value, 0),\n  );\n  const outV = nodes.map((_, i) =>\n    ls.filter((l) => l.s === i).reduce((s, l) => s + l.value, 0),\n  );\n  const value = nodes.map((_, i) => Math.max(inV[i], outV[i]));\n  const cols: number[][] = Array.from({ length: maxDepth + 1 }, () => []);\n  nodes.forEach((_, i) => cols[depth[i]].push(i));\n  const innerW = Math.max(1, width - LABEL_SPACE * 2 - NODE_W);\n  const ky = Math.min(\n    ...cols.map(\n      (c) =>\n        (height - (c.length - 1) * PAD) /\n        Math.max(\n          1,\n          c.reduce((s, i) => s + value[i], 0),\n        ),\n    ),\n  );\n  const laid: LaidNode[] = nodes.map((n, i) => ({\n    i,\n    id: n.id,\n    label: n.label,\n    color: n.color ?? palette[i % palette.length],\n    depth: depth[i],\n    value: value[i],\n    inV: inV[i],\n    outV: outV[i],\n    x: LABEL_SPACE + (maxDepth ? (depth[i] / maxDepth) * innerW : innerW / 2),\n    y: 0,\n    h: Math.max(2, value[i] * ky),\n  }));\n\n  // Resolve overlaps in a column: push nodes down to clear each other, then, if the last one spills\n  // past the bottom, pull it back and walk upward pushing the others up.\n  const stack = (col: number[]) => {\n    col.sort((a, b) => laid[a].y - laid[b].y);\n    let y = 0;\n    for (const i of col) {\n      laid[i].y = Math.max(laid[i].y, y);\n      y = laid[i].y + laid[i].h + PAD;\n    }\n    const last = laid[col[col.length - 1]];\n    if (last && last.y + last.h > height) {\n      last.y = height - last.h;\n      for (let k = col.length - 2; k >= 0; k--) {\n        const node = laid[col[k]];\n        const below = laid[col[k + 1]];\n        if (node.y + node.h + PAD > below.y) node.y = below.y - PAD - node.h;\n      }\n    }\n  };\n  // Start each column stacked in input order, centred vertically.\n  cols.forEach((col) => {\n    const total =\n      col.reduce((s, i) => s + laid[i].h, 0) + (col.length - 1) * PAD;\n    let y = (height - total) / 2;\n    for (const i of col) {\n      laid[i].y = y;\n      y += laid[i].h + PAD;\n    }\n  });\n  // Relax: move nodes toward the weighted centre of their neighbours, alternating directions.\n  const centre = (i: number) => laid[i].y + laid[i].h / 2;\n  for (let pass = 0; pass < 6; pass++) {\n    const forward = pass % 2 === 0;\n    const order = forward ? cols.slice(1) : cols.slice(0, -1).reverse();\n    for (const col of order) {\n      for (const i of col) {\n        const nb = ls.filter((l) => (forward ? l.t === i : l.s === i));\n        const w = nb.reduce((s, l) => s + l.value, 0);\n        if (!w) continue;\n        const c =\n          nb.reduce((s, l) => s + centre(forward ? l.s : l.t) * l.value, 0) / w;\n        laid[i].y += (c - centre(i)) * 0.6;\n      }\n      stack(col);\n    }\n  }\n  cols.forEach(stack);\n\n  // Ribbon offsets: outgoing links ordered by target height, incoming by source height.\n  const outOff = nodes.map(() => 0);\n  const inOff = nodes.map(() => 0);\n  const laidLinks: LaidLink[] = ls.map((l) => ({\n    ...l,\n    w: l.value * ky,\n    sy: 0,\n    ty: 0,\n  }));\n  [...laidLinks]\n    .sort((a, b) => centre(a.t) - centre(b.t))\n    .forEach((l) => {\n      l.sy = laid[l.s].y + outOff[l.s];\n      outOff[l.s] += l.w;\n    });\n  [...laidLinks]\n    .sort((a, b) => centre(a.s) - centre(b.s))\n    .forEach((l) => {\n      l.ty = laid[l.t].y + inOff[l.t];\n      inOff[l.t] += l.w;\n    });\n  return { nodes: laid, links: laidLinks, maxDepth };\n}\n\nexport function SankeyDiagram({\n  theme = \"dark\",\n  title = \"Where visitors go\",\n  subtitle = \"Traffic source → first page → outcome, last 30 days\",\n  nodes = DEFAULT_NODES,\n  links = DEFAULT_LINKS,\n  height = 340,\n  minWidth = 620,\n  formatValue = (v) => v.toLocaleString(\"en-US\"),\n  className,\n  style,\n  ...props\n}: SankeyDiagramProps) {\n  const pal = PALETTES[theme];\n  const reduce = useReducedMotion();\n  const outerRef = React.useRef<HTMLDivElement>(null);\n  const outer = useWidth(outerRef);\n  const width = Math.max(outer, minWidth);\n  const reveal = useReveal(outerRef, reduce);\n  const [hover, setHover] = React.useState<{\n    kind: \"node\" | \"link\";\n    i: number;\n  } | null>(null);\n  const [pointer, setPointer] = React.useState({ x: 0, y: 0 });\n  const id = React.useId();\n\n  const g = React.useMemo(\n    () => (outer ? layout(nodes, links, width, height, pal.series) : null),\n    [nodes, links, width, height, pal.series, outer],\n  );\n\n  const linkActive = (l: LaidLink) =>\n    !hover ||\n    (hover.kind === \"link\"\n      ? hover.i === l.i\n      : l.s === hover.i || l.t === hover.i);\n  const nodeActive = (n: LaidNode) =>\n    !hover ||\n    (hover.kind === \"node\"\n      ? hover.i === n.i ||\n        g!.links.some(\n          (l) =>\n            (l.s === hover.i && l.t === n.i) ||\n            (l.t === hover.i && l.s === n.i),\n        )\n      : g!.links[hover.i]?.s === n.i || g!.links[hover.i]?.t === n.i);\n  const ribbon = (l: LaidLink) => {\n    const a = g!.nodes[l.s];\n    const b = g!.nodes[l.t];\n    const x0 = a.x + NODE_W;\n    const x1 = b.x;\n    const xm = (x0 + x1) / 2;\n    return `M${x0},${l.sy}C${xm},${l.sy} ${xm},${l.ty} ${x1},${l.ty}L${x1},${l.ty + l.w}C${xm},${l.ty + l.w} ${xm},${l.sy + l.w} ${x0},${l.sy + l.w}Z`;\n  };\n  const items = g\n    ? [\n        ...g.nodes.map((n) => ({ kind: \"node\" as const, i: n.i })),\n        ...g.links.map((l) => ({ kind: \"link\" as const, i: l.i })),\n      ]\n    : [];\n  const onKey = (event: React.KeyboardEvent) => {\n    if (event.key === \"Escape\") return setHover(null);\n    if (\n      ![\"ArrowRight\", \"ArrowLeft\", \"ArrowDown\", \"ArrowUp\"].includes(\n        event.key,\n      ) ||\n      !items.length ||\n      !g\n    )\n      return;\n    event.preventDefault();\n    const dir =\n      event.key === \"ArrowRight\" || event.key === \"ArrowDown\" ? 1 : -1;\n    const at = hover\n      ? items.findIndex((it) => it.kind === hover.kind && it.i === hover.i)\n      : -1;\n    const next = items[(at + dir + items.length) % items.length];\n    setHover(next);\n    // Put the keyboard tooltip at the item's middle.\n    if (next.kind === \"node\") {\n      const n = g.nodes[next.i];\n      setPointer({ x: n.x + NODE_W / 2, y: n.y + n.h / 2 });\n    } else {\n      const l = g.links[next.i];\n      setPointer({\n        x: (g.nodes[l.s].x + g.nodes[l.t].x) / 2,\n        y: (l.sy + l.ty) / 2 + l.w / 2,\n      });\n    }\n  };\n  const track = (e: React.PointerEvent) => {\n    const r = (e.currentTarget as HTMLElement).getBoundingClientRect();\n    setPointer({ x: e.clientX - r.left, y: e.clientY - r.top });\n  };\n\n  const sources = g ? g.nodes.filter((n) => n.depth === 0) : [];\n  const total = sources.reduce((s, n) => s + n.value, 0);\n  const summary = `${title}. ${links.map((l) => `${nodes.find((n) => n.id === l.source)?.label} to ${nodes.find((n) => n.id === l.target)?.label}: ${formatValue(l.value)}`).join(\"; \")}.`;\n  let tip: React.ReactNode = null;\n  if (g && hover) {\n    if (hover.kind === \"link\") {\n      const l = g.links[hover.i];\n      const a = g.nodes[l.s];\n      const b = g.nodes[l.t];\n      tip = (\n        <>\n          <p className=\"flex items-center gap-1.5 font-semibold\">\n            <span\n              className=\"size-2 rounded-full\"\n              style={{ background: a.color }}\n            />\n            {a.label} <span style={{ color: pal.sub }}>→</span>{\" \"}\n            <span\n              className=\"size-2 rounded-full\"\n              style={{ background: b.color }}\n            />\n            {b.label}\n          </p>\n          <p className=\"mt-1.5 text-[16px] font-semibold tabular-nums\">\n            {formatValue(l.value)}\n          </p>\n          <p className=\"mt-0.5 tabular-nums\" style={{ color: pal.sub }}>\n            {((l.value / Math.max(1, a.outV)) * 100).toFixed(1)}% of {a.label} ·{\" \"}\n            {((l.value / Math.max(1, b.inV)) * 100).toFixed(1)}% of {b.label}\n          </p>\n        </>\n      );\n    } else {\n      const n = g.nodes[hover.i];\n      tip = (\n        <>\n          <p className=\"flex items-center gap-1.5 font-semibold\">\n            <span\n              className=\"size-2 rounded-full\"\n              style={{ background: n.color }}\n            />\n            {n.label}\n          </p>\n          <p className=\"mt-1.5 text-[16px] font-semibold tabular-nums\">\n            {formatValue(n.value)}\n          </p>\n          {n.inV > 0 && (\n            <p className=\"mt-0.5 tabular-nums\" style={{ color: pal.sub }}>\n              In {formatValue(n.inV)} from{\" \"}\n              {g.links.filter((l) => l.t === n.i).length} sources\n            </p>\n          )}\n          {n.outV > 0 && (\n            <p className=\"mt-0.5 tabular-nums\" style={{ color: pal.sub }}>\n              Out {formatValue(n.outV)} to{\" \"}\n              {g.links.filter((l) => l.s === n.i).length} targets\n            </p>\n          )}\n          {total > 0 && (\n            <p className=\"mt-0.5 tabular-nums\" style={{ color: pal.sub }}>\n              {((n.value / total) * 100).toFixed(1)}% of all traffic\n            </p>\n          )}\n        </>\n      );\n    }\n  }\n\n  return (\n    <div\n      className={cn(\n        \"w-full overflow-hidden rounded-[20px] p-5 sm:p-7\",\n        className,\n      )}\n      style={{\n        background: pal.card,\n        border: `1px solid ${pal.border}`,\n        color: pal.text,\n        fontFamily: \"Inter, -apple-system, BlinkMacSystemFont, sans-serif\",\n        ...style,\n      }}\n      {...props}\n    >\n      <div className=\"flex flex-wrap items-start justify-between gap-4\">\n        <div className=\"min-w-0\">\n          <p className=\"text-[15px] font-semibold tracking-[-0.01em]\">\n            {title}\n          </p>\n          {subtitle && (\n            <p className=\"mt-1 text-[12.5px]\" style={{ color: pal.sub }}>\n              {subtitle}\n            </p>\n          )}\n        </div>\n        <div className=\"text-right\">\n          <p className=\"text-[22px] leading-none font-semibold tracking-[-0.02em] tabular-nums\">\n            {formatValue(total)}\n          </p>\n          <p className=\"mt-1 text-[11.5px]\" style={{ color: pal.sub }}>\n            Total flow\n          </p>\n        </div>\n      </div>\n\n      <div\n        ref={outerRef}\n        className=\"mt-5 w-full overflow-x-auto overscroll-x-contain\"\n      >\n        <div\n          role=\"img\"\n          aria-label={summary}\n          tabIndex={0}\n          onKeyDown={onKey}\n          onBlur={() => setHover(null)}\n          onPointerMove={track}\n          onPointerLeave={(e) => e.pointerType === \"mouse\" && setHover(null)}\n          className=\"relative rounded-lg outline-none focus-visible:ring-2\"\n          style={{ width, height: height + 8 }}\n        >\n          {g && (\n            <svg\n              width={width}\n              height={height + 8}\n              className=\"block overflow-visible\"\n              aria-hidden=\"true\"\n            >\n              <defs>\n                <clipPath id={`${id}-clip`}>\n                  <rect\n                    x={-10}\n                    y={-10}\n                    width={\n                      reveal >= 1\n                        ? width + 20\n                        : LABEL_SPACE +\n                          NODE_W +\n                          (width - LABEL_SPACE - NODE_W) * reveal\n                    }\n                    height={height + 30}\n                  />\n                </clipPath>\n                {g.links.map((l) => (\n                  <linearGradient\n                    key={l.i}\n                    id={`${id}-l${l.i}`}\n                    gradientUnits=\"userSpaceOnUse\"\n                    x1={g.nodes[l.s].x}\n                    x2={g.nodes[l.t].x}\n                    y1={0}\n                    y2={0}\n                  >\n                    <stop offset=\"0%\" stopColor={g.nodes[l.s].color} />\n                    <stop offset=\"100%\" stopColor={g.nodes[l.t].color} />\n                  </linearGradient>\n                ))}\n              </defs>\n              <g clipPath={`url(#${id}-clip)`} transform=\"translate(0 4)\">\n                {g.links.map((l) => (\n                  <path\n                    key={l.i}\n                    d={ribbon(l)}\n                    fill={`url(#${id}-l${l.i})`}\n                    fillOpacity={\n                      linkActive(l)\n                        ? hover\n                          ? 0.6\n                          : theme === \"dark\"\n                            ? 0.32\n                            : 0.36\n                        : 0.07\n                    }\n                    onPointerEnter={() => setHover({ kind: \"link\", i: l.i })}\n                    onPointerDown={() => setHover({ kind: \"link\", i: l.i })}\n                    style={{\n                      transition: \"fill-opacity 180ms\",\n                      cursor: \"pointer\",\n                    }}\n                  />\n                ))}\n                {g.nodes.map((n) => (\n                  <g\n                    key={n.id}\n                    opacity={nodeActive(n) ? 1 : 0.35}\n                    style={{ transition: \"opacity 180ms\" }}\n                  >\n                    <rect\n                      x={n.x}\n                      y={n.y}\n                      width={NODE_W}\n                      height={n.h}\n                      rx={3}\n                      fill={n.color}\n                      onPointerEnter={() => setHover({ kind: \"node\", i: n.i })}\n                      onPointerDown={() => setHover({ kind: \"node\", i: n.i })}\n                      style={{ cursor: \"pointer\" }}\n                    />\n                    <text\n                      x={\n                        n.depth === g.maxDepth\n                          ? n.x + NODE_W + 10\n                          : n.depth === 0\n                            ? n.x - 10\n                            : n.x + NODE_W + 8\n                      }\n                      y={n.y + n.h / 2 - (n.h > 26 ? 3 : -4)}\n                      textAnchor={n.depth === 0 ? \"end\" : \"start\"}\n                      fontSize={12}\n                      fontWeight={600}\n                      fill={pal.text}\n                      style={{\n                        paintOrder: \"stroke\",\n                        stroke:\n                          n.depth > 0 && n.depth < g.maxDepth\n                            ? pal.card\n                            : \"none\",\n                        strokeWidth: 4,\n                        strokeLinejoin: \"round\",\n                      }}\n                    >\n                      {n.label}\n                    </text>\n                    {n.h > 26 && (\n                      <text\n                        x={\n                          n.depth === g.maxDepth\n                            ? n.x + NODE_W + 10\n                            : n.depth === 0\n                              ? n.x - 10\n                              : n.x + NODE_W + 8\n                        }\n                        y={n.y + n.h / 2 + 12}\n                        textAnchor={n.depth === 0 ? \"end\" : \"start\"}\n                        fontSize={11}\n                        fill={pal.sub}\n                        className=\"tabular-nums\"\n                        style={{\n                          paintOrder: \"stroke\",\n                          stroke:\n                            n.depth > 0 && n.depth < g.maxDepth\n                              ? pal.card\n                              : \"none\",\n                          strokeWidth: 4,\n                          strokeLinejoin: \"round\",\n                        }}\n                      >\n                        {formatValue(n.value)}\n                      </text>\n                    )}\n                  </g>\n                ))}\n              </g>\n            </svg>\n          )}\n          {tip && (\n            <div\n              className=\"pointer-events-none absolute z-10 max-w-[260px] min-w-[180px] rounded-xl px-3 py-2.5 text-[12px] shadow-xl\"\n              style={{\n                left: pointer.x > width - 280 ? undefined : pointer.x + 14,\n                right:\n                  pointer.x > width - 280 ? width - pointer.x + 14 : undefined,\n                top: Math.min(height - 90, Math.max(0, pointer.y - 30)),\n                background: pal.tip,\n                border: `1px solid ${pal.tipBorder}`,\n                backdropFilter: \"blur(8px)\",\n              }}\n            >\n              {tip}\n            </div>\n          )}\n        </div>\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}