{
  "name": "blur-carousel",
  "type": "registry:ui",
  "description": "Origin Kit blur carousel adapted for Canadian AI surfaces",
  "files": [
    {
      "path": "components/origin-kit/blur-carousel.tsx",
      "content": "// Upstream: Originkit blurcarousel (MIT). Adapted for CAI; preserve this provenance notice.\\n\"use client\";\n\nimport {\n    useState,\n    useEffect,\n    useCallback,\n    type CSSProperties,\n    type PointerEvent as ReactPointerEvent,\n} from \"react\"\n\n// In Next.js there is no static renderer — always returns false.\nfunction useIsStaticRenderer(): boolean {\n    return false\n}\n\ninterface Slide {\n    image?: { src?: string; srcSet?: string; alt?: string }\n    title?: string\n}\n\ntype Movement = \"horizontal\" | \"vertical\"\ntype TitleCorner = \"topLeft\" | \"topRight\" | \"bottomLeft\" | \"bottomRight\"\n\ninterface BlurCarouselProps {\n    slides?: Slide[]\n    movement?: Movement\n    cardWidth?: number\n    cardHeight?: number\n    radius?: number\n    tilt?: number\n    blurAmount?: number\n    arrowColor?: string\n    arrowInactiveColor?: string\n    arrowSize?: number\n    autoplay?: boolean\n    transition?: any\n    showTitle?: boolean\n    titleFont?: CSSProperties\n    titleColor?: string\n    titlePosition?: {\n        position?: TitleCorner\n        paddingLeft?: number\n        paddingRight?: number\n        paddingTop?: number\n        paddingBottom?: number\n    }\n    style?: CSSProperties\n}\n\nconst DEFAULT_SLIDES: Slide[] = [\n    {\n        image: {\n            src: \"https://imagedelivery.net/IEUjvl3YUlxY-MrTpOAWDQ/316d1761-fd79-4ca9-b8d4-f2bb20521a00/w=800\",\n        },\n        title: \"For Sitting\\nMetal\\nMinimal\",\n    },\n    {\n        image: {\n            src: \"https://imagedelivery.net/IEUjvl3YUlxY-MrTpOAWDQ/aeaa0756-9647-4f6c-d900-204bd25e4a00/w=800\",\n        },\n        title: \"For Living\\nConcrete\\nForm\",\n    },\n    {\n        image: {\n            src: \"https://imagedelivery.net/IEUjvl3YUlxY-MrTpOAWDQ/34ce1842-4b7a-4d52-0302-38582c341700/w=800\",\n        },\n        title: \"For Working\\nSteel\\nClean\",\n    },\n    {\n        image: {\n            src: \"https://imagedelivery.net/IEUjvl3YUlxY-MrTpOAWDQ/6d2ad64a-102d-4eab-0efe-31479e34b500/w=800\",\n        },\n        title: \"For Resting\\nLinen\\nQuiet\",\n    },\n]\n\nconst PERSPECTIVE = 1100\nconst PRESS_SCALE = 0.965\nconst PRESS_SHIFT = 6\nconst BLUR_WIDTH = 42\nconst OVERLAY_DARKEN = 0.35\n\nfunction cssTransition(t: any): { dur: number; ease: string } {\n    const dur = t && typeof t.duration === \"number\" ? t.duration : 0.55\n    let ease = \"cubic-bezier(0.2, 0.8, 0.2, 1)\"\n    const e = t?.ease\n    if (Array.isArray(e) && e.length === 4) {\n        ease = `cubic-bezier(${e[0]}, ${e[1]}, ${e[2]}, ${e[3]})`\n    } else if (typeof e === \"string\") {\n        const map: Record<string, string> = {\n            linear: \"linear\",\n            easeIn: \"ease-in\",\n            easeOut: \"ease-out\",\n            easeInOut: \"ease-in-out\",\n        }\n        ease = map[e] || \"ease\"\n    }\n    return { dur, ease }\n}\n\nexport default function BlurCarousel(props: BlurCarouselProps) {\n    const {\n        slides = DEFAULT_SLIDES,\n        movement = \"horizontal\",\n        cardWidth = 480,\n        cardHeight = 500,\n        radius = 8,\n        tilt = 9,\n        blurAmount = 14,\n        arrowColor = \"#ffffff\",\n        arrowInactiveColor = \"rgba(255,255,255,0.6)\",\n        arrowSize = 26,\n        autoplay = false,\n        transition,\n        showTitle = true,\n        titleFont,\n        titleColor = \"#ffffff\",\n        titlePosition,\n        style,\n    } = props\n\n    const tp = titlePosition || {}\n    const corner: TitleCorner = tp.position || \"topLeft\"\n    const isTop = corner === \"topLeft\" || corner === \"topRight\"\n    const isRight = corner === \"topRight\" || corner === \"bottomRight\"\n    const padLeft = tp.paddingLeft ?? 26\n    const padRight = tp.paddingRight ?? 26\n    const padTop = tp.paddingTop ?? 24\n    const padBottom = tp.paddingBottom ?? 24\n\n    const isStatic = useIsStaticRenderer()\n    const list = slides && slides.length ? slides : DEFAULT_SLIDES\n    const n = list.length\n    const vertical = movement === \"vertical\"\n\n    const loop = true\n    const [index, setIndex] = useState(0)\n    const [pressDir, setPressDir] = useState(0)\n    const [hoverSide, setHoverSide] = useState(0)\n\n    useEffect(() => {\n        setIndex((i) => Math.max(0, Math.min(n - 1, i)))\n    }, [n])\n\n    const go = useCallback(\n        (dir: number) => {\n            setIndex((i) => {\n                if (loop) return (((i + dir) % n) + n) % n\n                return Math.max(0, Math.min(n - 1, i + dir))\n            })\n        },\n        [n]\n    )\n\n    const delay =\n        transition && typeof transition.delay === \"number\"\n            ? transition.delay\n            : 4\n    useEffect(() => {\n        if (isStatic || !autoplay || n < 2) return\n        const ms = Math.max(0.3, delay) * 1000\n        const id = window.setInterval(() => go(1), ms)\n        return () => window.clearInterval(id)\n    }, [isStatic, autoplay, delay, n, go])\n\n    const onArrowDown = (dir: number) => (e: ReactPointerEvent) => {\n        if (isStatic || autoplay) return\n        e.preventDefault()\n        e.currentTarget.setPointerCapture?.(e.pointerId)\n        setHoverSide(dir)\n        setPressDir(dir)\n    }\n    const onArrowUp = (dir: number) => (e: ReactPointerEvent) => {\n        if (isStatic || autoplay) return\n        e.currentTarget.releasePointerCapture?.(e.pointerId)\n        go(dir)\n        setPressDir(0)\n    }\n    const onArrowCancel = () => setPressDir(0)\n    const onArrowEnter = (dir: number) => () => {\n        if (!isStatic && !autoplay) setHoverSide(dir)\n    }\n    const onArrowLeave = () => {\n        if (!isStatic) setHoverSide(0)\n    }\n\n    const onKeyDown = useCallback(\n        (e: React.KeyboardEvent) => {\n            const next = vertical ? \"ArrowDown\" : \"ArrowRight\"\n            const prev = vertical ? \"ArrowUp\" : \"ArrowLeft\"\n            if (e.key === next) {\n                e.preventDefault()\n                go(1)\n            } else if (e.key === prev) {\n                e.preventDefault()\n                go(-1)\n            }\n        },\n        [go, vertical]\n    )\n\n    const { dur, ease } = cssTransition(transition)\n    const tiltTransition = `transform ${dur}s ${ease}`\n    const fadeTransition = `opacity ${dur}s ease`\n\n    const radiusPx =\n        (Math.max(0, Math.min(20, radius)) / 20) *\n        (Math.min(cardWidth, cardHeight) / 2)\n\n    const rootStyle: CSSProperties = {\n        ...(style || {}),\n        position: \"relative\",\n        width: \"100%\",\n        height: \"100%\",\n        minWidth: 200,\n        minHeight: 220,\n        display: \"flex\",\n        alignItems: \"center\",\n        justifyContent: \"center\",\n        perspective: `${PERSPECTIVE}px`,\n        outline: \"none\",\n        userSelect: \"none\",\n        WebkitTapHighlightColor: \"transparent\",\n    }\n\n    const frameStyle: CSSProperties = {\n        position: \"relative\",\n        width: cardWidth,\n        height: cardHeight,\n        borderRadius: radiusPx,\n        clipPath: `inset(0 round ${radiusPx}px)`,\n        overflow: \"hidden\",\n        background: \"#0c0c0c\",\n        transformStyle: \"preserve-3d\",\n        transformOrigin: \"center center\",\n        transform: vertical\n            ? `translateY(${pressDir * PRESS_SHIFT}px) rotateX(${-pressDir * tilt}deg) scale(${pressDir !== 0 ? PRESS_SCALE : 1})`\n            : `translateX(${pressDir * PRESS_SHIFT}px) rotateY(${pressDir * tilt}deg) scale(${pressDir !== 0 ? PRESS_SCALE : 1})`,\n        transition: tiltTransition,\n    }\n\n    const titleStyle = (i: number): CSSProperties => ({\n        position: \"absolute\",\n        left: padLeft,\n        right: padRight,\n        [isTop ? \"top\" : \"bottom\"]: isTop ? padTop : padBottom,\n        textAlign: isRight ? \"right\" : \"left\",\n        color: titleColor,\n        fontSize: 30,\n        fontWeight: 700,\n        lineHeight: \"1.12em\",\n        letterSpacing: \"-0.01em\",\n        whiteSpace: \"pre-line\",\n        textShadow: \"0 2px 14px rgba(0,0,0,0.35)\",\n        opacity: i === index ? 1 : 0,\n        transition: fadeTransition,\n        pointerEvents: \"none\",\n        zIndex: 4,\n        ...(titleFont || {}),\n    })\n\n    const arrowWrap = (dir: number): CSSProperties => {\n        const base: CSSProperties = {\n            position: \"absolute\",\n            display: \"flex\",\n            alignItems: \"center\",\n            justifyContent: \"center\",\n            width: arrowSize + 18,\n            height: arrowSize + 18,\n            zIndex: 5,\n            cursor: \"pointer\",\n            color: hoverSide === dir ? arrowColor : arrowInactiveColor,\n            transition: \"color 0.25s ease, transform 0.2s ease\",\n            touchAction: \"none\",\n        }\n        if (vertical) {\n            return {\n                ...base,\n                left: \"50%\",\n                [dir < 0 ? \"top\" : \"bottom\"]: 14,\n                transform: \"translateX(-50%)\",\n            }\n        }\n        return {\n            ...base,\n            top: \"50%\",\n            [dir < 0 ? \"left\" : \"right\"]: 14,\n            transform: \"translateY(-50%)\",\n        }\n    }\n\n    const blurOverlay = (dir: number): CSSProperties => {\n        const common: CSSProperties = {\n            position: \"absolute\",\n            backdropFilter: `blur(${blurAmount}px)`,\n            WebkitBackdropFilter: `blur(${blurAmount}px)`,\n            opacity: hoverSide === dir ? 1 : 0,\n            transition: \"opacity 0.4s ease\",\n            pointerEvents: \"none\",\n            zIndex: 3,\n        }\n        if (vertical) {\n            const grad =\n                dir < 0\n                    ? \"linear-gradient(to bottom, #000 0%, transparent 100%)\"\n                    : \"linear-gradient(to top, #000 0%, transparent 100%)\"\n            return {\n                ...common,\n                left: 0,\n                right: 0,\n                [dir < 0 ? \"top\" : \"bottom\"]: 0,\n                height: `${BLUR_WIDTH}%`,\n                maskImage: grad,\n                WebkitMaskImage: grad,\n            }\n        }\n        const grad =\n            dir < 0\n                ? \"linear-gradient(to right, #000 0%, transparent 100%)\"\n                : \"linear-gradient(to left, #000 0%, transparent 100%)\"\n        return {\n            ...common,\n            top: 0,\n            bottom: 0,\n            [dir < 0 ? \"left\" : \"right\"]: 0,\n            width: `${BLUR_WIDTH}%`,\n            maskImage: grad,\n            WebkitMaskImage: grad,\n        }\n    }\n\n    return (\n        <div\n            style={rootStyle}\n            tabIndex={0}\n            role=\"group\"\n            aria-roledescription=\"carousel\"\n            onKeyDown={isStatic ? undefined : onKeyDown}\n        >\n            <div style={frameStyle}>\n                {list.map((s, i) => (\n                    <img\n                        key={i}\n                        src={s.image?.src || \"\"}\n                        alt={s.image?.alt || s.title || \"\"}\n                        draggable={false}\n                        style={{\n                            position: \"absolute\",\n                            inset: 0,\n                            width: \"100%\",\n                            height: \"100%\",\n                            objectFit: \"cover\",\n                            display: \"block\",\n                            opacity: i === index ? 1 : 0,\n                            transition: fadeTransition,\n                        }}\n                    />\n                ))}\n\n                <div\n                    style={{\n                        position: \"absolute\",\n                        inset: 0,\n                        background: `linear-gradient(180deg, rgba(0,0,0,${OVERLAY_DARKEN}) 0%, rgba(0,0,0,0) 42%)`,\n                        pointerEvents: \"none\",\n                    }}\n                />\n\n                {showTitle &&\n                    list.map((s, i) => (\n                        <div key={i} style={titleStyle(i)}>\n                            {s.title}\n                        </div>\n                    ))}\n\n                <div style={blurOverlay(-1)} />\n                <div style={blurOverlay(1)} />\n\n                <div\n                    role=\"button\"\n                    aria-label=\"Previous slide\"\n                    style={arrowWrap(-1)}\n                    onPointerDown={onArrowDown(-1)}\n                    onPointerUp={onArrowUp(-1)}\n                    onPointerCancel={onArrowCancel}\n                    onPointerEnter={onArrowEnter(-1)}\n                    onPointerLeave={onArrowLeave}\n                >\n                    <svg\n                        width={arrowSize}\n                        height={arrowSize}\n                        viewBox=\"0 0 24 24\"\n                        fill=\"none\"\n                        stroke=\"currentColor\"\n                        strokeWidth={2}\n                        strokeLinecap=\"round\"\n                        strokeLinejoin=\"round\"\n                        aria-hidden=\"true\"\n                    >\n                        <polyline\n                            points={vertical ? \"6 15 12 9 18 15\" : \"15 18 9 12 15 6\"}\n                        />\n                    </svg>\n                </div>\n                <div\n                    role=\"button\"\n                    aria-label=\"Next slide\"\n                    style={arrowWrap(1)}\n                    onPointerDown={onArrowDown(1)}\n                    onPointerUp={onArrowUp(1)}\n                    onPointerCancel={onArrowCancel}\n                    onPointerEnter={onArrowEnter(1)}\n                    onPointerLeave={onArrowLeave}\n                >\n                    <svg\n                        width={arrowSize}\n                        height={arrowSize}\n                        viewBox=\"0 0 24 24\"\n                        fill=\"none\"\n                        stroke=\"currentColor\"\n                        strokeWidth={2}\n                        strokeLinecap=\"round\"\n                        strokeLinejoin=\"round\"\n                        aria-hidden=\"true\"\n                    >\n                        <polyline\n                            points={vertical ? \"6 9 12 15 18 9\" : \"9 18 15 12 9 6\"}\n                        />\n                    </svg>\n                </div>\n            </div>\n        </div>\n    )\n}\n",
      "type": "registry:ui"
    }
  ]
}