{
  "$schema": "https://pdfx.akashpise.dev/schema/registry-item.json",
  "name": "watermark",
  "type": "registry:ui",
  "title": "Watermark",
  "description": "Diagonal or positioned text overlay for DRAFT, CONFIDENTIAL, PAID, etc.",
  "files": [
    {
      "path": "components/pdfx/watermark/pdfx-watermark.tsx",
      "content": "import { Text as PDFText, StyleSheet, View } from '@react-pdf/renderer';\nimport type { Style } from '@react-pdf/types';\nimport { usePdfxTheme, useSafeMemo } from '../lib/pdfx-theme-context';\ntype PdfxTheme = ReturnType<typeof usePdfxTheme>;\n\nexport type WatermarkPosition =\n  | 'center'\n  | 'top-left'\n  | 'top-right'\n  | 'bottom-left'\n  | 'bottom-right';\n\n/**\n * Diagonal watermark overlaid across the full page using absolute positioning.\n * Props - `text` | `opacity` | `fontSize` | `color` | `angle` | `position` | `fixed` | `style`\n * @see {@link PdfWatermarkProps}\n */\nexport interface PdfWatermarkProps {\n  /** Custom styles to merge with component defaults */\n  style?: Style;\n  text: string;\n  opacity?: number;\n  fontSize?: number;\n  color?: string;\n  angle?: number;\n  position?: WatermarkPosition;\n  /**\n   * @default true\n   */\n  fixed?: boolean;\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 createWatermarkStyles(t: PdfxTheme) {\n  const { fontWeights } = t.primitives;\n  // Use page margins as corner insets so watermark position adapts to the active theme.\n  const { marginTop, marginBottom, marginLeft, marginRight } = t.spacing.page;\n  return StyleSheet.create({\n    container: {\n      position: 'absolute',\n      top: 0,\n      left: 0,\n      right: 0,\n      bottom: 0,\n      justifyContent: 'center',\n      alignItems: 'center',\n      zIndex: -1,\n      pointerEvents: 'none',\n    },\n    text: {\n      fontFamily: t.typography.heading.fontFamily,\n      fontWeight: fontWeights.bold,\n      textTransform: 'uppercase',\n      letterSpacing: 4,\n    },\n    positionCenter: { justifyContent: 'center', alignItems: 'center' },\n    positionTopLeft: {\n      justifyContent: 'flex-start',\n      alignItems: 'flex-start',\n      paddingTop: marginTop,\n      paddingLeft: marginLeft,\n    },\n    positionTopRight: {\n      justifyContent: 'flex-start',\n      alignItems: 'flex-end',\n      paddingTop: marginTop,\n      paddingRight: marginRight,\n    },\n    positionBottomLeft: {\n      justifyContent: 'flex-end',\n      alignItems: 'flex-start',\n      paddingBottom: marginBottom,\n      paddingLeft: marginLeft,\n    },\n    positionBottomRight: {\n      justifyContent: 'flex-end',\n      alignItems: 'flex-end',\n      paddingBottom: marginBottom,\n      paddingRight: marginRight,\n    },\n  });\n}\n\nexport function PdfWatermark({\n  text,\n  opacity = 0.15,\n  fontSize = 60,\n  color = 'mutedForeground',\n  angle = -45,\n  position = 'center',\n  fixed = true,\n  style,\n}: PdfWatermarkProps) {\n  const theme = usePdfxTheme();\n  const styles = useSafeMemo(() => createWatermarkStyles(theme), [theme]);\n  const positionMap: Record<WatermarkPosition, Style> = {\n    center: styles.positionCenter,\n    'top-left': styles.positionTopLeft,\n    'top-right': styles.positionTopRight,\n    'bottom-left': styles.positionBottomLeft,\n    'bottom-right': styles.positionBottomRight,\n  };\n  const containerStyles: Style[] = [styles.container, positionMap[position]];\n  if (style) containerStyles.push(...[style].flat());\n  const textStyles: Style[] = [\n    styles.text,\n    {\n      fontSize,\n      color: resolveColor(color, theme.colors),\n      opacity,\n      transform: `rotate(${angle}deg)`,\n    },\n  ];\n  return (\n    <View style={containerStyles} fixed={fixed}>\n      <PDFText style={textStyles}>{text}</PDFText>\n    </View>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "dependencies": [
    "@react-pdf/renderer"
  ],
  "registryDependencies": [
    "theme"
  ]
}