{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"empty-states","type":"registry:block","title":"Empty states","description":"Four empty states in one illustration whose shapes morph between scenes as you switch tabs.","categories":["blocks"],"dependencies":["motion"],"registryDependencies":["https://uiarc.dev/r/arc-motion-tokens.json","https://uiarc.dev/r/button.json"],"files":[{"path":"registry/blocks/empty-states/empty-states.tsx","type":"registry:component","target":"@components/arc/blocks/empty-states/empty-states.tsx","content":"\"use client\";\n\nimport { useEffect, useId, useLayoutEffect, useRef, useState } from \"react\";\nimport type { KeyboardEvent, PointerEvent } from \"react\";\nimport { AnimatePresence, animate, motion, useMotionValue, useReducedMotion } from \"motion/react\";\nimport { motionTokens } from \"../../lib/motion-tokens\";\nimport { Button } from \"../../button/button\";\nimport { FRAMES, KINDS, VIEW, shapePath } from \"./empty-states-art\";\nimport type { Frame, Phase, SceneId } from \"./empty-states-art\";\nimport styles from \"./empty-states.module.css\";\n\n/**\n * One product illustration for four empty states. The tabs pick a state; every shape in the drawing travels to its new\n * position, size, radius, rotation and color on a spring, outlines morph point by point, and line accents draw in a beat later.\n * Each primary action does something local and visible: filters clear into results, a retry reconnects after a short wait,\n * a mail check redraws the check, and a lost page is found in the archive. Nothing here talks to a server.\n */\n\ntype View = { scene: SceneId; phase: Phase; from: Phase };\ntype Copy = { title: string; line: string; action: string };\n\nconst SCENES: { id: SceneId; tab: string }[] = [\n  { id: \"search\", tab: \"No results\" },\n  { id: \"offline\", tab: \"Offline\" },\n  { id: \"inbox\", tab: \"Caught up\" },\n  { id: \"map\", tab: \"Not found\" },\n];\n\nconst COPY: Record<SceneId, { idle: Copy; done: Copy; loading: string; wait: number }> = {\n  search: {\n    idle: { title: \"No results for “Q3 roadmap”\", line: \"Two filters are on: owner is Emma Collins and status is archived.\", action: \"Clear filters\" },\n    done: { title: \"12 results for “Q3 roadmap”\", line: \"Filters cleared. Showing matches from every owner and status.\", action: \"Restore filters\" },\n    loading: \"\", wait: 0,\n  },\n  offline: {\n    idle: { title: \"You are offline\", line: \"Edits are saved on this device and sync when the connection returns.\", action: \"Try again\" },\n    done: { title: \"Back online\", line: \"Three edits synced to the Northwind workspace just now.\", action: \"Go offline\" },\n    loading: \"Reaching sync.northwind.example…\", wait: 1400,\n  },\n  inbox: {\n    idle: { title: \"All caught up\", line: \"You have read every message in Inbox. New mail lands here first.\", action: \"Check for mail\" },\n    done: { title: \"Still all caught up\", line: \"Checked just now. Nothing new since 8:30 this morning.\", action: \"Check again\" },\n    loading: \"Checking for new mail…\", wait: 1100,\n  },\n  map: {\n    idle: { title: \"Page not found\", line: \"The link to /projects/atlas-2023 is broken, or the page has moved.\", action: \"Find the page\" },\n    done: { title: \"Found it in Archive\", line: \"Atlas 2023 roadmap moved to /archive/atlas-2023 in March.\", action: \"Show broken link\" },\n    loading: \"Searching the workspace for Atlas…\", wait: 1200,\n  },\n};\n\n/** Shapes lead, details trail: back tiles, body, front tiles, then lines and the mark. Totals stay under 0.4s. */\nconst DELAY = [.05, .03, 0, .04, .07, .1, .06, .09, .11, .14];\nconst NUDGE = [.03, .015, 0, .02, .035, .05, .02, .04, .05, .07];\nconst DRIFT = 2.5;\n\nconst first = FRAMES.search.idle;\nconst INITIAL = first.prims.map((p, i) => ({ ...shapePath(KINDS[i]!, p.geo, p.fx[1], 0, 0), o: String(p.fx[0]) }));\n\nconst enter = [...motionTokens.ease.enter] as [number, number, number, number];\nconst standard = [...motionTokens.ease.standard] as [number, number, number, number];\n\n/** Motion's visualDuration and bounce, turned into stiffness and damping for the vector springs below. */\nfunction springOf({ visualDuration, bounce }: { visualDuration: number; bounce: number }) {\n  const root = (2 * Math.PI) / (visualDuration * 1.2);\n  return { k: root * root, c: 2 * Math.min(1, Math.max(.05, 1 - bounce)) * root };\n}\nconst MORPH = springOf(motionTokens.spring.morph), SMOOTH = springOf(motionTokens.spring.smooth), SWAY = { k: 90, c: 19 };\n\ntype Channel = { pos: Float64Array; vel: Float64Array; target: Float64Array; queue: { at: number; values: number[] }[]; k: number; c: number; still: boolean };\nconst channel = (values: number[], spring: { k: number; c: number }): Channel =>\n  ({ pos: Float64Array.from(values), vel: new Float64Array(values.length), target: Float64Array.from(values), queue: [], ...spring, still: true });\n\n/** Integrates one spring vector. A new target keeps the current velocity, so shapes retarget mid-flight without a hitch. */\nfunction advance(ch: Channel, now: number, dt: number) {\n  while (ch.queue.length && ch.queue[0]!.at <= now) {\n    const next = ch.queue.shift();\n    if (next) { ch.target.set(next.values); ch.still = false; }\n  }\n  if (!ch.still) {\n    const steps = Math.max(1, Math.ceil(dt * 240)), h = dt / steps, { pos, vel, target, k, c } = ch;\n    for (let s = 0; s < steps; s++) for (let i = 0; i < pos.length; i++) { vel[i]! += (-k * (pos[i]! - target[i]!) - c * vel[i]!) * h; pos[i]! += vel[i]! * h; }\n    let settled = true;\n    for (let i = 0; i < pos.length; i++) if (Math.abs(pos[i]! - target[i]!) > .004 || Math.abs(vel[i]!) > .02) { settled = false; break; }\n    if (settled) { pos.set(target); vel.fill(0); ch.still = true; }\n  }\n  return !ch.still || ch.queue.length > 0;\n}\n\ntype Nodes = { paths: SVGPathElement[]; ghosts: SVGPathElement[]; main: SVGGElement; ghost: SVGGElement };\n\n/** One animation frame loop drives every shape through refs. It sleeps once everything has settled. */\nfunction createEngine(nodes: Nodes, start: Frame) {\n  const geo = start.prims.map(p => channel(p.geo, MORPH));\n  const fx = start.prims.map(p => channel(p.fx, SMOOTH));\n  const sway = channel([0, 0], SWAY);\n  const written = INITIAL.map(item => ({ d: item.d, o: item.o, dash: item.dash }));\n  let frame = start, raf = 0, last = 0, parallax = false;\n\n  const paint = () => {\n    const ox = sway.pos[0]! * DRIFT, oy = sway.pos[1]! * DRIFT;\n    nodes.paths.forEach((node, i) => {\n      const g = geo[i]!.pos, f = fx[i]!.pos, w = written[i]!;\n      const { d, dash } = shapePath(KINDS[i]!, g, f[1]!, ox, oy);\n      const o = String(Math.round(Math.min(1, Math.max(0, f[0]!)) * 1000) / 1000);\n      if (d !== w.d) { node.setAttribute(\"d\", d); w.d = d; }\n      if (o !== w.o) { node.setAttribute(\"opacity\", o); w.o = o; }\n      if (dash !== w.dash) { node.setAttribute(\"stroke-dasharray\", dash); w.dash = dash; }\n    });\n  };\n  const tick = (time: number) => {\n    raf = 0;\n    const now = time / 1000, dt = last ? Math.min(.034, Math.max(0, now - last)) : 1 / 60;\n    last = now;\n    let busy = advance(sway, now, dt);\n    for (let i = 0; i < geo.length; i++) busy = advance(geo[i]!, now, dt) || busy;\n    for (let i = 0; i < fx.length; i++) busy = advance(fx[i]!, now, dt) || busy;\n    paint();\n    if (busy) raf = requestAnimationFrame(tick); else last = 0;\n  };\n  const kick = () => { if (!raf) raf = requestAnimationFrame(tick); };\n\n  const pointer = (x: number, y: number) => {\n    sway.queue = [];\n    sway.target.set(parallax ? [x, y] : [0, 0]);\n    sway.still = false;\n    kick();\n  };\n\n  return {\n    pointer,\n    go(next: Frame, sceneChanged: boolean, reduced: boolean) {\n      if (reduced) {\n        // Crossfade without travel: freeze the old drawing in a ghost layer, snap to the new one, and fade between them.\n        nodes.paths.forEach((node, i) => {\n          const ghost = nodes.ghosts[i]!;\n          ghost.setAttribute(\"d\", node.getAttribute(\"d\") ?? \"\");\n          ghost.setAttribute(\"opacity\", node.getAttribute(\"opacity\") ?? \"1\");\n          ghost.setAttribute(\"stroke-dasharray\", node.getAttribute(\"stroke-dasharray\") ?? \"none\");\n          ghost.dataset.tone = frame.prims[i]!.tone;\n        });\n        next.prims.forEach((p, i) => {\n          for (const [ch, values] of [[geo[i]!, p.geo], [fx[i]!, p.fx]] as const) { ch.queue = []; ch.target.set(values); ch.pos.set(values); ch.vel.fill(0); ch.still = true; }\n        });\n        frame = next;\n        paint();\n        animate(nodes.ghost, { opacity: [1, 0] }, { duration: motionTokens.duration.standard, ease: standard });\n        animate(nodes.main, { opacity: [0, 1] }, { duration: motionTokens.duration.standard, ease: standard });\n        return;\n      }\n      const now = performance.now() / 1000, delays = sceneChanged ? DELAY : NUDGE;\n      next.prims.forEach((p, i) => {\n        const delay = delays[i]!, f = fx[i]!;\n        geo[i]!.queue = [{ at: now + delay, values: p.geo }];\n        if (sceneChanged && p.redraw) f.queue = [{ at: now, values: [p.fx[0], 0] }, { at: now + delay + .18, values: p.fx }];\n        else f.queue = [{ at: now + delay + (p.fx[1] > f.target[1]! + .01 ? .12 : 0), values: p.fx }];\n      });\n      frame = next;\n      kick();\n    },\n    setParallax(on: boolean) { parallax = on; if (!on) pointer(0, 0); },\n    destroy() { if (raf) cancelAnimationFrame(raf); raf = 0; },\n  };\n}\n\nexport function EmptyStates() {\n  const uid = useId();\n  const reduced = useReducedMotion() ?? false;\n  const [view, setView] = useState<View>({ scene: \"search\", phase: \"idle\", from: \"idle\" });\n  const [announcement, setAnnouncement] = useState(\"\");\n  const tabs = useRef<(HTMLButtonElement | null)[]>([]);\n  const paths = useRef<(SVGPathElement | null)[]>([]);\n  const ghosts = useRef<(SVGPathElement | null)[]>([]);\n  const mainLayer = useRef<SVGGElement>(null);\n  const ghostLayer = useRef<SVGGElement>(null);\n  const engine = useRef<ReturnType<typeof createEngine> | null>(null);\n  const shown = useRef({ scene: view.scene, phase: view.phase });\n  const pending = useRef({ timer: 0 });\n  const copyInner = useRef<HTMLDivElement>(null);\n  const copyHeight = useMotionValue<number | \"auto\">(\"auto\");\n  const armedUntil = useRef(0);\n\n  const frame = FRAMES[view.scene][view.phase];\n  const text = COPY[view.scene];\n  const copy: Copy = view.phase === \"loading\" ? { ...text[view.from === \"done\" ? \"done\" : \"idle\"], line: text.loading } : text[view.phase === \"done\" ? \"done\" : \"idle\"];\n  const copyKey = `${copy.title}|${copy.line}`;\n\n  useEffect(() => {\n    const main = mainLayer.current, ghost = ghostLayer.current;\n    const nodes = paths.current.filter(Boolean) as SVGPathElement[], ghostNodes = ghosts.current.filter(Boolean) as SVGPathElement[];\n    if (!main || !ghost || nodes.length !== KINDS.length || ghostNodes.length !== KINDS.length) return;\n    const instance = createEngine({ paths: nodes, ghosts: ghostNodes, main, ghost }, first);\n    engine.current = instance;\n    const bag = pending.current;\n    return () => { instance.destroy(); engine.current = null; window.clearTimeout(bag.timer); };\n  }, []);\n\n  useEffect(() => {\n    const fine = typeof window !== \"undefined\" && window.matchMedia(\"(hover: hover) and (pointer: fine)\").matches;\n    engine.current?.setParallax(fine && !reduced);\n  }, [reduced]);\n\n  useEffect(() => {\n    const prev = shown.current;\n    if (prev.scene === view.scene && prev.phase === view.phase) return;\n    shown.current = { scene: view.scene, phase: view.phase };\n    engine.current?.go(FRAMES[view.scene][view.phase], prev.scene !== view.scene, reduced);\n  }, [view.scene, view.phase, reduced]);\n\n  // The copy block springs to the height of the incoming text, so the action never jumps.\n  useLayoutEffect(() => { armedUntil.current = performance.now() + 700; }, [copyKey]);\n  useEffect(() => {\n    const node = copyInner.current;\n    if (!node || typeof ResizeObserver === \"undefined\") return;\n    let measured = false;\n    const observer = new ResizeObserver(([entry]) => {\n      if (!entry) return;\n      const next = entry.borderBoxSize?.[0]?.blockSize ?? entry.contentRect.height;\n      if (!measured || reduced || performance.now() > armedUntil.current) { measured = true; copyHeight.jump(next); return; }\n      animate(copyHeight, next, motionTokens.spring.smooth);\n    });\n    observer.observe(node);\n    return () => observer.disconnect();\n  }, [reduced, copyHeight]);\n\n  function choose(scene: SceneId) {\n    if (scene === view.scene) return;\n    window.clearTimeout(pending.current.timer);\n    setView({ scene, phase: \"idle\", from: \"idle\" });\n    setAnnouncement(\"\");\n  }\n\n  function act() {\n    const { scene, phase } = view;\n    if (phase === \"loading\") return;\n    const entry = COPY[scene];\n    if (scene === \"search\" || (phase === \"done\" && scene !== \"inbox\")) {\n      const next: Phase = phase === \"idle\" ? \"done\" : \"idle\";\n      setView({ scene, phase: next, from: phase });\n      setAnnouncement(`${entry[next === \"done\" ? \"done\" : \"idle\"].title}. ${entry[next === \"done\" ? \"done\" : \"idle\"].line}`);\n      return;\n    }\n    setView({ scene, phase: \"loading\", from: phase });\n    setAnnouncement(entry.loading);\n    window.clearTimeout(pending.current.timer);\n    pending.current.timer = window.setTimeout(() => {\n      setView(current => (current.scene === scene && current.phase === \"loading\" ? { scene, phase: \"done\", from: \"loading\" } : current));\n      setAnnouncement(`${entry.done.title}. ${entry.done.line}`);\n    }, entry.wait);\n  }\n\n  function onTabKey(event: KeyboardEvent<HTMLDivElement>) {\n    const index = SCENES.findIndex(item => item.id === view.scene);\n    const next = event.key === \"ArrowRight\" ? (index + 1) % SCENES.length : event.key === \"ArrowLeft\" ? (index + SCENES.length - 1) % SCENES.length : event.key === \"Home\" ? 0 : event.key === \"End\" ? SCENES.length - 1 : -1;\n    if (next < 0) return;\n    event.preventDefault();\n    choose(SCENES[next]!.id);\n    tabs.current[next]?.focus();\n  }\n\n  function onPointerMove(event: PointerEvent<HTMLDivElement>) {\n    if (event.pointerType !== \"mouse\") return;\n    const rect = event.currentTarget.getBoundingClientRect();\n    engine.current?.pointer(((event.clientX - rect.left) / rect.width - .5) * 2, ((event.clientY - rect.top) / rect.height - .5) * 2);\n  }\n\n  const rise = reduced\n    ? { initial: { opacity: 0 }, exit: { opacity: 0, transition: { duration: motionTokens.duration.exit } } }\n    : { initial: { opacity: 0, y: 8, filter: `blur(${motionTokens.blur.soft}px)` }, exit: { opacity: 0, y: -6, filter: `blur(${motionTokens.blur.soft}px)`, transition: { duration: motionTokens.duration.exit, ease: standard } } };\n  const shownText = { opacity: 1, y: 0, filter: \"blur(0px)\" };\n  const textIn = (delay: number) => ({ duration: reduced ? motionTokens.duration.standard : motionTokens.duration.considered, ease: enter, delay: reduced ? 0 : delay });\n\n  return (\n    <section className={styles.root} aria-label=\"Empty states\">\n      <div className={styles.card}>\n        <div className={styles.tabs} role=\"tablist\" aria-label=\"Empty state\" onKeyDown={onTabKey}>\n          {SCENES.map((item, index) => {\n            const selected = item.id === view.scene;\n            return (\n              <button key={item.id} ref={node => { tabs.current[index] = node; }} id={`${uid}-tab-${item.id}`} type=\"button\" role=\"tab\" aria-selected={selected} aria-controls={`${uid}-panel`} tabIndex={selected ? 0 : -1} className={styles.tab} onClick={() => choose(item.id)}>\n                {selected ? <motion.span layoutId={`${uid}-highlight`} className={styles.highlight} transition={reduced ? { duration: 0 } : motionTokens.spring.morph} /> : null}\n                <span className={styles.tabLabel}>{item.tab}</span>\n              </button>\n            );\n          })}\n        </div>\n\n        <div className={styles.panel} role=\"tabpanel\" id={`${uid}-panel`} aria-labelledby={`${uid}-tab-${view.scene}`}>\n          <div className={styles.stage} onPointerMove={onPointerMove} onPointerLeave={() => engine.current?.pointer(0, 0)}>\n            <svg className={styles.art} viewBox={`0 0 ${VIEW.width} ${VIEW.height}`} role=\"img\" aria-label={frame.label}>\n              <g ref={ghostLayer} opacity={0} aria-hidden=\"true\">\n                {KINDS.map((kind, i) => <path key={i} ref={node => { ghosts.current[i] = node; }} className={styles.shape} data-kind={kind} d=\"\" />)}\n              </g>\n              <g ref={mainLayer}>\n                {INITIAL.map((item, i) => (\n                  <path key={i} ref={node => { paths.current[i] = node; }} className={styles.shape} data-kind={KINDS[i]} data-tone={frame.prims[i]!.tone} d={item.d} opacity={item.o} strokeDasharray={item.dash} style={{ transitionDelay: `${DELAY[i]}s` }} />\n                ))}\n              </g>\n            </svg>\n          </div>\n\n          <div className={styles.copy}>\n            <motion.div className={styles.copyFrame} style={{ height: copyHeight }}>\n              <div ref={copyInner} className={styles.copyInner}>\n                <h2 className={styles.title}>\n                  <AnimatePresence mode=\"popLayout\" initial={false}>\n                    <motion.span key={copy.title} className={styles.swap} initial={rise.initial} animate={shownText} exit={rise.exit} transition={textIn(.06)}>{copy.title}</motion.span>\n                  </AnimatePresence>\n                </h2>\n                <p className={styles.line}>\n                  <AnimatePresence mode=\"popLayout\" initial={false}>\n                    <motion.span key={copy.line} className={styles.swap} initial={rise.initial} animate={shownText} exit={rise.exit} transition={textIn(.06 + motionTokens.stagger.word)}>{copy.line}</motion.span>\n                  </AnimatePresence>\n                </p>\n              </div>\n            </motion.div>\n            <Button size=\"sm\" onClick={act} loading={view.phase === \"loading\"}>{copy.action}</Button>\n          </div>\n          <p className={styles.srOnly} aria-live=\"polite\">{announcement}</p>\n        </div>\n      </div>\n    </section>\n  );\n}\n\nexport default EmptyStates;\n"},{"path":"registry/blocks/empty-states/empty-states.module.css","type":"registry:component","target":"@components/arc/blocks/empty-states/empty-states.module.css","content":".root { container-type: inline-size; width: 100%; color: var(--foreground); font-family: var(--font-body); letter-spacing: var(--tracking-body); }\n\n.card { display: flex; flex-direction: column; align-items: center; gap: clamp(20px, 4cqi, 32px); padding: clamp(16px, 5cqi, 48px) clamp(16px, 4cqi, 40px); border: 1px solid var(--border); border-radius: 20px; background: var(--surface); }\n\n/* Tabs: equal columns while there is room, never narrower than a label. The highlight glides under the labels. */\n.tabs { isolation: isolate; display: grid; grid-template-columns: repeat(4, minmax(max-content, 1fr)); gap: 2px; width: min(100%, 460px); overflow-x: auto; padding: 3px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-muted); scrollbar-width: none; }\n.tabs::-webkit-scrollbar { display: none; }\n.tab { position: relative; min-height: 30px; padding: 0 clamp(8px, 2.6cqi, 14px); border: 0; border-radius: 9px; background: transparent; color: var(--text-muted); font: inherit; font-size: var(--text-sm); font-weight: 500; line-height: var(--leading-body); white-space: nowrap; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: color var(--duration-fast) var(--ease-standard); }\n.tab[aria-selected=\"true\"] { color: var(--foreground); }\n@media (hover: hover) and (pointer: fine) { .tab:hover { color: var(--foreground); } }\n.highlight { position: absolute; inset: 0; z-index: -1; border: 1px solid var(--border); border-radius: inherit; background: var(--surface); box-shadow: var(--shadow-resting); }\n.tabLabel { position: relative; }\n@container (max-width: 420px) { .tab { padding: 0 6px; font-size: var(--text-xs); } }\n\n.panel { display: flex; flex-direction: column; align-items: center; gap: var(--space-5); width: 100%; max-width: 480px; }\n\n/* The drawing keeps one aspect ratio, so switching scenes never changes the layout. */\n.stage { width: min(100%, 360px); aspect-ratio: 320 / 216; }\n.art { display: block; width: 100%; height: 100%; overflow: visible; }\n\n/* Strokes stay 1.5px on screen at any size. Colors come from tones and cross over on CSS transitions while the geometry springs. */\n.shape { vector-effect: non-scaling-stroke; fill: none; stroke: none; stroke-width: 1.5px; stroke-linecap: round; stroke-linejoin: round; transition: fill var(--duration-considered) var(--ease-standard), stroke var(--duration-considered) var(--ease-standard); }\n.shape[data-tone=\"outline\"] { fill: var(--surface); stroke: var(--foreground); }\n.shape[data-tone=\"tuck\"] { fill: var(--surface); stroke: var(--border-strong); }\n.shape[data-tone=\"slot\"] { fill: var(--surface); stroke: var(--border-strong); }\n.shape[data-tone=\"query\"] { fill: var(--text-muted); stroke: transparent; }\n.shape[data-tone=\"bar\"] { fill: var(--border-strong); stroke: transparent; }\n.shape[data-tone=\"back\"] { fill: var(--surface); stroke: var(--text-muted); }\n.shape[data-tone=\"shade\"] { fill: var(--surface-muted); stroke: var(--foreground); }\n.shape[data-tone=\"dot\"] { fill: var(--foreground); stroke: transparent; }\n.shape[data-tone=\"ink\"] { fill: var(--surface); stroke: var(--foreground); }\n.shape[data-tone=\"muted\"] { fill: var(--surface); stroke: var(--text-muted); }\n.shape[data-tone=\"subtle\"] { fill: var(--surface); stroke: var(--border-strong); }\n.shape[data-tone=\"accent\"] { fill: var(--surface); stroke: var(--foreground); }\n.shape[data-tone=\"success\"] { fill: var(--surface); stroke: var(--success); }\n.shape[data-tone=\"warning\"] { fill: var(--surface); stroke: var(--warning); }\n.shape:is([data-kind=\"stroke\"], [data-kind=\"mark\"])[data-tone] { fill: none; }\n\n/* Copy */\n.copy { display: flex; flex-direction: column; align-items: center; gap: var(--space-4); width: 100%; text-align: center; }\n.copyFrame { width: 100%; }\n.copyInner { display: grid; gap: 6px; padding-inline: var(--space-2); }\n.title { position: relative; margin: 0; font-variant-numeric: tabular-nums; font-size: var(--text-lg); font-weight: 500; line-height: var(--leading-body); letter-spacing: var(--tracking-body); text-wrap: balance; }\n@container (min-width: 560px) { .title { font-size: var(--text-xl); } }\n.line { position: relative; max-width: 40ch; margin: 0 auto; color: var(--text-secondary); font-size: var(--text-sm); line-height: var(--leading-body); text-wrap: pretty; }\n.swap { display: block; }\n\n.srOnly { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n\n@media (prefers-reduced-motion: reduce) {\n  .shape, .tab { transition: none; }\n}\n"},{"path":"registry/blocks/empty-states/empty-states-art.ts","type":"registry:component","target":"@components/arc/blocks/empty-states/empty-states-art.ts","content":"/**\n * Geometry for the empty states illustration. Every scene is drawn from the same ten primitives, in the same paint order:\n * two back tiles, one morphing body, four front tiles, two line accents and one two-stroke mark. A scene only moves them.\n * Tiles are rounded rectangles described by center, size, radius, rotation and skew, so a circle can become a panel.\n * The body, lines and mark are equal-count point lists, sampled clockwise from the top left, so any outline can become any other.\n */\n\nexport type SceneId = \"search\" | \"offline\" | \"inbox\" | \"map\";\nexport type Phase = \"idle\" | \"loading\" | \"done\";\nexport type Kind = \"tile\" | \"body\" | \"stroke\" | \"mark\";\n/** `geo` springs as one vector; `fx` holds opacity and how much of a stroke is drawn. */\nexport type Prim = { kind: Kind; geo: number[]; fx: [number, number]; tone: string; redraw: boolean };\nexport type Frame = { prims: Prim[]; label: string };\n\nexport const KINDS: Kind[] = [\"tile\", \"tile\", \"body\", \"tile\", \"tile\", \"tile\", \"tile\", \"stroke\", \"stroke\", \"mark\"];\n\ntype Pt = readonly [number, number];\ntype Seg = { len: number; at: (t: number) => Pt };\n\nconst N = 176, K = 40, M = 12;\nconst TAU = Math.PI * 2, RAD = Math.PI / 180;\n\nconst seg = (a: Pt, b: Pt): Seg => {\n  const dx = b[0] - a[0], dy = b[1] - a[1];\n  return { len: Math.hypot(dx, dy), at: t => [a[0] + dx * t, a[1] + dy * t] };\n};\n\n/** Arcs always run clockwise on screen, from `from` to `to` in radians. */\nfunction arc(c: Pt, r: number, from: number, to: number): Seg {\n  let end = to;\n  while (end < from - 1e-9) end += TAU;\n  const span = end - from;\n  return { len: span * r, at: t => [c[0] + r * Math.cos(from + span * t), c[1] + r * Math.sin(from + span * t)] };\n}\nconst arcDeg = (c: Pt, r: number, from: number, to: number) => arc(c, r, from * RAD, to * RAD);\nconst polar = (c: Pt, r: number, deg: number): Pt => [c[0] + r * Math.cos(deg * RAD), c[1] + r * Math.sin(deg * RAD)];\n\nconst chain = (points: Pt[], closed = false) => {\n  const segs: Seg[] = [];\n  for (let i = 0; i < (closed ? points.length : points.length - 1); i++) segs.push(seg(points[i]!, points[(i + 1) % points.length]!));\n  return segs;\n};\n\n/** A Catmull-Rom curve through the points, walked by arc length. */\nfunction curve(points: Pt[]): Seg {\n  const dense: Pt[] = [];\n  for (let i = 0; i < points.length - 1; i++) {\n    const p0 = points[Math.max(0, i - 1)]!, p1 = points[i]!, p2 = points[i + 1]!, p3 = points[Math.min(points.length - 1, i + 2)]!;\n    for (let s = 0; s < 16; s++) {\n      const t = s / 16, t2 = t * t, t3 = t2 * t;\n      const axis = (k: 0 | 1) => .5 * (2 * p1[k] + (p2[k] - p0[k]) * t + (2 * p0[k] - 5 * p1[k] + 4 * p2[k] - p3[k]) * t2 + (3 * p1[k] - p0[k] - 3 * p2[k] + p3[k]) * t3);\n      dense.push([axis(0), axis(1)]);\n    }\n  }\n  dense.push(points[points.length - 1]!);\n  const cum = [0];\n  for (let i = 1; i < dense.length; i++) cum.push(cum[i - 1]! + Math.hypot(dense[i]![0] - dense[i - 1]![0], dense[i]![1] - dense[i - 1]![1]));\n  const len = cum[cum.length - 1]!;\n  return {\n    len,\n    at: t => {\n      const goal = t * len;\n      let i = 1;\n      while (i < cum.length - 1 && cum[i]! < goal) i++;\n      const a = dense[i - 1]!, b = dense[i]!, u = (goal - cum[i - 1]!) / (cum[i]! - cum[i - 1]! || 1);\n      return [a[0] + (b[0] - a[0]) * u, a[1] + (b[1] - a[1]) * u];\n    },\n  };\n}\n\n/** Shares `n` points between segments by length. Every segment starts on a point, so sharp corners survive the resample. */\nfunction allot(lens: number[], n: number) {\n  const total = lens.reduce((sum, len) => sum + len, 0);\n  if (total < 1e-6) return lens.map((_, i) => (i === 0 ? n : 0));\n  const exact = lens.map(len => (len / total) * n);\n  const counts = exact.map((value, i) => (lens[i]! > 1e-6 ? Math.max(1, Math.floor(value)) : 0));\n  let sum = counts.reduce((a, b) => a + b, 0);\n  while (sum < n) {\n    let best = -1;\n    for (let i = 0; i < counts.length; i++) if (lens[i]! > 1e-6 && (best < 0 || exact[i]! - counts[i]! > exact[best]! - counts[best]!)) best = i;\n    counts[best]!++; sum++;\n  }\n  while (sum > n) {\n    let best = -1;\n    for (let i = 0; i < counts.length; i++) if (counts[i]! > 1 && (best < 0 || counts[i]! - exact[i]! > counts[best]! - exact[best]!)) best = i;\n    counts[best]!--; sum--;\n  }\n  return counts;\n}\n\nfunction sample(segs: Seg[], n: number, open: boolean) {\n  const counts = allot(segs.map(s => s.len), open ? n - 1 : n);\n  const out: number[] = [];\n  segs.forEach((s, i) => { for (let j = 0; j < counts[i]!; j++) { const [x, y] = s.at(j / counts[i]!); out.push(x, y); } });\n  if (open) { const [x, y] = segs[segs.length - 1]!.at(1); out.push(x, y); }\n  return out;\n}\n\nfunction rrect(x: number, y: number, w: number, h: number, radius: number | [number, number, number, number]): Seg[] {\n  const [tl, tr, br, bl] = typeof radius === \"number\" ? [radius, radius, radius, radius] : radius;\n  return [\n    seg([x + tl, y], [x + w - tr, y]), arcDeg([x + w - tr, y + tr], tr, -90, 0),\n    seg([x + w, y + tr], [x + w, y + h - br]), arcDeg([x + w - br, y + h - br], br, 0, 90),\n    seg([x + w - br, y + h], [x + bl, y + h]), arcDeg([x + bl, y + h - bl], bl, 90, 180),\n    seg([x, y + h - bl], [x, y + tl]), arcDeg([x + tl, y + tl], tl, 180, 270),\n  ];\n}\n\n/** A cloud is a row of overlapping circles sitting on a flat base; the outline walks each circle's exposed top between neighbours. */\nfunction cloud(lobes: { c: Pt; r: number }[], base: number): Seg[] {\n  const meet = (a: { c: Pt; r: number }, b: { c: Pt; r: number }): Pt => {\n    const dx = b.c[0] - a.c[0], dy = b.c[1] - a.c[1], d = Math.hypot(dx, dy);\n    const along = (a.r * a.r - b.r * b.r + d * d) / (2 * d), h = Math.sqrt(Math.max(0, a.r * a.r - along * along));\n    const mx = a.c[0] + (along * dx) / d, my = a.c[1] + (along * dy) / d;\n    const p: Pt = [mx + (h * dy) / d, my - (h * dx) / d], q: Pt = [mx - (h * dy) / d, my + (h * dx) / d];\n    return p[1] < q[1] ? p : q;\n  };\n  const angle = (c: Pt, p: Pt) => Math.atan2(p[1] - c[1], p[0] - c[0]);\n  const joins = lobes.slice(1).map((lobe, i) => meet(lobes[i]!, lobe));\n  const first = lobes[0]!, last = lobes[lobes.length - 1]!;\n  const segs = [arc(first.c, first.r, -Math.PI / 2, angle(first.c, joins[0]!))];\n  for (let i = 1; i < lobes.length - 1; i++) { const lobe = lobes[i]!; segs.push(arc(lobe.c, lobe.r, angle(lobe.c, joins[i - 1]!), angle(lobe.c, joins[i]!))); }\n  segs.push(arc(last.c, last.r, angle(last.c, joins[joins.length - 1]!), Math.PI / 2));\n  segs.push(seg([last.c[0], base], [first.c[0], base]));\n  segs.push(arc(first.c, first.r, Math.PI / 2, Math.PI * 1.5));\n  return segs;\n}\n\ntype TileOptions = { rot?: number; skew?: number; z?: number; o?: number };\nconst tile = (cx: number, cy: number, w: number, h: number, r: number, tone: string, { rot = 0, skew = 0, z = 1, o = 1 }: TileOptions = {}): Prim =>\n  ({ kind: \"tile\", geo: [cx, cy, w, h, r, rot, skew, z], fx: [o, 1], tone, redraw: false });\nconst box = (x: number, y: number, w: number, h: number, r: number, tone: string, options?: TileOptions) => tile(x + w / 2, y + h / 2, w, h, r, tone, options);\nconst disc = (c: Pt, r: number, tone: string, options?: TileOptions) => tile(c[0], c[1], r * 2, r * 2, r, tone, options);\n/** Shapes a scene does not need shrink into a point inside something that stays, and fade on the way. */\nconst park = (c: Pt, z: number) => tile(c[0], c[1], 4, 4, 2, \"tuck\", { z, o: 0 });\nconst body = (segs: Seg[], z: number): Prim => ({ kind: \"body\", geo: [...sample(segs, N, false), z], fx: [1, 1], tone: \"outline\", redraw: false });\n\ntype StrokeOptions = { dash?: number; z?: number; z1?: number; o?: number; draw?: number; redraw?: boolean };\nconst line = (segs: Seg[], tone: string, { dash = 0, z = 1, z1 = z, o = 1, draw = 1, redraw = false }: StrokeOptions = {}): Prim =>\n  ({ kind: \"stroke\", geo: [...sample(segs, K, true), dash, z, z1], fx: [o, draw], tone, redraw });\nconst rest = (p: Pt, z: number) => line([seg(p, p)], \"ink\", { z, o: 0, draw: 0 });\nconst mark = ([a, b]: [Seg[], Seg[]], tone: string, { z = 1, o = 1, draw = 1, redraw = true }: StrokeOptions = {}): Prim =>\n  ({ kind: \"mark\", geo: [...sample(a, M, true), ...sample(b, M, true), 0, z, z], fx: [o, draw], tone, redraw });\n\nconst check = (c: Pt, s: number): [Seg[], Seg[]] => {\n  const a: Pt = [c[0] - .42 * s, c[1] + .02 * s], b: Pt = [c[0] - .12 * s, c[1] + .32 * s], e: Pt = [c[0] + .44 * s, c[1] - .3 * s];\n  return [[seg(a, b)], [seg(b, e)]];\n};\nconst cross = (c: Pt, h: number): [Seg[], Seg[]] => [[seg([c[0] - h, c[1] - h], [c[0] + h, c[1] + h])], [seg([c[0] + h, c[1] - h], [c[0] - h, c[1] + h])]];\nconst slashes = (c: Pt): [Seg[], Seg[]] => [[seg([c[0] - 10, c[1] + 5], [c[0] - 2, c[1] - 5])], [seg([c[0] + 2, c[1] + 5], [c[0] + 10, c[1] - 5])]];\nconst glare = (c: Pt, r: number): [Seg[], Seg[]] => [[arcDeg(c, r, 196, 236)], [arcDeg(c, r, 248, 256)]];\n\nfunction search(phase: Phase): Frame {\n  const card = body(rrect(58, 36, 172, 132, 18), .6);\n  const tucked = [tile(144, 102, 96, 58, 14, \"tuck\", { z: .3 }), tile(144, 102, 120, 76, 16, \"tuck\", { z: .3 })];\n  if (phase !== \"done\") {\n    const lens: Pt = [196, 118];\n    return {\n      label: \"A magnifying glass over three empty result rows\",\n      prims: [\n        ...tucked, card,\n        box(78, 64, 132, 20, 8, \"slot\", { z: .6 }), box(78, 92, 132, 20, 8, \"slot\", { z: .6 }), box(78, 120, 132, 20, 8, \"slot\", { z: .6 }),\n        disc(lens, 30, \"outline\", { z: 1.6 }),\n        line([seg(polar(lens, 30, 45), [244, 166])], \"ink\", { z: 1.6 }),\n        rest([244, 166], 1.6),\n        mark(glare(lens, 20), \"muted\", { z: 1.6 }),\n      ],\n    };\n  }\n  // Filters cleared: the magnifier docks into the header beside the query and the rows fill in as results.\n  const lens: Pt = [204, 61];\n  return {\n    label: \"A results list with a search field and two results\",\n    prims: [\n      ...tucked, card,\n      box(78, 56, 64, 10, 5, \"query\", { z: .6 }), box(78, 100, 128, 10, 5, \"bar\", { z: .6 }), box(78, 124, 96, 10, 5, \"bar\", { z: .6 }),\n      disc(lens, 9, \"outline\", { z: 1 }),\n      line([seg(polar(lens, 9, 45), polar(lens, 17, 45))], \"ink\", { z: 1 }),\n      line([seg([58, 84], [230, 84])], \"subtle\", { z: .6 }),\n      mark(glare(lens, 5), \"muted\", { z: 1, o: 0, draw: 0 }),\n    ],\n  };\n}\n\nfunction offline(phase: Phase): Frame {\n  const hub: Pt = [160, 92];\n  const [top, bottom] = phase === \"done\" ? [146, 146] : phase === \"loading\" ? [141, 151] : [134, 158];\n  const wire = phase === \"loading\" ? \"accent\" : \"ink\";\n  return {\n    label: phase === \"done\" ? \"A cloud joined to a device by an unbroken line, with a check on the device\" : phase === \"loading\" ? \"The broken line reaching back toward the cloud\" : \"A cloud joined to a device by a broken line\",\n    prims: [\n      tile(160, 92, 80, 30, 15, \"tuck\", { z: .3 }), tile(160, 92, 104, 36, 18, \"tuck\", { z: .3 }),\n      body(cloud([{ c: [100, 96], r: 22 }, { c: [140, 72], r: 34 }, { c: [188, 76], r: 28 }, { c: [220, 98], r: 20 }], 118), 1.3),\n      park(hub, 1.3), park(hub, 1.3), park(hub, 1.3),\n      box(134, 168, 52, 34, 9, phase === \"done\" ? \"success\" : phase === \"loading\" ? \"accent\" : \"outline\", { z: .7 }),\n      line([seg([160, 118], [160, top])], wire, { z: 1.3, z1: 1 }),\n      line([seg([160, bottom], [160, 168])], wire, { z: 1, z1: .7 }),\n      phase === \"done\" ? mark(check([160, 185], 18), \"success\", { z: .7 }) : mark(slashes([160, 146]), \"warning\", { z: 1, draw: phase === \"loading\" ? 0 : 1 }),\n    ],\n  };\n}\n\nfunction inbox(phase: Phase): Frame {\n  const lift = phase === \"loading\" ? 1 : 0;\n  const badge: Pt = [226, 84], slot: Pt = [160, 140];\n  return {\n    label: phase === \"loading\" ? \"A stacked inbox while new mail is checked\" : \"A stacked inbox with a check mark\",\n    prims: [\n      box(112, 72 - 8 * lift, 96, 40, 12, \"back\", { z: .25 }), box(100, 88 - 4 * lift, 120, 40, 12, \"back\", { z: .45 }),\n      body(rrect(88, 104, 144, 72, [8, 8, 16, 16]), .7),\n      park(slot, .7), park(slot, .7), park(slot, .7),\n      disc(badge, 17, phase === \"loading\" ? \"muted\" : \"success\", { z: 1.5 }),\n      line(chain([[88, 126], [124, 126], [133, 140], [187, 140], [196, 126], [232, 126]]), \"ink\", { z: .7 }),\n      rest(slot, .7),\n      mark(check(badge, 16), \"success\", { z: 1.5, draw: phase === \"loading\" ? 0 : 1 }),\n    ],\n  };\n}\n\nfunction map(phase: Phase): Frame {\n  const start: Pt = [90, 142], pin: Pt = [206, 110], found = phase === \"done\";\n  const route = found\n    ? curve([start, [114, 152], [140, 140], [160, 122], [182, 128], polar(pin, 10, 135)])\n    : curve([start, [108, 124], [132, 130], [152, 108], [178, 100], [200, 84]]);\n  return {\n    label: found ? \"A folded map with a dashed route that ends at a checked destination\" : phase === \"loading\" ? \"A folded map while the route is searched again\" : \"A folded map with a dashed route that ends in an x\",\n    prims: [\n      tile(151, 107, 90, 56, 12, \"tuck\", { z: .3 }), tile(151, 107, 110, 70, 14, \"tuck\", { z: .3 }),\n      body(chain([[70, 62], [124, 48], [178, 62], [232, 48], [232, 152], [178, 166], [124, 152], [70, 166]], true), .8),\n      park(start, .8),\n      tile(151, 107, 54, 104, 0, \"shade\", { skew: Math.atan2(14, 54) / RAD, z: .8 }),\n      found ? disc(pin, 10, \"success\", { z: .8 }) : park(start, .8),\n      disc(start, 4, \"dot\", { z: .8 }),\n      line([route], \"accent\", { dash: 5, z: .8, draw: phase === \"loading\" ? 0 : 1, redraw: true }),\n      rest(start, .8),\n      found ? mark(check(pin, 10), \"success\", { z: .8 }) : mark(cross([208, 76], 5), \"ink\", { z: .8, draw: phase === \"loading\" ? 0 : 1 }),\n    ],\n  };\n}\n\n/** Moves every point of a frame; used to center each scene in the view box. */\nfunction move(frame: Frame, dx: number, dy: number): Frame {\n  return {\n    ...frame,\n    prims: frame.prims.map(p => {\n      const geo = [...p.geo];\n      if (p.kind === \"tile\") { geo[0]! += dx; geo[1]! += dy; }\n      else for (let i = 0; i < geo.length - (p.kind === \"body\" ? 1 : 3); i += 2) { geo[i]! += dx; geo[i + 1]! += dy; }\n      return { ...p, geo };\n    }),\n  };\n}\n\nfunction center(frame: Frame) {\n  let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;\n  const add = (x: number, y: number) => { x0 = Math.min(x0, x); y0 = Math.min(y0, y); x1 = Math.max(x1, x); y1 = Math.max(y1, y); };\n  for (const p of frame.prims) {\n    if (p.fx[0] < .01) continue;\n    if (p.kind === \"tile\") { const [cx, cy, w, h] = p.geo as [number, number, number, number]; add(cx - w / 2, cy - h / 2); add(cx + w / 2, cy + h / 2); continue; }\n    if (p.kind !== \"body\" && p.fx[1] < .01) continue;\n    for (let i = 0; i < p.geo.length - (p.kind === \"body\" ? 1 : 3); i += 2) add(p.geo[i]!, p.geo[i + 1]!);\n  }\n  return [VIEW.width / 2 - (x0 + x1) / 2, VIEW.height / 2 - (y0 + y1) / 2] as const;\n}\n\nexport const VIEW = { width: 320, height: 216 };\n\nconst builders: Record<SceneId, (phase: Phase) => Frame> = { search, offline, inbox, map };\nconst phases: Phase[] = [\"idle\", \"loading\", \"done\"];\n\n/** Every frame is computed once at load, so the server and the first client render draw the same thing. */\nexport const FRAMES = Object.fromEntries((Object.keys(builders) as SceneId[]).map(id => {\n  const [dx, dy] = center(builders[id](\"idle\"));\n  return [id, Object.fromEntries(phases.map(phase => [phase, move(builders[id](phase), dx, dy)]))];\n})) as Record<SceneId, Record<Phase, Frame>>;\n\nconst fmt = (v: number) => String(Math.round(v * 100) / 100);\n\nfunction tilePath(g: ArrayLike<number>, ox: number, oy: number) {\n  const w = Math.max(0, g[2]!), h = Math.max(0, g[3]!);\n  if (w < .05 || h < .05) return \"\";\n  const r = Math.min(Math.max(0, g[4]!), w / 2, h / 2), tan = Math.tan(g[6]! * RAD), cos = Math.cos(g[5]! * RAD), sin = Math.sin(g[5]! * RAD);\n  const px = g[0]! + ox * g[7]!, py = g[1]! + oy * g[7]!, hw = w / 2, hh = h / 2;\n  const corners: [number, number, number][] = [[hw - r, -hh + r, -90], [hw - r, hh - r, 0], [-hw + r, hh - r, 90], [-hw + r, -hh + r, 180]];\n  let d = \"\";\n  for (const [cx, cy, start] of corners) {\n    for (let s = 0; s <= 6; s++) {\n      const a = (start + s * 15) * RAD, x = cx + r * Math.cos(a), y = cy + r * Math.sin(a) + (cx + r * Math.cos(a)) * tan;\n      d += `${d ? \"L\" : \"M\"}${fmt(x * cos - y * sin + px)} ${fmt(x * sin + y * cos + py)}`;\n    }\n  }\n  return `${d}Z`;\n}\n\nfunction span(g: ArrayLike<number>, from: number, count: number) {\n  let len = 0;\n  for (let i = from + 1; i < from + count; i++) len += Math.hypot(g[2 * i]! - g[2 * i - 2]!, g[2 * i + 1]! - g[2 * i - 1]!);\n  return len;\n}\n\n/** Draws the first `budget` units of a polyline. Each point drifts by its own depth, so a line can stretch between two layers. */\nfunction trace(g: ArrayLike<number>, from: number, count: number, budget: number, ox: number, oy: number, z0: number, z1: number, total: number) {\n  if (budget <= .05) return \"\";\n  const at = (i: number): Pt => {\n    const z = z0 + (z1 - z0) * (total > 1 ? (from + i) / (total - 1) : 0);\n    return [g[2 * (from + i)]! + ox * z, g[2 * (from + i) + 1]! + oy * z];\n  };\n  let [px, py] = at(0), left = budget, d = `M${fmt(px)} ${fmt(py)}`;\n  for (let i = 1; i < count; i++) {\n    const [x, y] = at(i), len = Math.hypot(x - px, y - py);\n    if (len >= left) { const u = len ? left / len : 0; return `${d}L${fmt(px + (x - px) * u)} ${fmt(py + (y - py) * u)}`; }\n    left -= len; d += `L${fmt(x)} ${fmt(y)}`; px = x; py = y;\n  }\n  return d;\n}\n\n/** Turns a primitive's current vector into path data, plus a dash pattern for strokes. */\nexport function shapePath(kind: Kind, g: ArrayLike<number>, drawn: number, ox: number, oy: number): { d: string; dash: string } {\n  if (kind === \"tile\") return { d: tilePath(g, ox, oy), dash: \"none\" };\n  if (kind === \"body\") {\n    const z = g[2 * N]!, dx = ox * z, dy = oy * z;\n    let d = \"\";\n    for (let i = 0; i < N; i++) d += `${i ? \"L\" : \"M\"}${fmt(g[2 * i]! + dx)} ${fmt(g[2 * i + 1]! + dy)}`;\n    return { d: `${d}Z`, dash: \"none\" };\n  }\n  const draw = Math.min(1, Math.max(0, drawn)), count = (g.length - 3) / 2, gap = g[g.length - 3]!, z0 = g[g.length - 2]!, z1 = g[g.length - 1]!;\n  const dash = gap > .2 ? `3 ${fmt(gap)}` : \"none\";\n  if (kind === \"stroke\") return { d: trace(g, 0, count, draw * span(g, 0, count), ox, oy, z0, z1, count), dash };\n  const first = span(g, 0, M), budget = draw * (first + span(g, M, M));\n  return { d: trace(g, 0, M, Math.min(budget, first), ox, oy, z0, z1, 1) + trace(g, M, M, budget - first, ox, oy, z0, z1, 1), dash };\n}\n"}],"docs":"Use this for no results, offline, inbox zero and missing page moments. Wire each action to your real filter reset, retry, refresh or search; the preview simulates them locally.","meta":{"tier":"free","kind":"block","docs":"https://uiarc.dev/components/blocks/empty-states"}}