{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "review-card-portrait",
  "title": "Review Card Portrait",
  "description": "A portrait-format testimonial card with a crossfading top image strip, counter, thumbnail selector, and an animated quote with name/role, plus prev/next navigation and optional autoplay.",
  "dependencies": [
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/review-card-portrait/review-card-portrait.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport interface ReviewCardPortraitItem {\n  src: string;\n  name?: string;\n  role?: string;\n  quote?: string;\n}\n\nexport interface ReviewCardPortraitProps extends Omit<React.ComponentPropsWithoutRef<\"div\">, \"children\"> {\n  /** Business or product these reviews are about, named in the schema.org Review markup search engines read. */\n  reviewSubject?: string;\n  reviews?: ReviewCardPortraitItem[];\n  theme?: \"light\" | \"dark\";\n  sectionLabel?: string;\n  autoPlay?: boolean;\n  autoPlayInterval?: number;\n}\n\nconst DEFAULT_REVIEWS: ReviewCardPortraitItem[] = [\n  {\n    src: \"/demo/49.webp\",\n    name: \"Elena Marsh\",\n    role: \"Product Designer\",\n    quote: \"Shipped in weeks, not months.\",\n  },\n  {\n    src: \"/demo/50.webp\",\n    name: \"Daniel Ruiz\",\n    role: \"Founder, Northwind\",\n    quote: \"Clear from day one.\",\n  },\n  {\n    src: \"/demo/51.webp\",\n    name: \"Priya Nair\",\n    role: \"Head of Marketing\",\n    quote: \"Conversion jumped fast.\",\n  },\n];\n\n/**\n * ReviewCardPortrait — a portrait-format testimonial card with a\n * crossfading top image strip, thumbnail selector, and animated quote text.\n */\nexport function ReviewCardPortrait({\n  reviewSubject,\n  className,\n  reviews = DEFAULT_REVIEWS,\n  theme = \"light\",\n  sectionLabel = \"Reviews\",\n  autoPlay = false,\n  autoPlayInterval = 5,\n  ...props\n}: ReviewCardPortraitProps) {\n  const containerRef = React.useRef<HTMLDivElement>(null);\n  const fadeTimeoutRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n  const safeReviews = (reviews || []).filter((r) => r.src);\n  const count = safeReviews.length;\n\n  const [active, setActive] = React.useState(0);\n  const [fading, setFading] = React.useState(false);\n  const [isVisible, setIsVisible] = React.useState(true);\n  const [navFocus, setNavFocus] = React.useState<\"prev\" | \"next\" | null>(null);\n  const [paused, setPaused] = React.useState(false);\n  const [hoverPaused, setHoverPaused] = React.useState(false);\n\n  const isDark = theme === \"dark\";\n  const bg = isDark ? \"#0a0a0a\" : \"#ffffff\";\n  const textPrimary = isDark ? \"#ffffff\" : \"#0a0a0a\";\n  const textSecondary = isDark ? \"rgba(255,255,255,0.5)\" : \"rgba(0,0,0,0.55)\";\n  const border = isDark ? \"rgba(255,255,255,0.08)\" : \"rgba(0,0,0,0.08)\";\n\n  const goTo = React.useCallback(\n    (idx: number) => {\n      if (fading || idx === active) return;\n      setFading(true);\n      if (fadeTimeoutRef.current) clearTimeout(fadeTimeoutRef.current);\n      fadeTimeoutRef.current = setTimeout(() => {\n        setActive(idx);\n        setFading(false);\n      }, 450);\n    },\n    [fading, active]\n  );\n  const prev = React.useCallback(() => goTo((active - 1 + count) % count), [active, count, goTo]);\n  const next = React.useCallback(() => goTo((active + 1) % count), [active, count, goTo]);\n\n  React.useEffect(() => {\n    return () => {\n      if (fadeTimeoutRef.current) clearTimeout(fadeTimeoutRef.current);\n    };\n  }, []);\n\n  React.useEffect(() => {\n    if (!containerRef.current) return;\n    const observer = new IntersectionObserver(([entry]) => setIsVisible(entry.isIntersecting), { threshold: 0 });\n    observer.observe(containerRef.current);\n    return () => observer.disconnect();\n  }, []);\n\n  React.useEffect(() => {\n    if (!autoPlay || count < 2 || !isVisible || paused || hoverPaused) return;\n    const id = setInterval(next, autoPlayInterval * 1000);\n    return () => clearInterval(id);\n  }, [autoPlay, autoPlayInterval, next, count, isVisible, paused, hoverPaused]);\n\n  React.useEffect(() => {\n    const el = containerRef.current;\n    if (!el) return;\n    const f = (e: KeyboardEvent) => {\n      if (e.key === \"ArrowLeft\") prev();\n      else if (e.key === \"ArrowRight\") next();\n    };\n    el.addEventListener(\"keydown\", f);\n    return () => el.removeEventListener(\"keydown\", f);\n  }, [prev, next]);\n\n  if (count === 0) {\n    return (\n      <div\n        ref={containerRef}\n        className={cn(\"relative flex h-full w-full items-center justify-center text-[13px]\", className)}\n        style={{ background: bg, color: textSecondary }}\n        {...props}\n      >\n        Add reviews →\n      </div>\n    );\n  }\n  const r = safeReviews[active];\n\n  // schema.org Review markup (JSON-LD) for search engines, skipped while the placeholder reviews show.\n  const reviewsJsonLd = reviews === DEFAULT_REVIEWS\n    ? null\n    : JSON.stringify({\n        \"@context\": \"https://schema.org\",\n        \"@graph\": reviews\n          .filter((r) => r.quote && r.name)\n          .map((r) => ({\n            \"@type\": \"Review\",\n            reviewBody: r.quote,\n            author: { \"@type\": \"Person\", name: r.name },\n            ...(reviewSubject ? { itemReviewed: { \"@type\": \"Organization\", name: reviewSubject } } : {}),\n          })),\n      }).replace(/</g, \"\\\\u003c\");\n\n  return (\n    <div\n      ref={containerRef}\n      role=\"region\"\n      aria-roledescription=\"carousel\"\n      aria-label={sectionLabel || \"Reviews\"}\n      onMouseEnter={() => setHoverPaused(true)}\n      onMouseLeave={() => setHoverPaused(false)}\n      onFocus={() => setHoverPaused(true)}\n      onBlur={(e) => {\n        if (!e.currentTarget.contains(e.relatedTarget as Node)) setHoverPaused(false);\n      }}\n      className={cn(\"relative flex h-full w-full flex-col overflow-hidden\", className)}\n      style={{ background: bg }}\n      {...props}\n    >\n      {reviewsJsonLd && <script type=\"application/ld+json\" dangerouslySetInnerHTML={{ __html: reviewsJsonLd }} />}\n      {/* Top image strip */}\n      <div className=\"relative h-[45%] flex-shrink-0 overflow-hidden\">\n        {safeReviews.map((rv, i) => (\n          <div\n            key={i}\n            className=\"absolute inset-0\"\n            style={{ opacity: i === active ? (fading ? 0 : 1) : 0, transition: \"opacity 0.6s ease\" }}\n          >\n            <img\n              src={rv.src}\n              alt={rv.name ? `${rv.name}${rv.role ? \", \" + rv.role : \"\"}` : \"Customer review photo\"}\n              className=\"block h-full w-full object-cover\"\n            />\n          </div>\n        ))}\n        <div\n          className=\"absolute inset-0\"\n          style={{ background: `linear-gradient(to bottom, transparent 60%, ${bg} 100%)` }}\n        />\n        <div\n          aria-hidden=\"true\"\n          className=\"absolute right-7 top-6 text-[11px] tracking-widest text-white/50\"\n          style={{ textShadow: \"0 1px 3px rgba(0,0,0,0.6)\" }}\n        >\n          {String(active + 1).padStart(2, \"0\")} / {String(count).padStart(2, \"0\")}\n        </div>\n        <div\n          aria-hidden=\"true\"\n          className=\"absolute left-7 top-6 text-[9px] uppercase tracking-[0.3em] text-white/40\"\n          style={{ textShadow: \"0 1px 3px rgba(0,0,0,0.6)\" }}\n        >\n          {sectionLabel}\n        </div>\n        {autoPlay && count > 1 && (\n          <button\n            type=\"button\"\n            onClick={() => setPaused((p) => !p)}\n            aria-label={paused ? \"Play automatic slideshow\" : \"Pause automatic slideshow\"}\n            aria-pressed={paused}\n            className=\"absolute bottom-4 right-7 flex h-7 w-7 items-center justify-center rounded-full border border-white/40 bg-black/35 p-0 backdrop-blur-sm\"\n          >\n            <svg width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" fill=\"#fff\">\n              {paused ? (\n                <path d=\"M1 0.5L9 5L1 9.5V0.5Z\" />\n              ) : (\n                <>\n                  <rect x=\"1.5\" y=\"1\" width=\"2.4\" height=\"8\" />\n                  <rect x=\"6.1\" y=\"1\" width=\"2.4\" height=\"8\" />\n                </>\n              )}\n            </svg>\n          </button>\n        )}\n        {/* Thumbnail strip */}\n        <div className=\"absolute bottom-4 left-7 flex gap-1.5\">\n          {safeReviews.map((rv, i) => (\n            <button\n              key={i}\n              type=\"button\"\n              onClick={() => goTo(i)}\n              aria-label={`Show review ${i + 1}`}\n              aria-current={i === active}\n              className=\"h-10 w-10 overflow-hidden rounded-[8px] border-none bg-transparent p-0\"\n              style={{\n                opacity: i === active ? 1 : 0.35,\n                boxShadow: i === active ? \"0 0 0 1.5px rgba(255,255,255,0.8)\" : \"none\",\n                transition: \"opacity 0.3s ease\",\n              }}\n            >\n              <img src={rv.src} alt=\"\" className=\"block h-full w-full object-cover\" />\n            </button>\n          ))}\n        </div>\n      </div>\n\n      {/* Bottom text */}\n      <div className=\"flex flex-1 flex-col justify-between px-10 pb-9 pt-8\">\n        <div role=\"group\" aria-roledescription=\"slide\" aria-label={`Review ${active + 1} of ${count}`} aria-live=\"polite\" aria-atomic=\"true\">\n          <div\n            key={`q-${active}`}\n            style={{\n              opacity: fading ? 0 : 1,\n              transform: fading ? \"translateY(10px)\" : \"translateY(0)\",\n              transition: \"opacity 0.45s ease, transform 0.45s ease\",\n            }}\n          >\n            <p className=\"mb-1.5 text-[13px] tracking-[0.02em]\" style={{ color: textSecondary }}>\n              {r.role}\n            </p>\n            <cite className=\"mb-5 block text-[15px] font-semibold not-italic tracking-[-0.01em]\" style={{ color: textPrimary }}>\n              {r.name}\n            </cite>\n            <blockquote className=\"m-0 text-[20px] font-normal leading-[1.2] tracking-tight\" style={{ color: textPrimary, fontFamily: \"Georgia, 'Times New Roman', serif\" }}>\n              &ldquo;{r.quote}&rdquo;\n            </blockquote>\n          </div>\n        </div>\n        {/* Nav */}\n        <div className=\"flex gap-2\">\n          <button\n            type=\"button\"\n            onClick={prev}\n            aria-label=\"Previous review\"\n            onFocus={() => setNavFocus(\"prev\")}\n            onBlur={() => setNavFocus((f) => (f === \"prev\" ? null : f))}\n            className=\"flex h-[42px] w-[42px] items-center justify-center rounded-full bg-transparent outline-none\"\n            style={{\n              border: `1px solid ${border}`,\n              boxShadow: navFocus === \"prev\" ? `0 0 0 2px ${textPrimary}` : \"none\",\n            }}\n          >\n            <svg width=\"14\" height=\"14\" viewBox=\"0 0 14 14\" fill=\"none\">\n              <path d=\"M9 2L4 7L9 12\" stroke={textPrimary} strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n            </svg>\n          </button>\n          <button\n            type=\"button\"\n            onClick={next}\n            aria-label=\"Next review\"\n            onFocus={() => setNavFocus(\"next\")}\n            onBlur={() => setNavFocus((f) => (f === \"next\" ? null : f))}\n            className=\"flex h-[42px] w-[42px] items-center justify-center rounded-full border-none outline-none\"\n            style={{\n              background: textPrimary,\n              boxShadow: navFocus === \"next\" ? `0 0 0 2px ${border}, 0 0 0 4px ${textPrimary}` : \"none\",\n            }}\n          >\n            <svg width=\"14\" height=\"14\" viewBox=\"0 0 14 14\" fill=\"none\">\n              <path d=\"M5 2L10 7L5 12\" stroke={bg} strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n            </svg>\n          </button>\n        </div>\n      </div>\n    </div>\n  );\n}\n\nexport default ReviewCardPortrait;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}