{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "carousel",
  "title": "Carousel",
  "description": "Embla carousel parts for Astro image and content sequences.",
  "dependencies": [
    "@data-slot/core",
    "@lucide/astro",
    "cn",
    "embla-carousel"
  ],
  "registryDependencies": [
    "@gnostic/button"
  ],
  "files": [
    {
      "path": "packages/ui/src/components/ui/carousel/carousel-content.astro",
      "content": "---\nimport type { HTMLAttributes } from \"astro/types\"\n\nimport { cn } from \"cn\"\n\nimport type { CarouselContentProps } from \"./types.ts\"\n\ntype Props = HTMLAttributes<\"div\"> & CarouselContentProps\n\nconst {\n  class: className,\n  style: styleProp,\n  gap = \"1rem\",\n  viewportClass,\n  ...props\n} = Astro.props\n\nconst style =\n  typeof styleProp === \"string\"\n    ? `--carousel-gap: ${gap}; ${styleProp}`\n    : {\n        \"--carousel-gap\": gap,\n        ...styleProp,\n      }\n---\n\n<div class={cn(\"overflow-hidden\", viewportClass)} data-slot=\"carousel-content\">\n  <div\n    data-slot=\"carousel-viewport\"\n    class={cn(\n      \"flex [touch-action:pan-y_pinch-zoom] -ml-(--carousel-gap)\",\n      \"group-data-[orientation=vertical]/carousel:-mt-(--carousel-gap) group-data-[orientation=vertical]/carousel:[touch-action:pan-x_pinch-zoom] group-data-[orientation=vertical]/carousel:flex-col\",\n      className,\n    )}\n    style={style}\n    {...props}\n  >\n    <slot />\n  </div>\n</div>\n",
      "type": "registry:file",
      "target": "~/src/components/ui/carousel/carousel-content.astro"
    },
    {
      "path": "packages/ui/src/components/ui/carousel/carousel-dots.astro",
      "content": "---\nimport type { HTMLAttributes } from \"astro/types\"\nimport { cn } from \"cn\"\n\ntype Props = HTMLAttributes<\"div\"> & {\n  label?: string\n}\n\nconst { class: className, label = \"Slide navigation\", ...props } = Astro.props\n---\n\n<div\n  data-slot=\"carousel-dots\"\n  role=\"group\"\n  aria-label={label}\n  class={cn(\n    \"flex flex-wrap items-center justify-center gap-1 data-[snap-count=0]:hidden data-[snap-count=1]:hidden\",\n    className,\n  )}\n  {...props}\n>\n  <template>\n    <button\n      type=\"button\"\n      data-slot=\"carousel-dot\"\n      class=\"group/carousel-dot focus-visible:ring-ring ring-offset-background flex h-8 min-w-6 shrink-0 cursor-pointer touch-manipulation items-center justify-center rounded-full px-2 outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-default\"\n    >\n      <span\n        aria-hidden=\"true\"\n        class=\"bg-muted-foreground/30 h-2 w-2 shrink-0 rounded-full transition-[width,background-color] duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] group-hover/carousel-dot:bg-muted-foreground/50 group-aria-current/carousel-dot:w-6 group-aria-current/carousel-dot:bg-primary motion-reduce:transition-none\"\n      />\n    </button>\n  </template>\n</div>\n",
      "type": "registry:file",
      "target": "~/src/components/ui/carousel/carousel-dots.astro"
    },
    {
      "path": "packages/ui/src/components/ui/carousel/carousel-item.astro",
      "content": "---\nimport type { HTMLAttributes } from \"astro/types\"\n\nimport { cn } from \"cn\"\n\ntype Props = HTMLAttributes<\"div\">\n\nconst { class: className, ...props } = Astro.props\n---\n\n<div\n  data-slot=\"carousel-item\"\n  role=\"group\"\n  aria-roledescription=\"slide\"\n  class={cn(\n    \"group/carousel-item min-w-0 shrink-0 grow-0 basis-full pl-(--carousel-gap)\",\n    \"group-data-[orientation=vertical]/carousel:pt-(--carousel-gap)\",\n    className,\n  )}\n  {...props}\n>\n  <slot />\n</div>\n",
      "type": "registry:file",
      "target": "~/src/components/ui/carousel/carousel-item.astro"
    },
    {
      "path": "packages/ui/src/components/ui/carousel/carousel-layer.astro",
      "content": "---\nimport type { HTMLAttributes } from \"astro/types\"\nimport { cn } from \"cn\"\n\ntype Props = HTMLAttributes<\"div\">\nconst { class: className, ...props } = Astro.props\n---\n\n<div\n  data-slot=\"carousel-layer\"\n  class={cn(\"relative origin-center\", className)}\n  {...props}\n>\n  <slot />\n</div>\n",
      "type": "registry:file",
      "target": "~/src/components/ui/carousel/carousel-layer.astro"
    },
    {
      "path": "packages/ui/src/components/ui/carousel/carousel-next.astro",
      "content": "---\nimport type { HTMLAttributes } from \"astro/types\"\nimport ChevronRightIcon from \"@lucide/astro/icons/chevron-right\"\n\nimport { cn } from \"cn\"\nimport { buttonVariants, type ButtonVariantProps } from \"../button/index.ts\"\n\ntype Props = Omit<HTMLAttributes<\"button\">, \"type\"> & ButtonVariantProps\n\nconst {\n  class: className,\n  variant = \"outline\",\n  size = \"icon-sm\",\n  disabled,\n  ...props\n} = Astro.props\n---\n\n<button\n  type=\"button\"\n  data-slot=\"carousel-next\"\n  data-size={size}\n  data-variant={variant}\n  data-manual-disabled={disabled ? \"true\" : undefined}\n  disabled={disabled}\n  class={cn(buttonVariants({ variant, size }), \"absolute touch-manipulation rounded-full group-data-[orientation=horizontal]/carousel:inset-y-0 group-data-[orientation=horizontal]/carousel:-right-12 group-data-[orientation=horizontal]/carousel:my-auto group-data-[orientation=vertical]/carousel:right-auto group-data-[orientation=vertical]/carousel:-bottom-12 group-data-[orientation=vertical]/carousel:left-1/2 group-data-[orientation=vertical]/carousel:-translate-x-1/2 group-data-[orientation=vertical]/carousel:translate-y-0 group-data-[orientation=vertical]/carousel:rotate-90\", className)}\n  {...props}\n>\n  <slot>\n    <ChevronRightIcon aria-hidden=\"true\" />\n    <span class=\"sr-only\">Next slide</span>\n  </slot>\n</button>\n",
      "type": "registry:file",
      "target": "~/src/components/ui/carousel/carousel-next.astro"
    },
    {
      "path": "packages/ui/src/components/ui/carousel/carousel-parallax.astro",
      "content": "---\nimport type { HTMLAttributes } from \"astro/types\"\nimport { cn } from \"cn\"\n\ntype Props = HTMLAttributes<\"div\">\nconst { class: className, ...props } = Astro.props\n---\n\n<div\n  data-slot=\"carousel-parallax\"\n  class={cn(\"overflow-hidden\", className)}\n  {...props}\n>\n  <div data-slot=\"carousel-parallax-content\" class=\"origin-center\">\n    <slot />\n  </div>\n</div>\n",
      "type": "registry:file",
      "target": "~/src/components/ui/carousel/carousel-parallax.astro"
    },
    {
      "path": "packages/ui/src/components/ui/carousel/carousel-previous.astro",
      "content": "---\nimport type { HTMLAttributes } from \"astro/types\"\nimport ChevronLeftIcon from \"@lucide/astro/icons/chevron-left\"\n\nimport { cn } from \"cn\"\nimport { buttonVariants, type ButtonVariantProps } from \"../button/index.ts\"\n\ntype Props = Omit<HTMLAttributes<\"button\">, \"type\"> & ButtonVariantProps\n\nconst {\n  class: className,\n  variant = \"outline\",\n  size = \"icon-sm\",\n  disabled,\n  ...props\n} = Astro.props\n---\n\n<button\n  type=\"button\"\n  data-slot=\"carousel-previous\"\n  data-size={size}\n  data-variant={variant}\n  data-manual-disabled={disabled ? \"true\" : undefined}\n  disabled={disabled}\n  class={cn(\n    buttonVariants({ variant, size }),\n    \"absolute touch-manipulation rounded-full group-data-[orientation=horizontal]/carousel:inset-y-0 group-data-[orientation=horizontal]/carousel:-left-12 group-data-[orientation=horizontal]/carousel:my-auto group-data-[orientation=vertical]/carousel:-top-12 group-data-[orientation=vertical]/carousel:left-1/2 group-data-[orientation=vertical]/carousel:-translate-x-1/2 group-data-[orientation=vertical]/carousel:translate-y-0 group-data-[orientation=vertical]/carousel:rotate-90\",\n    className,\n  )}\n  {...props}\n>\n  <slot>\n    <ChevronLeftIcon aria-hidden=\"true\" />\n    <span class=\"sr-only\">Previous slide</span>\n  </slot>\n</button>\n",
      "type": "registry:file",
      "target": "~/src/components/ui/carousel/carousel-previous.astro"
    },
    {
      "path": "packages/ui/src/components/ui/carousel/carousel.astro",
      "content": "---\nimport type { HTMLAttributes } from \"astro/types\"\nimport type { EmblaOptionsType } from \"embla-carousel\"\n\nimport { cn } from \"cn\"\nimport type { CarouselOptions } from \"./types.ts\"\n\ntype Props = CarouselOptions & HTMLAttributes<\"div\">\n\nconst {\n  class: className,\n  carouselOptions,\n  orientation = \"horizontal\",\n  effects,\n  ...props\n} = Astro.props\n\nconst resolvedOpts: EmblaOptionsType = {\n  loop: true,\n  ...carouselOptions,\n  axis: orientation === \"horizontal\" ? \"x\" : \"y\",\n}\n---\n\n<div\n  data-slot=\"carousel\"\n  data-orientation={orientation}\n  data-carousel-effects={effects ? JSON.stringify(effects) : undefined}\n  data-carousel-options={JSON.stringify(resolvedOpts)}\n  class={cn(\"@container/carousel group/carousel relative\", className)}\n  role=\"region\"\n  aria-roledescription=\"carousel\"\n  {...props}\n>\n  <slot />\n</div>\n\n<script>\n  import { create, type CarouselController } from \"./carousel.ts\"\n\n  const controllers = new Set<CarouselController>()\n  const clearDisconnected = () => {\n    for (const controller of controllers) {\n      if (!controller.root.isConnected) {\n        controller.destroy()\n        controllers.delete(controller)\n      }\n    }\n  }\n  const observer = new MutationObserver(clearDisconnected)\n  const initialize = () => {\n    clearDisconnected()\n    for (const controller of create()) controllers.add(controller)\n    observer.observe(document.documentElement, {\n      childList: true,\n      subtree: true,\n    })\n  }\n  const clear = () => {\n    observer.disconnect()\n    for (const controller of controllers) controller.destroy()\n    controllers.clear()\n  }\n\n  initialize()\n  document.addEventListener(\"astro:page-load\", initialize)\n  document.addEventListener(\"astro:before-swap\", clear)\n</script>\n",
      "type": "registry:file",
      "target": "~/src/components/ui/carousel/carousel.astro"
    },
    {
      "path": "packages/ui/src/components/ui/carousel/carousel.ts",
      "content": "import {\n    clearRootBinding,\n    getRootBinding,\n    getRoots,\n    hasRootBinding,\n    setRootBinding,\n} from '@data-slot/core'\nimport EmblaCarousel, {\n    type EmblaCarouselType,\n    type EmblaOptionsType,\n    type EmblaPluginType,\n} from 'embla-carousel'\n\nimport { setupCarouselEffects } from './effects.ts'\n\nimport type { CarouselEffects, CarouselOptions } from './types.ts'\n\nconst ROOT_SLOT = 'carousel'\n\n/** Browser-only setup options. Plugin functions stay in the client script. */\nexport type CarouselControllerOptions = Omit<\n    CarouselOptions,\n    'carouselOptions'\n> & {\n    /** Browser options can include callbacks and DOM elements. */\n    carouselOptions?: EmblaOptionsType\n    plugins?: EmblaPluginType[]\n    /** Optional ancestor that receives arrow keys, such as a dialog panel. */\n    keyboardTarget?: HTMLElement\n}\n\nexport interface CarouselController {\n    readonly root: HTMLElement\n    readonly api: EmblaCarouselType\n    destroy(): void\n}\n\n/** Read an existing instance without private element or window properties. */\nexport function getCarouselApi(root: Element): EmblaCarouselType | undefined {\n    return getRootBinding<CarouselController>(root, ROOT_SLOT)?.api\n}\n\n/** Bind each unbound carousel in the scope. */\nexport function create(scope: ParentNode = document): CarouselController[] {\n    return getRoots<HTMLElement>(scope, ROOT_SLOT)\n        .filter((root) => !hasRootBinding(root, ROOT_SLOT))\n        .map((root) => createCarousel(root))\n}\n\nfunction readOptions<T>(value: string | undefined): T {\n    try {\n        const parsed = JSON.parse(value ?? '{}')\n        return parsed && typeof parsed === 'object' && !Array.isArray(parsed)\n            ? parsed\n            : ({} as T)\n    } catch {\n        return {} as T\n    }\n}\n\nconst getDetails = (api: EmblaCarouselType) => ({\n    api,\n    canScrollPrev: api.canScrollPrev(),\n    canScrollNext: api.canScrollNext(),\n    selectedScrollSnap: api.selectedScrollSnap(),\n    scrollSnapList: api.scrollSnapList(),\n})\n\nconst emit = (\n    root: HTMLElement,\n    type: 'carousel:init' | 'carousel:select',\n    api: EmblaCarouselType,\n) => {\n    root.dispatchEvent(\n        new CustomEvent(type, {\n            detail: getDetails(api),\n        }),\n    )\n}\n\nconst syncButton = (button: Element | null, enabled: boolean) => {\n    if (!(button instanceof HTMLButtonElement)) {\n        return\n    }\n\n    if (button.dataset.manualDisabled === 'true') {\n        button.disabled = true\n        return\n    }\n\n    button.disabled = !enabled\n}\n\n/** Bind one carousel. Repeated calls return its existing controller. */\nexport function createCarousel(\n    root: HTMLElement,\n    options: CarouselControllerOptions = {},\n): CarouselController {\n    const existing = getRootBinding<CarouselController>(root, ROOT_SLOT)\n    if (existing) return existing\n    const ownedElements = <T extends Element>(selector: string) =>\n        Array.from(root.querySelectorAll<T>(selector)).filter(\n            (element) => element.closest('[data-slot=\"carousel\"]') === root,\n        )\n    const viewport = ownedElements<HTMLElement>(\n        '[data-slot=\"carousel-content\"]',\n    )[0]\n    const prevButtons = ownedElements<HTMLButtonElement>(\n        '[data-slot=\"carousel-previous\"]',\n    )\n    const nextButtons = ownedElements<HTMLButtonElement>(\n        '[data-slot=\"carousel-next\"]',\n    )\n    const dotGroups = ownedElements<HTMLElement>('[data-slot=\"carousel-dots\"]')\n\n    if (!(viewport instanceof HTMLElement)) {\n        throw new Error('Carousel requires CarouselContent.')\n    }\n\n    const orientation =\n        options.orientation ?? root.dataset.orientation ?? 'horizontal'\n    root.dataset.orientation = orientation\n    const api = EmblaCarousel(\n        viewport,\n        {\n            loop: true,\n            ...readOptions<EmblaOptionsType>(root.dataset.carouselOptions),\n            ...options.carouselOptions,\n            axis: orientation === 'vertical' ? 'y' : 'x',\n        },\n        options.plugins,\n    )\n    const reducedMotion = root.ownerDocument.defaultView!.matchMedia(\n        '(prefers-reduced-motion: reduce)',\n    )\n\n    const syncDots = (count: number, selected: number) => {\n        for (const group of dotGroups) {\n            let buttons = Array.from(\n                group.querySelectorAll<HTMLButtonElement>(\n                    '[data-slot=\"carousel-dot\"]',\n                ),\n            )\n\n            if (buttons.length !== count) {\n                const template =\n                    group.querySelector<HTMLTemplateElement>('template')\n                const prototype = template?.content.querySelector('button')\n                if (!prototype) continue\n\n                const focusedIndex = buttons.findIndex(\n                    (button) => button === document.activeElement,\n                )\n                buttons.forEach((button) => button.remove())\n                buttons = Array.from({ length: count }, (_, index) => {\n                    const button = prototype.cloneNode(\n                        true,\n                    ) as HTMLButtonElement\n                    button.dataset.carouselSnap = String(index)\n                    button.setAttribute(\n                        'aria-label',\n                        `Go to slide ${index + 1}`,\n                    )\n                    group.append(button)\n                    return button\n                })\n                if (focusedIndex >= 0) {\n                    buttons[Math.min(focusedIndex, count - 1)]?.focus({\n                        preventScroll: true,\n                    })\n                }\n            }\n\n            group.dataset.snapCount = String(count)\n            buttons.forEach((button, index) => {\n                if (index === selected)\n                    button.setAttribute('aria-current', 'true')\n                else button.removeAttribute('aria-current')\n                button.disabled = count < 2\n            })\n        }\n    }\n\n    const sync = () => {\n        const details = getDetails(api)\n\n        root.dataset.canScrollPrev = details.canScrollPrev ? 'true' : 'false'\n        root.dataset.canScrollNext = details.canScrollNext ? 'true' : 'false'\n        root.dataset.selectedScrollSnap = String(details.selectedScrollSnap)\n\n        prevButtons.forEach((button) =>\n            syncButton(button, details.canScrollPrev),\n        )\n        nextButtons.forEach((button) =>\n            syncButton(button, details.canScrollNext),\n        )\n        syncDots(details.scrollSnapList.length, details.selectedScrollSnap)\n\n        // A scroll snap can contain several slides. Use Embla's group mapping.\n        const selectedSlides = new Set(\n            api.internalEngine().slideRegistry[details.selectedScrollSnap],\n        )\n        api.slideNodes().forEach((slide, index) => {\n            const selected = selectedSlides.has(index)\n            slide.dataset.selected = String(selected)\n        })\n\n        emit(root, 'carousel:select', api)\n    }\n\n    const onPrevClick = () => {\n        api.scrollPrev(reducedMotion.matches)\n    }\n\n    const onNextClick = () => {\n        api.scrollNext(reducedMotion.matches)\n    }\n\n    const onClick = (event: MouseEvent) => {\n        if (!(event.target instanceof Element)) return\n        const button = event.target.closest(\n            '[data-slot=\"carousel-dot\"], [data-carousel-select]',\n        )\n        if (!button || button.closest('[data-slot=\"carousel\"]') !== root) return\n\n        if (\n            button instanceof HTMLElement &&\n            button.dataset.carouselSnap !== undefined\n        ) {\n            api.scrollTo(\n                Number(button.dataset.carouselSnap),\n                reducedMotion.matches,\n            )\n            return\n        }\n\n        const slide = button.closest<HTMLElement>('[data-slot=\"carousel-item\"]')\n        if (!slide) return\n        const slideIndex = api.slideNodes().indexOf(slide)\n        const snapIndex = api\n            .internalEngine()\n            .slideRegistry.findIndex((group) => group.includes(slideIndex))\n        if (snapIndex >= 0) api.scrollTo(snapIndex, reducedMotion.matches)\n    }\n\n    const keyboardTarget = options.keyboardTarget ?? root\n    const onKeyDown = (event: KeyboardEvent) => {\n        if (\n            !(event.target instanceof Element) ||\n            (event.target.closest('[data-slot=\"carousel\"]') !== root &&\n                (keyboardTarget === root ||\n                    event.target.closest('[data-slot=\"carousel\"]')))\n        )\n            return\n        if (\n            event.defaultPrevented ||\n            event.altKey ||\n            event.ctrlKey ||\n            event.metaKey\n        )\n            return\n        if (\n            event.target.closest(\n                'input, textarea, select, [contenteditable=\"true\"]',\n            )\n        )\n            return\n        const isVertical = api.internalEngine().options.axis === 'y'\n        const rtl = api.internalEngine().options.direction === 'rtl'\n\n        if (!isVertical && event.key === 'ArrowLeft') {\n            event.preventDefault()\n            const scroll = rtl ? api.scrollNext : api.scrollPrev\n            scroll(reducedMotion.matches)\n        }\n\n        if (!isVertical && event.key === 'ArrowRight') {\n            event.preventDefault()\n            const scroll = rtl ? api.scrollPrev : api.scrollNext\n            scroll(reducedMotion.matches)\n        }\n\n        if (isVertical && event.key === 'ArrowUp') {\n            event.preventDefault()\n            api.scrollPrev(reducedMotion.matches)\n        }\n\n        if (isVertical && event.key === 'ArrowDown') {\n            event.preventDefault()\n            api.scrollNext(reducedMotion.matches)\n        }\n    }\n\n    prevButtons.forEach((button) =>\n        button.addEventListener('click', onPrevClick),\n    )\n    nextButtons.forEach((button) =>\n        button.addEventListener('click', onNextClick),\n    )\n\n    root.addEventListener('click', onClick)\n    keyboardTarget.addEventListener('keydown', onKeyDown, true)\n\n    api.on('reInit', sync)\n    api.on('select', sync)\n\n    const cleanupEffects = setupCarouselEffects(\n        api,\n        options.effects ??\n            readOptions<CarouselEffects>(root.dataset.carouselEffects),\n        reducedMotion,\n    )\n    let destroyed = false\n    const view = root.ownerDocument.defaultView!\n    const frame = view.requestAnimationFrame(() => {\n        if (!destroyed) emit(root, 'carousel:init', api)\n    })\n    const controller: CarouselController = {\n        root,\n        api,\n        destroy() {\n            if (destroyed) return\n            destroyed = true\n            view.cancelAnimationFrame(frame)\n            api.off('reInit', sync)\n            api.off('select', sync)\n            api.off('destroy', controller.destroy)\n            prevButtons.forEach((button) =>\n                button.removeEventListener('click', onPrevClick),\n            )\n            nextButtons.forEach((button) =>\n                button.removeEventListener('click', onNextClick),\n            )\n            root.removeEventListener('click', onClick)\n            keyboardTarget.removeEventListener('keydown', onKeyDown, true)\n            cleanupEffects()\n            clearRootBinding(root, ROOT_SLOT, controller)\n            api.destroy()\n        },\n    }\n    setRootBinding(root, ROOT_SLOT, controller)\n    api.on('destroy', controller.destroy)\n    sync()\n    return controller\n}\n",
      "type": "registry:file",
      "target": "~/src/components/ui/carousel/carousel.ts"
    },
    {
      "path": "packages/ui/src/components/ui/carousel/effects.ts",
      "content": "import type { EmblaCarouselType } from 'embla-carousel'\n\nimport type {\n    CarouselArcOptions,\n    CarouselEffects,\n    CarouselFadeOptions,\n    CarouselParallaxOptions,\n    CarouselScaleOptions,\n} from './types.ts'\n\nconst clamp = (value: number, min: number, max: number) =>\n    Math.min(max, Math.max(min, value))\n\nconst finite = (value: number | undefined, fallback: number) =>\n    typeof value === 'number' && Number.isFinite(value) ? value : fallback\n\nconst positive = (value: number | undefined, fallback: number) => {\n    const result = finite(value, fallback)\n    return result > 0 ? result : fallback\n}\n\n/** Interpolate from one at the center to a minimum at the given distance. */\nconst tween = (distance: number, min: number, range: number) =>\n    1 - (1 - min) * clamp(Math.abs(distance) / range, 0, 1)\n\n/** Select the equivalent loop position nearest the viewport center. */\nconst wrap = (offset: number, length: number) =>\n    length > 0 ? offset - Math.floor(offset / length + 0.5) * length : offset\n\n/** Arc geometry only. The renderer owns loop compensation and style writes. */\nfunction createArc(options: CarouselArcOptions = {}) {\n    const radius = positive(options.radius, 2.4)\n    const angle = clamp(finite(options.angle, 18), 1, 45)\n    return (distance: number, width: number) => {\n        const rotation = clamp(distance * angle, -90, 90)\n        const radians = (rotation * Math.PI) / 180\n        return {\n            x: radius * width * Math.sin(radians),\n            y: radius * width * (1 - Math.cos(radians)),\n            rotation,\n        }\n    }\n}\n\n/** Opacity interpolation adapted from Embla's tween example. */\nfunction createFade(options: CarouselFadeOptions = {}) {\n    const min = clamp(finite(options.min, 0), 0, 1)\n    const distance = positive(options.distance, 2.5)\n    return (position: number) => tween(position, min, distance)\n}\n\n/** Scale interpolation adapted from Embla's tween example. */\nfunction createScale(options: CarouselScaleOptions = {}) {\n    const min = clamp(finite(options.min, 0.8), 0, 1)\n    const distance = positive(options.distance, 1)\n    return (position: number) => tween(position, min, distance)\n}\n\n/** Translation and overscan for clipped content, adapted from Embla's example. */\nfunction createParallax(options: CarouselParallaxOptions = {}) {\n    const amount = clamp(finite(options.amount, 0.2), 0, 1)\n    return (distance: number, size: number) => ({\n        offset: -clamp(distance, -1, 1) * amount * size,\n        scale: 1 + amount * 2,\n    })\n}\n\nconst bindings = new WeakMap<EmblaCarouselType, () => void>()\nconst config = <T>(value: boolean | T): T | undefined =>\n    typeof value === 'boolean' ? undefined : value\n\ntype StyleProperty =\n    | 'transform'\n    | 'opacity'\n    | 'z-index'\n    | 'position'\n    | 'transition'\n\ntype SavedStyle = { value: string; priority: string }\n\n/**\n * Bind one effect renderer to an Embla instance. Calling it again replaces the\n * previous effects. Return a cleanup function; destroy also runs it.\n * The scroll interpolation follows Embla's v8 tween examples:\n * https://www.embla-carousel.com/docs/v8/examples/predefined\n */\nexport function setupCarouselEffects(\n    api: EmblaCarouselType,\n    options: CarouselEffects = {},\n    reducedMotion = api\n        .internalEngine()\n        .ownerWindow.matchMedia('(prefers-reduced-motion: reduce)'),\n): () => void {\n    bindings.get(api)?.()\n    if (!options.arc && !options.scale && !options.fade && !options.parallax)\n        return () => {}\n\n    const arc = options.arc ? createArc(config(options.arc)) : undefined\n    const scale = options.scale ? createScale(config(options.scale)) : undefined\n    const fade = options.fade ? createFade(config(options.fade)) : undefined\n    const parallax = options.parallax\n        ? createParallax(config(options.parallax))\n        : undefined\n    let engine = api.internalEngine()\n    let destroyed = false\n    let slides: ReturnType<typeof measure>[] = []\n    let loopOffsets = new Map<number, () => number>()\n    const styles = new Map<HTMLElement, Map<StyleProperty, SavedStyle>>()\n\n    const write = (\n        node: HTMLElement,\n        property: StyleProperty,\n        value: string,\n    ) => {\n        let saved = styles.get(node)\n        if (!saved) styles.set(node, (saved = new Map()))\n        if (!saved.has(property))\n            saved.set(property, {\n                value: node.style.getPropertyValue(property),\n                priority: node.style.getPropertyPriority(property),\n            })\n        if (node.style.getPropertyValue(property) !== value)\n            node.style.setProperty(property, value)\n    }\n    const clear = () => {\n        for (const [node, properties] of styles) {\n            for (const [property, saved] of properties) {\n                if (saved.value)\n                    node.style.setProperty(\n                        property,\n                        saved.value,\n                        saved.priority,\n                    )\n                else node.style.removeProperty(property)\n            }\n        }\n        styles.clear()\n        for (const { layer, inert } of slides) {\n            if (layer && layer.inert !== inert) layer.inert = inert\n        }\n    }\n    const ownPart = (slide: HTMLElement, slot: string) =>\n        Array.from(\n            slide.querySelectorAll<HTMLElement>(`[data-slot=\"${slot}\"]`),\n        ).find((node) => node.closest('[data-slot=\"carousel-item\"]') === slide)\n\n    function measure(slide: HTMLElement) {\n        const layer = ownPart(slide, 'carousel-layer')\n        const content = ownPart(slide, 'carousel-parallax-content')\n        return {\n            slide,\n            layer,\n            content,\n            width: layer?.offsetWidth ?? 0,\n            contentSize:\n                engine.options.axis === 'x'\n                    ? (content?.offsetWidth ?? 0)\n                    : (content?.offsetHeight ?? 0),\n            inert: layer?.inert ?? false,\n        }\n    }\n\n    const update = () => {\n        if (destroyed || reducedMotion.matches) return\n        const { axis, containerRect, slideRects, offsetLocation } = engine\n        const viewSize = axis.measureSize(containerRect)\n        if (!viewSize) return\n        const hasArc = !!arc && engine.options.axis === 'x'\n        const loopLength = engine.options.loop ? engine.limit.length : 0\n        const location = offsetLocation.get()\n\n        slides.forEach(\n            ({ slide, layer, content, width, contentSize, inert }, index) => {\n                const rect = slideRects[index]\n                if (!rect) return\n                const size = axis.measureSize(rect)\n                if (!size) return\n                const offset =\n                    axis.direction(\n                        rect[axis.startEdge] - containerRect[axis.startEdge],\n                    ) +\n                    size / 2 +\n                    location -\n                    viewSize / 2\n                const renderedOffset = axis.direction(\n                    offset + (loopOffsets.get(index)?.() ?? 0),\n                )\n                // The nearest visual copy is independent of Embla's flat loop boundary.\n                // Compensate on the inner layer when Embla relocates the outer slide.\n                const visualOffset =\n                    hasArc && loopLength\n                        ? axis.direction(wrap(offset, loopLength))\n                        : renderedOffset\n                const distance = visualOffset / size\n\n                if (layer && (hasArc || scale || fade)) {\n                    const transforms: string[] = []\n                    let opacity = fade?.(distance) ?? 1\n                    if (hasArc) {\n                        const point = arc!(distance, width)\n                        transforms.push(\n                            `translate3d(${point.x - renderedOffset}px, ${point.y}px, 0) rotate(${point.rotation}deg)`,\n                        )\n                        write(slide, 'position', 'relative')\n                        write(\n                            slide,\n                            'z-index',\n                            String(Math.round(100 - Math.abs(distance) * 10)),\n                        )\n                        // Hide the seam before the nearest copy switches sides. This\n                        // also covers small radii where both ends fit in the viewport.\n                        if (loopLength)\n                            opacity *= clamp(\n                                (loopLength / 2 - Math.abs(visualOffset)) /\n                                    size,\n                                0,\n                                1,\n                            )\n                    }\n                    if (scale) transforms.push(`scale(${scale(distance)})`)\n                    if (transforms.length) {\n                        write(layer, 'transition', 'none')\n                        write(layer, 'transform', transforms.join(' '))\n                    }\n                    if (fade || (hasArc && loopLength)) {\n                        write(layer, 'transition', 'none')\n                        write(layer, 'opacity', String(opacity))\n                        const hidden = inert || opacity === 0\n                        if (layer.inert !== hidden) layer.inert = hidden\n                    }\n                }\n                if (content && parallax) {\n                    const value = parallax(distance, contentSize)\n                    const x = engine.options.axis === 'x' ? value.offset : 0\n                    const y = engine.options.axis === 'y' ? value.offset : 0\n                    write(content, 'transition', 'none')\n                    write(\n                        content,\n                        'transform',\n                        `translate3d(${x}px, ${y}px, 0) scale(${value.scale})`,\n                    )\n                }\n            },\n        )\n    }\n\n    const refresh = () => {\n        clear()\n        engine = api.internalEngine()\n        slides = api.slideNodes().map(measure)\n        loopOffsets = new Map(\n            engine.options.loop\n                ? engine.slideLooper.loopPoints.map((point) => [\n                      point.index,\n                      point.target,\n                  ])\n                : [],\n        )\n        update()\n    }\n    const onMotionChange = () => {\n        clear()\n        update()\n    }\n    const cleanup = () => {\n        if (destroyed) return\n        destroyed = true\n        api.off('scroll', update)\n        api.off('settle', update)\n        api.off('slideFocus', update)\n        api.off('reInit', refresh)\n        api.off('destroy', cleanup)\n        reducedMotion.removeEventListener('change', onMotionChange)\n        clear()\n        if (bindings.get(api) === cleanup) bindings.delete(api)\n    }\n\n    bindings.set(api, cleanup)\n    api.on('scroll', update)\n    api.on('settle', update)\n    api.on('slideFocus', update)\n    api.on('reInit', refresh)\n    api.on('destroy', cleanup)\n    reducedMotion.addEventListener('change', onMotionChange)\n    refresh()\n    return cleanup\n}\n",
      "type": "registry:file",
      "target": "~/src/components/ui/carousel/effects.ts"
    },
    {
      "path": "packages/ui/src/components/ui/carousel/index.ts",
      "content": "export type {\n    EmblaCarouselType as CarouselApi,\n    EmblaPluginType as CarouselPlugin,\n} from 'embla-carousel'\n\nexport type {\n    CarouselArcOptions,\n    CarouselContentProps,\n    CarouselEffects,\n    CarouselEmblaOptions,\n    CarouselFadeOptions,\n    CarouselOptions,\n    CarouselParallaxOptions,\n    CarouselScaleOptions,\n} from './types.ts'\n\nexport { create, createCarousel, getCarouselApi } from './carousel.ts'\nexport type {\n    CarouselController,\n    CarouselControllerOptions,\n} from './carousel.ts'\nexport { setupCarouselEffects } from './effects.ts'\n\nexport { default as Carousel } from './carousel.astro'\nexport { default as CarouselContent } from './carousel-content.astro'\nexport { default as CarouselItem } from './carousel-item.astro'\nexport { default as CarouselLayer } from './carousel-layer.astro'\nexport { default as CarouselParallax } from './carousel-parallax.astro'\nexport { default as CarouselDots } from './carousel-dots.astro'\nexport { default as CarouselPrevious } from './carousel-previous.astro'\nexport { default as CarouselNext } from './carousel-next.astro'\n",
      "type": "registry:file",
      "target": "~/src/components/ui/carousel/index.ts"
    },
    {
      "path": "packages/ui/src/components/ui/carousel/types.ts",
      "content": "import type { EmblaOptionsType } from 'embla-carousel'\n\ntype CarouselAlign = Extract<EmblaOptionsType['align'], string>\n\ntype SerializableEmblaOptions = Pick<\n    EmblaOptionsType,\n    | 'active'\n    | 'containScroll'\n    | 'direction'\n    | 'slidesToScroll'\n    | 'dragFree'\n    | 'dragThreshold'\n    | 'inViewThreshold'\n    | 'loop'\n    | 'skipSnaps'\n    | 'duration'\n    | 'startIndex'\n>\n\ninterface CarouselEmblaBaseOptions extends SerializableEmblaOptions {\n    /** Enable the carousel's controls. @default true */\n    active?: boolean\n    /** Prevent the carousel from scrolling outside of its container. @default true */\n    containScroll?: NonNullable<EmblaOptionsType['containScroll']>\n    /** The direction of the carousel. @default 'ltr' (left to right) */\n    direction?: 'ltr' | 'rtl'\n    /** The number of slides to scroll on a single previous/next button click. @default 1 */\n    slidesToScroll?: NonNullable<EmblaOptionsType['slidesToScroll']>\n    /** Allow the user to drag the carousel freely. @default false */\n    dragFree?: boolean\n    /** The percentage of the slide that must be dragged to be considered a drag. @default 0.5 */\n    dragThreshold?: number\n    /** The percentage of the slide that must be visible to be considered in view. @default 0.5 */\n    inViewThreshold?: NonNullable<EmblaOptionsType['inViewThreshold']>\n    /** Return to the starting slide when the end is reached. @default false */\n    loop?: boolean\n    /** Skip the snap points when the carousel is at the start or end. @default false */\n    skipSnaps?: boolean\n    /** The duration of the animation in milliseconds. @default 1000 */\n    duration?: number\n    /** The index of the first slide to show. @default 0 */\n    startIndex?: number\n    /** Slide alignment. Callback functions require browser setup. */\n    align?: CarouselAlign\n    /** Enable drag handling. @default true */\n    watchDrag?: boolean\n    /** Observe carousel size changes. @default true */\n    watchResize?: boolean\n    /** Observe added or removed slides. @default true */\n    watchSlides?: boolean\n    /** Scroll to focused slide content. @default true */\n    watchFocus?: boolean\n}\n\n/** Embla options that can pass through JSON from Astro to the browser. */\nexport type CarouselEmblaOptions = CarouselEmblaBaseOptions & {\n    /** Media queries with the same options, without nested breakpoints. */\n    breakpoints?: Record<string, CarouselEmblaBaseOptions>\n}\n\n/** Geometry for a horizontal arc. Scale and fade are separate effects. */\nexport type CarouselArcOptions = {\n    /** Circle radius in layer widths. Must be positive. @default 2.4 */\n    radius?: number\n    /** Rotation per slide width, in degrees. Range: 1–45. @default 18 */\n    angle?: number\n}\n\n/** Scale of a layer as it moves away from the viewport center. */\nexport type CarouselScaleOptions = {\n    /** Smallest scale. Range: 0–1. @default 0.8 */\n    min?: number\n    /** Distance to the smallest scale, in slide widths. @default 1 */\n    distance?: number\n}\n\n/** Opacity of a layer as it moves away from the viewport center. */\nexport type CarouselFadeOptions = {\n    /** Lowest opacity. Range: 0–1. @default 0 */\n    min?: number\n    /** Distance to the lowest opacity, in slide widths. @default 2.5 */\n    distance?: number\n}\n\n/** Movement of content inside a clipped CarouselParallax part. */\nexport type CarouselParallaxOptions = {\n    /** Maximum translation as a fraction of the content size. Range: 0–1. @default 0.2 */\n    amount?: number\n}\n\n/** Optional effects. `true` uses the defaults; omitted effects stay off. */\nexport type CarouselEffects = {\n    /** Position and rotate CarouselLayer parts on a horizontal arc. */\n    arc?: boolean | CarouselArcOptions\n    /** Scale CarouselLayer parts. */\n    scale?: boolean | CarouselScaleOptions\n    /** Fade CarouselLayer parts. Fully transparent layers become inert. */\n    fade?: boolean | CarouselFadeOptions\n    /** Move content inside CarouselParallax parts. Supports either axis. */\n    parallax?: boolean | CarouselParallaxOptions\n}\n\n/** Props for the carousel root, minus HTML attributes. */\nexport type CarouselOptions = {\n    /** JSON-compatible Embla options. Orientation and Astro parts control the axis and elements. */\n    carouselOptions?: CarouselEmblaOptions\n    /** Scroll axis for the carousel. @default \"horizontal\" */\n    orientation?: 'horizontal' | 'vertical'\n    /** Independent effects applied to the optional inner parts. */\n    effects?: CarouselEffects\n}\n\n/** Layout props for the carousel track and its clipping viewport. */\nexport type CarouselContentProps = {\n    /** CSS gap value for space between items. @default \"1rem\" */\n    gap?: string\n    /** Classes for the clipping viewport, such as padding for an arc. */\n    viewportClass?: string\n}\n",
      "type": "registry:ui",
      "target": "~/src/components/ui/carousel/types.ts"
    }
  ],
  "meta": {
    "framework": "astro",
    "source": "@gnostic/ui",
    "testedDependencies": {
      "@data-slot/core": "^1.0.2",
      "@lucide/astro": "^1.68.0",
      "cn": "0.5.2",
      "embla-carousel": "^8.6.0"
    }
  },
  "docs": "https://ui.gnosticai.com/components/carousel",
  "categories": [
    "ui"
  ],
  "type": "registry:ui"
}
