{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "storey-pole",
  "title": "Storey Pole",
  "description": "Indoor level switcher drawn as a true architectural cross-section: floors are horizontal slabs at their real relative heights (a double-height lobby is visibly taller than a mezzanine), a spring-loaded datum line points at the selected slab's elevation, below-grade floors carry a 45-degree hatch fill, and every label prints its elevation in metres.",
  "dependencies": [],
  "files": [
    {
      "path": "registry/core/storey-pole/component.tsx",
      "content": "\"use client\";\n\nimport { useCallback, useEffect, useId, useMemo, useRef, useState } from \"react\";\n\n// ---------------------------------------------------------------------------\n// StoreyPole — an indoor level switcher drawn as a true architectural\n// cross-section rather than an abstract vertical list. Floors are horizontal\n// slab bars stacked by their REAL relative heights: slab pixel height =\n// storeyHeight(metres) x one shared px-per-metre scale, the same scale for\n// every slab in the drawing. A double-height lobby is visibly taller than a\n// mezzanine; nothing here ever renders two different storeys as identical\n// bars, because that would make the section a fake.\n//\n// GOVERNING SCALAR: `e`, the selected level's datum elevation in metres\n// (its finished-floor elevation, the bottom edge of its slab). Four things\n// derive from `e`: the datum line's y position, which slab is visually\n// highlighted, the plan viewport's crossfade pairing, and the readout text.\n//\n// MECHANISM: slabs never move — a section is a fixed drawing. Only the\n// datum line moves, via an rAF mass-spring (k constant, zeta derived from\n// how many floors were crossed: 1 floor is near-critically-damped with\n// almost no overshoot, farther jumps progressively underdamp so the\n// overshoot visibly scales with distance traveled — a fixed overshoot would\n// make a 1-floor and an 8-floor jump feel identical). Pointer interaction on\n// the cross-section drags the line continuously: it magnetizes to a slab's\n// datum with a deadband 30% of THAT slab's own height, snapping there when\n// close; outside every deadband it free-follows the pointer. The nearest\n// slab is tracked as a live PREVIEW (drives the highlight, the plan\n// crossfade and the readout) without touching the committed value or\n// firing onValueChange until pointer-up.\n//\n// Below-grade slabs (elevation < 0) carry a 45-degree --border hatch fill\n// down their left margin — the standard section convention for earth — so\n// \"below ground\" reads before any label does.\n//\n// STRUCTURE: real native input type=radio per level (not wrapped in a\n// <label>, since pointer commits are handled by the drag/click surface\n// covering the whole section — but every native radio behavior arrow-key\n// roving, Tab order, form participation, aria-checked comes free from the\n// browser). Each radio's accessible name carries the real numbers: label,\n// elevation phrase, optional name, and its immediate neighbors above/below.\n// Arrow-key/commit changes push a spoken elevation delta (\"up 3.6 m\") into\n// an aria-live region. The datum line and hatch are aria-hidden; reduced\n// motion repositions the line instantly instead of springing, and skips the\n// plan crossfade's fade in favor of an instant swap.\n//\n// Pure DOM + SVG + CSS. No canvas. Every ink color is one of --background\n// --foreground --ns-muted --border --ns-accent, --ns-accent reserved for\n// the keyboard focus ring only.\n//\n// Distinct from counterpoise-tiers: counterpoise-tiers stacks CONTENT by\n// weight (an information hierarchy). StoreyPole stacks REAL BUILDING\n// GEOMETRY — the metres behind every slab's proportion are printed in its\n// accessible name, and the falsifiable constraint (shared px/metre scale)\n// means the drawing is either an honest section or visibly wrong, never a\n// stylistic choice.\n// ---------------------------------------------------------------------------\n\nexport interface StoreyPoleLevel {\n  /** Stable identifier, used as the native radio's value. */\n  id: string;\n  /** Short floor code, e.g. \"3\", \"G\", \"M\", \"B2\". */\n  label: string;\n  /** Optional descriptive name, e.g. \"Engineering\", \"Lobby\", \"Parking\". */\n  name?: string;\n  /** Finished-floor elevation in metres above ground (negative = below grade). */\n  elevation: number;\n  /** Storey height in metres — the ONLY thing that drives this slab's drawn height. */\n  height: number;\n}\n\nexport interface StoreyPoleProps {\n  /** Accessible name for the radiogroup, e.g. \"Select floor\". */\n  label: string;\n  levels: StoreyPoleLevel[];\n  /** Controlled selected level id. */\n  value?: string;\n  /** Initial value when uncontrolled. @default the level at elevation 0, else the topmost level */\n  defaultValue?: string;\n  /** called with the new level id when the committed selection changes */\n  onValueChange?: (id: string) => void;\n  /** Shared `name` for the native radios. @default a generated id */\n  name?: string;\n  /** extra classes merged onto the rendered root element */\n  className?: string;\n}\n\ninterface Geom {\n  level: StoreyPoleLevel;\n  top: number;\n  height: number;\n  bottom: number;\n}\n\ninterface SpringState {\n  raf: number;\n  last: number;\n  y: number;\n  vy: number;\n  target: number;\n  zeta: number;\n  deadline: number;\n}\n\nconst PX_PER_METRE = 15;\nconst BAR_WIDTH = 44;\nconst SPRING_K = 300; // rad^2/s^2, constant — only zeta varies with distance\nconst BASE_SETTLE_MS = 280;\nconst PER_FLOOR_SETTLE_MS = 45;\nconst MAX_SETTLE_MS = 640;\nconst MIN_ZETA = 0.28;\nconst ZETA_STEP = 0.11;\nconst PLAN_FADE_MS = 220;\nconst DEADBAND_FRACTION = 0.3;\n\nfunction useReducedMotion(): boolean {\n  const [reduced, setReduced] = useState(false);\n  useEffect(() => {\n    const mq = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n    setReduced(mq.matches);\n    const onChange = () => setReduced(mq.matches);\n    mq.addEventListener(\"change\", onChange);\n    return () => mq.removeEventListener(\"change\", onChange);\n  }, []);\n  return reduced;\n}\n\nfunction elevationPhrase(elevation: number): string {\n  if (elevation === 0) return \"at ground level\";\n  const abs = Math.abs(elevation).toFixed(1);\n  return elevation > 0 ? `${abs} m above ground` : `${abs} m below ground`;\n}\n\nfunction elevationShort(elevation: number): string {\n  if (elevation === 0) return \"±0.0 m\";\n  const sign = elevation > 0 ? \"+\" : \"−\";\n  return `${sign}${Math.abs(elevation).toFixed(1)} m`;\n}\n\nfunction neighborName(g: Geom | undefined): string | undefined {\n  if (!g) return undefined;\n  return g.level.name ?? `Level ${g.level.label}`;\n}\n\n// --- deterministic per-level \"plan\" glyph -----------------------------------\n// A tiny seeded PRNG (mulberry32, seeded from a FNV-1a hash of the level id)\n// so each floor gets a stable, visually distinct abstract room layout across\n// renders and reloads, with no per-render randomness.\nfunction seedFromString(s: string): number {\n  let h = 2166136261;\n  for (let i = 0; i < s.length; i++) {\n    h ^= s.charCodeAt(i);\n    h = Math.imul(h, 16777619);\n  }\n  return h >>> 0;\n}\n\nfunction mulberry32(seed: number) {\n  let a = seed;\n  return () => {\n    a |= 0;\n    a = (a + 0x6d2b79f5) | 0;\n    let t = Math.imul(a ^ (a >>> 15), 1 | a);\n    t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;\n    return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n  };\n}\n\nfunction PlanGlyph({\n  level,\n  className,\n}: {\n  level: StoreyPoleLevel;\n  className?: string;\n}) {\n  // One memo, one draw order. `cuts` and `core` used to share a single stateful\n  // `rng` across two separate useMemos: `cuts` consumes a VARIABLE number of\n  // rng() calls (random loop count, branch per iteration), so `core` read\n  // whatever position the stream happened to be at. React is free to re-run\n  // memos independently on the client, which left the server drawing core at\n  // x=22.67 and the client at x=46.82 — a hydration mismatch. Deriving both\n  // from one generator in a fixed order makes the sequence deterministic.\n  const { cuts, core } = useMemo(() => {\n    const rng = mulberry32(seedFromString(level.id));\n    const n = 2 + Math.floor(rng() * 3);\n    const lines: { x1: number; y1: number; x2: number; y2: number }[] = [];\n    for (let i = 0; i < n; i++) {\n      if (rng() > 0.5) {\n        const x = 14 + rng() * 68;\n        lines.push({ x1: x, y1: 6, x2: x, y2: 66 });\n      } else {\n        const y = 12 + rng() * 48;\n        lines.push({ x1: 6, y1: y, x2: 90, y2: y });\n      }\n    }\n    return {\n      cuts: lines,\n      core: {\n        x: 10 + rng() * 58,\n        y: 10 + rng() * 42,\n        w: 10 + rng() * 12,\n        h: 8 + rng() * 10,\n      },\n    };\n  }, [level.id]);\n  return (\n    <svg\n      viewBox=\"0 0 96 72\"\n      className={className}\n      aria-hidden=\"true\"\n      focusable=\"false\"\n    >\n      <rect\n        x={2}\n        y={2}\n        width={92}\n        height={68}\n        className=\"text-border\"\n        fill=\"none\"\n        stroke=\"currentColor\"\n        strokeWidth={1.5}\n      />\n      {cuts.map((l, i) => (\n        <line\n          key={i}\n          x1={l.x1}\n          y1={l.y1}\n          x2={l.x2}\n          y2={l.y2}\n          className=\"text-border\"\n          stroke=\"currentColor\"\n          strokeWidth={1}\n        />\n      ))}\n      <rect\n        x={core.x}\n        y={core.y}\n        width={core.w}\n        height={core.h}\n        className=\"text-ns-muted\"\n        fill=\"currentColor\"\n        fillOpacity={0.28}\n        stroke=\"currentColor\"\n        strokeWidth={1}\n      />\n    </svg>\n  );\n}\n\nexport function StoreyPole({\n  label,\n  levels,\n  value,\n  defaultValue,\n  onValueChange,\n  name,\n  className = \"\",\n}: StoreyPoleProps) {\n  const generatedName = useId();\n  const groupName = name ?? generatedName;\n  const reducedMotion = useReducedMotion();\n  const reducedMotionRef = useRef(reducedMotion);\n  reducedMotionRef.current = reducedMotion;\n\n  const sorted = useMemo(\n    () => [...levels].sort((a, b) => b.elevation - a.elevation),\n    [levels]\n  );\n\n  const geometry = useMemo<Geom[]>(() => {\n    let acc = 0;\n    return sorted.map((lvl) => {\n      const px = Math.max(0, lvl.height) * PX_PER_METRE;\n      const top = acc;\n      acc += px;\n      return { level: lvl, top, height: px, bottom: top + px };\n    });\n  }, [sorted]);\n\n  const totalHeight = geometry.length\n    ? geometry[geometry.length - 1].bottom\n    : 0;\n\n  const geomById = useMemo(\n    () => new Map(geometry.map((g) => [g.level.id, g] as const)),\n    [geometry]\n  );\n  const indexById = useMemo(\n    () => new Map(sorted.map((l, i) => [l.id, i] as const)),\n    [sorted]\n  );\n\n  const fallbackDefault = useMemo(() => {\n    const ground = sorted.find((l) => l.elevation === 0);\n    return ground?.id ?? sorted[0]?.id ?? \"\";\n  }, [sorted]);\n\n  const isControlled = value !== undefined;\n  const [internal, setInternal] = useState(\n    () => defaultValue ?? fallbackDefault\n  );\n  const committedId = isControlled ? (value as string) : internal;\n\n  const commit = useCallback(\n    (id: string) => {\n      if (!isControlled) setInternal(id);\n      if (id !== committedId) onValueChange?.(id);\n    },\n    [isControlled, committedId, onValueChange]\n  );\n\n  // live preview id: mirrors committedId at rest, but tracks the\n  // pointer-nearest slab during a drag scrub without committing.\n  const [previewId, setPreviewId] = useState(committedId);\n  const previewIdRef = useRef(previewId);\n  const draggingRef = useRef(false);\n\n  useEffect(() => {\n    if (draggingRef.current) return;\n    previewIdRef.current = committedId;\n    setPreviewId(committedId);\n  }, [committedId]);\n\n  // --- datum line spring -----------------------------------------------\n  const lineRef = useRef<HTMLDivElement | null>(null);\n  const springRef = useRef<SpringState | null>(null);\n  if (!springRef.current) {\n    const y = geomById.get(committedId)?.bottom ?? 0;\n    springRef.current = { raf: 0, last: 0, y, vy: 0, target: y, zeta: 1, deadline: 0 };\n  }\n\n  const applyTransform = useCallback((y: number) => {\n    const el = lineRef.current;\n    if (el) el.style.transform = `translateY(${y}px)`;\n  }, []);\n\n  const setLineImmediate = useCallback(\n    (px: number) => {\n      const s = springRef.current!;\n      if (s.raf) cancelAnimationFrame(s.raf);\n      s.raf = 0;\n      s.y = px;\n      s.vy = 0;\n      s.target = px;\n      applyTransform(px);\n    },\n    [applyTransform]\n  );\n\n  const loop = useCallback(\n    (now: number) => {\n      const s = springRef.current!;\n      s.raf = 0;\n      const dt = s.last ? Math.min(0.033, (now - s.last) / 1000) : 1 / 60;\n      s.last = now;\n      const c = 2 * s.zeta * Math.sqrt(SPRING_K);\n      s.vy += (-SPRING_K * (s.y - s.target) - c * s.vy) * dt;\n      s.y += s.vy * dt;\n      const settled =\n        now >= s.deadline || (Math.abs(s.y - s.target) < 0.3 && Math.abs(s.vy) < 4);\n      if (settled) {\n        s.y = s.target;\n        s.vy = 0;\n        applyTransform(s.y);\n        return;\n      }\n      applyTransform(s.y);\n      s.raf = requestAnimationFrame(loop);\n    },\n    [applyTransform]\n  );\n\n  const springTo = useCallback(\n    (px: number, dist: number) => {\n      if (reducedMotionRef.current) {\n        setLineImmediate(px);\n        return;\n      }\n      const s = springRef.current!;\n      s.target = px;\n      s.zeta = Math.max(MIN_ZETA, 1 - (dist - 1) * ZETA_STEP);\n      s.deadline =\n        performance.now() +\n        Math.min(MAX_SETTLE_MS, BASE_SETTLE_MS + (dist - 1) * PER_FLOOR_SETTLE_MS);\n      s.last = 0;\n      if (!s.raf) s.raf = requestAnimationFrame(loop);\n    },\n    [loop, setLineImmediate]\n  );\n\n  useEffect(() => {\n    return () => {\n      const s = springRef.current;\n      if (s?.raf) cancelAnimationFrame(s.raf);\n    };\n  }, []);\n\n  // reposition (spring, or instantly under reduced motion) whenever the\n  // COMMITTED value actually changes — via click, keyboard, drag-release,\n  // or a controlled `value` prop update. `dist` is the number of floors\n  // crossed since the last commit, which is what makes the overshoot scale\n  // with distance rather than being a fixed constant.\n  const prevIdxRef = useRef<number | null>(null);\n  useEffect(() => {\n    const idx = indexById.get(committedId);\n    const g = geomById.get(committedId);\n    if (idx === undefined || !g) return;\n    if (prevIdxRef.current === null) {\n      setLineImmediate(g.bottom);\n      prevIdxRef.current = idx;\n      return;\n    }\n    if (prevIdxRef.current === idx) return;\n    const dist = Math.max(1, Math.abs(idx - prevIdxRef.current));\n    prevIdxRef.current = idx;\n    springTo(g.bottom, dist);\n  }, [committedId, indexById, geomById, springTo, setLineImmediate]);\n\n  // --- drag / scrub -------------------------------------------------------\n  const sectionRef = useRef<HTMLDivElement | null>(null);\n\n  const nearestGeom = useCallback(\n    (px: number): Geom | undefined => {\n      let best: Geom | undefined;\n      let bestD = Infinity;\n      for (const g of geometry) {\n        const d = Math.abs(g.bottom - px);\n        if (d < bestD) {\n          bestD = d;\n          best = g;\n        }\n      }\n      return best;\n    },\n    [geometry]\n  );\n\n  const updateFromClientY = useCallback(\n    (clientY: number) => {\n      const el = sectionRef.current;\n      if (!el || geometry.length === 0) return;\n      const rect = el.getBoundingClientRect();\n      const raw = Math.min(totalHeight, Math.max(0, clientY - rect.top));\n      const nearest = nearestGeom(raw);\n      if (!nearest) return;\n      const deadband = nearest.height * DEADBAND_FRACTION;\n      const within = Math.abs(raw - nearest.bottom) < deadband / 2;\n      setLineImmediate(within ? nearest.bottom : raw);\n      previewIdRef.current = nearest.level.id;\n      setPreviewId(nearest.level.id);\n    },\n    [geometry, totalHeight, nearestGeom, setLineImmediate]\n  );\n\n  const onPointerDown = useCallback(\n    (e: React.PointerEvent<HTMLDivElement>) => {\n      if (geometry.length === 0) return;\n      draggingRef.current = true;\n      sectionRef.current?.setPointerCapture(e.pointerId);\n      updateFromClientY(e.clientY);\n    },\n    [geometry.length, updateFromClientY]\n  );\n\n  const onPointerMove = useCallback(\n    (e: React.PointerEvent<HTMLDivElement>) => {\n      if (!draggingRef.current) return;\n      updateFromClientY(e.clientY);\n    },\n    [updateFromClientY]\n  );\n\n  const endDrag = useCallback(() => {\n    if (!draggingRef.current) return;\n    draggingRef.current = false;\n    const id = previewIdRef.current;\n    const g = geomById.get(id);\n    commit(id);\n    if (g) springTo(g.bottom, 1);\n  }, [geomById, commit, springTo]);\n\n  // --- announcements --------------------------------------------------\n  const [announcement, setAnnouncement] = useState(\"\");\n  const prevElevRef = useRef<number | null>(null);\n  useEffect(() => {\n    const g = geomById.get(committedId);\n    if (!g) return;\n    const elev = g.level.elevation;\n    if (prevElevRef.current === null) {\n      prevElevRef.current = elev;\n      return;\n    }\n    const delta = elev - prevElevRef.current;\n    prevElevRef.current = elev;\n    if (delta === 0) {\n      setAnnouncement(`Level ${g.level.label} selected`);\n      return;\n    }\n    const dir = delta > 0 ? \"up\" : \"down\";\n    setAnnouncement(`${dir} ${Math.abs(delta).toFixed(1)} m to Level ${g.level.label}`);\n  }, [committedId, geomById]);\n\n  // --- plan viewport crossfade -----------------------------------------\n  const [outgoingLevel, setOutgoingLevel] = useState<StoreyPoleLevel | null>(null);\n  const outgoingElRef = useRef<HTMLDivElement | null>(null);\n  const lastPreviewIdRef = useRef(previewId);\n\n  useEffect(() => {\n    if (previewId === lastPreviewIdRef.current) return;\n    const prevId = lastPreviewIdRef.current;\n    lastPreviewIdRef.current = previewId;\n    if (reducedMotion) {\n      setOutgoingLevel(null);\n      return;\n    }\n    setOutgoingLevel(geomById.get(prevId)?.level ?? null);\n  }, [previewId, reducedMotion, geomById]);\n\n  useEffect(() => {\n    if (!outgoingLevel) return;\n    const el = outgoingElRef.current;\n    if (!el || typeof el.animate !== \"function\") {\n      setOutgoingLevel(null);\n      return;\n    }\n    const anim = el.animate([{ opacity: 1 }, { opacity: 0 }], {\n      duration: PLAN_FADE_MS,\n      easing: \"ease-out\",\n      fill: \"forwards\",\n    });\n    const done = () =>\n      setOutgoingLevel((cur) => (cur === outgoingLevel ? null : cur));\n    anim.onfinish = done;\n    anim.oncancel = done;\n  }, [outgoingLevel]);\n\n  if (geometry.length === 0) {\n    return (\n      <p className={`font-mono text-xs text-ns-muted ${className}`}>\n        No levels to show.\n      </p>\n    );\n  }\n\n  const currentLevel = geomById.get(previewId)?.level ?? sorted[0];\n\n  return (\n    <div className={`ns-sp-root flex flex-wrap items-start gap-6 ${className}`}>\n      <div\n        ref={sectionRef}\n        role=\"radiogroup\"\n        aria-label={label}\n        className=\"ns-sp-section touch-none\"\n        style={{ height: totalHeight }}\n        onPointerDown={onPointerDown}\n        onPointerMove={onPointerMove}\n        onPointerUp={endDrag}\n        onPointerCancel={endDrag}\n      >\n        {geometry.map((g, i) => {\n          const lvl = g.level;\n          const checked = lvl.id === committedId;\n          const highlighted = lvl.id === previewId;\n          const belowGrade = lvl.elevation < 0;\n\n          const belowNeighbor = neighborName(geometry[i + 1]);\n          const aboveNeighbor = neighborName(geometry[i - 1]);\n          const neighborParts: string[] = [];\n          if (belowNeighbor) neighborParts.push(`directly above ${belowNeighbor}`);\n          if (aboveNeighbor) neighborParts.push(`below ${aboveNeighbor}`);\n          const parts = [`Level ${lvl.label}`, elevationPhrase(lvl.elevation)];\n          if (lvl.name) parts.push(lvl.name);\n          let accLabel = parts.join(\", \");\n          if (neighborParts.length) accLabel += `; ${neighborParts.join(\", \")}`;\n\n          return (\n            <div key={lvl.id} className=\"ns-sp-row\" style={{ height: g.height }}>\n              <input\n                type=\"radio\"\n                className=\"ns-sp-input\"\n                name={groupName}\n                value={lvl.id}\n                checked={checked}\n                onChange={() => commit(lvl.id)}\n                aria-label={accLabel}\n              />\n              <span className=\"ns-sp-visual\" data-checked={highlighted || undefined}>\n                <span className=\"ns-sp-bar\" data-checked={highlighted || undefined}>\n                  {belowGrade && <span aria-hidden=\"true\" className=\"ns-sp-hatch\" />}\n                </span>\n                <span className=\"ns-sp-info\">\n                  <span className=\"ns-sp-code\" data-checked={highlighted || undefined}>\n                    {lvl.label}\n                  </span>\n                  <span className=\"ns-sp-elev\">{elevationShort(lvl.elevation)}</span>\n                  {lvl.name && <span className=\"ns-sp-name\">{lvl.name}</span>}\n                </span>\n              </span>\n            </div>\n          );\n        })}\n\n        <div\n          ref={lineRef}\n          aria-hidden=\"true\"\n          className=\"ns-sp-datum\"\n          style={{ transform: `translateY(${springRef.current.y}px)` }}\n        />\n      </div>\n\n      <div className=\"ns-sp-side min-w-[180px] max-w-[240px] flex-1\">\n        <div className=\"ns-sp-plan-stack\">\n          <PlanGlyph key={currentLevel.id} level={currentLevel} className=\"ns-sp-plan-glyph\" />\n          {outgoingLevel && (\n            <div ref={outgoingElRef} className=\"ns-sp-plan-overlay\">\n              <PlanGlyph level={outgoingLevel} className=\"ns-sp-plan-glyph\" />\n            </div>\n          )}\n        </div>\n        <div className=\"ns-sp-readout\">\n          <span className=\"ns-sp-readout-code\">{currentLevel.label}</span>\n          <span className=\"ns-sp-readout-elev\">{elevationPhrase(currentLevel.elevation)}</span>\n          {currentLevel.name && (\n            <span className=\"ns-sp-readout-name\">{currentLevel.name}</span>\n          )}\n        </div>\n      </div>\n\n      <div className=\"sr-only\" role=\"status\" aria-live=\"polite\">\n        {announcement}\n      </div>\n\n      <style>{`\n        .ns-sp-section {\n          position: relative;\n          width: ${BAR_WIDTH + 8}px;\n          min-width: max-content;\n        }\n        .ns-sp-row {\n          position: relative;\n        }\n        .ns-sp-input {\n          position: absolute;\n          width: 1px;\n          height: 1px;\n          padding: 0;\n          margin: -1px;\n          overflow: hidden;\n          clip: rect(0, 0, 0, 0);\n          white-space: nowrap;\n          border: 0;\n          outline: none;\n        }\n        .ns-sp-visual {\n          display: flex;\n          align-items: stretch;\n          height: 100%;\n          border-radius: 4px;\n        }\n        .ns-sp-input:focus-visible + .ns-sp-visual {\n          outline: 2px solid var(--ns-accent);\n          outline-offset: 2px;\n        }\n        .ns-sp-bar {\n          position: relative;\n          flex: 0 0 ${BAR_WIDTH}px;\n          width: ${BAR_WIDTH}px;\n          box-sizing: border-box;\n          border: 1px solid var(--border);\n          background: var(--background);\n          transition: background-color 160ms ease;\n          overflow: hidden;\n        }\n        .ns-sp-bar[data-checked] {\n          background: color-mix(in oklab, var(--foreground) 8%, transparent);\n        }\n        .ns-sp-row:hover .ns-sp-bar:not([data-checked]) {\n          background: color-mix(in oklab, var(--foreground) 4%, transparent);\n        }\n        .ns-sp-hatch {\n          position: absolute;\n          inset: 0 auto 0 0;\n          width: 9px;\n          background-image: repeating-linear-gradient(\n            45deg,\n            var(--border) 0 1.5px,\n            transparent 1.5px 5px\n          );\n        }\n        .ns-sp-info {\n          display: flex;\n          align-items: center;\n          gap: 8px;\n          padding: 0 10px 0 12px;\n          white-space: nowrap;\n        }\n        .ns-sp-code {\n          font-family: var(--font-mono, monospace);\n          font-size: 0.8125rem;\n          font-weight: 500;\n          color: var(--ns-muted);\n          min-width: 1.5em;\n          transition: color 160ms ease;\n        }\n        .ns-sp-code[data-checked] {\n          color: var(--foreground);\n          font-weight: 700;\n        }\n        .ns-sp-elev {\n          font-family: var(--font-mono, monospace);\n          font-size: 0.6875rem;\n          color: var(--ns-muted);\n          font-variant-numeric: tabular-nums;\n        }\n        .ns-sp-name {\n          font-size: 0.75rem;\n          color: var(--ns-muted);\n        }\n        .ns-sp-datum {\n          position: absolute;\n          left: 0;\n          right: 0;\n          top: -1px;\n          height: 2px;\n          background: var(--foreground);\n          pointer-events: none;\n          will-change: transform;\n        }\n\n        .ns-sp-side {\n          display: flex;\n          flex-direction: column;\n          gap: 10px;\n        }\n        .ns-sp-plan-stack {\n          position: relative;\n          aspect-ratio: 4 / 3;\n          width: 100%;\n          border-radius: 8px;\n          background: var(--background);\n        }\n        .ns-sp-plan-overlay {\n          position: absolute;\n          inset: 0;\n        }\n        .ns-sp-plan-glyph {\n          position: absolute;\n          inset: 0;\n          width: 100%;\n          height: 100%;\n        }\n        .ns-sp-readout {\n          display: flex;\n          flex-wrap: wrap;\n          align-items: baseline;\n          gap: 6px 8px;\n        }\n        .ns-sp-readout-code {\n          font-family: var(--font-mono, monospace);\n          font-size: 1.05rem;\n          font-weight: 700;\n          color: var(--foreground);\n        }\n        .ns-sp-readout-elev {\n          font-family: var(--font-mono, monospace);\n          font-size: 0.75rem;\n          color: var(--ns-muted);\n        }\n        .ns-sp-readout-name {\n          font-size: 0.8125rem;\n          color: var(--ns-muted);\n        }\n\n        @media (prefers-reduced-motion: reduce) {\n          .ns-sp-bar {\n            transition: none;\n          }\n          .ns-sp-code {\n            transition: none;\n          }\n        }\n      `}</style>\n    </div>\n  );\n}\n",
      "type": "registry:ui",
      "target": "components/ui/storey-pole.tsx"
    }
  ],
  "cssVars": {
    "theme": {
      "color-ns-muted": "var(--ns-muted)",
      "color-ns-accent": "var(--ns-accent)"
    },
    "light": {
      "ns-muted": "#4d4d4d",
      "ns-accent": "#006bff"
    },
    "dark": {
      "ns-muted": "#8f8f8f"
    }
  },
  "meta": {
    "collection": "core",
    "tags": [
      "radio-group",
      "navigation",
      "picker",
      "wayfinding",
      "physics",
      "drag",
      "svg"
    ],
    "instruction": "A floor/level switcher for indoor maps, office floorplan viewers, mall/airport/hospital wayfinders, or parking apps — anywhere a bare vertical list of B2/G/M/3 hides the fact that floors are not evenly spaced. STRUCTURE: real native input type=radio per level, one shared radiogroup, arrow-key roving and Tab order native to the browser; each radio's accessible name is generated, not authored: 'Level 3, 12.4 m above ground, Engineering; directly above Parking, below Food Court' — label, elevation phrase, optional name, and both immediate neighbors. GEOMETRY: each level supplies elevation (metres above ground, negative below grade) and height (storey height in metres). Slab pixel height = height x one shared px-per-metre scale used for every level in the drawing — the falsifiable constraint that forbids equal-height list rows: a double-height lobby renders roughly twice as tall as a normal floor, a short mezzanine renders shorter, because the drawing is a real section, not a styled list. Slabs are stacked contiguously in elevation order and never move; only the datum line moves. Below-grade slabs (elevation less than 0) carry a 45-degree --border hatch fill down their left margin, the standard section-drawing convention for earth, so 'below ground' reads before any label does. MECHANISM: one governing scalar, the selected level's elevation in metres, drives four things together: the datum line's y position, which slab is highlighted, the plan-viewport crossfade pairing, and the readout text. Selecting a level (click, keyboard, or a controlled value change) moves ONLY the datum line via an rAF mass-spring: stiffness is constant, damping ratio is derived from how many floors were crossed — one floor settles near-critically-damped in about 280ms with almost no overshoot, an eight-floor jump underdamps further and visibly overshoots before settling, because a fixed overshoot would make a 1-floor and an 8-floor jump feel identical. DRAG: pointer-down anywhere in the cross-section starts a continuous scrub — the line magnetizes to the nearest slab's datum with a deadband 30% of THAT slab's own height (snapping when close, free-following the pointer outside every deadband), and the nearest slab drives a live PREVIEW of the highlight, the plan glyph and the readout without calling onValueChange or moving the committed radio selection until pointer-up, when the nearest slab is committed and the line makes a small critically-damped settle correction. PLAN VIEWPORT: a small deterministic abstract floor-plan glyph (seeded per level id, so it's stable across renders, not random each time) crossfades to the previewed level's glyph on every change — outgoing glyph fades over 220ms via the Web Animations API while the incoming one is already in place underneath. ANNOUNCEMENTS: every committed change (never a drag preview) pushes a spoken elevation delta into an aria-live=polite region, e.g. 'up 3.6 m to Level 3'. REDUCED MOTION: the datum line repositions instantly with no spring, and the plan viewport swaps instantly with no crossfade; both remain fully functional. STYLING: the highlighted slab and its floor code step up from --ns-muted to --foreground; --ns-accent appears only as the keyboard focus-visible ring, never as a resting-state color. Pure DOM + SVG + CSS, no canvas — every color is one of --background --foreground --ns-muted --border --ns-accent, read as CSS custom properties already in scope so both themes restyle for free. Distinct from pricing-scale: pricing-scale stacks CONTENT by weight as an information hierarchy; StoreyPole stacks REAL BUILDING GEOMETRY, and the metre values behind every slab's proportion live in each radio's accessible name, not just in the pixels."
  },
  "type": "registry:ui"
}