{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "stacked-area-chart",
  "title": "Stacked area chart",
  "description": "Stacked area chart is a production-ready charts component from BJORK UI, packaged for shadcn registries.",
  "dependencies": [
    "clsx",
    "framer-motion",
    "next-themes",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "components/bjork-ui/charts/stacked-area-chart.tsx",
      "content": "\"use client\";\n\nimport { useEffect, useMemo, useRef, useState, type KeyboardEvent, type MouseEvent, type PointerEvent } from \"react\";\nimport { cn } from \"@/lib/utils\";\nimport type { BjorkTone } from \"@/components/bjork-ui/_core/palette\";\nimport { useChartCanvas, easeOut, roundRectPath, writeLabels, type PlacedLabel } from \"@/components/bjork-ui/charts/_kit/canvas\";\nimport {\n  useChartTheme,\n  chartFocusRing,\n  ChartTable,\n  LabelPool,\n  LegendKey,\n  placeTooltip,\n  HoverTooltip,\n  ChartAnnouncer,\n  type TooltipHandle,\n  type AnnouncerHandle,\n  type TooltipContent,\n  type TooltipRow,\n} from \"@/components/bjork-ui/charts/_kit/chrome\";\nimport { clamp, crisp, damp, niceDomain, niceTicks, timeTicks, withAlpha, formatCompact, formatPercent } from \"@/components/bjork-ui/charts/_kit/scale\";\nimport { CHART_OTHER, MAX_SERIES, foldSeries, seriesColor } from \"@/components/bjork-ui/charts/_kit/series\";\n\nexport interface AreaSeries {\n  id: string;\n  label: string;\n  /** One value per entry in `times`. Missing, non-finite and negative values count as zero. */\n  values: number[];\n}\n\nexport type StackedAreaMode = \"stacked\" | \"percent\" | \"lines\";\n\nexport interface StackedAreaChartProps {\n  /** Shared time axis in UTC milliseconds, ascending. */\n  times: number[];\n  /** Series in stack order, first at the bottom. Colour follows this index. Past six, the rest fold into \"Other\". */\n  series: AreaSeries[];\n  /** \"stacked\" (default) shows the total, \"percent\" each part's share, \"lines\" the parts unstacked. */\n  mode?: StackedAreaMode;\n  /** Hidden series ids, controlled. Toggled from the legend; the last visible series cannot be hidden. */\n  hidden?: string[];\n  defaultHidden?: string[];\n  onHiddenChange?: (hidden: string[]) => void;\n  /** Brushed window [start, end] in UTC ms, controlled. Defaults to the whole axis. */\n  range?: [number, number];\n  defaultRange?: [number, number];\n  /** Called when the user settles a new window (drag end, click, keyboard), not on every pointer move. */\n  onRangeChange?: (range: [number, number]) => void;\n  /** The overview strip with the draggable window under the plot. */\n  brush?: boolean;\n  formatValue?: (v: number) => string;\n  /** Date text for the tooltip, table and announcements. */\n  formatTime?: (t: number) => string;\n  /** How the table twin rolls up more than 120 points into weeks or months. */\n  tableAggregate?: \"mean\" | \"sum\" | \"last\";\n  /** Posed crosshair by point index. */\n  activeIndex?: number | null;\n  /** Posed crosshair by time (nearest point). */\n  activeTime?: number | null;\n  height?: number;\n  ariaLabel?: string;\n  tone?: BjorkTone;\n  className?: string;\n}\n\nconst PAD_R = 8;\nconst LEGEND_GAP = 18;\nconst AXIS_H = 24;\nconst BRUSH_H = 36;\nconst BRUSH_GAP = 8;\nconst TAU = 0.14;\nconst VIEW_TAU = 0.12;\nconst ENTER_MS = 720;\nconst Y_LABELS = 8;\nconst X_LABELS = 16;\nconst MIN_POINTS = 7;\nconst TABLE_MAX_ROWS = 120;\nconst DAY = 86400000;\nconst FILL_ALPHA: Record<BjorkTone, number> = { dark: 0.5, light: 0.46 };\nconst OTHER_ID = \"__other\";\n\nconst dateFmt = new Intl.DateTimeFormat(\"en-US\", { month: \"short\", day: \"numeric\", year: \"numeric\", timeZone: \"UTC\" });\nconst monthFmt = new Intl.DateTimeFormat(\"en-US\", { month: \"short\", year: \"numeric\", timeZone: \"UTC\" });\nconst weekFmt = new Intl.DateTimeFormat(\"en-US\", { month: \"short\", day: \"numeric\", timeZone: \"UTC\" });\nconst defaultFormatValue = (v: number) => formatCompact(v, 1);\nconst defaultFormatTime = (t: number) => dateFmt.format(t);\nconst formatShare = (f: number) => formatPercent(f, f > 0 && f < 0.1 ? 1 : 0);\n\n// First index with a[k] >= x.\nfunction lowerBound(a: number[], x: number): number {\n  let lo = 0;\n  let hi = a.length;\n  while (lo < hi) {\n    const mid = (lo + hi) >> 1;\n    if (a[mid] < x) lo = mid + 1;\n    else hi = mid;\n  }\n  return lo;\n}\n\nfunction nearestIndex(a: number[], t: number): number {\n  const n = a.length;\n  if (!n) return -1;\n  let k = lowerBound(a, t);\n  if (k >= n) k = n - 1;\n  else if (k > 0 && t - a[k - 1] < a[k] - t) k--;\n  return k;\n}\n\nfunction clampWindow(a: number, b: number, d0: number, d1: number, minSpan: number): [number, number] {\n  const full = d1 - d0;\n  let w = b - a;\n  if (!Number.isFinite(w)) w = full;\n  w = clamp(w, Math.min(minSpan, full), full);\n  let s = Number.isFinite(a) ? a : d0;\n  if (s < d0) s = d0;\n  if (s + w > d1) s = d1 - w;\n  return [s, s + w];\n}\n\nfunction measure(ctx: CanvasRenderingContext2D, cache: Map<string, number>, font: string, text: string): number {\n  const key = `${font}|${text}`;\n  let w = cache.get(key);\n  if (w === undefined) {\n    ctx.font = font;\n    w = ctx.measureText(text).width;\n    if (cache.size > 600) cache.clear();\n    cache.set(key, w);\n  }\n  return w;\n}\n\n// Monotone cubic tangents (as d3's curveMonotoneX) for row `off` over [a, b]: no overshoot, so\n// a band never dips below its neighbour and shared edges trace the same curve both ways.\nfunction monoTangents(xs: Float64Array, ys: Float64Array, off: number, a: number, b: number, m: Float64Array) {\n  if (b <= a) {\n    m[a] = 0;\n    return;\n  }\n  const secant = (k: number) => {\n    const h = xs[k + 1] - xs[k];\n    return h ? (ys[off + k + 1] - ys[off + k]) / h : 0;\n  };\n  if (b - a === 1) {\n    m[a] = m[b] = secant(a);\n    return;\n  }\n  for (let k = a + 1; k < b; k++) {\n    const h0 = xs[k] - xs[k - 1];\n    const h1 = xs[k + 1] - xs[k];\n    const s0 = secant(k - 1);\n    const s1 = secant(k);\n    const p = h0 + h1 ? (s0 * h1 + s1 * h0) / (h0 + h1) : 0;\n    m[k] = (Math.sign(s0) + Math.sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(p)) || 0;\n  }\n  m[a] = (3 * secant(a) - m[a + 1]) / 2;\n  m[b] = (3 * secant(b - 1) - m[b - 1]) / 2;\n}\n\n// Traces row `off` over [a, b] with the tangents in `m`, forward (moveTo first) or backward (lineTo first).\nfunction traceEdge(ctx: CanvasRenderingContext2D, xs: Float64Array, ys: Float64Array, off: number, a: number, b: number, m: Float64Array, reverse: boolean) {\n  if (!reverse) {\n    ctx.moveTo(xs[a], ys[off + a]);\n    for (let k = a; k < b; k++) {\n      const d = (xs[k + 1] - xs[k]) / 3;\n      ctx.bezierCurveTo(xs[k] + d, ys[off + k] + m[k] * d, xs[k + 1] - d, ys[off + k + 1] - m[k + 1] * d, xs[k + 1], ys[off + k + 1]);\n    }\n  } else {\n    ctx.lineTo(xs[b], ys[off + b]);\n    for (let k = b; k > a; k--) {\n      const d = (xs[k] - xs[k - 1]) / 3;\n      ctx.bezierCurveTo(xs[k] - d, ys[off + k] - m[k] * d, xs[k - 1] + d, ys[off + k - 1] + m[k - 1] * d, xs[k - 1], ys[off + k - 1]);\n    }\n  }\n}\n\ninterface Clean {\n  id: string;\n  label: string;\n  values: number[];\n}\n\ninterface Run {\n  ready: boolean;\n  enter: number;\n  vis: number[];\n  emph: number[];\n  pct: number;\n  lines: number;\n  hi: number;\n  gutter: number;\n  gutterKey: string;\n  gutterT: number;\n  vs: number;\n  ve: number;\n  ts: number;\n  te: number;\n  col: number | null;\n  source: \"pointer\" | \"keyboard\" | \"prop\" | null;\n  plot: { l: number; r: number; t: number; b: number; ot: number; ob: number };\n  legendW: number;\n  legendH: number;\n  legendKey: string;\n  drag: null | { mode: \"move\" | \"left\" | \"right\"; x: number; vs: number; ve: number; id: number };\n  focusId: string | null;\n  yCache: string[];\n  xCache: string[];\n  inCache: string[];\n  endCache: string[];\n  fonts: { mono: string; alpha: string } | null;\n  widths: Map<string, number>;\n  xs: Float64Array;\n  los: Float64Array;\n  his: Float64Array;\n  tan: Float64Array;\n  tot: Float64Array;\n}\n\nexport function StackedAreaChart({\n  times,\n  series,\n  mode = \"stacked\",\n  hidden: hiddenProp,\n  defaultHidden,\n  onHiddenChange,\n  range,\n  defaultRange,\n  onRangeChange,\n  brush = true,\n  formatValue = defaultFormatValue,\n  formatTime = defaultFormatTime,\n  tableAggregate = \"mean\",\n  activeIndex,\n  activeTime,\n  height = 400,\n  ariaLabel = \"Stacked area chart\",\n  tone: toneProp,\n  className,\n}: StackedAreaChartProps) {\n  const { tone, pal, reduce, vars } = useChartTheme(toneProp);\n  const announcer = useRef<AnnouncerHandle>(null);\n  const tipRef = useRef<TooltipHandle>(null);\n  const wrapperRef = useRef<HTMLDivElement>(null);\n  const legendRef = useRef<HTMLDivElement>(null);\n  const legendBtns = useRef<(HTMLButtonElement | null)[]>([]);\n  const startRef = useRef<HTMLDivElement>(null);\n  const endRef = useRef<HTMLDivElement>(null);\n  const bodyRef = useRef<HTMLDivElement>(null);\n  const yPool = useRef<(HTMLSpanElement | null)[]>([]);\n  const xPool = useRef<(HTMLSpanElement | null)[]>([]);\n  const inPool = useRef<(HTMLSpanElement | null)[]>([]);\n  const endPool = useRef<(HTMLSpanElement | null)[]>([]);\n  const rectRef = useRef<DOMRect | null>(null);\n  const tableTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n  const n = times.length;\n\n  // Sanitised, folded series. Colour stays with the caller's index; \"Other\" takes the neutral.\n  const folded = series.length > MAX_SERIES;\n  const data = useMemo<Clean[]>(() => {\n    const clean = series.map((s) => ({\n      id: s.id,\n      label: s.label,\n      values: times.map((_, j) => {\n        const v = s.values[j];\n        return Number.isFinite(v) && v > 0 ? v : 0;\n      }),\n    }));\n    return foldSeries(clean, MAX_SERIES, (rest) => ({\n      id: OTHER_ID,\n      label: \"Other\",\n      values: times.map((_, j) => rest.reduce((sum, r) => sum + r.values[j], 0)),\n    }));\n  }, [series, times]);\n  const colors = useMemo(() => data.map((_, i) => (folded && i === MAX_SERIES - 1 ? CHART_OTHER[tone] : seriesColor(tone, i))), [data, folded, tone]);\n\n  const domain = useMemo<[number, number]>(() => {\n    if (!n) return [0, DAY];\n    const a = times[0];\n    const b = times[n - 1];\n    return b > a ? [a, b] : [a - DAY / 2, a + DAY / 2];\n  }, [times, n]);\n  // Typical spacing, for keyboard steps and the narrowest window.\n  const stepMs = useMemo(() => {\n    if (n < 2) return DAY;\n    const diffs: number[] = [];\n    for (let j = 1; j < n; j++) diffs.push(times[j] - times[j - 1]);\n    diffs.sort((a, b) => a - b);\n    return Math.max(1, diffs[diffs.length >> 1]);\n  }, [times, n]);\n  const minSpan = Math.min(domain[1] - domain[0], stepMs * (MIN_POINTS - 1));\n\n  const [hiddenState, setHiddenState] = useState<string[]>(defaultHidden ?? []);\n  const hiddenList = hiddenProp ?? hiddenState;\n  const hiddenSet = useMemo(() => {\n    const set = new Set(hiddenList);\n    // Never hide everything.\n    return data.every((s) => set.has(s.id)) ? new Set<string>() : set;\n  }, [hiddenList, data]);\n  const visibleCount = data.filter((s) => !hiddenSet.has(s.id)).length;\n\n  const initWindow = useMemo(() => {\n    const r = range ?? defaultRange ?? domain;\n    return clampWindow(r[0], r[1], domain[0], domain[1], minSpan);\n    // Only the first render's window seeds the state.\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, []);\n  const [tableRange, setTableRange] = useState<[number, number]>(initWindow);\n\n  const legendKey = `${data.map((s) => s.label).join(\"|\")}|${mode}`;\n  const cfg = useRef({ times, data, colors, hiddenSet, mode, pal, tone, reduce, formatValue, formatTime, brush, domain, legendKey, minSpan });\n  useEffect(() => {\n    cfg.current = { times, data, colors, hiddenSet, mode, pal, tone, reduce, formatValue, formatTime, brush, domain, legendKey, minSpan };\n  });\n\n  const st = useRef<Run>({\n    ready: false,\n    enter: 0,\n    vis: [],\n    emph: [],\n    pct: 0,\n    lines: 0,\n    hi: 1,\n    gutter: 32,\n    gutterKey: \"\",\n    gutterT: 32,\n    vs: initWindow[0],\n    ve: initWindow[1],\n    ts: initWindow[0],\n    te: initWindow[1],\n    col: null,\n    source: null,\n    plot: { l: 0, r: 0, t: 0, b: 0, ot: 0, ob: 0 },\n    legendW: -1,\n    legendH: 0,\n    legendKey: \"\",\n    drag: null,\n    focusId: null,\n    yCache: [],\n    xCache: [],\n    inCache: [],\n    endCache: [],\n    fonts: null,\n    widths: new Map(),\n    xs: new Float64Array(0),\n    los: new Float64Array(0),\n    his: new Float64Array(0),\n    tan: new Float64Array(0),\n    tot: new Float64Array(0),\n  });\n\n  const { rootRef, hostRef, canvasRef, wake } = useChartCanvas(({ ctx, w, h, dt }) => {\n    const s = st.current;\n    const c = cfg.current;\n    const p = c.pal;\n    const T = c.times;\n    const N = T.length;\n    const D = c.data;\n    const S = D.length;\n    const [d0, d1] = c.domain;\n    const full = d1 - d0;\n\n    if (!s.fonts) {\n      const a = yPool.current[0];\n      const b = inPool.current[0];\n      if (a && b) {\n        const fa = getComputedStyle(a);\n        const fb = getComputedStyle(b);\n        s.fonts = { mono: `${fa.fontWeight} ${fa.fontSize} ${fa.fontFamily}`, alpha: `${fb.fontWeight} ${fb.fontSize} ${fb.fontFamily}` };\n      }\n    }\n    const mono = s.fonts?.mono ?? \"400 10px monospace\";\n    const alphaFont = s.fonts?.alpha ?? \"500 11px sans-serif\";\n    const tw = (font: string, text: string) => measure(ctx, s.widths, font, text);\n\n    // The legend wraps on narrow widths; the plot starts under it.\n    if (s.legendW !== w || s.legendKey !== c.legendKey) {\n      s.legendW = w;\n      s.legendKey = c.legendKey;\n      s.legendH = legendRef.current?.offsetHeight ?? 0;\n    }\n\n    // Scratch buffers, grown only when the data grows.\n    if (s.xs.length < N) {\n      s.xs = new Float64Array(N);\n      s.tan = new Float64Array(Math.max(N, MAX_SERIES));\n      s.tot = new Float64Array(N);\n    }\n    if (s.los.length < N * S) {\n      s.los = new Float64Array(N * S);\n      s.his = new Float64Array(N * S);\n    }\n\n    const first = !s.ready || c.reduce;\n    let moving = false;\n    const approach = (cur: number, target: number, tau: number, tol: number) => {\n      if (first || !Number.isFinite(cur)) return target;\n      const v = damp(cur, target, tau, dt);\n      if (Math.abs(v - target) > tol) {\n        moving = true;\n        return v;\n      }\n      return target;\n    };\n\n    const focusIdx = s.focusId ? D.findIndex((d) => d.id === s.focusId && !c.hiddenSet.has(d.id)) : -1;\n    for (let i = 0; i < S; i++) {\n      const visT = c.hiddenSet.has(D[i].id) ? 0 : 1;\n      s.vis[i] = approach(s.vis[i] ?? visT, visT, TAU, 1e-3);\n      const emT = focusIdx < 0 ? 1 : i === focusIdx ? 1.45 : 0.4;\n      s.emph[i] = approach(s.emph[i] ?? emT, emT, TAU * 0.7, 1e-3);\n    }\n    s.vis.length = S;\n    s.emph.length = S;\n    const pctT = c.mode === \"percent\" ? 1 : 0;\n    const linesT = c.mode === \"lines\" ? 1 : 0;\n    s.pct = approach(s.pct, pctT, TAU, 1e-3);\n    s.lines = approach(s.lines, linesT, TAU, 1e-3);\n    if (c.reduce || s.drag || first) {\n      s.vs = s.ts;\n      s.ve = s.te;\n    } else {\n      s.vs = approach(s.vs, s.ts, VIEW_TAU, full * 1e-5);\n      s.ve = approach(s.ve, s.te, VIEW_TAU, full * 1e-5);\n    }\n\n    // Layout, bottom up: brush strip, axis labels, plot.\n    const brushOn = c.brush && N > 1;\n    const top = s.legendH > 0 ? s.legendH + LEGEND_GAP : 12;\n    const ob = h - 1;\n    const ot = brushOn ? ob - BRUSH_H : ob;\n    const plotB = Math.max(top + 20, (brushOn ? ot - BRUSH_GAP : h) - AXIS_H);\n    const pH = Math.max(1, plotB - top);\n    const yCount = clamp(Math.round(pH / 56), 2, 6);\n\n    // Points in the window, plus one outside each edge so the curves run off the plot.\n    const i0 = Math.max(0, lowerBound(T, s.vs) - 1);\n    const i1 = Math.min(N - 1, lowerBound(T, s.ve));\n\n    // Target y domain over the window, from the target visibility, so it heads straight for its end.\n    let maxV = 0;\n    for (let j = i0; j <= i1; j++) {\n      let tot = 0;\n      let mx = 0;\n      for (let i = 0; i < S; i++) {\n        if (c.hiddenSet.has(D[i].id)) continue;\n        const v = D[i].values[j];\n        tot += v;\n        if (v > mx) mx = v;\n      }\n      const m = linesT ? mx : tot;\n      if (m > maxV) maxV = m;\n    }\n    const hiT = maxV > 0 ? niceDomain(0, maxV * 1.04, yCount)[1] : 1;\n    s.hi = approach(s.hi, hiT, TAU, hiT * 1e-4);\n\n    // Left gutter fits the widest target tick label, then glides there.\n    const gk = `${hiT}|${yCount}|${pctT}|${s.fonts ? 1 : 0}`;\n    if (s.gutterKey !== gk) {\n      s.gutterKey = gk;\n      const labels = pctT ? [\"100%\"] : niceTicks(0, hiT, yCount).map((v) => c.formatValue(v));\n      let mw = 0;\n      for (const l of labels) mw = Math.max(mw, tw(mono, l));\n      s.gutterT = Math.max(24, Math.ceil(mw) + 10);\n    }\n    s.gutter = approach(s.gutter, s.gutterT, TAU, 0.3);\n    s.ready = true;\n\n    const plot = { l: Math.round(s.gutter), r: w - PAD_R, t: top, b: plotB, ot, ob };\n    s.plot = plot;\n    const pW = Math.max(1, plot.r - plot.l);\n    const span = Math.max(1e-9, s.ve - s.vs);\n    const xOf = (t: number) => plot.l + ((t - s.vs) / span) * pW;\n\n    s.enter = c.reduce ? 1 : Math.min(1, s.enter + (dt * 1000) / ENTER_MS);\n    const e = easeOut(s.enter);\n\n    // Horizontal grid and y labels. The value and percent sets cross-fade through the mode change.\n    const usePct = s.pct >= 0.5;\n    const fade = Math.abs(1 - 2 * s.pct);\n    const ticks = usePct ? (pH < 120 ? [0, 0.5, 1] : [0, 0.25, 0.5, 0.75, 1]) : niceTicks(0, s.hi, yCount).filter((v) => v <= s.hi * 1.0001);\n    const yTick = (v: number) => (usePct ? plot.b - v * pH : plot.b - (v / s.hi) * pH);\n    ctx.lineWidth = 1;\n    ctx.strokeStyle = p.hair;\n    ctx.globalAlpha = fade;\n    ctx.beginPath();\n    for (const v of ticks) {\n      if (v <= 0) continue;\n      const y = crisp(yTick(v));\n      ctx.moveTo(plot.l, y);\n      ctx.lineTo(plot.r, y);\n    }\n    ctx.stroke();\n    ctx.globalAlpha = 1;\n    writeLabels(\n      yPool.current,\n      s.yCache,\n      ticks.map((v) => ({ text: usePct ? formatPercent(v) : c.formatValue(v), x: plot.l - 8, y: yTick(v), ax: -100, opacity: fade })),\n    );\n\n    // Edge geometry for every series over the window, in screen space. When the window holds more\n    // than one point per 3px, the drawing uses bucket means (buckets aligned to absolute indices,\n    // so panning never shimmers; every series shares them, so the stack stays consistent). The\n    // crosshair, tooltip and keyboard still read the true points.\n    const xs = s.xs;\n    const los = s.los;\n    const his = s.his;\n    const kL = 1 - s.lines;\n    const B = Math.max(1, Math.ceil((i1 - i0 + 1) / Math.max(1, pW / 3)));\n    const k0 = Math.max(0, Math.floor(i0 / B) - (B > 1 ? 1 : 0));\n    const k1 = Math.min(Math.floor((N - 1) / B), Math.floor(Math.max(0, i1) / B) + (B > 1 ? 1 : 0));\n    const R = N ? k1 - k0 + 1 : 0;\n    for (let r = 0; r < R; r++) {\n      const ja = (k0 + r) * B;\n      const jb = Math.min(N - 1, ja + B - 1);\n      const cnt = jb - ja + 1;\n      let tm = 0;\n      for (let j = ja; j <= jb; j++) tm += T[j];\n      xs[r] = xOf(tm / cnt);\n      // s.tan doubles as per-series scratch here; the tangents overwrite it later.\n      let tot = 0;\n      for (let i = 0; i < S; i++) {\n        let v = 0;\n        for (let j = ja; j <= jb; j++) v += D[i].values[j];\n        v = (v / cnt) * s.vis[i];\n        s.tan[i] = v;\n        tot += v;\n      }\n      let cum = 0;\n      let cumP = 0;\n      for (let i = 0; i < S; i++) {\n        const v = s.tan[i];\n        const share = tot > 0 ? v / tot : 0;\n        const b0 = cum * kL;\n        const aS = plot.b - (b0 / s.hi) * pH;\n        const bS = plot.b - ((b0 + v) / s.hi) * pH;\n        const aP = plot.b - cumP * pH;\n        const bP = plot.b - (cumP + share) * pH;\n        let ya = aS + (aP - aS) * s.pct;\n        let yb = bS + (bP - bS) * s.pct;\n        if (e < 1) {\n          ya = plot.b + (ya - plot.b) * e;\n          yb = plot.b + (yb - plot.b) * e;\n        }\n        los[i * N + r] = ya;\n        his[i * N + r] = yb;\n        cum += v;\n        cumP += share;\n      }\n    }\n    const ra = 0;\n    const rb = R - 1;\n\n    let topVis = -1;\n    for (let i = S - 1; i >= 0; i--) {\n      if (s.vis[i] > 0.01) {\n        topVis = i;\n        break;\n      }\n    }\n\n    ctx.save();\n    ctx.beginPath();\n    ctx.rect(plot.l, plot.t - 3, pW, pH + 3);\n    ctx.clip();\n    ctx.lineJoin = \"round\";\n    if (rb > ra && S) {\n      const fillBase = FILL_ALPHA[c.tone];\n      for (let i = 0; i < S; i++) {\n        if (s.vis[i] <= 0.01) continue;\n        const em = s.emph[i];\n        const col = c.colors[i];\n        ctx.beginPath();\n        monoTangents(xs, his, i * N, ra, rb, s.tan);\n        traceEdge(ctx, xs, his, i * N, ra, rb, s.tan, false);\n        monoTangents(xs, los, i * N, ra, rb, s.tan);\n        traceEdge(ctx, xs, los, i * N, ra, rb, s.tan, true);\n        ctx.closePath();\n        const fa = Math.min(0.85, fillBase * em) * kL;\n        if (fa > 0.003) {\n          ctx.fillStyle = withAlpha(col, fa);\n          ctx.fill();\n        }\n        if (kL > 0.5) {\n          // The top stroke is clipped to its own band, so it never spills onto a neighbour.\n          ctx.save();\n          ctx.clip();\n          ctx.beginPath();\n          monoTangents(xs, his, i * N, ra, rb, s.tan);\n          traceEdge(ctx, xs, his, i * N, ra, rb, s.tan, false);\n          ctx.lineWidth = i < topVis ? 5 : 3;\n          ctx.strokeStyle = withAlpha(col, clamp(0.3 + 0.7 * em, 0, 1));\n          ctx.stroke();\n          ctx.restore();\n        }\n      }\n      // 2px surface seams between neighbouring bands.\n      if (kL > 0.01) {\n        ctx.strokeStyle = withAlpha(p.stage, kL);\n        ctx.lineWidth = 2;\n        for (let i = 0; i < topVis; i++) {\n          if (s.vis[i] <= 0.01) continue;\n          ctx.beginPath();\n          monoTangents(xs, his, i * N, ra, rb, s.tan);\n          traceEdge(ctx, xs, his, i * N, ra, rb, s.tan, false);\n          ctx.stroke();\n        }\n      }\n      if (kL <= 0.5) {\n        ctx.lineWidth = 2;\n        for (let i = 0; i < S; i++) {\n          if (s.vis[i] <= 0.01) continue;\n          ctx.beginPath();\n          monoTangents(xs, his, i * N, ra, rb, s.tan);\n          traceEdge(ctx, xs, his, i * N, ra, rb, s.tan, false);\n          ctx.strokeStyle = withAlpha(c.colors[i], s.vis[i] * clamp(0.3 + 0.7 * s.emph[i], 0, 1));\n          ctx.stroke();\n        }\n      }\n    }\n    ctx.restore();\n\n    // Baseline.\n    ctx.strokeStyle = p.textFaint;\n    ctx.lineWidth = 1;\n    ctx.beginPath();\n    ctx.moveTo(plot.l, crisp(plot.b));\n    ctx.lineTo(plot.r, crisp(plot.b));\n    ctx.stroke();\n\n    // Calendar x ticks for the window; labels clamp inside the box and drop on collision.\n    const xt = timeTicks(s.vs, s.ve, pW, w < 520 ? 60 : 84);\n    const xl: PlacedLabel[] = [];\n    let lastR = -Infinity;\n    ctx.strokeStyle = p.hair;\n    ctx.beginPath();\n    for (const tk of xt) {\n      const x = xOf(tk.t);\n      if (x < plot.l - 0.5 || x > plot.r + 0.5) continue;\n      ctx.moveTo(crisp(x), plot.b + 1);\n      ctx.lineTo(crisp(x), plot.b + 5);\n      const hw = tw(mono, tk.label) / 2;\n      const cx = clamp(x, hw + 1, w - hw - 1);\n      if (cx - hw < lastR + 8) continue;\n      lastR = cx + hw;\n      xl.push({ text: tk.label, x: cx, y: plot.b + 14, ax: -50 });\n    }\n    ctx.stroke();\n    writeLabels(xPool.current, s.xCache, xl);\n\n    // Direct labels inside bands, at the thickest stretch that fits the label.\n    const inItems: PlacedLabel[] = [];\n    const endItems: PlacedLabel[] = [];\n    const labelIn = clamp((s.enter - 0.7) / 0.3, 0, 1);\n    if (rb - ra >= 2 && kL > 0.02) {\n      // Pixels per drawn point, to turn the label's half width into a reach in points.\n      const per = (xs[rb] - xs[ra]) / Math.max(1, rb - ra);\n      const stride = Math.max(1, Math.floor((rb - ra) / 90));\n      for (let i = 0; i < S; i++) {\n        if (s.vis[i] < 0.5 || c.hiddenSet.has(D[i].id)) continue;\n        const text = D[i].label;\n        const half = tw(alphaFont, text) / 2 + 5;\n        const reach = Math.max(1, Math.round(half / Math.max(0.1, per)));\n        let best = -1;\n        let bestT = 0;\n        for (let j = ra + 1; j < rb; j += stride) {\n          const x = xs[j];\n          if (x - half < plot.l + 2 || x + half > plot.r - 2) continue;\n          const a = Math.max(ra, j - reach);\n          const b = Math.min(rb, j + reach);\n          const o = i * N;\n          const ma = (a + j) >> 1;\n          const mb = (j + b) >> 1;\n          const t = Math.min(los[o + a] - his[o + a], los[o + ma] - his[o + ma], los[o + j] - his[o + j], los[o + mb] - his[o + mb], los[o + b] - his[o + b]);\n          if (t > bestT) {\n            bestT = t;\n            best = j;\n          }\n        }\n        if (best >= 0 && bestT >= 16) {\n          inItems.push({\n            text,\n            x: xs[best],\n            y: (los[i * N + best] + his[i * N + best]) / 2,\n            ax: -50,\n            opacity: kL * labelIn * (s.emph[i] < 0.95 ? 0.5 : 1),\n          });\n        }\n      }\n    }\n    // Lines mode: labels at the right end, pushed apart, when there are few enough lines.\n    if (s.lines > 0.02 && visibleCountOf(c.hiddenSet, D) <= 4 && rb > ra) {\n      let jEnd = rb;\n      while (jEnd > ra && xs[jEnd] > plot.r) jEnd--;\n      const ys: { text: string; y: number; o: number }[] = [];\n      for (let i = 0; i < S; i++) {\n        if (s.vis[i] < 0.5 || c.hiddenSet.has(D[i].id)) continue;\n        ys.push({ text: D[i].label, y: his[i * N + jEnd] - 9, o: s.emph[i] < 0.95 ? 0.5 : 1 });\n      }\n      ys.sort((a, b) => a.y - b.y);\n      for (let k = 1; k < ys.length; k++) if (ys[k].y - ys[k - 1].y < 13) ys[k].y = ys[k - 1].y + 13;\n      const over = ys.length ? ys[ys.length - 1].y - (plot.b - 8) : 0;\n      for (const it of ys) {\n        const y = Math.max(plot.t + 4, it.y - Math.max(0, over));\n        endItems.push({ text: it.text, x: plot.r - 4, y, ax: -100, opacity: s.lines * labelIn * it.o });\n      }\n    }\n    writeLabels(inPool.current, s.inCache, inItems);\n    writeLabels(endPool.current, s.endCache, endItems);\n\n    // Crosshair: rule, a dot on each visible top edge, tooltip beside it.\n    const tip = tipRef.current;\n    const col = s.col;\n    if (col !== null && col >= 0 && col < N && R > 0 && T[col] >= s.vs - span * 1e-6 && T[col] <= s.ve + span * 1e-6) {\n      const x = xOf(T[col]);\n      // Dots sit on the drawn edge: the exact point, or the resampled curve when bucketed.\n      let rr = 0;\n      while (rr < rb && xs[rr + 1] < x) rr++;\n      const f = rr < rb && xs[rr + 1] > xs[rr] ? clamp((x - xs[rr]) / (xs[rr + 1] - xs[rr]), 0, 1) : 0;\n      ctx.strokeStyle = withAlpha(p.text, 0.5);\n      ctx.lineWidth = 1;\n      ctx.beginPath();\n      ctx.moveTo(crisp(x) - 0.5, plot.t - 4);\n      ctx.lineTo(crisp(x) - 0.5, plot.b);\n      ctx.stroke();\n      for (let i = 0; i < S; i++) {\n        if (s.vis[i] < 0.5) continue;\n        ctx.beginPath();\n        ctx.arc(x, his[i * N + rr] + (rr < rb ? (his[i * N + rr + 1] - his[i * N + rr]) * f : 0), 3, 0, Math.PI * 2);\n        ctx.fillStyle = c.colors[i];\n        ctx.fill();\n        ctx.lineWidth = 1.5;\n        ctx.strokeStyle = p.stage;\n        ctx.stroke();\n      }\n      if (tip?.el) {\n        tip.el.style.visibility = \"visible\";\n        const pos = placeTooltip(x, plot.t + 6, tip.size.w, tip.size.h, w, Math.max(plot.b + 8, plot.t + 6 + tip.size.h), 14);\n        tip.el.style.transform = `translate3d(${pos.x}px, ${Math.max(plot.t, pos.y)}px, 0)`;\n      }\n    } else if (tip?.el) tip.el.style.visibility = \"hidden\";\n\n    // Overview strip: the total over the whole axis, with the brushed window.\n    if (brushOn) {\n      const oT = ot;\n      const oH = ob - ot;\n      ctx.fillStyle = withAlpha(p.text, 0.03);\n      ctx.beginPath();\n      roundRectPath(ctx, plot.l, oT, pW, oH, 6, 6);\n      ctx.fill();\n      const oxOf = (t: number) => plot.l + ((t - d0) / full) * pW;\n      let maxTot = 0;\n      for (let j = 0; j < N; j++) {\n        let tot = 0;\n        for (let i = 0; i < S; i++) tot += D[i].values[j] * s.vis[i];\n        s.tot[j] = tot;\n        if (tot > maxTot) maxTot = tot;\n      }\n      const base = ob - 2;\n      const oy = (v: number) => base - (maxTot > 0 ? v / maxTot : 0) * (oH - 8);\n      // One vertex per pixel column, keeping each column's peak.\n      const tracePeaks = () => {\n        let px = -1;\n        let pm = 0;\n        let started = false;\n        for (let j = 0; j < N; j++) {\n          const x = Math.round(oxOf(T[j]));\n          if (x !== px) {\n            if (px >= 0) {\n              if (!started) {\n                ctx.moveTo(px, oy(pm));\n                started = true;\n              } else ctx.lineTo(px, oy(pm));\n            }\n            px = x;\n            pm = s.tot[j];\n          } else if (s.tot[j] > pm) pm = s.tot[j];\n        }\n        if (!started) ctx.moveTo(px, oy(pm));\n        else ctx.lineTo(px, oy(pm));\n      };\n      ctx.beginPath();\n      tracePeaks();\n      ctx.lineTo(plot.r, base);\n      ctx.lineTo(plot.l, base);\n      ctx.closePath();\n      ctx.fillStyle = withAlpha(p.text, 0.1);\n      ctx.fill();\n      ctx.beginPath();\n      tracePeaks();\n      ctx.strokeStyle = withAlpha(p.text, 0.32);\n      ctx.lineWidth = 1;\n      ctx.stroke();\n\n      const bx0 = oxOf(s.vs);\n      const bx1 = oxOf(s.ve);\n      const whole = s.vs <= d0 + full * 1e-6 && s.ve >= d1 - full * 1e-6;\n      if (!whole) {\n        ctx.fillStyle = withAlpha(p.stage, 0.62);\n        ctx.fillRect(plot.l, oT, bx0 - plot.l, oH);\n        ctx.fillRect(bx1, oT, plot.r - bx1, oH);\n      }\n      ctx.fillStyle = withAlpha(p.accent, whole ? 0.05 : 0.08);\n      ctx.fillRect(bx0, oT, bx1 - bx0, oH);\n      ctx.strokeStyle = withAlpha(p.accentInk, whole ? 0.45 : 0.9);\n      ctx.lineWidth = 1;\n      ctx.strokeRect(Math.round(bx0) + 0.5, oT + 0.5, Math.max(1, Math.round(bx1 - bx0) - 1), oH - 1);\n      for (const gx of [bx0, bx1]) {\n        ctx.fillStyle = p.accent;\n        ctx.beginPath();\n        roundRectPath(ctx, gx - 2.5, oT + oH / 2 - 8, 5, 16, 2.5, 2.5);\n        ctx.fill();\n      }\n      const hs = startRef.current;\n      const he = endRef.current;\n      const hb = bodyRef.current;\n      if (hs) hs.style.transform = `translate3d(${(bx0 - 8).toFixed(1)}px, ${oT}px, 0)`;\n      if (he) he.style.transform = `translate3d(${(bx1 - 8).toFixed(1)}px, ${oT}px, 0)`;\n      if (hb) {\n        hb.style.transform = `translate3d(${bx0.toFixed(1)}px, ${oT}px, 0)`;\n        hb.style.width = `${Math.max(0, bx1 - bx0).toFixed(1)}px`;\n      }\n    }\n\n    return moving || s.enter < 1 || !!s.drag;\n  });\n\n  // Fonts landing changes every measurement.\n  useEffect(() => {\n    if (typeof document === \"undefined\" || !document.fonts) return;\n    let live = true;\n    document.fonts.ready.then(() => {\n      if (!live) return;\n      const s = st.current;\n      s.widths.clear();\n      s.fonts = null;\n      s.gutterKey = \"\";\n      s.legendW = -1;\n      wake();\n    });\n    return () => {\n      live = false;\n    };\n  }, [wake]);\n\n  const syncAria = () => {\n    const s = st.current;\n    const [d0, d1] = domain;\n    const set = (el: HTMLElement | null, now: number, text: string) => {\n      if (!el) return;\n      el.setAttribute(\"aria-valuemin\", String(Math.round(d0)));\n      el.setAttribute(\"aria-valuemax\", String(Math.round(d1)));\n      el.setAttribute(\"aria-valuenow\", String(Math.round(now)));\n      el.setAttribute(\"aria-valuetext\", text);\n    };\n    set(startRef.current, s.ts, formatTime(s.ts));\n    set(endRef.current, s.te, formatTime(s.te));\n    set(bodyRef.current, s.ts, `${formatTime(s.ts)} to ${formatTime(s.te)}`);\n  };\n\n  const scheduleTable = () => {\n    if (tableTimer.current) clearTimeout(tableTimer.current);\n    tableTimer.current = setTimeout(() => {\n      const s = st.current;\n      setTableRange((prev) => (prev[0] === s.ts && prev[1] === s.te ? prev : [s.ts, s.te]));\n    }, 160);\n  };\n  useEffect(\n    () => () => {\n      if (tableTimer.current) clearTimeout(tableTimer.current);\n    },\n    [],\n  );\n\n  const setView = (a: number, b: number, commit: boolean) => {\n    const s = st.current;\n    [s.ts, s.te] = clampWindow(a, b, domain[0], domain[1], minSpan);\n    syncAria();\n    if (commit) {\n      onRangeChange?.([s.ts, s.te]);\n      scheduleTable();\n    }\n    wake();\n  };\n\n  // Controlled window.\n  useEffect(() => {\n    if (!range) return;\n    const s = st.current;\n    [s.ts, s.te] = clampWindow(range[0], range[1], domain[0], domain[1], minSpan);\n    syncAria();\n    scheduleTable();\n    wake();\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [range?.[0], range?.[1], wake]);\n\n  // A new axis keeps the window inside it.\n  useEffect(() => {\n    const s = st.current;\n    [s.ts, s.te] = clampWindow(s.ts, s.te, domain[0], domain[1], minSpan);\n    if (s.col !== null && s.col >= n) s.col = null;\n    syncAria();\n    scheduleTable();\n    wake();\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [domain, minSpan, n, wake]);\n\n  const visibleRows = (j: number) => {\n    let tot = 0;\n    for (const sr of data) if (!hiddenSet.has(sr.id)) tot += sr.values[j] ?? 0;\n    return { tot, rows: data.map((sr, i) => ({ sr, i, v: sr.values[j] ?? 0 })).filter((r) => !hiddenSet.has(r.sr.id)) };\n  };\n\n  const tooltipFor = (j: number): TooltipContent | null => {\n    if (j < 0 || j >= n) return null;\n    const { tot, rows } = visibleRows(j);\n    const out: TooltipRow[] = [...rows].reverse().map(({ sr, i, v }) => ({\n      key: sr.id,\n      label: sr.label,\n      value: mode === \"percent\" ? formatShare(tot > 0 ? v / tot : 0) : formatValue(v),\n      color: colors[i],\n    }));\n    out.push({ key: \"__total\", label: \"Total\", value: formatValue(tot) });\n    return { key: `${j}|${mode}|${[...hiddenSet].join(\",\")}|${pal.text}|${data.length}`, title: formatTime(times[j]), rows: out };\n  };\n\n  const describe = (j: number) => {\n    const { tot, rows } = visibleRows(j);\n    const parts = [...rows].reverse().map(({ sr, v }) => `${sr.label} ${mode === \"percent\" ? formatShare(tot > 0 ? v / tot : 0) : formatValue(v)}`);\n    return `${formatTime(times[j])}. Total ${formatValue(tot)}. ${parts.join(\", \")}`;\n  };\n\n  const setCursor = (j: number | null, source: Run[\"source\"]) => {\n    const s = st.current;\n    const changed = s.col !== j;\n    s.col = j;\n    s.source = j === null ? null : source;\n    if (changed) tipRef.current?.set(j === null ? null : tooltipFor(j));\n    if (changed && j !== null && source === \"keyboard\") announcer.current?.say(describe(j));\n    wake();\n  };\n\n  // Refresh an open tooltip when what it shows changes.\n  useEffect(() => {\n    const s = st.current;\n    if (s.col !== null) tipRef.current?.set(tooltipFor(s.col));\n    s.gutterKey = \"\";\n    wake();\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [data, colors, hiddenSet, mode, pal, reduce, formatValue, formatTime, brush, wake]);\n\n  // Posed crosshair.\n  useEffect(() => {\n    if (activeIndex === undefined && activeTime === undefined) return;\n    const j = activeIndex != null ? clamp(Math.round(activeIndex), 0, n - 1) : activeTime != null ? nearestIndex(times, activeTime) : null;\n    setCursor(j !== null && j >= 0 && n ? j : null, \"prop\");\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [activeIndex, activeTime, times, n]);\n\n  useEffect(() => {\n    syncAria();\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [formatTime, brush]);\n\n  const local = (e: PointerEvent<HTMLDivElement>) => {\n    const r = rectRef.current ?? wrapperRef.current?.getBoundingClientRect();\n    return r ? { x: e.clientX - r.left, y: e.clientY - r.top } : null;\n  };\n  const brushOn = brush && n > 1;\n  const inBrush = (x: number, y: number) => {\n    const P = st.current.plot;\n    return brushOn && y >= P.ot - 6 && y <= P.ob + 4 && x >= P.l - 12 && x <= P.r + 12;\n  };\n  const brushHit = (x: number, touch: boolean): \"left\" | \"right\" | \"move\" | null => {\n    const s = st.current;\n    const P = s.plot;\n    const [d0, d1] = domain;\n    const ox = (t: number) => P.l + ((t - d0) / (d1 - d0)) * (P.r - P.l);\n    const bx0 = ox(s.ts);\n    const bx1 = ox(s.te);\n    const slop = touch ? 16 : 9;\n    const dl = Math.abs(x - bx0);\n    const dr = Math.abs(x - bx1);\n    if (dl <= slop && dl <= dr) return \"left\";\n    if (dr <= slop) return \"right\";\n    if (x > bx0 && x < bx1) return \"move\";\n    return null;\n  };\n\n  const onPointerDown = (e: PointerEvent<HTMLDivElement>) => {\n    if (wrapperRef.current) rectRef.current = wrapperRef.current.getBoundingClientRect();\n    const pt = local(e);\n    if (!pt) return;\n    const s = st.current;\n    if (inBrush(pt.x, pt.y)) {\n      let mode = brushHit(pt.x, e.pointerType === \"touch\");\n      if (!mode) {\n        // Click outside the window: centre it there, then keep dragging it.\n        const P = s.plot;\n        const t = domain[0] + ((pt.x - P.l) / Math.max(1, P.r - P.l)) * (domain[1] - domain[0]);\n        const wv = s.te - s.ts;\n        setView(t - wv / 2, t + wv / 2, false);\n        mode = \"move\";\n      }\n      s.drag = { mode, x: pt.x, vs: s.ts, ve: s.te, id: e.pointerId };\n      e.currentTarget.setPointerCapture(e.pointerId);\n      e.currentTarget.style.cursor = mode === \"move\" ? \"grabbing\" : \"ew-resize\";\n      if (s.source === \"pointer\") setCursor(null, null);\n      wake();\n      return;\n    }\n    if (e.pointerType === \"touch\") onPointerMove(e);\n  };\n\n  const onPointerMove = (e: PointerEvent<HTMLDivElement>) => {\n    const pt = local(e);\n    if (!pt) return;\n    const s = st.current;\n    const P = s.plot;\n    const pW = Math.max(1, P.r - P.l);\n    if (s.drag && s.drag.id === e.pointerId) {\n      const dT = ((pt.x - s.drag.x) / pW) * (domain[1] - domain[0]);\n      const { vs, ve } = s.drag;\n      if (s.drag.mode === \"move\") setView(vs + dT, ve + dT, false);\n      else if (s.drag.mode === \"left\") setView(Math.min(vs + dT, ve - minSpan), ve, false);\n      else setView(vs, Math.max(ve + dT, vs + minSpan), false);\n      return;\n    }\n    const el = e.currentTarget;\n    if (inBrush(pt.x, pt.y)) {\n      const hit = brushHit(pt.x, false);\n      el.style.cursor = hit === \"move\" ? \"grab\" : hit ? \"ew-resize\" : \"pointer\";\n      if (s.source === \"pointer\") setCursor(null, null);\n      return;\n    }\n    if (pt.x < P.l || pt.x > P.r || pt.y < P.t - 6 || pt.y > P.b + 4 || !n) {\n      el.style.cursor = \"\";\n      if (s.source === \"pointer\") setCursor(null, null);\n      return;\n    }\n    el.style.cursor = \"crosshair\";\n    const t = s.vs + ((pt.x - P.l) / pW) * (s.ve - s.vs);\n    let j = nearestIndex(times, t);\n    const a = lowerBound(times, s.vs);\n    const b = lowerBound(times, s.ve + 1e-6) - 1;\n    if (a <= b) j = clamp(j, a, b);\n    setCursor(j, \"pointer\");\n  };\n\n  const endDrag = (e: PointerEvent<HTMLDivElement>) => {\n    const s = st.current;\n    if (s.drag && s.drag.id === e.pointerId) {\n      s.drag = null;\n      e.currentTarget.style.cursor = \"\";\n      setView(s.ts, s.te, true);\n    }\n  };\n\n  const onDoubleClick = (e: MouseEvent<HTMLDivElement>) => {\n    const r = wrapperRef.current?.getBoundingClientRect();\n    if (!r) return;\n    if (inBrush(e.clientX - r.left, e.clientY - r.top)) setView(domain[0], domain[1], true);\n  };\n\n  // Moves the window so point j is inside it.\n  const ensureVisible = (j: number) => {\n    const s = st.current;\n    const t = times[j];\n    const wv = s.te - s.ts;\n    if (t < s.ts) setView(t, t + wv, true);\n    else if (t > s.te) setView(t - wv, t, true);\n  };\n\n  const onKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n    if (e.target !== e.currentTarget || !n) return;\n    const s = st.current;\n    const a = Math.min(n - 1, lowerBound(times, s.ts));\n    const b = Math.max(a, lowerBound(times, s.te + 1e-6) - 1);\n    const page = Math.max(1, Math.round((b - a + 1) * 0.1));\n    let next: number | null = null;\n    if (e.key === \"ArrowRight\" || e.key === \"ArrowLeft\") next = s.col === null || s.source === \"pointer\" ? (e.key === \"ArrowRight\" ? a : b) : s.col + (e.key === \"ArrowRight\" ? 1 : -1);\n    else if (e.key === \"PageUp\" || e.key === \"PageDown\") next = (s.col ?? (e.key === \"PageUp\" ? a : b)) + (e.key === \"PageUp\" ? page : -page);\n    else if (e.key === \"Home\") next = a;\n    else if (e.key === \"End\") next = b;\n    else if (e.key === \"Escape\") {\n      if (s.col === null) return;\n      e.preventDefault();\n      setCursor(null, null);\n      return;\n    }\n    if (next === null) return;\n    e.preventDefault();\n    next = clamp(next, 0, n - 1);\n    ensureVisible(next);\n    setCursor(next, \"keyboard\");\n  };\n\n  const onSliderKey = (which: \"start\" | \"end\" | \"window\", e: KeyboardEvent<HTMLDivElement>) => {\n    const s = st.current;\n    const [d0, d1] = domain;\n    const big = (d1 - d0) * 0.1;\n    let d = 0;\n    let to: \"min\" | \"max\" | null = null;\n    if (e.key === \"ArrowLeft\" || e.key === \"ArrowDown\") d = -stepMs;\n    else if (e.key === \"ArrowRight\" || e.key === \"ArrowUp\") d = stepMs;\n    else if (e.key === \"PageDown\") d = -big;\n    else if (e.key === \"PageUp\") d = big;\n    else if (e.key === \"Home\") to = \"min\";\n    else if (e.key === \"End\") to = \"max\";\n    else return;\n    e.preventDefault();\n    e.stopPropagation();\n    const wv = s.te - s.ts;\n    if (which === \"start\") {\n      const v = to === \"min\" ? d0 : to === \"max\" ? s.te - minSpan : clamp(s.ts + d, d0, s.te - minSpan);\n      setView(v, s.te, true);\n    } else if (which === \"end\") {\n      const v = to === \"min\" ? s.ts + minSpan : to === \"max\" ? d1 : clamp(s.te + d, s.ts + minSpan, d1);\n      setView(s.ts, v, true);\n    } else {\n      const v = to === \"min\" ? d0 : to === \"max\" ? d1 - wv : s.ts + d;\n      setView(v, v + wv, true);\n    }\n  };\n\n  const toggle = (id: string) => {\n    const off = hiddenSet.has(id);\n    if (!off && visibleCount <= 1) return;\n    const next = off ? hiddenList.filter((x) => x !== id) : [...hiddenList.filter((x) => x !== id), id];\n    if (hiddenProp === undefined) setHiddenState(next);\n    onHiddenChange?.(next);\n  };\n\n  // Legend hover and focus emphasise a band without re-rendering the chart.\n  const emphasise = (id: string | null) => {\n    const s = st.current;\n    const target = id && !hiddenSet.has(id) ? id : null;\n    if (s.focusId === target) return;\n    s.focusId = target;\n    data.forEach((sr, i) => {\n      const el = legendBtns.current[i];\n      if (el) el.dataset.dim = target && sr.id !== target ? \"true\" : \"false\";\n    });\n    wake();\n  };\n\n  const tableCols = useMemo(() => [\"Date\", ...data.filter((s) => !hiddenSet.has(s.id)).map((s) => s.label), \"Total\"], [data, hiddenSet]);\n  const { tableRows, tableCaption } = useMemo(() => {\n    const vis = data.filter((s) => !hiddenSet.has(s.id));\n    const a = lowerBound(times, tableRange[0]);\n    const b = lowerBound(times, tableRange[1] + 1e-6) - 1;\n    const count = Math.max(0, b - a + 1);\n    const rows: (string | number)[][] = [];\n    if (count <= TABLE_MAX_ROWS) {\n      for (let j = a; j <= b; j++) {\n        let tot = 0;\n        const cells = vis.map((s) => {\n          tot += s.values[j];\n          return formatValue(s.values[j]);\n        });\n        rows.push([formatTime(times[j]), ...cells, formatValue(tot)]);\n      }\n      return { tableRows: rows, tableCaption: `${ariaLabel}, ${count} points` };\n    }\n    // Too many rows to read: roll up by week (Monday start) or by month.\n    const byMonth = times[b] - times[a] > 182 * DAY;\n    const keyOf = (t: number) => {\n      if (byMonth) {\n        const d = new Date(t);\n        return Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), 1);\n      }\n      return Math.floor((t - 4 * DAY) / (7 * DAY)) * 7 * DAY + 4 * DAY;\n    };\n    let j = a;\n    while (j <= b) {\n      const k = keyOf(times[j]);\n      let end = j;\n      while (end + 1 <= b && keyOf(times[end + 1]) === k) end++;\n      let tot = 0;\n      const cells = vis.map((s) => {\n        let v = 0;\n        if (tableAggregate === \"last\") v = s.values[end];\n        else {\n          for (let q = j; q <= end; q++) v += s.values[q];\n          if (tableAggregate === \"mean\") v /= end - j + 1;\n        }\n        tot += v;\n        return formatValue(v);\n      });\n      rows.push([byMonth ? monthFmt.format(k) : `Week of ${weekFmt.format(Math.max(k, times[j]))}`, ...cells, formatValue(tot)]);\n      j = end + 1;\n    }\n    const how = tableAggregate === \"mean\" ? \"averages\" : tableAggregate === \"sum\" ? \"totals\" : \"closing values\";\n    return { tableRows: rows, tableCaption: `${ariaLabel}, ${byMonth ? \"monthly\" : \"weekly\"} ${how}` };\n  }, [data, hiddenSet, times, tableRange, tableAggregate, formatValue, formatTime, ariaLabel]);\n\n  const summary = useMemo(() => {\n    if (!n || !data.length) return `${ariaLabel}: no data`;\n    const j = n - 1;\n    let tot = 0;\n    let best = -1;\n    let bestV = -1;\n    data.forEach((sr, i) => {\n      if (hiddenSet.has(sr.id)) return;\n      tot += sr.values[j];\n      if (sr.values[j] > bestV) {\n        bestV = sr.values[j];\n        best = i;\n      }\n    });\n    const lead = best >= 0 && tot > 0 ? `, largest ${data[best].label} at ${formatShare(bestV / tot)}` : \"\";\n    return `${ariaLabel}: ${visibleCount} series from ${formatTime(times[0])} to ${formatTime(times[n - 1])}. Latest total ${formatValue(tot)}${lead}.`;\n  }, [n, data, hiddenSet, times, ariaLabel, visibleCount, formatTime, formatValue]);\n\n  const keyShape = mode === \"lines\" ? \"line\" : \"rect\";\n\n  return (\n    <div ref={rootRef} data-loop=\"idle\" className={cn(\"relative w-full select-none text-[color:var(--bjork-text)]\", className)} style={{ ...vars, height }}>\n      <div ref={legendRef} role=\"group\" aria-label=\"Series\" className=\"pointer-events-none absolute inset-x-0 top-0 z-10 flex flex-wrap items-center gap-x-2 gap-y-1\">\n        {data.map((sr, i) => {\n          const off = hiddenSet.has(sr.id);\n          const locked = !off && visibleCount <= 1;\n          return (\n            <button\n              key={sr.id}\n              ref={(el) => {\n                legendBtns.current[i] = el;\n              }}\n              type=\"button\"\n              aria-pressed={!off}\n              aria-disabled={locked || undefined}\n              onClick={() => toggle(sr.id)}\n              onPointerEnter={() => emphasise(sr.id)}\n              onPointerLeave={() => emphasise(null)}\n              onFocus={() => emphasise(sr.id)}\n              onBlur={() => emphasise(null)}\n              className={cn(\n                \"pointer-events-auto inline-flex items-center gap-1.5 rounded-[6px] px-1 py-1 font-bjork-alpha text-[11px] font-medium leading-3 text-[color:var(--bjork-text-medium)] transition-opacity duration-150 ease-out hover:text-[color:var(--bjork-text)] data-[dim=true]:opacity-50\",\n                off && \"opacity-45\",\n                locked ? \"cursor-default\" : \"cursor-pointer\",\n                chartFocusRing,\n              )}\n            >\n              {off ? (\n                <span aria-hidden=\"true\" className=\"inline-block size-2 rounded-[2px] border\" style={{ borderColor: colors[i] }} />\n              ) : (\n                <LegendKey color={colors[i]} shape={keyShape} />\n              )}\n              {sr.label}\n            </button>\n          );\n        })}\n      </div>\n      <div\n        ref={wrapperRef}\n        role=\"group\"\n        aria-roledescription=\"chart\"\n        aria-label={`${ariaLabel}. Left and right step through points, Page Up and Page Down jump, Home and End go to the ends of the window, Escape clears.`}\n        tabIndex={0}\n        onPointerEnter={() => {\n          if (wrapperRef.current) rectRef.current = wrapperRef.current.getBoundingClientRect();\n        }}\n        onPointerDown={onPointerDown}\n        onPointerMove={onPointerMove}\n        onPointerUp={endDrag}\n        onPointerCancel={endDrag}\n        onPointerLeave={(e) => {\n          // A touch tap or scrub fires leave on lift; keep the crosshair until the next touch.\n          if (e.pointerType !== \"touch\" && st.current.source === \"pointer\") setCursor(null, null);\n        }}\n        onDoubleClick={onDoubleClick}\n        onBlur={() => setCursor(null, null)}\n        onKeyDown={onKeyDown}\n        className={cn(\"absolute inset-0 touch-pan-y rounded-[10px]\", chartFocusRing)}\n      >\n        <div ref={hostRef} className=\"pointer-events-none absolute inset-0\">\n          <canvas ref={canvasRef} role=\"img\" aria-label={summary} className=\"pointer-events-none absolute left-0 top-0\" />\n        </div>\n        <LabelPool count={Y_LABELS} pool={yPool} />\n        <LabelPool count={X_LABELS} pool={xPool} />\n        <LabelPool\n          count={MAX_SERIES}\n          pool={inPool}\n          className=\"font-bjork-alpha text-[11px] font-medium leading-none text-[color:var(--bjork-text)] [text-box:trim-both_cap_alphabetic]\"\n        />\n        <LabelPool\n          count={MAX_SERIES}\n          pool={endPool}\n          className=\"font-bjork-alpha text-[11px] font-medium leading-none text-[color:var(--bjork-text-medium)] [text-box:trim-both_cap_alphabetic] [text-shadow:0_0_3px_var(--bjork-chart-bg),0_0_3px_var(--bjork-chart-bg)]\"\n        />\n        {brushOn && (\n          <>\n            <div\n              ref={startRef}\n              role=\"slider\"\n              tabIndex={0}\n              aria-label=\"Window start\"\n              aria-orientation=\"horizontal\"\n              onKeyDown={(e) => onSliderKey(\"start\", e)}\n              aria-valuenow={Math.round(initWindow[0])}\n              className={cn(\"absolute left-0 top-0 z-[1] w-4 rounded-[6px]\", chartFocusRing)}\n              style={{ height: BRUSH_H }}\n            />\n            <div\n              ref={bodyRef}\n              role=\"slider\"\n              tabIndex={0}\n              aria-label=\"Brushed window\"\n              aria-orientation=\"horizontal\"\n              onKeyDown={(e) => onSliderKey(\"window\", e)}\n              aria-valuenow={Math.round(initWindow[0])}\n              className={cn(\"absolute left-0 top-0 rounded-[4px]\", chartFocusRing)}\n              style={{ height: BRUSH_H }}\n            />\n            <div\n              ref={endRef}\n              role=\"slider\"\n              tabIndex={0}\n              aria-label=\"Window end\"\n              aria-orientation=\"horizontal\"\n              onKeyDown={(e) => onSliderKey(\"end\", e)}\n              aria-valuenow={Math.round(initWindow[1])}\n              className={cn(\"absolute left-0 top-0 z-[1] w-4 rounded-[6px]\", chartFocusRing)}\n              style={{ height: BRUSH_H }}\n            />\n          </>\n        )}\n        <HoverTooltip ref={tipRef} onMeasure={wake} />\n      </div>\n      <ChartTable caption={tableCaption} columns={tableCols} rows={tableRows} />\n      <ChartAnnouncer ref={announcer} />\n    </div>\n  );\n}\n\nfunction visibleCountOf(hidden: Set<string>, data: Clean[]): number {\n  let k = 0;\n  for (const d of data) if (!hidden.has(d.id)) k++;\n  return k;\n}\n",
      "type": "registry:component",
      "target": "@components/bjork-ui/charts/stacked-area-chart.tsx"
    },
    {
      "path": "lib/utils.ts",
      "content": "import { clsx, type ClassValue } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs))\n}\n",
      "type": "registry:lib",
      "target": "@lib/utils.ts"
    },
    {
      "path": "components/bjork-ui/_core/palette.ts",
      "content": "export type BjorkTone = \"dark\" | \"light\";\n\n// Canvas, WebGL and SVG attribute colours. DOM code uses the CSS tokens with these as fallbacks.\nexport const BJORK_PALETTE = {\n  dark: {\n    bg: \"#050505\", stage: \"#111111\", surface: \"#121212\", raised: \"#161616\", active: \"#202020\",\n    border: \"#232323\", borderStrong: \"#343434\",\n    text: \"#ededed\", textMedium: \"rgba(237,237,237,0.72)\", textMuted: \"rgba(237,237,237,0.6)\",\n    textSoft: \"rgba(237,237,237,0.5)\", textFaint: \"rgba(237,237,237,0.22)\", hair: \"rgba(237,237,237,0.12)\",\n    accent: \"#ec5c13\", accentInk: \"#ec5c13\", accentFill: \"#b84a12\", accentSoft: \"rgba(236,92,19,0.12)\", accentMuted: \"rgba(236,92,19,0.24)\",\n    accentFg: \"#fff2ea\", success: \"#4cc38a\", warning: \"#f2b544\", error: \"#ff5c4d\",\n  },\n  light: {\n    bg: \"#f7f5ef\", stage: \"#f7f5ef\", surface: \"#fffcf6\", raised: \"#f5efe3\", active: \"#efe7d8\",\n    border: \"#eee6db\", borderStrong: \"#e1d7c8\",\n    text: \"#171717\", textMedium: \"rgba(23,23,23,0.78)\", textMuted: \"rgba(23,23,23,0.68)\",\n    textSoft: \"rgba(23,23,23,0.62)\", textFaint: \"rgba(23,23,23,0.22)\", hair: \"rgba(23,23,23,0.10)\",\n    accent: \"#ec7d43\", accentInk: \"#b4531f\", accentFill: \"#ec7d43\", accentSoft: \"rgba(236,125,67,0.10)\", accentMuted: \"rgba(236,125,67,0.20)\",\n    accentFg: \"#3f2112\", success: \"#1f8a55\", warning: \"#a86b00\", error: \"#c8361f\",\n  },\n} as const;\n",
      "type": "registry:component",
      "target": "@components/bjork-ui/_core/palette.ts"
    },
    {
      "path": "components/bjork-ui/charts/_kit/canvas.ts",
      "content": "\"use client\";\n\n// Canvas plumbing shared by the Charts collection. One hook gives a chart a measured host, a\n// DPR-capped canvas that follows it, and a draw loop that pauses offscreen and idles when settled.\n\nimport { useCallback, useEffect, useRef, type RefObject } from \"react\";\nimport { useVisibleLoop } from \"@/components/bjork-ui/_core/loop\";\nimport { sizeCanvas, useElementSize } from \"@/components/bjork-ui/_core/canvas\";\nimport { cubicBezier, ease } from \"@/components/bjork-ui/_core/motion\";\n\nexport interface ChartFrame {\n  ctx: CanvasRenderingContext2D;\n  w: number;\n  h: number;\n  dt: number;\n  t: number;\n}\n\n/**\n * `draw` runs inside `useVisibleLoop`. Return true to keep animating, false to go idle until `wake()`.\n * The loop root is `rootRef` (gets `data-loop`). The canvas is sized to `hostRef`.\n */\nexport function useChartCanvas(draw: (f: ChartFrame) => boolean) {\n  const rootRef = useRef<HTMLDivElement>(null);\n  const hostRef = useRef<HTMLDivElement>(null);\n  const canvasRef = useRef<HTMLCanvasElement>(null);\n  const size = useElementSize(hostRef);\n  const sizeRef = useRef({ w: 0, h: 0, dpr: 1 });\n  const drawRef = useRef(draw);\n  useEffect(() => {\n    drawRef.current = draw;\n  });\n\n  const frame = useCallback((dt: number, t: number) => {\n    const canvas = canvasRef.current;\n    const { w, h, dpr } = sizeRef.current;\n    if (!canvas || !w || !h) return true;\n    const ctx = canvas.getContext(\"2d\");\n    if (!ctx) return false;\n    ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n    ctx.clearRect(0, 0, w, h);\n    return drawRef.current({ ctx, w, h, dt, t });\n  }, []);\n\n  const { wake } = useVisibleLoop(rootRef as RefObject<HTMLElement | null>, frame);\n\n  useEffect(() => {\n    const canvas = canvasRef.current;\n    if (!canvas || !size.width || !size.height) return;\n    sizeRef.current = { w: size.width, h: size.height, dpr: sizeCanvas(canvas, size.width, size.height) };\n    wake();\n  }, [size.width, size.height, wake]);\n\n  return { rootRef, hostRef, canvasRef, size, wake };\n}\n\n// The house ease-out for entrances, usable in rAF code.\nexport const easeOut = cubicBezier(...(ease.out as unknown as [number, number, number, number]));\nexport const easeInOut = cubicBezier(...(ease.inOut as unknown as [number, number, number, number]));\n\n// A 45 degree hatch pattern in `color`, for counterfactual and loss regions.\nconst hatchCache = new Map<string, CanvasPattern | null>();\nexport function hatchPattern(ctx: CanvasRenderingContext2D, color: string, gap = 5, width = 1): CanvasPattern | null {\n  const key = `${color}|${gap}|${width}`;\n  if (hatchCache.has(key)) return hatchCache.get(key)!;\n  if (typeof document === \"undefined\") return null;\n  const tile = document.createElement(\"canvas\");\n  const s = gap * 2;\n  tile.width = s * 2;\n  tile.height = s * 2;\n  const c = tile.getContext(\"2d\");\n  if (!c) return null;\n  c.scale(2, 2);\n  c.strokeStyle = color;\n  c.lineWidth = width;\n  c.beginPath();\n  for (let k = -s; k <= s * 2; k += gap) {\n    c.moveTo(k, s);\n    c.lineTo(k + s, 0);\n  }\n  c.stroke();\n  const pattern = ctx.createPattern(tile, \"repeat\");\n  pattern?.setTransform(new DOMMatrix().scale(0.5, 0.5));\n  hatchCache.set(key, pattern);\n  return pattern;\n}\n\n// Rounded rect path with independent top and bottom radii (bars: round data end, square baseline).\nexport function roundRectPath(\n  ctx: CanvasRenderingContext2D,\n  x: number,\n  y: number,\n  w: number,\n  h: number,\n  rTop: number,\n  rBottom = 0,\n) {\n  if (w <= 0 || h <= 0) return;\n  const rt = Math.min(rTop, w / 2, h / 2);\n  const rb = Math.min(rBottom, w / 2, h / 2);\n  ctx.moveTo(x + rt, y);\n  ctx.lineTo(x + w - rt, y);\n  if (rt) ctx.arcTo(x + w, y, x + w, y + rt, rt);\n  ctx.lineTo(x + w, y + h - rb);\n  if (rb) ctx.arcTo(x + w, y + h, x + w - rb, y + h, rb);\n  ctx.lineTo(x + rb, y + h);\n  if (rb) ctx.arcTo(x, y + h, x, y + h - rb, rb);\n  ctx.lineTo(x, y + rt);\n  if (rt) ctx.arcTo(x, y, x + rt, y, rt);\n  ctx.closePath();\n}\n\nexport interface PlacedLabel {\n  text: string;\n  x: number;\n  y: number;\n  /** translate percentages applied after the position, e.g. -50 to centre. */\n  ax?: number;\n  ay?: number;\n  opacity?: number;\n}\n\n// Writes a pool of absolutely positioned label spans from the loop: text only when it changes,\n// position by transform only. Unused spans hide.\nexport function writeLabels(els: (HTMLElement | null)[], cache: string[], items: PlacedLabel[]) {\n  for (let i = 0; i < els.length; i++) {\n    const el = els[i];\n    if (!el) continue;\n    const it = items[i];\n    if (!it) {\n      if (el.style.opacity !== \"0\") el.style.opacity = \"0\";\n      continue;\n    }\n    if (cache[i] !== it.text) {\n      cache[i] = it.text;\n      el.textContent = it.text;\n    }\n    el.style.opacity = String(it.opacity ?? 1);\n    el.style.transform = `translate3d(${it.x.toFixed(2)}px, ${it.y.toFixed(2)}px, 0) translate(${it.ax ?? 0}%, ${it.ay ?? -50}%)`;\n  }\n}\n",
      "type": "registry:component",
      "target": "@components/bjork-ui/charts/_kit/canvas.ts"
    },
    {
      "path": "components/bjork-ui/_core/loop.ts",
      "content": "\"use client\";\n\nimport { useCallback, useEffect, useMemo, useRef, type RefObject } from \"react\";\n\nexport interface VisibleLoopOptions {\n  enabled?: boolean;\n  fpsCap?: number;\n  rootMargin?: string;\n}\n\n/**\n * Runs `frame(dt, t)` on requestAnimationFrame while the element is near the viewport,\n * the tab is visible and `enabled` is not false. Return `false` from `frame` to go idle\n * until `wake()` is called. Writes `data-loop` on the element: running, idle or paused.\n */\nexport function useVisibleLoop(\n  ref: RefObject<HTMLElement | null>,\n  frame: (dt: number, t: number) => boolean | void,\n  opts?: VisibleLoopOptions,\n): { wake: () => void } {\n  const enabled = opts?.enabled !== false;\n  const fpsCap = opts?.fpsCap ?? 0;\n  const rootMargin = opts?.rootMargin ?? \"96px\";\n\n  const frameRef = useRef(frame);\n  useEffect(() => {\n    frameRef.current = frame;\n  }, [frame]);\n\n  const wakeRef = useRef<() => void>(() => {});\n  const wake = useCallback(() => wakeRef.current(), []);\n\n  useEffect(() => {\n    const el = ref.current;\n    if (!el || typeof window === \"undefined\") return;\n\n    let wants = true; // false once the frame callback returns false\n    let inView = false;\n    let raf = 0;\n    let last = 0;\n    let t = 0;\n    const minFrame = fpsCap > 0 ? 1000 / fpsCap : 0;\n\n    const canRun = () => enabled && inView && document.visibilityState === \"visible\";\n    const stop = () => {\n      if (raf) cancelAnimationFrame(raf);\n      raf = 0;\n    };\n\n    const update = () => {\n      if (!enabled) {\n        stop();\n        el.dataset.loop = \"paused\";\n        return;\n      }\n      if (!wants) {\n        stop();\n        el.dataset.loop = \"idle\";\n        return;\n      }\n      if (!canRun()) {\n        stop();\n        el.dataset.loop = \"paused\";\n        return;\n      }\n      el.dataset.loop = \"running\";\n      if (!raf) {\n        last = performance.now();\n        raf = requestAnimationFrame(tick);\n      }\n    };\n\n    const tick = (now: number) => {\n      raf = 0;\n      if (!canRun() || !wants) {\n        update();\n        return;\n      }\n      const elapsed = now - last;\n      if (minFrame && elapsed < minFrame - 0.5) {\n        raf = requestAnimationFrame(tick);\n        return;\n      }\n      last = now;\n      const dt = Math.min(0.05, Math.max(0, elapsed / 1000));\n      t += dt;\n      const keep = frameRef.current(dt, t);\n      if (keep === false) {\n        wants = false;\n        update();\n        return;\n      }\n      raf = requestAnimationFrame(tick);\n    };\n\n    const observer = new IntersectionObserver(\n      ([entry]) => {\n        inView = entry.isIntersecting;\n        update();\n      },\n      { rootMargin },\n    );\n    observer.observe(el);\n\n    const onVisibility = () => update();\n    document.addEventListener(\"visibilitychange\", onVisibility);\n\n    wakeRef.current = () => {\n      wants = true;\n      update();\n    };\n\n    update();\n\n    return () => {\n      stop();\n      observer.disconnect();\n      document.removeEventListener(\"visibilitychange\", onVisibility);\n      wakeRef.current = () => {};\n    };\n  }, [ref, enabled, fpsCap, rootMargin]);\n\n  return useMemo(() => ({ wake }), [wake]);\n}\n\n// matchMedia based check. False on the server.\nexport function isCoarsePointer(): boolean {\n  if (typeof window === \"undefined\" || typeof window.matchMedia !== \"function\") return false;\n  return window.matchMedia(\"(pointer: coarse)\").matches;\n}\n",
      "type": "registry:component",
      "target": "@components/bjork-ui/_core/loop.ts"
    },
    {
      "path": "components/bjork-ui/_core/canvas.ts",
      "content": "\"use client\";\n\nimport { useEffect, useState, type RefObject } from \"react\";\nimport { isCoarsePointer } from \"./loop\";\n\n// Caps DPR at 1.5 on coarse pointers and 2 otherwise.\nexport function defaultMaxDpr(): number {\n  return isCoarsePointer() ? 1.5 : 2;\n}\n\n// Sets the backing size for a CSS box and returns the DPR used.\nexport function sizeCanvas(\n  canvas: HTMLCanvasElement,\n  cssW: number,\n  cssH: number,\n  maxDpr: number = defaultMaxDpr(),\n): number {\n  const dpr = Math.min(typeof window !== \"undefined\" ? window.devicePixelRatio || 1 : 1, maxDpr);\n  canvas.width = Math.max(1, Math.round(cssW * dpr));\n  canvas.height = Math.max(1, Math.round(cssH * dpr));\n  canvas.style.width = `${cssW}px`;\n  canvas.style.height = `${cssH}px`;\n  return dpr;\n}\n\n// Rounded size of an element, kept current with a ResizeObserver.\nexport function useElementSize(ref: RefObject<HTMLElement | null>): { width: number; height: number } {\n  const [size, setSize] = useState({ width: 0, height: 0 });\n\n  useEffect(() => {\n    const el = ref.current;\n    if (!el || typeof ResizeObserver === \"undefined\") return;\n    const observer = new ResizeObserver((entries) => {\n      const box = entries[0]?.contentRect;\n      if (!box) return;\n      const width = Math.round(box.width);\n      const height = Math.round(box.height);\n      setSize((prev) => (prev.width === width && prev.height === height ? prev : { width, height }));\n    });\n    observer.observe(el);\n    return () => observer.disconnect();\n  }, [ref]);\n\n  return size;\n}\n",
      "type": "registry:component",
      "target": "@components/bjork-ui/_core/canvas.ts"
    },
    {
      "path": "components/bjork-ui/_core/motion.ts",
      "content": "// Shared springs, easings and durations. Components import these instead of inventing values.\n\nexport const springs = {\n  press: { type: \"spring\", stiffness: 500, damping: 30, mass: 0.6 },\n  snappy: { type: \"spring\", stiffness: 400, damping: 25, mass: 1 },\n  standard: { type: \"spring\", stiffness: 300, damping: 30, mass: 0.8 },\n  soft: { type: \"spring\", stiffness: 200, damping: 25, mass: 1.2 },\n  settle: { type: \"spring\", stiffness: 380, damping: 30, mass: 0.8 },\n  blurIn: { type: \"spring\", stiffness: 400, damping: 28, mass: 0.6 },\n} as const;\n\nexport const ease = {\n  out: [0.23, 1, 0.32, 1],\n  inOut: [0.77, 0, 0.175, 1],\n  drawer: [0.32, 0.72, 0, 1],\n} as const;\n\nexport const easeCss = {\n  out: \"cubic-bezier(0.23,1,0.32,1)\",\n  inOut: \"cubic-bezier(0.77,0,0.175,1)\",\n  drawer: \"cubic-bezier(0.32,0.72,0,1)\",\n} as const;\n\nexport const durations = { press: 140, tooltip: 160, menu: 200, panel: 280 } as const; // ms\n\n// Cubic bezier easing for canvas and rAF code. Returns progress y for input x in [0, 1].\nexport function cubicBezier(x1: number, y1: number, x2: number, y2: number): (t: number) => number {\n  const cx = 3 * x1;\n  const bx = 3 * (x2 - x1) - cx;\n  const ax = 1 - cx - bx;\n  const cy = 3 * y1;\n  const by = 3 * (y2 - y1) - cy;\n  const ay = 1 - cy - by;\n  const sampleX = (s: number) => ((ax * s + bx) * s + cx) * s;\n  const sampleY = (s: number) => ((ay * s + by) * s + cy) * s;\n  const sampleDX = (s: number) => (3 * ax * s + 2 * bx) * s + cx;\n\n  const solveX = (x: number) => {\n    let s = x;\n    for (let i = 0; i < 8; i++) {\n      const err = sampleX(s) - x;\n      if (Math.abs(err) < 1e-6) return s;\n      const d = sampleDX(s);\n      if (Math.abs(d) < 1e-6) break;\n      s -= err / d;\n    }\n    let lo = 0;\n    let hi = 1;\n    s = x;\n    while (lo < hi) {\n      const v = sampleX(s);\n      if (Math.abs(v - x) < 1e-6) return s;\n      if (x > v) lo = s;\n      else hi = s;\n      s = (lo + hi) / 2;\n      if (hi - lo < 1e-7) break;\n    }\n    return s;\n  };\n\n  return (t: number) => {\n    if (t <= 0) return 0;\n    if (t >= 1) return 1;\n    return sampleY(solveX(t));\n  };\n}\n",
      "type": "registry:component",
      "target": "@components/bjork-ui/_core/motion.ts"
    },
    {
      "path": "components/bjork-ui/charts/_kit/chrome.tsx",
      "content": "\"use client\";\n\n// Shared chart chrome for the Charts collection: theme vars, the hover tooltip, legend keys and the\n// screen-reader table twin every chart ships with.\n\nimport { forwardRef, memo, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState, type CSSProperties, type ReactNode } from \"react\";\nimport { useReducedMotion } from \"framer-motion\";\nimport { cn } from \"@/lib/utils\";\nimport { BJORK_PALETTE, type BjorkTone } from \"@/components/bjork-ui/_core/palette\";\nimport { useBjorkTone } from \"@/components/bjork-ui/_core/tone\";\nimport { LiveRegion } from \"@/components/bjork-ui/_core/a11y\";\nimport { surfaceVars } from \"@/components/bjork-ui/_core/surface\";\n\nexport type ChartPalette = (typeof BJORK_PALETTE)[BjorkTone];\n\n// Tokens a chart root writes so DOM overlays follow `tone` even outside a themed page.\nexport function chartVars(pal: ChartPalette): CSSProperties {\n  return {\n    ...surfaceVars(pal === BJORK_PALETTE.light ? \"light\" : \"dark\"),\n    \"--bjork-accent\": pal.accent,\n    \"--bjork-accent-ink\": pal.accentInk,\n    \"--bjork-accent-fill\": pal.accentFill,\n    \"--bjork-accent-soft\": pal.accentSoft,\n    \"--bjork-accent-foreground\": pal.accentFg,\n    \"--bjork-text\": pal.text,\n    \"--bjork-text-medium\": pal.textMedium,\n    \"--bjork-text-muted\": pal.textMuted,\n    \"--bjork-text-soft\": pal.textSoft,\n    \"--bjork-text-faint\": pal.textFaint,\n    \"--bjork-hair\": pal.hair,\n    \"--bjork-border\": pal.border,\n    \"--bjork-border-strong\": pal.borderStrong,\n    \"--bjork-surface\": pal.surface,\n    \"--bjork-surface-hover\": pal.raised,\n    \"--bjork-ring-offset\": pal.bg,\n    // The surface a chart sits on, for label halos and cut-outs. Override it on the root if needed.\n    \"--bjork-chart-bg\": pal.stage,\n    \"--bjork-success\": pal.success,\n    \"--bjork-warning\": pal.warning,\n    \"--bjork-error\": pal.error,\n  } as CSSProperties;\n}\n\n// Tone, palette, reduced motion and root vars in one call.\nexport function useChartTheme(toneProp?: BjorkTone) {\n  const tone = useBjorkTone(toneProp);\n  const pal = BJORK_PALETTE[tone];\n  const reduce = !!useReducedMotion();\n  return { tone, pal, reduce, vars: chartVars(pal) };\n}\n\n// Focus ring shared by every focusable plot surface.\nexport const chartFocusRing =\n  \"outline-none focus-visible:ring-2 focus-visible:ring-[color:var(--bjork-accent)] focus-visible:ring-offset-2 focus-visible:ring-offset-[color:var(--bjork-ring-offset)]\";\n\n// Mono label style: 10px Geist Mono, tabular, cap-trimmed.\nexport const chartMono = \"font-mono text-[10px] leading-none tabular-nums [text-box:trim-both_cap_alphabetic]\";\n\n// Floating chart surfaces follow the library canon (_core/surface.ts): a 1px border plus the inset light\n// shadow. Hover cards take the full surface shadow; small readout tags take the soft one. Colours come\n// from chartVars, so light and dark both follow the tone.\nexport const chartCardEdge = \"border border-[color:var(--bjork-border)] shadow-[var(--bjork-shadow-surface)]\";\nexport const chartTagEdge = \"border border-[color:var(--bjork-border)] shadow-[var(--bjork-shadow-soft)]\";\n\nexport interface TooltipRow {\n  key?: string;\n  label: ReactNode;\n  value: ReactNode;\n  color?: string;\n  dashed?: boolean;\n  strong?: boolean;\n}\n\n// The hover card. Values lead, labels follow, series keyed with a short line in the series colour.\n// Position it with `style.transform` from the caller; it never takes pointer events.\nexport const ChartTooltip = forwardRef<\n  HTMLDivElement,\n  { title?: ReactNode; rows: TooltipRow[]; visible: boolean; className?: string; style?: CSSProperties; tipKey?: string }\n>(function ChartTooltip({ title, rows, visible, className, style, tipKey }, ref) {\n  return (\n    <div\n      ref={ref}\n      data-key={tipKey}\n      role=\"presentation\"\n      aria-hidden=\"true\"\n      className={cn(\n        `pointer-events-none absolute left-0 top-0 z-10 min-w-[120px] rounded-[10px] ${chartCardEdge} bg-[color:var(--bjork-surface)] px-2.5 py-2 transition-opacity duration-150 ease-out`,\n        visible ? \"opacity-100\" : \"opacity-0\",\n        className,\n      )}\n      style={style}\n    >\n      {title !== undefined && (\n        <div className=\"mb-1.5 whitespace-nowrap font-mono text-[10px] uppercase leading-none tracking-[0.08em] text-[color:var(--bjork-text-soft)] [text-box:trim-both_cap_alphabetic]\">\n          {title}\n        </div>\n      )}\n      <div className=\"flex flex-col gap-[7px]\">\n        {rows.map((r, i) => (\n          <div key={r.key ?? i} className=\"flex items-center gap-2 whitespace-nowrap leading-none\">\n            {r.color && (\n              <span\n                aria-hidden=\"true\"\n                className=\"inline-block w-2.5 shrink-0\"\n                style={\n                  r.dashed\n                    ? { borderTop: `1.5px dashed ${r.color}`, height: 0 }\n                    : { background: r.color, height: 2, borderRadius: 1 }\n                }\n              />\n            )}\n            <span\n              className={cn(\n                \"font-mono text-[12px] tabular-nums [text-box:trim-both_cap_alphabetic]\",\n                r.strong === false ? \"text-[color:var(--bjork-text-medium)]\" : \"text-[color:var(--bjork-text)]\",\n              )}\n            >\n              {r.value}\n            </span>\n            <span className=\"ml-auto pl-3 font-bjork-alpha text-[11px] text-[color:var(--bjork-text-muted)] [text-box:trim-both_cap_alphabetic]\">\n              {r.label}\n            </span>\n          </div>\n        ))}\n      </div>\n    </div>\n  );\n});\n\n// Places a tooltip of size (tw, th) next to (x, y) inside a (w, h) box, flipping away from edges.\nexport function placeTooltip(\n  x: number,\n  y: number,\n  tw: number,\n  th: number,\n  w: number,\n  h: number,\n  gap = 12,\n): { x: number; y: number } {\n  let tx = x + gap;\n  if (tx + tw > w) tx = x - gap - tw;\n  if (tx < 0) tx = Math.max(0, Math.min(w - tw, x - tw / 2));\n  let ty = y - th - gap;\n  if (ty < 0) ty = Math.min(h - th, y + gap);\n  return { x: Math.round(tx), y: Math.round(Math.max(0, ty)) };\n}\n\nexport interface LegendItem {\n  id: string;\n  label: string;\n  color: string;\n  shape?: \"line\" | \"dash\" | \"rect\" | \"dot\";\n  muted?: boolean;\n}\n\n// A legend row. Keys mirror the mark: line for lines, rect for areas and bars.\nexport function ChartLegend({\n  items,\n  className,\n  onHover,\n  activeId,\n}: {\n  items: LegendItem[];\n  className?: string;\n  onHover?: (id: string | null) => void;\n  activeId?: string | null;\n}) {\n  return (\n    <div className={cn(\"flex flex-wrap items-center gap-x-4 gap-y-2\", className)}>\n      {items.map((it) => {\n        const dim = (activeId && activeId !== it.id) || it.muted;\n        return (\n          <span\n            key={it.id}\n            onPointerEnter={onHover ? () => onHover(it.id) : undefined}\n            onPointerLeave={onHover ? () => onHover(null) : undefined}\n            className={cn(\n              \"inline-flex items-center gap-1.5 font-bjork-alpha text-[11px] font-medium leading-3 transition-opacity duration-150 ease-out\",\n              dim ? \"opacity-45\" : \"opacity-100\",\n              \"text-[color:var(--bjork-text-medium)]\",\n            )}\n          >\n            <LegendKey color={it.color} shape={it.shape} />\n            {it.label}\n          </span>\n        );\n      })}\n    </div>\n  );\n}\n\nexport function LegendKey({ color, shape = \"rect\" }: { color: string; shape?: LegendItem[\"shape\"] }) {\n  if (shape === \"line\") return <span aria-hidden=\"true\" className=\"inline-block h-[2px] w-2.5 rounded-[1px]\" style={{ background: color }} />;\n  if (shape === \"dash\") return <span aria-hidden=\"true\" className=\"inline-block h-0 w-2.5\" style={{ borderTop: `1.5px dashed ${color}` }} />;\n  if (shape === \"dot\") return <span aria-hidden=\"true\" className=\"inline-block size-2 rounded-full\" style={{ background: color }} />;\n  return <span aria-hidden=\"true\" className=\"inline-block size-2 rounded-[2px]\" style={{ background: color }} />;\n}\n\n// The table twin. Every value the chart shows is reachable here without hovering.\n// Memoised: hover state re-renders the chart, never the table. Pass memoised rows.\nexport const ChartTable = memo(function ChartTable({\n  caption,\n  columns,\n  rows,\n}: {\n  caption: string;\n  columns: string[];\n  rows: (string | number)[][];\n}) {\n  return (\n    <table className=\"sr-only\">\n      <caption>{caption}</caption>\n      <thead>\n        <tr>\n          {columns.map((c) => (\n            <th key={c} scope=\"col\">\n              {c}\n            </th>\n          ))}\n        </tr>\n      </thead>\n      <tbody>\n        {rows.map((r, i) => (\n          <tr key={i}>\n            {r.map((cell, j) =>\n              j === 0 ? (\n                <th key={j} scope=\"row\">\n                  {cell}\n                </th>\n              ) : (\n                <td key={j}>{cell}</td>\n              ),\n            )}\n          </tr>\n        ))}\n      </tbody>\n    </table>\n  );\n});\n\n// A pool of absolutely positioned spans the draw loop fills through `writeLabels`.\nexport function LabelPool({\n  count,\n  pool,\n  className,\n}: {\n  count: number;\n  pool: { current: (HTMLSpanElement | null)[] };\n  className?: string;\n}) {\n  return (\n    <>\n      {Array.from({ length: count }).map((_, i) => (\n        <span\n          key={i}\n          ref={(el) => {\n            pool.current[i] = el;\n          }}\n          aria-hidden=\"true\"\n          className={cn(\n            \"pointer-events-none absolute left-0 top-0 whitespace-nowrap opacity-0\",\n            className ?? \"font-mono text-[10px] leading-none tabular-nums text-[color:var(--bjork-text-faint)] [text-box:trim-both_cap_alphabetic]\",\n          )}\n        />\n      ))}\n    </>\n  );\n}\n\nexport interface TooltipContent {\n  key: string;\n  title?: ReactNode;\n  rows: TooltipRow[];\n}\n\nexport interface TooltipHandle {\n  /** Shows `content`, or hides with `null`. Same key is a no-op. */\n  set: (content: TooltipContent | null) => void;\n  readonly el: HTMLDivElement | null;\n  /** Measured size of the current content. */\n  readonly size: { w: number; h: number };\n}\n\n// A tooltip that owns its state, so hovering re-renders only the tooltip, never the chart.\n// The chart positions it from its draw loop through `handle.el.style.transform`.\nexport const HoverTooltip = forwardRef<TooltipHandle, { onMeasure?: () => void; className?: string }>(function HoverTooltip(\n  { onMeasure, className },\n  ref,\n) {\n  const [state, setState] = useState<{ content: TooltipContent | null; last: TooltipContent | null }>({ content: null, last: null });\n  const elRef = useRef<HTMLDivElement>(null);\n  const size = useRef({ w: 0, h: 0 });\n  const onMeasureRef = useRef(onMeasure);\n  useEffect(() => {\n    onMeasureRef.current = onMeasure;\n  });\n  useImperativeHandle(\n    ref,\n    () => ({\n      set: (content) =>\n        setState((prev) => {\n          if ((prev.content?.key ?? null) === (content?.key ?? null)) return prev;\n          return { content, last: content ?? prev.last };\n        }),\n      get el() {\n        return elRef.current;\n      },\n      get size() {\n        return size.current;\n      },\n    }),\n    [],\n  );\n  useLayoutEffect(() => {\n    const el = elRef.current;\n    if (!el) return;\n    size.current = { w: el.offsetWidth, h: el.offsetHeight };\n    onMeasureRef.current?.();\n  }, [state.last]);\n  const shown = state.content ?? state.last;\n  return <ChartTooltip ref={elRef} title={shown?.title} rows={shown?.rows ?? []} visible={!!state.content} className={className} />;\n});\n\nexport interface AnnouncerHandle {\n  say: (message: string) => void;\n}\n\n// Polite live region with a 250ms trailing throttle, isolated from the chart's renders.\nexport const ChartAnnouncer = forwardRef<AnnouncerHandle, { ms?: number }>(function ChartAnnouncer({ ms = 250 }, ref) {\n  const [message, setMessage] = useState(\"\");\n  const at = useRef(0);\n  const timer = useRef<ReturnType<typeof setTimeout> | null>(null);\n  useEffect(\n    () => () => {\n      if (timer.current) clearTimeout(timer.current);\n    },\n    [],\n  );\n  useImperativeHandle(\n    ref,\n    () => ({\n      say: (text: string) => {\n        const now = performance.now();\n        if (timer.current) clearTimeout(timer.current);\n        if (now - at.current >= ms) {\n          at.current = now;\n          setMessage(text);\n        } else {\n          timer.current = setTimeout(() => {\n            at.current = performance.now();\n            setMessage(text);\n          }, ms);\n        }\n      },\n    }),\n    [ms],\n  );\n  return <LiveRegion message={message} />;\n});\n",
      "type": "registry:component",
      "target": "@components/bjork-ui/charts/_kit/chrome.tsx"
    },
    {
      "path": "components/bjork-ui/_core/tone.ts",
      "content": "\"use client\";\n\nimport { useSyncExternalStore } from \"react\";\nimport { useTheme } from \"next-themes\";\nimport type { BjorkTone } from \"./palette\";\n\nconst subscribeNoop = () => () => {};\nconst getMounted = () => true;\nconst getServerMounted = () => false;\n\n/**\n * Resolves the tone for a component. An explicit `tone` always wins.\n * Otherwise it follows next-themes' resolved theme, but only after mount,\n * so the server render and first client render agree on dark.\n */\nexport function useBjorkTone(tone?: BjorkTone): BjorkTone {\n  const { resolvedTheme } = useTheme();\n  const mounted = useSyncExternalStore(subscribeNoop, getMounted, getServerMounted);\n  if (tone) return tone;\n  if (!mounted) return \"dark\";\n  return resolvedTheme === \"light\" ? \"light\" : \"dark\";\n}\n",
      "type": "registry:component",
      "target": "@components/bjork-ui/_core/tone.ts"
    },
    {
      "path": "components/bjork-ui/_core/a11y.tsx",
      "content": "import type { ReactNode } from \"react\";\n\n// Text for assistive tech only.\nexport function VisuallyHidden({ children }: { children: ReactNode }) {\n  return <span className=\"sr-only\">{children}</span>;\n}\n\n// Announces `message` when it changes. Same text re-rendered does not re-announce.\nexport function LiveRegion({\n  message,\n  politeness = \"polite\",\n}: {\n  message: string;\n  politeness?: \"polite\" | \"assertive\";\n}) {\n  return (\n    <span role=\"status\" aria-live={politeness} aria-atomic=\"true\" className=\"sr-only\">\n      {message}\n    </span>\n  );\n}\n",
      "type": "registry:component",
      "target": "@components/bjork-ui/_core/a11y.tsx"
    },
    {
      "path": "components/bjork-ui/_core/surface.ts",
      "content": "import type { CSSProperties } from \"react\";\nimport type { BjorkTone } from \"./palette\";\n\n// The library surface (CANON.md §1). Values mirror app/globals.css :root and .dark. Change both together.\nexport const BJORK_SURFACE = {\n  light: {\n    surface: \"#fffcf6\", surfaceMuted: \"rgba(250, 246, 237, 0.94)\", surfaceHover: \"#f5efe3\", surfaceActive: \"#efe7d8\",\n    panel: \"#f8f2e7\", menu: \"rgba(255, 252, 246, 0.98)\", field: \"rgba(255, 252, 246, 0.96)\",\n    fieldMuted: \"rgba(248, 242, 231, 0.82)\", fieldInset: \"rgba(239, 231, 216, 0.72)\",\n    border: \"#eee6db\", borderMuted: \"#f5ede2\", borderStrong: \"#e1d7c8\",\n    shadowSurface: \"inset 0 7px 14px rgba(88, 72, 49, 0.045), inset 0 0.5px 0.5px rgba(255, 255, 255, 0.92), inset 1px 0 0 rgba(88, 72, 49, 0.026), inset -1px 0 0 rgba(255, 255, 255, 0.68), 0 14px 22px -9px rgba(66, 52, 33, 0.11)\",\n    shadowSoft: \"inset 0 1px 0 rgba(88, 72, 49, 0.045), inset 0 0.5px 0.5px rgba(255, 255, 255, 0.86)\",\n    shadowPanel: \"inset 0 1px 0 rgba(88, 72, 49, 0.04), inset 1px 0 0 rgba(88, 72, 49, 0.024), inset -1px 0 0 rgba(255, 255, 255, 0.64), 0 18px 38px -30px rgba(66, 52, 33, 0.2)\",\n    shadowMenu: \"inset 0 1px 0 rgba(88, 72, 49, 0.04), inset 0 12px 24px rgba(88, 72, 49, 0.022), inset 1px 0 0 rgba(88, 72, 49, 0.024), inset -1px 0 0 rgba(255, 255, 255, 0.62), 0 22px 44px -26px rgba(66, 52, 33, 0.22)\",\n    shadowInset: \"inset 0 1px 10px rgba(88, 72, 49, 0.12), inset 0 0.5px 0.5px rgba(255, 255, 255, 0.72)\",\n  },\n  dark: {\n    surface: \"#121212\", surfaceMuted: \"rgba(22, 22, 22, 0.92)\", surfaceHover: \"#161616\", surfaceActive: \"#202020\",\n    panel: \"#0d0d0d\", menu: \"rgba(18, 18, 18, 0.98)\", field: \"rgba(18, 18, 18, 0.95)\",\n    fieldMuted: \"rgba(18, 18, 18, 0.55)\", fieldInset: \"rgba(9, 9, 9, 0.75)\",\n    border: \"#232323\", borderMuted: \"#1c1c1c\", borderStrong: \"#343434\",\n    shadowSurface: \"inset 0 7px 14px rgba(255, 255, 255, 0.03), inset 0 0.5px 0.5px rgba(255, 255, 255, 0.06), 0 14px 20px -6px rgba(0, 0, 0, 0.45)\",\n    shadowSoft: \"inset 0 1px 0 rgba(255, 255, 255, 0.045)\",\n    shadowPanel: \"inset 0 1px 0 rgba(255, 255, 255, 0.035), 0 18px 36px -28px rgba(0, 0, 0, 0.9)\",\n    shadowMenu: \"inset 0 1px 0 rgba(255, 255, 255, 0.055), inset 0 12px 24px rgba(255, 255, 255, 0.018), inset 0 -18px 26px rgba(0, 0, 0, 0.24), 0 22px 42px -22px rgba(0, 0, 0, 0.9)\",\n    shadowInset: \"inset 0 1px 10px rgba(0, 0, 0, 0.45)\",\n  },\n} as const;\n\n/** Writes the surface tokens for a pinned tone as --bjork-* custom properties. Spread first; kit-specific keys may override. */\nexport function surfaceVars(tone: BjorkTone): CSSProperties {\n  const s = BJORK_SURFACE[tone];\n  return {\n    \"--bjork-surface\": s.surface, \"--bjork-surface-muted\": s.surfaceMuted, \"--bjork-surface-hover\": s.surfaceHover,\n    \"--bjork-surface-active\": s.surfaceActive, \"--bjork-panel\": s.panel, \"--bjork-menu\": s.menu, \"--bjork-field\": s.field,\n    \"--bjork-field-muted\": s.fieldMuted, \"--bjork-field-inset\": s.fieldInset, \"--bjork-border\": s.border,\n    \"--bjork-border-muted\": s.borderMuted, \"--bjork-border-strong\": s.borderStrong,\n    \"--bjork-shadow-surface\": s.shadowSurface, \"--bjork-shadow-soft\": s.shadowSoft, \"--bjork-shadow-panel\": s.shadowPanel,\n    \"--bjork-shadow-menu\": s.shadowMenu, \"--bjork-shadow-inset\": s.shadowInset,\n  } as CSSProperties;\n}\n",
      "type": "registry:component",
      "target": "@components/bjork-ui/_core/surface.ts"
    },
    {
      "path": "components/bjork-ui/charts/_kit/scale.ts",
      "content": "// Shared chart math for the Charts collection: nice ticks, scales, damping, colour and number formatting.\n// Pure functions only. Every chart imports what it needs by path.\n\nexport function clamp(v: number, lo: number, hi: number): number {\n  return v < lo ? lo : v > hi ? hi : v;\n}\n\nexport function lerp(a: number, b: number, t: number): number {\n  return a + (b - a) * t;\n}\n\n// Maps v from [d0, d1] to [r0, r1]. Degenerate domains map to the range midpoint.\nexport function scaleLinear(d0: number, d1: number, r0: number, r1: number): (v: number) => number {\n  const span = d1 - d0;\n  if (!(Math.abs(span) > 1e-12)) return () => (r0 + r1) / 2;\n  const k = (r1 - r0) / span;\n  return (v: number) => r0 + (v - d0) * k;\n}\n\n// Frame-rate independent approach: moves `cur` toward `target` with time constant `tau` seconds.\nexport function damp(cur: number, target: number, tau: number, dt: number): number {\n  if (tau <= 0) return target;\n  return target + (cur - target) * Math.exp(-dt / tau);\n}\n\n// A \"nice\" step (1, 2, 2.5 or 5 x 10^k) that splits `span` into roughly `count` intervals.\nexport function niceStep(span: number, count = 5): number {\n  if (!(span > 0) || !Number.isFinite(span)) return 1;\n  const raw = span / Math.max(1, count);\n  const mag = 10 ** Math.floor(Math.log10(raw));\n  const r = raw / mag;\n  const m = r <= 1 ? 1 : r <= 2 ? 2 : r <= 2.5 ? 2.5 : r <= 5 ? 5 : 10;\n  return m * mag;\n}\n\n// Tick values at a nice step, inclusive of the domain ends when they land on the step.\nexport function niceTicks(lo: number, hi: number, count = 5): number[] {\n  if (!(hi > lo)) return [lo];\n  const step = niceStep(hi - lo, count);\n  const first = Math.ceil(lo / step - 1e-9);\n  const last = Math.floor(hi / step + 1e-9);\n  const out: number[] = [];\n  for (let n = first; n <= last; n++) out.push(Number((n * step).toFixed(12)));\n  return out;\n}\n\n// Expands [lo, hi] outward to the nearest nice step, so the outer gridlines sit on round values.\nexport function niceDomain(lo: number, hi: number, count = 5): [number, number] {\n  if (!(hi > lo)) {\n    const pad = Math.max(Math.abs(hi) * 0.1, 1);\n    return [lo - pad, hi + pad];\n  }\n  const step = niceStep(hi - lo, count);\n  return [Math.floor(lo / step + 1e-9) * step, Math.ceil(hi / step - 1e-9) * step];\n}\n\n// Half-pixel snap for crisp 1px hairlines.\nexport function crisp(v: number): number {\n  return Math.round(v) + 0.5;\n}\n\n// --- Colour -------------------------------------------------------------------------------------\n\nconst rgbCache = new Map<string, [number, number, number, number]>();\n\n// Parses #rgb, #rrggbb and rgba()/rgb() strings. Returns [r, g, b, a].\nexport function parseColor(c: string): [number, number, number, number] {\n  const hit = rgbCache.get(c);\n  if (hit) return hit;\n  let out: [number, number, number, number] = [0, 0, 0, 1];\n  const s = c.trim();\n  if (s.startsWith(\"#\")) {\n    let h = s.slice(1);\n    if (h.length === 3) h = h.split(\"\").map((ch) => ch + ch).join(\"\");\n    const n = parseInt(h.slice(0, 6), 16);\n    out = [(n >> 16) & 255, (n >> 8) & 255, n & 255, 1];\n  } else {\n    const m = s.match(/rgba?\\(([^)]+)\\)/);\n    if (m) {\n      const p = m[1].split(\",\").map((x) => parseFloat(x));\n      out = [p[0] ?? 0, p[1] ?? 0, p[2] ?? 0, p[3] ?? 1];\n    }\n  }\n  rgbCache.set(c, out);\n  return out;\n}\n\n// The colour at alpha `a`, multiplied with any alpha the colour already has.\nexport function withAlpha(c: string, a: number): string {\n  const [r, g, b, a0] = parseColor(c);\n  return `rgba(${r},${g},${b},${+(a0 * a).toFixed(4)})`;\n}\n\n// Mixes two opaque colours in sRGB. t = 0 gives `a`.\nexport function mixColor(a: string, b: string, t: number): string {\n  const ca = parseColor(a);\n  const cb = parseColor(b);\n  const r = Math.round(lerp(ca[0], cb[0], t));\n  const g = Math.round(lerp(ca[1], cb[1], t));\n  const bl = Math.round(lerp(ca[2], cb[2], t));\n  return `rgb(${r},${g},${bl})`;\n}\n\n// --- Numbers ------------------------------------------------------------------------------------\n\nconst fmtCache = new Map<string, Intl.NumberFormat>();\nfunction nf(opts: Intl.NumberFormatOptions): Intl.NumberFormat {\n  const key = JSON.stringify(opts);\n  let f = fmtCache.get(key);\n  if (!f) {\n    f = new Intl.NumberFormat(\"en-US\", opts);\n    fmtCache.set(key, f);\n  }\n  return f;\n}\n\nexport function formatNumber(v: number, digits = 1): string {\n  if (!Number.isFinite(v)) return \"–\";\n  return nf({ maximumFractionDigits: digits, minimumFractionDigits: 0 }).format(v);\n}\n\nexport function formatFixed(v: number, digits = 2): string {\n  if (!Number.isFinite(v)) return \"–\";\n  return nf({ maximumFractionDigits: digits, minimumFractionDigits: digits }).format(v);\n}\n\n// 1,284 / 12.9K / 4.2M. Uses a true minus sign.\nexport function formatCompact(v: number, digits = 1): string {\n  if (!Number.isFinite(v)) return \"–\";\n  const s = nf({ notation: \"compact\", maximumFractionDigits: digits }).format(Math.abs(v));\n  return v < 0 ? `−${s}` : s;\n}\n\nexport function formatPercent(v: number, digits = 0): string {\n  if (!Number.isFinite(v)) return \"–\";\n  const s = nf({ maximumFractionDigits: digits, minimumFractionDigits: digits }).format(Math.abs(v * 100));\n  return `${v < 0 ? \"−\" : \"\"}${s}%`;\n}\n\n// +1.2 / −0.8 / 0. Signed numbers use a true minus and an explicit plus.\nexport function formatSigned(v: number, format: (n: number) => string = (n) => formatNumber(n)): string {\n  if (!Number.isFinite(v)) return \"–\";\n  const body = format(Math.abs(v));\n  // A value that rounds to zero carries no sign.\n  if (Math.abs(v) < 1e-12 || !/[1-9]/.test(body)) return body;\n  return `${v > 0 ? \"+\" : \"−\"}${body}`;\n}\n\n// Gaussian kernel density at x for a sorted sample, bandwidth h.\nexport function kde(sample: number[], x: number, h: number): number {\n  const n = sample.length;\n  if (!n || !(h > 0)) return 0;\n  let s = 0;\n  const inv = 1 / h;\n  for (let i = 0; i < n; i++) {\n    const u = (x - sample[i]) * inv;\n    if (u > 4 || u < -4) continue;\n    s += Math.exp(-0.5 * u * u);\n  }\n  return s / (n * h * Math.sqrt(2 * Math.PI));\n}\n\n// Silverman's rule of thumb bandwidth.\nexport function silverman(sample: number[]): number {\n  const n = sample.length;\n  if (n < 2) return 1;\n  const mean = sample.reduce((a, b) => a + b, 0) / n;\n  const sd = Math.sqrt(sample.reduce((a, b) => a + (b - mean) ** 2, 0) / (n - 1));\n  const sorted = [...sample].sort((a, b) => a - b);\n  const iqr = quantile(sorted, 0.75) - quantile(sorted, 0.25);\n  const spread = Math.min(sd, iqr / 1.34) || sd || 1;\n  return 0.9 * spread * n ** -0.2;\n}\n\n// Linear-interpolated quantile of a sorted array.\nexport function quantile(sorted: number[], q: number): number {\n  const n = sorted.length;\n  if (!n) return NaN;\n  if (n === 1) return sorted[0];\n  const pos = clamp(q, 0, 1) * (n - 1);\n  const lo = Math.floor(pos);\n  const hi = Math.min(n - 1, lo + 1);\n  return sorted[lo] + (sorted[hi] - sorted[lo]) * (pos - lo);\n}\n\n// Standard normal sample from a uniform source (Box-Muller).\nexport function gaussian(rnd: () => number): number {\n  const u = Math.max(rnd(), 1e-9);\n  const v = rnd();\n  return Math.sqrt(-2 * Math.log(u)) * Math.cos(2 * Math.PI * v);\n}\n\n// --- Time ---------------------------------------------------------------------------------------\n\nconst HOUR = 3600000;\nconst DAY = 86400000;\nconst timeFmt = {\n  hour: new Intl.DateTimeFormat(\"en-US\", { hour: \"numeric\", timeZone: \"UTC\" }),\n  day: new Intl.DateTimeFormat(\"en-US\", { month: \"short\", day: \"numeric\", timeZone: \"UTC\" }),\n  month: new Intl.DateTimeFormat(\"en-US\", { month: \"short\", timeZone: \"UTC\" }),\n  monthYear: new Intl.DateTimeFormat(\"en-US\", { month: \"short\", year: \"2-digit\", timeZone: \"UTC\" }),\n  year: new Intl.DateTimeFormat(\"en-US\", { year: \"numeric\", timeZone: \"UTC\" }),\n};\n\nexport interface TimeTick {\n  t: number;\n  label: string;\n}\n\n// Calendar-aligned ticks (UTC) for [t0, t1] drawn across `px` pixels, at least `minPx` apart.\nexport function timeTicks(t0: number, t1: number, px: number, minPx = 64): TimeTick[] {\n  const span = t1 - t0;\n  if (!(span > 0) || !(px > 0)) return [];\n  const maxTicks = Math.max(1, Math.floor(px / minPx));\n  const perTick = span / maxTicks;\n  const out: TimeTick[] = [];\n  const hourSteps = [1, 2, 3, 6, 12];\n  for (const k of hourSteps) {\n    if (k * HOUR >= perTick) {\n      const step = k * HOUR;\n      for (let t = Math.ceil(t0 / step) * step; t <= t1; t += step) {\n        const d = new Date(t);\n        out.push({ t, label: d.getUTCHours() === 0 ? timeFmt.day.format(t) : timeFmt.hour.format(t) });\n      }\n      return out;\n    }\n  }\n  const daySteps = [1, 2, 3, 7, 14];\n  for (const k of daySteps) {\n    if (k * DAY >= perTick) {\n      const step = k * DAY;\n      // Weekly steps land on Mondays.\n      const offset = k === 7 || k === 14 ? 4 * DAY : 0;\n      for (let t = Math.ceil((t0 - offset) / step) * step + offset; t <= t1; t += step) out.push({ t, label: timeFmt.day.format(t) });\n      return out;\n    }\n  }\n  const monthSteps = [1, 2, 3, 6, 12, 24, 60];\n  for (const k of monthSteps) {\n    if (k * 30.44 * DAY >= perTick) {\n      const d0 = new Date(t0);\n      let y = d0.getUTCFullYear();\n      let m = d0.getUTCMonth();\n      // First boundary at or after t0 that is a multiple of k months.\n      m = Math.ceil(m / k) * k;\n      for (;;) {\n        y += Math.floor(m / 12);\n        m %= 12;\n        const t = Date.UTC(y, m, 1);\n        if (t > t1) break;\n        if (t >= t0) {\n          const label = k >= 12 ? timeFmt.year.format(t) : m === 0 ? timeFmt.monthYear.format(t) : timeFmt.month.format(t);\n          out.push({ t, label });\n        }\n        m += k;\n      }\n      return out;\n    }\n  }\n  return out;\n}\n\nexport function formatDateUTC(t: number, style: \"day\" | \"full\" = \"day\"): string {\n  if (style === \"full\") return new Date(t).toLocaleDateString(\"en-US\", { weekday: \"short\", month: \"short\", day: \"numeric\", year: \"numeric\", timeZone: \"UTC\" });\n  return timeFmt.day.format(t);\n}\n",
      "type": "registry:component",
      "target": "@components/bjork-ui/charts/_kit/scale.ts"
    },
    {
      "path": "components/bjork-ui/charts/_kit/series.ts",
      "content": "// Series colour for the Charts collection: a fixed categorical order for identity and a one-hue\n// ramp for magnitude. Pure data and functions; every chart imports what it needs by path.\n//\n// The categorical order is warm-anchored: the ember accent first, then warm ink-neutral steps,\n// then one cool counterpoint (steel), then deeper or lighter steps of the accent family. Every\n// light slot clears 3:1 on the paper stage. Hues are assigned in this order and never cycled:\n// past six series, fold the rest into \"Other\" (see `foldSeries`).\n\nimport type { BjorkTone } from \"@/components/bjork-ui/_core/palette\";\nimport { clamp, lerp, parseColor } from \"@/components/bjork-ui/charts/_kit/scale\";\n\nexport const CHART_SERIES: Record<BjorkTone, readonly string[]> = {\n  //       ember      warm ink   warm grey  steel      deep rust  light ember\n  dark: [\"#ec5c13\", \"#d9d3c7\", \"#8f877a\", \"#5b8fb9\", \"#b84a12\", \"#f0a272\"],\n  light: [\"#c94f10\", \"#3a352d\", \"#8a8174\", \"#3f6f96\", \"#8f3a0e\", \"#d67a45\"],\n};\n\n// The neutral an \"Other\" bucket takes, so it never impersonates a series.\nexport const CHART_OTHER: Record<BjorkTone, string> = { dark: \"#5c5c5c\", light: \"#a8a39a\" };\n\nexport const MAX_SERIES = 6;\n\n// Slot colour by the series' stable index (its position in the caller's data, never its rank).\nexport function seriesColor(tone: BjorkTone, index: number): string {\n  const set = CHART_SERIES[tone];\n  return index >= 0 && index < set.length ? set[index] : CHART_OTHER[tone];\n}\n\n// Keeps the first `max - 1` items and sums the rest into one \"Other\" item when there are more\n// than `max`. `merge` builds the Other item from the folded ones.\nexport function foldSeries<T>(items: T[], max: number, merge: (rest: T[]) => T): T[] {\n  if (items.length <= max) return items;\n  return [...items.slice(0, max - 1), merge(items.slice(max - 1))];\n}\n\n// One-hue magnitude ramp in the accent family. t = 0 recedes toward the stage, t = 1 is the\n// strongest step. Dark mode brightens with magnitude, light mode darkens, so \"more\" always reads\n// as more contrast against the surface.\nconst RAMP: Record<BjorkTone, readonly string[]> = {\n  dark: [\"#1d1611\", \"#3a2112\", \"#6a3013\", \"#a84514\", \"#ec5c13\", \"#ff9a5c\"],\n  light: [\"#f1e8dc\", \"#f3cfb2\", \"#eda57a\", \"#e07a43\", \"#b4531f\", \"#7a3412\"],\n};\n\nexport function rampColor(tone: BjorkTone, t: number): string {\n  const stops = RAMP[tone];\n  const x = clamp(Number.isFinite(t) ? t : 0, 0, 1) * (stops.length - 1);\n  const i = Math.min(stops.length - 2, Math.floor(x));\n  const a = parseColor(stops[i]);\n  const b = parseColor(stops[i + 1]);\n  const f = x - i;\n  return `rgb(${Math.round(lerp(a[0], b[0], f))},${Math.round(lerp(a[1], b[1], f))},${Math.round(lerp(a[2], b[2], f))})`;\n}\n\n// WCAG relative luminance of an sRGB colour.\nfunction relLum(color: string): number {\n  const [r, g, b] = parseColor(color).map((c) => {\n    const v = c / 255;\n    return v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;\n  });\n  return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n}\n\n// Light or dark ink for text on a filled mark, whichever has more WCAG contrast. The inks are\n// near-white (L ≈ 0.94) and near-black (L ≈ 0.009). Saturated orange gets dark ink; white text\n// only lands on the deeper rust steps, the same rule as --bjork-accent-fill.\nexport function inkOn(color: string): \"light\" | \"dark\" {\n  const L = relLum(color);\n  return (0.94 + 0.05) / (L + 0.05) >= (L + 0.05) / (0.009 + 0.05) ? \"light\" : \"dark\";\n}\n\n// Whether text on a ramp cell at `t` should use the light or dark ink.\nexport function rampInk(tone: BjorkTone, t: number): \"light\" | \"dark\" {\n  return inkOn(rampColor(tone, t));\n}\n",
      "type": "registry:component",
      "target": "@components/bjork-ui/charts/_kit/series.ts"
    }
  ],
  "cssVars": {
    "light": {
      "bjork-bg": "#f7f3ea",
      "bjork-surface": "#fffcf6",
      "bjork-surface-muted": "rgba(250, 246, 237, 0.94)",
      "bjork-surface-hover": "#f5efe3",
      "bjork-surface-active": "#efe7d8",
      "bjork-panel": "#f8f2e7",
      "bjork-menu": "rgba(255, 252, 246, 0.98)",
      "bjork-field": "rgba(255, 252, 246, 0.96)",
      "bjork-field-muted": "rgba(248, 242, 231, 0.82)",
      "bjork-field-inset": "rgba(239, 231, 216, 0.72)",
      "bjork-error-bg": "#fff0e8",
      "bjork-text": "#171717",
      "bjork-text-strong": "rgba(23, 23, 23, 0.9)",
      "bjork-text-medium": "rgba(23, 23, 23, 0.78)",
      "bjork-text-muted": "rgba(23, 23, 23, 0.68)",
      "bjork-text-soft": "rgba(23, 23, 23, 0.62)",
      "bjork-text-faint": "rgba(23, 23, 23, 0.22)",
      "bjork-inverted-text": "#fff8f0",
      "bjork-border": "#eee6db",
      "bjork-border-muted": "#f5ede2",
      "bjork-border-strong": "#e1d7c8",
      "bjork-thumb": "#a49b8e",
      "bjork-track": "#ded6ca",
      "bjork-accent": "#ec7d43",
      "bjork-accent-hover": "#f0935f",
      "bjork-accent-soft": "rgba(236, 125, 67, 0.1)",
      "bjork-accent-muted": "rgba(236, 125, 67, 0.2)",
      "bjork-accent-badge": "rgba(236, 125, 67, 0.16)",
      "bjork-accent-badge-foreground": "#8d421d",
      "bjork-accent-foreground": "#3f2112",
      "bjork-accent-fill": "#ec7d43",
      "bjork-accent-fill-hover": "#f0935f",
      "bjork-shadow-surface": "inset 0 7px 14px rgba(88, 72, 49, 0.045), inset 0 0.5px 0.5px rgba(255, 255, 255, 0.92), inset 1px 0 0 rgba(88, 72, 49, 0.026), inset -1px 0 0 rgba(255, 255, 255, 0.68), 0 14px 22px -9px rgba(66, 52, 33, 0.11)",
      "bjork-shadow-soft": "inset 0 1px 0 rgba(88, 72, 49, 0.045), inset 0 0.5px 0.5px rgba(255, 255, 255, 0.86)",
      "bjork-shadow-panel": "inset 0 1px 0 rgba(88, 72, 49, 0.04), inset 1px 0 0 rgba(88, 72, 49, 0.024), inset -1px 0 0 rgba(255, 255, 255, 0.64), 0 18px 38px -30px rgba(66, 52, 33, 0.2)",
      "bjork-shadow-menu": "inset 0 1px 0 rgba(88, 72, 49, 0.04), inset 0 12px 24px rgba(88, 72, 49, 0.022), inset 1px 0 0 rgba(88, 72, 49, 0.024), inset -1px 0 0 rgba(255, 255, 255, 0.62), 0 22px 44px -26px rgba(66, 52, 33, 0.22)",
      "bjork-shadow-inset": "inset 0 1px 10px rgba(88, 72, 49, 0.12), inset 0 0.5px 0.5px rgba(255, 255, 255, 0.72)",
      "bjork-ring-offset": "#f7f3ea"
    },
    "dark": {
      "bjork-bg": "#111111",
      "bjork-surface": "#121212",
      "bjork-surface-muted": "rgba(22, 22, 22, 0.92)",
      "bjork-surface-hover": "#161616",
      "bjork-surface-active": "#202020",
      "bjork-panel": "#0d0d0d",
      "bjork-menu": "rgba(18, 18, 18, 0.98)",
      "bjork-field": "rgba(18, 18, 18, 0.95)",
      "bjork-field-muted": "rgba(18, 18, 18, 0.55)",
      "bjork-field-inset": "rgba(9, 9, 9, 0.75)",
      "bjork-error-bg": "#130d0a",
      "bjork-text": "#ededed",
      "bjork-text-strong": "rgba(237, 237, 237, 0.9)",
      "bjork-text-medium": "rgba(237, 237, 237, 0.72)",
      "bjork-text-muted": "rgba(237, 237, 237, 0.6)",
      "bjork-text-soft": "rgba(237, 237, 237, 0.5)",
      "bjork-text-faint": "rgba(237, 237, 237, 0.22)",
      "bjork-inverted-text": "#080808",
      "bjork-border": "#232323",
      "bjork-border-muted": "#1c1c1c",
      "bjork-border-strong": "#343434",
      "bjork-thumb": "#626262",
      "bjork-track": "#090909",
      "bjork-accent": "#ec5c13",
      "bjork-accent-hover": "#f07832",
      "bjork-accent-soft": "rgba(236, 92, 19, 0.12)",
      "bjork-accent-muted": "rgba(236, 92, 19, 0.24)",
      "bjork-accent-badge": "#b84a12",
      "bjork-accent-badge-foreground": "#fff2ea",
      "bjork-accent-foreground": "#fff2ea",
      "bjork-accent-fill": "#b84a12",
      "bjork-accent-fill-hover": "#a84a14",
      "bjork-shadow-surface": "inset 0 7px 14px rgba(255, 255, 255, 0.03), inset 0 0.5px 0.5px rgba(255, 255, 255, 0.06), 0 14px 20px -6px rgba(0, 0, 0, 0.45)",
      "bjork-shadow-soft": "inset 0 1px 0 rgba(255, 255, 255, 0.045)",
      "bjork-shadow-panel": "inset 0 1px 0 rgba(255, 255, 255, 0.035), 0 18px 36px -28px rgba(0, 0, 0, 0.9)",
      "bjork-shadow-menu": "inset 0 1px 0 rgba(255, 255, 255, 0.055), inset 0 12px 24px rgba(255, 255, 255, 0.018), inset 0 -18px 26px rgba(0, 0, 0, 0.24), 0 22px 42px -22px rgba(0, 0, 0, 0.9)",
      "bjork-shadow-inset": "inset 0 1px 10px rgba(0, 0, 0, 0.45)",
      "bjork-ring-offset": "#080808"
    }
  },
  "css": {
    ".bjork-range": {
      "box-shadow": "inset 0 1px 1px rgba(255, 255, 255, 0.04), 0 0 14px rgba(189, 69, 20, 0.06)"
    },
    ".bjork-range::-webkit-slider-thumb": {
      "appearance": "none",
      "width": "16px",
      "height": "8px",
      "border": "0",
      "border-radius": "999px",
      "background": "var(--bjork-thumb)",
      "box-shadow": "inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.42)"
    },
    ".bjork-range::-moz-range-thumb": {
      "width": "16px",
      "height": "8px",
      "border": "0",
      "border-radius": "999px",
      "background": "var(--bjork-thumb)",
      "box-shadow": "inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.42)"
    },
    ".bjork-layered-button-accent, .bjork-layered-button-raised": {
      "position": "relative",
      "isolation": "isolate",
      "appearance": "none",
      "overflow": "hidden",
      "border": "0",
      "border-radius": "13px",
      "box-shadow": "inset 0 1px 0 #ffffff38, 0 4px 6px -1px #0000001a, 0 2px 4px -2px #0000001a",
      "transition": "filter 150ms ease-out, box-shadow 150ms ease-out"
    },
    ".bjork-layered-button-accent::after, .bjork-layered-button-raised::after": {
      "position": "absolute",
      "inset": "0",
      "pointer-events": "none",
      "content": "\"\"",
      "border": "1.5px solid transparent",
      "border-radius": "inherit",
      "background": "linear-gradient(#ffffffb8, #0000003d 41% 75%, #ffffff47) border-box",
      "mix-blend-mode": "overlay",
      "-webkit-mask-image": "linear-gradient(#000, #000), linear-gradient(#000, #000)",
      "mask-image": "linear-gradient(#000, #000), linear-gradient(#000, #000)",
      "-webkit-mask-clip": "padding-box, border-box",
      "mask-clip": "padding-box, border-box",
      "-webkit-mask-origin": "padding-box, border-box",
      "mask-origin": "padding-box, border-box",
      "-webkit-mask-composite": "xor",
      "mask-composite": "exclude"
    },
    ".bjork-layered-button-accent": {
      "color": "oklch(100% 0 0)",
      "text-shadow": "0 -1px #00000040",
      "background": "radial-gradient(ellipse at -20px top, rgba(255, 255, 255, 0.14), transparent), linear-gradient(180deg, #ec5c13 0%, #ec5c13 62%, color-mix(in oklab, #ec5c13 84%, black 16%) 100%)"
    },
    ".bjork-layered-button-raised": {
      "color": "oklch(100% 0 0)",
      "text-shadow": "0 -1px #00000026",
      "background": "radial-gradient(ellipse at -20px top, #ffffff38, #fff0), linear-gradient(180deg, oklch(0.1881 0.006 265), oklch(0.5493 0.0081 265))"
    },
    ".dark .bjork-layered-button-raised": {
      "color": "oklch(0.2574 0.0056 265)",
      "text-shadow": "0 -1px #00000026",
      "background": "radial-gradient(ellipse at -20px top, #ffffff38, #fff0), linear-gradient(180deg, color-mix(in oklab, oklch(0.9674 0.0013 265) 80%, oklch(0.2574 0.0056 265) 20%), color-mix(in oklab, oklch(0.669 0.0107 265) 80%, oklch(0.2574 0.0056 265) 20%))"
    },
    "@media (hover: hover)": {
      ".bjork-layered-button-accent:hover": {
        "filter": "brightness(1.08) saturate(1.04)"
      },
      ".bjork-layered-button-raised:hover": {
        "filter": "brightness(1.08) contrast(0.9)"
      }
    }
  },
  "meta": {
    "collection": "Charts",
    "registryUrl": "https://ui.isaiahbjork.com/stacked-area-chart.json",
    "installCommand": "npx shadcn@latest add https://ui.isaiahbjork.com/stacked-area-chart.json"
  },
  "type": "registry:component"
}