{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "moment",
  "title": "Moment",
  "description": "A moment in an app's life, shown in the space it is given: nothing here yet, on its way, something failed, a first run, or something finished.",
  "registryDependencies": [
    "@ouro/button",
    "@ouro/heading",
    "@ouro/lib-announce",
    "@ouro/lib-celebration-cap",
    "@ouro/lib-class-name-check",
    "@ouro/lib-cn",
    "@ouro/lib-env",
    "@ouro/lib-focus-handoff",
    "@ouro/lib-refs",
    "@ouro/lib-use-dev-messages",
    "@ouro/lib-use-ouro",
    "@ouro/lib-use-reduced-motion",
    "@ouro/spinner",
    "@ouro/text"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/moment/moment-styles.ts",
      "content": "export {\n  artFrameClass,\n  dismissedKey,\n  dismissPeriods,\n  haloClass,\n  isDismissed,\n  kindToneClass,\n  keepDismissed,\n  MOMENT_STORAGE_PREFIX,\n  periods,\n  rootClass,\n  SETTLE_MS,\n  seenThisSession,\n  sparkClasses,\n  sparkleClass,\n  subscribeMoments,\n  takeShowing,\n  type MomentKind,\n  type MomentPeriod,\n};\n\nimport { celebrationPeriods, takeCelebration, type CelebrationPeriod } from \"@/registry/ouro/lib/ouro/celebration-cap\";\n\n// Class strings, values and the stored-state helpers for Moment, apart from the component so\n// its file exports only components (React Fast Refresh). Class strings are literal so the\n// app's Tailwind finds them when it compiles.\n\n/** What a moment is about. @internal */\ntype MomentKind = \"empty\" | \"loading\" | \"error\" | \"first-run\" | \"success\" | \"ask\";\n\n/** How long a celebration cap counts showings for, shared with Celebrate. @internal */\ntype MomentPeriod = CelebrationPeriod;\n\n/**\n * Each period in milliseconds; a month is 30 days.\n *\n * @internal\n * @claim \"Each period in milliseconds; a month\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment cap > counts by id without a dismissKey, keeps ever for good, and never celebrates at times 0)\n */\nconst periods = celebrationPeriods;\n\n/**\n * The prefix of every key Moment writes to `localStorage`.\n *\n * @internal\n * @claim \"The prefix of every key Moment\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment dismissal > stays dismissed through dismissKey, after a remount and in another tab)\n * @claim \"The prefix of every key Moment\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment cap > celebrates at most times per period, then again once the period has passed)\n */\nconst MOMENT_STORAGE_PREFIX = \"ouro-moment:\";\n\n/** The key that remembers a dismissal. @internal */\nconst dismissedKey = (key: string) => `${MOMENT_STORAGE_PREFIX}dismissed:${key}`;\n\n\n/** Values kept in memory, for a browser that refuses localStorage (a private window), so a dismissal still holds on the page. */\nconst memory = new Map<string, string>();\nconst listeners = new Set<() => void>();\n\nfunction read(key: string): string | null {\n  try {\n    return localStorage.getItem(key);\n  } catch {\n    return memory.get(key) ?? null;\n  }\n}\n\nfunction write(key: string, value: string): void {\n  try {\n    localStorage.setItem(key, value);\n  } catch {\n    memory.set(key, value);\n  }\n}\n\n/**\n * Calls `onChange` when a moment is dismissed in this page or, through the storage event, in\n * another tab.\n *\n * @internal\n */\nfunction subscribeMoments(onChange: () => void): () => void {\n  listeners.add(onChange);\n  addEventListener(\"storage\", onChange);\n  return () => {\n    listeners.delete(onChange);\n    removeEventListener(\"storage\", onChange);\n  };\n}\n\n/**\n * How long an art's looping motion runs before it settles, in milliseconds.\n *\n * @internal\n * @claim \"How long an art's looping motion\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment motion budget > settles the art's loops at the end of their turn within 5 s, SVG animations too, and leaves other motion alone)\n */\nconst SETTLE_MS = 5000;\n\nconst seenInMemory = new Set<string>();\n\n/**\n * Whether a moment with this key has appeared before in this session (this tab, until it\n * closes), and from now on it has.\n *\n * @internal\n */\nfunction seenThisSession(key: string): boolean {\n  const name = `${MOMENT_STORAGE_PREFIX}seen:${key}`;\n  try {\n    if (sessionStorage.getItem(name) !== null) return true;\n    sessionStorage.setItem(name, \"1\");\n    return false;\n  } catch {\n    if (seenInMemory.has(name)) return true;\n    seenInMemory.add(name);\n    return false;\n  }\n}\n\n/**\n * Whether the moment with this key was dismissed: for good, or, with `forMs`, less than that\n * long ago. A dismissal kept for good stays so.\n *\n * @internal\n */\nfunction isDismissed(key: string, forMs: number | undefined, now: number): boolean {\n  const value = read(dismissedKey(key));\n  if (value === null) return false;\n  const at = Number(value);\n  return forMs === undefined || value === \"1\" || now - at < forMs;\n}\n\n/** How long a dismissal with `dismissFor` lasts, in milliseconds. @internal */\nconst dismissPeriods = { hour: 60 * 60 * 1000, day: 24 * 60 * 60 * 1000, week: 7 * 24 * 60 * 60 * 1000, month: 30 * 24 * 60 * 60 * 1000 } as const;\n\n/**\n * Remembers that the moment with this key was dismissed, and tells every moment on the page.\n *\n * @internal\n * @claim \"Remembers that the moment with this\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment dismissal > closes every copy of a moment on the page at once)\n */\nfunction keepDismissed(key: string, at: number | undefined): void {\n  write(dismissedKey(key), at === undefined ? \"1\" : String(at));\n  for (const listener of [...listeners]) listener();\n}\n\n/**\n * Whether a celebration may show now under `cap`, and if so, records it, under the same keys\n * as Celebrate's.\n *\n * @internal\n */\nconst takeShowing = takeCelebration;\n\n/**\n * The colour each kind gives the art's `currentColor` and its celebration.\n *\n * @internal\n * @claim \"The colour each kind gives the\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment > names its kind in data-moment and colours the art from the theme by kind)\n */\nconst kindToneClass: Record<MomentKind, string> = {\n  empty: \"text-muted-foreground\",\n  loading: \"text-muted-foreground\",\n  error: \"text-destructive\",\n  \"first-run\": \"text-primary\",\n  success: \"text-success\",\n  ask: \"text-primary\",\n};\n\n/** The root, by layout. @internal */\nconst rootClass = {\n  default: \"@container/moment relative box-border flex w-full min-w-0 flex-col items-center gap-4 px-6 py-8 text-center text-balance\",\n  quiet: \"relative box-border flex w-full min-w-0 items-center gap-3 px-3 py-2.5 text-start\",\n  inline: \"relative box-border flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-start\",\n} as const;\n\n/**\n * The art's frame, by layout: up to 160px tall, 96px when the moment is narrower than 24rem\n * (its content box, inside the padding, narrower than 21rem), and 24px inline.\n * The art fills the frame's height.\n *\n * @internal\n * @claim \"The art's frame, by layout: up\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment sizes > gives the art 160px, 96px in a pane narrower than 24rem, and 24px inline)\n */\nconst artFrameClass = {\n  default: \"relative flex h-(--ouro-moment-art) max-w-full shrink-0 items-center justify-center [--ouro-moment-art:10rem] @max-[21rem]/moment:[--ouro-moment-art:6rem]\",\n  hero: \"relative flex h-(--ouro-moment-art) max-w-full shrink-0 items-center justify-center [--ouro-moment-art:13.75rem] @max-[21rem]/moment:[--ouro-moment-art:6rem]\",\n  inline: \"relative flex size-(--ouro-moment-art) shrink-0 items-center justify-center [--ouro-moment-art:1.5rem]\",\n} as const;\n\n/**\n * The soft disc that swells out from behind the art when a moment celebrates; with reduced\n * motion it only fades.\n *\n * @internal\n */\nconst haloClass =\n  \"pointer-events-none absolute inset-0 m-auto size-(--ouro-moment-art) max-w-full rounded-full bg-current opacity-0 \" +\n  \"[transition:transform_var(--ouro-duration-sheet)_var(--ouro-ease-out),opacity_var(--ouro-duration-sheet)_var(--ouro-ease-out)] \" +\n  \"starting:opacity-20 motion-safe:starting:[transform:scale(0.5)]\";\n\n/**\n * A small four-pointed spark that grows beside the art and fades; it stays inside the art's\n * frame, and it is hidden with reduced motion.\n *\n * @internal\n * @claim \"A small four-pointed spark that grows\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment > stays in the page's flow, and its celebration stays inside the art's frame)\n * @claim \"A small four-pointed spark that grows\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment motion > swells the disc and grows the sparks when it celebrates, and with reduced motion only fades the disc)\n */\nconst sparkleClass =\n  \"pointer-events-none absolute size-3 opacity-0 motion-reduce:hidden \" +\n  \"[transition:transform_var(--ouro-duration-sheet)_var(--ouro-ease-out),opacity_var(--ouro-duration-slow)_ease_var(--ouro-duration-slow)] \" +\n  \"starting:[transform:scale(0)] starting:opacity-100\";\n\n/** Where the sparks sit in the art's frame, and their tones. @internal */\nconst sparkClasses = [\"start-[8%] top-[14%] text-primary\", \"end-[10%] top-[6%] text-warning\", \"end-[4%] bottom-[22%] text-success\", \"start-[16%] bottom-[8%] text-primary\"] as const;\n",
      "type": "registry:ui",
      "target": "@components/ouro/moment/moment-styles.ts"
    },
    {
      "path": "registry/ouro/components/ouro/moment/moment.tsx",
      "content": "\"use client\";\n\nimport { createContext, useContext, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore, type HTMLAttributes, type JSX, type ReactNode, type Ref } from \"react\";\nimport { Button } from \"@/registry/ouro/components/ouro/button/button\";\nimport {\n  artFrameClass,\n  haloClass,\n  dismissPeriods,\n  isDismissed,\n  keepDismissed,\n  kindToneClass,\n  periods,\n  rootClass,\n  SETTLE_MS,\n  seenThisSession,\n  sparkClasses,\n  sparkleClass,\n  subscribeMoments,\n  takeShowing,\n  type MomentKind,\n  type MomentPeriod,\n} from \"@/registry/ouro/components/ouro/moment/moment-styles\";\nimport { Spinner } from \"@/registry/ouro/components/ouro/spinner/spinner\";\nimport { Heading } from \"@/registry/ouro/components/ouro/text/heading\";\nimport { Text } from \"@/registry/ouro/components/ouro/text/text\";\nimport { announce as speak } from \"@/registry/ouro/lib/ouro/announce\";\nimport { useAppearanceClassNameCheck } from \"@/registry/ouro/lib/ouro/class-name-check\";\nimport { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { useFocusHandoff } from \"@/registry/ouro/lib/ouro/focus-handoff\";\nimport { useMergedRef } from \"@/registry/ouro/lib/ouro/refs\";\nimport { useOuro } from \"@/registry/ouro/lib/ouro/use-ouro\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\nimport { useReducedMotion } from \"@/registry/ouro/lib/ouro/use-reduced-motion\";\n\n/** The props Moment adds to the `<div>` attributes it passes through. */\nexport interface MomentOwnProps {\n  /**\n   * What the moment is about. `empty`: nothing here yet. `loading`: on its way, with a\n   * spinner when there is no art. `error`: something failed. `first-run`: a first run or a\n   * welcome (`welcome` is the same kind by its older name, and the root says `first-run`).\n   * `success`: something finished, which celebrates (see `celebrate`). `ask`: something the\n   * app, or an agent working for the person, asks them to look at; show it with\n   * `size=\"inline\"` in a slot of its own, such as a header strip or a notices area, never over\n   * the content. The kind colours the art's `currentColor` from the theme and is on the root\n   * as `data-moment`.\n   * @claim \"`ask`: something the app, or an\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment ask > docks in the slot it is given as one row, is heard when asked, and comes back after dismissFor)\n   * @default \"empty\"\n   * @claim \"`loading`: on its way, with a\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment > shows a spinner for a loading moment without art, sized to the layout)\n   * @claim \"`welcome` is the same kind by\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment > takes welcome as first-run's older name, and says first-run)\n   * @claim \"The kind colours the art's `currentColor`\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment > names its kind in data-moment and colours the art from the theme by kind)\n   */\n  kind?: \"empty\" | \"loading\" | \"error\" | \"first-run\" | \"welcome\" | \"success\" | \"ask\" | (string & { 'Use \"empty\", \"loading\", \"error\", \"first-run\", \"success\" or \"ask\"; info is \"empty\"': never }) | undefined;\n  /**\n   * What happened or what is here, in a few words: \"Inbox cleared\". Required, because it is\n   * what a screen reader finds.\n   */\n  title: string;\n  /** One line on what to do or what it means: \"Messages you send show up here.\" */\n  description?: ReactNode;\n  /**\n   * The picture: any node, usually an inline SVG, which fills the art's height (160px, 96px\n   * when the moment is narrower than 24rem, 24px inline; none when quiet). It is decorative\n   * and hidden from screen readers unless you pass `artLabel`. Draw it with `currentColor`\n   * and the theme's variables so it follows the kind, the theme and dark mode. With reduced\n   * motion, its CSS animations stop and its SVG animations pause. Its motion has a budget too:\n   * its loops settle at the end of their turn about 5 s after it appears, and with a `dismissKey`\n   * or `id` its entrance plays once a session, so a moment that comes back as people switch\n   * views or filters arrives still.\n   * @claim \"Its motion has a budget too:\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment motion budget > settles the art's loops at the end of their turn within 5 s, SVG animations too, and leaves other motion alone)\n   * @claim \"Its motion has a budget too:\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment motion budget > plays the art's entrance once a session for a moment with a key, and every time without one)\n   * @claim \"which fills the art's height (160px,\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment sizes > gives the art 160px, 96px in a pane narrower than 24rem, and 24px inline)\n   * @claim \"It is decorative and hidden from\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment > hides the art from screen readers, or names it with artLabel)\n   * @claim \"With reduced motion, its CSS animations\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment motion > stops the art's CSS animations and pauses its SVG animations with reduced motion, and lets them run again after)\n   */\n  art?: ReactNode;\n  /** Names the art for screen readers (`role=\"img\"`), for a picture that says something the title does not. */\n  artLabel?: string | undefined;\n  /**\n   * Which picture this is, such as a pose (\"waving\", \"pedalling\"), for checkers, tests and\n   * styles: the art carries it as `data-moment-art`, which it has, empty, whenever there is\n   * art. Not shown or spoken.\n   * @claim \"the art carries it as `data-moment-art`,\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment > marks its art with data-moment-art, carrying artName)\n   */\n  artName?: string | undefined;\n  /** The way forward, usually one `Button`: `action={<Button onClick={compose}>New message</Button>}`. */\n  action?: ReactNode;\n  /**\n   * A second, quieter way, beside `action`: `secondaryAction={<Button variant=\"plain\">Learn more</Button>}`. Two at most.\n   * @claim \"Two at most.\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment > renders the art, an <h3> title, the line and up to two actions)\n   */\n  secondaryAction?: ReactNode;\n  /**\n   * The title's heading level. Pick the level below the section the moment sits in. Inline,\n   * the title is plain text unless you pass one.\n   * @default 3, and no heading with `size=\"inline\"`\n   * @claim \"3, and no heading with\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment sizes > is one row inline, with a plain-text title unless given a heading level)\n   */\n  headingLevel?: 2 | 3 | 4 | 5 | 6 | (number & { \"Use 2 to 6, one below the section's heading\": never }) | undefined;\n  /**\n   * `default` stacks the art, title, line and actions in the space it is given. `hero` does too,\n   * with art up to 220px tall, for the main state of a large, otherwise empty pane; narrower than\n   * 24rem it holds at 96px, as `default` does. `inline` is a single row with 24px art, for a\n   * \"working\" row in a list or toolbar; in a slot too narrow for its words and its actions, the\n   * actions move under the words.\n   * @default \"default\"\n   * @claim \"`hero` does too, with art up\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment sizes > gives hero art 220px, and 96px in a pane narrower than 24rem)\n   * @claim \"in a slot too narrow for its\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment ask > moves its actions under its words in a slot too narrow for both, so the words keep their room)\n   * @claim \"`inline` is a single row with\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment sizes > gives the art 160px, 96px in a pane narrower than 24rem, and 24px inline)\n   * @claim \"`inline` is a single row with\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment sizes > is one row inline, with a plain-text title unless given a heading level)\n   */\n  size?: \"default\" | \"hero\" | \"inline\" | (string & { 'Use \"default\", \"hero\" or \"inline\"; for a compact moment use quiet': never }) | undefined;\n  /**\n   * Words only, in a compact row: the title and one line, with no art and no celebration (a\n   * loading moment keeps its small spinner). For dense panes, and for people who want less:\n   * `OuroProvider`'s `quiet` sets it for the whole app, and `MomentProvider` for a part of it.\n   * @default the nearest `MomentProvider`'s `quiet`, else `OuroProvider`'s, else `false`\n   * @claim \"Words only, in a compact row:\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment quiet > keeps its words and drops its art and celebration under OuroProvider's quiet, unless MomentProvider or the prop says otherwise)\n   * @claim \"Words only, in a compact row:\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment quiet > renders a compact row from the prop or from MomentProvider, and the prop wins)\n   */\n  quiet?: boolean | undefined;\n  /**\n   * A short flourish when the moment appears: a soft disc swells from behind the art and four\n   * sparks grow and fade, all inside the art's frame. With reduced motion only the disc fades.\n   * Never when quiet or inline. Capped with `cap`.\n   * @default `true` for `kind=\"success\"`, otherwise `false`\n   * @claim \"A short flourish when the moment\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment > stays in the page's flow, and its celebration stays inside the art's frame)\n   * @claim \"A short flourish when the moment\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment motion > swells the disc and grows the sparks when it celebrates, and with reduced motion only fades the disc)\n   * @claim \"Never when quiet or inline.\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment quiet > never celebrates when quiet or inline)\n   * @claim \"With reduced motion only the disc fades.\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment motion > swells the disc and grows the sparks when it celebrates, and with reduced motion only fades the disc)\n   */\n  celebrate?: boolean | undefined;\n  /**\n   * Shows the flourish at most `times` times `per` day, week, 30-day month or ever, counted in\n   * `localStorage` under the moment's `dismissKey`, or its `id`; after that the moment is\n   * quiet. Without a key the flourish shows every time the moment appears.\n   * @claim \"Without a key the flourish shows\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment cap > celebrates every time without a cap, or without a key to count under)\n   * @claim \"Shows the flourish at most `times`\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment cap > celebrates at most times per period, then again once the period has passed)\n   */\n  cap?: { times: number; per: \"day\" | \"week\" | \"month\" | \"ever\" | (string & { 'Use \"day\", \"week\", \"month\" or \"ever\"': never }) } | undefined;\n  /**\n   * Keeps a dismissal: once the person closes the moment, it stays closed on every visit and in\n   * every tab, stored in `localStorage` as `ouro-moment:dismissed:<dismissKey>`. Shows the\n   * close button. With it the moment renders nothing until the browser has said whether it\n   * was dismissed, so a server-rendered page never flashes a closed moment.\n   * @claim \"Keeps a dismissal: once the person closes\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment dismissal > stays dismissed through dismissKey, after a remount and in another tab)\n   * @claim \"With it the moment renders nothing\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment dismissal > renders nothing on the server with a dismissKey, and everything without one)\n   */\n  dismissKey?: string | undefined;\n  /**\n   * How long a dismissal through `dismissKey` lasts: an hour, a day, a week or 30 days; then the\n   * moment may show again. Without it a dismissal lasts for good. For an ask that may come back\n   * later, but not straight away.\n   * @claim \"How long a dismissal through `dismissKey`\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment ask > docks in the slot it is given as one row, is heard when asked, and comes back after dismissFor)\n   */\n  dismissFor?: \"hour\" | \"day\" | \"week\" | \"month\" | (string & { 'Use \"hour\", \"day\", \"week\" or \"month\"': never }) | undefined;\n  /**\n   * Shows a quiet close button. Pressing it hides the moment, hands focus to what follows it,\n   * and calls this.\n   * @claim \"Pressing it hides the moment, hands\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment dismissal > closes from the keyboard, calls onDismiss and hands focus on)\n   */\n  onDismiss?: (() => void) | undefined;\n  /** The close button's accessible name, for other languages. @default \"Dismiss\" */\n  dismissLabel?: string | undefined;\n  /**\n   * Speaks a `success`, `error` or `ask` moment politely to screen readers when it appears: the title,\n   * then the description when it is text. Other kinds are never spoken.\n   * @claim \"Other kinds are never spoken.\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment > speaks a success or error moment politely only when asked)\n   * @claim \"Speaks a `success`, `error` or `ask`\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment > speaks a success or error moment politely only when asked)\n   */\n  announce?: boolean | undefined;\n  /** Layout only: margins, width, grid placement (`mt-6`). Appearance classes warn in development; use `kind` and `quiet`. */\n  className?: string | undefined;\n  ref?: Ref<HTMLDivElement> | undefined;\n\n  /** Not a prop. Ouro UI uses `art`: `<Moment art={<Illustration />}>`. */\n  icon?: { 'Use art={<Illustration />}': never };\n  /** Not a prop. Ouro UI uses `art`: `<Moment art={<Illustration />}>`. */\n  illustration?: { 'Use art={<Illustration />}': never };\n  /** Not a prop. Ouro UI uses `title`: `<Moment title=\"No messages yet\">`. */\n  heading?: { 'Use <Moment title=\"No messages yet\">': never };\n  /** Not a prop. Ouro UI uses `description`: `<Moment description=\"Messages you send show up here.\">`. */\n  body?: { 'Use <Moment description=\"Messages you send show up here.\">': never };\n  /** Not a prop. Ouro UI uses `action` and `secondaryAction`: `<Moment action={<Button>Retry</Button>}>`. */\n  actions?: { 'Use action={<Button>Retry</Button>} and secondaryAction': never };\n  /** Not a prop. Ouro UI uses `onDismiss`: `<Moment onDismiss={() => setOpen(false)}>`. */\n  onClose?: { 'Use onDismiss={() => setOpen(false)}': never };\n  /** Not a prop. Ouro UI uses `kind`: `<Moment kind=\"error\">`. */\n  variant?: { 'Use kind=\"error\"': never };\n}\n\n/** Props for {@link Moment}: its own props and the div attributes it passes through. */\nexport type MomentProps = Omit<HTMLAttributes<HTMLDivElement>, keyof MomentOwnProps> & MomentOwnProps;\n\n/** Props for {@link MomentProvider}. */\nexport interface MomentProviderProps {\n  /**\n   * Renders every `Moment` inside quiet, unless the moment sets `quiet` itself.\n   * @default `OuroProvider`'s `quiet`\n   * @claim \"Renders every `Moment` inside quiet, unless\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment quiet > renders a compact row from the prop or from MomentProvider, and the prop wins)\n   */\n  quiet?: boolean | undefined;\n  /** The part of the app it applies to. */\n  children: ReactNode;\n}\n\nconst MomentContext = createContext<boolean | undefined>(undefined);\n\n/**\n * Sets `quiet` for every `Moment` inside it, so an app can make its moments compact\n * everywhere, for a dense layout or for people who asked for less. A moment's own `quiet`\n * wins.\n *\n * Use `Moment`'s `quiet` prop instead for one moment.\n *\n * @claim \"Sets `quiet` for every `Moment` inside\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment quiet > renders a compact row from the prop or from MomentProvider, and the prop wins)\n *\n * @group Feedback\n * @see https://ui.ouroboros.bot/docs/moment\n *\n * @example\n * <MomentProvider quiet={settings.quietMoments}>\n *   <App />\n * </MomentProvider>\n */\nexport function MomentProvider({ quiet, children }: MomentProviderProps): JSX.Element {\n  return <MomentContext value={quiet}>{children}</MomentContext>;\n}\n\nconst levels = [2, 3, 4, 5, 6] as const;\nconst sizes = [\"default\", \"hero\", \"inline\"] as const;\nconst spoken = new Set<MomentKind>([\"success\", \"error\", \"ask\"]);\n\n// A slot holds something to render unless it is undefined, null or false.\nconst present = (node: ReactNode) => node !== undefined && node !== null && node !== false;\n\nfunction CloseIcon(): JSX.Element {\n  return (\n    <svg aria-hidden=\"true\" viewBox=\"0 0 20 20\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" className=\"size-4\">\n      <path d=\"m5.5 5.5 9 9m0-9-9 9\" />\n    </svg>\n  );\n}\n\n/**\n * A moment in an app's life, shown in the space it is given: nothing here yet, on its way,\n * something failed, a first run, or something finished. It holds art (any node, usually an\n * inline SVG), a title, one line and up to two actions. It renders in the page's flow and\n * never floats over what the person is using; its celebration stays inside the art's frame.\n *\n * Moments behave so they never get in the way: the art is decorative unless labelled, the\n * art's own motion stops with reduced motion, the close button keeps a dismissal through\n * `dismissKey`, `cap` limits how often a success celebrates, and `quiet` (or\n * `MomentProvider`) makes them compact. The root carries `data-moment` (the kind),\n * `data-celebrate` while it celebrates and `data-quiet` when quiet, and the art\n * `data-moment-art` (its `artName`).\n *\n * Use `Empty` instead for a plain empty list with an icon and no art, `Alert` for a message\n * about something that happened beside the content, `Skeleton` for the shape of content that\n * is loading, and `toast()` to confirm an everyday action.\n *\n * @claim \"It holds art (any node, usually\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment > renders the art, an <h3> title, the line and up to two actions)\n * @claim \"Moments behave so they never get\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment > hides the art from screen readers, or names it with artLabel)\n * @claim \"Moments behave so they never get\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment motion > stops the art's CSS animations and pauses its SVG animations with reduced motion, and lets them run again after)\n * @claim \"Moments behave so they never get\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment dismissal > stays dismissed through dismissKey, after a remount and in another tab)\n * @claim \"Moments behave so they never get\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment cap > celebrates at most times per period, then again once the period has passed)\n * @claim \"Moments behave so they never get\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment quiet > renders a compact row from the prop or from MomentProvider, and the prop wins)\n * @claim \"It renders in the page's flow\" registry/ouro/components/ouro/moment/moment.test.tsx verify:testExists(registry/ouro/components/ouro/moment/moment.test.tsx::Moment > stays in the page's flow, and its celebration stays inside the art's frame)\n * @group Feedback\n * @see https://ui.ouroboros.bot/docs/moment\n *\n * @example\n * <Moment\n *   art={<EmptyInbox />}\n *   title=\"No messages yet\"\n *   description=\"Messages you send show up here.\"\n *   action={<Button onClick={compose}>New message</Button>}\n * />\n * <Moment kind=\"success\" art={<Done />} title=\"All caught up\" dismissKey=\"caught-up\" cap={{ times: 1, per: \"day\" }} />\n */\nexport function Moment(props: MomentProps): JSX.Element | null {\n  const {\n    kind: kindProp = \"empty\",\n    title,\n    description,\n    art,\n    artLabel,\n    artName,\n    action,\n    secondaryAction,\n    headingLevel,\n    size: sizeProp = \"default\",\n    quiet: quietProp,\n    celebrate,\n    cap,\n    dismissKey,\n    dismissFor,\n    onDismiss,\n    dismissLabel = \"Dismiss\",\n    announce,\n    className,\n    ref,\n    // Guard props (hint types), dropped here so they never reach the DOM.\n    icon,\n    illustration,\n    heading,\n    body,\n    actions,\n    onClose,\n    variant,\n    ...rest\n  } = props;\n  // `welcome` is first-run's older name.\n  const named = kindProp === \"welcome\" ? \"first-run\" : kindProp;\n  const kind: MomentKind = Object.hasOwn(kindToneClass, named) ? (named as MomentKind) : \"empty\";\n  const provided = useContext(MomentContext);\n  const ouro = useOuro();\n  const quiet = quietProp ?? provided ?? ouro.quiet === true;\n  const layout = sizeProp === \"inline\" ? \"inline\" : quiet ? \"quiet\" : \"default\";\n  const level = headingLevel === undefined ? (layout === \"inline\" ? undefined : 3) : (levels as readonly unknown[]).includes(headingLevel) ? (headingLevel as (typeof levels)[number]) : 3;\n  const per: MomentPeriod = cap !== undefined && Object.hasOwn(periods, cap.per) ? (cap.per as MomentPeriod) : \"day\";\n  const times = cap === undefined ? undefined : Number.isInteger(cap.times) && cap.times >= 0 ? cap.times : 1;\n  const key = dismissKey ?? rest.id;\n\n  useAppearanceClassNameCheck(\n    \"Moment\",\n    className,\n    process.env.NODE_ENV !== \"production\"\n      ? (token: string) => `remove \"${token}\"; Moment takes its look from kind and quiet`\n      : // Stryker disable next-line StringLiteral: production only; the check never runs there.\n        /* istanbul ignore next @preserve -- production only */ \"\",\n  );\n  useDevWarnings(\n    \"Moment\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => [\n          !title && [\"title is required; it says what the moment is about\", '<Moment title=\"No messages yet\">'],\n          kind !== named && [`kind=\"${String(kindProp)}\" is not a kind; use \"empty\", \"loading\", \"error\", \"first-run\", \"success\", \"ask\"`, '<Moment kind=\"empty\">'],\n          !(sizes as readonly string[]).includes(sizeProp) && [`size=\"${String(sizeProp)}\" is not a size; use \"default\", \"hero\", \"inline\"`, \"<Moment quiet>\"],\n          headingLevel !== undefined && level !== headingLevel && [`headingLevel must be 2, 3, 4, 5 or 6, got ${String(headingLevel)}`, \"<Moment headingLevel={2}>\"],\n          cap !== undefined && per !== cap.per && [`cap per \"${String(cap.per)}\" is not a period; use \"day\", \"week\", \"month\", \"ever\"`, '<Moment cap={{ times: 1, per: \"day\" }}>'],\n          cap !== undefined && times !== cap.times && [`cap times must be a whole number, 0 or more, got ${String(cap.times)}`, '<Moment cap={{ times: 1, per: \"day\" }}>'],\n          cap !== undefined && key === undefined && [\"cap counts showings under dismissKey or id, and this moment has neither\", '<Moment dismissKey=\"caught-up\" cap={{ times: 1, per: \"day\" }}>'],\n          announce === true && !spoken.has(kind) && [`announce speaks only success, error and ask moments, not kind=\"${kind}\"`, '<Moment kind=\"success\" announce>'],\n          dismissFor !== undefined && !Object.hasOwn(dismissPeriods, dismissFor) && [`dismissFor=\"${String(dismissFor)}\" is not a period; use \"hour\", \"day\", \"week\", \"month\"`, '<Moment dismissKey=\"ask\" dismissFor=\"day\">'],\n          dismissFor !== undefined && dismissKey === undefined && [\"dismissFor keeps a dismissal through dismissKey, and this moment has none\", '<Moment dismissKey=\"ask\" dismissFor=\"day\">'],\n          (icon !== undefined || illustration !== undefined) && [`${icon !== undefined ? \"icon\" : \"illustration\"} is not a prop`, \"<Moment art={<Illustration />}>\"],\n          heading !== undefined && [\"heading is not a prop\", `<Moment title=\"${String(heading)}\">`],\n          body !== undefined && [\"body is not a prop\", `<Moment description=\"${String(body)}\">`],\n          actions !== undefined && [\"actions is not a prop\", \"<Moment action={<Button>…</Button>} secondaryAction={<Button>…</Button>}>\"],\n          onClose !== undefined && [\"onClose is not a prop\", \"<Moment onDismiss={() => setOpen(false)}>\"],\n          variant !== undefined && [\"variant is not a prop\", `<Moment kind=\"${Object.hasOwn(kindToneClass, String(variant)) ? String(variant) : \"error\"}\">`],\n        ]\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n\n  const forMs = dismissFor === undefined ? undefined : Object.hasOwn(dismissPeriods, dismissFor) ? dismissPeriods[dismissFor as keyof typeof dismissPeriods] : dismissPeriods.day;\n  // A kept dismissal is read after hydration: until then a moment with a dismissKey renders nothing.\n  const kept = useSyncExternalStore(\n    subscribeMoments,\n    () => dismissKey !== undefined && isDismissed(dismissKey, forMs, Date.now()),\n    () => dismissKey !== undefined,\n  );\n  const [closed, setClosed] = useState(false);\n  const visible = !kept && !closed;\n\n  // The celebration starts a frame after the moment appears, once per appearance, within its cap.\n  const celebratory = layout === \"default\" && (celebrate ?? kind === \"success\");\n  const [celebrating, setCelebrating] = useState(false);\n  const started = useRef(false);\n  useEffect(() => {\n    if (!celebratory || !visible) {\n      requestAnimationFrame(() => setCelebrating(false));\n      started.current = false;\n      return;\n    }\n    if (started.current) return;\n    started.current = true;\n    if (key !== undefined && times !== undefined && !takeShowing(key, { times, per }, Date.now())) return;\n    requestAnimationFrame(() => setCelebrating(true));\n  }, [celebratory, visible, key, times, per]);\n  const flourish = celebrating && celebratory;\n\n  const speakText = typeof description === \"string\" ? `${title}. ${description}` : title;\n  const speaks = announce === true && spoken.has(kind) && visible;\n  useEffect(() => {\n    if (speaks) speak(speakText);\n  }, [speaks, speakText]);\n\n  // SVG animations ignore CSS, so the art's are paused here while reduced motion is on.\n  // Stryker disable next-line BooleanLiteral: the server's guess lasts only until hydration, and the effect that reads it runs after the live value replaces it.\n  const reduced = useReducedMotion(false);\n  const artRef = useRef<HTMLDivElement>(null);\n  useEffect(() => {\n    const host = artRef.current;\n    if (!reduced || !host) return;\n    const svgs = [...host.querySelectorAll(\"svg\")];\n    for (const svg of svgs) svg.pauseAnimations();\n    return () => svgs.forEach((svg) => svg.unpauseAnimations());\n  }, [reduced, art]);\n\n  // The art's own motion has a budget: its entrance plays once a session for a moment with a key,\n  // and its loops settle, at the end of the turn they are on, a few seconds after it appears.\n  // Whether this moment's key had already appeared is asked once per key, so a second run of the\n  // effect, as React's StrictMode makes in development, does not count as a second showing.\n  const repeat = useRef<{ key: string; seen: boolean }>(undefined);\n  useLayoutEffect(() => {\n    const host = artRef.current;\n    if (!host || key === undefined) return;\n    if (repeat.current?.key !== key) repeat.current = { key, seen: seenThisSession(key) };\n    if (!repeat.current.seen) return;\n    for (const animation of host.getAnimations({ subtree: true })) if (animation.effect!.getComputedTiming().endTime !== Infinity) animation.finish();\n  }, [art, key]);\n  useEffect(() => {\n    const host = artRef.current;\n    if (!host) return;\n    const timer = setTimeout(() => {\n      for (const animation of host.getAnimations({ subtree: true })) {\n        const timing = animation.effect!.getComputedTiming();\n        if (timing.endTime === Infinity) animation.effect!.updateTiming({ iterations: timing.currentIteration! + 1 });\n      }\n      for (const svg of host.querySelectorAll(\"svg\")) {\n        svg.pauseAnimations();\n        svg.setCurrentTime(0);\n      }\n    }, SETTLE_MS);\n    return () => clearTimeout(timer);\n  }, [art, kind]);\n\n  const merged = useMergedRef(ref, useFocusHandoff<HTMLDivElement>());\n  if (!visible) return null;\n\n  const dismissible = onDismiss !== undefined || dismissKey !== undefined;\n  const dismiss = () => {\n    setClosed(true);\n    if (dismissKey !== undefined) keepDismissed(dismissKey, forMs === undefined ? undefined : Date.now());\n    onDismiss?.();\n  };\n  const hasArt = present(art) && !quiet;\n  const spinner = !hasArt && kind === \"loading\";\n\n  const titleNode =\n    level === undefined ? (\n      <span className=\"min-w-0 truncate text-sm font-medium text-foreground\">{title}</span>\n    ) : (\n      <Heading level={level} size={layout === \"default\" ? \"md\" : \"sm\"} className={layout === \"default\" ? undefined : \"min-w-0 truncate text-nowrap\"}>\n        {title}\n      </Heading>\n    );\n  const descriptionNode =\n    !present(description) ? null : layout === \"default\" ? (\n      <Text as=\"div\" size=\"sm\" tone=\"muted\">\n        {description}\n      </Text>\n    ) : (\n      <Text as={layout === \"inline\" ? \"span\" : \"div\"} size=\"sm\" tone=\"muted\" truncate className=\"min-w-0\">\n        {description}\n      </Text>\n    );\n  const hasActions = present(action) || present(secondaryAction);\n\n  return (\n    <div\n      {...rest}\n      ref={merged}\n      data-ouro=\"moment\"\n      data-moment={kind}\n      data-quiet={quiet ? \"\" : undefined}\n      data-celebrate={flourish ? \"\" : undefined}\n      data-open={flourish ? \"\" : undefined}\n      className={cn(rootClass[layout], dismissible && layout === \"default\" && \"pt-12\", className)}\n    >\n      {spinner && (\n        <span aria-hidden=\"true\" data-ouro-moment-art=\"\" className={cn(\"grid shrink-0 place-items-center\", kindToneClass[kind])}>\n          <Spinner size={layout === \"default\" ? \"lg\" : layout === \"quiet\" ? \"md\" : \"sm\"} />\n        </span>\n      )}\n      {hasArt && (\n        <div data-ouro-moment-frame=\"\" className={cn(artFrameClass[layout === \"inline\" ? \"inline\" : sizeProp === \"hero\" ? \"hero\" : \"default\"], kindToneClass[kind])}>\n          {flourish && <span aria-hidden=\"true\" data-ouro-part=\"halo\" className={haloClass} />}\n          {flourish &&\n            sparkClasses.map((spark) => (\n              <svg key={spark} aria-hidden=\"true\" viewBox=\"0 0 12 12\" data-ouro-part=\"sparkle\" className={cn(sparkleClass, spark)}>\n                <path d=\"M6 0Q6.7 5.3 12 6 6.7 6.7 6 12 5.3 6.7 0 6 5.3 5.3 6 0Z\" fill=\"currentColor\" />\n              </svg>\n            ))}\n          <div\n            ref={artRef}\n            {...(artLabel ? { role: \"img\", \"aria-label\": artLabel } : { \"aria-hidden\": true })}\n            data-ouro-moment-art=\"\"\n            data-moment-art={artName ?? \"\"}\n            className=\"relative flex h-(--ouro-moment-art) max-w-full items-center justify-center *:h-(--ouro-moment-art) *:w-auto *:max-w-full motion-reduce:**:[animation:none]!\"\n          >\n            {art}\n          </div>\n        </div>\n      )}\n      <div className={layout === \"default\" ? \"flex min-w-0 flex-col items-center gap-1.5\" : layout === \"quiet\" ? \"flex min-w-0 flex-1 flex-col\" : \"flex min-w-0 flex-[1_1_12rem] items-baseline gap-2\"}>\n        {titleNode}\n        {descriptionNode}\n      </div>\n      {hasActions && (\n        <div data-ouro-moment-actions=\"\" className={layout === \"default\" ? \"flex flex-wrap items-center justify-center gap-2 pt-1\" : \"flex shrink-0 items-center gap-2\"}>\n          {action}\n          {secondaryAction}\n        </div>\n      )}\n      {dismissible && (\n        <Button\n          variant=\"plain\"\n          tone=\"secondary\"\n          size=\"sm\"\n          aria-label={dismissLabel}\n          data-ouro-control=\"moment\"\n          data-ouro-part=\"dismiss\"\n          onClick={dismiss}\n          className={cn(\"w-(--ouro-button-h) shrink-0 px-0\", layout === \"default\" ? \"absolute end-2 top-2\" : \"-me-1\")}\n        >\n          <CloseIcon />\n        </Button>\n      )}\n    </div>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/moment/moment.tsx"
    }
  ],
  "docs": "A moment in an app's life, shown in the space it is given: nothing here yet, on its way, something failed, a first run, or something finished. Import: import { Moment } from \"@/components/ouro/moment/moment\", with @/components replaced by your components alias (aliases.components in components.json, such as ~/components). Also installed: button, heading, spinner, text, the helpers they import in lib/ouro. Needs ouro-base in your stylesheet: add that item once per app, from the same place as this one, if you have not. Docs: https://ui.ouroboros.bot/docs/moment.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}