{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pdf-dropzone",
  "title": "PDF Dropzone",
  "description": "A PDF-only upload dropzone that opens the dropped file in the shared PDF viewer.",
  "registryDependencies": [
    "@extend/file-upload",
    "@extend/pdf-viewer"
  ],
  "files": [
    {
      "path": "registry/new-york-v4/blocks/pdf-dropzone.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { FileUpload } from \"@/components/extend/file-upload\"\nimport { PDFViewer } from \"@/components/extend/pdf-viewer\"\nimport { IconPlaceholder } from \"@/components/icon-placeholder\"\n\nfunction FileUploadGlyph(props: InlineRegistryIconProps) {\n  return (\n    <IconPlaceholder\n      lucide=\"FileUp\"\n      tabler=\"IconFileUpload\"\n      hugeicons=\"FileUploadIcon\"\n      phosphor=\"FileArrowUpIcon\"\n      remixicon=\"RiFileUploadLine\"\n      {...props}\n    />\n  )\n}\nconst PDF_ACCEPT = \"application/pdf,.pdf\"\nconst PDF_UPLOAD_DROPZONE_SELECTOR = \"[data-pdf-upload-dropzone]\"\nfunction isPdfFile(file: File) {\n  return (\n    file.type === \"application/pdf\" || file.name.toLowerCase().endsWith(\".pdf\")\n  )\n}\nexport function PdfDropzoneBlock() {\n  const [pdfFile, setPdfFile] = React.useState<{\n    name: string\n    url: string\n  } | null>(null)\n  const objectUrlRef = React.useRef<string | null>(null)\n  const loadPdf = React.useCallback((files: File[]) => {\n    const nextFile = files.find(isPdfFile)\n    if (!nextFile) return\n    const nextUrl = URL.createObjectURL(nextFile)\n    if (objectUrlRef.current) URL.revokeObjectURL(objectUrlRef.current)\n    objectUrlRef.current = nextUrl\n    setPdfFile({ name: nextFile.name, url: nextUrl })\n  }, [])\n  React.useEffect(() => {\n    return () => {\n      if (objectUrlRef.current) URL.revokeObjectURL(objectUrlRef.current)\n    }\n  }, [])\n  if (!pdfFile) {\n    return (\n      <div\n        className=\"grid h-full min-h-[680px] place-items-center bg-background p-4\"\n        onDragEnter={(event) => event.preventDefault()}\n        onDragOver={(event) => event.preventDefault()}\n        onDrop={(event) => {\n          event.preventDefault()\n          const target = event.target\n          if (\n            target instanceof Element &&\n            target.closest(PDF_UPLOAD_DROPZONE_SELECTOR)\n          ) {\n            return\n          }\n          if (event.dataTransfer.files.length > 0) {\n            loadPdf(Array.from(event.dataTransfer.files))\n          }\n        }}\n      >\n        <div data-pdf-upload-dropzone className=\"w-full max-w-xl\">\n          <FileUpload\n            accept={PDF_ACCEPT}\n            acceptedFileTypes={[{ label: \"PDF\", icon: FileUploadGlyph }]}\n            browseLabel=\"Browse PDF\"\n            className=\"w-full\"\n            description=\"PDF files only\"\n            draggingLabel=\"Drop PDF\"\n            multiple={false}\n            showFileList={false}\n            title=\"Drop a PDF to preview\"\n            onFilesAccepted={loadPdf}\n          />\n        </div>\n      </div>\n    )\n  }\n  return (\n    <div className=\"h-full min-h-[680px] bg-background\">\n      <PDFViewer\n        key={pdfFile.url}\n        src={pdfFile.url}\n        defaultZoom={1}\n        fileName={pdfFile.name}\n        onPdfUpload={(file) => loadPdf([file])}\n        toolbarActions={\n          <div className=\"hidden max-w-40 truncate text-xs text-muted-foreground sm:block\">\n            {pdfFile.name}\n          </div>\n        }\n      />\n    </div>\n  )\n}\ntype InlineRegistryIconProps = Omit<\n  React.ComponentProps<\"svg\">,\n  \"children\" | \"strokeWidth\"\n> & { strokeWidth?: number }\n",
      "type": "registry:component",
      "target": "@components/blocks/pdf-dropzone.tsx"
    }
  ],
  "categories": [
    "documents",
    "blocks"
  ],
  "type": "registry:block",
  "dependencies": []
}
