{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"toast","type":"registry:ui","title":"Toast","description":"Stacked notifications with progress and actions.","dependencies":["@base-ui/react","motion"],"registryDependencies":["@kobra/alert","@kobra/button","@kobra/spinner"],"docs":"Sound: the data-slot attributes on this component are read by the Sound layer, installed separately with `npx shadcn@latest add @kobra/sound`.\nKeep the data-slot and data-sound attributes as written — they are the wiring, not decoration.\nWrap your app once in <SoundEffects> from components/ui/sound.tsx and every Kobra component answers a press.","files":[{"path":"components/ui/toast.tsx","content":"import { useDirection } from '@base-ui/react/direction-provider'\nimport {\n  type ComponentProps,\n  type CSSProperties,\n  type ReactNode,\n  type RefObject,\n  useCallback,\n  useEffect,\n  useLayoutEffect,\n  useRef,\n  useState,\n  useSyncExternalStore,\n} from 'react'\nimport {\n  animate,\n  AnimatePresence,\n  cancelFrame,\n  frame,\n  motion,\n  MotionConfig,\n  useIsPresent,\n  useMotionValue,\n  usePresenceData,\n  useReducedMotion,\n} from 'motion/react'\n\nimport { ALERT_MARKS, type AlertTone } from '@/components/ui/alert'\nimport { Button } from '@/components/ui/button'\nimport { StatusBadge } from '@/components/ui/spinner'\nimport { joinsLetters } from '@/lib/joined-script'\nimport { dissolve } from '@/lib/smoky-dissolve'\nimport { cn } from '@/lib/utils'\n\nconst EVENT = 'kobra:toast'\nconst DISMISS = 'kobra:toast-dismiss'\nconst LIFETIME = 2400\n\nconst DETAIL_LIFETIME = 4000\n\nconst ACTION_LIFETIME = 6000\nconst GAP = 8\n\nconst PEEK = 10\nconst SHRINK = 0.03\nconst DEPTH = 3\nconst FADE = 0.15\nconst REACH = 10\nconst SWIPE = 44\nconst FLICK = 380\nconst MORPH = { type: 'spring', duration: 0.3, bounce: 0 } as const\nconst EXIT = { type: 'spring', duration: 0.2, bounce: 0 } as const\n\nexport const LINE_HEIGHT = 36\n\nconst CARD_WIDTH = 340\n\nexport type ToastSide = 'top' | 'bottom'\n\nexport type ToastAlign = 'start' | 'center' | 'end' | 'left' | 'right'\nexport type ToastPosition = `${ToastSide}-${ToastAlign}`\nexport const toastPositions = [\n  'top-start',\n  'top-center',\n  'top-end',\n  'bottom-start',\n  'bottom-center',\n  'bottom-end',\n] as const satisfies readonly ToastPosition[]\n\ntype ToastEdge = 'start' | 'center' | 'end'\n\nconst JUSTIFY: Record<ToastEdge, string> = {\n  start: 'justify-start',\n  center: 'justify-center',\n  end: 'justify-end',\n}\n\nexport type ToastState = 'pending' | AlertTone\nexport type ToastAction = { label: string; run: () => void }\nexport type ToastInput = {\n  id?: string\n  message: string\n\n  description?: string\n  state?: ToastState\n  action?: ToastAction\n  lifetime?: number\n}\nexport type Note = ToastInput & { id: string }\nexport type ToastClock = { waits: Map<string, number>; since: number | null }\nexport type StackSlot = { y: number; scale: number; opacity: number }\nexport type StackCard = {\n  id: string\n  render: (behind: boolean) => ReactNode\n}\n\nlet nextId = 0\n\nexport function toast(input: string | ToastInput) {\n  const detail = typeof input === 'string' ? { message: input } : input\n  window.dispatchEvent(\n    new CustomEvent(EVENT, {\n      detail: { ...detail, id: detail.id ?? `toast-${++nextId}` },\n    }),\n  )\n}\n\nexport function dismissToast(id: string) {\n  window.dispatchEvent(new CustomEvent(DISMISS, { detail: id }))\n}\n\nexport function upsertToast(notes: readonly Note[], note: Note): Note[] {\n  const index = notes.findIndex((item) => item.id === note.id)\n  return index === -1 ? [note, ...notes] : notes.map((item, at) => (at === index ? note : item))\n}\n\nexport function dismissDelay(\n  state: ToastState | undefined,\n  hasAction: boolean,\n  lifetime?: number,\n  hasDetail = false,\n): number | null {\n  if (state === 'pending') return null\n  if (lifetime !== undefined) return lifetime\n  return hasAction ? ACTION_LIFETIME : hasDetail ? DETAIL_LIFETIME : LIFETIME\n}\n\nexport function tick(clock: ToastClock, at: number) {\n  if (clock.since === null) return\n\n  const spent = at - clock.since\n  clock.since = at\n  for (const [id, left] of clock.waits) clock.waits.set(id, left - spent)\n}\n\nexport function pileSlot(index: number): StackSlot {\n  const depth = Math.min(index, DEPTH - 1)\n  return {\n    y: depth * PEEK,\n    scale: 1 - depth * SHRINK,\n    opacity: index < DEPTH ? 1 - depth * FADE : 0,\n  }\n}\n\nexport function fanSlot(index: number, heights: readonly number[]): StackSlot {\n  let y = 0\n  for (let at = 0; at < index; at++) y += (heights[at] ?? LINE_HEIGHT) + GAP\n  return { y, scale: 1, opacity: 1 }\n}\n\nconst TONE_INK: Record<Exclude<AlertTone, 'success'>, string> = {\n  error: 'text-error',\n  warning: 'text-warning',\n  info: 'text-info',\n}\n\nconst BADGE_SIZE = { '--check-size': '16px' } as CSSProperties\n\nfunction ToastGlyph({ state }: { state: ToastState }) {\n  switch (state) {\n\n    case 'pending':\n    case 'success':\n      return (\n\n        <span className=\"flex\" style={BADGE_SIZE}>\n          <StatusBadge state={state === 'success' ? 'done' : 'loading'} />\n        </span>\n      )\n    case 'error':\n    case 'warning':\n    case 'info': {\n      const Mark = ALERT_MARKS[state]\n\n      return (\n        <Mark\n          className={cn('shrink-0', state === 'error' ? 'size-5' : 'size-4', TONE_INK[state])}\n          aria-hidden\n        />\n      )\n    }\n    default: {\n      const exhaustive: never = state\n      return exhaustive\n    }\n  }\n}\n\nconst GLYPH_POP = {\n  initial: { opacity: 0, scale: 0.25, filter: 'blur(4px)' },\n  animate: { opacity: 1, scale: 1, filter: 'blur(0px)' },\n  exit: { opacity: 0, scale: 0.25, filter: 'blur(4px)', transition: EXIT },\n} as const\n\nconst REVEAL = {\n\n  delay: 0.04,\n\n  sweep: 0.16,\n  step: 0.02,\n  duration: 0.24,\n\n  after: 0.06,\n  ease: [0.23, 1, 0.32, 1],\n} as const\n\nconst graphemes = new Intl.Segmenter(undefined, { granularity: 'grapheme' })\n\nfunction RevealText({\n  text,\n  words = false,\n  after = 0,\n}: {\n  text: string\n  words?: boolean\n  after?: number\n}) {\n  const reduceMotion = useReducedMotion()\n\n  const parts =\n    words || joinsLetters(text)\n      ? text.split(/(\\s+)/).filter(Boolean)\n      : [...graphemes.segment(text)].map(({ segment }) => segment)\n  const step = Math.min(REVEAL.step, REVEAL.sweep / Math.max(parts.length - 1, 1))\n\n  return (\n    <>\n      <span className=\"sr-only\">{text}</span>\n      <span aria-hidden>\n        {parts.map((part, index) => (\n          <motion.span\n            key={index}\n            initial={reduceMotion ? false : { opacity: 0, filter: 'blur(4px)' }}\n            animate={{ opacity: 1, filter: 'blur(0px)' }}\n            transition={{\n              duration: REVEAL.duration,\n              ease: REVEAL.ease,\n              delay: REVEAL.delay + after + index * step,\n            }}\n          >\n            {part}\n          </motion.span>\n        ))}\n      </span>\n    </>\n  )\n}\n\nfunction ToastLine({\n  message,\n  reveal = false,\n  from = 0,\n}: {\n  message: string\n  reveal?: boolean\n  from?: number\n}) {\n\n  const [revealed] = useState(reveal)\n  const fading = !useIsPresent()\n  return (\n    <motion.div\n      initial={{ width: from }}\n      animate={{ width: 'auto' }}\n      exit={{ opacity: 0, filter: 'blur(4px)', transition: EXIT }}\n      transition={MORPH}\n      className={cn('flex items-center overflow-hidden', fading && 'absolute inset-y-0 start-0')}\n    >\n      <span className=\"w-max max-w-lg shrink-0 truncate\">\n        {revealed ? <RevealText text={message} /> : message}\n      </span>\n    </motion.div>\n  )\n}\n\nfunction ToastDetail({ text, reveal, from }: { text: string; reveal: boolean; from: number }) {\n  const [revealed] = useState(reveal)\n  const present = useIsPresent()\n  const swapping = usePresenceData() === true\n  const fading = !present && swapping\n  return (\n    <motion.div\n      initial={{\n        height: from,\n        opacity: revealed ? 1 : 0,\n        filter: revealed ? 'blur(0px)' : 'blur(4px)',\n      }}\n      animate={{ height: 'auto', opacity: 1, filter: 'blur(0px)' }}\n      exit=\"leave\"\n      variants={{\n        leave: (swap: boolean) =>\n          swap\n            ? { opacity: 0, filter: 'blur(4px)', transition: EXIT }\n            : { height: 0, opacity: 0, filter: 'blur(4px)' },\n      }}\n      transition={MORPH}\n      className={cn('overflow-hidden', fading && 'absolute inset-x-0 top-0')}\n    >\n\n      <p className=\"pb-0.75 text-pretty text-muted-foreground\">\n        {revealed ? <RevealText text={text} words after={REVEAL.after} /> : text}\n      </p>\n    </motion.div>\n  )\n}\n\nconst glyphKey = (state: ToastState) =>\n  state === 'pending' || state === 'success' ? 'badge' : state\n\nfunction ToastPill({\n  state,\n  message,\n  description,\n  action,\n  onAction,\n  onDismiss,\n  behind,\n}: {\n  state?: ToastState\n  message: string\n  description?: string\n  action?: ToastAction\n  onAction: () => void\n  onDismiss: () => void\n  behind: boolean\n}) {\n  const pill = useRef<HTMLDivElement>(null)\n  const lines = useRef<HTMLDivElement>(null)\n  const details = useRef<HTMLDivElement>(null)\n  const [lineWidth, setLineWidth] = useState(0)\n  const [detailHeight, setDetailHeight] = useState(0)\n  useLayoutEffect(() => {\n    const line = lines.current\n    const detail = details.current\n    if (!line || !detail) return\n    const observer = new ResizeObserver(() => {\n      setLineWidth(line.offsetWidth)\n      setDetailHeight(detail.offsetHeight)\n    })\n    observer.observe(line)\n    observer.observe(detail)\n    return () => observer.disconnect()\n  }, [])\n\n  const [last, setLast] = useState({ message, state, description })\n  const [reveal, setReveal] = useState(false)\n  const [revealDetail, setRevealDetail] = useState(false)\n  const [detailSwap, setDetailSwap] = useState(false)\n  if (last.message !== message || last.state !== state || last.description !== description) {\n    setReveal(last.message !== message)\n    setRevealDetail(last.description !== description)\n    setDetailSwap(Boolean(last.description) && Boolean(description))\n    setLast({ message, state, description })\n  }\n\n  return (\n    <motion.div\n      ref={pill}\n\n      style={{ borderRadius: LINE_HEIGHT / 2 }}\n      drag={behind ? false : true}\n      dragSnapToOrigin\n      dragElastic={0.6}\n      dragMomentum={false}\n      dragTransition={{ bounceStiffness: 520, bounceDamping: 42 }}\n      onDragEnd={(_, info) => {\n        const far = Math.hypot(info.offset.x, info.offset.y) > SWIPE\n        const fast = Math.hypot(info.velocity.x, info.velocity.y) > FLICK\n        if (!far && !fast) return\n\n        if (pill.current) dissolve(pill.current, { onComplete: onDismiss })\n        else onDismiss()\n      }}\n      className={cn(\n        'toast-pill relative flex max-w-lg overflow-hidden bg-popover/80 text-sm text-foreground backdrop-blur-md',\n        behind ? 'pointer-events-none' : 'pointer-events-auto cursor-grab active:cursor-grabbing',\n\n        action ? 'pe-2' : 'pe-4',\n        state ? 'ps-3' : 'ps-4',\n\n        description && 'pt-0.5',\n      )}\n    >\n      <motion.div\n        animate={{ opacity: behind ? 0 : 1 }}\n        transition={MORPH}\n\n        className=\"grid min-w-max grid-cols-[auto_minmax(0,1fr)_auto] items-center\"\n      >\n\n        <div className=\"col-start-1 row-start-1 flex\">\n          <AnimatePresence initial={false}>\n            {state ? (\n              <motion.div\n                key=\"glyph\"\n                initial={{ width: 0 }}\n                animate={{ width: 'auto' }}\n                exit={{ width: 0 }}\n                transition={MORPH}\n\n                className=\"flex justify-end\"\n              >\n\n                <div className=\"flex w-max items-center pe-3\">\n\n                  <AnimatePresence initial={false} mode=\"popLayout\">\n                    <motion.span\n                      key={glyphKey(state)}\n                      {...GLYPH_POP}\n                      transition={MORPH}\n                      className=\"flex size-4 shrink-0 items-center justify-center\"\n                    >\n                      <ToastGlyph state={state} />\n                    </motion.span>\n                  </AnimatePresence>\n                </div>\n              </motion.div>\n            ) : null}\n          </AnimatePresence>\n        </div>\n\n        <div\n          ref={lines}\n          className={cn(\n            'relative col-start-2 row-start-1 flex h-9 items-center justify-self-start',\n            description && 'font-bold',\n          )}\n        >\n          <AnimatePresence initial={false}>\n            <ToastLine key={message} message={message} reveal={reveal} from={lineWidth} />\n          </AnimatePresence>\n        </div>\n\n        <div className=\"col-start-3 row-start-1 flex\">\n          <AnimatePresence initial={false}>\n            {action ? (\n              <motion.div\n                key=\"action\"\n                initial={{ width: 0 }}\n                animate={{ width: 'auto' }}\n                exit={{ width: 0 }}\n                transition={MORPH}\n\n                className=\"-my-1 -me-1 flex items-center overflow-hidden rounded-full py-1 pe-1\"\n              >\n                <div className=\"w-max ps-7\">\n                  <Button type=\"button\" size=\"sm\" onClick={onAction} className=\"h-7 rounded-full\">\n                    {action.label}\n                  </Button>\n                </div>\n              </motion.div>\n            ) : null}\n          </AnimatePresence>\n        </div>\n\n        <div\n          ref={details}\n          className={cn(\n            'toast-detail relative -top-1.5 col-span-2 col-start-2 row-start-2 w-0 min-w-full',\n            action ? 'pe-2' : 'pe-0',\n          )}\n        >\n          <AnimatePresence initial={false} custom={detailSwap}>\n            {description ? (\n              <ToastDetail\n                key={description}\n                text={description}\n                reveal={revealDetail}\n                from={detailSwap ? detailHeight : 0}\n              />\n            ) : null}\n          </AnimatePresence>\n        </div>\n\n        <motion.div\n          aria-hidden\n          initial={false}\n          animate={{ width: description ? CARD_WIDTH - (state ? 12 : 16) - (action ? 8 : 16) : 0 }}\n          transition={MORPH}\n          className=\"col-span-3 col-start-1 row-start-3\"\n        />\n      </motion.div>\n    </motion.div>\n  )\n}\n\nfunction sameBoxes(\n  first: Record<string, { width: number; height: number }>,\n  second: Record<string, { width: number; height: number }>,\n) {\n  const ids = Object.keys(second)\n  return (\n    ids.length === Object.keys(first).length &&\n    ids.every(\n      (id) => first[id]?.width === second[id]?.width && first[id]?.height === second[id]?.height,\n    )\n  )\n}\n\ntype Side = 'maxWidth' | 'maxHeight'\n\nfunction useCap(box: RefObject<HTMLDivElement | null>, side: Side, cap: number | null) {\n  const limit = useMotionValue<number | string>('none')\n\n  useLayoutEffect(() => {\n    const element = box.current\n    if (!element) return\n\n    const natural = () => {\n      const held = element.style[side]\n      element.style[side] = ''\n      const size = side === 'maxWidth' ? element.offsetWidth : element.offsetHeight\n      element.style[side] = held\n      return size\n    }\n    if (cap === null) {\n      if (limit.get() === 'none') return\n      const release = () => limit.set('none')\n      const controls = animate(limit, natural(), {\n        ...MORPH,\n\n        onComplete: () => frame.update(release),\n      })\n      return () => {\n        controls.stop()\n        cancelFrame(release)\n      }\n    }\n\n    if (limit.get() === 'none') limit.set(natural())\n    const controls = animate(limit, cap, MORPH)\n    return () => controls.stop()\n  }, [box, side, cap, limit])\n\n  return limit\n}\n\nfunction DeckCap({\n  width,\n  height,\n  ref,\n  children,\n}: {\n  width: number | null\n  height: number | null\n  ref: (element: HTMLDivElement | null) => void\n  children: ReactNode\n}) {\n  const box = useRef<HTMLDivElement | null>(null)\n  const maxWidth = useCap(box, 'maxWidth', width)\n  const maxHeight = useCap(box, 'maxHeight', height)\n\n  return (\n    <motion.div\n      ref={(element) => {\n        box.current = element\n        ref(element)\n      }}\n      style={{ maxWidth, maxHeight }}\n\n      className=\"relative flex flex-col\"\n    >\n      {children}\n    </motion.div>\n  )\n}\n\nfunction DeckSlot({\n  layer,\n  style,\n  ...motionProps\n}: ComponentProps<typeof motion.div> & { layer: number }) {\n  const present = useIsPresent()\n  return <motion.div {...motionProps} style={{ ...style, zIndex: present ? layer : 0 }} />\n}\n\nfunction ToastStack({\n  cards,\n  onOpen,\n  position,\n}: {\n  cards: StackCard[]\n  onOpen: (open: boolean) => void\n  position: ToastPosition\n}) {\n  const [pointing, setPointing] = useState(false)\n  const [focused, setFocused] = useState(false)\n  const [holding, setHolding] = useState(false)\n  const [boxes, setBoxes] = useState<Record<string, { width: number; height: number }>>({})\n  const measured = useRef(new Map<string, HTMLElement>())\n  const root = useRef<HTMLDivElement>(null)\n  const textDirection = useDirection()\n\n  const open = pointing || focused || holding\n  const piled = cards.length > 1 && !open\n\n  useEffect(() => onOpen(open), [onOpen, open])\n\n  useEffect(() => {\n    if (!holding) return\n    const release = () => setHolding(false)\n\n    const check = (event: PointerEvent) => {\n      if (event.buttons === 0) release()\n    }\n    window.addEventListener('pointerup', release)\n    window.addEventListener('pointercancel', release)\n    window.addEventListener('pointermove', check)\n    return () => {\n      window.removeEventListener('pointerup', release)\n      window.removeEventListener('pointercancel', release)\n      window.removeEventListener('pointermove', check)\n    }\n  }, [holding])\n\n  const at = useRef<{ x: number; y: number } | null>(null)\n  const overCards = useCallback(\n    () =>\n      at.current !== null &&\n      [...measured.current.values()].some((element) => {\n        const box = element.getBoundingClientRect()\n        return (\n          at.current!.x >= box.left - REACH &&\n          at.current!.x <= box.right + REACH &&\n          at.current!.y >= box.top - REACH &&\n          at.current!.y <= box.bottom + REACH\n        )\n      }),\n    [],\n  )\n\n  useEffect(() => {\n    const onMove = (event: PointerEvent) => {\n      at.current = { x: event.clientX, y: event.clientY }\n      setPointing(overCards())\n    }\n\n    const onLeave = () => {\n      at.current = null\n      setPointing(false)\n    }\n\n    window.addEventListener('pointermove', onMove)\n    document.documentElement.addEventListener('pointerleave', onLeave)\n    return () => {\n      window.removeEventListener('pointermove', onMove)\n      document.documentElement.removeEventListener('pointerleave', onLeave)\n    }\n  }, [overCards])\n\n  useEffect(() => {\n    if (!pointing) return\n    let frame = requestAnimationFrame(function check() {\n      if (!overCards()) {\n        setPointing(false)\n        return\n      }\n      frame = requestAnimationFrame(check)\n    })\n    return () => cancelAnimationFrame(frame)\n  }, [pointing, overCards])\n\n  useEffect(() => {\n    if (!focused) return\n    let frame = requestAnimationFrame(function check() {\n      if (!root.current?.contains(document.activeElement)) {\n        setFocused(false)\n        return\n      }\n      frame = requestAnimationFrame(check)\n    })\n    return () => cancelAnimationFrame(frame)\n  }, [focused])\n\n  const measure = useCallback(() => {\n    const next: Record<string, { width: number; height: number }> = {}\n    for (const [id, element] of measured.current) {\n\n      const { maxWidth, maxHeight } = element.style\n      element.style.maxWidth = ''\n      element.style.maxHeight = ''\n      next[id] = { width: element.offsetWidth, height: element.offsetHeight }\n      element.style.maxWidth = maxWidth\n      element.style.maxHeight = maxHeight\n    }\n    setBoxes((current) => (sameBoxes(current, next) ? current : next))\n  }, [])\n\n  useLayoutEffect(measure, [cards, measure])\n\n  const sizes = useRef<ResizeObserver | null>(null)\n  useEffect(() => {\n    const observer = new ResizeObserver(measure)\n    for (const element of measured.current.values()) observer.observe(element)\n    sizes.current = observer\n    return () => observer.disconnect()\n  }, [measure])\n\n  const heights = cards.map((card) => boxes[card.id]?.height ?? LINE_HEIGHT)\n  const deck = cards[0] ? boxes[cards[0].id] : undefined\n  const [side, align] = position.split('-') as [ToastSide, ToastAlign]\n  const rtl = textDirection === 'rtl'\n  const edge: ToastEdge =\n    align === 'left' ? (rtl ? 'end' : 'start') : align === 'right' ? (rtl ? 'start' : 'end') : align\n\n  const corner = edge === 'center' ? 'center' : (edge === 'start') !== rtl ? 'left' : 'right'\n\n  const fall = side === 'top' ? 1 : -1\n\n  return (\n    <motion.div\n      ref={root}\n      aria-live=\"polite\"\n      onPointerDown={() => setHolding(true)}\n      onFocus={() => setFocused(true)}\n      onBlur={(event) => {\n        if (!event.currentTarget.contains(event.relatedTarget)) setFocused(false)\n      }}\n      className={cn(\n        'pointer-events-none fixed inset-x-0 z-100',\n        side === 'top' ? 'top-4' : 'bottom-4',\n      )}\n    >\n      <AnimatePresence initial={false}>\n        {cards.map((card, index) => {\n          const slot = piled ? pileSlot(index) : fanSlot(index, heights)\n\n          const drop =\n            piled && index > 0\n              ? Math.max(0, (heights[0] ?? LINE_HEIGHT) - (heights[index] ?? LINE_HEIGHT))\n              : 0\n          const y = (slot.y + drop) * fall\n          const from = (slot.y + drop - 8) * fall\n          return (\n            <DeckSlot\n              key={card.id}\n              layer={cards.length - index}\n              style={{\n\n                transformOrigin: `${side} ${corner}`,\n              }}\n              initial={{ opacity: 0, y: from, scale: slot.scale * 0.98 }}\n              animate={{ opacity: slot.opacity, y, scale: slot.scale }}\n              exit={{ opacity: 0, y: from, scale: slot.scale * 0.96, transition: EXIT }}\n              transition={MORPH}\n              className={cn(\n                'absolute inset-x-0 flex px-4',\n                side === 'top' ? 'top-0' : 'bottom-0',\n                JUSTIFY[edge],\n              )}\n              aria-hidden={slot.opacity === 0 || undefined}\n            >\n              <DeckCap\n                width={piled && index > 0 ? (deck?.width ?? null) : null}\n                height={piled && index > 0 ? (deck?.height ?? null) : null}\n                ref={(element) => {\n                  if (element) {\n                    measured.current.set(card.id, element)\n                    sizes.current?.observe(element)\n                    return\n                  }\n                  const gone = measured.current.get(card.id)\n                  if (gone) sizes.current?.unobserve(gone)\n                  measured.current.delete(card.id)\n                }}\n              >\n                {card.render(piled && index > 0)}\n              </DeckCap>\n            </DeckSlot>\n          )\n        })}\n      </AnimatePresence>\n    </motion.div>\n  )\n}\n\nfunction subscribeVisibility(onChange: () => void) {\n  document.addEventListener('visibilitychange', onChange)\n  return () => document.removeEventListener('visibilitychange', onChange)\n}\n\nfunction useDocumentHidden() {\n  return useSyncExternalStore(\n    subscribeVisibility,\n    () => document.hidden,\n    () => false,\n  )\n}\n\nexport function Toasts({ position = 'top-center' }: { position?: ToastPosition }) {\n  const [notes, setNotes] = useState<Note[]>([])\n  const [reading, setReading] = useState(false)\n  const hidden = useDocumentHidden()\n\n  const paused = reading || hidden\n  const clock = useRef<ToastClock>({ waits: new Map(), since: null })\n\n  const issued = useRef<string | null>(null)\n\n  useEffect(() => {\n    clock.current.since = performance.now()\n\n    const onToast = (event: Event) => {\n      const note = (event as CustomEvent<Note>).detail\n      issued.current = note.id\n      setNotes((current) => upsertToast(current, note))\n      tick(clock.current, performance.now())\n      const delay = dismissDelay(\n        note.state,\n        note.action !== undefined,\n        note.lifetime,\n        note.description !== undefined,\n      )\n      if (delay === null) clock.current.waits.delete(note.id)\n      else clock.current.waits.set(note.id, delay)\n    }\n    const onDismiss = (event: Event) => {\n      const id = (event as CustomEvent<string>).detail\n      clock.current.waits.delete(id)\n      setNotes((current) => current.filter((note) => note.id !== id))\n    }\n\n    window.addEventListener(EVENT, onToast)\n    window.addEventListener(DISMISS, onDismiss)\n    return () => {\n      window.removeEventListener(EVENT, onToast)\n      window.removeEventListener(DISMISS, onDismiss)\n    }\n  }, [])\n\n  useEffect(() => {\n    tick(clock.current, performance.now())\n    clock.current.since = paused ? null : performance.now()\n  }, [paused])\n\n  useEffect(() => {\n    if (paused) return\n\n    tick(clock.current, performance.now())\n    const waits = [...clock.current.waits.values()]\n    if (waits.length === 0) return\n\n    const timer = window.setTimeout(\n      () => {\n        tick(clock.current, performance.now())\n        const expired = new Set<string>()\n        for (const [id, left] of clock.current.waits) {\n          if (left <= 0) expired.add(id)\n        }\n        for (const id of expired) clock.current.waits.delete(id)\n        setNotes((current) => current.filter((note) => !expired.has(note.id)))\n      },\n      Math.max(0, Math.min(...waits)),\n    )\n    return () => window.clearTimeout(timer)\n  }, [notes, paused])\n\n  return (\n    <MotionConfig reducedMotion=\"user\">\n      <ToastStack\n        position={position}\n        onOpen={setReading}\n        cards={notes.map((note) => {\n          const drop = () => {\n            clock.current.waits.delete(note.id)\n            setNotes((current) => current.filter((item) => item.id !== note.id))\n          }\n\n          const act = () => {\n            issued.current = null\n            note.action?.run()\n            if (issued.current !== note.id) drop()\n          }\n          return {\n            id: note.id,\n            render: (behind) => (\n              <ToastPill\n                state={note.state}\n                message={note.message}\n                description={note.description}\n                action={note.action}\n                onAction={act}\n                onDismiss={drop}\n                behind={behind}\n              />\n            ),\n          }\n        })}\n      />\n    </MotionConfig>\n  )\n}\n","type":"registry:ui","target":"components/ui/toast.tsx"},{"path":"lib/joined-script.ts","content":"const JOINED =\n  /[\\p{Script=Arabic}\\p{Script=Syriac}\\p{Script=Nko}\\p{Script=Mongolian}\\p{Script=Adlam}\\p{Script=Hanifi_Rohingya}\\p{Script=Mandaic}]/u\n\nexport const joinsLetters = (text: string) => JOINED.test(text)\n","type":"registry:lib","target":"lib/joined-script.ts"},{"path":"lib/smoky-dissolve.ts","content":"function readNum(name: string, fallback: number): number {\n  const raw = getComputedStyle(document.documentElement).getPropertyValue(name).trim()\n  if (!raw) return fallback\n  if (raw.endsWith('ms')) return Number.parseFloat(raw)\n  if (raw.endsWith('s')) return Number.parseFloat(raw) * 1000\n  const n = Number.parseFloat(raw)\n  return Number.isNaN(n) ? fallback : n\n}\n\nfunction readStr(name: string): string {\n  return getComputedStyle(document.documentElement).getPropertyValue(name).trim()\n}\n\nfunction makeEaseSampler(raw: string): (x: number) => number {\n  const kw: Record<string, [number, number, number, number]> = {\n    linear: [0, 0, 1, 1],\n    ease: [0.25, 0.1, 0.25, 1],\n    'ease-in': [0.42, 0, 1, 1],\n    'ease-out': [0, 0, 0.58, 1],\n    'ease-in-out': [0.42, 0, 0.58, 1],\n  }\n  let c = kw[raw.trim()]\n  if (!c) {\n    const m = /cubic-bezier\\(\\s*([-\\d.]+),\\s*([-\\d.]+),\\s*([-\\d.]+),\\s*([-\\d.]+)\\s*\\)/.exec(raw)\n    if (m) c = [Number(m[1]), Number(m[2]), Number(m[3]), Number(m[4])]\n  }\n  const [x1, y1, x2, y2] = c ?? kw.ease!\n  const cx = 3 * x1\n  const bx = 3 * (x2 - x1) - cx\n  const ax = 1 - cx - bx\n  const cy = 3 * y1\n  const by = 3 * (y2 - y1) - cy\n  const ay = 1 - cy - by\n  const sx = (t: number) => ((ax * t + bx) * t + cx) * t\n  const dxf = (t: number) => (3 * ax * t + 2 * bx) * t + cx\n  const sy = (t: number) => ((ay * t + by) * t + cy) * t\n  return (x) => {\n    if (x <= 0) return 0\n    if (x >= 1) return 1\n    let t = x\n    for (let i = 0; i < 6; i++) {\n      const e = sx(t) - x\n      if (Math.abs(e) < 1e-4) break\n      const d = dxf(t)\n      if (Math.abs(d) < 1e-6) break\n      t -= e / d\n    }\n    return sy(t)\n  }\n}\n\nconst TRANSPARENT = /^rgba?\\(.*,\\s*0\\)$/\n\nfunction radiusOf(style: CSSStyleDeclaration, w: number, h: number): number {\n  const raw = style.borderTopLeftRadius\n  const value = raw.endsWith('%')\n    ? (Number.parseFloat(raw) / 100) * Math.min(w, h)\n    : Number.parseFloat(raw)\n  return Math.min(Number.isNaN(value) ? 0 : value, Math.min(w, h) / 2)\n}\n\nfunction paintSvg(ctx: CanvasRenderingContext2D, svg: SVGSVGElement, x: number, y: number) {\n  const box = svg.getBoundingClientRect()\n  const view = svg.viewBox.baseVal\n  const vw = view.width || box.width\n  const vh = view.height || box.height\n  if (!vw || !vh) return\n  ctx.save()\n  ctx.translate(x, y)\n  ctx.scale(box.width / vw, box.height / vh)\n  ctx.translate(-view.x, -view.y)\n  for (const path of svg.querySelectorAll('path')) {\n    const d = path.getAttribute('d')\n    if (!d) continue\n    const style = getComputedStyle(path)\n    const shape = new Path2D(d)\n    if (style.fill && style.fill !== 'none' && !TRANSPARENT.test(style.fill)) {\n      ctx.fillStyle = style.fill\n      ctx.fill(shape)\n    }\n    if (style.stroke && style.stroke !== 'none' && !TRANSPARENT.test(style.stroke)) {\n      ctx.strokeStyle = style.stroke\n      ctx.lineWidth = Number.parseFloat(style.strokeWidth) || 1\n      ctx.lineCap = style.strokeLinecap as CanvasLineCap\n      ctx.lineJoin = style.strokeLinejoin as CanvasLineJoin\n\n      const dash = style.strokeDasharray\n      if (dash && dash !== 'none') {\n        ctx.setLineDash(\n          dash\n            .split(/[\\s,]+/)\n            .map(Number.parseFloat)\n            .filter(Number.isFinite),\n        )\n        ctx.lineDashOffset = Number.parseFloat(style.strokeDashoffset) || 0\n      }\n      ctx.stroke(shape)\n      ctx.setLineDash([])\n    }\n  }\n  ctx.restore()\n}\n\nfunction fillBox(\n  ctx: CanvasRenderingContext2D,\n  style: CSSStyleDeclaration,\n  x: number,\n  y: number,\n  w: number,\n  h: number,\n) {\n  const r = radiusOf(style, w, h)\n  if (!TRANSPARENT.test(style.backgroundColor) && style.backgroundColor !== 'transparent') {\n    ctx.beginPath()\n    ctx.roundRect(x, y, w, h, r)\n    ctx.fillStyle = style.backgroundColor\n    ctx.fill()\n  }\n  const bw = Number.parseFloat(style.borderTopWidth)\n  if (bw > 0 && !TRANSPARENT.test(style.borderTopColor)) {\n    ctx.beginPath()\n    ctx.roundRect(x + bw / 2, y + bw / 2, w - bw, h - bw, Math.max(0, r - bw / 2))\n    ctx.strokeStyle = style.borderTopColor\n    ctx.lineWidth = bw\n    ctx.stroke()\n  }\n}\n\nfunction paintPseudo(\n  ctx: CanvasRenderingContext2D,\n  node: Element,\n  which: '::before' | '::after',\n  x: number,\n  y: number,\n) {\n  const style = getComputedStyle(node, which)\n  if (style.content === 'none' || style.position !== 'absolute') return\n  const w = Number.parseFloat(style.width)\n  const h = Number.parseFloat(style.height)\n  const top = Number.parseFloat(style.top)\n  const left = Number.parseFloat(style.left)\n  if (![w, h, top, left].every(Number.isFinite)) return\n  fillBox(ctx, style, x + left, y + top, w, h)\n}\n\nfunction paint(ctx: CanvasRenderingContext2D, root: Element, ox: number, oy: number) {\n  const origin = root.getBoundingClientRect()\n  const walk = (node: Element) => {\n    const style = getComputedStyle(node)\n    const alpha = Number(style.opacity)\n    if (style.visibility === 'hidden' || style.display === 'none' || alpha === 0) return\n    const box = node.getBoundingClientRect()\n    if (box.width === 0 || box.height === 0) return\n\n    if (style.overflow === 'hidden' && box.width <= 1 && box.height <= 1) return\n    const x = box.left - origin.left + ox\n    const y = box.top - origin.top + oy\n\n    ctx.save()\n    ctx.globalAlpha = Number.isNaN(alpha) ? 1 : alpha\n    if (node instanceof SVGSVGElement) {\n      paintSvg(ctx, node, x, y)\n      ctx.restore()\n      return\n    }\n\n    fillBox(ctx, style, x, y, box.width, box.height)\n    paintPseudo(ctx, node, '::before', x, y)\n\n    ctx.fillStyle = style.color\n    ctx.font = `${style.fontStyle} ${style.fontWeight} ${style.fontSize} ${style.fontFamily}`\n    ctx.textBaseline = 'middle'\n\n    ctx.direction = style.direction === 'rtl' ? 'rtl' : 'ltr'\n    ctx.textAlign = 'left'\n    for (const child of node.childNodes) {\n      if (child.nodeType !== Node.TEXT_NODE || !child.textContent?.trim()) continue\n\n      const range = document.createRange()\n      range.selectNodeContents(child)\n      if (range.getClientRects().length > 1) {\n\n        for (const word of child.textContent.matchAll(/\\S+/g)) {\n          range.setStart(child, word.index)\n          range.setEnd(child, word.index + word[0].length)\n          const at = range.getBoundingClientRect()\n          ctx.fillText(\n            word[0],\n            at.left - origin.left + ox,\n            at.top - origin.top + oy + at.height / 2,\n          )\n        }\n        continue\n      }\n      const line = range.getBoundingClientRect()\n      ctx.fillText(\n        child.textContent,\n        line.left - origin.left + ox,\n        line.top - origin.top + oy + line.height / 2,\n      )\n    }\n    paintPseudo(ctx, node, '::after', x, y)\n    ctx.restore()\n\n    for (const child of node.children) walk(child)\n  }\n  walk(root)\n}\n\nfunction boxH(srcA: Uint8ClampedArray, dstA: Uint8ClampedArray, w: number, h: number, r: number) {\n  const inv = 1 / (2 * r + 1)\n  for (let y = 0; y < h; y++) {\n    const base = y * w * 4\n    let sr = 0\n    let sg = 0\n    let sb = 0\n    let sa = 0\n    for (let x = 0; x <= r && x < w; x++) {\n      const i = base + x * 4\n      sr += srcA[i]!\n      sg += srcA[i + 1]!\n      sb += srcA[i + 2]!\n      sa += srcA[i + 3]!\n    }\n    for (let x = 0; x < w; x++) {\n      const o = base + x * 4\n      dstA[o] = sr * inv\n      dstA[o + 1] = sg * inv\n      dstA[o + 2] = sb * inv\n      dstA[o + 3] = sa * inv\n      const xa = x + r + 1\n      if (xa < w) {\n        const ia = base + xa * 4\n        sr += srcA[ia]!\n        sg += srcA[ia + 1]!\n        sb += srcA[ia + 2]!\n        sa += srcA[ia + 3]!\n      }\n      const xs = x - r\n      if (xs >= 0) {\n        const is = base + xs * 4\n        sr -= srcA[is]!\n        sg -= srcA[is + 1]!\n        sb -= srcA[is + 2]!\n        sa -= srcA[is + 3]!\n      }\n    }\n  }\n}\n\nfunction boxV(\n  srcA: Uint8ClampedArray,\n  dstA: Uint8ClampedArray,\n  w: number,\n  h: number,\n  r: number,\n  straight: boolean,\n) {\n  const stride = w * 4\n  const inv = 1 / (2 * r + 1)\n  for (let x = 0; x < w; x++) {\n    const base = x * 4\n    let sr = 0\n    let sg = 0\n    let sb = 0\n    let sa = 0\n    for (let y = 0; y <= r && y < h; y++) {\n      const i = base + y * stride\n      sr += srcA[i]!\n      sg += srcA[i + 1]!\n      sb += srcA[i + 2]!\n      sa += srcA[i + 3]!\n    }\n    for (let y = 0; y < h; y++) {\n      const o = base + y * stride\n      const aOut = sa * inv\n      if (straight && aOut > 0.5 && aOut < 254.6) {\n        const k = 255 / aOut\n        dstA[o] = sr * inv * k\n        dstA[o + 1] = sg * inv * k\n        dstA[o + 2] = sb * inv * k\n      } else {\n        dstA[o] = sr * inv\n        dstA[o + 1] = sg * inv\n        dstA[o + 2] = sb * inv\n      }\n      dstA[o + 3] = aOut\n      const ya = y + r + 1\n      if (ya < h) {\n        const ia = base + ya * stride\n        sr += srcA[ia]!\n        sg += srcA[ia + 1]!\n        sb += srcA[ia + 2]!\n        sa += srcA[ia + 3]!\n      }\n      const ys = y - r\n      if (ys >= 0) {\n        const is = base + ys * stride\n        sr -= srcA[is]!\n        sg -= srcA[is + 1]!\n        sb -= srcA[is + 2]!\n        sa -= srcA[is + 3]!\n      }\n    }\n  }\n}\n\nexport type DissolveOptions = { onComplete?: () => void }\n\nexport function dissolve(el: HTMLElement, { onComplete }: DissolveOptions = {}) {\n  if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) {\n    onComplete?.()\n    return\n  }\n\n  const durMs = readNum('--smoky-dur', 550)\n  const g = readNum('--smoky-gravity', 150)\n  const warp = readNum('--smoky-warp', 30)\n  const warpDurRaw = readNum('--smoky-warp-dur', 0)\n  const warpDurMs = warpDurRaw > 0 ? warpDurRaw : durMs\n  const maxBlur = readNum('--smoky-blur', 12)\n  const sway = readNum('--smoky-sway', 0)\n  const spin = readNum('--smoky-spin', 3)\n  const churn = readNum('--smoky-churn', 30)\n  const spread = readNum('--smoky-spread', 0)\n  const grain = readNum('--smoky-grain', 28)\n  const warpEase = makeEaseSampler(readStr('--smoky-warp-ease'))\n  const blurEase = makeEaseSampler(readStr('--smoky-blur-ease'))\n  const gravityEase = makeEaseSampler(readStr('--smoky-gravity-ease'))\n  const dissolveEase = makeEaseSampler(readStr('--smoky-dissolve-ease'))\n\n  const dpr = Math.min(window.devicePixelRatio || 1, 2)\n  const rect = el.getBoundingClientRect()\n  const cardW = rect.width\n  const cardH = rect.height\n  const pad = Math.min(Math.ceil(warp / 2 + maxBlur * 2) + 6, 80)\n  const padDev = Math.round(pad * dpr)\n  const snapW = Math.max(1, Math.round(cardW * dpr))\n  const snapH = Math.max(1, Math.round(cardH * dpr))\n  const workW = snapW + padDev * 2\n  const workH = snapH + padDev * 2\n\n  const canvas = document.createElement('canvas')\n  canvas.width = workW\n  canvas.height = workH\n  canvas.setAttribute('aria-hidden', 'true')\n  canvas.style.cssText = `position:fixed;left:${rect.left - pad}px;top:${rect.top - pad}px;width:${cardW + pad * 2}px;height:${cardH + pad * 2}px;pointer-events:none;z-index:200;will-change:transform,opacity`\n  const ctx = canvas.getContext('2d')\n  if (!ctx) {\n    onComplete?.()\n    return\n  }\n  ctx.imageSmoothingQuality = 'high'\n\n  const snap = document.createElement('canvas')\n  snap.width = snapW\n  snap.height = snapH\n  const sc = snap.getContext('2d')\n  if (!sc) {\n    onComplete?.()\n    return\n  }\n  sc.setTransform(dpr, 0, 0, dpr, 0, 0)\n  paint(sc, el, 0, 0)\n\n  const sd = sc.getImageData(0, 0, snapW, snapH).data\n  const snapPre = new Uint8ClampedArray(sd.length)\n  for (let i = 0; i < sd.length; i += 4) {\n    const aP = sd[i + 3]!\n    snapPre[i] = (sd[i]! * aP) / 255\n    snapPre[i + 1] = (sd[i + 1]! * aP) / 255\n    snapPre[i + 2] = (sd[i + 2]! * aP) / 255\n    snapPre[i + 3] = aP\n  }\n\n  const workHalf = document.createElement('canvas')\n  const wW2 = Math.ceil(workW / 2)\n  const wH2 = Math.ceil(workH / 2)\n  workHalf.width = wW2\n  workHalf.height = wH2\n  const whctx = workHalf.getContext('2d')!\n  const workData = ctx.createImageData(workW, workH)\n  const halfData = whctx.createImageData(wW2, wH2)\n  const blurTmp = new Uint8ClampedArray(halfData.data.length)\n\n  const LAT = 4\n  const latW = Math.ceil(workW / LAT) + 2\n  const latH = Math.ceil(workH / LAT) + 2\n  const latDX = new Float32Array(latW * latH)\n  const latDY = new Float32Array(latW * latH)\n\n  function remap(dstArr: Uint8ClampedArray, dw: number, dh: number, s: number, straight: boolean) {\n    const src = snapPre\n    const invLat = 1 / LAT\n    let di = 0\n    for (let yD = 0; yD < dh; yD++) {\n      const yF = yD * s\n      const gy = yF * invLat\n      const gy0 = gy | 0\n      const fy = gy - gy0\n      const row0 = gy0 * latW\n      const row1 = row0 + latW\n      for (let xD = 0; xD < dw; xD++, di += 4) {\n        const xF = xD * s\n        const gx = xF * invLat\n        const gx0 = gx | 0\n        const fx = gx - gx0\n        const a = row0 + gx0\n        const b = row1 + gx0\n        const dxv =\n          (latDX[a]! + (latDX[a + 1]! - latDX[a]!) * fx) * (1 - fy) +\n          (latDX[b]! + (latDX[b + 1]! - latDX[b]!) * fx) * fy\n        const dyv =\n          (latDY[a]! + (latDY[a + 1]! - latDY[a]!) * fx) * (1 - fy) +\n          (latDY[b]! + (latDY[b + 1]! - latDY[b]!) * fx) * fy\n        const sxf = xF - padDev + dxv\n        const syf = yF - padDev + dyv\n        const sx0 = Math.floor(sxf)\n        const sy0 = Math.floor(syf)\n        if (sx0 < -1 || sx0 > snapW - 1 || sy0 < -1 || sy0 > snapH - 1) {\n\n          dstArr[di] = 0\n          dstArr[di + 1] = 0\n          dstArr[di + 2] = 0\n          dstArr[di + 3] = 0\n          continue\n        }\n        const u = sxf - sx0\n        const v = syf - sy0\n        let rC = 0\n        let gC = 0\n        let bC = 0\n        let aC = 0\n        for (const [ox2, oy2, w] of [\n          [0, 0, (1 - u) * (1 - v)],\n          [1, 0, u * (1 - v)],\n          [0, 1, (1 - u) * v],\n          [1, 1, u * v],\n        ] as const) {\n          const sx = sx0 + ox2\n          const sy = sy0 + oy2\n          if (sx < 0 || sx >= snapW || sy < 0 || sy >= snapH) continue\n          const si = (sy * snapW + sx) * 4\n          rC += src[si]! * w\n          gC += src[si + 1]! * w\n          bC += src[si + 2]! * w\n          aC += src[si + 3]! * w\n        }\n        if (straight && aC > 0.5 && aC < 254.6) {\n          const k = 255 / aC\n          rC *= k\n          gC *= k\n          bC *= k\n        }\n        dstArr[di] = rC\n        dstArr[di + 1] = gC\n        dstArr[di + 2] = bC\n        dstArr[di + 3] = aC\n      }\n    }\n  }\n\n  const N = 64\n  const noiseR = new Float32Array(N * N)\n  const noiseG = new Float32Array(N * N)\n  let seed = 4\n  for (let i = 0; i < N * N; i++) {\n    seed = (seed * 1664525 + 1013904223) >>> 0\n    noiseR[i] = seed / 2147483648 - 1\n    seed = (seed * 1664525 + 1013904223) >>> 0\n    noiseG[i] = seed / 2147483648 - 1\n  }\n  const gridAt = (gArr: Float32Array, x: number, y: number) => {\n    const xi = Math.floor(x)\n    const yi = Math.floor(y)\n    let fx = x - xi\n    let fy = y - yi\n    fx = fx * fx * (3 - 2 * fx)\n    fy = fy * fy * (3 - 2 * fy)\n    const x0 = ((xi % N) + N) % N\n    const x1 = (x0 + 1) % N\n    const y0 = ((yi % N) + N) % N\n    const y1 = (y0 + 1) % N\n    const top = gArr[y0 * N + x0]! + (gArr[y0 * N + x1]! - gArr[y0 * N + x0]!) * fx\n    const bot = gArr[y1 * N + x0]! + (gArr[y1 * N + x1]! - gArr[y1 * N + x0]!) * fx\n    return top + (bot - top) * fy\n  }\n  const noise2 = (gArr: Float32Array, px: number, py: number) =>\n    (gridAt(gArr, px / grain, py / grain) +\n      0.5 * gridAt(gArr, (px / grain) * 2 + 37.7, (py / grain) * 2 + 11.3)) /\n    1.5\n\n  el.style.visibility = 'hidden'\n  document.body.appendChild(canvas)\n  const t0 = performance.now()\n  let frame = 0\n\n  const tick = (now: number) => {\n    const t = (now - t0) / 1000\n\n    const rawP = Math.min((now - t0) / Math.max(durMs, 1), 1)\n    const p = dissolveEase(rawP)\n\n    const teff = gravityEase(p) * (durMs / 1000)\n    const fallY = 0.5 * g * teff * teff\n    const swayX = Math.sin(t * 5) * sway * p\n    const pw = Math.min((now - t0) / Math.max(warpDurMs, 1), 1)\n    const dispScale = warp * warpEase(pw)\n    const blur = maxBlur * blurEase(p)\n    const alpha = 1 - p ** 1.6\n    const driftY = churn * t\n    const driftX = Math.sin(t * 3.2) * churn * 0.3\n\n    if (frame % 2 === 0 || rawP >= 1) {\n      const halfDev = (dispScale / 2) * dpr\n      for (let ly = 0; ly < latH; ly++) {\n        const py = (ly * LAT - padDev) / dpr\n        for (let lx = 0; lx < latW; lx++) {\n          const px = (lx * LAT - padDev) / dpr\n          const li = ly * latW + lx\n          latDX[li] = halfDev * noise2(noiseR, px - driftX, py - driftY)\n          latDY[li] = halfDev * noise2(noiseG, px - driftX, py - driftY)\n        }\n      }\n      const rBox = blur > 0.3 ? Math.round(blur * dpr * 1.22) : 0\n      if (rBox >= 2) {\n        remap(halfData.data, wW2, wH2, 2, false)\n        const rHalf = Math.max(1, Math.round(rBox / 2))\n        boxH(halfData.data, blurTmp, wW2, wH2, rHalf)\n        boxH(blurTmp, halfData.data, wW2, wH2, rHalf)\n        boxV(halfData.data, blurTmp, wW2, wH2, rHalf, false)\n        boxV(blurTmp, halfData.data, wW2, wH2, rHalf, true)\n        whctx.putImageData(halfData, 0, 0)\n        ctx.clearRect(0, 0, workW, workH)\n        ctx.drawImage(workHalf, 0, 0, wW2, wH2, 0, 0, workW, workH)\n      } else {\n        remap(workData.data, workW, workH, 1, true)\n        ctx.putImageData(workData, 0, 0)\n      }\n    }\n    frame++\n\n    canvas.style.transform = `translate(${swayX.toFixed(1)}px, ${fallY.toFixed(1)}px) rotate(${(spin * p).toFixed(2)}deg) scale(${(1 + (spread / 100) * p).toFixed(3)})`\n    canvas.style.opacity = alpha.toFixed(3)\n\n    if (rawP < 1) {\n      requestAnimationFrame(tick)\n      return\n    }\n    canvas.remove()\n    onComplete?.()\n  }\n  requestAnimationFrame(tick)\n}\n","type":"registry:lib","target":"lib/smoky-dissolve.ts"}],"cssVars":{"theme":{"--toast-morph-duration":"300ms","--toast-morph-ease":"cubic-bezier(0.32, 0.72, 0, 1)","--color-error":"var(--error)","--color-warning":"var(--warning)","--color-success":"var(--success)","--color-info":"var(--info)"},"light":{"--error":"oklch(0.5 0.21 27.3)","--warning":"oklch(0.5 0.14 70)","--success":"oklch(0.5 0.13 152)","--info":"oklch(0.5 0.17 255)"},"dark":{"--error":"oklch(0.704 0.191 22.216)","--warning":"oklch(0.704 0.15 75)","--success":"oklch(0.704 0.15 152)","--info":"oklch(0.704 0.15 255)"}},"css":{".toast-pill":{"box-shadow":"0 1px 2px rgb(0 0 0 / 18%), 0 8px 24px rgb(0 0 0 / 20%), 0 0 0 1px rgb(255 255 255 / 10%)","transition":"padding var(--toast-morph-duration) var(--toast-morph-ease)"},".toast-detail":{"transition":"padding var(--toast-morph-duration) var(--toast-morph-ease)"},"@media (prefers-reduced-motion: reduce)":{".toast-pill, .toast-detail":{"transition":"none"}},"@media (prefers-reduced-transparency: reduce)":{".toast-pill":{"background":"var(--popover)","backdrop-filter":"none"}}}}