{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "result-card",
  "type": "registry:ui",
  "title": "Result Card",
  "description": "A compact card for something an agent produced.",
  "categories": [
    "data-display"
  ],
  "dependencies": [
    "@hugeicons/core-free-icons@4.4.0",
    "@hugeicons/react@1.1.10"
  ],
  "registryDependencies": [
    "https://sprout.tulipfarm.ai/r/sprout-base.json",
    "https://sprout.tulipfarm.ai/r/brand-icon.json",
    "https://sprout.tulipfarm.ai/r/button.json",
    "https://sprout.tulipfarm.ai/r/popover.json",
    "https://sprout.tulipfarm.ai/r/spinner.json"
  ],
  "files": [
    {
      "path": "registry/sprout/components/ui/result-card.tsx",
      "type": "registry:ui",
      "target": "components/ui/result-card.tsx",
      "content": "'use client';\n\nimport type { ComponentProps, ReactNode } from 'react';\nimport { CheckIcon } from '@/lib/sprout/icons/check-icon';\nimport { DangerIcon } from '@/lib/sprout/icons/danger-icon';\nimport { PlugIcon } from '@/lib/sprout/icons/plug-icon';\nimport { cn } from '@/lib/sprout/classes';\nimport { BrandIcon, BrandTile, type Brand } from '@/components/ui/brand-icon';\nimport { Button } from '@/components/ui/button';\nimport { Popover, PopoverContent, PopoverTitle, PopoverTrigger } from '@/components/ui/popover';\nimport { Spinner } from '@/components/ui/spinner';\n\nexport const resultCardKindNames = [\n  'File',\n  'Plan',\n  'Workflow',\n  'Action',\n  'Calendar',\n  'Table',\n  'Activity',\n  'Agent',\n  'Skill',\n] as const;\n\nexport const resultCardStateNames = ['default', 'loading', 'running', 'disabled', 'error', 'success'] as const;\n\nexport const resultAppActionStateNames = [\n  'completed',\n  'pending',\n  'running',\n  'failed',\n  'unknown',\n  'blocked',\n  'cancelled',\n  'skipped',\n] as const;\n\nexport type ResultCardKind = (typeof resultCardKindNames)[number];\nexport type ResultCardState = (typeof resultCardStateNames)[number];\nexport type ResultAppActionState = (typeof resultAppActionStateNames)[number];\n\nexport type ResultAppAction = { label: string; state: ResultAppActionState };\n\nexport type ResultApp = {\n  brand: Brand | null;\n  name: string;\n  icon?: ReactNode;\n  actions: readonly ResultAppAction[];\n};\n\nexport type ResultCardAction = {\n  label: string;\n  onClick: () => void;\n  disabled?: boolean | undefined;\n};\n\nexport interface ResultCardProps extends Omit<ComponentProps<'section'>, 'title' | 'children'> {\n  title: string;\n  kind: ResultCardKind;\n  apps: readonly ResultApp[];\n  status: string;\n  state?: ResultCardState | undefined;\n  action?: ResultCardAction | undefined;\n  icon?: ReactNode;\n  children?: ReactNode;\n}\n\nconst actionPrefixes: Record<Exclude<ResultAppActionState, 'completed'>, string> = {\n  failed: 'Failed:',\n  unknown: 'Unconfirmed:',\n  pending: 'Pending:',\n  running: 'In progress:',\n  blocked: 'Blocked:',\n  cancelled: 'Cancelled:',\n  skipped: 'Skipped:',\n};\n\nfunction mergeApps(apps: readonly ResultApp[]) {\n  const byKey = new Map<string, ResultApp>();\n  for (const app of apps) {\n    const key = app.brand ?? app.name;\n    const existing = byKey.get(key);\n    byKey.set(key, existing ? { ...existing, actions: [...existing.actions, ...app.actions] } : app);\n  }\n  return [...byKey.values()];\n}\n\nexport function ResultCard({\n  title,\n  kind,\n  apps,\n  status,\n  state = 'default',\n  action,\n  icon,\n  children,\n  className,\n  ...props\n}: ResultCardProps) {\n  const unique = mergeApps(apps);\n  const visible = unique.slice(0, 2);\n  const hidden = unique.slice(2);\n  const busy = state === 'loading' || state === 'running';\n  const disabled = state === 'disabled';\n  return (\n    <section\n      data-slot=\"result-card\"\n      data-state={state}\n      data-kind={kind}\n      aria-label={`${kind}: ${title}`}\n      aria-busy={busy}\n      {...props}\n      className={cn('sprout-result-card', className)}\n    >\n      <div className=\"sprout-result-card-header\">\n        {visible.length > 0 ? (\n          <div role=\"group\" aria-label=\"Apps used\" className=\"sprout-result-card-apps\">\n            {visible.map(app => (\n              <span\n                key={app.brand ?? app.name}\n                data-result-app={app.brand ?? 'connected-app'}\n                className=\"sprout-result-card-app\"\n              >\n                <AppActionsPopover apps={[app]} disabled={disabled} />\n              </span>\n            ))}\n            {hidden.length > 0 && (\n              <span data-result-overflow={hidden.length} className=\"sprout-result-card-app\">\n                <AppActionsPopover apps={hidden} overflow disabled={disabled} />\n              </span>\n            )}\n          </div>\n        ) : (\n          icon && (\n            <BrandTile aria-hidden=\"true\" className=\"sprout-result-card-icon\">\n              {icon}\n            </BrandTile>\n          )\n        )}\n        <div className=\"sprout-result-card-main\">\n          <div className=\"sprout-result-card-text\">\n            <h3 className=\"sprout-result-card-title\">{title}</h3>\n            <div className=\"sprout-result-card-meta\">\n              <span>{kind}</span>\n              <span aria-hidden=\"true\">·</span>\n              <span\n                role=\"status\"\n                data-tone={state === 'success' || state === 'error' ? state : undefined}\n                className=\"sprout-result-card-status\"\n              >\n                {busy ? (\n                  <Spinner aria-hidden=\"true\" />\n                ) : state === 'success' ? (\n                  <CheckIcon size=\"sm\" aria-hidden=\"true\" />\n                ) : state === 'error' ? (\n                  <DangerIcon size=\"sm\" aria-hidden=\"true\" />\n                ) : null}\n                {status}\n              </span>\n            </div>\n          </div>\n          {action && (\n            <div className=\"sprout-result-card-action\">\n              <Button\n                variant=\"outline\"\n                disabled={state === 'loading' || disabled || action.disabled === true}\n                onClick={action.onClick}\n              >\n                {action.label}\n              </Button>\n            </div>\n          )}\n        </div>\n      </div>\n      {children && <div className=\"sprout-result-card-body\">{children}</div>}\n    </section>\n  );\n}\n\nfunction AppActionsPopover({\n  apps,\n  overflow = false,\n  disabled,\n}: {\n  apps: readonly ResultApp[];\n  overflow?: boolean;\n  disabled: boolean;\n}) {\n  const first = apps[0];\n  if (!first) return null;\n  const title = overflow ? `${apps.length} more ${apps.length === 1 ? 'app' : 'apps'}` : `${first.name} actions`;\n  return (\n    <Popover>\n      <PopoverTrigger\n        openOnHover\n        delay={800}\n        closeDelay={200}\n        render={<BrandTile size=\"action\" render={<Button variant=\"ghost\" size=\"icon\" disabled={disabled} />} />}\n        aria-label={title}\n      >\n        {overflow ? (\n          <span className=\"sprout-result-card-overflow\">+{apps.length}</span>\n        ) : first.brand ? (\n          <BrandIcon brand={first.brand} size=\"fill\" />\n        ) : first.icon ? (\n          <span aria-hidden=\"true\" className=\"sprout-result-app-icon\">\n            {first.icon}\n          </span>\n        ) : (\n          <PlugIcon size=\"lg\" aria-hidden=\"true\" />\n        )}\n      </PopoverTrigger>\n      <PopoverContent\n        size=\"app-actions\"\n        align=\"start\"\n        sideOffset={8}\n        initialFocus={interaction => interaction !== 'mouse'}\n      >\n        <PopoverTitle>{title}</PopoverTitle>\n        <ResultAppActions apps={apps} showAppNames={overflow} />\n      </PopoverContent>\n    </Popover>\n  );\n}\n\nexport interface ResultAppActionsProps extends Omit<ComponentProps<'div'>, 'children'> {\n  apps: readonly ResultApp[];\n  showAppNames?: boolean | undefined;\n}\n\nexport function ResultAppActions({ apps, showAppNames = true, className, ...props }: ResultAppActionsProps) {\n  return (\n    <div data-slot=\"result-app-actions\" {...props} className={cn('sprout-result-app-actions', className)}>\n      {apps.map(app => (\n        <section key={app.brand ?? app.name} aria-label={app.name} className=\"sprout-result-app\">\n          {showAppNames && (\n            <div className=\"sprout-result-app-name\">\n              {app.brand ? (\n                <BrandIcon brand={app.brand} size=\"glyph\" />\n              ) : app.icon ? (\n                <span aria-hidden=\"true\" className=\"sprout-result-app-icon\">\n                  {app.icon}\n                </span>\n              ) : (\n                <PlugIcon size=\"xl\" aria-hidden=\"true\" />\n              )}\n              <h4>{app.name}</h4>\n            </div>\n          )}\n          {app.actions.length === 0 ? (\n            <p className=\"sprout-result-app-empty\">No action details were recorded.</p>\n          ) : (\n            <ul className=\"sprout-result-app-list\">\n              {app.actions.map((action, index) => (\n                <li key={`${action.label}:${index}`} data-state={action.state} className=\"sprout-result-app-action\">\n                  {action.state === 'completed' ? (\n                    <span className=\"sprout-result-app-check\">\n                      <CheckIcon size=\"md\" aria-hidden=\"true\" />\n                      <span className=\"sprout-result-sr-only\">Completed:</span>\n                    </span>\n                  ) : (\n                    <span className=\"sprout-result-app-prefix\">{actionPrefixes[action.state]}</span>\n                  )}\n                  <span className=\"sprout-result-app-label\">{action.label}</span>\n                </li>\n              ))}\n            </ul>\n          )}\n        </section>\n      ))}\n    </div>\n  );\n}\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/check-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/check-icon.tsx",
      "content": "import { Tick02Icon as glyph } from '@hugeicons/core-free-icons';\nimport { createIcon } from '@/lib/sprout/icons/create-icon';\n\nexport const CheckIcon = /* @__PURE__ */ createIcon(glyph, 'CheckIcon');\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/create-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/create-icon.tsx",
      "content": "import { HugeiconsIcon, type IconSvgElement } from '@hugeicons/react';\nimport type { ReactElement, Ref, SVGProps } from 'react';\n\nexport const iconSizes = {\n  xs: 12,\n  sm: 14,\n  md: 16,\n  lg: 18,\n  xl: 20,\n  '2xl': 24,\n} as const;\n\nexport type IconSize = keyof typeof iconSizes;\n\nexport const iconStrokeWidth = 1.5;\n\nexport type IconProps = Omit<SVGProps<SVGSVGElement>, 'ref'> & {\n  size?: IconSize | number;\n  ref?: Ref<SVGSVGElement>;\n};\n\nexport type IconComponent = (props: IconProps) => ReactElement;\n\nexport function createIcon(glyph: IconSvgElement, name: string): IconComponent {\n  const Icon = ({ size = '2xl', strokeWidth = iconStrokeWidth, ...props }: IconProps) => (\n    <HugeiconsIcon\n      icon={glyph}\n      size={typeof size === 'number' ? size : iconSizes[size]}\n      strokeWidth={Number(strokeWidth)}\n      {...props}\n    />\n  );\n  Icon.displayName = name;\n  return Icon;\n}\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/danger-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/danger-icon.tsx",
      "content": "import { Alert01Icon as glyph } from '@hugeicons/core-free-icons';\nimport { createIcon } from '@/lib/sprout/icons/create-icon';\n\nexport const DangerIcon = /* @__PURE__ */ createIcon(glyph, 'DangerIcon');\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/plug-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/plug-icon.tsx",
      "content": "import { Plug01Icon as glyph } from '@hugeicons/core-free-icons';\nimport { createIcon } from '@/lib/sprout/icons/create-icon';\n\nexport const PlugIcon = /* @__PURE__ */ createIcon(glyph, 'PlugIcon');\n"
    }
  ],
  "css": {
    "@layer components": {
      ".sprout-result-card": {
        "box-sizing": "border-box",
        "border": "1px solid var(--sprout-input)",
        "border-radius": "var(--sprout-radius-panel)",
        "background": "var(--sprout-surface)",
        "min-width": "0",
        "color": "var(--sprout-text)",
        "font-family": "var(--sprout-font)",
        "--sprout-brand-ring": "var(--sprout-surface)",
        "container-type": "inline-size"
      },
      ".sprout-result-card-header": {
        "align-items": "flex-start",
        "gap": "12px",
        "padding": "16px",
        "display": "flex"
      },
      ".sprout-result-card-apps": {
        "isolation": "isolate",
        "flex-shrink": "0",
        "align-items": "center",
        "display": "flex"
      },
      ".sprout-result-card-app": {
        "box-shadow": "0 0 0 2px var(--sprout-surface)",
        "border-radius": ".5rem",
        "flex-shrink": "0",
        "display": "inline-flex",
        "position": "relative"
      },
      ".sprout-result-card-app + .sprout-result-card-app": {
        "margin-inline-start": "-6px"
      },
      ".sprout-result-card-app:hover, .sprout-result-card-app:focus-within": {
        "z-index": "10"
      },
      ".sprout-result-card-overflow": {
        "font-size": "var(--sprout-text-xs)",
        "font-variant-numeric": "tabular-nums",
        "font-weight": "500"
      },
      ".sprout-result-card-icon[data-size]": {
        "color": "var(--sprout-text)"
      },
      ".sprout-result-card-icon > svg": {
        "width": "18px",
        "height": "18px"
      },
      ".sprout-result-card-main": {
        "flex-direction": "column",
        "flex": "1",
        "gap": "12px",
        "min-width": "0",
        "display": "flex"
      },
      ".sprout-result-card-text": {
        "flex-direction": "column",
        "flex": "auto",
        "gap": "6px",
        "min-width": "0",
        "display": "flex"
      },
      ".sprout-result-card-title": {
        "color": "var(--sprout-text)",
        "font-size": "var(--sprout-text-base)",
        "overflow-wrap": "anywhere",
        "margin": "0",
        "font-weight": "500",
        "line-height": "1.5rem"
      },
      ".sprout-result-card-meta": {
        "color": "var(--sprout-muted)",
        "font-size": "var(--sprout-text-sm)",
        "flex-wrap": "wrap",
        "align-items": "center",
        "gap": "4px 8px",
        "line-height": "1.25rem",
        "display": "flex"
      },
      ".sprout-result-card-status": {
        "overflow-wrap": "anywhere",
        "min-width": "0",
        "transition": "color var(--sprout-motion-normal) var(--sprout-motion-ease)",
        "align-items": "center",
        "gap": "6px",
        "display": "inline-flex"
      },
      ".sprout-result-card-status > svg": {
        "flex-shrink": "0"
      },
      ".sprout-result-card-status[data-tone=\"success\"]": {
        "color": "var(--sprout-success)"
      },
      ".sprout-result-card-status[data-tone=\"error\"]": {
        "color": "var(--sprout-danger)"
      },
      ".sprout-result-card-action": {
        "flex-shrink": "0",
        "align-self": "flex-start"
      },
      ".sprout-result-card-body": {
        "font-size": "var(--sprout-text-sm)",
        "flex-direction": "column",
        "gap": "12px",
        "padding": "0 16px 16px",
        "display": "flex"
      },
      ".sprout-result-card-body :where(p)": {
        "margin": "0"
      },
      "@container (width >= 28rem)": {
        ".sprout-result-card-main": {
          "flex-direction": "row",
          "justify-content": "space-between",
          "align-items": "center"
        },
        ".sprout-result-card-action": {
          "align-self": "center"
        }
      },
      "@media (pointer: coarse)": {
        ".sprout-result-card-app + .sprout-result-card-app": {
          "margin-inline-start": "-8px"
        },
        ".sprout-result-card-action .sprout-button": {
          "height": "44px"
        }
      },
      ".sprout-result-app-actions": {
        "font-family": "var(--sprout-font)",
        "color": "var(--sprout-text)",
        "flex-direction": "column",
        "gap": "16px",
        "display": "flex"
      },
      ".sprout-result-app": {
        "flex-direction": "column",
        "gap": "8px",
        "min-width": "0",
        "display": "flex"
      },
      ".sprout-result-app-name": {
        "align-items": "center",
        "gap": "8px",
        "display": "flex"
      },
      ".sprout-result-app-name > svg": {
        "flex-shrink": "0"
      },
      ".sprout-result-app-icon": {
        "flex-shrink": "0",
        "width": "18px",
        "height": "18px",
        "display": "inline-flex"
      },
      ".sprout-result-app-name > .sprout-result-app-icon": {
        "width": "20px",
        "height": "20px"
      },
      ".sprout-result-app-icon > svg": {
        "width": "100%",
        "height": "100%"
      },
      ".sprout-result-app-name h4": {
        "color": "var(--sprout-text)",
        "font-size": "var(--sprout-text-sm)",
        "margin": "0",
        "font-weight": "500",
        "line-height": "1.25rem"
      },
      ".sprout-result-app-empty": {
        "color": "var(--sprout-muted)",
        "font-size": "var(--sprout-text-sm)",
        "margin": "0",
        "line-height": "1.25rem"
      },
      ".sprout-result-app-list": {
        "flex-direction": "column",
        "gap": "8px",
        "margin": "0",
        "padding": "0",
        "list-style": "none",
        "display": "flex"
      },
      ".sprout-result-app-action": {
        "font-size": "var(--sprout-text-sm)",
        "align-items": "flex-start",
        "gap": "8px",
        "line-height": "1.25rem",
        "display": "flex"
      },
      ".sprout-result-app-check": {
        "color": "var(--sprout-success)",
        "flex-shrink": "0",
        "margin-top": "2px",
        "display": "inline-flex"
      },
      ".sprout-result-app-prefix": {
        "color": "var(--sprout-muted)",
        "flex-shrink": "0"
      },
      ".sprout-result-app-action[data-state=\"failed\"] .sprout-result-app-prefix": {
        "color": "var(--sprout-danger)"
      },
      ".sprout-result-app-label": {
        "overflow-wrap": "anywhere",
        "min-width": "0"
      },
      ".sprout-result-sr-only": {
        "clip": "rect(0 0 0 0)",
        "white-space": "nowrap",
        "border": "0",
        "width": "1px",
        "height": "1px",
        "margin": "-1px",
        "padding": "0",
        "position": "absolute",
        "overflow": "hidden"
      },
      "@media (prefers-reduced-motion: reduce)": {
        ".sprout-result-card-status": {
          "transition": "none"
        }
      }
    }
  },
  "docs": "Docs and examples: https://sprout.tulipfarm.ai/components/result-card/",
  "meta": {
    "source": "packages/sprout/src/components/result-card.tsx"
  }
}
