{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "file-upload",
  "type": "registry:ui",
  "title": "File Upload",
  "description": "File Upload is a native file input with drag-and-drop dropzone, advisory validation, selected-file list, and multipart form submission — selection only, not network upload.",
  "author": "Skrewww",
  "dependencies": [
    "@phosphor-icons/react"
  ],
  "registryDependencies": [
    "@skrewww/form-field",
    "@skrewww/foundation"
  ],
  "docs": "Host requirements (assumed already present, not installed by this command): react, react-dom.",
  "files": [
    {
      "path": "components/ui/FileUpload.tsx",
      "content": "/** @skrewww-component file-upload */\n\"use client\";\n\nimport { UploadSimple, X } from \"@phosphor-icons/react\";\nimport {\n  useCallback,\n  useEffect,\n  useId,\n  useRef,\n  useState,\n  type ChangeEvent,\n  type DragEvent,\n} from \"react\";\nimport { FormField } from \"@/components/ui/FormField\";\nimport { cn } from \"@/lib/cn\";\nimport styles from \"@/components/ui/file-upload.module.css\";\nimport {\n  assignFilesToInput,\n  buildDisplayItems,\n  clearNativeFileInput,\n  syncAcceptedFilesToInput,\n  type FileUploadDisplayItem,\n} from \"@/components/ui/internal/file-upload-file-list\";\nimport {\n  formatBytes,\n  validateFileBatch,\n  type FileUploadRejection,\n} from \"@/components/ui/internal/file-upload-validation\";\n\nexport type { FileUploadRejection, FileUploadRejectionCode } from \"@/components/ui/internal/file-upload-validation\";\n\nexport type FileUploadProps = {\n  id?: string;\n  name: string;\n  label: string;\n  supportingText?: string;\n  error?: string;\n  accept?: string;\n  multiple?: boolean;\n  maxFiles?: number;\n  maxSize?: number;\n  required?: boolean;\n  disabled?: boolean;\n  onFilesChange?: (files: File[]) => void;\n  onRejectedFiles?: (rejections: FileUploadRejection[]) => void;\n  className?: string;\n};\n\nfunction buildStatusMessage(\n  acceptedCount: number,\n  rejectedCount: number,\n  removedFileName?: string,\n  cleared?: boolean,\n): string {\n  if (cleared) return \"Selection cleared.\";\n  if (removedFileName) return `${removedFileName} removed.`;\n  if (acceptedCount > 0 && rejectedCount > 0) {\n    return `${acceptedCount} file${acceptedCount === 1 ? \"\" : \"s\"} selected. ${rejectedCount} file${rejectedCount === 1 ? \" was\" : \"s were\"} rejected.`;\n  }\n  if (rejectedCount > 0) {\n    return `${rejectedCount} file${rejectedCount === 1 ? \" was\" : \"s were\"} rejected.`;\n  }\n  if (acceptedCount > 0) {\n    return `${acceptedCount} file${acceptedCount === 1 ? \"\" : \"s\"} selected.`;\n  }\n  return \"\";\n}\n\nexport function FileUpload({\n  id,\n  name,\n  label,\n  supportingText,\n  error,\n  accept,\n  multiple = false,\n  maxFiles,\n  maxSize,\n  required = false,\n  disabled = false,\n  onFilesChange,\n  onRejectedFiles,\n  className,\n}: FileUploadProps) {\n  const inputRef = useRef<HTMLInputElement>(null);\n  const dragDepthRef = useRef(0);\n  const dragAnnouncedRef = useRef(false);\n  const removeButtonRefs = useRef<Map<string, HTMLButtonElement>>(new Map());\n  const [items, setItems] = useState<FileUploadDisplayItem[]>([]);\n  const [rejections, setRejections] = useState<FileUploadRejection[]>([]);\n  const [dragging, setDragging] = useState(false);\n  const [statusMessage, setStatusMessage] = useState(\"\");\n  const [syncUnavailable, setSyncUnavailable] = useState(false);\n  const rejectionListId = useId();\n  const statusId = useId();\n\n  const showFieldError = Boolean(error);\n  const showRejections = rejections.length > 0 && !showFieldError;\n\n  const applyFallbackClear = useCallback(\n    (announce = true) => {\n      if (inputRef.current) {\n        clearNativeFileInput(inputRef.current);\n      }\n      setItems([]);\n      setRejections([]);\n      setSyncUnavailable(true);\n      onFilesChange?.([]);\n      if (announce) {\n        setStatusMessage(\"Selection cleared.\");\n      }\n    },\n    [onFilesChange],\n  );\n\n  const commitSelection = useCallback(\n    (incoming: File[]) => {\n      const { accepted, rejected } = validateFileBatch({\n        files: incoming,\n        accept,\n        maxSize,\n        maxFiles,\n        multiple,\n      });\n\n      if (!inputRef.current) return;\n\n      if (accepted.length === 0) {\n        clearNativeFileInput(inputRef.current);\n        setItems([]);\n        setRejections(rejected);\n        setSyncUnavailable(false);\n        onFilesChange?.([]);\n        if (rejected.length) {\n          onRejectedFiles?.(rejected);\n        }\n        setStatusMessage(buildStatusMessage(0, rejected.length));\n        return;\n      }\n\n      if (!syncAcceptedFilesToInput(inputRef.current, accepted)) {\n        applyFallbackClear(true);\n        return;\n      }\n\n      setSyncUnavailable(false);\n      setItems(buildDisplayItems(accepted));\n      setRejections(rejected);\n      onFilesChange?.(accepted);\n      if (rejected.length) {\n        onRejectedFiles?.(rejected);\n      }\n      setStatusMessage(buildStatusMessage(accepted.length, rejected.length));\n    },\n    [accept, applyFallbackClear, maxFiles, maxSize, multiple, onFilesChange, onRejectedFiles],\n  );\n\n  const handleInputChange = useCallback(\n    (event: ChangeEvent<HTMLInputElement>) => {\n      const nextFiles = event.target.files ? Array.from(event.target.files) : [];\n      commitSelection(nextFiles);\n    },\n    [commitSelection],\n  );\n\n  const handleDragEnter = useCallback(\n    (event: DragEvent<HTMLDivElement>) => {\n      event.preventDefault();\n      event.stopPropagation();\n      if (disabled) return;\n      dragDepthRef.current += 1;\n      setDragging(true);\n      if (!dragAnnouncedRef.current) {\n        dragAnnouncedRef.current = true;\n        setStatusMessage(\"Files ready to drop.\");\n      }\n    },\n    [disabled],\n  );\n\n  const handleDragLeave = useCallback((event: DragEvent<HTMLDivElement>) => {\n    event.preventDefault();\n    event.stopPropagation();\n    dragDepthRef.current = Math.max(0, dragDepthRef.current - 1);\n    if (dragDepthRef.current === 0) {\n      setDragging(false);\n      dragAnnouncedRef.current = false;\n    }\n  }, []);\n\n  const handleDragOver = useCallback((event: DragEvent<HTMLDivElement>) => {\n    event.preventDefault();\n    event.stopPropagation();\n  }, []);\n\n  const handleDrop = useCallback(\n    (event: DragEvent<HTMLDivElement>) => {\n      event.preventDefault();\n      event.stopPropagation();\n      dragDepthRef.current = 0;\n      dragAnnouncedRef.current = false;\n      setDragging(false);\n      if (disabled) return;\n\n      const dropped = event.dataTransfer?.files\n        ? Array.from(event.dataTransfer.files)\n        : [];\n      commitSelection(dropped);\n    },\n    [commitSelection, disabled],\n  );\n\n  const handleRemove = useCallback(\n    (item: FileUploadDisplayItem) => {\n      const remaining = items.filter((entry) => entry.id !== item.id);\n      if (!inputRef.current) return;\n\n      if (remaining.length === 0) {\n        clearNativeFileInput(inputRef.current);\n        setItems([]);\n        setRejections([]);\n        onFilesChange?.([]);\n        setStatusMessage(buildStatusMessage(0, 0, item.file.name));\n        inputRef.current.focus();\n        return;\n      }\n\n      if (!syncAcceptedFilesToInput(inputRef.current, remaining.map((entry) => entry.file))) {\n        applyFallbackClear(true);\n        return;\n      }\n\n      setItems(remaining);\n      onFilesChange?.(remaining.map((entry) => entry.file));\n      setStatusMessage(buildStatusMessage(0, 0, item.file.name));\n\n      const index = items.findIndex((entry) => entry.id === item.id);\n      const next = remaining[index];\n      const previous = remaining[index - 1];\n      if (next) {\n        removeButtonRefs.current.get(next.id)?.focus();\n      } else if (previous) {\n        removeButtonRefs.current.get(previous.id)?.focus();\n      } else {\n        inputRef.current.focus();\n      }\n    },\n    [applyFallbackClear, items, onFilesChange],\n  );\n\n  useEffect(() => {\n    const input = inputRef.current;\n    const form = input?.form;\n    if (!form || !input) return;\n\n    const handleReset = () => {\n      window.requestAnimationFrame(() => {\n        setItems([]);\n        setRejections([]);\n        setDragging(false);\n        setSyncUnavailable(false);\n        dragDepthRef.current = 0;\n        dragAnnouncedRef.current = false;\n        setStatusMessage(\"Selection cleared.\");\n      });\n    };\n\n    form.addEventListener(\"reset\", handleReset);\n    return () => form.removeEventListener(\"reset\", handleReset);\n  }, []);\n\n  const dropzoneLabel = items.length\n    ? `${items.length} file${items.length === 1 ? \"\" : \"s\"} selected. Choose replacement files.`\n    : multiple\n      ? \"Drag and drop files here or browse to choose files\"\n      : \"Drag and drop a file here or browse to choose a file\";\n\n  return (\n    <FormField\n      label={label}\n      controlId={id}\n      required={required}\n      supportingText={supportingText}\n      error={error}\n      className={className}\n    >\n      {({ controlId, describedBy, invalid }) => {\n        const describedByIds = [\n          describedBy,\n          showRejections ? rejectionListId : undefined,\n          statusMessage ? statusId : undefined,\n        ]\n          .filter(Boolean)\n          .join(\" \");\n\n        return (\n          <div className={styles.root}>\n            <div\n              className={cn(\n                styles.dropzone,\n                items.length === 0 && styles.dropzoneEmpty,\n                dragging && styles.dropzoneDragging,\n                (invalid || showRejections) && styles.dropzoneError,\n                disabled && styles.dropzoneDisabled,\n              )}\n              onDragEnter={handleDragEnter}\n              onDragLeave={handleDragLeave}\n              onDragOver={handleDragOver}\n              onDrop={handleDrop}\n            >\n              <input\n                ref={inputRef}\n                id={controlId}\n                name={name}\n                type=\"file\"\n                accept={accept}\n                multiple={multiple}\n                required={required}\n                disabled={disabled}\n                aria-invalid={invalid || showRejections || undefined}\n                aria-describedby={describedByIds || undefined}\n                className={styles.nativeInput}\n                onChange={handleInputChange}\n              />\n              <div className={styles.dropzoneContent} aria-hidden=\"true\">\n                <UploadSimple className={styles.icon} weight=\"regular\" aria-hidden=\"true\" />\n                <p className={styles.title}>{dropzoneLabel}</p>\n                <p className={styles.description}>\n                  {accept ? `Accepted: ${accept}` : \"All file types accepted\"}\n                  {maxSize !== undefined ? ` · Max ${formatBytes(maxSize)}` : \"\"}\n                  {multiple && maxFiles !== undefined ? ` · Up to ${maxFiles} files` : \"\"}\n                </p>\n              </div>\n            </div>\n\n            {syncUnavailable ? (\n              <p className={styles.description} role=\"note\">\n                File selection was cleared because this browser cannot keep the native file input synchronized with the visible list.\n              </p>\n            ) : null}\n\n            {showRejections ? (\n              <ul id={rejectionListId} className={styles.rejectionList} aria-label=\"Rejected files\">\n                {rejections.map((rejection) => (\n                  <li key={`${rejection.file.name}-${rejection.file.size}-${rejection.message}`} className={styles.rejectionItem}>\n                    {rejection.message}\n                  </li>\n                ))}\n              </ul>\n            ) : null}\n\n            {items.length > 0 ? (\n              <ul className={styles.fileList} aria-label=\"Selected files\">\n                {items.map((item) => (\n                  <li key={item.id} className={styles.fileItem}>\n                    <div className={styles.fileMeta}>\n                      <p className={styles.fileName}>{item.file.name}</p>\n                      <p className={styles.fileDetails}>\n                        {formatBytes(item.file.size)}\n                        {item.file.type ? ` · ${item.file.type}` : \"\"}\n                      </p>\n                    </div>\n                    <button\n                      ref={(node) => {\n                        if (node) {\n                          removeButtonRefs.current.set(item.id, node);\n                        } else {\n                          removeButtonRefs.current.delete(item.id);\n                        }\n                      }}\n                      type=\"button\"\n                      className={styles.removeButton}\n                      aria-label={`Remove ${item.file.name}`}\n                      disabled={disabled}\n                      onClick={() => handleRemove(item)}\n                    >\n                      <X className={styles.removeIcon} aria-hidden=\"true\" />\n                    </button>\n                  </li>\n                ))}\n              </ul>\n            ) : null}\n\n            <div\n              id={statusId}\n              role=\"status\"\n              aria-live=\"polite\"\n              aria-atomic=\"true\"\n              className={styles.statusRegion}\n            >\n              {statusMessage}\n            </div>\n          </div>\n        );\n      }}\n    </FormField>\n  );\n}\n",
      "type": "registry:ui",
      "target": "~/components/ui/FileUpload.tsx"
    },
    {
      "path": "components/ui/file-upload.module.css",
      "content": ".root {\n  display: grid;\n  gap: var(--file-upload-list-gap);\n}\n\n.dropzone {\n  position: relative;\n  display: grid;\n  place-items: center;\n  min-height: var(--file-upload-min-height);\n  padding: var(--file-upload-padding);\n  border: 1.5px var(--file-upload-border-style) var(--file-upload-border);\n  border-radius: var(--file-upload-radius);\n  background-color: var(--file-upload-surface);\n  background-image: var(--component-surface-gradient-overlay);\n  box-shadow: none;\n  backdrop-filter: var(--component-surface-backdrop-filter);\n  transition:\n    border-color 120ms ease,\n    background-color 120ms ease,\n    box-shadow 120ms ease;\n}\n\n.dropzone:focus-within {\n  outline: 2px solid var(--semantic-focus-ring);\n  outline-offset: 2px;\n}\n\n.dropzoneDragging {\n  border-color: var(--file-upload-border-dragging);\n  background: var(--file-upload-dragging-surface);\n  background-image: none;\n}\n\n.dropzoneDragging .icon {\n  color: var(--semantic-action-primary);\n}\n\n.dropzoneDragging .title {\n  color: var(--semantic-text-primary);\n}\n\n.dropzoneError {\n  border-color: var(--file-upload-border-error);\n}\n\n/* Error roles stay split: icon danger/500, title text/danger, border action/danger. */\n.dropzoneError .icon {\n  color: var(--semantic-icon-danger);\n}\n\n.dropzoneError .title {\n  color: var(--semantic-text-danger);\n}\n\n.dropzoneEmpty:not(.dropzoneDragging):not(.dropzoneDisabled):not(.dropzoneError) .description {\n  color: var(--semantic-text-secondary);\n}\n\n.dropzoneDisabled {\n  cursor: not-allowed;\n  opacity: var(--opacity-disabled);\n  background-image: none;\n}\n\n.dropzoneDisabled .title,\n.dropzoneDisabled .description {\n  color: var(--semantic-text-disabled);\n}\n\n.nativeInput {\n  position: absolute;\n  inset: 0;\n  width: 100%;\n  height: 100%;\n  margin: 0;\n  opacity: 0;\n  cursor: pointer;\n}\n\n.nativeInput:disabled {\n  cursor: not-allowed;\n}\n\n.dropzoneContent {\n  display: grid;\n  justify-items: center;\n  gap: 0.5rem;\n  pointer-events: none;\n  text-align: center;\n}\n\n.icon {\n  width: var(--file-upload-icon-size);\n  height: var(--file-upload-icon-size);\n  color: var(--file-upload-icon);\n}\n\n.title {\n  margin: 0;\n  font-size: 0.9375rem;\n  font-weight: 500;\n  color: var(--file-upload-title-text);\n}\n\n.description {\n  margin: 0;\n  font-size: 0.8125rem;\n  color: var(--file-upload-description-text);\n}\n\n.fileList {\n  display: grid;\n  gap: 0;\n  margin: 0;\n  padding: 0;\n  overflow: hidden;\n  border: 1px solid var(--file-upload-item-border);\n  border-radius: var(--file-upload-radius);\n  background-color: var(--file-upload-item-surface);\n  background-image: var(--component-surface-gradient-overlay);\n  box-shadow: none;\n  backdrop-filter: var(--component-surface-backdrop-filter);\n  list-style: none;\n}\n\n.fileItem {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  gap: 0.75rem;\n  padding: var(--file-upload-item-padding);\n  border: 0;\n  border-bottom: 1px solid var(--semantic-border-default);\n  border-radius: 0;\n  background: transparent;\n}\n\n.fileItem:last-child {\n  border-bottom: 0;\n}\n\n.dropzoneDragging ~ .fileList,\n.dropzoneDisabled ~ .fileList {\n  background-image: none;\n}\n\n.fileMeta {\n  min-width: 0;\n}\n\n.fileName {\n  margin: 0;\n  font-size: 0.875rem;\n  font-weight: 500;\n  color: var(--file-upload-file-name-text);\n  overflow-wrap: anywhere;\n}\n\n.fileDetails {\n  margin: 0.125rem 0 0;\n  font-size: 0.75rem;\n  color: var(--file-upload-metadata-text);\n}\n\n.removeButton {\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  flex-shrink: 0;\n  width: var(--file-upload-remove-size);\n  height: var(--file-upload-remove-size);\n  border: 0;\n  border-radius: var(--shape-radius-control);\n  background: transparent;\n  color: var(--component-surface-content-muted);\n  cursor: pointer;\n}\n\n.removeButton:hover {\n  background: var(--semantic-surface-elevated);\n  color: var(--semantic-text-primary);\n}\n\n.removeButton:focus-visible {\n  outline: 2px solid var(--semantic-focus-ring);\n  outline-offset: 2px;\n}\n\n.removeButton:disabled {\n  cursor: not-allowed;\n  opacity: var(--primitive-opacity-disabled);\n}\n\n.removeIcon {\n  width: 1rem;\n  height: 1rem;\n}\n\n.rejectionList {\n  margin: 0;\n  padding-left: 1.125rem;\n  color: var(--semantic-text-danger);\n  font-size: 0.8125rem;\n}\n\n.rejectionItem {\n  margin: 0.125rem 0;\n}\n\n.statusRegion {\n  position: absolute;\n  width: 1px;\n  height: 1px;\n  padding: 0;\n  margin: -1px;\n  overflow: hidden;\n  clip: rect(0, 0, 0, 0);\n  white-space: nowrap;\n  border: 0;\n}\n",
      "type": "registry:ui",
      "target": "~/components/ui/file-upload.module.css"
    },
    {
      "path": "lib/cn.ts",
      "content": "export function cn(...classes: Array<string | false | null | undefined>): string {\n  return classes.filter(Boolean).join(\" \");\n}\n",
      "type": "registry:lib",
      "target": "~/lib/cn.ts"
    },
    {
      "path": "components/ui/internal/file-upload-file-list.ts",
      "content": "export type FileUploadDisplayItem = {\n  id: string;\n  file: File;\n};\n\nexport function createFileItemId(file: File, occurrenceIndex: number): string {\n  return `${file.name}:${file.size}:${file.type}:${file.lastModified}:${occurrenceIndex}`;\n}\n\nexport function buildDisplayItems(files: File[]): FileUploadDisplayItem[] {\n  return files.map((file, index) => ({\n    id: createFileItemId(file, index),\n    file,\n  }));\n}\n\nfunction buildFileList(files: File[]): FileList {\n  const list = {\n    length: files.length,\n    item: (index: number) => files[index] ?? null,\n    [Symbol.iterator]: () => files[Symbol.iterator](),\n  } as FileList;\n\n  files.forEach((file, index) => {\n    Object.defineProperty(list, index, { value: file, enumerable: true });\n  });\n\n  return list;\n}\n\nexport function supportsDataTransferFileAssignment(): boolean {\n  if (typeof DataTransfer === \"undefined\") return false;\n  const input = document.createElement(\"input\");\n  input.type = \"file\";\n  return assignFilesToInput(input, [new File([\"test\"], \"test.txt\", { type: \"text/plain\" })]);\n}\n\nexport function assignFilesToInput(input: HTMLInputElement, files: File[]): boolean {\n  try {\n    const transfer = new DataTransfer();\n    for (const file of files) {\n      transfer.items.add(file);\n    }\n\n    input.files = transfer.files;\n    if (input.files && input.files.length === files.length) {\n      return true;\n    }\n  } catch {\n    // Fall through to defineProperty assignment for environments like jsdom.\n  }\n\n  try {\n    Object.defineProperty(input, \"files\", {\n      configurable: true,\n      value: buildFileList(files),\n    });\n    return (input.files?.length ?? 0) === files.length;\n  } catch {\n    return false;\n  }\n}\n\nexport function filesMatchInputSelection(input: HTMLInputElement, files: File[]): boolean {\n  const current = Array.from(input.files ?? []);\n  return (\n    current.length === files.length &&\n    current.every((file, index) => file === files[index])\n  );\n}\n\nexport function syncAcceptedFilesToInput(input: HTMLInputElement, files: File[]): boolean {\n  if (files.length === 0) {\n    clearNativeFileInput(input);\n    return (input.files?.length ?? 0) === 0;\n  }\n\n  if (filesMatchInputSelection(input, files)) {\n    return true;\n  }\n\n  return assignFilesToInput(input, files);\n}\n\nexport function clearNativeFileInput(input: HTMLInputElement): void {\n  input.value = \"\";\n  try {\n    Object.defineProperty(input, \"files\", {\n      configurable: true,\n      value: buildFileList([]),\n    });\n  } catch {\n    // Native reset via value=\"\" is sufficient in browsers that expose an empty FileList.\n  }\n}\n",
      "type": "registry:lib",
      "target": "~/components/ui/internal/file-upload-file-list.ts"
    },
    {
      "path": "components/ui/internal/file-upload-validation.ts",
      "content": "export type FileUploadRejectionCode = \"file-type\" | \"file-size\" | \"max-files\";\n\nexport type FileUploadRejection = {\n  file: File;\n  code: FileUploadRejectionCode;\n  message: string;\n};\n\nexport function parseAcceptTokens(accept?: string): string[] {\n  if (!accept?.trim()) return [];\n  return accept\n    .split(\",\")\n    .map((token) => token.trim().toLowerCase())\n    .filter(Boolean);\n}\n\nexport function fileMatchesAccept(file: File, accept?: string): boolean {\n  const tokens = parseAcceptTokens(accept);\n  if (!tokens.length) return true;\n\n  const fileType = file.type.toLowerCase();\n  const fileName = file.name.toLowerCase();\n\n  return tokens.some((token) => {\n    if (token.startsWith(\".\")) {\n      return fileName.endsWith(token);\n    }\n    if (token.endsWith(\"/*\")) {\n      const prefix = token.slice(0, -1);\n      return fileType.startsWith(prefix);\n    }\n    return fileType === token;\n  });\n}\n\nexport function buildRejectionMessage(\n  file: File,\n  code: FileUploadRejectionCode,\n  maxSize?: number,\n  maxFiles?: number,\n): string {\n  switch (code) {\n    case \"file-type\":\n      return `${file.name} is not an accepted file type.`;\n    case \"file-size\":\n      return `${file.name} exceeds the ${formatBytes(maxSize ?? 0)} limit.`;\n    case \"max-files\":\n      return `${file.name} exceeds the maximum of ${maxFiles ?? 1} file${maxFiles === 1 ? \"\" : \"s\"}.`;\n    default:\n      return `${file.name} was rejected.`;\n  }\n}\n\nexport function formatBytes(bytes: number): string {\n  if (bytes < 1024) return `${bytes} B`;\n  if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`;\n  return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;\n}\n\nexport function validateFileBatch(options: {\n  files: File[];\n  accept?: string;\n  maxSize?: number;\n  maxFiles?: number;\n  multiple?: boolean;\n}): { accepted: File[]; rejected: FileUploadRejection[] } {\n  const { files, accept, maxSize, maxFiles, multiple = false } = options;\n  const accepted: File[] = [];\n  const rejected: FileUploadRejection[] = [];\n  const limit = multiple ? maxFiles ?? Number.POSITIVE_INFINITY : 1;\n\n  for (const file of files) {\n    if (!fileMatchesAccept(file, accept)) {\n      rejected.push({\n        file,\n        code: \"file-type\",\n        message: buildRejectionMessage(file, \"file-type\"),\n      });\n      continue;\n    }\n\n    if (maxSize !== undefined && file.size > maxSize) {\n      rejected.push({\n        file,\n        code: \"file-size\",\n        message: buildRejectionMessage(file, \"file-size\", maxSize),\n      });\n      continue;\n    }\n\n    if (accepted.length >= limit) {\n      rejected.push({\n        file,\n        code: \"max-files\",\n        message: buildRejectionMessage(file, \"max-files\", maxSize, multiple ? maxFiles ?? limit : 1),\n      });\n      continue;\n    }\n\n    accepted.push(file);\n  }\n\n  return { accepted, rejected };\n}\n",
      "type": "registry:lib",
      "target": "~/components/ui/internal/file-upload-validation.ts"
    }
  ]
}
