{
  "$schema": "https://pdfx.akashpise.dev/schema/registry-item.json",
  "name": "qrcode",
  "type": "registry:ui",
  "title": "QRCode",
  "description": "Native SVG QR code for URLs, payments, and document verification",
  "files": [
    {
      "path": "components/pdfx/qrcode/pdfx-qrcode.tsx",
      "content": "import { Text as PDFText, Rect, StyleSheet, Svg, View } from '@react-pdf/renderer';\nimport type { Style } from '@react-pdf/types';\nimport QRCode from 'qrcode';\nimport { usePdfxTheme, useSafeMemo } from '../lib/pdfx-theme-context';\ntype PdfxTheme = ReturnType<typeof usePdfxTheme>;\n\nexport type QRCodeErrorLevel = 'L' | 'M' | 'Q' | 'H';\n\n/**\n * QR code rendered as an SVG grid for use in PDF documents.\n * Props - `value` | `size` | `color` | `backgroundColor` | `errorLevel` | `margin` | `caption` | `style`\n * @see {@link PdfQRCodeProps}\n */\nexport interface PdfQRCodeProps {\n  /** Custom styles to merge with component defaults */\n  style?: Style;\n  value: string;\n  size?: number;\n  color?: string;\n  backgroundColor?: string;\n  errorLevel?: QRCodeErrorLevel;\n  margin?: number;\n  caption?: string;\n  children?: never;\n}\n\nconst THEME_COLOR_KEYS = ['foreground','muted','mutedForeground','primary','primaryForeground','accent','destructive','success','warning','info'] as const;\nfunction resolveColor(value: string, colors: Record<string, string>): string {\n  return THEME_COLOR_KEYS.includes(value as (typeof THEME_COLOR_KEYS)[number]) ? colors[value] : value;\n}\nfunction createQRCodeStyles(t: PdfxTheme) {\n  const { spacing } = t.primitives;\n  return StyleSheet.create({\n    container: { alignItems: 'center' },\n    caption: {\n      fontFamily: t.typography.body.fontFamily,\n      fontSize: t.primitives.typography.xs,\n      color: t.colors.mutedForeground,\n      marginTop: spacing[1],\n      textAlign: 'center',\n    },\n  });\n}\n\nfunction generateQRMatrix(\n  value: string,\n  errorLevel: QRCodeErrorLevel,\n  margin: number\n): boolean[][] {\n  const qr = QRCode.create(value, { errorCorrectionLevel: errorLevel });\n  const { size, data } = qr.modules;\n  const totalSize = size + margin * 2;\n  const matrix: boolean[][] = [];\n  for (let row = 0; row < totalSize; row++) {\n    const rowData: boolean[] = [];\n    for (let col = 0; col < totalSize; col++) {\n      const isInMargin =\n        row < margin || row >= size + margin || col < margin || col >= size + margin;\n      if (isInMargin) {\n        rowData.push(false);\n      } else {\n        rowData.push(data[(row - margin) * size + (col - margin)] === 1);\n      }\n    }\n    matrix.push(rowData);\n  }\n  return matrix;\n}\n\nexport function PdfQRCode({\n  value,\n  size = 100,\n  color = '#000000',\n  backgroundColor = '#ffffff',\n  errorLevel = 'M',\n  margin = 2,\n  caption,\n  style,\n}: PdfQRCodeProps) {\n  const theme = usePdfxTheme();\n  const styles = useSafeMemo(() => createQRCodeStyles(theme), [theme]);\n  const matrix = useSafeMemo(\n    () => generateQRMatrix(value, errorLevel, margin),\n    [value, errorLevel, margin]\n  );\n  const moduleSize = size / matrix.length;\n  const resolvedColor = resolveColor(color, theme.colors);\n  const resolvedBgColor =\n    backgroundColor === 'transparent' ? undefined : resolveColor(backgroundColor, theme.colors);\n  const containerStyles: Style[] = [styles.container];\n  if (style) containerStyles.push(...[style].flat());\n\n  return (\n    <View style={containerStyles}>\n      <Svg width={size} height={size} viewBox={`0 0 ${size} ${size}`}>\n        {resolvedBgColor !== undefined && (\n          <Rect x={0} y={0} width={size} height={size} fill={resolvedBgColor} />\n        )}\n        {matrix\n          .flatMap((row, y) =>\n            row\n              .map((isDark, x) => (isDark ? { x, y } : null))\n              .filter((pos): pos is { x: number; y: number } => pos !== null)\n          )\n          .map((pos) => (\n            <Rect\n              key={`qr-${pos.y}-${pos.x}`}\n              x={pos.x * moduleSize}\n              y={pos.y * moduleSize}\n              width={moduleSize}\n              height={moduleSize}\n              fill={resolvedColor}\n            />\n          ))}\n      </Svg>\n      {caption && <PDFText style={styles.caption}>{caption}</PDFText>}\n    </View>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "dependencies": [
    "@react-pdf/renderer",
    "qrcode"
  ],
  "devDependencies": [
    "@types/qrcode"
  ],
  "registryDependencies": [
    "theme"
  ]
}