{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "files",
  "title": "Files",
  "description": "Primitives for files: a dropzone around a real file input that checks type, size and count, a provider-agnostic upload hook with progress, cancel, retry and a concurrency limit, ruled upload rows with a progress bar and their status in words, icons for eleven kinds of file from the name or MIME type, en-US file sizes, a file actions menu and folder breadcrumbs.",
  "registryDependencies": [
    "button",
    "dropdown-menu",
    "https://www.dashboardblocks.com/r/radix/format.json",
    "https://www.dashboardblocks.com/r/radix/status-label.json",
    "https://www.dashboardblocks.com/r/radix/details.json"
  ],
  "files": [
    {
      "path": "registry/components/dashboardblocks/files.tsx",
      "content": "'use client'\n\nimport { Details } from '@/registry/components/dashboardblocks/details'\nimport { StatusLabel } from '@/registry/components/dashboardblocks/status-label'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { formatNumber, formatPercent } from '@/registry/lib/dashboardblocks/format'\nimport {\n  type ChangeEvent,\n  type DragEvent,\n  Fragment,\n  type ReactNode,\n  useEffect,\n  useId,\n  useRef,\n  useState,\n} from 'react'\n\nimport { Button } from '@/components/ui/button'\nimport {\n  DropdownMenu,\n  DropdownMenuContent,\n  DropdownMenuItem,\n  DropdownMenuSeparator,\n  DropdownMenuTrigger,\n} from '@/components/ui/dropdown-menu'\n\nimport { cn } from '@/lib/utils'\n\ntype FileKind =\n  | 'archive'\n  | 'audio'\n  | 'code'\n  | 'document'\n  | 'folder'\n  | 'image'\n  | 'other'\n  | 'pdf'\n  | 'presentation'\n  | 'spreadsheet'\n  | 'video'\n\nconst EXTENSION_KINDS: Record<string, FileKind> = {\n  '7z': 'archive',\n  aac: 'audio',\n  avi: 'video',\n  avif: 'image',\n  bmp: 'image',\n  bz2: 'archive',\n  c: 'code',\n  cpp: 'code',\n  css: 'code',\n  csv: 'spreadsheet',\n  doc: 'document',\n  docx: 'document',\n  flac: 'audio',\n  gif: 'image',\n  go: 'code',\n  gz: 'archive',\n  heic: 'image',\n  html: 'code',\n  java: 'code',\n  jpeg: 'image',\n  jpg: 'image',\n  js: 'code',\n  json: 'code',\n  jsx: 'code',\n  key: 'presentation',\n  m4a: 'audio',\n  m4v: 'video',\n  md: 'document',\n  mkv: 'video',\n  mov: 'video',\n  mp3: 'audio',\n  mp4: 'video',\n  numbers: 'spreadsheet',\n  odp: 'presentation',\n  ods: 'spreadsheet',\n  odt: 'document',\n  ogg: 'audio',\n  pages: 'document',\n  pdf: 'pdf',\n  php: 'code',\n  png: 'image',\n  ppt: 'presentation',\n  pptx: 'presentation',\n  py: 'code',\n  rar: 'archive',\n  rb: 'code',\n  rs: 'code',\n  rtf: 'document',\n  sh: 'code',\n  sql: 'code',\n  svg: 'image',\n  swift: 'code',\n  tar: 'archive',\n  tgz: 'archive',\n  tif: 'image',\n  tiff: 'image',\n  ts: 'code',\n  tsv: 'spreadsheet',\n  tsx: 'code',\n  txt: 'document',\n  wav: 'audio',\n  webm: 'video',\n  webp: 'image',\n  xls: 'spreadsheet',\n  xlsx: 'spreadsheet',\n  xml: 'code',\n  yaml: 'code',\n  yml: 'code',\n  zip: 'archive',\n}\n\nconst MIME_KINDS: [RegExp, FileKind][] = [\n  [/^image\\//, 'image'],\n  [/^video\\//, 'video'],\n  [/^audio\\//, 'audio'],\n  [/^application\\/pdf$/, 'pdf'],\n  [/spreadsheet|ms-excel|^text\\/(csv|tab-separated-values)$/, 'spreadsheet'],\n  [/presentation|ms-powerpoint/, 'presentation'],\n  [/zip|compressed|x-tar|x-rar|gzip|x-7z/, 'archive'],\n  [/json|javascript|typescript|^text\\/(html|css|xml)$|^application\\/xml$/, 'code'],\n  [/wordprocessing|msword|opendocument\\.text|^text\\//, 'document'],\n]\n\nfunction getFileKind(name: string, type?: string): FileKind {\n  if (name.endsWith('/')) return 'folder'\n  const dot = name.lastIndexOf('.')\n  const extension = dot > 0 ? name.slice(dot + 1).toLowerCase() : ''\n  if (Object.hasOwn(EXTENSION_KINDS, extension)) return EXTENSION_KINDS[extension]\n  const mime = (type || name).toLowerCase()\n  return MIME_KINDS.find(([pattern]) => pattern.test(mime))?.[1] ?? 'other'\n}\n\ninterface FileKindConfig {\n  icon: ReactNode\n  label: string\n}\n\nconst fileKindConfig: Record<FileKind, FileKindConfig> = {\n  archive: {\n    icon: (\n      <IconPlaceholder\n        lucide='FileArchiveIcon'\n        tabler='IconFileZip'\n        hugeicons='FileZipIcon'\n        phosphor='FileZipIcon'\n        remixicon='RiFileZipLine'\n      />\n    ),\n    label: 'Archive',\n  },\n  audio: {\n    icon: (\n      <IconPlaceholder\n        lucide='FileMusicIcon'\n        tabler='IconFileMusic'\n        hugeicons='FileAudioIcon'\n        phosphor='FileAudioIcon'\n        remixicon='RiFileMusicLine'\n      />\n    ),\n    label: 'Audio',\n  },\n  code: {\n    icon: (\n      <IconPlaceholder\n        lucide='FileCodeIcon'\n        tabler='IconFileCode'\n        hugeicons='FileCodeIcon'\n        phosphor='FileCodeIcon'\n        remixicon='RiFileCodeLine'\n      />\n    ),\n    label: 'Code',\n  },\n  document: {\n    icon: (\n      <IconPlaceholder\n        lucide='FileTextIcon'\n        tabler='IconFileText'\n        hugeicons='File02Icon'\n        phosphor='FileTextIcon'\n        remixicon='RiFileTextLine'\n      />\n    ),\n    label: 'Document',\n  },\n  folder: {\n    icon: (\n      <IconPlaceholder\n        lucide='FolderIcon'\n        tabler='IconFolder'\n        hugeicons='Folder01Icon'\n        phosphor='FolderIcon'\n        remixicon='RiFolderLine'\n      />\n    ),\n    label: 'Folder',\n  },\n  image: {\n    icon: (\n      <IconPlaceholder\n        lucide='FileImageIcon'\n        tabler='IconPhoto'\n        hugeicons='Image01Icon'\n        phosphor='FileImageIcon'\n        remixicon='RiFileImageLine'\n      />\n    ),\n    label: 'Image',\n  },\n  other: {\n    icon: (\n      <IconPlaceholder\n        lucide='FileIcon'\n        tabler='IconFile'\n        hugeicons='File01Icon'\n        phosphor='FileIcon'\n        remixicon='RiFileLine'\n      />\n    ),\n    label: 'File',\n  },\n  pdf: {\n    icon: (\n      <IconPlaceholder\n        lucide='FileTextIcon'\n        tabler='IconFileTypePdf'\n        hugeicons='Pdf01Icon'\n        phosphor='FilePdfIcon'\n        remixicon='RiFilePdf2Line'\n      />\n    ),\n    label: 'PDF',\n  },\n  presentation: {\n    icon: (\n      <IconPlaceholder\n        lucide='PresentationIcon'\n        tabler='IconPresentation'\n        hugeicons='Ppt01Icon'\n        phosphor='FilePptIcon'\n        remixicon='RiFilePpt2Line'\n      />\n    ),\n    label: 'Presentation',\n  },\n  spreadsheet: {\n    icon: (\n      <IconPlaceholder\n        lucide='FileSpreadsheetIcon'\n        tabler='IconFileSpreadsheet'\n        hugeicons='Xls01Icon'\n        phosphor='FileXlsIcon'\n        remixicon='RiFileExcel2Line'\n      />\n    ),\n    label: 'Spreadsheet',\n  },\n  video: {\n    icon: (\n      <IconPlaceholder\n        lucide='FileVideoCameraIcon'\n        tabler='IconMovie'\n        hugeicons='Video01Icon'\n        phosphor='FileVideoIcon'\n        remixicon='RiFileVideoLine'\n      />\n    ),\n    label: 'Video',\n  },\n}\n\nconst fileIconSizes = {\n  lg: 'size-12 rounded-lg [&_svg]:size-6',\n  md: 'size-10 rounded-md [&_svg]:size-5',\n  sm: 'size-8 rounded-md [&_svg]:size-4',\n}\n\ninterface FileKindIconProps {\n  className?: string\n  /** Leave out to work it out from `name` and `type`. */\n  kind?: FileKind\n  name?: string\n  /** @default 'md' */\n  size?: keyof typeof fileIconSizes\n  type?: string\n}\n\nfunction FileKindIcon({\n  className,\n  kind,\n  name = '',\n  size = 'md',\n  type,\n}: FileKindIconProps) {\n  const config = fileKindConfig[kind ?? getFileKind(name, type)]\n  return (\n    <span\n      aria-hidden\n      className={cn(\n        'flex shrink-0 items-center justify-center',\n        'bg-muted text-muted-foreground',\n        fileIconSizes[size],\n        className,\n      )}\n    >\n      {config.icon}\n    </span>\n  )\n}\n\nconst FILE_SIZE_UNITS = ['B', 'KB', 'MB', 'GB', 'TB']\n\n/** \"0 B\", \"940 KB\", \"2.4 MB\", \"1.2 GB\", in steps of 1,024 as browsers and operating systems count. */\nfunction formatFileSize(bytes: number) {\n  if (!Number.isFinite(bytes) || bytes <= 0) return '0 B'\n  let exponent = Math.min(\n    FILE_SIZE_UNITS.length - 1,\n    Math.floor(Math.log(bytes) / Math.log(1024)),\n  )\n  let value = bytes / 1024 ** exponent\n  if (Math.round(value) >= 1024 && exponent < FILE_SIZE_UNITS.length - 1) {\n    exponent += 1\n    value /= 1024\n  }\n  const digits = exponent > 0 && value < 100 ? 1 : 0\n  return `${formatNumber(value, { maximumFractionDigits: digits })} ${FILE_SIZE_UNITS[exponent]}`\n}\n\ntype FileRejectionReason = 'count' | 'size' | 'type'\n\ninterface FileRejection {\n  file: File\n  message: string\n  reason: FileRejectionReason\n}\n\ninterface FileRules {\n  /** As in an input's `accept`: extensions and MIME types, such as \".pdf,image/*\". */\n  accept?: string\n  maxFiles?: number\n  /** Largest file in bytes. */\n  maxSize?: number\n}\n\nfunction matchesAccept(file: Pick<File, 'name' | 'type'>, accept?: string) {\n  const tokens = (accept ?? '')\n    .split(',')\n    .map((token) => token.trim().toLowerCase())\n    .filter(Boolean)\n  if (tokens.length === 0) return true\n  const name = file.name.toLowerCase()\n  const type = file.type.toLowerCase()\n  return tokens.some((token) => {\n    if (token.startsWith('.')) return name.endsWith(token)\n    if (token.endsWith('/*')) return type.startsWith(token.slice(0, -1))\n    return type === token\n  })\n}\n\nfunction validateFiles(files: File[], { accept, maxFiles, maxSize }: FileRules = {}) {\n  const accepted: File[] = []\n  const rejected: FileRejection[] = []\n  for (const file of files) {\n    if (!matchesAccept(file, accept)) {\n      rejected.push({\n        file,\n        message: 'File type not accepted',\n        reason: 'type',\n      })\n    } else if (maxSize !== undefined && file.size > maxSize) {\n      rejected.push({\n        file,\n        message: `Larger than ${formatFileSize(maxSize)}`,\n        reason: 'size',\n      })\n    } else if (maxFiles !== undefined && accepted.length >= maxFiles) {\n      rejected.push({\n        file,\n        message: `Over the limit of ${maxFiles} ${maxFiles === 1 ? 'file' : 'files'}`,\n        reason: 'count',\n      })\n    } else {\n      accepted.push(file)\n    }\n  }\n  return { accepted, rejected }\n}\n\ninterface FileDropzoneProps extends FileRules {\n  className?: string\n  disabled?: boolean\n  hint?: ReactNode\n  icon?: ReactNode\n  /** @default true */\n  multiple?: boolean\n  /** The input's name, to submit the files with a form. */\n  name?: string\n  onFiles: (accepted: File[], rejected: FileRejection[]) => void\n  /** @default 'Drop files here or browse' */\n  title?: ReactNode\n}\n\nfunction FileDropzone({\n  accept,\n  className,\n  disabled = false,\n  hint,\n  icon,\n  maxFiles,\n  maxSize,\n  multiple = true,\n  name,\n  onFiles,\n  title,\n}: FileDropzoneProps) {\n  const [dragging, setDragging] = useState(false)\n  const depth = useRef(0)\n\n  const receive = (list: FileList | null) => {\n    const files = Array.from(list ?? [])\n    if (files.length === 0) return\n    const { accepted, rejected } = validateFiles(multiple ? files : files.slice(0, 1), {\n      accept,\n      maxFiles: multiple ? maxFiles : 1,\n      maxSize,\n    })\n    onFiles(accepted, rejected)\n  }\n\n  const onDragEnter = (event: DragEvent<HTMLLabelElement>) => {\n    if (disabled || !event.dataTransfer.types.includes('Files')) return\n    event.preventDefault()\n    depth.current += 1\n    setDragging(true)\n  }\n\n  const onDragOver = (event: DragEvent<HTMLLabelElement>) => {\n    if (disabled || !event.dataTransfer.types.includes('Files')) return\n    event.preventDefault()\n    event.dataTransfer.dropEffect = 'copy'\n  }\n\n  const onDragLeave = () => {\n    depth.current = Math.max(0, depth.current - 1)\n    if (depth.current === 0) setDragging(false)\n  }\n\n  const onDrop = (event: DragEvent<HTMLLabelElement>) => {\n    event.preventDefault()\n    depth.current = 0\n    setDragging(false)\n    if (!disabled) receive(event.dataTransfer.files)\n  }\n\n  const onChange = (event: ChangeEvent<HTMLInputElement>) => {\n    receive(event.target.files)\n    event.target.value = ''\n  }\n\n  return (\n    // oxlint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- dropping is the mouse path; the input inside is the keyboard one\n    <label\n      data-dragging={dragging || undefined}\n      data-disabled={disabled || undefined}\n      onDragEnter={onDragEnter}\n      onDragOver={onDragOver}\n      onDragLeave={onDragLeave}\n      onDrop={onDrop}\n      className={cn(\n        'border-input hover:bg-muted/50 has-focus-visible:border-ring has-focus-visible:ring-ring/50 data-dragging:border-primary data-dragging:bg-primary/5 flex cursor-pointer flex-col items-center justify-center gap-3 rounded-lg border border-dashed px-6 py-8 text-center transition-colors has-focus-visible:ring-3 data-disabled:cursor-not-allowed data-disabled:opacity-50 data-disabled:hover:bg-transparent',\n        className,\n      )}\n    >\n      <input\n        type='file'\n        name={name}\n        accept={accept}\n        multiple={multiple}\n        disabled={disabled}\n        onChange={onChange}\n        className='sr-only'\n      />\n      <span\n        aria-hidden\n        className='bg-muted text-muted-foreground in-data-dragging:bg-primary in-data-dragging:text-primary-foreground flex size-10 items-center justify-center rounded-full transition-colors [&_svg]:size-5'\n      >\n        {icon ?? (\n          <IconPlaceholder\n            lucide='CloudUploadIcon'\n            tabler='IconCloudUpload'\n            hugeicons='CloudUploadIcon'\n            phosphor='CloudArrowUpIcon'\n            remixicon='RiUploadCloud2Line'\n          />\n        )}\n      </span>\n      <span className='flex flex-col gap-1'>\n        <span className='text-sm font-medium'>\n          {title ?? (\n            <>\n              Drop files here or{' '}\n              <span className='text-primary underline underline-offset-4'>browse</span>\n            </>\n          )}\n        </span>\n        {hint && <span className='text-muted-foreground text-xs'>{hint}</span>}\n      </span>\n    </label>\n  )\n}\n\ntype UploadStatus = 'canceled' | 'done' | 'error' | 'queued' | 'uploading'\n\ninterface FileUpload {\n  error?: string\n  file?: File\n  id: string\n  name: string\n  /** From 0 to 1. */\n  progress: number\n  rejected?: boolean\n  /** In bytes. */\n  size: number\n  status: UploadStatus\n  type: string\n  url?: string\n}\n\ninterface UploadOptions {\n  /** Report progress from 0 to 1. */\n  onProgress: (progress: number) => void\n  /** Aborts when the upload is canceled or removed. */\n  signal: AbortSignal\n}\n\ntype UploadFn = (file: File, options: UploadOptions) => Promise<void | { url?: string }>\n\ninterface UseFileUploadsOptions {\n  concurrency?: number\n  initialUploads?: FileUpload[]\n  upload: UploadFn\n}\n\nfunction patchUpload(uploads: FileUpload[], id: string, changes: Partial<FileUpload>) {\n  return uploads.map((item) => (item.id === id ? { ...item, ...changes } : item))\n}\n\nfunction useFileUploads({\n  concurrency = 3,\n  initialUploads = [],\n  upload,\n}: UseFileUploadsOptions) {\n  const prefix = useId()\n  const nextId = useRef(0)\n  const [uploads, setUploads] = useState<FileUpload[]>(initialUploads)\n  const controllers = useRef(new Map<string, AbortController>())\n  const uploadRef = useRef(upload)\n\n  useEffect(() => {\n    uploadRef.current = upload\n  }, [upload])\n\n  useEffect(() => {\n    const running = controllers.current\n    return () => {\n      if (running.size === 0) return\n      const aborted = new Set(running.keys())\n      for (const controller of running.values()) controller.abort()\n      running.clear()\n      setUploads((current) =>\n        current.map((item) =>\n          aborted.has(item.id) && item.status === 'uploading'\n            ? { ...item, progress: 0, status: 'queued' }\n            : item,\n        ),\n      )\n    }\n  }, [])\n\n  useEffect(() => {\n    const running = controllers.current\n    const room = concurrency - running.size\n    const next = uploads\n      .filter((item) => item.status === 'queued' && item.file && !running.has(item.id))\n      .slice(0, Math.max(0, room))\n    for (const item of next) {\n      const controller = new AbortController()\n      const { signal } = controller\n      running.set(item.id, controller)\n      const update = (changes: Partial<FileUpload>) => {\n        if (!signal.aborted)\n          setUploads((current) => patchUpload(current, item.id, changes))\n      }\n      const finish = (changes: Partial<FileUpload>) => {\n        if (running.get(item.id) === controller) running.delete(item.id)\n        update(changes)\n      }\n      update({ error: undefined, progress: 0, status: 'uploading' })\n      uploadRef\n        .current(item.file as File, {\n          onProgress: (progress) =>\n            update({ progress: Math.min(1, Math.max(0, progress)) }),\n          signal,\n        })\n        .then((result) => finish({ progress: 1, status: 'done', url: result?.url }))\n        .catch((error: unknown) =>\n          finish({\n            error: error instanceof Error ? error.message : 'Upload failed',\n            status: 'error',\n          }),\n        )\n    }\n  }, [concurrency, uploads])\n\n  const stop = (id: string) => {\n    controllers.current.get(id)?.abort()\n    controllers.current.delete(id)\n  }\n\n  const add = (files: File[], rejected: FileRejection[] = []) => {\n    const created = (file: File): Omit<FileUpload, 'progress' | 'status'> => ({\n      file,\n      id: `${prefix}${nextId.current++}`,\n      name: file.name,\n      size: file.size,\n      type: file.type,\n    })\n    setUploads((current) => [\n      ...current,\n      ...files.map((file) => ({\n        ...created(file),\n        progress: 0,\n        status: 'queued' as const,\n      })),\n      ...rejected.map(({ file, message }) => ({\n        ...created(file),\n        error: message,\n        progress: 0,\n        rejected: true,\n        status: 'error' as const,\n      })),\n    ])\n  }\n\n  const cancel = (id: string) => {\n    stop(id)\n    setUploads((current) =>\n      current.map((item) =>\n        item.id === id && (item.status === 'queued' || item.status === 'uploading')\n          ? { ...item, status: 'canceled' }\n          : item,\n      ),\n    )\n  }\n\n  const retry = (id: string) => {\n    setUploads((current) =>\n      current.map((item) =>\n        item.id === id && item.file && !item.rejected\n          ? { ...item, error: undefined, progress: 0, status: 'queued' }\n          : item,\n      ),\n    )\n  }\n\n  const remove = (id: string) => {\n    stop(id)\n    setUploads((current) => current.filter((item) => item.id !== id))\n  }\n\n  const clear = (statuses: UploadStatus[] = ['done']) => {\n    setUploads((current) => current.filter((item) => !statuses.includes(item.status)))\n  }\n\n  return { add, cancel, clear, remove, retry, uploads }\n}\n\nfunction summarizeUploads(uploads: FileUpload[]) {\n  let active = 0\n  let done = 0\n  let failed = 0\n  let sent = 0\n  let total = 0\n  for (const item of uploads) {\n    if (item.status === 'queued' || item.status === 'uploading') active += 1\n    if (item.status === 'done') done += 1\n    if (item.status === 'error') failed += 1\n    if (item.status === 'error' || item.status === 'canceled') continue\n    sent += item.size * item.progress\n    total += item.size\n  }\n  return { active, done, failed, progress: total > 0 ? sent / total : 0 }\n}\n\nfunction FileUploadProgress({\n  className,\n  label,\n  value,\n}: {\n  className?: string\n  label: string\n  /** From 0 to 1. */\n  value: number\n}) {\n  const percent = Math.round(Math.min(1, Math.max(0, value)) * 100)\n  return (\n    <div\n      role='progressbar'\n      aria-label={label}\n      aria-valuemin={0}\n      aria-valuemax={100}\n      aria-valuenow={percent}\n      className={cn('bg-muted h-1.5 w-full overflow-hidden rounded-full', className)}\n    >\n      <div\n        className='bg-primary h-full rounded-full transition-[width] duration-200 ease-out motion-reduce:transition-none'\n        style={{ width: `${percent}%` }}\n      />\n    </div>\n  )\n}\n\nfunction FileUploadList({\n  children,\n  className,\n  label = 'Uploads',\n}: {\n  children: ReactNode\n  className?: string\n  /** @default 'Uploads' */\n  label?: string\n}) {\n  return (\n    <ul aria-label={label} className={cn('flex flex-col border-t', className)}>\n      {children}\n    </ul>\n  )\n}\n\ninterface FileUploadItemProps {\n  className?: string\n  onCancel?: (id: string) => void\n  onRemove?: (id: string) => void\n  onRetry?: (id: string) => void\n  upload: FileUpload\n}\n\nfunction FileUploadItem({\n  className,\n  onCancel,\n  onRemove,\n  onRetry,\n  upload,\n}: FileUploadItemProps) {\n  const { error, name, progress, size, status } = upload\n  const running = status === 'queued' || status === 'uploading'\n  const canRetry =\n    (status === 'error' || status === 'canceled') && !!upload.file && !upload.rejected\n  const actionsRef = useRef<HTMLDivElement>(null)\n  const canceling = useRef(false)\n\n  useEffect(() => {\n    if (!canceling.current || running) return\n    canceling.current = false\n    actionsRef.current?.querySelector('button')?.focus()\n  }, [running])\n\n  return (\n    <li\n      data-status={status}\n      className={cn(\n        'flex items-center gap-3 border-b py-2.5 last:border-b-0 [&_svg]:shrink-0',\n        className,\n      )}\n    >\n      <FileKindIcon name={name} type={upload.type} />\n      <div className='flex min-w-0 flex-1 flex-col gap-1'>\n        <div className='flex items-baseline justify-between gap-3'>\n          <p className='truncate text-sm font-medium' title={name}>\n            {name}\n          </p>\n          {status === 'uploading' && (\n            <span className='text-muted-foreground text-sm tabular-nums'>\n              {formatPercent(progress, { maximumFractionDigits: 0 })}\n            </span>\n          )}\n        </div>\n        {running && (\n          <FileUploadProgress\n            label={`Uploading ${name}`}\n            value={status === 'queued' ? 0 : progress}\n          />\n        )}\n        <p className='text-muted-foreground flex min-w-0 items-baseline gap-1 text-sm tabular-nums'>\n          {status === 'queued' && (\n            <Details>\n              {formatFileSize(size)}\n              Waiting…\n            </Details>\n          )}\n          {status === 'uploading' && (\n            <>\n              {formatFileSize(size * progress)} of {formatFileSize(size)}\n            </>\n          )}\n          {status === 'done' && (\n            <Details>\n              {formatFileSize(size)}\n              <StatusLabel variant='text' tone='good'>\n                Uploaded\n              </StatusLabel>\n            </Details>\n          )}\n          {status === 'error' && (\n            <StatusLabel variant='text' tone='bad' className='min-w-0 whitespace-normal'>\n              {error ?? 'Upload failed'}\n            </StatusLabel>\n          )}\n          {status === 'canceled' && (\n            <Details>\n              {formatFileSize(size)}\n              Canceled\n            </Details>\n          )}\n        </p>\n      </div>\n      <div ref={actionsRef} className='flex shrink-0 items-center'>\n        {running && onCancel && (\n          <Button\n            variant='ghost'\n            size='icon-sm'\n            aria-label={`Cancel upload of ${name}`}\n            onClick={() => {\n              canceling.current = true\n              onCancel(upload.id)\n            }}\n          >\n            <IconPlaceholder\n              lucide='XIcon'\n              tabler='IconX'\n              hugeicons='Cancel01Icon'\n              phosphor='XIcon'\n              remixicon='RiCloseLine'\n            />\n          </Button>\n        )}\n        {canRetry && onRetry && (\n          <Button\n            variant='ghost'\n            size='icon-sm'\n            aria-label={`Retry ${name}`}\n            onClick={() => onRetry(upload.id)}\n          >\n            <IconPlaceholder\n              lucide='RefreshCwIcon'\n              tabler='IconRefresh'\n              hugeicons='RefreshIcon'\n              phosphor='ArrowClockwiseIcon'\n              remixicon='RiRefreshLine'\n            />\n          </Button>\n        )}\n        {!running && onRemove && (\n          <Button\n            variant='ghost'\n            size='icon-sm'\n            aria-label={`Remove ${name}`}\n            onClick={() => onRemove(upload.id)}\n          >\n            <IconPlaceholder\n              lucide='Trash2Icon'\n              tabler='IconTrash'\n              hugeicons='Delete02Icon'\n              phosphor='TrashIcon'\n              remixicon='RiDeleteBinLine'\n            />\n          </Button>\n        )}\n      </div>\n    </li>\n  )\n}\n\ninterface FileAction {\n  icon?: ReactNode\n  label: string\n  onSelect: () => void\n  variant?: 'default' | 'destructive'\n}\n\nfunction FileActionsMenu({\n  actions,\n  className,\n  label,\n}: {\n  actions: FileAction[]\n  className?: string\n  label: string\n}) {\n  const firstDestructive = actions.findIndex((action) => action.variant === 'destructive')\n  return (\n    <DropdownMenu modal={false}>\n      <DropdownMenuTrigger asChild>\n        <Button variant='ghost' size='icon-sm' aria-label={label} className={className}>\n          <IconPlaceholder\n            lucide='EllipsisIcon'\n            tabler='IconDots'\n            hugeicons='MoreHorizontalCircle01Icon'\n            phosphor='DotsThreeIcon'\n            remixicon='RiMoreLine'\n          />\n        </Button>\n      </DropdownMenuTrigger>\n      <DropdownMenuContent align='end' className='w-auto min-w-40'>\n        {actions.map((action, index) => (\n          <Fragment key={action.label}>\n            {index === firstDestructive && index > 0 && <DropdownMenuSeparator />}\n            <DropdownMenuItem variant={action.variant} onClick={action.onSelect}>\n              {action.icon}\n              {action.label}\n            </DropdownMenuItem>\n          </Fragment>\n        ))}\n      </DropdownMenuContent>\n    </DropdownMenu>\n  )\n}\n\ninterface FileBreadcrumb {\n  id: string\n  label: string\n}\n\nfunction FileBreadcrumbs({\n  className,\n  items,\n  label = 'Folder path',\n  onNavigate,\n}: {\n  className?: string\n  items: FileBreadcrumb[]\n  /** @default 'Folder path' */\n  label?: string\n  onNavigate: (id: string) => void\n}) {\n  return (\n    <nav aria-label={label} className={cn('min-w-0', className)}>\n      <ol className='text-muted-foreground flex flex-wrap items-center gap-1 text-sm'>\n        {items.map((item, index) => {\n          const current = index === items.length - 1\n          return (\n            <li key={item.id} className='flex min-w-0 items-center gap-1'>\n              {current ? (\n                <span\n                  aria-current='page'\n                  className='text-foreground truncate px-1 font-medium'\n                >\n                  {item.label}\n                </span>\n              ) : (\n                <>\n                  <button\n                    type='button'\n                    onClick={() => onNavigate(item.id)}\n                    className='hover:text-foreground focus-visible:ring-ring/50 truncate rounded-sm px-1 transition-colors outline-none focus-visible:ring-3'\n                  >\n                    {item.label}\n                  </button>\n                  <IconPlaceholder\n                    lucide='ChevronRightIcon'\n                    tabler='IconChevronRight'\n                    hugeicons='ArrowRight01Icon'\n                    phosphor='CaretRightIcon'\n                    remixicon='RiArrowRightSLine'\n                    aria-hidden\n                    className='size-3.5 shrink-0'\n                  />\n                </>\n              )}\n            </li>\n          )\n        })}\n      </ol>\n    </nav>\n  )\n}\n\nexport {\n  FileActionsMenu,\n  FileBreadcrumbs,\n  FileDropzone,\n  FileKindIcon,\n  FileUploadItem,\n  FileUploadList,\n  FileUploadProgress,\n  fileKindConfig,\n  formatFileSize,\n  getFileKind,\n  matchesAccept,\n  summarizeUploads,\n  useFileUploads,\n  validateFiles,\n}\n\nexport type {\n  FileAction,\n  FileBreadcrumb,\n  FileDropzoneProps,\n  FileKindIconProps,\n  FileKind,\n  FileKindConfig,\n  FileRejection,\n  FileRejectionReason,\n  FileRules,\n  FileUpload,\n  FileUploadItemProps,\n  UploadFn,\n  UploadOptions,\n  UploadStatus,\n  UseFileUploadsOptions,\n}\n",
      "type": "registry:component",
      "target": "@components/dashboardblocks/files.tsx"
    }
  ],
  "type": "registry:component"
}
