{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "toast",
  "title": "Toast",
  "description": "Actionable feedback on Base UI Toast that docks into a host cell or floats at the inline-end corner: done, failed, info, warning and loading kinds, a description line, one action (Undo, Retry), the countdown draining the keyline. useToaster() and createToaster() add promise tracking, update and dismiss, and calls from outside React.",
  "dependencies": [
    "@base-ui/react@1.9.0",
    "class-variance-authority"
  ],
  "registryDependencies": [
    "@keyline-ui/keyline",
    "utils",
    "@keyline-ui/keyline-scope",
    "@keyline-ui/keyline-render"
  ],
  "files": [
    {
      "path": "src/registry/keyline/ui/toast.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { Toast } from \"@base-ui/react/toast\";\nimport { cva } from \"class-variance-authority\";\n\nimport { cn } from \"@/lib/utils\";\nimport { scopeProps, useDomDirection, useKeylineScope, useMergedRef } from \"../lib/keyline-scope\";\nimport { dataAttrs, resolveClassName } from \"../lib/keyline-render\";\n\n/**\n * Wrap the app once. Up to `limit` (3) messages stay at once, newest in front; older ones wait behind it as a\n * stack and come forward as the newer ones close. Pass `toastManager={toaster}` (from\n * `createToaster()`) to raise messages from outside React too.\n */\nfunction ToastProvider({ timeout = 6000, limit = 3, ...props }: Toast.Provider.Props): React.ReactElement {\n  return <Toast.Provider timeout={timeout} limit={limit} {...props} />;\n}\n\n/** Keyline's kinds. Base UI's own `success` and `error` (what its promise tracking sets) draw as done and failed. */\ntype ToastKind = \"done\" | \"failed\" | \"info\" | \"warning\" | \"loading\";\n\ntype Notify = {\n  title: React.ReactNode;\n  /** A second line: what happened to what, or what to do next. Announced with the title. */\n  description?: React.ReactNode;\n  /**\n   * done (default) · failed (red ! cell, announced urgently) · info · warning (attention glyph on the ink toast;\n   * red stays for failure) · loading (the pending segment on the bottom keyline; it stays until updated or dismissed)\n   */\n  type?: ToastKind;\n  /** One action cell (Undo, Retry, Open). It closes the toast after it runs. */\n  action?: { label: string; onClick: () => void };\n  /** ms; 0 keeps the toast until it is dismissed. Loading toasts never time out. */\n  timeout?: number;\n};\n\ntype Track<T> = {\n  loading: string | Notify;\n  done: string | Notify | ((value: T) => string | Notify);\n  failed: string | Notify | ((error: unknown) => string | Notify);\n};\n\ntype Manager = Pick<ReturnType<typeof Toast.createToastManager>, \"add\" | \"close\" | \"update\" | \"promise\">;\n\nconst toOptions = ({ title, description, type = \"done\", action, timeout }: Notify) => ({\n  title,\n  description,\n  type,\n  ...(type === \"loading\" ? { timeout: 0 } : timeout !== undefined ? { timeout } : null),\n  priority: (type === \"failed\" ? \"high\" : \"low\") as \"high\" | \"low\",\n  // the toast list closes the toast after any action runs\n  actionProps: action ? { children: action.label, onClick: action.onClick } : undefined,\n});\nconst resolve = <V,>(o: string | Notify | ((v: V) => string | Notify), v: V, type: ToastKind) => {\n  const r = typeof o === \"function\" ? o(v) : o;\n  return toOptions(typeof r === \"string\" ? { title: r, type } : { type, ...r });\n};\n\n/** The calls Keyline adds over a Base UI toast manager: the same functions inside and outside React. */\nfunction bind(m: Manager) {\n  /** `notify({ title, description, type, action })`; returns the toast's id. */\n  const notify = (n: Notify): string => m.add(toOptions(n));\n  return {\n    notify,\n    /**\n     * Tracks a promise in one toast: loading (the pending segment) → done or failed, in place, without a second\n     * message. Returns the promise, which still rejects when it fails. Base UI's manager.promise underneath.\n     */\n    promise: <T,>(p: Promise<T>, t: Track<T>): Promise<T> =>\n      m.promise(p, {\n        loading: resolve(t.loading, undefined, \"loading\"),\n        // Base UI marks these success and error; the list draws them as done and failed\n        success: (v: T) => resolve(t.done, v, \"done\"),\n        error: (e: unknown) => resolve(t.failed, e, \"failed\"),\n      }),\n    /** Changes a toast in place (its title, kind, action), e.g. a loading toast you resolve yourself. */\n    update: (id: string, n: Partial<Notify>) => {\n      const o = toOptions({ title: undefined, ...n });\n      // every update restarts the drain (it is keyed on updateKey), so it always names a timeout, which makes\n      // Base UI restart the timer with it: the bar and the dismissal stay in step\n      m.update(id, (prev) => ({\n        ...(\"title\" in n ? { title: o.title } : null),\n        ...(\"description\" in n ? { description: o.description } : null),\n        // leaving loading restores the provider's timeout unless one is given\n        ...(\"type\" in n\n          ? { type: o.type, priority: o.priority, timeout: n.type === \"loading\" ? 0 : n.timeout }\n          : { timeout: \"timeout\" in n ? n.timeout : prev.timeout }),\n        ...(\"action\" in n ? { actionProps: o.actionProps } : null),\n      }));\n    },\n    /** Closes one toast, or every toast without an id. */\n    dismiss: (id?: string) => m.close(id),\n  };\n}\n\n/**\n * A toast manager that works outside React: a data layer, a websocket handler, a router guard.\n *\n *   export const toaster = createToaster()\n *   <ToastProvider toastManager={toaster}>…<ToastDock /></ToastProvider>\n *   toaster.notify({ title: \"Manifest sent\" })\n *\n * It is Base UI's `Toast.createToastManager()` with Keyline's calls added.\n */\nfunction createToaster() {\n  const m = Toast.createToastManager();\n  // Keyline's promise and update take Keyline's options and call Base UI's underneath: bound to a copy of the\n  // manager's own methods, so replacing them on the manager does not make them call themselves\n  return Object.assign(m, bind({ ...m }));\n}\n\n/** `notify({ title, type, action })`. The action closes the toast after it runs. */\nfunction useToast() {\n  const m = Toast.useToastManager();\n  return React.useCallback((n: Notify) => m.add(toOptions(n)), [m]);\n}\n\n/** notify, promise, update and dismiss for the nearest ToastProvider. */\nfunction useToaster() {\n  const m = Toast.useToastManager();\n  return React.useMemo(() => bind(m), [m]);\n}\n\n/* ------------------------------------------------------------------ *\n * VIEWPORT\n * Two placements. DOCKED renders the viewport INSIDE a host cell (e.g. the table pager), so a message never covers\n * data. FLOATING is the fallback for pages without a dock, at the bottom inline-end corner. The toasts read the\n * placement from the viewport they are in.\n * ------------------------------------------------------------------ */\n\ntype Placement = \"dock\" | \"floating\";\ntype Swipe = \"up\" | \"down\" | \"left\" | \"right\";\n/** The viewport a toast is in: how it is drawn, and which way it swipes away (toward the inline end; a floating\n * toast also down). */\nconst ViewportContext = React.createContext<{ placement: Placement; swipe: Swipe[] }>({\n  placement: \"dock\",\n  swipe: [\"right\"],\n});\n\n/* --kl-ts-move: how long a toast takes to change place in the stack. Transitions, never keyframes: toasts arrive in\n   bursts, and a transition retargets from wherever the toast is instead of restarting. */\nconst viewportVariants = cva(\n  cn(\n    \"outline-0 [--kl-ts-ease:cubic-bezier(0.22,1,0.36,1)] [--kl-ts-gap:8px] [--kl-ts-move:320ms] [--kl-ts-peek:8px]\",\n    \"in-data-[kl-motion=reduce]:[--kl-ts-move:0ms] motion-reduce:[--kl-ts-move:0ms]\",\n  ),\n  {\n    variants: {\n      placement: {\n        dock: \"relative flex min-w-0 items-stretch empty:pointer-events-none\",\n        // in a portal, the outermost element: it carries Keyline's type and ink (design.md, rule 8)\n        floating: cn(\n          \"fixed end-4 bottom-4 z-(--kl-z-toast) w-[min(440px,calc(100vw-32px))]\",\n          \"font-(family-name:--kl-font) text-(length:--kl-fs)/[1.4] text-kl-ink tabular-nums antialiased\",\n        ),\n      },\n    },\n  },\n);\n\n/** Base UI pauses toast timers while the window is blurred; the drain follows that (it drained to empty on\n * a background window while the toast stayed, so the countdown lied about the time left). */\nfunction useWindowBlurred() {\n  const [blurred, setBlurred] = React.useState(false);\n  React.useEffect(() => {\n    const on = () => setBlurred(true);\n    const off = () => setBlurred(false);\n    addEventListener(\"blur\", on);\n    addEventListener(\"focus\", off);\n    return () => {\n      removeEventListener(\"blur\", on);\n      removeEventListener(\"focus\", off);\n    };\n  }, []);\n  return blurred;\n}\n\ntype ToastViewportProps = React.ComponentProps<typeof Toast.Viewport> & {\n  /** dock (default): in flow, inside a host cell · floating: fixed at the bottom inline-end corner, in a portal. */\n  placement?: Placement;\n  /** Floating only: where the portal renders (defaults to <body>). */\n  container?: Toast.Portal.Props[\"container\"];\n  /** Floating only: props for Base UI's Toast.Portal. */\n  portalProps?: Omit<Toast.Portal.Props, \"container\" | \"children\">;\n};\n\nfunction DockViewport({ className, ref: refProp, ...props }: Omit<ToastViewportProps, \"placement\" | \"container\">) {\n  const paused = useWindowBlurred();\n  const ref = React.useRef<HTMLDivElement | null>(null);\n  const [dir] = useDomDirection(ref);\n  const setRef = useMergedRef(ref, refProp);\n  const value = React.useMemo(\n    () => ({ placement: \"dock\" as const, swipe: [dir === \"rtl\" ? \"left\" : \"right\"] as Swipe[] }),\n    [dir],\n  );\n  return (\n    <ViewportContext.Provider value={value}>\n      <Toast.Viewport\n        ref={setRef}\n        data-kl-paused={paused || undefined}\n        {...dataAttrs({ placement: \"dock\" })}\n        className={resolveClassName(cn(viewportVariants({ placement: \"dock\" })), className)}\n        {...props}\n        data-slot=\"toast-viewport\"\n      />\n    </ViewportContext.Provider>\n  );\n}\n\nfunction FloatingViewport({ className, container, portalProps, ...props }: Omit<ToastViewportProps, \"placement\">) {\n  const [marker, scope] = useKeylineScope(true, container);\n  const paused = useWindowBlurred();\n  const value = React.useMemo(\n    () => ({ placement: \"floating\" as const, swipe: [\"down\", scope.dir === \"rtl\" ? \"left\" : \"right\"] as Swipe[] }),\n    [scope.dir],\n  );\n  return (\n    <ViewportContext.Provider value={value}>\n      {marker}\n      <Toast.Portal container={container} {...portalProps}>\n        {/* carries the configuration of the place it is written, without a box of its own */}\n        <div {...scopeProps(scope, { className: \"contents\" })}>\n          <Toast.Viewport\n            data-kl-paused={paused || undefined}\n            {...dataAttrs({ placement: \"floating\" })}\n            className={resolveClassName(cn(viewportVariants({ placement: \"floating\" })), className)}\n            {...props}\n            data-slot=\"toast-viewport\"\n          />\n        </div>\n      </Toast.Portal>\n    </ViewportContext.Provider>\n  );\n}\n\n/**\n * Where toasts show: Base UI's Viewport (the F6 landmark; hover and keyboard focus expand it and pause the timers).\n * `placement=\"floating\"` adds Base UI's Portal and carries the configuration of the place it is written. Give it\n * ToastRoot children, or use ToastDock / ToastFloating, which render the manager's toasts.\n */\nfunction ToastViewport({ placement = \"dock\", ...props }: ToastViewportProps): React.ReactElement {\n  return placement === \"floating\" ? <FloatingViewport {...props} /> : <DockViewport {...props} />;\n}\n\n/* ------------------------------------------------------------------ *\n * TOAST\n * The stack, on Base UI's own stacking: it numbers the toasts (--toast-index), measures them (--toast-height,\n * --toast-offset-y, the viewport's --toast-frontmost-height), expands the viewport on hover and keyboard focus\n * (data-expanded, timers paused), and tracks swipes (--toast-swipe-movement-*). Keyline marks which toast is in\n * front (data-kl-front) and which wait behind it (data-kl-behind); the classes draw the rest.\n * ------------------------------------------------------------------ */\n\nconst KIND: Record<string, ToastKind> = { success: \"done\", error: \"failed\" };\nconst kindOf = (t: { type?: string | undefined }): ToastKind => KIND[t.type ?? \"\"] ?? (t.type as ToastKind) ?? \"done\";\n\nconst rootVariants = cva(\n  cn(\n    \"group/toast relative flex min-w-0 flex-1 bg-kl-inverse text-kl-on-inverse\",\n    // the swipe follows the pointer 1:1 (no transition while held); a released swipe that falls short springs back\n    \"[--kl-ts-x:var(--toast-swipe-movement-x,0px)] [--kl-ts-y:var(--toast-swipe-movement-y,0px)]\",\n    \"data-swiping:duration-0! data-swiping:select-none\",\n    \"data-limited:pointer-events-none data-limited:invisible data-limited:opacity-0\",\n    \"data-kl-behind:not-data-expanded:*:pointer-events-none data-kl-behind:not-data-expanded:*:opacity-0\",\n  ),\n  {\n    variants: {\n      placement: {\n        /*\n         * Collapsed, nothing leaves the cell (a dock never covers the rows above it): the front toast is in flow and\n         * its +n cell counts the waiting ones. Expanded, they unfold upward from the dock's top keyline as one column\n         * of ink cells on shared seams, newest nearest the dock, like any surface docked to its owner. The dock clips\n         * its toasts (the wipe), so a focused toast's ring is drawn inside it.\n         */\n        dock: cn(\n          \"[transform:translateX(var(--kl-ts-x))] [clip-path:inset(0)]\",\n          \"[transition:clip-path_var(--kl-t-unfold)_var(--kl-ease-out),transform_var(--kl-ts-move)_var(--kl-ts-ease),opacity_var(--kl-t-unfold)_linear]\",\n          \"focus-visible:outline-(length:--kl-ring) focus-visible:outline-offset-(--kl-ring-in) focus-visible:outline-current focus-visible:outline-solid\",\n          \"[&:is([data-starting-style],[data-ending-style])]:[clip-path:inset(0_100%_0_0)]\",\n          \"kl-rtl:[&:is([data-starting-style],[data-ending-style])]:[clip-path:inset(0_0_0_100%)]\",\n          \"data-ending-style:duration-(--kl-t-fold)\",\n          // a swiped toast leaves in the swipe's direction, unclipped (one attribute more than the RTL wipe above)\n          \"data-ending-style:data-swipe-direction:[&:is([data-swipe-direction=right],[data-swipe-direction=left])]:opacity-0\",\n          \"data-ending-style:data-swipe-direction:[&:is([data-swipe-direction=right],[data-swipe-direction=left])]:[clip-path:inset(0)]\",\n          \"not-data-kl-front:absolute not-data-kl-front:inset-x-0 not-data-kl-front:bottom-0 not-data-kl-front:h-(--toast-height,auto)\",\n          \"not-data-kl-front:border-b-(length:--kl-k1) not-data-kl-front:border-b-kl-on-inverse\",\n          \"not-data-kl-front:[transform:translate(var(--kl-ts-x),calc(-1*var(--toast-offset-y,0px)))]\",\n          \"data-kl-behind:not-data-expanded:invisible data-kl-behind:not-data-expanded:opacity-0\",\n          \"data-kl-behind:not-data-expanded:[transform:translateY(0)] data-kl-behind:data-expanded:z-3\",\n          \"forced-colors:border forced-colors:border-[CanvasText]\",\n        ),\n        /*\n         * Collapsed: the newest toast in front, an ink 2px frame. Older ones wait behind it as paper cards with an ink\n         * frame, as tall as the front one, each lifted by --kl-ts-peek and inset 8px a side, so their top keylines\n         * step up behind it: a count you can see, with no scaling (a scaled 2px keyline blurs) and no shadow.\n         * Expanded (hover or keyboard focus, Base UI): every card turns into its toast and the stack fans out into a\n         * column, --kl-ts-gap apart, newest at the bottom. In from below and out the same way; a swiped toast leaves\n         * in the swipe's direction.\n         */\n        floating: cn(\n          \"absolute inset-x-[calc(var(--kl-ts-i)*8px)] bottom-0 z-[calc(10-var(--kl-ts-i))] box-border [--kl-ts-i:var(--toast-index,0)]\",\n          \"h-(--toast-frontmost-height,auto) border-(length:--kl-k2) border-kl-inverse\",\n          \"[transform:translate(var(--kl-ts-x),calc(var(--kl-ts-y)-var(--kl-ts-i)*var(--kl-ts-peek)))]\",\n          \"[transition:transform_var(--kl-ts-move)_var(--kl-ts-ease),inset-inline_var(--kl-ts-move)_var(--kl-ts-ease),height_var(--kl-ts-move)_var(--kl-ts-ease),background-color_var(--kl-t-unfold)_linear,border-color_var(--kl-t-unfold)_linear,opacity_var(--kl-ts-move)_linear]\",\n          \"focus-visible:outline-(length:--kl-ring) focus-visible:outline-offset-(--kl-ring-out) focus-visible:outline-kl-focus focus-visible:outline-solid\",\n          // the front toast keeps its own height (it is what was measured as the frontmost)\n          \"data-kl-front:not-data-expanded:h-auto\",\n          \"data-kl-behind:not-data-expanded:border-kl-line data-kl-behind:not-data-expanded:bg-kl-cell\",\n          \"forced-colors:data-kl-behind:not-data-expanded:border-[CanvasText]\",\n          \"data-expanded:inset-x-0 data-expanded:h-(--toast-height,auto)\",\n          \"[&[data-expanded]:not([data-starting-style],[data-ending-style])]:[transform:translate(var(--kl-ts-x),calc(var(--kl-ts-y)-var(--toast-offset-y,0px)-var(--kl-ts-i)*var(--kl-ts-gap)))]\",\n          // the gap between fanned-out toasts still counts as the stack: the pointer crossing it keeps it open\n          \"data-expanded:after:absolute data-expanded:after:inset-x-0 data-expanded:after:top-full data-expanded:after:h-[calc(var(--kl-ts-gap)+2px)]\",\n          \"[&:is([data-starting-style],[data-ending-style])]:[transform:translate(var(--kl-ts-x),calc(100%+16px))]\",\n          \"data-ending-style:opacity-0\",\n          \"data-ending-style:data-[swipe-direction=right]:[transform:translate(calc(var(--kl-ts-x)+100%+16px),var(--kl-ts-y))]\",\n          \"data-ending-style:data-[swipe-direction=left]:[transform:translate(calc(var(--kl-ts-x)-100%-16px),var(--kl-ts-y))]\",\n          \"data-ending-style:data-[swipe-direction=down]:[transform:translate(var(--kl-ts-x),calc(var(--kl-ts-y)+100%+16px))]\",\n        ),\n      },\n    },\n  },\n);\n\ntype ToastRootProps = React.ComponentProps<typeof Toast.Root>;\n\n/**\n * One message: Base UI's Toast.Root, drawn for the viewport it is in. It marks its kind (data-kind: done, failed,\n * info, warning, loading), whether it is in front (data-kl-front) and whether it waits behind the front one\n * (data-kl-behind). It swipes away toward the inline end (a floating one also down) unless `swipeDirection` says\n * otherwise.\n */\nfunction ToastRoot({ toast, className, swipeDirection, ...props }: ToastRootProps): React.ReactElement {\n  const { placement, swipe } = React.useContext(ViewportContext);\n  const m = Toast.useToastManager();\n  // the front is the newest one on screen\n  const front = m.toasts.find((t) => t.transitionStatus !== \"ending\" && !t.limited)?.id;\n  const isFront = toast.id === front;\n  const behind = !isFront && toast.transitionStatus !== \"ending\" && !toast.limited;\n  return (\n    <Toast.Root\n      toast={toast}\n      swipeDirection={swipeDirection ?? swipe}\n      data-kind={kindOf(toast)}\n      data-kl-front={isFront || undefined}\n      data-kl-behind={behind || undefined}\n      {...dataAttrs({ placement })}\n      className={resolveClassName(cn(rootVariants({ placement })), className)}\n      {...props}\n      data-slot=\"toast-root\"\n    />\n  );\n}\n\nfunction ToastTitle({ className, ...props }: Toast.Title.Props): React.ReactElement {\n  return (\n    <Toast.Title\n      className={resolveClassName(\n        \"m-0 text-(length:--kl-text-body)/[1.3] font-(--kl-weight-strong) wrap-anywhere\",\n        className,\n      )}\n      {...props}\n      data-slot=\"toast-title\"\n    />\n  );\n}\n\nfunction ToastDescription({ className, ...props }: Toast.Description.Props): React.ReactElement {\n  return (\n    <Toast.Description\n      className={resolveClassName(\"m-0 text-(length:--kl-text-label)/[1.35] font-normal wrap-anywhere\", className)}\n      {...props}\n      data-slot=\"toast-description\"\n    />\n  );\n}\n\n/* a button on the ink toast: its ring takes the toast's text colour, inside the cell */\nconst ring =\n  \"focus-visible:outline-(length:--kl-ring) focus-visible:outline-offset-(--kl-ring-in) focus-visible:outline-current focus-visible:outline-solid\";\n\n/** The action cell (Undo, Retry): paper on the ink toast, yellow on hover. A cell sets no border: the row of cells\n * draws the divider before it. */\nfunction ToastAction({ className, ...props }: Toast.Action.Props): React.ReactElement {\n  return (\n    <Toast.Action\n      className={resolveClassName(\n        cn(\n          \"flex-none cursor-pointer bg-kl-cell px-3.5 font-(family-name:--kl-font) font-(--kl-weight-display) text-kl-ink\",\n          \"hover:bg-kl-yellow hover:text-kl-on-yellow\",\n          ring,\n        ),\n        className,\n      )}\n      {...props}\n      data-slot=\"toast-action\"\n    />\n  );\n}\n\n/** The dismiss cell. It shows only an icon, so it needs a name. */\nfunction ToastClose({\n  className,\n  children,\n  ...props\n}: Toast.Close.Props & { \"aria-label\": string }): React.ReactElement {\n  return (\n    <Toast.Close\n      className={resolveClassName(\n        cn(\n          \"grid w-10 flex-none cursor-pointer place-items-center bg-transparent text-inherit\",\n          \"hover:bg-kl-on-inverse hover:text-kl-inverse\",\n          ring,\n        ),\n        className,\n      )}\n      {...props}\n      data-slot=\"toast-close\"\n    >\n      {children ?? (\n        <svg\n          viewBox=\"0 0 16 16\"\n          width=\"14\"\n          height=\"14\"\n          fill=\"none\"\n          stroke=\"currentColor\"\n          strokeWidth=\"2\"\n          strokeLinecap=\"square\"\n          aria-hidden\n        >\n          <path d=\"m4.5 4.5 7 7m0-7-7 7\" />\n        </svg>\n      )}\n    </Toast.Close>\n  );\n}\n\nfunction Sig({ kind }: { kind: ToastKind }) {\n  if (kind === \"failed\") return <>!</>;\n  if (kind === \"info\") return <>i</>;\n  if (kind === \"warning\") return <span className=\"kl-glyph\" data-kind=\"attention\" />;\n  if (kind === \"loading\") return null;\n  return (\n    <svg\n      viewBox=\"0 0 16 16\"\n      width=\"16\"\n      height=\"16\"\n      fill=\"none\"\n      stroke=\"currentColor\"\n      strokeWidth=\"2.25\"\n      strokeLinecap=\"square\"\n    >\n      <path d=\"m3.5 8.5 3 3 6-7\" />\n    </svg>\n  );\n}\n\n/* the countdown drains the bottom keyline; it pauses exactly when Base UI's timers do: the stack expanded (hover,\n   keyboard focus), or the window losing focus (data-kl-paused). A pointer press inside does not pause the timer, so\n   it does not pause the drain. */\nconst drain = cn(\n  \"absolute inset-x-0 bottom-0 h-[3px] origin-left bg-kl-yellow text-inherit kl-rtl:origin-right\",\n  \"animate-[kl-drain_var(--kl-toast-t,6000ms)_linear_forwards]\",\n  \"in-data-expanded:[animation-play-state:paused] in-data-kl-paused:[animation-play-state:paused]\",\n  \"in-data-[kl-motion=reduce]:transform-none in-data-[kl-motion=reduce]:animate-none motion-reduce:animate-none\",\n  \"forced-colors:bg-[Highlight] forced-colors:forced-color-adjust-none\",\n);\n\n/** The manager's toasts, each composed from the parts: signal cell, title and description, the +n count, the action\n * and dismiss cells, and the countdown or the pending segment on the bottom keyline. */\nfunction ToastList({ timeout }: { timeout: number }) {\n  const m = Toast.useToastManager();\n  const live = m.toasts.filter((t) => t.transitionStatus !== \"ending\");\n  // the front is the newest one on screen; the count includes those over the limit (they come back in turn)\n  const front = live.find((t) => !t.limited)?.id;\n  return m.toasts.map((t) => {\n    const kind = kindOf(t);\n    const lasts = kind !== \"loading\" && t.timeout !== 0;\n    return (\n      <ToastRoot key={t.id} toast={t} style={{ \"--kl-toast-t\": `${t.timeout ?? timeout}ms` } as React.CSSProperties}>\n        {/* a plain container, not Toast.Content: that part re-measures the root inside its own ResizeObserver, with\n            flushSync, on the frame after it mounts; a toast arrives on the frame its host is re-laying out (the bulk\n            bar, the pager), and that commit mid-delivery is a loop error in WebKit. The root measures itself on arrival */}\n        {/* the toast's colour, not the ink the foundation gives a Keyline element with no Keyline ancestor (the root\n            carries no kl- class) */}\n        <div\n          data-slot=\"toast-cells\"\n          className=\"kl-cells min-w-0 flex-1 text-inherit transition-opacity duration-(--kl-t-unfold) ease-linear [&>:not(:first-child)]:border-s-kl-on-inverse\"\n        >\n          <span\n            data-slot=\"toast-signal\"\n            className=\"grid w-10 flex-none place-items-center font-(--kl-weight-display) group-data-[kind=failed]/toast:bg-kl-red group-data-[kind=failed]/toast:text-kl-on-red\"\n            aria-hidden\n          >\n            <Sig kind={kind} />\n          </span>\n          <span data-slot=\"toast-text\" className=\"flex min-w-0 flex-1 flex-col justify-center gap-0.5 px-3 py-1.5\">\n            <ToastTitle />\n            {t.description ? <ToastDescription /> : null}\n          </span>\n          {/* how many wait behind the front one, in the Code voice: the docked stack shows no peek (it never covers the\n              rows above); expanded, every message is in view, so the cell leaves */}\n          {t.id === front && live.length > 1 ? (\n            <span\n              data-slot=\"toast-more\"\n              className=\"kl-code grid min-w-10 flex-none place-items-center px-2 text-(length:--kl-text-meta) text-inherit group-data-expanded/toast:hidden\"\n            >\n              <bdi dir=\"ltr\" aria-hidden>\n                +{live.length - 1}\n              </bdi>\n              <span className=\"kl-sr\">{`${live.length - 1} more`}</span>\n            </span>\n          ) : null}\n          {t.actionProps ? <ToastAction onClick={() => m.close(t.id)} /> : null}\n          <ToastClose aria-label=\"Dismiss\" />\n        </div>\n        {/* …but only on arrival, so a toast updated in place (a promise: loading → done with a description) kept\n            its first height, and the expanded stack sized it from that stale --toast-height and clipped it. Once a\n            toast has been updated, a hidden Toast.Content re-measures it: on mount, in the update's own commit, and\n            on each later update through its MutationObserver (updateKey is its text) */}\n        {t.updateKey ? <Toast.Content hidden>{t.updateKey}</Toast.Content> : null}\n        {/* loading: the pending segment runs on the bottom keyline, and the signal cell stays empty (pending is a\n            segment, never a spinner) */}\n        {kind === \"loading\" ? (\n          <span data-slot=\"toast-pending\" className=\"kl-pending [--kl-bw:3px]\" aria-hidden />\n        ) : lasts ? (\n          <span key={t.updateKey} data-slot=\"toast-drain\" className={drain} aria-hidden />\n        ) : null}\n      </ToastRoot>\n    );\n  });\n}\n\ntype ListViewportProps = Omit<ToastViewportProps, \"placement\" | \"children\"> & {\n  /** The countdown's length for a toast that names no timeout: the provider's `timeout` (default 6000). */\n  timeout?: number;\n};\n\n/**\n * DOCKED feedback: the viewport inside a host cell (e.g. the table pager), rendering the manager's toasts. The front\n * message fills the cell and counts the ones waiting (+2); hovering or focusing the dock unfolds them upward on shared\n * seams. The undo countdown drains the bottom keyline and pauses with the timers. Swipe toward the inline end to\n * dismiss.\n */\nfunction ToastDock({ timeout = 6000, ...props }: ListViewportProps): React.ReactElement {\n  return (\n    <ToastViewport placement=\"dock\" {...props}>\n      <ToastList timeout={timeout} />\n    </ToastViewport>\n  );\n}\n\n/**\n * Floating fallback for pages without a dock, at the bottom inline-end corner. The newest message is in front\n * (an ink 2px frame); older ones wait behind it as paper cards whose top keylines peek above it. Hover or\n * keyboard focus fans the stack out into a column and pauses every timer. Swipe down or toward the inline end\n * to dismiss.\n */\nfunction ToastFloating({ timeout = 6000, ...props }: ListViewportProps): React.ReactElement {\n  return (\n    <ToastViewport placement=\"floating\" {...props}>\n      <ToastList timeout={timeout} />\n    </ToastViewport>\n  );\n}\n\nexport {\n  ToastProvider,\n  ToastViewport,\n  ToastRoot,\n  ToastTitle,\n  ToastDescription,\n  ToastAction,\n  ToastClose,\n  ToastDock,\n  ToastFloating,\n  useToast,\n  useToaster,\n  createToaster,\n  type Notify,\n  type ToastKind,\n};\n",
      "type": "registry:ui",
      "target": "components/keyline/ui/toast.tsx"
    }
  ],
  "type": "registry:ui"
}