{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "diagonal-carousel",
  "title": "Diagonal Carousel",
  "description": "Square cards fan out diagonally into a stacked deck, each inactive card rotates and offsets away from the active one, with paper/glass themes.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/diagonal-carousel/diagonal-carousel.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion } from \"motion/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 DiagonalCarouselSlide {\n  src: string;\n  title: string;\n}\n\nexport type DiagonalCarouselTitleAlign = \"bottom-left\" | \"bottom-center\" | \"center\";\nexport type DiagonalCarouselTheme = \"paper\" | \"glass\";\n\nexport interface DiagonalCarouselProps extends Omit<React.ComponentPropsWithoutRef<\"div\">, \"children\"> {\n  slides?: DiagonalCarouselSlide[];\n  cardSize?: number;\n  cardBorderRadius?: number;\n  rotateAngle?: number;\n  yOffset?: number;\n  inactiveScale?: number;\n  theme?: DiagonalCarouselTheme;\n  titleAlign?: DiagonalCarouselTitleAlign;\n  titleSize?: number;\n  initialIndex?: number;\n}\n\nconst DEFAULT_SLIDES: DiagonalCarouselSlide[] = [\n  { src: \"/demo/1.webp\", title: \"Quiet living room\" },\n  { src: \"/demo/3.webp\", title: \"Warm oak kitchen\" },\n  { src: \"/demo/4.webp\", title: \"Soft linen bedroom\" },\n  { src: \"/demo/5.webp\", title: \"Sculpted stone bath\" },\n  { src: \"/demo/6.webp\", title: \"Open plan lounge\" },\n  { src: \"/demo/7.webp\", title: \"Hidden storage wall\" },\n  { src: \"/demo/8.webp\", title: \"Garden courtyard light\" },\n  { src: \"/demo/9.webp\", title: \"Low sofa seating\" },\n  { src: \"/demo/10.webp\", title: \"Built-in reading nook\" },\n  { src: \"/demo/2.webp\", title: \"Tonal plaster hallway\" },\n];\n\nconst TOKENS = {\n  paper: \"#f5f5f5\",\n  ink: \"#221e1b\",\n  inkFaint: \"rgba(34,30,27,0.40)\",\n  glassBg: \"rgba(20,18,17,0.88)\",\n  glassFg: \"#ffffff\",\n  glassFgFaint: \"rgba(255,255,255,0.40)\",\n  glassBorder: \"rgba(255,255,255,0.12)\",\n  glassPillBg: \"rgba(255,255,255,0.10)\",\n  paperPillBg: \"#ffffff\",\n  paperBorder: \"rgba(34,30,27,0.10)\",\n  easeSignature: \"cubic-bezier(0.16, 1, 0.3, 1)\",\n} as const;\n\nexport function DiagonalCarousel({\n  slides = DEFAULT_SLIDES,\n  cardSize = 280,\n  cardBorderRadius = 20,\n  rotateAngle = 30,\n  yOffset = 50,\n  inactiveScale = 0.6,\n  theme = \"paper\",\n  titleAlign = \"bottom-left\",\n  titleSize = 14,\n  initialIndex = 3,\n  className,\n  style,\n  ...props\n}: DiagonalCarouselProps) {\n  const effectiveSlides = slides.length > 0 ? slides : DEFAULT_SLIDES;\n\n  const [activeIndex, setActiveIndex] = React.useState(() => Math.min(initialIndex, effectiveSlides.length - 1));\n\n  const toPrev = () => setActiveIndex((prev) => Math.max(0, prev - 1));\n  const toNext = () => setActiveIndex((prev) => Math.min(effectiveSlides.length - 1, prev + 1));\n  const toSlide = (index: number) => setActiveIndex(index);\n\n  const isGlass = theme === \"glass\";\n  const bg = isGlass ? TOKENS.glassBg : TOKENS.paper;\n  const fg = isGlass ? TOKENS.glassFg : TOKENS.ink;\n  const fgFaint = isGlass ? TOKENS.glassFgFaint : TOKENS.inkFaint;\n  const pillBg = isGlass ? TOKENS.glassPillBg : TOKENS.paperPillBg;\n  const pillBorder = isGlass ? TOKENS.glassBorder : TOKENS.paperBorder;\n\n  const totalWidth = cardSize * effectiveSlides.length;\n\n  const handleKeyDown = (e: React.KeyboardEvent) => {\n    if (e.key === \"ArrowLeft\") {\n      e.preventDefault();\n      toPrev();\n    }\n    if (e.key === \"ArrowRight\") {\n      e.preventDefault();\n      toNext();\n    }\n  };\n\n  return (\n    <div\n      tabIndex={0}\n      onKeyDown={handleKeyDown}\n      className={cn(\"relative flex h-full w-full flex-col items-center justify-center overflow-hidden select-none outline-none\", className)}\n      style={{ backgroundColor: bg, color: fg, fontFamily: \"'Helvetica Neue', Arial, sans-serif\", ...style }}\n      {...props}\n    >\n      <div className=\"mb-12\" style={{ width: cardSize, overflow: \"visible\" }}>\n        <motion.div\n          className=\"flex\"\n          style={{ width: totalWidth }}\n          animate={{ x: -activeIndex * cardSize }}\n          transition={{ type: \"spring\", bounce: 0.1, duration: 0.8 }}\n        >\n          {effectiveSlides.map((item, i) => {\n            const isActive = activeIndex === i;\n            const delta = i - activeIndex;\n            return (\n              <motion.div\n                key={i}\n                onClick={() => !isActive && toSlide(i)}\n                className=\"flex shrink-0 flex-col items-center gap-2.5 [will-change:transform]\"\n                style={{ width: cardSize, height: cardSize, cursor: isActive ? \"default\" : \"pointer\" }}\n                animate={{ rotate: delta * rotateAngle, scale: isActive ? 1 : inactiveScale, y: delta * (cardSize * (yOffset / 100)) }}\n                transition={{ type: \"spring\", bounce: 0.2, duration: 0.8 }}\n              >\n                <div className=\"relative h-full w-full shrink-0 overflow-hidden\" style={{ borderRadius: cardBorderRadius }}>\n                  <img src={item.src} alt={item.title} className=\"block h-full w-full object-cover\" />\n\n                  <div\n                    className=\"pointer-events-none absolute inset-0 transition-opacity duration-[400ms]\"\n                    // Source's \"opacity 400ms ease\" uses the CSS default\n                    // \"ease\" — Tailwind's ease-out utility is a different\n                    // curve (cubic-bezier(0,0,0.2,1)), not a match.\n                    style={{\n                      background:\n                        titleAlign === \"center\"\n                          ? \"rgba(0,0,0,0.28)\"\n                          : \"linear-gradient(to top, rgba(0,0,0,0.62) 0%, rgba(0,0,0,0.12) 45%, transparent 100%)\",\n                      opacity: isActive ? 1 : 0.6,\n                      transitionTimingFunction: \"ease\",\n                    }}\n                  />\n\n                  <div\n                    className=\"pointer-events-none absolute inset-0 bg-black/[0.22] transition-opacity duration-[400ms]\"\n                    style={{ opacity: isActive ? 0 : 1, transitionTimingFunction: \"ease\" }}\n                  />\n\n                  <motion.div\n                    className=\"pointer-events-none absolute font-semibold text-white [will-change:opacity,filter]\"\n                    style={{\n                      ...(titleAlign === \"center\"\n                        ? { top: \"50%\", left: 0, right: 0, textAlign: \"center\" as const, padding: \"0 16px\" }\n                        : titleAlign === \"bottom-center\"\n                          ? { bottom: 16, left: 0, right: 0, textAlign: \"center\" as const, padding: \"0 16px\" }\n                          : { bottom: 16, left: 16, right: 16, textAlign: \"left\" as const }),\n                      fontSize: titleSize,\n                      letterSpacing: \"-0.01em\",\n                      lineHeight: 1.2,\n                    }}\n                    animate={{\n                      opacity: isActive ? 1 : 0.72,\n                      filter: isActive ? \"blur(0px)\" : \"blur(0.5px)\",\n                      y: titleAlign === \"center\" ? (isActive ? \"-50%\" : \"-44%\") : isActive ? 0 : 4,\n                    }}\n                    transition={{ duration: 0.4, ease: [0.16, 1, 0.3, 1] }}\n                  >\n                    {item.title}\n                  </motion.div>\n                </div>\n              </motion.div>\n            );\n          })}\n        </motion.div>\n      </div>\n\n      <div\n        className=\"flex items-center gap-2 rounded-full px-2.5 py-1.5\"\n        style={{\n          backgroundColor: pillBg,\n          backdropFilter: isGlass ? \"blur(24px) saturate(180%)\" : undefined,\n          WebkitBackdropFilter: isGlass ? \"blur(24px) saturate(180%)\" : undefined,\n          border: `1px solid ${pillBorder}`,\n          boxShadow: isGlass ? \"0 4px 24px rgba(0,0,0,0.32)\" : \"0 1px 4px rgba(34,30,27,0.08)\",\n        }}\n      >\n        <button\n          type=\"button\"\n          aria-label=\"Previous slide\"\n          onClick={toPrev}\n          className=\"flex items-center justify-center rounded-md border-none bg-transparent px-2.5 py-1.5 transition-opacity duration-200\"\n          // Source's \"opacity 200ms ease\" needs an explicit ease override —\n          // Tailwind's transition-opacity defaults to a different curve.\n          style={{ color: fg, cursor: activeIndex === 0 ? \"default\" : \"pointer\", opacity: activeIndex === 0 ? 0.3 : 1, transitionTimingFunction: \"ease\" }}\n        >\n          <svg width={16} height={16} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2.2} strokeLinecap=\"round\" strokeLinejoin=\"round\">\n            <polyline points=\"15 18 9 12 15 6\" />\n          </svg>\n        </button>\n\n        <div className=\"flex items-center gap-1.5 px-1\">\n          {effectiveSlides.map((_, i) => (\n            <button\n              key={i}\n              type=\"button\"\n              aria-label={`Go to slide ${i + 1}`}\n              aria-current={activeIndex === i}\n              onClick={() => toSlide(i)}\n              className=\"h-1.75 shrink-0 cursor-pointer rounded-full border-none p-0\"\n              style={{\n                width: activeIndex === i ? 24 : 7,\n                backgroundColor: activeIndex === i ? fg : fgFaint,\n                transition: `width 300ms ${TOKENS.easeSignature}, background-color 300ms ease`,\n              }}\n            />\n          ))}\n        </div>\n\n        <button\n          type=\"button\"\n          aria-label=\"Next slide\"\n          onClick={toNext}\n          className=\"flex items-center justify-center rounded-md border-none bg-transparent px-2.5 py-1.5 transition-opacity duration-200\"\n          style={{\n            color: fg,\n            cursor: activeIndex === effectiveSlides.length - 1 ? \"default\" : \"pointer\",\n            opacity: activeIndex === effectiveSlides.length - 1 ? 0.3 : 1,\n            transitionTimingFunction: \"ease\",\n          }}\n        >\n          <svg width={16} height={16} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2.2} strokeLinecap=\"round\" strokeLinejoin=\"round\">\n            <polyline points=\"9 18 15 12 9 6\" />\n          </svg>\n        </button>\n      </div>\n\n          </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}