{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "liquid-glass-carousel",
  "title": "Liquid Glass Carousel",
  "description": "A snap carousel of capsule cards that melt into liquid glass at the edges of the frame. Cards stretch into a flared, smeared drip with a thin rainbow fringe as they leave, re-form as they come back, and the centred card stays crisp.",
  "dependencies": [
    "@rexa-developer/tiks",
    "lucide-react",
    "motion",
    "web-haptics"
  ],
  "files": [
    {
      "path": "src/registry/components/liquid-glass-carousel/liquid-glass-carousel.tsx",
      "content": "\"use client\";\n\nimport { useTiks } from \"@rexa-developer/tiks/react\";\nimport {\n\tArrowDownIcon,\n\tArrowLeftIcon,\n\tArrowRightIcon,\n\tArrowUpIcon,\n\tPauseIcon,\n\tPlayIcon,\n} from \"lucide-react\";\nimport {\n\ttype AnimationPlaybackControls,\n\tanimate,\n\tcancelFrame,\n\tframe,\n\tuseMotionValue,\n\tuseReducedMotion,\n} from \"motion/react\";\nimport {\n\tChildren,\n\ttype ComponentProps,\n\ttype CSSProperties,\n\tcreateContext,\n\ttype KeyboardEvent,\n\ttype MouseEvent,\n\ttype PointerEvent,\n\ttype ReactNode,\n\ttype Ref,\n\tuseCallback,\n\tuseContext,\n\tuseEffect,\n\tuseId,\n\tuseImperativeHandle,\n\tuseLayoutEffect,\n\tuseReducer,\n\tuseRef,\n\tuseState,\n} from \"react\";\nimport { useWebHaptics } from \"web-haptics/react\";\nimport { cn } from \"@/lib/utils\";\n\nconst DEFAULT_SLIDE_SIZE = { width: 168, height: 232 } as const;\nconst DEFAULT_GAP = 20;\n/** Viewport length, in slide lengths, unless `--lgc-length` is set. */\nconst VIEWPORT_SLIDES = 2.6;\n/**\n * Room across the axis, as a share of the slide's width, so a full flare is\n * never clipped. Slides scale down to keep it on narrow screens.\n */\nconst CROSS_ROOM = 1.24;\n\n// Motion. Position is a slide count along the axis, and everything is drawn\n// from it, so the melt follows a drag exactly and reverses exactly.\n/** About 500 ms to rest, critically damped, so the centred card never overshoots. */\nconst snapSpring = { type: \"spring\", stiffness: 260, damping: 32 } as const;\n/** Reduced motion swaps the glide for a fade of this length. */\nconst FADE_MS = 150;\n/** Pointer travel, in px, before a press becomes a drag. */\nconst DRAG_SLOP = 6;\n/** Ms of pointer samples used for the release speed. */\nconst VELOCITY_WINDOW = 100;\n/** Seconds of release velocity projected ahead before picking a slide. */\nconst PROJECTION_SECONDS = 0.16;\n/** Most slides one flick can travel. */\nconst MAX_FLICK = 2;\n/** Furthest a drag rubber-bands past either end when not looping, in px. */\nconst RUBBER_LIMIT = 56;\n/** Most slides arrow keys can queue ahead of the one on screen. */\nconst MAX_QUEUE = 3;\n/** Wheel travel, in px, that steps one slide. */\nconst WHEEL_STEP = 40;\n/** Ms without wheel events that ends a wheel gesture. */\nconst WHEEL_IDLE = 160;\n/** Jumps longer than this skip ahead and glide the last two slides. */\nconst MAX_GLIDE = 3;\n\n// The melt: a lens fixed to each end of the frame. Inside the outer\n// `meltZone` of the viewport every pixel samples back toward the centre, more\n// the closer it sits to the edge, so cards passing through smear into\n// streaks, flare like a drip, and pick up a thin rainbow fringe.\n/**\n * How hard the lens magnifies along the axis once it is fully in: rows are\n * drawn 1 / (1 - 0.86), about 7 times as long. Under 1, so it never folds.\n */\nconst MAGNIFY = 0.9;\n/** Share of the zone, from its inner edge, over which the lens eases in. */\nconst RAMP = 1;\n/** Extra width at the very edge, as a share of the distance from the axis. */\nconst FLARE = 0.3;\n/**\n * Blue bends further than green, and red less: the spread of their pulls\n * along the axis, and of their flare across it. Tiny along the axis, where\n * the lens magnifies 7 times, so content keeps clean streaks; a little wider\n * across, so the flared sides split by a pixel or two at the very edge.\n */\nconst DISPERSION_ALONG = 0.004;\nconst DISPERSION_ACROSS = 0.1;\n/**\n * Share of the split colour kept in the result; the rest is the undispersed\n * image, so the fringe is a faint tint, never a saturated rim.\n */\nconst FRINGE = 0.45;\n/** Blur along the axis inside the zones, in px, so magnified rows read as streaks. */\nconst STREAK_BLUR = 2;\n/** A little blur across, so the fringe reads as light, not as painted bands. */\nconst FRINGE_BLUR = 0.8;\n/** Depth of the soft fade at each end, as a share of the viewport length. */\nconst EDGE_FADE = 0.12;\n/** Where SVG filters are off, slides stretch, flare, and blur on their own. */\nconst FALLBACK_STRETCH = 0.28;\nconst FALLBACK_FLARE = 0.08;\nconst FALLBACK_BLUR = 1.6;\n/** Rows along the axis and columns across it in the displacement map. */\nconst MAP_LENGTH = 512;\nconst MAP_CROSS = 64;\n/** Room for the fringe and blur either side of a fully flared slide, in px. */\nconst BAND_MARGIN = 8;\n\n// A fingertip on a glass rod: a short, bright tick with a faint ring.\nconst TICK_SOUND = {\n\tname: \"liquid-glass-carousel-tick\",\n\tbaseFreq: 1180,\n\tnoiseColor: \"white\",\n\toscType: \"sine\",\n\tfilterFreq: 5400,\n\tfilterQ: 6,\n\tattack: 0.001,\n\tdecay: 0.32,\n\tbrightness: 5200,\n} as const;\n\nconst NO_DRAG_SELECTOR =\n\t\"input, textarea, select, [contenteditable=''], [contenteditable='true'], [data-lgc-no-drag]\";\n\ntype Orientation = \"vertical\" | \"horizontal\";\ntype MeltMode = \"filter\" | \"css\" | \"off\";\n/**\n * What moved the carousel. Only `user` plays sound and announces, and only\n * `prop` (a controlled index) skips `onIndexChange`.\n */\ntype Source = \"user\" | \"auto\" | \"api\" | \"prop\";\ntype Geometry = {\n\t/** Viewport length along the axis, in px. */\n\tlength: number;\n\t/** Slide length along the axis, in px. */\n\tslide: number;\n\t/** Slide width across the axis, in px. */\n\tcross: number;\n\t/** Slide length plus the gap. */\n\tpitch: number;\n\t/** Melt zone depth, in px, at each end. */\n\tzone: number;\n\t/** 1, or -1 for a horizontal carousel in a right-to-left page. */\n\tsign: number;\n};\ntype Painted = {\n\tvisible: boolean;\n\ttransform: string;\n\torigin: string;\n\tfilter: string;\n\twillChange: string;\n};\ntype Channel = \"r\" | \"g\" | \"b\";\ntype Lens = {\n\t/** A displacement map for each colour channel. */\n\tmaps: Record<Channel, string>;\n\t/** Viewport size along and across the axis, in px. */\n\tlength: number;\n\tcross: number;\n\t/**\n\t * Width of the band the filter covers across the axis, centred on it, in\n\t * px: a flared slide and its fringe. The rest is empty page, and filter\n\t * cost grows with area.\n\t */\n\tband: number;\n\tzone: number;\n\t/** Displacement scale, in px: twice the furthest pull at the edge. */\n\tscale: number;\n};\ntype Drag = {\n\tpointerId: number;\n\tpointerType: string;\n\tstartX: number;\n\tstartY: number;\n\tstartPosition: number;\n\t/** Layout px per screen px, so zoom and transforms work. */\n\tscale: number;\n\tmoved: boolean;\n\tsamples: Array<{ time: number; along: number }>;\n};\n\nexport type LiquidGlassCarouselLength = number | string;\n\nexport interface LiquidGlassCarouselHandle {\n\t/** Moves to the next slide. Silent, like a prop change. */\n\tnext: () => void;\n\t/** Moves to the previous slide. Silent. */\n\tprev: () => void;\n\t/** Moves to slide `index`, the short way round when looping. Silent. */\n\tgoTo: (index: number) => void;\n}\n\nexport interface LiquidGlassCarouselProps\n\textends Omit<ComponentProps<\"div\">, \"children\" | \"ref\" | \"aria-label\"> {\n\t/** `LiquidGlassCarouselSlide` elements, and optionally `LiquidGlassCarouselControls`. */\n\tchildren?: ReactNode;\n\t/** Names the carousel region, such as \"Featured artists\". */\n\t\"aria-label\": string;\n\t/** Axis the slides travel along. */\n\torientation?: Orientation;\n\t/** Controlled index of the centred slide. */\n\tindex?: number;\n\t/** Slide centred on mount when uncontrolled. */\n\tdefaultIndex?: number;\n\t/** Called when a drag, key, click, wheel, or autoplay step picks a new slide. */\n\tonIndexChange?: (index: number) => void;\n\t/** Wrap from the last slide back to the first, with no seam. */\n\tloop?: boolean;\n\t/** Ms between automatic steps, or `false`. Starts paused under reduced motion. */\n\tautoplay?: false | number;\n\t/** Depth of the melt at each end, as a share of the viewport length, from 0 to 0.5. */\n\tmeltZone?: number;\n\t/** `\"off\"` keeps the soft edge fade but never distorts the slides. */\n\tmelt?: \"auto\" | \"off\";\n\t/**\n\t * Slide size, in px or CSS lengths. Px sizes scale down to fit narrow\n\t * containers. The viewport is 2.6 slides long; set `--lgc-length` on the\n\t * root to change it.\n\t */\n\tslideSize?: {\n\t\twidth: LiquidGlassCarouselLength;\n\t\theight: LiquidGlassCarouselLength;\n\t};\n\t/** Space between slides, in px or a CSS length. */\n\tgap?: LiquidGlassCarouselLength;\n\t/** Play a soft glass tick when a slide you moved to settles. */\n\tsound?: boolean;\n\t/** Trigger a haptic tick on touch devices when a swiped slide settles. */\n\thaptics?: boolean;\n\t/** Exposes `next()`, `prev()`, and `goTo()`. */\n\tref?: Ref<LiquidGlassCarouselHandle>;\n}\n\ntype CarouselContextValue = {\n\tcount: number;\n\tindex: number;\n\tloop: boolean;\n\torientation: Orientation;\n\tautoplay: boolean;\n\tplaying: boolean;\n\tsetPlaying: (playing: boolean) => void;\n\tstep: (by: number) => void;\n\tregisterControls: () => () => void;\n};\n\nconst CarouselContext = createContext<CarouselContextValue | null>(null);\n\ntype SlideContextValue = { index: number; count: number };\n\nconst SlideContext = createContext<SlideContextValue | null>(null);\n\nfunction useCarousel(part: string) {\n\tconst context = useContext(CarouselContext);\n\tif (!context) {\n\t\tthrow new Error(`${part} must be used inside LiquidGlassCarousel.`);\n\t}\n\treturn context;\n}\n\nfunction clamp(value: number, min: number, max: number) {\n\treturn Math.min(Math.max(value, min), max);\n}\n\nfunction round(value: number) {\n\treturn Math.round(value * 100) / 100;\n}\n\nfunction mod(value: number, size: number) {\n\treturn ((value % size) + size) % size;\n}\n\n/** `value` wrapped into `[-size / 2, size / 2)`. */\nfunction wrap(value: number, size: number) {\n\treturn mod(value + size / 2, size) - size / 2;\n}\n\n/** Eases `over` toward `limit`, never reaching it. */\nfunction band(over: number, limit: number) {\n\treturn (over * limit) / (Math.abs(over) + limit);\n}\n\nfunction cssLength(value: LiquidGlassCarouselLength) {\n\treturn typeof value === \"number\" ? `${value}px` : value;\n}\n\nfunction pad(value: number) {\n\treturn String(value).padStart(2, \"0\");\n}\n\n/**\n * SVG filters on HTML are fast and exact in Chromium. Safari draws them\n * unreliably on HTML and Firefox rasterises them on the CPU, so both get the\n * stretch, flare, and blur fallback instead.\n */\nfunction supportsSvgMelt() {\n\tif (typeof navigator === \"undefined\") return false;\n\tconst brands = (\n\t\tnavigator as Navigator & {\n\t\t\tuserAgentData?: { brands?: Array<{ brand: string }> };\n\t\t}\n\t).userAgentData?.brands;\n\treturn brands?.some((entry) => entry.brand === \"Chromium\") ?? false;\n}\n\n/**\n * The edge fade as a mask. Smoothstep-eased over many stops, so it has no\n * crease where it starts and dark cards dissolve into the page instead of\n * passing through a band of grey.\n */\nfunction edgeMask(orientation: Orientation) {\n\tconst steps = 8;\n\tconst ramp = Array.from({ length: steps + 1 }, (_, step) => {\n\t\tconst t = step / steps;\n\t\treturn {\n\t\t\talpha: round(t * t * (3 - 2 * t)),\n\t\t\tat: round(t * EDGE_FADE * 100),\n\t\t};\n\t});\n\tconst stops = [\n\t\t...ramp.map(({ alpha, at }) => `rgb(0 0 0 / ${alpha}) ${at}%`),\n\t\t...ramp\n\t\t\t.reverse()\n\t\t\t.map(({ alpha, at }) => `rgb(0 0 0 / ${alpha}) ${100 - at}%`),\n\t];\n\tconst to = orientation === \"vertical\" ? \"bottom\" : \"right\";\n\treturn `linear-gradient(to ${to}, ${stops.join(\", \")})`;\n}\n\nconst mapCache = new Map<string, string>();\n\n/**\n * How far a pixel `depth` into a zone (0 inner edge, 1 frame edge) samples\n * back toward the centre, as a share of the pull at the edge. Its slope is the\n * magnification: 0 at the inner edge, easing up to `MAGNIFY` over `RAMP`.\n */\nfunction easedPull(depth: number) {\n\tconst t = Math.min(depth / RAMP, 1);\n\tconst eased = RAMP * (t ** 3 - t ** 4 / 2) + Math.max(depth - RAMP, 0);\n\treturn eased / (1 - RAMP / 2);\n}\n\n/** Pull at the frame's edge, in px, for a zone `zone` px deep. */\nfunction lensPull(zone: number) {\n\treturn zone * MAGNIFY * (1 - RAMP / 2);\n}\n\n/** Scale shared by the three channel maps: room for the furthest pull. */\nfunction lensScale(zone: number) {\n\treturn 2 * lensPull(zone) * (1 + DISPERSION_ALONG);\n}\n\n/** How much more (above 0) or less each channel bends than green. */\nconst SPREAD: Record<Channel, number> = { r: -1, g: 0, b: 1 };\n\n/**\n * The lens as a displacement map over the filter's band, for one colour\n * channel. Red moves pixels across the axis and green along it, both centred\n * on 0.5 (no movement). In each melt zone, rows sample back toward the centre\n * by up to the pull at the edge, so the content nearest the edge is magnified\n * into streaks and the content that physically reaches the edge is never\n * drawn. Columns sample toward the axis, so cards widen toward the edge.\n * Blue carries the weight of the streak blur.\n */\nfunction lensMap(\n\torientation: Orientation,\n\tlength: number,\n\tband: number,\n\tzone: number,\n\tslideCross: number,\n\tchannel: Channel,\n) {\n\tconst sizes = [length, band, zone, slideCross].map(Math.round).join(\"-\");\n\tconst key = `${orientation}-${sizes}-${channel}`;\n\tconst cached = mapCache.get(key);\n\tif (cached) return cached;\n\tconst vertical = orientation === \"vertical\";\n\tconst width = vertical ? MAP_CROSS : MAP_LENGTH;\n\tconst height = vertical ? MAP_LENGTH : MAP_CROSS;\n\tconst canvas = document.createElement(\"canvas\");\n\tcanvas.width = width;\n\tcanvas.height = height;\n\tconst context = canvas.getContext(\"2d\");\n\tif (!context) return \"\";\n\tconst image = context.createImageData(width, height);\n\tconst scale = lensScale(zone);\n\tconst edgePull = lensPull(zone) * (1 + SPREAD[channel] * DISPERSION_ALONG);\n\t// A slide flared by `f` is `1 / (1 - f)` times as wide at the edge. Where\n\t// the band is narrower than that, the flare is eased off to fit, so the\n\t// drip is never cut off by the frame.\n\tconst room =\n\t\t(1 - slideCross / (band - BAND_MARGIN * 2)) / (1 + DISPERSION_ACROSS);\n\tconst flare =\n\t\tclamp(room, 0, FLARE) * (1 + SPREAD[channel] * DISPERSION_ACROSS);\n\t// Past this distance from the axis the flare stays flat; it only moves page.\n\tconst reach = slideCross * 0.75;\n\tfor (let y = 0; y < height; y++) {\n\t\tfor (let x = 0; x < width; x++) {\n\t\t\tconst along = ((vertical ? y : x) + 0.5) / (vertical ? height : width);\n\t\t\tconst across = ((vertical ? x : y) + 0.5) / (vertical ? width : height);\n\t\t\tconst at = along * length;\n\t\t\t// 0 at the zone's inner edge, 1 at the frame's edge; sign is the end.\n\t\t\tconst depth =\n\t\t\t\tat < zone\n\t\t\t\t\t? 1 - at / zone\n\t\t\t\t\t: at > length - zone\n\t\t\t\t\t\t? (at - (length - zone)) / zone\n\t\t\t\t\t\t: 0;\n\t\t\tconst end = at > length / 2 ? 1 : -1;\n\t\t\tconst pull = easedPull(depth);\n\t\t\tconst axis = 0.5 - (end * pull * edgePull) / scale;\n\t\t\tconst offAxis = clamp((across - 0.5) * band, -reach, reach);\n\t\t\tconst side = clamp(0.5 - (flare * pull * offAxis) / scale, 0, 1);\n\t\t\tconst index = (y * width + x) * 4;\n\t\t\timage.data[index] = Math.round((vertical ? side : axis) * 255);\n\t\t\timage.data[index + 1] = Math.round((vertical ? axis : side) * 255);\n\t\t\t// Blue: how much of the streak blur shows. It eases out, so it is\n\t\t\t// already there where rows start to magnify and step the flared rims.\n\t\t\timage.data[index + 2] = Math.round((1 - (1 - depth) ** 2) * 255);\n\t\t\timage.data[index + 3] = 255;\n\t\t}\n\t}\n\tcontext.putImageData(image, 0, 0);\n\tconst url = canvas.toDataURL(\"image/png\");\n\tmapCache.set(key, url);\n\treturn url;\n}\n\n/** Keeps one channel of an image and makes it opaque. */\nconst CHANNEL = {\n\tr: \"1 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0 1\",\n\tg: \"0 0 0 0 0  0 1 0 0 0  0 0 0 0 0  0 0 0 0 1\",\n\tb: \"0 0 0 0 0  0 0 0 0 0  0 0 1 0 0  0 0 0 0 1\",\n} as const;\n\nconst CHANNELS = [\"r\", \"g\", \"b\"] as const;\n\n/** Moves a map's blue channel into alpha, as a mask for the streak blur. */\nconst WEIGHT = \"0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 1 0 0\";\n\n/**\n * The lens filter for the track. Each colour channel is displaced through its\n * own map and laid over the page colour, so where one channel's card reaches\n * past the others the page shows through in the rest: a thin rainbow fringe.\n * Only `FRINGE` of it is kept over the undispersed (green) pass, so the rim is\n * a faint tint. The channels are joined under the union of their shapes and\n * blurred along the axis, more toward the edge, so magnified rows read as\n * streaks. The band between the zones is the untouched source, so the centred\n * card is never resampled.\n */\nfunction LensFilter({\n\tid,\n\tlens,\n\torientation,\n}: {\n\tid: string;\n\tlens: Lens;\n\torientation: Orientation;\n}) {\n\tconst vertical = orientation === \"vertical\";\n\tconst middle = Math.max(lens.length - lens.zone * 2, 0);\n\tconst inset = round((lens.cross - lens.band) / 2);\n\treturn (\n\t\t<filter\n\t\t\tid={id}\n\t\t\tfilterUnits=\"userSpaceOnUse\"\n\t\t\tx={vertical ? inset : 0}\n\t\t\ty={vertical ? 0 : inset}\n\t\t\twidth={vertical ? lens.band : lens.length}\n\t\t\theight={vertical ? lens.length : lens.band}\n\t\t\tcolorInterpolationFilters=\"sRGB\"\n\t\t>\n\t\t\t<feFlood\n\t\t\t\tstyle={{ floodColor: \"var(--lgc-surface, var(--background, #fff))\" }}\n\t\t\t\tresult=\"surface\"\n\t\t\t/>\n\t\t\t{CHANNELS.map((channel) => (\n\t\t\t\t<feImage\n\t\t\t\t\tkey={`${channel}-map`}\n\t\t\t\t\thref={lens.maps[channel]}\n\t\t\t\t\tpreserveAspectRatio=\"none\"\n\t\t\t\t\tresult={`${channel}-map`}\n\t\t\t\t/>\n\t\t\t))}\n\t\t\t{CHANNELS.map((channel) => (\n\t\t\t\t<feDisplacementMap\n\t\t\t\t\tkey={`${channel}-moved`}\n\t\t\t\t\tin=\"SourceGraphic\"\n\t\t\t\t\tin2={`${channel}-map`}\n\t\t\t\t\tscale={round(lens.scale)}\n\t\t\t\t\txChannelSelector=\"R\"\n\t\t\t\t\tyChannelSelector=\"G\"\n\t\t\t\t\tresult={`${channel}-moved`}\n\t\t\t\t/>\n\t\t\t))}\n\t\t\t{CHANNELS.map((channel) => (\n\t\t\t\t<feComposite\n\t\t\t\t\tkey={`${channel}-flat`}\n\t\t\t\t\tin={`${channel}-moved`}\n\t\t\t\t\tin2=\"surface\"\n\t\t\t\t\toperator=\"over\"\n\t\t\t\t\tresult={`${channel}-flat`}\n\t\t\t\t/>\n\t\t\t))}\n\t\t\t{CHANNELS.map((channel) => (\n\t\t\t\t<feColorMatrix\n\t\t\t\t\tkey={channel}\n\t\t\t\t\tin={`${channel}-flat`}\n\t\t\t\t\tvalues={CHANNEL[channel]}\n\t\t\t\t\tresult={channel}\n\t\t\t\t/>\n\t\t\t))}\n\t\t\t<feComposite\n\t\t\t\tin=\"r\"\n\t\t\t\tin2=\"g\"\n\t\t\t\toperator=\"arithmetic\"\n\t\t\t\tk2={1}\n\t\t\t\tk3={1}\n\t\t\t\tresult=\"rg\"\n\t\t\t/>\n\t\t\t<feComposite\n\t\t\t\tin=\"rg\"\n\t\t\t\tin2=\"b\"\n\t\t\t\toperator=\"arithmetic\"\n\t\t\t\tk2={1}\n\t\t\t\tk3={1}\n\t\t\t\tresult=\"rgb\"\n\t\t\t/>\n\t\t\t<feComposite\n\t\t\t\tin=\"r-moved\"\n\t\t\t\tin2=\"g-moved\"\n\t\t\t\toperator=\"over\"\n\t\t\t\tresult=\"rg-shape\"\n\t\t\t/>\n\t\t\t<feComposite in=\"b-moved\" in2=\"rg-shape\" operator=\"over\" result=\"shape\" />\n\t\t\t<feComposite\n\t\t\t\tin=\"rgb\"\n\t\t\t\tin2=\"g-flat\"\n\t\t\t\toperator=\"arithmetic\"\n\t\t\t\tk2={FRINGE}\n\t\t\t\tk3={1 - FRINGE}\n\t\t\t\tresult=\"mixed\"\n\t\t\t/>\n\t\t\t<feComposite in=\"mixed\" in2=\"shape\" operator=\"in\" result=\"lens\" />\n\t\t\t<feColorMatrix in=\"g-map\" values={WEIGHT} result=\"weight\" />\n\t\t\t<feGaussianBlur\n\t\t\t\tin=\"lens\"\n\t\t\t\tstdDeviation={\n\t\t\t\t\tvertical\n\t\t\t\t\t\t? `${FRINGE_BLUR} ${STREAK_BLUR}`\n\t\t\t\t\t\t: `${STREAK_BLUR} ${FRINGE_BLUR}`\n\t\t\t\t}\n\t\t\t\tresult=\"blurred\"\n\t\t\t/>\n\t\t\t<feComposite in=\"blurred\" in2=\"weight\" operator=\"in\" result=\"soft\" />\n\t\t\t<feComposite in=\"lens\" in2=\"weight\" operator=\"out\" result=\"sharp\" />\n\t\t\t<feComposite\n\t\t\t\tin=\"soft\"\n\t\t\t\tin2=\"sharp\"\n\t\t\t\toperator=\"arithmetic\"\n\t\t\t\tk2={1}\n\t\t\t\tk3={1}\n\t\t\t\tresult=\"streaks\"\n\t\t\t/>\n\t\t\t<feOffset\n\t\t\t\tin=\"SourceGraphic\"\n\t\t\t\tx={vertical ? inset : round(lens.zone)}\n\t\t\t\ty={vertical ? round(lens.zone) : inset}\n\t\t\t\twidth={vertical ? lens.band : round(middle)}\n\t\t\t\theight={vertical ? round(middle) : lens.band}\n\t\t\t\tresult=\"middle\"\n\t\t\t/>\n\t\t\t<feMerge>\n\t\t\t\t<feMergeNode in=\"streaks\" />\n\t\t\t\t<feMergeNode in=\"middle\" />\n\t\t\t</feMerge>\n\t\t</filter>\n\t);\n}\n\nexport function LiquidGlassCarousel({\n\tchildren,\n\t\"aria-label\": ariaLabel,\n\torientation = \"vertical\",\n\tindex: indexProp,\n\tdefaultIndex = 0,\n\tonIndexChange,\n\tloop: loopProp = true,\n\tautoplay = false,\n\tmeltZone = 0.28,\n\tmelt = \"auto\",\n\tslideSize = DEFAULT_SLIDE_SIZE,\n\tgap = DEFAULT_GAP,\n\tsound = true,\n\thaptics = true,\n\tref,\n\tclassName,\n\tstyle,\n\t...props\n}: LiquidGlassCarouselProps) {\n\tconst slides: ReactNode[] = [];\n\tconst extras: ReactNode[] = [];\n\tfor (const child of Children.toArray(children)) {\n\t\tconst slide =\n\t\t\ttypeof child === \"object\" &&\n\t\t\tchild !== null &&\n\t\t\t\"type\" in child &&\n\t\t\tchild.type === LiquidGlassCarouselSlide;\n\t\t(slide ? slides : extras).push(child);\n\t}\n\tconst count = slides.length;\n\tconst loop = loopProp && count > 1;\n\tconst vertical = orientation === \"vertical\";\n\n\tconst reducedMotion = useReducedMotion() ?? false;\n\tconst { trigger: haptic } = useWebHaptics();\n\t// Sound stays on under reduced motion; only movement is reduced.\n\tconst { click: playTick } = useTiks({\n\t\ttheme: TICK_SOUND,\n\t\trespectReducedMotion: false,\n\t});\n\n\tconst ids = useId().replace(/[^\\w-]/g, \"\");\n\tconst lensId = `lgc-${ids}-lens`;\n\n\tconst startIndex = clamp(\n\t\tMath.round(indexProp ?? defaultIndex),\n\t\t0,\n\t\tMath.max(count - 1, 0),\n\t);\n\tconst [internalIndex, setInternalIndex] = useState(startIndex);\n\tconst controlled = indexProp !== undefined;\n\tconst index = clamp(\n\t\tcontrolled ? Math.round(indexProp) : internalIndex,\n\t\t0,\n\t\tMath.max(count - 1, 0),\n\t);\n\tconst [, rerender] = useReducer((value: number) => value + 1, 0);\n\t/** Slides drawn either side of the centre; sets how many clones a loop needs. */\n\tconst [reach, setReach] = useState(2);\n\t/** Slot at the centre, or heading there. Slots near it are the real slides. */\n\tconst [anchor, setAnchor] = useState(startIndex);\n\t/** Bumped on every move, so autoplay times its next step from it. */\n\tconst [moves, bumpMoves] = useReducer((value: number) => value + 1, 0);\n\tconst [meltMode, setMeltMode] = useState<MeltMode>(\"off\");\n\tconst [lens, setLens] = useState<Lens | null>(null);\n\tconst [announcement, setAnnouncement] = useState(\"\");\n\tconst [playing, setPlayingState] = useState(true);\n\tconst [hovered, setHovered] = useState(false);\n\tconst [focused, setFocused] = useState(false);\n\tconst [pressed, setPressed] = useState(false);\n\tconst [hidden, setHidden] = useState(false);\n\tconst [controlsCount, setControlsCount] = useState(0);\n\n\t// A loop draws enough copies that its seam is always off-screen.\n\tconst minimumSlots = reach * 2 + 1;\n\tconst slotCount =\n\t\tloop && count < minimumSlots\n\t\t\t? count * Math.ceil(minimumSlots / count)\n\t\t\t: count;\n\n\tconst position = useMotionValue(startIndex);\n\tconst rootRef = useRef<HTMLDivElement>(null);\n\tconst viewportRef = useRef<HTMLDivElement>(null);\n\tconst trackRef = useRef<HTMLDivElement>(null);\n\tconst gapRef = useRef<HTMLSpanElement>(null);\n\tconst slotRefs = useRef<Array<HTMLDivElement | null>>([]);\n\tconst paintedRef = useRef<Array<Painted | null>>([]);\n\tconst geometryRef = useRef<Geometry | null>(null);\n\tconst meltRef = useRef<MeltMode>(\"off\");\n\tconst animationRef = useRef<AnimationPlaybackControls | null>(null);\n\tconst dragRef = useRef<Drag | null>(null);\n\t/** Where the carousel is heading, in slides; unbounded when looping. */\n\tconst targetRef = useRef(startIndex);\n\t/** Index of the slide at `targetRef`. */\n\tconst indexRef = useRef(startIndex);\n\t/** The last slide that settled, so a tick plays only for a new one. */\n\tconst settledRef = useRef(startIndex);\n\t/** What started the move in flight. */\n\tconst sourceRef = useRef<Source>(\"prop\");\n\t/** The move in flight came from a touch, so it may buzz. */\n\tconst touchRef = useRef(false);\n\tconst suppressClickRef = useRef(false);\n\tconst wheelRef = useRef({ total: 0, locked: false, timer: 0 });\n\tconst userToggledRef = useRef(false);\n\n\t// Event handlers and the render loop read the latest props through refs.\n\tconst latest = useRef({\n\t\tcount,\n\t\tloop,\n\t\tslotCount,\n\t\tindex,\n\t\tcontrolled,\n\t\tindexProp,\n\t\tonIndexChange,\n\t\tsound,\n\t\thaptics,\n\t\treducedMotion,\n\t\tmeltZone,\n\t\tvertical,\n\t});\n\tuseLayoutEffect(() => {\n\t\tlatest.current = {\n\t\t\tcount,\n\t\t\tloop,\n\t\t\tslotCount,\n\t\t\tindex,\n\t\t\tcontrolled,\n\t\t\tindexProp,\n\t\t\tonIndexChange,\n\t\t\tsound,\n\t\t\thaptics,\n\t\t\treducedMotion,\n\t\t\tmeltZone,\n\t\t\tvertical,\n\t\t};\n\t});\n\n\tconst silent = () =>\n\t\ttypeof document !== \"undefined\" && document.visibilityState === \"hidden\";\n\n\t/** Draws every slot for the current position, writing only what changed. */\n\tconst paint = () => {\n\t\tconst geometry = geometryRef.current;\n\t\tif (!geometry) return;\n\t\tconst { count, loop, slotCount, vertical } = latest.current;\n\t\tif (count === 0) return;\n\t\tconst value = position.get();\n\t\tconst mode = meltRef.current;\n\t\tconst moving = !!dragRef.current?.moved || !!animationRef.current;\n\t\tconst half = geometry.length / 2;\n\t\tfor (let slot = 0; slot < slotCount; slot++) {\n\t\t\tconst element = slotRefs.current[slot];\n\t\t\tif (!element) continue;\n\t\t\tconst offset =\n\t\t\t\t(loop ? wrap(slot - value, slotCount) : slot - value) * geometry.pitch;\n\t\t\tconst distance = Math.abs(offset);\n\t\t\t// Hidden once the end facing the centre has left the frame.\n\t\t\tconst visible = distance - geometry.slide / 2 < half + 1;\n\t\t\tlet next: Painted;\n\t\t\tif (!visible) {\n\t\t\t\tnext = {\n\t\t\t\t\tvisible,\n\t\t\t\t\ttransform: \"\",\n\t\t\t\t\torigin: \"\",\n\t\t\t\t\tfilter: \"\",\n\t\t\t\t\twillChange: \"\",\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\t// How far the slide's outer end has sunk into the zone, eased in so\n\t\t\t\t// a slide that only grazes it stays crisp.\n\t\t\t\tconst edge =\n\t\t\t\t\tclamp(\n\t\t\t\t\t\t(distance + geometry.slide / 2 - (half - geometry.zone)) /\n\t\t\t\t\t\t\t(geometry.zone + geometry.slide / 2),\n\t\t\t\t\t\t0,\n\t\t\t\t\t\t1,\n\t\t\t\t\t) ** 2;\n\t\t\t\t// The lens draws the melt over the whole track; the fallback melts\n\t\t\t\t// each slide on its own.\n\t\t\t\tconst melting = mode === \"css\" && edge > 0;\n\t\t\t\t// Screen direction of the slot from the centre: 1 is down or right.\n\t\t\t\tconst side = offset * geometry.sign >= 0 ? 1 : -1;\n\t\t\t\tconst shift = round(offset * geometry.sign);\n\t\t\t\tconst stretch = melting ? round(1 + FALLBACK_STRETCH * edge) : 1;\n\t\t\t\tconst flare = melting ? round(1 + FALLBACK_FLARE * edge) : 1;\n\t\t\t\tconst move = vertical\n\t\t\t\t\t? `translate3d(0, ${shift}px, 0)`\n\t\t\t\t\t: `translate3d(${shift}px, 0, 0)`;\n\t\t\t\tconst scale =\n\t\t\t\t\tstretch === 1 && flare === 1\n\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t: vertical\n\t\t\t\t\t\t\t? ` scale(${flare}, ${stretch})`\n\t\t\t\t\t\t\t: ` scale(${stretch}, ${flare})`;\n\t\t\t\tconst blur = melting ? round(FALLBACK_BLUR * edge) : 0;\n\t\t\t\tconst filter = blur > 0 ? `blur(${blur}px)` : \"\";\n\t\t\t\tnext = {\n\t\t\t\t\tvisible,\n\t\t\t\t\ttransform: move + scale,\n\t\t\t\t\t// Stretch away from the centre, so the gap stays put.\n\t\t\t\t\torigin: vertical\n\t\t\t\t\t\t? side > 0\n\t\t\t\t\t\t\t? \"50% 0%\"\n\t\t\t\t\t\t\t: \"50% 100%\"\n\t\t\t\t\t\t: side > 0\n\t\t\t\t\t\t\t? \"0% 50%\"\n\t\t\t\t\t\t\t: \"100% 50%\",\n\t\t\t\t\tfilter,\n\t\t\t\t\twillChange: moving && mode !== \"filter\" ? \"transform\" : \"\",\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst painted = paintedRef.current[slot];\n\t\t\tconst style = element.style;\n\t\t\tif (painted?.visible !== next.visible) {\n\t\t\t\tstyle.visibility = next.visible ? \"\" : \"hidden\";\n\t\t\t}\n\t\t\tif (painted?.transform !== next.transform && next.visible) {\n\t\t\t\tstyle.transform = next.transform;\n\t\t\t}\n\t\t\tif (painted?.origin !== next.origin && next.visible) {\n\t\t\t\tstyle.transformOrigin = next.origin;\n\t\t\t}\n\t\t\tif (painted?.filter !== next.filter) style.filter = next.filter;\n\t\t\tif (painted?.willChange !== next.willChange) {\n\t\t\t\tstyle.willChange = next.willChange;\n\t\t\t}\n\t\t\tpaintedRef.current[slot] = next;\n\t\t}\n\t};\n\n\t// One paint per frame, however many times the position changed in it.\n\tconst paintRef = useRef(paint);\n\tuseLayoutEffect(() => {\n\t\tpaintRef.current = paint;\n\t});\n\tconst scheduledRef = useRef(false);\n\tconst renderRef = useRef(() => {\n\t\tscheduledRef.current = false;\n\t\tpaintRef.current();\n\t});\n\tconst schedule = useCallback(() => {\n\t\tif (scheduledRef.current) return;\n\t\tscheduledRef.current = true;\n\t\tframe.render(renderRef.current);\n\t}, []);\n\n\tuseEffect(() => {\n\t\tconst stop = position.on(\"change\", schedule);\n\t\treturn () => {\n\t\t\tstop();\n\t\t\tcancelFrame(renderRef.current);\n\t\t\tscheduledRef.current = false;\n\t\t\tanimationRef.current?.stop();\n\t\t\twindow.clearTimeout(wheelRef.current.timer);\n\t\t};\n\t}, [position, schedule]);\n\n\t/** Reads the sizes the CSS settled on, and repaints. */\n\tconst measure = useCallback(() => {\n\t\tconst viewport = viewportRef.current;\n\t\tconst slot = slotRefs.current.find(Boolean);\n\t\tif (!viewport || !slot) return;\n\t\tconst { vertical, meltZone } = latest.current;\n\t\tconst length = vertical ? viewport.offsetHeight : viewport.offsetWidth;\n\t\tconst slide = vertical ? slot.offsetHeight : slot.offsetWidth;\n\t\tconst cross = vertical ? slot.offsetWidth : slot.offsetHeight;\n\t\tconst gapPx = gapRef.current?.offsetWidth ?? 0;\n\t\tif (!length || !slide) return;\n\t\tconst rtl = getComputedStyle(viewport).direction === \"rtl\";\n\t\tconst pitch = slide + gapPx;\n\t\tgeometryRef.current = {\n\t\t\tlength,\n\t\t\tslide,\n\t\t\tcross,\n\t\t\tpitch,\n\t\t\tzone: clamp(meltZone, 0, 0.5) * length,\n\t\t\tsign: !vertical && rtl ? -1 : 1,\n\t\t};\n\t\t// Slides reach the frame's edge with their stretched outer end.\n\t\tsetReach(\n\t\t\tMath.max(\n\t\t\t\t1,\n\t\t\t\tMath.ceil((length / 2 + slide * (0.5 + FALLBACK_STRETCH)) / pitch),\n\t\t\t),\n\t\t);\n\t\tif (meltRef.current === \"filter\") {\n\t\t\tconst zone = geometryRef.current.zone;\n\t\t\tconst across = vertical ? viewport.offsetWidth : viewport.offsetHeight;\n\t\t\tconst band = Math.min(\n\t\t\t\tacross,\n\t\t\t\tMath.ceil(\n\t\t\t\t\tcross / (1 - FLARE * (1 + DISPERSION_ACROSS)) + BAND_MARGIN * 2,\n\t\t\t\t),\n\t\t\t);\n\t\t\tconst maps = {\n\t\t\t\tr: lensMap(orientation, length, band, zone, cross, \"r\"),\n\t\t\t\tg: lensMap(orientation, length, band, zone, cross, \"g\"),\n\t\t\t\tb: lensMap(orientation, length, band, zone, cross, \"b\"),\n\t\t\t};\n\t\t\tsetLens((current) =>\n\t\t\t\tcurrent?.maps.g === maps.g && current.cross === across\n\t\t\t\t\t? current\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tmaps,\n\t\t\t\t\t\t\tlength,\n\t\t\t\t\t\t\tcross: across,\n\t\t\t\t\t\t\tband,\n\t\t\t\t\t\t\tzone,\n\t\t\t\t\t\t\tscale: lensScale(zone),\n\t\t\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\tpaintedRef.current = [];\n\t\tpaintRef.current();\n\t}, [orientation]);\n\n\t// Melt mode: SVG filters where they are fast, a CSS fallback elsewhere, and\n\t// none with reduced motion or `melt=\"off\"`.\n\tuseLayoutEffect(() => {\n\t\tconst mode: MeltMode =\n\t\t\tmelt === \"off\" || reducedMotion\n\t\t\t\t? \"off\"\n\t\t\t\t: supportsSvgMelt()\n\t\t\t\t\t? \"filter\"\n\t\t\t\t\t: \"css\";\n\t\tmeltRef.current = mode;\n\t\tsetMeltMode(mode);\n\t\tmeasure();\n\t}, [melt, reducedMotion, measure]);\n\n\t// biome-ignore lint/correctness/useExhaustiveDependencies: re-observe when the loop's clones change the first slot\n\tuseLayoutEffect(() => {\n\t\tconst viewport = viewportRef.current;\n\t\tif (!viewport) return;\n\t\tmeasure();\n\t\tconst observer = new ResizeObserver(() => measure());\n\t\tobserver.observe(viewport);\n\t\tconst slot = slotRefs.current.find(Boolean);\n\t\tif (slot) observer.observe(slot);\n\t\treturn () => observer.disconnect();\n\t}, [measure, slotCount]);\n\n\t// New slots (a loop's clones) are painted before the browser shows them.\n\t// biome-ignore lint/correctness/useExhaustiveDependencies: repaint when these change\n\tuseLayoutEffect(() => {\n\t\tpaintedRef.current = [];\n\t\tpaintRef.current();\n\t}, [slotCount, meltMode, meltZone]);\n\n\t/** Ends a move: normalises a loop's position and plays the landing cue. */\n\tconst settle = () => {\n\t\tanimationRef.current = null;\n\t\tconst { loop, slotCount, sound, haptics } = latest.current;\n\t\tif (loop) {\n\t\t\t// Whole loops change nothing on screen, so drop them.\n\t\t\tconst turns = Math.floor(targetRef.current / slotCount) * slotCount;\n\t\t\tif (turns !== 0) {\n\t\t\t\ttargetRef.current -= turns;\n\t\t\t\tposition.jump(position.get() - turns);\n\t\t\t}\n\t\t}\n\t\tconst landed = indexRef.current;\n\t\tif (landed !== settledRef.current) {\n\t\t\tsettledRef.current = landed;\n\t\t\tif (sourceRef.current === \"user\" && !silent()) {\n\t\t\t\tif (sound) playTick();\n\t\t\t\tif (haptics && touchRef.current) void haptic(\"selection\");\n\t\t\t}\n\t\t}\n\t\tschedule();\n\t};\n\n\t/** Glides, or under reduced motion fades, to `target`, carrying `velocity`. */\n\tconst run = (target: number, velocity?: number) => {\n\t\tanimationRef.current?.stop();\n\t\tif (latest.current.reducedMotion) {\n\t\t\tanimationRef.current = null;\n\t\t\tposition.jump(target);\n\t\t\ttrackRef.current?.animate([{ opacity: 0.2 }, { opacity: 1 }], {\n\t\t\t\tduration: FADE_MS,\n\t\t\t\teasing: \"ease-out\",\n\t\t\t});\n\t\t\tsettle();\n\t\t\treturn;\n\t\t}\n\t\tconst controls = animate(position, target, {\n\t\t\t...snapSpring,\n\t\t\tvelocity: velocity ?? position.getVelocity(),\n\t\t\trestDelta: 0.0005,\n\t\t\trestSpeed: 0.005,\n\t\t\tonComplete: () => {\n\t\t\t\tif (animationRef.current === controls) settle();\n\t\t\t},\n\t\t});\n\t\tanimationRef.current = controls;\n\t\tschedule();\n\t};\n\n\t/** Heads for `target` (in slides) and publishes the new index. */\n\tconst moveTo = (target: number, source: Source, velocity?: number) => {\n\t\tconst { count, loop, slotCount, controlled } = latest.current;\n\t\tif (count < 2) return;\n\t\tconst next = loop ? target : clamp(target, 0, count - 1);\n\t\tconst nextIndex = mod(next, count);\n\t\ttargetRef.current = next;\n\t\tsourceRef.current = source;\n\t\tconst changed = nextIndex !== indexRef.current;\n\t\tindexRef.current = nextIndex;\n\t\tsetAnchor(loop ? mod(next, slotCount) : next);\n\t\tbumpMoves();\n\t\tif (changed) {\n\t\t\tif (source !== \"prop\") {\n\t\t\t\tlatest.current.index = nextIndex;\n\t\t\t\tif (controlled) rerender();\n\t\t\t\telse setInternalIndex(nextIndex);\n\t\t\t\tlatest.current.onIndexChange?.(nextIndex);\n\t\t\t} else if (!controlled) {\n\t\t\t\tsetInternalIndex(nextIndex);\n\t\t\t}\n\t\t\tif (source === \"user\") {\n\t\t\t\tsetAnnouncement(`Slide ${nextIndex + 1} of ${count}`);\n\t\t\t}\n\t\t}\n\t\t// A long jump skips ahead first, so only the last two slides glide by.\n\t\tconst from = position.get();\n\t\tif (\n\t\t\t!latest.current.reducedMotion &&\n\t\t\tMath.abs(next - from) > MAX_GLIDE &&\n\t\t\t!dragRef.current?.moved\n\t\t) {\n\t\t\tanimationRef.current?.stop();\n\t\t\tposition.jump(next - Math.sign(next - from) * 2);\n\t\t}\n\t\trun(next, velocity);\n\t};\n\n\t/** Moves `by` slides from where the carousel is heading. */\n\tconst step = (by: number, source: Source = \"user\") => {\n\t\tconst { count, loop } = latest.current;\n\t\tif (count < 2) return;\n\t\tlet target = targetRef.current + by;\n\t\tif (!loop) target = clamp(target, 0, count - 1);\n\t\t// Fast key repeats queue up, but never run far ahead of the screen.\n\t\tif (Math.abs(target - position.get()) > MAX_QUEUE) return;\n\t\tif (source === \"user\") touchRef.current = false;\n\t\tmoveTo(target, source);\n\t};\n\n\t/** Moves to slide `to`, the short way round when looping. */\n\tconst goTo = (to: number, source: Source = \"user\") => {\n\t\tconst { count, loop } = latest.current;\n\t\tif (count < 2) return;\n\t\tconst nextIndex = clamp(Math.round(to), 0, count - 1);\n\t\tconst delta = loop\n\t\t\t? wrap(nextIndex - indexRef.current, count)\n\t\t\t: nextIndex - indexRef.current;\n\t\tif (source === \"user\") touchRef.current = false;\n\t\tmoveTo(targetRef.current + delta, source);\n\t};\n\n\tconst stepRef = useRef(step);\n\tconst goToRef = useRef(goTo);\n\tuseLayoutEffect(() => {\n\t\tstepRef.current = step;\n\t\tgoToRef.current = goTo;\n\t});\n\n\tuseImperativeHandle(\n\t\tref,\n\t\t() => ({\n\t\t\tnext: () => stepRef.current(1, \"api\"),\n\t\t\tprev: () => stepRef.current(-1, \"api\"),\n\t\t\tgoTo: (to: number) => goToRef.current(to, \"api\"),\n\t\t}),\n\t\t[],\n\t);\n\n\t// A parent changing `index` glides there silently. A parent that keeps the\n\t// old index after `onIndexChange` sends the carousel back.\n\tuseLayoutEffect(() => {\n\t\tif (!controlled || dragRef.current?.moved) return;\n\t\tif (index === indexRef.current) return;\n\t\tgoToRef.current(index, \"prop\");\n\t});\n\n\t// Autoplay: pauses on hover, keyboard focus, a press, a hidden tab, and the\n\t// pause button, and starts paused under reduced motion.\n\tuseEffect(() => {\n\t\tif (reducedMotion && !userToggledRef.current) setPlayingState(false);\n\t}, [reducedMotion]);\n\n\tuseEffect(() => {\n\t\tconst update = () => setHidden(document.visibilityState === \"hidden\");\n\t\tupdate();\n\t\tdocument.addEventListener(\"visibilitychange\", update);\n\t\treturn () => document.removeEventListener(\"visibilitychange\", update);\n\t}, []);\n\n\tconst autoplayOn = typeof autoplay === \"number\" && autoplay > 0 && count > 1;\n\tconst running =\n\t\tautoplayOn && playing && !hovered && !focused && !pressed && !hidden;\n\n\tuseEffect(() => {\n\t\tif (!running || typeof autoplay !== \"number\") return;\n\t\t// `moves` restarts the wait after every step, whoever made it.\n\t\tvoid moves;\n\t\tconst timer = window.setTimeout(() => {\n\t\t\tif (dragRef.current) return;\n\t\t\tstepRef.current(1, \"auto\");\n\t\t}, autoplay);\n\t\treturn () => window.clearTimeout(timer);\n\t}, [running, autoplay, moves]);\n\n\tconst setPlaying = useCallback((next: boolean) => {\n\t\tuserToggledRef.current = true;\n\t\tsetPlayingState(next);\n\t}, []);\n\n\t// Wheel and trackpad: one slide per gesture. At a closed end the page\n\t// scrolls on as normal.\n\tuseEffect(() => {\n\t\tconst viewport = viewportRef.current;\n\t\tif (!viewport) return;\n\t\tconst onWheel = (event: WheelEvent) => {\n\t\t\tconst { count, loop, vertical } = latest.current;\n\t\t\tif (count < 2 || event.ctrlKey) return;\n\t\t\tconst unit = event.deltaMode === 1 ? 16 : event.deltaMode === 2 ? 400 : 1;\n\t\t\tconst raw = (vertical ? event.deltaY : event.deltaX) * unit;\n\t\t\tconst cross = (vertical ? event.deltaX : event.deltaY) * unit;\n\t\t\tif (Math.abs(raw) <= Math.abs(cross)) return;\n\t\t\tconst sign = geometryRef.current?.sign ?? 1;\n\t\t\tconst direction = Math.sign(raw) * sign;\n\t\t\tconst wheel = wheelRef.current;\n\t\t\tconst at = targetRef.current;\n\t\t\tconst blocked =\n\t\t\t\t!loop && (direction > 0 ? at >= count - 1 : at <= 0) && !wheel.locked;\n\t\t\tif (blocked) return;\n\t\t\tevent.preventDefault();\n\t\t\twindow.clearTimeout(wheel.timer);\n\t\t\twheel.timer = window.setTimeout(() => {\n\t\t\t\twheel.total = 0;\n\t\t\t\twheel.locked = false;\n\t\t\t}, WHEEL_IDLE);\n\t\t\tif (wheel.locked) return;\n\t\t\twheel.total += raw;\n\t\t\tif (Math.abs(wheel.total) < WHEEL_STEP) return;\n\t\t\twheel.locked = true;\n\t\t\twheel.total = 0;\n\t\t\ttouchRef.current = false;\n\t\t\tstepRef.current(direction > 0 ? 1 : -1);\n\t\t};\n\t\tviewport.addEventListener(\"wheel\", onWheel, { passive: false });\n\t\treturn () => viewport.removeEventListener(\"wheel\", onWheel);\n\t}, []);\n\n\tconst onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n\t\tif (event.target !== event.currentTarget || count < 2) return;\n\t\tconst rtl = (geometryRef.current?.sign ?? 1) < 0;\n\t\tconst back = vertical ? \"ArrowUp\" : rtl ? \"ArrowRight\" : \"ArrowLeft\";\n\t\tconst forward = vertical ? \"ArrowDown\" : rtl ? \"ArrowLeft\" : \"ArrowRight\";\n\t\tlet handled = true;\n\t\tif (event.key === forward) step(1);\n\t\telse if (event.key === back) step(-1);\n\t\telse if (event.key === \"PageDown\") step(MAX_QUEUE);\n\t\telse if (event.key === \"PageUp\") step(-MAX_QUEUE);\n\t\telse if (event.key === \"Home\") goTo(0);\n\t\telse if (event.key === \"End\") goTo(count - 1);\n\t\telse handled = false;\n\t\tif (handled) event.preventDefault();\n\t};\n\n\t/** The slot under a point, in slides from the one at the centre. */\n\tconst slotAt = (clientX: number, clientY: number, scale: number) => {\n\t\tconst viewport = viewportRef.current;\n\t\tconst geometry = geometryRef.current;\n\t\tif (!viewport || !geometry) return 0;\n\t\tconst rect = viewport.getBoundingClientRect();\n\t\tconst along = vertical\n\t\t\t? (clientY - rect.top - rect.height / 2) * scale\n\t\t\t: (clientX - rect.left - rect.width / 2) * scale;\n\t\tconst offset = (along * geometry.sign) / geometry.pitch;\n\t\tconst from = position.get() - Math.round(position.get());\n\t\tconst slots = Math.round(offset + from);\n\t\t// Only slots inside the frame count.\n\t\tconst reachable = Math.floor(\n\t\t\t(geometry.length / 2 + geometry.slide / 2) / geometry.pitch,\n\t\t);\n\t\treturn clamp(slots, -reachable, reachable);\n\t};\n\n\tconst onPointerDown = (event: PointerEvent<HTMLDivElement>) => {\n\t\tif (count < 2 || dragRef.current) return;\n\t\tif (event.pointerType === \"mouse\" && event.button !== 0) return;\n\t\tconst target = event.target as Element;\n\t\tif (target.closest?.(NO_DRAG_SELECTOR)) return;\n\t\tconst viewport = event.currentTarget;\n\t\tconst rect = viewport.getBoundingClientRect();\n\t\tdragRef.current = {\n\t\t\tpointerId: event.pointerId,\n\t\t\tpointerType: event.pointerType,\n\t\t\tstartX: event.clientX,\n\t\t\tstartY: event.clientY,\n\t\t\tstartPosition: position.get(),\n\t\t\tscale:\n\t\t\t\t(vertical\n\t\t\t\t\t? viewport.offsetHeight / rect.height\n\t\t\t\t\t: viewport.offsetWidth / rect.width) || 1,\n\t\t\tmoved: false,\n\t\t\tsamples: [],\n\t\t};\n\t\tsetPressed(true);\n\t};\n\n\tconst onPointerMove = (event: PointerEvent<HTMLDivElement>) => {\n\t\tconst drag = dragRef.current;\n\t\tconst geometry = geometryRef.current;\n\t\tif (!drag || drag.pointerId !== event.pointerId || !geometry) return;\n\t\tconst dx = (event.clientX - drag.startX) * drag.scale;\n\t\tconst dy = (event.clientY - drag.startY) * drag.scale;\n\t\tconst along = vertical ? dy : dx;\n\t\tconst across = vertical ? dx : dy;\n\t\tif (!drag.moved) {\n\t\t\tif (Math.abs(along) < DRAG_SLOP && Math.abs(across) < DRAG_SLOP) return;\n\t\t\tif (Math.abs(across) > Math.abs(along)) {\n\t\t\t\tendDrag(event);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tdrag.moved = true;\n\t\t\tanimationRef.current?.stop();\n\t\t\tanimationRef.current = null;\n\t\t\t// Track from where the slides are now, so the slop doesn't jump them.\n\t\t\tdrag.startPosition =\n\t\t\t\tposition.get() + (along * geometry.sign) / geometry.pitch;\n\t\t\ttry {\n\t\t\t\tevent.currentTarget.setPointerCapture(event.pointerId);\n\t\t\t} catch {}\n\t\t}\n\t\tconst now = performance.now();\n\t\tdrag.samples.push({ time: now, along });\n\t\twhile (\n\t\t\tdrag.samples.length > 2 &&\n\t\t\tnow - drag.samples[0].time > VELOCITY_WINDOW\n\t\t) {\n\t\t\tdrag.samples.shift();\n\t\t}\n\t\tlet value = drag.startPosition - (along * geometry.sign) / geometry.pitch;\n\t\tif (!loop) {\n\t\t\tconst last = count - 1;\n\t\t\tif (value < 0)\n\t\t\t\tvalue = band(value * geometry.pitch, RUBBER_LIMIT) / geometry.pitch;\n\t\t\telse if (value > last) {\n\t\t\t\tvalue =\n\t\t\t\t\tlast +\n\t\t\t\t\tband((value - last) * geometry.pitch, RUBBER_LIMIT) / geometry.pitch;\n\t\t\t}\n\t\t}\n\t\tposition.set(value);\n\t};\n\n\tconst endDrag = (event: PointerEvent<HTMLDivElement>, cancelled = false) => {\n\t\tconst drag = dragRef.current;\n\t\tif (!drag || drag.pointerId !== event.pointerId) return;\n\t\tdragRef.current = null;\n\t\tsetPressed(false);\n\t\tconst geometry = geometryRef.current;\n\t\tif (!geometry) return;\n\t\tif (!drag.moved) {\n\t\t\tif (cancelled) return;\n\t\t\t// A click on a neighbour brings it to the centre.\n\t\t\tconst slots = slotAt(event.clientX, event.clientY, drag.scale);\n\t\t\tif (slots !== 0) {\n\t\t\t\tsuppressClickRef.current = true;\n\t\t\t\ttouchRef.current = drag.pointerType === \"touch\";\n\t\t\t\tmoveTo(targetRef.current + slots, \"user\");\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tsuppressClickRef.current = true;\n\t\tlet speed = 0;\n\t\tconst samples = drag.samples;\n\t\tif (!cancelled && samples.length > 1) {\n\t\t\tconst first = samples[0];\n\t\t\tconst last = samples[samples.length - 1];\n\t\t\tconst elapsed = (last.time - first.time) / 1000;\n\t\t\t// A pointer that stopped before letting go carries no speed.\n\t\t\tif (elapsed > 0 && performance.now() - last.time < 60) {\n\t\t\t\tspeed = (last.along - first.along) / elapsed;\n\t\t\t}\n\t\t}\n\t\tconst velocity = -(speed * geometry.sign) / geometry.pitch;\n\t\tconst value = position.get();\n\t\tconst home = Math.round(drag.startPosition);\n\t\tconst projected = Math.round(value + velocity * PROJECTION_SECONDS);\n\t\tconst target = clamp(projected, home - MAX_FLICK, home + MAX_FLICK);\n\t\ttouchRef.current = drag.pointerType === \"touch\";\n\t\tmoveTo(target, \"user\", velocity);\n\t};\n\n\tconst onClickCapture = (event: MouseEvent<HTMLDivElement>) => {\n\t\tif (!suppressClickRef.current) return;\n\t\tsuppressClickRef.current = false;\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\t};\n\n\tconst registerControls = useCallback(() => {\n\t\tsetControlsCount((value) => value + 1);\n\t\treturn () => setControlsCount((value) => value - 1);\n\t}, []);\n\n\tconst sizeVars = (() => {\n\t\tconst { width, height } = slideSize;\n\t\tif (typeof width === \"number\" && typeof height === \"number\") {\n\t\t\t// Px sizes shrink to leave room for the flare across the axis.\n\t\t\tconst room = vertical ? CROSS_ROOM : 1.2;\n\t\t\tconst fit = `min(${width}px, 100cqi / ${room})`;\n\t\t\tconst gapLength =\n\t\t\t\ttypeof gap === \"number\"\n\t\t\t\t\t? `calc(var(--lgc-w) * ${round(gap / width)})`\n\t\t\t\t\t: gap;\n\t\t\treturn {\n\t\t\t\t\"--lgc-w\": fit,\n\t\t\t\t\"--lgc-h\": `calc(var(--lgc-w) * ${round((height / width) * 1000) / 1000})`,\n\t\t\t\t\"--lgc-gap\": gapLength,\n\t\t\t\t\"--lgc-along\": vertical ? \"var(--lgc-h)\" : \"var(--lgc-w)\",\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t\"--lgc-w\": cssLength(width),\n\t\t\t\"--lgc-h\": cssLength(height),\n\t\t\t\"--lgc-gap\": cssLength(gap),\n\t\t\t\"--lgc-along\": vertical ? \"var(--lgc-h)\" : \"var(--lgc-w)\",\n\t\t};\n\t})();\n\n\tconst context: CarouselContextValue = {\n\t\tcount,\n\t\tindex,\n\t\tloop,\n\t\torientation,\n\t\tautoplay: autoplayOn,\n\t\tplaying,\n\t\tsetPlaying,\n\t\tstep: (by: number) => step(by),\n\t\tregisterControls,\n\t};\n\n\tconst currentSlot = loop ? mod(anchor, slotCount) : index;\n\n\treturn (\n\t\t<CarouselContext.Provider value={context}>\n\t\t\t<div\n\t\t\t\tref={rootRef}\n\t\t\t\trole=\"region\"\n\t\t\t\taria-roledescription=\"carousel\"\n\t\t\t\taria-label={ariaLabel}\n\t\t\t\tdata-slot=\"liquid-glass-carousel\"\n\t\t\t\tdata-orientation={orientation}\n\t\t\t\tclassName={cn(\n\t\t\t\t\t\"@container relative flex w-full flex-col items-center\",\n\t\t\t\t\tclassName,\n\t\t\t\t)}\n\t\t\t\tstyle={{ ...sizeVars, ...style } as CSSProperties}\n\t\t\t\tonPointerEnter={(event) => {\n\t\t\t\t\tif (event.pointerType === \"mouse\") setHovered(true);\n\t\t\t\t}}\n\t\t\t\tonPointerLeave={(event) => {\n\t\t\t\t\tif (event.pointerType === \"mouse\") setHovered(false);\n\t\t\t\t}}\n\t\t\t\tonFocus={(event) => {\n\t\t\t\t\t// Keyboard focus pauses autoplay, except on the play button.\n\t\t\t\t\tconst target = event.target as HTMLElement;\n\t\t\t\t\tsetFocused(\n\t\t\t\t\t\ttarget.matches(\":focus-visible\") &&\n\t\t\t\t\t\t\t!target.closest(\"[data-lgc-play]\"),\n\t\t\t\t\t);\n\t\t\t\t}}\n\t\t\t\tonBlur={(event) => {\n\t\t\t\t\tif (!event.currentTarget.contains(event.relatedTarget as Node)) {\n\t\t\t\t\t\tsetFocused(false);\n\t\t\t\t\t}\n\t\t\t\t}}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t<div className=\"relative w-full\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tref={viewportRef}\n\t\t\t\t\t\t// biome-ignore lint/a11y/noNoninteractiveTabindex: the slides take keyboard focus as one stop for the arrow keys\n\t\t\t\t\t\ttabIndex={0}\n\t\t\t\t\t\trole=\"group\"\n\t\t\t\t\t\taria-label=\"Slides\"\n\t\t\t\t\t\tdata-slot=\"liquid-glass-carousel-viewport\"\n\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t\"peer relative w-full select-none overflow-hidden outline-none\",\n\t\t\t\t\t\t\tvertical\n\t\t\t\t\t\t\t\t? \"h-(--lgc-viewport) touch-pan-x\"\n\t\t\t\t\t\t\t\t: \"h-[calc(var(--lgc-h)*1.4)] touch-pan-y\",\n\t\t\t\t\t\t)}\n\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\"--lgc-viewport\": `var(--lgc-length, calc(var(--lgc-h) * ${VIEWPORT_SLIDES}))`,\n\t\t\t\t\t\t\t\tmaskImage: edgeMask(orientation),\n\t\t\t\t\t\t\t} as CSSProperties\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonKeyDown={onKeyDown}\n\t\t\t\t\t\tonPointerDown={onPointerDown}\n\t\t\t\t\t\tonPointerMove={onPointerMove}\n\t\t\t\t\t\tonPointerUp={(event) => endDrag(event)}\n\t\t\t\t\t\tonPointerCancel={(event) => endDrag(event, true)}\n\t\t\t\t\t\tonLostPointerCapture={(event) => {\n\t\t\t\t\t\t\t// A touch's implicit capture on a child is lost when the\n\t\t\t\t\t\t\t// viewport takes it; only the viewport's own loss ends a drag.\n\t\t\t\t\t\t\tif (event.target !== event.currentTarget) return;\n\t\t\t\t\t\t\tif (dragRef.current?.moved) endDrag(event);\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tonClickCapture={onClickCapture}\n\t\t\t\t\t\tonDragStart={(event) => event.preventDefault()}\n\t\t\t\t\t>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tref={gapRef}\n\t\t\t\t\t\t\taria-hidden\n\t\t\t\t\t\t\tclassName=\"invisible absolute h-0 w-(--lgc-gap)\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tref={trackRef}\n\t\t\t\t\t\t\tdata-slot=\"liquid-glass-carousel-track\"\n\t\t\t\t\t\t\tclassName=\"absolute inset-0 overflow-hidden\"\n\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\tfilter:\n\t\t\t\t\t\t\t\t\tmeltMode === \"filter\" && lens ? `url(#${lensId})` : undefined,\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{Array.from({ length: slotCount }, (_, slot) => {\n\t\t\t\t\t\t\t\tconst slideIndex = slot % Math.max(count, 1);\n\t\t\t\t\t\t\t\tconst relative = loop\n\t\t\t\t\t\t\t\t\t? wrap(slot - anchor, slotCount)\n\t\t\t\t\t\t\t\t\t: slot - index;\n\t\t\t\t\t\t\t\t// The copy nearest the centre is the real slide; others are clones.\n\t\t\t\t\t\t\t\tconst real = loop\n\t\t\t\t\t\t\t\t\t? relative >= -count / 2 && relative < count / 2\n\t\t\t\t\t\t\t\t\t: true;\n\t\t\t\t\t\t\t\tconst current = slot === currentSlot;\n\t\t\t\t\t\t\t\tconst initial = loop\n\t\t\t\t\t\t\t\t\t? wrap(slot - startIndex, slotCount)\n\t\t\t\t\t\t\t\t\t: slot - startIndex;\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\tkey={slot}\n\t\t\t\t\t\t\t\t\t\tref={(element) => {\n\t\t\t\t\t\t\t\t\t\t\tslotRefs.current[slot] = element;\n\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\tdata-slot=\"liquid-glass-carousel-item\"\n\t\t\t\t\t\t\t\t\t\tdata-index={slideIndex}\n\t\t\t\t\t\t\t\t\t\tdata-current={current || undefined}\n\t\t\t\t\t\t\t\t\t\tdata-clone={real ? undefined : \"\"}\n\t\t\t\t\t\t\t\t\t\taria-hidden={real ? undefined : true}\n\t\t\t\t\t\t\t\t\t\tinert={!current}\n\t\t\t\t\t\t\t\t\t\tclassName=\"absolute inset-0 m-auto h-(--lgc-h) w-(--lgc-w)\"\n\t\t\t\t\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\t\t\t\t\ttransform: vertical\n\t\t\t\t\t\t\t\t\t\t\t\t? `translate3d(0, calc((var(--lgc-along) + var(--lgc-gap)) * ${initial}), 0)`\n\t\t\t\t\t\t\t\t\t\t\t\t: `translate3d(calc((var(--lgc-along) + var(--lgc-gap)) * ${initial}), 0, 0)`,\n\t\t\t\t\t\t\t\t\t\t\tvisibility:\n\t\t\t\t\t\t\t\t\t\t\t\tMath.abs(initial) > reach ? \"hidden\" : undefined,\n\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<SlideContext.Provider value={{ index: slideIndex, count }}>\n\t\t\t\t\t\t\t\t\t\t\t{slides[slideIndex]}\n\t\t\t\t\t\t\t\t\t\t</SlideContext.Provider>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<span\n\t\t\t\t\t\taria-hidden\n\t\t\t\t\t\tclassName=\"pointer-events-none absolute inset-0 rounded-3xl ring-ring/60 ring-offset-2 ring-offset-background peer-focus-visible:ring-2\"\n\t\t\t\t\t/>\n\t\t\t\t\t{autoplayOn && controlsCount === 0 ? (\n\t\t\t\t\t\t<PlayButton\n\t\t\t\t\t\t\tplaying={playing}\n\t\t\t\t\t\t\tonToggle={() => setPlaying(!playing)}\n\t\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t\t// The face sits at the outer edge of its hit area, flush with the column.\n\t\t\t\t\t\t\t\t\"absolute justify-end\",\n\t\t\t\t\t\t\t\tvertical\n\t\t\t\t\t\t\t\t\t? \"top-1/2 right-0 -translate-y-1/2 rtl:right-auto rtl:left-0\"\n\t\t\t\t\t\t\t\t\t: \"right-0 bottom-0 rtl:right-auto rtl:left-0\",\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : null}\n\t\t\t\t\t{meltMode === \"filter\" && lens ? (\n\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\taria-hidden\n\t\t\t\t\t\t\twidth=\"0\"\n\t\t\t\t\t\t\theight=\"0\"\n\t\t\t\t\t\t\tclassName=\"pointer-events-none absolute\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<defs>\n\t\t\t\t\t\t\t\t<LensFilter id={lensId} lens={lens} orientation={orientation} />\n\t\t\t\t\t\t\t</defs>\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t) : null}\n\t\t\t\t</div>\n\t\t\t\t{extras}\n\t\t\t\t<div aria-live=\"polite\" aria-atomic className=\"sr-only\">\n\t\t\t\t\t{announcement}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</CarouselContext.Provider>\n\t);\n}\n\nexport interface LiquidGlassCarouselSlideProps extends ComponentProps<\"div\"> {\n\t/** Defaults to \"n of N\". */\n\t\"aria-label\"?: string;\n}\n\nexport function LiquidGlassCarouselSlide({\n\tclassName,\n\tchildren,\n\t\"aria-label\": ariaLabel,\n\t...props\n}: LiquidGlassCarouselSlideProps) {\n\tconst slide = useContext(SlideContext);\n\treturn (\n\t\t<div\n\t\t\trole=\"group\"\n\t\t\taria-roledescription=\"slide\"\n\t\t\taria-label={\n\t\t\t\tariaLabel ??\n\t\t\t\t(slide ? `${slide.index + 1} of ${slide.count}` : undefined)\n\t\t\t}\n\t\t\tdata-slot=\"liquid-glass-carousel-slide\"\n\t\t\tclassName={cn(\n\t\t\t\t\"relative size-full overflow-hidden rounded-full\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t>\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n\nfunction PlayButton({\n\tplaying,\n\tonToggle,\n\tclassName,\n}: {\n\tplaying: boolean;\n\tonToggle: () => void;\n\tclassName?: string;\n}) {\n\treturn (\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tdata-lgc-play=\"\"\n\t\t\tdata-slot=\"liquid-glass-carousel-play\"\n\t\t\taria-label={playing ? \"Pause autoplay\" : \"Start autoplay\"}\n\t\t\tonClick={onToggle}\n\t\t\tclassName={cn(\n\t\t\t\t\"group/lgc-button inline-flex size-11 items-center justify-center rounded-full outline-none\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t>\n\t\t\t{/* The face ignores the pointer, so swapping the icon never leaves\n\t\t\t    the pointer over a removed node, which would swallow the\n\t\t\t    carousel's pointerleave and keep autoplay paused. */}\n\t\t\t<span className=\"pointer-events-none inline-flex size-7 items-center justify-center rounded-full text-muted-foreground transition-colors group-hover/lgc-button:bg-muted group-hover/lgc-button:text-foreground group-focus-visible/lgc-button:ring-2 group-focus-visible/lgc-button:ring-ring/60\">\n\t\t\t\t{playing ? (\n\t\t\t\t\t<PauseIcon className=\"size-3\" fill=\"currentColor\" strokeWidth={0} />\n\t\t\t\t) : (\n\t\t\t\t\t<PlayIcon className=\"size-3\" fill=\"currentColor\" strokeWidth={0} />\n\t\t\t\t)}\n\t\t\t</span>\n\t\t</button>\n\t);\n}\n\nexport type LiquidGlassCarouselControlsProps = ComponentProps<\"div\">;\n\n/** Previous and next buttons, a \"03 / 07\" counter, and a pause button when autoplay is on. */\nexport function LiquidGlassCarouselControls({\n\tclassName,\n\t...props\n}: LiquidGlassCarouselControlsProps) {\n\tconst carousel = useCarousel(\"LiquidGlassCarouselControls\");\n\tconst { registerControls } = carousel;\n\tuseLayoutEffect(() => registerControls(), [registerControls]);\n\tif (carousel.count < 2) return null;\n\tconst vertical = carousel.orientation === \"vertical\";\n\tconst atStart = !carousel.loop && carousel.index === 0;\n\tconst atEnd = !carousel.loop && carousel.index === carousel.count - 1;\n\tconst buttonClass =\n\t\t\"group/lgc-button inline-flex size-11 items-center justify-center rounded-full outline-none disabled:pointer-events-none disabled:opacity-40\";\n\tconst faceClass =\n\t\t\"pointer-events-none inline-flex size-8 items-center justify-center rounded-full border bg-background text-foreground shadow-xs transition-colors group-hover/lgc-button:bg-muted group-focus-visible/lgc-button:ring-2 group-focus-visible/lgc-button:ring-ring/60\";\n\tconst Prev = vertical ? ArrowUpIcon : ArrowLeftIcon;\n\tconst Next = vertical ? ArrowDownIcon : ArrowRightIcon;\n\treturn (\n\t\t<div\n\t\t\tdata-slot=\"liquid-glass-carousel-controls\"\n\t\t\tclassName={cn(\"flex items-center gap-1\", className)}\n\t\t\t{...props}\n\t\t>\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\taria-label=\"Previous slide\"\n\t\t\t\tdisabled={atStart}\n\t\t\t\tonClick={() => carousel.step(-1)}\n\t\t\t\tclassName={buttonClass}\n\t\t\t>\n\t\t\t\t<span className={faceClass}>\n\t\t\t\t\t<Prev className={cn(\"size-4\", !vertical && \"rtl:rotate-180\")} />\n\t\t\t\t</span>\n\t\t\t</button>\n\t\t\t<span\n\t\t\t\taria-hidden\n\t\t\t\tdir=\"ltr\"\n\t\t\t\tclassName=\"min-w-14 text-center font-medium text-muted-foreground text-xs tabular-nums\"\n\t\t\t>\n\t\t\t\t<span className=\"text-foreground\">{pad(carousel.index + 1)}</span> /{\" \"}\n\t\t\t\t{pad(carousel.count)}\n\t\t\t</span>\n\t\t\t<button\n\t\t\t\ttype=\"button\"\n\t\t\t\taria-label=\"Next slide\"\n\t\t\t\tdisabled={atEnd}\n\t\t\t\tonClick={() => carousel.step(1)}\n\t\t\t\tclassName={buttonClass}\n\t\t\t>\n\t\t\t\t<span className={faceClass}>\n\t\t\t\t\t<Next className={cn(\"size-4\", !vertical && \"rtl:rotate-180\")} />\n\t\t\t\t</span>\n\t\t\t</button>\n\t\t\t{carousel.autoplay ? (\n\t\t\t\t<PlayButton\n\t\t\t\t\tplaying={carousel.playing}\n\t\t\t\t\tonToggle={() => carousel.setPlaying(!carousel.playing)}\n\t\t\t\t/>\n\t\t\t) : null}\n\t\t</div>\n\t);\n}\n\nexport default LiquidGlassCarousel;\n",
      "type": "registry:component",
      "target": "@components/liquid-glass-carousel.tsx"
    }
  ],
  "meta": {
    "createdAt": "2026-11-14",
    "image": "https://cdn.tentui.com/images/components/liquid-glass-carousel?v=1",
    "video": "https://cdn.tentui.com/videos/components/liquid-glass-carousel?v=1"
  },
  "docs": "https://tentui.com/components/liquid-glass-carousel",
  "categories": [
    "lists"
  ],
  "type": "registry:component"
}