{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "category-core",
  "type": "registry:ui",
  "title": "Category Pictogram Core",
  "description": "The 1024-grid category pictogram renderer: transparent ink, gradient split orbs and comets, and a tiny hover travel.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "meta": {
    "style": "category",
    "grid": 1024,
    "stroke": 23,
    "display": 40,
    "hover": "spring, 320 / 24"
  },
  "files": [
    {
      "path": "components/prequelui/categories/category-core.tsx",
      "target": "components/prequelui/categories/category-core.tsx",
      "type": "registry:ui",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { useReducedMotion } from \"motion/react\";\nimport { cn } from \"@/lib/utils\";\n\nexport type CategoryPictogramPart = {\n  d: string;\n  fill?: boolean;\n  width?: number;\n  opacity?: number;\n  transform?: string;\n};\n\nexport type CategoryPictogramMotion = {\n  x?: number;\n  y?: number;\n  rotate?: number;\n  scale?: number;\n};\n\nexport type CategoryPictogramDefinition = {\n  slug: string;\n  name: string;\n  group: string;\n  theme: string;\n  keywords: string[];\n  description: string;\n  motion: string;\n  isNew?: boolean;\n  ink: CategoryPictogramPart[];\n  accent: CategoryPictogramPart[];\n  palette: { light: [string, string]; dark: [string, string] };\n  motionConfig: {\n    main: CategoryPictogramMotion;\n    accent: CategoryPictogramMotion;\n  };\n};\n\nexport type CategoryPictogramProps = Omit<\n  React.ComponentPropsWithoutRef<\"span\">,\n  \"children\"\n> & {\n  definition: CategoryPictogramDefinition;\n  size?: number;\n  active?: boolean;\n  animateOnHover?: boolean;\n  label?: string;\n};\n\nconst BASE = { x: 0, y: 0, rotate: 0, scale: 1 };\nconst PICTURE_EASE = \"cubic-bezier(0.34, 1.3, 0.64, 1)\";\n\n/*\n * The artwork is authored in a 1024 grid with generous padding so the accents\n * can breathe. Displayed in a 40 px slot, that padding made the glyph read like\n * a 20 px icon. Scaling the art around the centre brings the visual keyline to\n * the measured 28-30 px while the stroke is counter-scaled to stay hairline.\n */\nconst ART_SCALE = 1.32;\nconst ART_TRANSFORM = `translate(512 512) scale(${ART_SCALE}) translate(-512 -512)`;\nconst INK_STROKE = 23;\n/* The reference builds its keylines as filled bands, which read a touch\n   heavier than a 0.9 px stroke. A small optical boost keeps the same presence\n   without leaving the hairline family. */\nconst STROKE_BOOST = 1.12;\n\nfunction targetOf(\n  base: CategoryPictogramMotion,\n  motion: CategoryPictogramMotion | undefined,\n): CategoryPictogramMotion {\n  return { ...base, ...(motion ?? {}) };\n}\n\nfunction escapeXml(value: string | number) {\n  return String(value)\n    .replace(/&/g, \"&amp;\")\n    .replace(/\"/g, \"&quot;\")\n    .replace(/</g, \"&lt;\")\n    .replace(/>/g, \"&gt;\");\n}\n\nexport function categoryGradient(\n  definition: CategoryPictogramDefinition,\n  id: string,\n) {\n  const { light, dark } = definition.palette;\n  return `<linearGradient id=\"${id}\" x1=\"0\" y1=\"1\" x2=\"1\" y2=\"0\"><stop stop-color=\"light-dark(${light[0]}, ${dark[0]})\"/><stop offset=\"1\" stop-color=\"light-dark(${light[1]}, ${dark[1]})\"/></linearGradient>`;\n}\n\nfunction accentMarkup(part: CategoryPictogramPart, gradientId: string) {\n  return `<path d=\"${escapeXml(part.d)}\"${part.transform ? ` transform=\"${escapeXml(part.transform)}\"` : \"\"} fill=\"url(#${gradientId})\"${part.opacity !== undefined ? ` opacity=\"${part.opacity}\"` : \"\"}/>`;\n}\n\nfunction inkMarkup(part: CategoryPictogramPart) {\n  const transform = part.transform ? ` transform=\"${escapeXml(part.transform)}\"` : \"\";\n  if (part.fill) {\n    return `<path d=\"${escapeXml(part.d)}\"${transform} fill=\"currentColor\" fill-rule=\"evenodd\"${part.opacity !== undefined ? ` opacity=\"${part.opacity}\"` : \"\"}/>`;\n  }\n  const width = ((part.width ?? INK_STROKE) * STROKE_BOOST) / ART_SCALE;\n  return `<path d=\"${escapeXml(part.d)}\"${transform} fill=\"none\" stroke=\"currentColor\" stroke-width=\"${width}\" stroke-linecap=\"round\" stroke-linejoin=\"round\"${part.opacity !== undefined ? ` opacity=\"${part.opacity}\"` : \"\"}/>`;\n}\n\nexport function buildCategorySvg(\n  definition: CategoryPictogramDefinition,\n  size = 40,\n) {\n  const gradientId = `cat-${definition.slug}`;\n  return `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${size}\" height=\"${size}\" viewBox=\"0 0 1024 1024\" fill=\"none\" style=\"color-scheme: light dark\" aria-hidden=\"true\"><defs>${categoryGradient(definition, gradientId)}</defs><g transform=\"${ART_TRANSFORM}\"><g>${definition.accent.map((part) => accentMarkup(part, gradientId)).join(\"\")}</g><g>${definition.ink.map(inkMarkup).join(\"\")}</g></g></svg>`;\n}\n\nexport function CategoryPictogram({\n  definition,\n  size = 40,\n  active,\n  animateOnHover = true,\n  label,\n  className,\n  onPointerEnter,\n  onPointerLeave,\n  ...props\n}: CategoryPictogramProps) {\n  const reactId = React.useId();\n  const gradientId = `cat-${definition.slug}-${reactId.replace(/[^a-zA-Z0-9_-]/g, \"\")}`;\n  const reduce = useReducedMotion();\n  const [hovered, setHovered] = React.useState(false);\n  const isActive =\n    !!animateOnHover && !reduce && (active === undefined ? hovered : active);\n  const { light, dark } = definition.palette;\n\n  const mainTarget = targetOf(BASE, isActive ? definition.motionConfig.main : undefined);\n  const accentTarget = targetOf(\n    BASE,\n    isActive ? definition.motionConfig.accent : undefined,\n  );\n  const transformOf = (target: CategoryPictogramMotion) =>\n    `translate3d(${target.x ?? 0}px, ${target.y ?? 0}px, 0) rotate(${target.rotate ?? 0}deg) scale(${target.scale ?? 1})`;\n  const transition = reduce\n    ? \"none\"\n    : `transform 520ms ${PICTURE_EASE}`;\n\n  const accessibility = label\n    ? { role: \"img\" as const, \"aria-label\": label }\n    : { \"aria-hidden\": true as const };\n\n  return (\n    <span\n      {...props}\n      data-category-pictogram-host=\"\"\n      data-active={active && animateOnHover ? \"true\" : undefined}\n      className={cn(\"inline-flex shrink-0 items-center justify-center\", className)}\n      onPointerEnter={(event) => {\n        onPointerEnter?.(event);\n        if (animateOnHover) setHovered(true);\n      }}\n      onPointerLeave={(event) => {\n        onPointerLeave?.(event);\n        setHovered(false);\n      }}\n    >\n      <svg\n        xmlns=\"http://www.w3.org/2000/svg\"\n        width={size}\n        height={size}\n        viewBox=\"0 0 1024 1024\"\n        fill=\"none\"\n        data-category-pictogram={definition.slug}\n        data-category-motion={definition.motion}\n        {...accessibility}\n      >\n        <defs>\n          <linearGradient id={gradientId} x1=\"0\" y1=\"1\" x2=\"1\" y2=\"0\">\n            <stop stopColor={`light-dark(${light[0]}, ${dark[0]})`} />\n            <stop offset=\"1\" stopColor={`light-dark(${light[1]}, ${dark[1]})`} />\n          </linearGradient>\n        </defs>\n        <g transform={ART_TRANSFORM}>\n          <g\n            data-category-accents=\"\"\n            fill={`url(#${gradientId})`}\n            style={{\n              transform: transformOf(accentTarget),\n              transition,\n              transformBox: \"fill-box\",\n              transformOrigin: \"center\",\n            }}\n          >\n            {definition.accent.map((part, index) => (\n              <path\n                key={`a${index}`}\n                d={part.d}\n                transform={part.transform}\n                opacity={part.opacity}\n              />\n            ))}\n          </g>\n          <g\n            data-category-ink=\"\"\n            style={{\n              transform: transformOf(mainTarget),\n              transition,\n              transformBox: \"fill-box\",\n              transformOrigin: \"center\",\n            }}\n          >\n            {definition.ink.map((part, index) =>\n              part.fill ? (\n                <path\n                  key={`i${index}`}\n                  d={part.d}\n                  transform={part.transform}\n                  fill=\"currentColor\"\n                  fillRule=\"evenodd\"\n                  opacity={part.opacity}\n                />\n              ) : (\n                <path\n                  key={`i${index}`}\n                  d={part.d}\n                  transform={part.transform}\n                  fill=\"none\"\n                  stroke=\"currentColor\"\n                  strokeWidth={\n                    ((part.width ?? INK_STROKE) * STROKE_BOOST) / ART_SCALE\n                  }\n                  strokeLinecap=\"round\"\n                  strokeLinejoin=\"round\"\n                  opacity={part.opacity}\n                />\n              ),\n            )}\n          </g>\n        </g>\n      </svg>\n    </span>\n  );\n}\n"
    }
  ]
}
