{
  "name": "link-preview",
  "type": "registry:ui",
  "description": "Origin Kit hover link preview adapted for Canadian AI surfaces",
  "files": [
    {
      "path": "components/origin-kit/link-preview.tsx",
      "content": "// Upstream: Originkit link-preview (MIT). Adapted for CAI; preserve this provenance notice.\\n\"use client\";\n\nimport {\n    AnimatePresence,\n    motion,\n    useMotionValue,\n    useSpring,\n    useTransform,\n} from \"framer-motion\"\nimport { useRef, useState, type CSSProperties } from \"react\"\n\n// In Next.js there is no static renderer — always returns false.\nfunction useIsStaticRenderer(): boolean {\n    return false\n}\n\ninterface ImageValue {\n    src: string\n    srcSet?: string\n    alt?: string\n}\n\ninterface LinkPreviewProps {\n    title: string\n    link?: string\n    imageMode?: \"original\" | \"custom\"\n    customImage?: ImageValue\n    previewWidth?: number\n    previewHeight?: number\n    radius?: number\n    shadow?: boolean\n    shadowColor?: string\n    textColor?: string\n    underlineColor?: string\n    font?: CSSProperties\n    style?: CSSProperties\n}\n\nfunction originalImage(link?: string): string | undefined {\n    if (!link) return undefined\n    return `https://api.microlink.io/?url=${encodeURIComponent(link)}&embed=image.url`\n}\n\nexport default function LinkPreview(props: LinkPreviewProps) {\n    const {\n        title = \"Lander Studio\",\n        link = \"https://lander.studio/\",\n        imageMode = \"original\",\n        customImage,\n        previewWidth = 520,\n        previewHeight = 300,\n        radius = 0,\n        shadow = true,\n        shadowColor = \"rgba(0,0,0,0.30)\",\n        textColor = \"#FFFFFF\",\n        underlineColor = \"#FFFFFF\",\n        font,\n        style,\n    } = props\n\n    const isStatic = useIsStaticRenderer()\n    const [hovered, setHovered] = useState(false)\n    const containerRef = useRef<HTMLSpanElement>(null)\n\n    const x = useMotionValue(0)\n    const springX = useSpring(x, { stiffness: 120, damping: 16, mass: 0.6 })\n    const translateX = useTransform(springX, [0, 1], [-50, 50])\n\n    const onMove = (e: React.MouseEvent) => {\n        const el = containerRef.current\n        if (!el) return\n        const rect = el.getBoundingClientRect()\n        const ratio = (e.clientX - rect.left) / Math.max(1, rect.width)\n        x.set(Math.max(0, Math.min(1, ratio)))\n    }\n\n    const imgSrc =\n        imageMode === \"custom\" ? customImage?.src : originalImage(link)\n    const imgSrcSet = imageMode === \"custom\" ? customImage?.srcSet : undefined\n\n    return (\n        <span\n            ref={containerRef}\n            style={{\n                position: \"relative\",\n                display: \"inline-block\",\n                width: \"auto\",\n                ...font,\n                ...style,\n            }}\n            onMouseEnter={isStatic ? undefined : () => setHovered(true)}\n            onMouseLeave={isStatic ? undefined : () => setHovered(false)}\n            onMouseMove={isStatic ? undefined : onMove}\n        >\n            <a\n                href={link}\n                target=\"_blank\"\n                rel=\"noreferrer\"\n                style={{\n                    color: textColor,\n                    textDecoration: \"underline\",\n                    textDecorationColor: underlineColor,\n                    textUnderlineOffset: \"0.18em\",\n                    textDecorationThickness: \"1.5px\",\n                    whiteSpace: \"nowrap\",\n                    cursor: \"pointer\",\n                    ...font,\n                }}\n            >\n                {title}\n            </a>\n\n            <AnimatePresence>\n                {hovered && (\n                    <motion.div\n                        initial={{ opacity: 0, y: 14, scale: 0.92 }}\n                        animate={{ opacity: 1, y: 0, scale: 1 }}\n                        exit={{ opacity: 0, y: 10, scale: 0.96 }}\n                        transition={{\n                            type: \"spring\",\n                            stiffness: 260,\n                            damping: 22,\n                        }}\n                        style={{\n                            position: \"absolute\",\n                            left: \"50%\",\n                            bottom: \"calc(100% + 14px)\",\n                            x: translateX,\n                            marginLeft: -previewWidth / 2,\n                            width: previewWidth,\n                            height: previewHeight,\n                            borderRadius: radius,\n                            overflow: \"hidden\",\n                            background: \"#fff\",\n                            boxShadow: shadow\n                                ? `0 18px 40px ${shadowColor}, 0 2px 8px ${shadowColor}`\n                                : \"none\",\n                            border: \"1px solid rgba(0,0,0,0.06)\",\n                            pointerEvents: \"none\",\n                            zIndex: 10,\n                        }}\n                    >\n                        <img\n                            src={imgSrc}\n                            srcSet={imgSrcSet}\n                            alt={title}\n                            style={{\n                                width: \"100%\",\n                                height: \"100%\",\n                                objectFit: \"cover\",\n                                display: \"block\",\n                            }}\n                            draggable={false}\n                        />\n                    </motion.div>\n                )}\n            </AnimatePresence>\n        </span>\n    )\n}\n",
      "type": "registry:ui"
    }
  ]
}