{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "bounding-box-citations-block",
  "title": "Bounding Box Citations",
  "description": "An extraction citation block linked to source PDF bounding boxes.",
  "registryDependencies": [
    "@extend/bounding-box-citations",
    "@extend/pdf-block-resizable-shell",
    "@extend/pdf-viewer"
  ],
  "files": [
    {
      "path": "registry/new-york-v4/blocks/bounding-box-citations-block.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport {\n  findReviewField,\n  getMetadataLocation,\n  getReviewFieldLocation,\n  getReviewLocationKey,\n  HumanReviewHighlight,\n  HumanReviewPanel,\n  REVIEW_FIELDS,\n  type HumanReviewTheme,\n  type JsonValue,\n  type ReviewField,\n  type ReviewLocation,\n  type ReviewMetadataEntry,\n} from \"@/components/extend/bounding-box-citations\"\nimport { PdfBlockResizableShell } from \"@/components/extend/pdf-block-resizable-shell\"\nimport { PDFViewer, type PDFViewerHandle } from \"@/components/extend/pdf-viewer\"\n\nconst DEFAULT_ZOOM = 1\nexport function HumanReviewBlock({\n  file,\n  fields = REVIEW_FIELDS,\n  className,\n  metadata,\n  resolveArrayItemMetadataPath,\n  resolveLocation,\n  showExpected = true,\n  theme,\n}: {\n  file?: string\n  fields?: ReviewField[]\n  className?: string\n  metadata?: Record<string, ReviewMetadataEntry>\n  resolveArrayItemMetadataPath?: (\n    metadataPath: string,\n    rowIndex: number,\n    rowValue: JsonValue\n  ) => string | undefined\n  resolveLocation?: (metadataPath: string) => ReviewLocation | undefined\n  showExpected?: boolean\n  theme?: HumanReviewTheme\n}) {\n  const [activeFieldKey, setActiveFieldKey] = React.useState(fields[0]?.key)\n  const [hoverLocation, setHoverLocation] =\n    React.useState<ReviewLocation | null>(null)\n  const viewerRef = React.useRef<PDFViewerHandle>(null)\n  const hoverLocationKeyRef = React.useRef<string | null>(null)\n  const resolveFieldLocation = React.useCallback(\n    (metadataPath: string) =>\n      resolveLocation?.(metadataPath) ??\n      getMetadataLocation(metadata, metadataPath),\n    [metadata, resolveLocation]\n  )\n  const activeField = findReviewField(fields, activeFieldKey) ?? fields[0]\n  const activeLocation =\n    hoverLocation ?? getReviewFieldLocation(activeField, resolveFieldLocation)\n  if (!activeFieldKey && fields[0]) {\n    setActiveFieldKey(fields[0].key)\n  }\n  const focusField = React.useCallback(\n    (field: ReviewField) => {\n      if (field.key === activeFieldKey) return\n      setActiveFieldKey(field.key)\n      const location = getReviewFieldLocation(field, resolveFieldLocation)\n      if (location) {\n        viewerRef.current?.scrollToPageArea(location.page, location.area)\n      }\n    },\n    [activeFieldKey, resolveFieldLocation]\n  )\n  const handleLocationHover = React.useCallback((location?: ReviewLocation) => {\n    setHoverLocation(location ?? null)\n    const locationKey = getReviewLocationKey(location)\n    if (!location) {\n      hoverLocationKeyRef.current = null\n      return\n    }\n    if (locationKey === hoverLocationKeyRef.current) return\n    hoverLocationKeyRef.current = locationKey\n    viewerRef.current?.scrollToPageArea(location.page, location.area, {\n      behavior: \"auto\",\n    })\n  }, [])\n  return (\n    <PdfBlockResizableShell\n      autoSaveId=\"pdf-block-bounding-box-citations\"\n      className={className}\n      rightDefaultSize={42}\n      rightMaxSize={60}\n      rightMinSize={30}\n      left={\n        <PDFViewer\n          ref={viewerRef}\n          src={file}\n          defaultZoom={DEFAULT_ZOOM}\n          renderPageOverlay={({ pageNumber }) =>\n            activeLocation?.page === pageNumber ? (\n              <HumanReviewHighlight location={activeLocation} />\n            ) : null\n          }\n        />\n      }\n      right={\n        <aside className=\"min-h-0 bg-background\">\n          <HumanReviewPanel\n            fields={fields}\n            activeFieldKey={activeField?.key}\n            className=\"h-full min-h-0\"\n            theme={theme}\n            showExpected={showExpected}\n            onFieldFocus={focusField}\n            onLocationHover={handleLocationHover}\n            resolveArrayItemMetadataPath={resolveArrayItemMetadataPath}\n            resolveLocation={resolveFieldLocation}\n          />\n        </aside>\n      }\n    />\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/blocks/bounding-box-citations-block.tsx"
    }
  ],
  "categories": [
    "documents",
    "blocks"
  ],
  "type": "registry:block",
  "dependencies": []
}
