{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "carousel",
  "title": "Carousel",
  "description": "A viewer: slides in a cut frame, with keys, segment indicators and a position readout.",
  "dependencies": [
    "@ui-sdk/react@0.1.0-beta.5",
    "lucide-react@1.73.0"
  ],
  "registryDependencies": [
    "https://www.cyberspec.dev/r/cyber.json",
    "https://www.cyberspec.dev/r/button.json"
  ],
  "files": [
    {
      "path": "registry/cyber/ui/carousel.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport {\n  Carousel as SdkCarousel,\n  CarouselContent,\n  CarouselIndicator,\n  CarouselIndicatorGroup,\n  CarouselItem,\n  CarouselNext,\n  CarouselPrevious,\n  CarouselViewport,\n} from \"@ui-sdk/react/carousel\"\nimport { ChevronLeft, ChevronRight } from \"lucide-react\"\nimport \"@/registry/cyber/ui/cyber/button.css\"\nimport \"@/registry/cyber/ui/cyber/carousel.css\"\n\ntype CarouselSlide = {\n  id: string\n  // What the slide is called: printed under the still, and the name of its\n  // indicator.\n  title: string\n  // The still: an <svg>, an <img>. It fills a 16:9 frame.\n  media: React.ReactNode\n  caption?: React.ReactNode\n}\n\nconst two = (n: number) => String(n).padStart(2, \"0\")\n\n// \"02 / 05\", for the eye only: each slide is already labelled by its\n// position (\"2 of 5\") and the SDK announces the one that comes into view.\n// The figure slips for a moment as it steps, but not as the page loads.\nfunction Readout({ page, pageCount }: { page: number; pageCount: number }) {\n  const first = React.useRef(page)\n  const [stepped, setStepped] = React.useState(false)\n  React.useEffect(() => {\n    if (page !== first.current) setStepped(true)\n  }, [page])\n  return (\n    <p data-kit=\"carousel-readout\" aria-hidden>\n      <b key={page} data-kit=\"carousel-page\" data-stepped={stepped ? \"\" : undefined}>\n        {two(page)}\n      </b>{\" \"}\n      / {two(pageCount)}\n    </p>\n  )\n}\n\n// A viewer: stills in a cut frame, one at a time, each with a caption\n// under it. Swipe or drag the frame, press the keys, or focus the frame\n// and use the arrow keys, Home and End. A row of segments shows where you\n// are (the current one is lit and wider) beside a readout of the same,\n// and each segment goes straight to its slide.\n//\n// - `label` names the viewer (\"Recon stills\").\n// - `slides`: `{ id, title, media, caption? }`.\n// - `code`: a line of micro-print over the frame. Decoration only.\n//\n// The rest goes to ui-sdk's Carousel: `page`, `defaultPage`,\n// `onPageChange`, `loop`, `controller`.\nfunction Carousel({\n  label,\n  slides,\n  code,\n  ...props\n}: Omit<React.ComponentProps<typeof SdkCarousel>, \"children\" | \"aria-label\"> & {\n  label: string\n  slides: CarouselSlide[]\n  code?: string\n}) {\n  return (\n    <SdkCarousel data-kit=\"carousel\" aria-label={label} {...props}>\n      {({ page, pageCount }) => (\n        <>\n          {code && (\n            <span data-kit=\"carousel-code\" data-micro aria-hidden>\n              {code}\n            </span>\n          )}\n          {/* The frame is around the viewport, not on it: a frame's cuts and\n              edges would scroll away with the slides. It lights when the\n              viewport inside it takes focus. */}\n          <div data-kit=\"carousel-frame\" data-frame=\"tr bl\" data-frame-focus=\"within\">\n            <CarouselViewport data-kit=\"carousel-viewport\">\n              <CarouselContent data-kit=\"carousel-content\">\n                {slides.map((slide) => (\n                  <CarouselItem key={slide.id} data-kit=\"carousel-slide\">\n                    <figure data-kit=\"carousel-figure\">\n                      <div data-kit=\"carousel-media\" data-scanlines=\"\">\n                        {slide.media}\n                      </div>\n                      <figcaption data-kit=\"carousel-caption\">\n                        <span data-kit=\"carousel-title\">{slide.title}</span>\n                        {slide.caption != null && <span data-kit=\"carousel-text\">{slide.caption}</span>}\n                      </figcaption>\n                    </figure>\n                  </CarouselItem>\n                ))}\n              </CarouselContent>\n            </CarouselViewport>\n          </div>\n          <div data-kit=\"carousel-bar\">\n            <CarouselIndicatorGroup data-kit=\"carousel-indicators\" aria-label=\"Choose a slide\">\n              {slides.map((slide, index) => (\n                <CarouselIndicator key={slide.id} data-kit=\"carousel-indicator\" data-sfx=\"select\" page={index + 1} aria-label={slide.title} />\n              ))}\n            </CarouselIndicatorGroup>\n            <Readout page={page} pageCount={pageCount ?? slides.length} />\n            <div data-kit=\"carousel-steps\">\n              <CarouselPrevious\n                data-kit=\"button\"\n                data-frame=\"notch br\"\n                data-press-flash=\"\"\n                data-tone=\"secondary\"\n                data-icon=\"\"\n                data-sfx=\"tick\"\n                aria-label=\"Previous slide\"\n              >\n                <ChevronLeft data-kit=\"carousel-chevron\" aria-hidden />\n              </CarouselPrevious>\n              <CarouselNext\n                data-kit=\"button\"\n                data-frame=\"notch br\"\n                data-press-flash=\"\"\n                data-tone=\"secondary\"\n                data-icon=\"\"\n                data-sfx=\"tick\"\n                aria-label=\"Next slide\"\n              >\n                <ChevronRight data-kit=\"carousel-chevron\" aria-hidden />\n              </CarouselNext>\n            </div>\n          </div>\n        </>\n      )}\n    </SdkCarousel>\n  )\n}\n\nexport { Carousel }\nexport type { CarouselSlide }\n",
      "type": "registry:ui",
      "target": "@ui/carousel.tsx"
    },
    {
      "path": "registry/cyber/ui/cyber/carousel.css",
      "content": "@layer ui-sdk, cyber.tokens, cyber.base, cyber.ui, cyber.blocks, cyber.fx, cyber.a11y;\n\n@layer cyber.ui {\n  /* A column: the micro-print, the frame with the slides in it, and a bar\n     with the segments, the readout and the keys. */\n  [data-skin=\"cyber\"] [data-kit=\"carousel\"] {\n    display: flex;\n    flex-direction: column;\n    gap: 4px;\n    width: 100%;\n    min-width: 0;\n    text-align: start;\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"carousel-code\"] {\n    align-self: flex-start;\n    max-width: 100%;\n    overflow: hidden;\n  }\n\n  /* The frame holds still while the slides pass under it. Focus belongs to\n     the viewport inside, and the frame draws it (data-frame-focus). */\n  [data-skin=\"cyber\"] [data-kit=\"carousel-frame\"] {\n    --frame-cut: var(--cy-cut);\n    --frame-line: var(--cy-line-ctl);\n    --frame-fill: var(--cy-panel);\n    /* Frame variables inherit, and a surface behind may have set one. */\n    --frame-image: none;\n\n    min-width: 0;\n\n    /* A still fills the frame to its edges and covers the stroke the frame\n       paints along its top-right cut, so that stroke is drawn again over\n       the slides. It reads the frame's own line color and weight, which\n       turn to the focus color with the rest of the edge. */\n    &::after {\n      content: \"\";\n      position: absolute;\n      top: -1px;\n      right: -1px;\n      width: var(--frame-cut);\n      height: var(--frame-cut);\n      background: linear-gradient(\n        to top right,\n        transparent calc(50% - var(--_w, 1px) - 0.5px),\n        var(--_line, var(--cy-line-ctl)) calc(50% - var(--_w, 1px))\n      );\n      pointer-events: none;\n      z-index: 1;\n    }\n\n    /* Likewise the focus ring: the frame draws it inside itself, where a\n       still would cover it, so it's drawn once more on top. */\n    &:has(:focus-visible)::before {\n      content: \"\";\n      position: absolute;\n      inset: 0;\n      z-index: 1;\n      box-shadow: inset 0 0 0 1px var(--frame-focus, var(--cy-signal));\n      pointer-events: none;\n    }\n  }\n\n  /* The viewport scrolls natively; its scrollbar is hidden, since the\n     segments under the frame say where you are. */\n  [data-skin=\"cyber\"] [data-kit=\"carousel-viewport\"] {\n    scrollbar-width: none;\n\n    @media (hover: hover) {\n      cursor: grab;\n    }\n    &[data-dragging] {\n      cursor: grabbing;\n    }\n  }\n\n  /* One slide to a view. */\n  [data-skin=\"cyber\"] [data-kit=\"carousel-slide\"] {\n    flex: 0 0 100%;\n    min-width: 0;\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"carousel-figure\"] {\n    display: flex;\n    flex-direction: column;\n    height: 100%;\n  }\n\n  /* The still. Whatever is put in it fills the 16:9 field; the scanlines\n     lie over the still only, so the caption under it stays clean. */\n  [data-skin=\"cyber\"] [data-kit=\"carousel-media\"] {\n    flex: none;\n    aspect-ratio: 16 / 9;\n    overflow: hidden;\n    background: var(--cy-void);\n    color: var(--cy-accent);\n\n    & > :is(svg, img, video, canvas) {\n      display: block;\n      width: 100%;\n      height: 100%;\n      object-fit: cover;\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"carousel-caption\"] {\n    flex: 1 1 auto;\n    display: grid;\n    align-content: start;\n    gap: 2px;\n    padding: 8px 12px 10px;\n    border-block-start: 1px solid var(--cy-line-deco);\n    user-select: none;\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"carousel-title\"] {\n    font-size: var(--cy-text-md);\n    font-weight: 600;\n    line-height: 1.25;\n    letter-spacing: var(--cy-track);\n    text-transform: uppercase;\n    overflow-wrap: anywhere;\n    color: var(--cy-ink);\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"carousel-text\"] {\n    font-size: var(--cy-text-sm);\n    line-height: 1.4;\n    color: var(--cy-ink-hi);\n    text-wrap: pretty;\n  }\n\n  /* Segments first, then the readout and the keys pushed to the far end.\n     On a narrow column the segments take a row of their own, with the\n     readout and the keys under them; they only narrow once there are too\n     many for that row. */\n  [data-skin=\"cyber\"] [data-kit=\"carousel-bar\"] {\n    container-type: inline-size;\n    display: flex;\n    flex-wrap: wrap;\n    align-items: center;\n    gap: 4px 12px;\n    min-width: 0;\n    padding-block-start: 2px;\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"carousel-indicators\"] {\n    flex: 1 1 auto;\n    display: flex;\n    align-items: center;\n    gap: 4px;\n    min-width: 0;\n\n    @container (width < 300px) {\n      flex-basis: 100%;\n    }\n  }\n\n  /* A segment is a 24px-tall target, 24px from the next, with the mark\n     people see drawn inside it: a hollow dash.\n       idle     outline 70%\n       hover    outline 100%, fill 10%\n       current  solid accent, taller, twice as wide and with one end cut,\n                so it isn't told by color alone */\n  [data-skin=\"cyber\"] [data-kit=\"carousel-indicator\"] {\n    flex: 0 1 auto;\n    display: grid;\n    align-items: center;\n    width: 20px;\n    min-width: 8px;\n    height: 24px;\n    padding: 0;\n    border: 0;\n    background: none;\n    cursor: pointer;\n\n    /* The ring sits on the target's own edge, clear of its neighbours. */\n    &:focus-visible {\n      outline-offset: 0;\n    }\n\n    &::before {\n      content: \"\";\n      height: 6px;\n      border: 1px solid var(--cy-line-ctl);\n      transition:\n        background-color var(--cy-t-fast) linear,\n        border-color var(--cy-t-fast) linear;\n    }\n\n    @media (hover: hover) {\n      &:hover:not([data-selected])::before {\n        border-color: var(--cy-line-hot);\n        background: var(--cy-fill-hover);\n      }\n    }\n\n    &:active:not([data-selected])::before {\n      border-color: var(--cy-line-hot);\n      background: var(--cy-fill-active);\n    }\n\n    &[data-selected] {\n      width: 36px;\n      cursor: default;\n    }\n    &[data-selected]::before {\n      height: 8px;\n      clip-path: polygon(0 0, 100% 0, 100% 100%, 5px 100%, 0 calc(100% - 5px));\n      border-color: var(--cy-line-hot);\n      background: var(--cy-line-hot);\n    }\n\n    @media (pointer: coarse) {\n      height: 44px;\n    }\n  }\n\n  /* 02 / 05: a readout, so it's in the signal color. The current figure\n     slips its channels as it steps. */\n  [data-skin=\"cyber\"] [data-kit=\"carousel-readout\"] {\n    flex: none;\n    font-family: var(--cy-mono);\n    font-size: var(--cy-text-xs);\n    line-height: 1;\n    letter-spacing: 0.04em;\n    white-space: nowrap;\n    color: var(--cy-signal);\n    user-select: none;\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"carousel-page\"] {\n    display: inline-block;\n    font-size: var(--cy-text-md);\n    font-weight: 500;\n\n    &[data-stepped] {\n      animation: var(--cy-fx-rgb) 240ms var(--cy-ease-snap);\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"carousel-steps\"] {\n    flex: none;\n    display: flex;\n    gap: 4px;\n    margin-inline-start: auto;\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"carousel-chevron\"]:dir(rtl) {\n    scale: -1 1;\n  }\n\n  /* Forced colors drop fills: the current segment keeps its extra width\n     and height, and takes the system's highlight. */\n  @media (forced-colors: active) {\n    /* The frame's cuts come off, and the stroke over one goes with them. */\n    [data-skin=\"cyber\"] [data-kit=\"carousel-frame\"]::after {\n      display: none;\n    }\n    [data-skin=\"cyber\"] [data-kit=\"carousel-indicator\"]::before {\n      border-color: CanvasText;\n    }\n    [data-skin=\"cyber\"] [data-kit=\"carousel-indicator\"][data-selected]::before {\n      border-color: Highlight;\n      background: Highlight;\n    }\n  }\n}\n",
      "type": "registry:file",
      "target": "@ui/cyber/carousel.css"
    }
  ],
  "type": "registry:ui"
}
