{
  "$schema": "https://pdfx.akashpise.dev/schema/registry-item.json",
  "name": "link",
  "type": "registry:ui",
  "title": "Link",
  "description": "PDF link component for hyperlinks",
  "files": [
    {
      "path": "components/pdfx/link/pdfx-link.tsx",
      "content": "import { Link as PDFLink, StyleSheet } from '@react-pdf/renderer';\nimport type { Style } from '@react-pdf/types';\nimport { usePdfxTheme, useSafeMemo } from '../lib/pdfx-theme-context';\nimport type React from 'react';\ntype PdfxTheme = ReturnType<typeof usePdfxTheme>;\n\nexport type LinkVariant = 'default' | 'muted' | 'primary';\nexport type LinkUnderline = 'always' | 'none';\n\n/**\n * Clickable hyperlink for PDF documents.\n * Props - `href` | `children` | `align` | `color` | `variant` | `underline` | `style`\n * @see {@link LinkProps}\n */\nexport interface LinkProps {\n  /** Custom styles to merge with component defaults */\n  style?: Style;\n  /** Content to render */\n  children: React.ReactNode;\n  href: string;\n  /**\n   * @default 'left'\n   */\n  align?: 'left' | 'center' | 'right';\n  color?: string;\n  /**\n   * @default 'default'\n   */\n  variant?: LinkVariant;\n  /**\n   * @default 'always'\n   */\n  underline?: LinkUnderline;\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 createLinkStyles(t: PdfxTheme) {\n  const { fontWeights } = t.primitives;\n  const base = {\n    fontFamily: t.typography.body.fontFamily,\n    fontSize: t.typography.body.fontSize,\n    lineHeight: t.typography.body.lineHeight,\n    marginBottom: t.spacing.paragraphGap,\n  };\n  return StyleSheet.create({\n    default: {\n      ...base,\n      color: t.colors.accent,\n      fontWeight: fontWeights.medium,\n      textDecoration: 'underline',\n    },\n    muted: {\n      ...base,\n      color: t.colors.mutedForeground,\n      fontWeight: fontWeights.regular,\n      textDecoration: 'underline',\n    },\n    primary: {\n      ...base,\n      color: t.colors.primary,\n      fontWeight: fontWeights.semibold,\n      textDecoration: 'underline',\n    },\n    underlineAlways: { textDecoration: 'underline' },\n    underlineNone: { textDecoration: 'none' },\n  });\n}\n\nexport function Link({\n  href,\n  align,\n  color,\n  variant = 'default',\n  underline,\n  children,\n  style,\n}: LinkProps) {\n  const theme = usePdfxTheme();\n  const styles = useSafeMemo(() => createLinkStyles(theme), [theme]);\n  const variantMap = { default: styles.default, muted: styles.muted, primary: styles.primary };\n  const underlineMap = { always: styles.underlineAlways, none: styles.underlineNone };\n  const styleArray: Style[] = [variantMap[variant]];\n  if (underline && underline in underlineMap) styleArray.push(underlineMap[underline]);\n  const semantic = {} as Style;\n  if (align) semantic.textAlign = align;\n  if (color) semantic.color = resolveColor(color, theme.colors);\n  if (Object.keys(semantic).length > 0) styleArray.push(semantic);\n  if (style) styleArray.push(...[style].flat());\n  return (\n    <PDFLink src={href} style={styleArray}>\n      {children}\n    </PDFLink>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "dependencies": [
    "@react-pdf/renderer"
  ],
  "registryDependencies": [
    "theme"
  ]
}