{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"kanban-board","type":"registry:block","title":"Kanban Board","description":"Task board whose cards drag within and across columns, opening a dashed drop slot where they will land, lighting up the column underneath and flying into place via shared layout. Space, arrows and Escape move cards from the keyboard with live announcements. Columns show count badges, cards carry tags, assignee initials and a priority dot, and on mobile the columns scroll horizontally with snap. Controlled/uncontrolled, reduced-motion safe.","author":"kara <ztzyrant@gmail.com>","dependencies":["clsx","motion","tailwind-merge"],"registryDependencies":[],"files":[{"path":"components/motion/kanban-board.tsx","type":"registry:component","target":"@components/motion/kanban-board.tsx","content":"\"use client\";\n// karaui.kamisama-v0.my.id/components/blocks/kanban-board\n\nimport {\n  type DragControls,\n  LayoutGroup,\n  motion,\n  type PanInfo,\n  useDragControls,\n  useReducedMotion,\n} from \"motion/react\";\nimport {\n  type KeyboardEvent,\n  type PointerEvent as ReactPointerEvent,\n  useCallback,\n  useEffect,\n  useId,\n  useRef,\n  useState,\n} from \"react\";\nimport { SPRING_LAYOUT } from \"@/lib/ease\";\nimport { TOUCH_GESTURE_CONTENT_CLASS } from \"@/lib/touch\";\nimport { cn } from \"@/lib/utils\";\n\nexport type KanbanPriority = \"low\" | \"medium\" | \"high\" | \"urgent\";\n\nexport type KanbanCard = {\n  id: string;\n  title: string;\n  tags?: string[];\n  /** Assignee name; initials are derived unless `initials` is given. */\n  assignee?: { name: string; initials?: string };\n  priority?: KanbanPriority;\n};\n\nexport type KanbanColumn = {\n  id: string;\n  title: string;\n  cards: KanbanCard[];\n};\n\nexport type KanbanMove = {\n  cardId: string;\n  from: { columnId: string; index: number };\n  to: { columnId: string; index: number };\n};\n\nexport interface KanbanBoardProps {\n  /** Controlled columns. */\n  columns?: KanbanColumn[];\n  /** Initial columns when uncontrolled. */\n  defaultColumns?: KanbanColumn[];\n  /** Fires once per completed move with the next columns and what moved. */\n  onChange?: (columns: KanbanColumn[], move: KanbanMove) => void;\n  className?: string;\n  columnClassName?: string;\n  cardClassName?: string;\n}\n\ntype Location = { columnId: string; index: number };\n\ntype PointerDrag = {\n  cardId: string;\n  from: Location;\n  height: number;\n};\n\ntype KeyboardGrab = {\n  cardId: string;\n  original: KanbanColumn[];\n};\n\nconst INSTANT = { duration: 0 } as const;\nconst FADE = { duration: 0.15 } as const;\n// Touch needs a short press before a card lifts, so a swipe across the board\n// still scrolls the columns instead of grabbing whatever card is underneath.\nconst TOUCH_LIFT_DELAY = 220;\nconst TOUCH_SLOP = 8;\n\nconst PRIORITY: Record<KanbanPriority, { label: string; dot: string }> = {\n  low: { label: \"Low priority\", dot: \"bg-sky-500\" },\n  medium: { label: \"Medium priority\", dot: \"bg-amber-500\" },\n  high: { label: \"High priority\", dot: \"bg-orange-500\" },\n  urgent: { label: \"Urgent\", dot: \"bg-red-500\" },\n};\n\nfunction initialsOf(name: string) {\n  return name\n    .split(/\\s+/)\n    .filter(Boolean)\n    .slice(0, 2)\n    .map((part) => part[0]?.toUpperCase() ?? \"\")\n    .join(\"\");\n}\n\nfunction locate(columns: KanbanColumn[], cardId: string): Location | null {\n  for (const column of columns) {\n    const index = column.cards.findIndex((card) => card.id === cardId);\n    if (index !== -1) return { columnId: column.id, index };\n  }\n  return null;\n}\n\n/** Move a card to `to`, where `to.index` counts the target's other cards. */\nfunction moveCard(\n  columns: KanbanColumn[],\n  cardId: string,\n  to: Location,\n): KanbanColumn[] {\n  let moving: KanbanCard | undefined;\n  const without = columns.map((column) => {\n    const card = column.cards.find((entry) => entry.id === cardId);\n    if (!card) return column;\n    moving = card;\n    return {\n      ...column,\n      cards: column.cards.filter((entry) => entry.id !== cardId),\n    };\n  });\n  if (!moving) return columns;\n  const card = moving;\n  return without.map((column) => {\n    if (column.id !== to.columnId) return column;\n    const cards = column.cards.slice();\n    cards.splice(Math.max(0, Math.min(cards.length, to.index)), 0, card);\n    return { ...column, cards };\n  });\n}\n\nfunction KanbanCardView({\n  card,\n  layoutId,\n  reduce,\n  dragging,\n  grabbed,\n  describedBy,\n  className,\n  registerCard,\n  onLift,\n  onDragMove,\n  onDrop,\n  onKeyDown,\n  onBlur,\n}: {\n  card: KanbanCard;\n  layoutId: string;\n  reduce: boolean;\n  dragging: boolean;\n  grabbed: boolean;\n  describedBy: string;\n  className?: string;\n  registerCard: (id: string, el: HTMLElement | null) => void;\n  onLift: (card: KanbanCard, el: HTMLElement | null) => void;\n  onDragMove: (point: { x: number; y: number }) => void;\n  onDrop: (card: KanbanCard) => void;\n  onKeyDown: (event: KeyboardEvent<HTMLButtonElement>, card: KanbanCard) => void;\n  onBlur: (relatedTarget: EventTarget | null) => void;\n}) {\n  const controls = useDragControls();\n  const itemRef = useRef<HTMLLIElement>(null);\n  const lifted = dragging || grabbed;\n  const startTouchLift = useTouchLift(controls);\n  const priority = card.priority ? PRIORITY[card.priority] : null;\n\n  return (\n    <motion.li\n      ref={(el) => {\n        itemRef.current = el;\n        registerCard(card.id, el);\n      }}\n      layout\n      layoutId={layoutId}\n      drag\n      dragControls={controls}\n      dragListener={false}\n      dragSnapToOrigin\n      dragMomentum={false}\n      onDragStart={() => onLift(card, itemRef.current)}\n      onDrag={(_event, info: PanInfo) =>\n        // `info.point` is page space; hit-testing reads viewport rects.\n        onDragMove({\n          x: info.point.x - window.scrollX,\n          y: info.point.y - window.scrollY,\n        })\n      }\n      onDragEnd={() => onDrop(card)}\n      animate={{ scale: lifted && !reduce ? 1.03 : 1 }}\n      transition={reduce ? INSTANT : SPRING_LAYOUT}\n      className={cn(\"relative list-none\", lifted ? \"z-30\" : \"z-0\")}\n    >\n      <motion.span\n        aria-hidden=\"true\"\n        initial={false}\n        animate={{ opacity: lifted ? 1 : 0 }}\n        transition={reduce ? INSTANT : FADE}\n        className=\"pointer-events-none absolute inset-0 rounded-xl shadow-[0_16px_36px_-14px_rgb(0_0_0/0.4)]\"\n      />\n      <button\n        type=\"button\"\n        aria-roledescription=\"draggable card\"\n        aria-describedby={describedBy}\n        aria-pressed={grabbed}\n        onPointerDown={(event) => {\n          if (event.button !== 0) return;\n          startTouchLift(event);\n        }}\n        onKeyDown={(event) => onKeyDown(event, card)}\n        onBlur={(event) => onBlur(event.relatedTarget)}\n        className={cn(\n          \"relative flex w-full cursor-grab flex-col gap-2.5 rounded-xl border border-border bg-card p-3 text-left outline-none transition-colors active:cursor-grabbing\",\n          \"hover:border-foreground/20 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n          grabbed && \"border-foreground/30\",\n          TOUCH_GESTURE_CONTENT_CLASS,\n          dragging && \"select-none\",\n          className,\n        )}\n      >\n        <span className=\"flex items-start gap-2\">\n          {priority ? (\n            <span\n              className={cn(\"mt-1.5 h-2 w-2 shrink-0 rounded-full\", priority.dot)}\n            >\n              <span className=\"sr-only\">{priority.label}</span>\n            </span>\n          ) : null}\n          <span className=\"text-sm font-medium leading-snug text-foreground\">\n            {card.title}\n          </span>\n        </span>\n        {card.tags?.length || card.assignee ? (\n          <span className=\"flex items-end justify-between gap-2\">\n            <span className=\"flex flex-wrap gap-1\">\n              {card.tags?.map((tag) => (\n                <span\n                  key={tag}\n                  className=\"rounded-md bg-muted px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground\"\n                >\n                  {tag}\n                </span>\n              ))}\n            </span>\n            {card.assignee ? (\n              <span\n                title={card.assignee.name}\n                className=\"grid h-6 w-6 shrink-0 place-items-center rounded-full bg-foreground text-[10px] font-semibold text-background\"\n              >\n                <span aria-hidden=\"true\">\n                  {card.assignee.initials ?? initialsOf(card.assignee.name)}\n                </span>\n                <span className=\"sr-only\">Assigned to {card.assignee.name}</span>\n              </span>\n            ) : null}\n          </span>\n        ) : null}\n      </button>\n    </motion.li>\n  );\n}\n\n/**\n * Mouse and pen lift immediately (motion still waits for a few pixels of\n * travel before it calls it a drag). Touch lifts after a short still press;\n * moving first hands the gesture back to the scroller.\n */\nfunction useTouchLift(controls: DragControls) {\n  const timer = useRef<number | null>(null);\n  const cleanup = useRef<(() => void) | null>(null);\n\n  useEffect(() => () => cleanup.current?.(), []);\n\n  return useCallback(\n    (event: ReactPointerEvent<HTMLElement>) => {\n      if (event.pointerType !== \"touch\") {\n        controls.start(event);\n        return;\n      }\n      cleanup.current?.();\n      const native = event.nativeEvent;\n      const startX = native.clientX;\n      const startY = native.clientY;\n      let lifted = false;\n\n      // Once lifted, the page must not scroll under the finger.\n      const blockScroll = (touch: TouchEvent) => {\n        if (lifted) touch.preventDefault();\n      };\n      const onMove = (move: PointerEvent) => {\n        if (lifted) return;\n        if (\n          Math.abs(move.clientX - startX) > TOUCH_SLOP ||\n          Math.abs(move.clientY - startY) > TOUCH_SLOP\n        ) {\n          cleanup.current?.();\n        }\n      };\n      const stop = () => {\n        if (timer.current !== null) window.clearTimeout(timer.current);\n        timer.current = null;\n        window.removeEventListener(\"pointermove\", onMove);\n        window.removeEventListener(\"pointerup\", stop);\n        window.removeEventListener(\"pointercancel\", stop);\n        window.removeEventListener(\"touchmove\", blockScroll);\n        cleanup.current = null;\n      };\n\n      window.addEventListener(\"pointermove\", onMove);\n      window.addEventListener(\"pointerup\", stop);\n      window.addEventListener(\"pointercancel\", stop);\n      window.addEventListener(\"touchmove\", blockScroll, { passive: false });\n      cleanup.current = stop;\n      timer.current = window.setTimeout(() => {\n        timer.current = null;\n        lifted = true;\n        controls.start(native);\n      }, TOUCH_LIFT_DELAY);\n    },\n    [controls],\n  );\n}\n\nexport function KanbanBoard({\n  columns,\n  defaultColumns,\n  onChange,\n  className,\n  columnClassName,\n  cardClassName,\n}: KanbanBoardProps) {\n  const reduce = useReducedMotion() ?? false;\n  const boardId = useId();\n  const instructionsId = useId();\n  const [internal, setInternal] = useState<KanbanColumn[]>(\n    defaultColumns ?? [],\n  );\n  const isControlled = columns !== undefined;\n  const committed = isControlled ? columns : internal;\n\n  const [draft, setDraft] = useState<KanbanColumn[] | null>(null);\n  const [pointer, setPointer] = useState<PointerDrag | null>(null);\n  const [over, setOver] = useState<Location | null>(null);\n  const [grab, setGrab] = useState<KeyboardGrab | null>(null);\n  const [announcement, setAnnouncement] = useState(\"\");\n  const overRef = useRef<Location | null>(null);\n  const cardEls = useRef(new Map<string, HTMLElement>());\n  const columnEls = useRef(new Map<string, HTMLElement>());\n  const view = draft ?? committed;\n\n  const registerCard = useCallback((id: string, el: HTMLElement | null) => {\n    if (el) cardEls.current.set(id, el);\n    else cardEls.current.delete(id);\n  }, []);\n\n  const titleOf = (cardId: string, list = view) => {\n    for (const column of list) {\n      const card = column.cards.find((entry) => entry.id === cardId);\n      if (card) return card.title;\n    }\n    return \"Card\";\n  };\n\n  const describe = (list: KanbanColumn[], cardId: string) => {\n    const at = locate(list, cardId);\n    const column = list.find((entry) => entry.id === at?.columnId);\n    if (!at || !column) return \"\";\n    return `${column.title}, position ${at.index + 1} of ${column.cards.length}`;\n  };\n\n  const commit = (next: KanbanColumn[], move: KanbanMove) => {\n    if (\n      move.from.columnId === move.to.columnId &&\n      move.from.index === move.to.index\n    ) {\n      return;\n    }\n    if (!isControlled) setInternal(next);\n    onChange?.(next, move);\n  };\n\n  // Keep focus on the grabbed card as it changes place; crossing a column\n  // remounts it, and the shared layoutId flies it to its new slot.\n  const grabbedId = grab?.cardId;\n  const grabbedAt = grabbedId ? locate(view, grabbedId) : null;\n  const grabbedSlot = grabbedAt ? `${grabbedAt.columnId}:${grabbedAt.index}` : \"\";\n  useEffect(() => {\n    if (!grabbedId || !grabbedSlot) return;\n    const el = cardEls.current.get(grabbedId)?.querySelector(\"button\");\n    if (el && document.activeElement !== el) el.focus();\n  }, [grabbedId, grabbedSlot]);\n\n  /* ----------------------------- pointer drag ----------------------------- */\n\n  const onLift = (card: KanbanCard, el: HTMLElement | null) => {\n    const from = locate(committed, card.id);\n    if (!from) return;\n    setPointer({\n      cardId: card.id,\n      from,\n      height: el?.getBoundingClientRect().height ?? 72,\n    });\n  };\n\n  const onDragMove = (point: { x: number; y: number }) => {\n    if (!pointer) return;\n    let target: KanbanColumn | undefined;\n    let nearest = Number.POSITIVE_INFINITY;\n    for (const column of view) {\n      const rect = columnEls.current.get(column.id)?.getBoundingClientRect();\n      if (!rect) continue;\n      const distance =\n        point.x < rect.left\n          ? rect.left - point.x\n          : point.x > rect.right\n            ? point.x - rect.right\n            : 0;\n      if (distance < nearest) {\n        nearest = distance;\n        target = column;\n      }\n    }\n    // Only a column the pointer is actually over (or right beside) accepts.\n    if (!target || nearest > 24) {\n      if (overRef.current) {\n        overRef.current = null;\n        setOver(null);\n      }\n      return;\n    }\n    let index = 0;\n    for (const card of target.cards) {\n      if (card.id === pointer.cardId) continue;\n      const rect = cardEls.current.get(card.id)?.getBoundingClientRect();\n      if (rect && point.y > rect.top + rect.height / 2) index += 1;\n    }\n    const prev = overRef.current;\n    if (prev?.columnId === target.id && prev.index === index) return;\n    const next = { columnId: target.id, index };\n    overRef.current = next;\n    setOver(next);\n  };\n\n  const onPointerDrop = (card: KanbanCard) => {\n    const to = overRef.current;\n    const from = pointer?.from;\n    overRef.current = null;\n    setOver(null);\n    setPointer(null);\n    if (!to || !from) return;\n    const next = moveCard(committed, card.id, to);\n    commit(next, { cardId: card.id, from, to });\n    setAnnouncement(`${card.title} dropped in ${describe(next, card.id)}.`);\n  };\n\n  /* ---------------------------- keyboard moves ---------------------------- */\n\n  const drop = (cardId: string) => {\n    if (!grab) return;\n    const from = locate(grab.original, cardId);\n    const to = locate(view, cardId);\n    setGrab(null);\n    setDraft(null);\n    if (!from || !to) return;\n    setAnnouncement(`${titleOf(cardId)} dropped in ${describe(view, cardId)}.`);\n    commit(view, { cardId, from, to });\n  };\n\n  const onCardKeyDown = (\n    event: KeyboardEvent<HTMLButtonElement>,\n    card: KanbanCard,\n  ) => {\n    const isToggle = event.key === \" \" || event.key === \"Enter\";\n\n    if (!grab) {\n      if (!isToggle) return;\n      event.preventDefault();\n      setGrab({ cardId: card.id, original: committed });\n      setDraft(committed);\n      setAnnouncement(\n        `Picked up ${card.title} in ${describe(committed, card.id)}. Use the arrow keys to move, Space to drop, Escape to cancel.`,\n      );\n      return;\n    }\n\n    if (grab.cardId !== card.id) return;\n\n    if (isToggle) {\n      event.preventDefault();\n      drop(card.id);\n      return;\n    }\n\n    if (event.key === \"Escape\") {\n      event.preventDefault();\n      setGrab(null);\n      setDraft(null);\n      setAnnouncement(\n        `Move cancelled. ${card.title} returned to ${describe(grab.original, card.id)}.`,\n      );\n      return;\n    }\n\n    const at = locate(view, card.id);\n    if (!at) return;\n    const columnIndex = view.findIndex((column) => column.id === at.columnId);\n    let to: Location | null = null;\n\n    if (event.key === \"ArrowUp\" || event.key === \"ArrowDown\") {\n      const length = view[columnIndex].cards.length;\n      const index = at.index + (event.key === \"ArrowUp\" ? -1 : 1);\n      if (index >= 0 && index < length) to = { columnId: at.columnId, index };\n    } else if (event.key === \"ArrowLeft\" || event.key === \"ArrowRight\") {\n      const target = view[columnIndex + (event.key === \"ArrowLeft\" ? -1 : 1)];\n      if (target) {\n        to = {\n          columnId: target.id,\n          index: Math.min(at.index, target.cards.length),\n        };\n      }\n    } else {\n      return;\n    }\n\n    event.preventDefault();\n    if (!to) return;\n    const next = moveCard(view, card.id, to);\n    setDraft(next);\n    setAnnouncement(`${card.title} moved to ${describe(next, card.id)}.`);\n  };\n\n  const onCardBlur = (relatedTarget: EventTarget | null) => {\n    // Tabbing or clicking away drops the card in place. A null target is the\n    // card being remounted into another column mid-move.\n    if (grab && relatedTarget) drop(grab.cardId);\n  };\n\n  return (\n    <div className={cn(\"w-full\", className)}>\n      <p id={instructionsId} className=\"sr-only\">\n        Press Space to pick up a card. Use the left and right arrow keys to\n        change column, the up and down arrow keys to change position, Space to\n        drop and Escape to cancel.\n      </p>\n      <LayoutGroup id={boardId}>\n        <div className=\"flex snap-x snap-mandatory gap-3 overflow-x-auto pb-4 [scrollbar-color:var(--border-strong)_transparent] [scrollbar-width:thin] sm:snap-none\">\n          {view.map((column) => {\n            const isOver = pointer !== null && over?.columnId === column.id;\n            const sameSlot =\n              pointer !== null &&\n              over !== null &&\n              pointer.from.columnId === over.columnId &&\n              pointer.from.index === over.index;\n            const showPlaceholder = isOver && !sameSlot;\n            let counted = 0;\n\n            const placeholder = (\n              <motion.li\n                key=\"kanban-placeholder\"\n                layout\n                aria-hidden=\"true\"\n                initial={{ opacity: 0 }}\n                animate={{ opacity: 1 }}\n                transition={reduce ? INSTANT : FADE}\n                style={{ height: pointer?.height }}\n                className=\"list-none rounded-xl border-2 border-dashed border-foreground/20 bg-foreground/[0.03]\"\n              />\n            );\n\n            return (\n              <section\n                key={column.id}\n                aria-label={`${column.title}, ${column.cards.length} ${column.cards.length === 1 ? \"card\" : \"cards\"}`}\n                className={cn(\n                  \"relative flex w-[78%] max-w-72 shrink-0 snap-start flex-col rounded-2xl bg-muted/60 p-2 sm:w-auto sm:min-w-56 sm:max-w-none sm:flex-1\",\n                  columnClassName,\n                )}\n              >\n                {/* Highlight is its own layer so only opacity animates. */}\n                <motion.span\n                  aria-hidden=\"true\"\n                  initial={false}\n                  animate={{ opacity: isOver ? 1 : 0 }}\n                  transition={reduce ? INSTANT : FADE}\n                  className=\"pointer-events-none absolute inset-0 rounded-2xl bg-foreground/[0.04] ring-2 ring-foreground/15 ring-inset\"\n                />\n                <header className=\"relative flex items-center justify-between px-1.5 pt-1 pb-2.5\">\n                  <h3 className=\"text-sm font-semibold text-foreground\">\n                    {column.title}\n                  </h3>\n                  <span\n                    aria-hidden=\"true\"\n                    className=\"min-w-6 rounded-full bg-background px-2 py-0.5 text-center text-xs font-medium tabular-nums text-muted-foreground\"\n                  >\n                    {column.cards.length}\n                  </span>\n                </header>\n                <ul\n                  ref={(el) => {\n                    if (el) columnEls.current.set(column.id, el);\n                    else columnEls.current.delete(column.id);\n                  }}\n                  className=\"relative flex min-h-24 flex-1 flex-col gap-2\"\n                >\n                  {column.cards.flatMap((card) => {\n                    const isDragged = pointer?.cardId === card.id;\n                    const before =\n                      showPlaceholder && !isDragged && counted === over?.index;\n                    if (!isDragged) counted += 1;\n                    const node = (\n                      <KanbanCardView\n                        key={card.id}\n                        card={card}\n                        layoutId={`card-${card.id}`}\n                        reduce={reduce}\n                        dragging={isDragged}\n                        grabbed={grab?.cardId === card.id}\n                        describedBy={instructionsId}\n                        className={cardClassName}\n                        registerCard={registerCard}\n                        onLift={onLift}\n                        onDragMove={onDragMove}\n                        onDrop={onPointerDrop}\n                        onKeyDown={onCardKeyDown}\n                        onBlur={onCardBlur}\n                      />\n                    );\n                    return before ? [placeholder, node] : [node];\n                  })}\n                  {showPlaceholder && counted === over?.index\n                    ? placeholder\n                    : null}\n                </ul>\n              </section>\n            );\n          })}\n        </div>\n      </LayoutGroup>\n      <div aria-live=\"polite\" aria-atomic=\"true\" className=\"sr-only\">\n        {announcement}\n      </div>\n    </div>\n  );\n}\n"},{"path":"lib/ease.ts","type":"registry:lib","target":"@lib/ease.ts","content":"// Shared motion tokens. Easing curves mirror the CSS custom properties in\n// globals.css; springs are the canonical physics used across components.\n// Strong custom variants — defaults like `ease-in`/`ease-out` feel weak.\n\nexport const EASE_OUT = [0.16, 1, 0.3, 1] as const;\nexport const EASE_IN_OUT = [0.77, 0, 0.175, 1] as const;\nexport const EASE_DRAWER = [0.32, 0.72, 0, 1] as const;\n\n/** CSS string form of EASE_OUT for inline style transitions. */\nexport const EASE_OUT_CSS = \"cubic-bezier(0.16, 1, 0.3, 1)\";\n\n/** Press feedback on buttons and other tappable surfaces. */\nexport const SPRING_PRESS = {\n  type: \"spring\",\n  stiffness: 500,\n  damping: 30,\n  mass: 0.6,\n} as const;\n\n/** Content swaps — label/icon slots trading places inside a control. */\nexport const SPRING_SWAP = {\n  type: \"spring\",\n  stiffness: 460,\n  damping: 30,\n  mass: 0.55,\n} as const;\n\n/** Overlay panel entrances — modals and sheets summoned by pointer. */\nexport const SPRING_PANEL = {\n  type: \"spring\",\n  stiffness: 420,\n  damping: 40,\n  mass: 0.5,\n} as const;\n\n/** Shared-layout glides — pills, indicators and panels morphing between positions. */\nexport const SPRING_LAYOUT = {\n  type: \"spring\",\n  stiffness: 360,\n  damping: 32,\n  mass: 0.6,\n} as const;\n\n/** Cursor-follow physics for decorative mouse tracking (magnetic, tilt, dock). */\nexport const SPRING_MOUSE = {\n  stiffness: 200,\n  damping: 15,\n  mass: 0.3,\n} as const;\n\n/** Dragged handles and fills (sliders) — critically damped `useSpring` config,\n * so the value follows the pointer butterily and never rebounds off an end. */\nexport const SPRING_GLIDE = {\n  stiffness: 700,\n  damping: 50,\n  mass: 0.5,\n} as const;\n"},{"path":"lib/touch.ts","type":"registry:lib","target":"@lib/touch.ts","content":"// Shared touch primitives. iOS and iPadOS run their own gestures on top of the\n// page — the long-press selection callout and the selection it drags in with\n// it — and they win: once the platform claims a touch it cancels ours\n// mid-gesture, so a press-and-hold or a drag simply dies. Surfaces that own\n// their gesture have to opt out.\n//\n// What the two classes below cover, precisely:\n// - `-webkit-touch-callout: none` stops iOS's long-press callout. WebKit-only:\n//   it is not a property other engines have, so it is inert everywhere else.\n// - `user-select: none` stops the long-press selection on every engine,\n//   Android included, and stops a drag from painting a selection under the\n//   cursor. It is inherited, so it reaches every descendant — which is why the\n//   two classes differ only in whether they apply it unconditionally.\n// What neither covers:\n// - Chrome for Android's long-press menu on a link or an image. No CSS\n//   suppresses it; a gesture surface that wraps one needs its own\n//   `onContextMenu` with `preventDefault()`.\n// - The native drag of an `<img>` or `<a>` descendant. `-webkit-user-drag` is\n//   not inherited and plain divs and buttons are not drag sources, so setting\n//   it on the surface does nothing — the child itself needs `draggable={false}`.\n\n/**\n * Classes for a surface that *is* the control: a thumb, a drum, a stage, a\n * handle, a hold button. Selection is suppressed on every input, because a\n * drag that highlights the control's own label is wrong on a mouse too.\n * Compose with `touch-none` when the surface also owns the scroll axis — leave\n * it off when the page must still scroll from there.\n */\nexport const TOUCH_GESTURE_CLASS = \"select-none [-webkit-touch-callout:none]\";\n\n/**\n * The same opt-out for a gesture surface that wraps content the consumer owns:\n * a scroller, a context-menu trigger, a sheet header, a list row. Selection is\n * suppressed only where the platform runs its own press gestures — a coarse\n * pointer — so a mouse user can still select and copy that content. If the\n * gesture itself would paint a selection under the cursor, add `select-none`\n * for the duration of the gesture rather than reaching for\n * `TOUCH_GESTURE_CLASS`.\n *\n * `pointer: coarse` describes the *primary* pointer and nothing else, so a\n * hybrid machine reads it wrong in both directions: a tablet with a mouse\n * plugged in keeps touch as primary and loses mouse selection, and a laptop\n * with a touchscreen keeps the mouse as primary and leaves selection live\n * under a finger. No media query can answer per interaction — the query is\n * about the device, and the question is about the gesture in progress. The\n * default stays here because it is right on the machines that are one thing or\n * the other, and losing a selection is a nuisance; where the miss costs a\n * *gesture* instead, the surface pairs it with `holdSelection` on the press.\n */\nexport const TOUCH_GESTURE_CONTENT_CLASS =\n  \"[-webkit-touch-callout:none] pointer-coarse:select-none\";\n\n/**\n * Grow a small control's *hit area* to at least 44×44px (WCAG 2.5.5, Apple\n * HIG) on a coarse pointer, without changing what it looks like or the space\n * it takes in layout. An invisible `::after` box, centered on the control and\n * `max(100%, 2.75rem)` on each axis, catches the taps: a 32px icon button\n * reaches 6px past each edge, a wide 40px button only grows vertically, and a\n * control already 44px or larger is left as it is. Hit-testing a pseudo\n * element lands on its owner, so handlers, focus and `:active` all behave.\n *\n * Mouse and trackpad rendering is untouched — nothing here applies outside\n * `pointer: coarse`. Requirements on the element it goes on:\n * - It must be the containing block: add `relative` (and keep it mergeable, so\n *   a consumer's `absolute` still wins through `cn`).\n * - It must not clip itself (`overflow-hidden`), or the overhang is clipped\n *   away along with its hit area.\n * - It must render children: `<input>` and other void elements have no\n *   `::after`. Put it on the wrapper or label instead.\n * - It must not already use `::after` for something visible.\n *\n * Centered 44px means two 32px buttons with a 4px gap overlap by 8px; the\n * later one wins that strip, which still ends well short of the earlier\n * button's visual center. Below a ~32px pitch the later neighbour starts\n * eating into that center — use `TOUCH_TARGET_Y_CLASS` for such dense rows.\n *\n * The overhang is real geometry: inside a scroll container it counts as\n * scrollable overflow, so a control flush against a scroller's edge can add a\n * few pixels of scroll on touch screens. Give such a scroller a little padding\n * on that side.\n */\nexport const TOUCH_TARGET_CLASS =\n  \"pointer-coarse:after:absolute pointer-coarse:after:top-1/2 pointer-coarse:after:left-1/2 pointer-coarse:after:size-[max(100%,2.75rem)] pointer-coarse:after:-translate-x-1/2 pointer-coarse:after:-translate-y-1/2 pointer-coarse:after:content-['']\";\n\n/**\n * `TOUCH_TARGET_CLASS` on the vertical axis only, for controls packed tighter\n * than ~32px apart in a row (pagination dots, dense swatches), where growing\n * sideways would hand most of each control to its neighbour. Same rules.\n */\nexport const TOUCH_TARGET_Y_CLASS =\n  \"pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:top-1/2 pointer-coarse:after:h-[max(100%,2.75rem)] pointer-coarse:after:-translate-y-1/2 pointer-coarse:after:content-['']\";\n\n/**\n * Suppress selection on `element` for as long as a gesture is running on it,\n * whatever the primary pointer of the machine happens to be. Returns the\n * release. Inline, so it wins over the class above and is gone again the\n * moment the gesture ends.\n *\n * For the press gestures a native selection would otherwise steal — a\n * long-press that opens a menu. Elsewhere prefer the classes: a surface that\n * takes selection away for the whole session is a surface whose text nobody\n * can copy.\n */\nexport function holdSelection(element: HTMLElement) {\n  element.style.setProperty(\"user-select\", \"none\");\n  element.style.setProperty(\"-webkit-user-select\", \"none\");\n  return () => {\n    element.style.removeProperty(\"user-select\");\n    element.style.removeProperty(\"-webkit-user-select\");\n  };\n}\n\n/**\n * Pointer capture, best effort. WebKit throws `NotFoundError` when the pointer\n * is already gone by the time the handler runs — routine on iOS, where the\n * system can claim the touch first — and an uncaught throw takes the rest of\n * the handler, the gesture included, down with it. Touch pointers carry\n * implicit capture anyway, so losing it is never fatal.\n */\nexport function capturePointer(element: Element, pointerId: number) {\n  try {\n    element.setPointerCapture(pointerId);\n  } catch {\n    // Pointer is no longer active — implicit capture still applies on touch.\n  }\n}\n\n/** Release a capture taken with `capturePointer`, ignoring a stale pointer. */\nexport function releasePointer(element: Element, pointerId: number) {\n  try {\n    if (element.hasPointerCapture(pointerId)) {\n      element.releasePointerCapture(pointerId);\n    }\n  } catch {\n    // Capture was already dropped by the browser.\n  }\n}\n\n/**\n * Whether this event came from a pointer that is *hovering*: not a touch, and\n * not currently pressed. Which input the user is holding right now is not\n * something a device capability can answer — a touchscreen laptop hovers and\n * taps, and iPadOS reports a fine hovering pointer for a finger — so both\n * paths stay live and each handler branches on the event it was given.\n *\n * A pen resting on the glass is making contact, not hovering: `buttons` is the\n * tell, and it sends a pen tap down the same route a finger takes.\n *\n * This answers what an *enter* asks. A leave is the other half of a pair and\n * has to be read against the enter that started it — `useHoverGesture` in\n * `lib/hooks/use-hover-gesture` does that, and hover surfaces should use it\n * rather than asking this question twice.\n */\nexport const isHoveringPointer = (event: {\n  pointerType: string;\n  buttons: number;\n}) => event.pointerType !== \"touch\" && event.buttons === 0;\n"},{"path":"lib/utils.ts","type":"registry:lib","target":"@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"}]}