{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"text-highlighter","type":"registry:ui","title":"Text Highlighter","description":"A marker-pen stroke swipes behind chosen words as they scroll into view, flipping the ink color in sync.","dependencies":[],"registryDependencies":[],"files":[{"path":"registry/ui/text-highlighter.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { useEffect, useRef, useState, type ReactNode } from \"react\";\n\nexport interface TextHighlighterProps {\n  children: ReactNode;\n  /** Marker color. */\n  color?: string;\n  /** Text color while highlighted (marker variant). */\n  textColor?: string;\n  /** Full marker stroke, or a low underline swipe. */\n  variant?: \"marker\" | \"underline\";\n  /** Direction the pen travels. */\n  direction?: \"ltr\" | \"rtl\";\n  /** Stroke duration, in ms. */\n  duration?: number;\n  /** Delay after entering view, in ms. */\n  delay?: number;\n  className?: string;\n}\n\nexport function TextHighlighter({\n  children,\n  color = \"#a3e635\",\n  textColor = \"#0a0a0a\",\n  variant = \"marker\",\n  direction = \"ltr\",\n  duration = 900,\n  delay = 0,\n  className,\n}: TextHighlighterProps) {\n  const ref = useRef<HTMLSpanElement>(null);\n  const [on, setOn] = useState(false);\n\n  useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const io = new IntersectionObserver(([e]) => {\n      if (e.isIntersecting) {\n        setOn(true);\n        io.disconnect();\n      }\n    }, { threshold: 0.6 });\n    io.observe(el);\n    return () => io.disconnect();\n  }, []);\n\n  const hidden = direction === \"ltr\" ? \"inset(-20% 100% -20% 0)\" : \"inset(-20% 0 -20% 100%)\";\n  const marker = variant === \"marker\";\n  const layer = {\n    position: \"absolute\",\n    inset: 0,\n    padding: \"0 0.18em\",\n    clipPath: on ? \"inset(-20% 0 -20% 0)\" : hidden,\n    transition: `clip-path ${duration}ms cubic-bezier(.65,0,.35,1) ${delay}ms`,\n    pointerEvents: \"none\",\n  } as const;\n\n  return (\n    <span\n      ref={ref}\n      className={className}\n      style={{ position: \"relative\", display: \"inline-block\", padding: \"0 0.18em\", margin: \"0 -0.18em\", isolation: \"isolate\" }}\n    >\n      {children}\n      <span aria-hidden style={{ ...layer, zIndex: marker ? 0 : -1 }}>\n        <span\n          style={{\n            position: \"absolute\",\n            left: 0,\n            right: 0,\n            top: marker ? \"0.1em\" : \"62%\",\n            bottom: marker ? \"0.02em\" : \"0.04em\",\n            background: color,\n            borderRadius: \"0.35em 0.2em 0.45em 0.15em / 0.5em 0.25em 0.6em 0.3em\",\n            transform: \"rotate(-0.8deg) skewX(-6deg)\",\n            opacity: marker ? 1 : 0.85,\n          }}\n        />\n        {marker && <span style={{ position: \"relative\", color: textColor }}>{children}</span>}\n      </span>\n    </span>\n  );\n}\n"}]}