{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "popover",
  "title": "Popover",
  "description": "A small non-modal panel beside its trigger, for a short form or a few choices: a share link, filters, a quick edit.",
  "dependencies": [
    "@base-ui/react@^1.8.0"
  ],
  "registryDependencies": [
    "@ouro/lib-class-name-check",
    "@ouro/lib-cn",
    "@ouro/lib-dev",
    "@ouro/lib-env",
    "@ouro/lib-floating",
    "@ouro/lib-last-input",
    "@ouro/lib-open-mode",
    "@ouro/lib-page-scroll-hold",
    "@ouro/lib-portal-container",
    "@ouro/lib-use-dev-messages",
    "@ouro/lib-use-keyboard-scrollable",
    "@ouro/lib-use-sheet-presentation",
    "@ouro/sheet"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/popover/popover-parts.tsx",
      "content": "\"use client\";\n\nimport { Popover as BasePopover } from \"@base-ui/react/popover\";\nimport { createContext, useContext, type CSSProperties, type JSX } from \"react\";\nimport { useAppearanceClassNameCheck } from \"@/registry/ouro/lib/ouro/class-name-check\";\nimport { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { devThrow } from \"@/registry/ouro/lib/ouro/dev\";\nimport {\n  floatingAlign,\n  floatingHint,\n  floatingMotionClass,\n  floatingPlacementWarnings,\n  floatingPortalClass,\n  floatingSide,\n  floatingSurfaceClass,\n  type FloatingAlign,\n  type FloatingSide,\n} from \"@/registry/ouro/lib/ouro/floating\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\nimport { holdPageAtPress } from \"@/registry/ouro/lib/ouro/page-scroll-hold\";\nimport { PortalScope, usePortalContainer } from \"@/registry/ouro/lib/ouro/portal-container\";\nimport { popoverCloseClass } from \"@/registry/ouro/components/ouro/popover/popover-styles\";\n\nexport type { FloatingAlign as PopoverAlign, FloatingSide as PopoverSide } from \"@/registry/ouro/lib/ouro/floating\";\n\nconst PopoverContext = createContext(false);\n\n/** The JSX that puts a part in its place, for the dev message when it is not. */\nfunction shape(inner: string): string {\n  return `<PopoverRoot><PopoverTrigger render={<Button>Open</Button>} /><PopoverPortal><PopoverPositioner><PopoverPopup>${inner}</PopoverPopup></PopoverPositioner></PopoverPortal></PopoverRoot>`;\n}\n\n/** Throws in development, with the JSX the part belongs in, unless it sits inside a popover root. */\nfunction usePopoverPart(part: string, inner: string): void {\n  if (!useContext(PopoverContext)) {\n    devThrow(\n      part,\n      \"must be rendered inside <PopoverRoot>\",\n      process.env.NODE_ENV !== \"production\" ? shape(inner) : /* istanbul ignore next @preserve -- production only */ \"\",\n    );\n  }\n}\n\n/**\n * Part: the state owner of a popover built from parts. Use the `Popover` component\n * instead unless its props cannot express your layout; `Popover` also becomes a bottom\n * sheet on phones with `presentation=\"auto\"`, which parts do not.\n *\n * @example\n * <PopoverRoot>\n *   <PopoverTrigger render={<Button>Share</Button>} />\n *   <PopoverPortal>\n *     <PopoverPositioner side=\"bottom\" align=\"start\">\n *       <PopoverPopup>\n *         <PopoverTitle>Share recipe</PopoverTitle>\n *         …\n *       </PopoverPopup>\n *     </PopoverPositioner>\n *   </PopoverPortal>\n * </PopoverRoot>\n */\nexport function PopoverRoot(props: BasePopover.Root.Props): JSX.Element {\n  return (\n    <PopoverContext.Provider value>\n      <BasePopover.Root {...props} />\n    </PopoverContext.Provider>\n  );\n}\n\n/**\n * Part: the button that opens and closes the popover. Pass your button as `render={<Button>Open</Button>}`.\n * The trigger anchors the popover, which opens on click while the button is pressed, so the\n * press scale is cancelled on it (Button's pressed wash still shows) and the popover lands once.\n */\nexport function PopoverTrigger({ style, onPointerDown, onKeyDown, ...props }: BasePopover.Trigger.Props): JSX.Element {\n  usePopoverPart(\"PopoverTrigger\", \"…\");\n  const noScale = (own?: CSSProperties): CSSProperties => ({ ...own, [\"--ouro-press-scale\" as string]: 1 });\n  return (\n    <BasePopover.Trigger\n      {...(props.render === undefined ? { className: \"forced-colors:border forced-colors:border-solid\", \"data-ouro-control\": \"popover\", \"data-ouro-part\": \"trigger\" } : {})}\n      {...props}\n      onPointerDown={(event) => {\n        holdPageAtPress.button.onPointerDown(event);\n        onPointerDown?.(event);\n      }}\n      onKeyDown={(event) => {\n        holdPageAtPress.button.onKeyDown(event);\n        onKeyDown?.(event);\n      }}\n      style={typeof style === \"function\" ? (state) => noScale(style(state)) : noScale(style)}\n    />\n  );\n}\n\n/**\n * Part: moves the popover to the end of `<body>`, in its own stacking context at the\n * `--ouro-layer` z-index (50 by default, from ouro-base.css), like Dialog and Sheet.\n * Raise it in a `:root` rule of your own after the Ouro tokens: `:root { --ouro-layer: 60; }`.\n * @claim \"Part: moves the popover to the\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::Popover stacking > puts the portal on the --ouro-layer level, as its own stacking context)\n * @claim \"Part: moves the popover to the\" registry/ouro/theme/ouro-base.css verify:fileLine(registry/ouro/theme/ouro-base.css, /^\\s+--ouro-layer:\\s50;/)\n */\nexport function PopoverPortal(props: Omit<BasePopover.Portal.Props, \"className\">): JSX.Element {\n  usePopoverPart(\"PopoverPortal\", \"…\");\n  const portal = usePortalContainer(\"Popover\", true);\n  return (\n    <BasePopover.Portal {...portal} {...props} data-ouro=\"popover-portal\" className={floatingPortalClass}>\n      <PortalScope>{props.children}</PortalScope>\n    </BasePopover.Portal>\n  );\n}\n\n/** Props for {@link PopoverPositioner}. */\nexport type PopoverPositionerProps = Omit<BasePopover.Positioner.Props, \"className\" | \"side\" | \"align\"> & {\n  /**\n   * The side of the trigger the popover sits on; it flips when there is no room. @default \"bottom\"\n   *\n   * @claim \"it flips when there is no room\" https://base-ui.com/react/components/popover verify:urlOk(https://base-ui.com/react/components/popover)\n   */\n  side?: FloatingSide | (string & { 'Use \"top\", \"bottom\", \"left\" or \"right\"': never }) | undefined;\n  /** How the popover lines up with the trigger along that side. @default \"center\" */\n  align?: FloatingAlign | (string & { 'Use \"start\", \"center\" or \"end\": left is \"start\", right is \"end\"': never }) | undefined;\n};\n\n/**\n * Part: places the popover beside its trigger (or `anchor`), 8px away and at least 8px\n * from the screen edges, and flips it to the other side when there is no room.\n * @claim \"Part: places the popover beside its\" registry/ouro/components/ouro/popover/popover-parts.tsx verify:fileLine(registry/ouro/components/ouro/popover/popover-parts.tsx, /sideOffset=\\{8\\}\\scollisionPadding=\\{8\\}/)\n * @claim \"Part: places the popover beside its\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::Popover > opens below its trigger as a non-modal dialog named by its title)\n */\nexport function PopoverPositioner({ side: sideProp, align: alignProp, ...props }: PopoverPositionerProps): JSX.Element {\n  usePopoverPart(\"PopoverPositioner\", \"…\");\n  useDevWarnings(\n    \"PopoverPositioner\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => floatingPlacementWarnings(\"<PopoverPositioner\", sideProp, \"bottom\", alignProp, undefined)\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n  return <PopoverPositionerUnchecked {...props} side={floatingSide(sideProp, \"bottom\")} align={floatingAlign(alignProp)} />;\n}\n\n/**\n * The positioner without its own prop checks, for `Popover`, which checks its own.\n *\n * @internal\n */\nexport function PopoverPositionerUnchecked(\n  props: Omit<BasePopover.Positioner.Props, \"className\" | \"side\" | \"align\"> & { side: FloatingSide; align: FloatingAlign },\n): JSX.Element {\n  usePopoverPart(\"PopoverPositioner\", \"…\");\n  return <BasePopover.Positioner sideOffset={8} collisionPadding={8} {...props} data-ouro=\"popover-positioner\" />;\n}\n\n/** Props for {@link PopoverPopup}. `className` is for layout only (width, padding). */\nexport type PopoverPopupProps = Omit<BasePopover.Popup.Props, \"className\"> & { className?: string | undefined };\n\n/**\n * Part: the popover panel, 18rem wide (never wider than the screen allows) with 1rem of\n * padding. It grows from the trigger over 200ms on the ease-out token and fades; reduced motion\n * keeps only the fade. Put a `PopoverTitle` first: it names the popover.\n * @claim \"Part: the popover panel, 18rem wide\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::Popover > is 18rem wide by default, and className sets layout)\n * @claim \"It grows from the trigger over\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::Popover motion > grows from the trigger's side on the ease-out token and fades)\n * @claim \"It grows from the trigger over\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::Popover motion > drops the scale under reduced motion and keeps the fade)\n */\nexport function PopoverPopup(props: PopoverPopupProps): JSX.Element {\n  useAppearanceClassNameCheck(\n    \"PopoverPopup\",\n    props.className,\n    process.env.NODE_ENV !== \"production\"\n      ? floatingHint(\"<PopoverPopup>\", \"</PopoverPopup>\")\n      : /* istanbul ignore next @preserve -- production only */ \"\",\n  );\n  return <PopoverPopupUnchecked {...props} />;\n}\n\n/**\n * The popup without its own className check, for `Popover`, which checks its own.\n *\n * @internal\n */\nexport function PopoverPopupUnchecked({ className, ...props }: PopoverPopupProps): JSX.Element {\n  usePopoverPart(\"PopoverPopup\", \"…\");\n  return (\n    <BasePopover.Popup\n      {...props}\n      data-ouro=\"popover\"\n      className={cn(\n        floatingSurfaceClass,\n        floatingMotionClass,\n        \"relative flex w-72 max-w-(--available-width) max-h-(--available-height) min-h-0 flex-col gap-2 p-4\",\n        className,\n      )}\n    />\n  );\n}\n\n/** Props for {@link PopoverTitle}. */\nexport type PopoverTitleProps = Omit<BasePopover.Title.Props, \"className\"> & {\n  /** Hides the title visually; it still names the popover for screen readers. */\n  visuallyHidden?: boolean | undefined;\n};\n\n/**\n * Part: the popover's title, which names it. Every popover needs one.\n *\n * @claim \"Every popover needs one\" registry/ouro/components/ouro/popover/popover.test.tsx verify:fileLine(registry/ouro/components/ouro/popover/popover.test.tsx, /warns\\swhen\\sthe\\stitle\\sis\\smissing/)\n */\nexport function PopoverTitle({ visuallyHidden, ...props }: PopoverTitleProps): JSX.Element {\n  usePopoverPart(\"PopoverTitle\", \"<PopoverTitle>…</PopoverTitle>…\");\n  return (\n    <BasePopover.Title\n      {...props}\n      data-ouro-popover-title=\"\"\n      className={visuallyHidden ? \"sr-only\" : \"m-0 font-[family-name:var(--font-heading,inherit)] text-sm leading-5 font-semibold text-popover-foreground\"}\n    />\n  );\n}\n\n/** Part: a line under the title that describes the popover. */\nexport function PopoverDescription(props: Omit<BasePopover.Description.Props, \"className\">): JSX.Element {\n  usePopoverPart(\"PopoverDescription\", \"<PopoverTitle>…</PopoverTitle><PopoverDescription>…</PopoverDescription>…\");\n  return (\n    <BasePopover.Description\n      {...props}\n      data-ouro-popover-description=\"\"\n      className=\"m-0 text-sm leading-5 text-pretty text-muted-foreground\"\n    />\n  );\n}\n\n/**\n * Part: closes the popover. Pass your button as `render={<Button>Done</Button>}`. With no\n * `render` it is the screen-reader close button `Popover` uses: hidden until it has\n * keyboard focus, so phone screen-reader users, who have no Escape key, can close it.\n * @claim \"With no `render` it is the\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::Popover > has a close button for screen readers, hidden until it has keyboard focus, labelled by closeLabel)\n * @claim \"With no `render` it is the\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::Popover parts > PopoverTitle hides visually, and PopoverClose without render is the screen-reader close button)\n */\nexport function PopoverClose(props: BasePopover.Close.Props): JSX.Element {\n  usePopoverPart(\"PopoverClose\", \"<PopoverTitle>…</PopoverTitle><PopoverClose>Close</PopoverClose>\");\n  return <BasePopover.Close {...(props.render === undefined ? { className: popoverCloseClass, \"data-ouro-control\": \"popover\", \"data-ouro-part\": \"close\" } : {})} {...props} />;\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/popover/popover-parts.tsx"
    },
    {
      "path": "registry/ouro/components/ouro/popover/popover-styles.ts",
      "content": "export { popoverCloseClass };\n\n// Class strings for Popover and its parts, apart from the components so each component\n// file exports only components (React Fast Refresh). The export list comes first because\n// the shadcn CLI drops comments before a file's first statement.\n\n/**\n * The popover's close button: always present for screen readers (a phone has no Escape\n * key), hidden from view until it has keyboard focus, then shown at the top corner.\n *\n * @internal\n * @claim \"The popover's close button: always present\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::Popover > has a close button for screen readers, hidden until it has keyboard focus, labelled by closeLabel)\n */\nconst popoverCloseClass =\n  \"sr-only focus-visible:top-2 focus-visible:end-2 focus-visible:z-1 focus-visible:m-0 focus-visible:size-auto \" +\n  \"focus-visible:overflow-visible focus-visible:[clip-path:none] focus-visible:px-2 focus-visible:py-1 \" +\n  \"focus-visible:rounded-ouro-md focus-visible:bg-muted focus-visible:text-foreground focus-visible:text-xs focus-visible:leading-4 focus-visible:font-medium \" +\n  \"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring focus-visible:outline-solid\";\n",
      "type": "registry:ui",
      "target": "@components/ouro/popover/popover-styles.ts"
    },
    {
      "path": "registry/ouro/components/ouro/popover/popover.tsx",
      "content": "\"use client\";\n\nimport { useRef, useState, type JSX, type ReactElement, type ReactNode, type RefObject } from \"react\";\nimport { useAppearanceClassNameCheck } from \"@/registry/ouro/lib/ouro/class-name-check\";\nimport { devThrow } from \"@/registry/ouro/lib/ouro/dev\";\nimport { floatingAlign, floatingHint, floatingPlacementWarnings, floatingSide, type FloatingAlign, type FloatingSide } from \"@/registry/ouro/lib/ouro/floating\";\nimport { lastInput } from \"@/registry/ouro/lib/ouro/last-input\";\nimport { checkOpenMode, type TriggerOrOpen } from \"@/registry/ouro/lib/ouro/open-mode\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\nimport { useKeyboardScrollable } from \"@/registry/ouro/lib/ouro/use-keyboard-scrollable\";\nimport { useSheetPresentation } from \"@/registry/ouro/lib/ouro/use-sheet-presentation\";\nimport { SheetFrame } from \"@/registry/ouro/components/ouro/sheet/sheet\";\nimport {\n  PopoverClose,\n  PopoverDescription,\n  PopoverPopupUnchecked,\n  PopoverPortal,\n  PopoverPositionerUnchecked,\n  PopoverRoot,\n  PopoverTitle,\n  PopoverTrigger,\n} from \"@/registry/ouro/components/ouro/popover/popover-parts\";\n\nexport type { PopoverAlign, PopoverSide } from \"@/registry/ouro/components/ouro/popover/popover-parts\";\n\n/**\n * How a Popover presents: `auto` is a popover from 640px up and a bottom sheet below.\n *\n * @claim \"How a Popover presents: `auto` is\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::Popover presentation > is a bottom sheet below 640px with presentation auto, and a popover from 640px up)\n */\nexport type PopoverPresentation = \"auto\" | \"popover\" | \"sheet\";\n\nconst presentations: readonly PopoverPresentation[] = [\"auto\", \"popover\", \"sheet\"];\n\nconst controlFix = \"<Popover open={open} onOpenChange={setOpen} anchor={buttonRef}>\";\n\n/** Props shared by both ways of opening a Popover. */\nexport interface PopoverBaseProps {\n  /**\n   * Names the popover for screen readers and shows at its top. Always required; hide it with `hideTitle`.\n   *\n   * @claim \"Always required; hide it with `hideTitle`\" registry/ouro/components/ouro/popover/popover.test-d.ts verify:fileLine(registry/ouro/components/ouro/popover/popover.test-d.ts, /\\{\\strigger:\\sReactElement;\\schildren:\\s\"Body\"\\s\\}>\\(\\)\\.not\\.toExtend<PopoverProps>/)\n   */\n  title: string;\n  /** Hides the title visually. It still names the popover for screen readers. */\n  hideTitle?: boolean | undefined;\n  /** A short line under the title, read out when the popover opens. */\n  description?: ReactNode;\n  /**\n   * The label of the close button, the last control in the popover. It is hidden until\n   * it has keyboard focus, so screen-reader users on phones (who have no Escape key)\n   * can always close the popover. @default \"Close\"\n   * @claim \"It is hidden until it has\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::Popover > has a close button for screen readers, hidden until it has keyboard focus, labelled by closeLabel)\n   */\n  closeLabel?: string | undefined;\n  /**\n   * The side of the trigger the popover sits on; it flips when there is no room. @default \"bottom\"\n   *\n   * @claim \"it flips when there is no room\" https://base-ui.com/react/components/popover verify:urlOk(https://base-ui.com/react/components/popover)\n   */\n  side?: FloatingSide | (string & { 'Use \"top\", \"bottom\", \"left\" or \"right\"': never }) | undefined;\n  /** How the popover lines up with the trigger along that side. @default \"center\" */\n  align?: FloatingAlign | (string & { 'Use \"start\", \"center\" or \"end\": left is \"start\", right is \"end\"': never }) | undefined;\n  /**\n   * `popover` stays beside the trigger at every width. `auto` is a popover from the `sm`\n   * breakpoint (640px) up and a bottom sheet below it, for a popover with controls that\n   * would be fiddly on a phone. `sheet` is always a bottom sheet. The server renders the\n   * popover form and corrects it on hydration.\n   * @default \"popover\"\n   * @claim \"`auto` is a popover from the\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::Popover presentation > is a bottom sheet below 640px with presentation auto, and a popover from 640px up)\n   * @claim \"`auto` is a popover from the\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::Popover presentation > stays open, with the same trigger node, when a resize crosses 640px)\n   * @claim \"`popover` stays beside the trigger at\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::Popover presentation > stays a popover on a phone by default)\n   * @claim \"`auto` is a popover from the\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::Popover presentation > stays a popover on a phone by default)\n   * @claim \"`sheet` is always a bottom sheet\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::Popover presentation > is always a sheet with presentation sheet)\n   */\n  presentation?: PopoverPresentation | (string & { 'Use \"auto\", \"popover\" or \"sheet\"': never }) | undefined;\n  /**\n   * The body. It scrolls when the popover is taller than the space beside the trigger. Its focus ring is drawn over\n   * the content, so a header that sticks to the top never hides an edge of it.\n   * @claim \"Its focus ring is drawn over the content\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::Popover > draws its focus ring whole over content that sticks to an edge, and leaves the pointer to the content)\n   */\n  children: ReactNode;\n  /**\n   * Layout only, applied to the popover panel: width (18rem, `w-72`, by default) and\n   * margins. Your classes win over Ouro UI's. The sheet keeps its full width. Appearance\n   * classes warn in development.\n   * @claim \"Layout only, applied to the popover\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::Popover > is 18rem wide by default, and className sets layout)\n   */\n  className?: string | undefined;\n\n  /** Not a prop. Ouro UI uses `open` with `onOpenChange`: `<Popover open={open} onOpenChange={setOpen} anchor={buttonRef}>`. */\n  isOpen?: { 'Use <Popover open={open} onOpenChange={setOpen} anchor={buttonRef}>': never };\n  /** Not a prop. `onOpenChange(false)` fires on close: `<Popover open={open} onOpenChange={setOpen} anchor={buttonRef}>`. */\n  onClose?: { 'Use <Popover open={open} onOpenChange={setOpen} anchor={buttonRef}>': never };\n  /** Not a prop. Ouro UI splits placement into `side` and `align`: `<Popover side=\"bottom\" align=\"start\">`. */\n  placement?: { 'Use side=\"bottom\" align=\"start\"': never };\n  /** Not a prop. The body is the children: `<Popover title=\"…\" trigger={…}>…</Popover>`. */\n  content?: { 'Use children: <Popover title=\"...\" trigger={...}>...</Popover>': never };\n}\n\n/** An uncontrolled Popover: `trigger` opens and closes it, and it sits beside the trigger. */\nexport type PopoverWithTriggerProps = PopoverBaseProps & {\n  /** The element that opens and closes the popover, usually a Button: `trigger={<Button>Share</Button>}`. */\n  trigger: ReactElement;\n  /** Not with `trigger`. Remove `trigger` to control the popover with `open`, `onOpenChange` and `anchor`. */\n  open?: TriggerOrOpen;\n  /** Not with `trigger`. Remove `trigger` to control the popover with `open`, `onOpenChange` and `anchor`. */\n  onOpenChange?: never;\n  /** Not with `trigger`. The popover sits beside its trigger. */\n  anchor?: never;\n};\n\n/** A controlled Popover: you own `open`, update it in `onOpenChange`, and say what it points at with `anchor`. */\nexport type PopoverControlledProps = PopoverBaseProps & {\n  /**\n   * Whether the popover is open. After a touch or pen tap the popover focuses itself\n   * rather than its first input, so no software keyboard pops up; after a key press it\n   * focuses the first control.\n   * @claim \"After a touch or pen tap\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::controlled Popover > focuses its first control after a keyboard open, and its popup after a pen tap)\n   * @claim \"After a touch or pen tap\" registry/ouro/components/ouro/popover/popover.touch.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.touch.test.tsx::Popover on a phone > stays a popover beside the trigger by default, and focuses the popup, not its input, after a tap)\n   */\n  open: boolean;\n  /** Called with `false` when the user dismisses the popover (Escape, outside press, the close button). */\n  onOpenChange: (open: boolean) => void;\n  /**\n   * The element the popover points at, usually the button that toggles it:\n   * `anchor={buttonRef}`. A press on it never counts as an outside press, so its own\n   * `onClick` can toggle `open`.\n   * @claim \"A press on it never counts\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::Popover > closes from an outside press, and the trigger toggles it)\n   * @claim \"A press on it never counts\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::Popover > keeps the trigger's own ref and onClick)\n   */\n  anchor: RefObject<HTMLElement | null>;\n  /** Not with `open`. Remove `open`, `onOpenChange` and `anchor` to let a trigger open the popover. */\n  trigger?: never;\n};\n\n/** Props for {@link Popover}: either `trigger`, or `open` with `onOpenChange` and `anchor`. */\nexport type PopoverProps = PopoverWithTriggerProps | PopoverControlledProps;\n\n/**\n * A small non-modal panel beside its trigger, for a short form or a few choices: a share\n * link, filters, a quick edit. It is named by its title, closes on Escape and outside\n * presses, returns focus to the trigger, and flips to the other side when there is no\n * room. With `presentation=\"auto\"` it is a bottom sheet on phones (below 640px).\n *\n * Use `trigger` for a popover a button opens, or `open` with `onOpenChange` and `anchor`\n * to control it. To give the trigger a tooltip too, put the Tooltip inside `trigger`:\n * `trigger={<Tooltip content=\"Share recipe\"><Button aria-label=\"Share\">…</Button></Tooltip>}`. Use `Tooltip` instead for a short label on hover or focus, `HoverCard`\n * for a preview of a link, and `Dialog` when the task needs\n * the user's full attention.\n *\n * It stacks above the page at `--ouro-layer`, a z-index of 50 by default (from\n * ouro-base.css), like Dialog and Sheet. Raise it in a `:root` rule of your own after\n * the Ouro tokens, outside any `@layer`: `:root { --ouro-layer: 60; }`.\n *\n * @group Overlays\n * @see https://ui.ouroboros.bot/docs/popover\n *\n * @example\n * <Popover title=\"Share recipe\" trigger={<Button>Share</Button>}>\n *   <TextField label=\"Link\" defaultValue={url} readOnly />\n * </Popover>\n * <Popover title=\"Filters\" presentation=\"auto\" open={open} onOpenChange={setOpen} anchor={filtersRef}>\n *   <FilterForm />\n * </Popover>\n * @claim \"` it is a bottom sheet on phones\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::Popover presentation > is a bottom sheet below 640px with presentation auto, and a popover from 640px up)\n * @claim \"It stacks above the page at\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::Popover stacking > puts the portal on the --ouro-layer level, as its own stacking context)\n * @claim \"It stacks above the page at\" registry/ouro/theme/ouro-base.css verify:fileLine(registry/ouro/theme/ouro-base.css, /^\\s+--ouro-layer:\\s50;/)\n * @claim \"It is named by its title\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::Popover > opens below its trigger as a non-modal dialog named by its title)\n * @claim \"It is named by its title\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::Popover > closes on Escape and returns focus to the trigger)\n * @claim \"It is named by its title\" registry/ouro/components/ouro/popover/popover.test.tsx verify:testExists(registry/ouro/components/ouro/popover/popover.test.tsx::Popover > closes from an outside press, and the trigger toggles it)\n * @claim \"It is named by its title\" https://base-ui.com/react/components/popover verify:urlOk(https://base-ui.com/react/components/popover)\n */\nexport function Popover(props: PopoverProps): JSX.Element {\n  const {\n    title,\n    hideTitle,\n    description,\n    closeLabel = \"Close\",\n    side: sideProp,\n    align: alignProp,\n    presentation: presentationProp = \"popover\",\n    children,\n    className,\n    trigger,\n    open,\n    onOpenChange,\n    anchor,\n    // Guard props (hint types), dropped here so they never reach the DOM.\n    isOpen,\n    onClose,\n    placement,\n    content,\n  } = props as PopoverBaseProps & {\n    trigger?: ReactElement;\n    open?: boolean;\n    onOpenChange?: (open: boolean) => void;\n    anchor?: RefObject<HTMLElement | null>;\n  };\n\n  checkOpenMode(\"Popover\", \"popover\", trigger !== undefined, open, onOpenChange);\n  if (open !== undefined && anchor === undefined) {\n    devThrow(\n      \"Popover\",\n      \"open needs anchor, the element it points at\",\n      process.env.NODE_ENV !== \"production\" ? controlFix : /* istanbul ignore next @preserve -- production only */ \"\",\n    );\n  }\n\n  // A side, alignment or presentation that is not one of Ouro UI's (a type error) warns and renders the default.\n  const side = floatingSide(sideProp, \"bottom\");\n  const align = floatingAlign(alignProp);\n  const presentation = presentations.includes(presentationProp as PopoverPresentation)\n    ? (presentationProp as PopoverPresentation)\n    : \"popover\";\n\n  useAppearanceClassNameCheck(\n    \"Popover\",\n    className,\n    process.env.NODE_ENV !== \"production\"\n      ? floatingHint('<Popover title=\"…\">', \"</Popover>\")\n      : /* istanbul ignore next @preserve -- production only */ \"\",\n  );\n  useDevWarnings(\n    \"Popover\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => [\n          !title && [\"title is required; it names the popover for screen readers\", '<Popover title=\"Share recipe\">'],\n          ...floatingPlacementWarnings(\"<Popover\", sideProp, \"bottom\", alignProp, placement),\n          presentation !== presentationProp && [\n            `presentation=\"${String(presentationProp)}\" is not a presentation; use ${presentations.map((name) => `\"${name}\"`).join(\", \")}`,\n            '<Popover presentation=\"auto\">',\n          ],\n          isOpen !== undefined && [\"isOpen is not a prop\", controlFix],\n          onClose !== undefined && [\"onClose is not a prop\", controlFix],\n          content !== undefined && [\"content is not a prop; the body is children\", '<Popover title=\"…\" trigger={…}>…</Popover>'],\n        ]\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n\n  // The Popover owns the open state even with a trigger, so it stays open when a resize\n  // across 640px swaps the popover for the sheet.\n  const [ownOpen, setOwnOpen] = useState(false);\n  const controlled = open !== undefined;\n  const isOpenNow = controlled ? open : ownOpen;\n  const setOpen = controlled ? onOpenChange! : setOwnOpen;\n\n  const asSheet = useSheetPresentation(presentation);\n  const triggerRef = useRef<HTMLButtonElement>(null);\n  const popupRef = useRef<HTMLDivElement>(null);\n  const bodyRef = useKeyboardScrollable<HTMLDivElement>(true);\n\n  // In either presentation the trigger stays a Base UI popover trigger in the same place\n  // in the tree, so its DOM node (and its focus, and the server-rendered node after\n  // hydration) survives a switch. As a sheet, the popover root stays closed and the press\n  // opens the sheet through the same state.\n\n  return (\n    <PopoverRoot\n      open={isOpenNow && !asSheet}\n      onOpenChange={(next, details) => {\n        // The app's own toggle (the anchor) is not outside: its onClick decides.\n        const target = details.event?.target as Node | undefined;\n        if (!next && details.reason === \"outside-press\" && target && anchor?.current?.contains(target)) return;\n        setOpen(next);\n      }}\n    >\n      {trigger !== undefined && (\n        <PopoverTrigger render={trigger} ref={triggerRef} aria-expanded={isOpenNow} />\n      )}\n      <PopoverPortal>\n        <PopoverPositionerUnchecked side={side} align={align} {...(anchor ? { anchor } : {})}>\n          <PopoverPopupUnchecked\n            ref={popupRef}\n            className={className}\n            data-ouro-presentation=\"popover\"\n            {...(controlled\n              ? {\n                  initialFocus: () => (lastInput() === \"touch\" || lastInput() === \"pen\" ? popupRef.current : true),\n                  // Safari does not focus a button on click, so name where focus goes back.\n                  finalFocus: anchor,\n                }\n              : {})}\n          >\n            {(!hideTitle || description !== undefined) ? (\n              <div data-ouro-popover-header=\"\" className=\"grid shrink-0 gap-1\">\n                <PopoverTitle visuallyHidden={hideTitle}>{title}</PopoverTitle>\n                {description !== undefined && <PopoverDescription>{description}</PopoverDescription>}\n              </div>\n            ) : (\n              <PopoverTitle visuallyHidden>{title}</PopoverTitle>\n            )}\n            <div className=\"relative box-border flex min-h-0 flex-auto flex-col\">\n              <div\n                ref={bodyRef}\n                data-ouro-popover-content=\"\"\n                data-ouro-control=\"popover\"\n                data-ouro-part=\"content\"\n                className=\"peer box-border min-h-0 flex-auto overflow-y-auto overscroll-contain text-sm leading-5 outline-none focus-visible:isolate\"\n              >\n                {children}\n              </div>\n              <span\n                aria-hidden=\"true\"\n                data-popover-focus-ring=\"\"\n                className=\"pointer-events-none absolute inset-0 hidden rounded-[inherit] outline-ring -outline-offset-2 peer-focus-visible:block peer-focus-visible:outline-2 peer-focus-visible:outline-solid\"\n              />\n            </div>\n            <PopoverClose data-ouro-popover-close=\"\">{closeLabel}</PopoverClose>\n          </PopoverPopupUnchecked>\n        </PopoverPositionerUnchecked>\n      </PopoverPortal>\n      {asSheet && (\n        <SheetFrame\n          title={title}\n          hideTitle={hideTitle}\n          closeLabel={closeLabel}\n          description={description}\n          side=\"bottom\"\n          open={isOpenNow}\n          onOpenChange={setOpen}\n          presentation=\"sheet\"\n          finalFocus={trigger !== undefined ? triggerRef : anchor}\n        >\n          {children}\n        </SheetFrame>\n      )}\n    </PopoverRoot>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/popover/popover.tsx"
    }
  ],
  "docs": "A small non-modal panel beside its trigger, for a short form or a few choices: a share link, filters, a quick edit. Import: import { Popover } from \"@/components/ouro/popover/popover\", with @/components replaced by your components alias (aliases.components in components.json, such as ~/components). Also installed: sheet, 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/popover.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}