{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "loader",
  "title": "Loader",
  "description": "A boot screen in miniature: a mark, a thin progress bar, a percentage and a cycling status line.",
  "dependencies": [
    "@ui-sdk/react@0.1.0-beta.5"
  ],
  "registryDependencies": [
    "https://www.cyberspec.dev/r/cyber.json"
  ],
  "files": [
    {
      "path": "registry/cyber/ui/loader.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { Progress as SdkProgress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue } from \"@ui-sdk/react/progress\"\nimport \"@/registry/cyber/ui/cyber/loader.css\"\n\nconst bootPhrases = [\"Linking…\", \"Verifying keys…\", \"Mapping routes…\", \"Syncing cache…\"]\n\n// How long one phrase stays up while the progress isn't known. Slow enough\n// that a screen reader can finish one before the next arrives.\nconst phraseMs = 2600\n\n// A boot screen in miniature: a mark, what's loading, a hairline bar, the\n// percentage in the signal color, and a status line that says what the\n// machine is doing right now.\n//\n// - `value`: how far along, between `min` and `max` (0 to 100 unless set).\n//   Leave it out, or pass null, while that isn't known: the bar hatches, a\n//   highlight sweeps across it and the percentage is withheld.\n// - `phrases`: the status lines. With a value they're spread across the\n//   range, so each one is shown once, in order, as the work passes it;\n//   without one they turn over on a timer. The line is a polite live\n//   region, so a screen reader hears each change without being interrupted.\n// - `doneLabel`: the status line once the value reaches `max`.\n// - `fill`: covers its nearest positioned ancestor, for a whole screen.\n// - `code`: a line of micro-print under the bar. Decoration only.\n//\n// With effects off the bar, the percentage and the status line still say\n// everything; only the sweep, the caret and the mark's pulse stop.\nfunction Loader({\n  label,\n  value = null,\n  min = 0,\n  max = 100,\n  phrases = bootPhrases,\n  doneLabel = \"Link stable.\",\n  fill,\n  code,\n  getValueLabel,\n  className,\n  style,\n  ...props\n}: Omit<React.ComponentProps<typeof SdkProgress>, \"children\" | \"value\" | \"className\" | \"style\"> & {\n  label: string\n  value?: number | null\n  phrases?: string[]\n  doneLabel?: string\n  fill?: boolean\n  code?: string\n  className?: string\n  style?: React.CSSProperties\n}) {\n  const [turn, setTurn] = React.useState(0)\n  const unknown = value == null\n  const count = phrases.length\n\n  React.useEffect(() => {\n    if (!unknown || count < 2) return\n    const timer = window.setInterval(() => setTurn((now) => now + 1), phraseMs)\n    return () => window.clearInterval(timer)\n  }, [unknown, count])\n\n  // Where the value sits in its range, from 0 to 1. The bar is scaled by\n  // this rather than given a width, so it can move without layout.\n  const part = unknown || max <= min ? null : Math.min(1, Math.max(0, (value - min) / (max - min)))\n  const done = part === 1\n  const phrase = done ? doneLabel : count === 0 ? \"\" : part == null ? phrases[turn % count] : phrases[Math.min(count - 1, Math.floor(part * count))]\n\n  return (\n    <div\n      data-kit=\"loader\"\n      data-fill={fill ? \"\" : undefined}\n      data-state={done ? \"complete\" : unknown ? \"indeterminate\" : \"progressing\"}\n      className={className}\n      style={style}\n    >\n      <div data-kit=\"loader-body\">\n        <LoaderMark />\n        <SdkProgress\n          data-kit=\"loader-bar\"\n          value={value}\n          min={min}\n          max={max}\n          // While there's no number, a screen reader gets a word for the\n          // bar's value rather than nothing.\n          getValueLabel={getValueLabel ?? ((current, details) => (current == null ? \"In progress\" : details.formatted))}\n          style={{ \"--loader-part\": part ?? undefined } as React.CSSProperties}\n          {...props}\n        >\n          <ProgressLabel data-kit=\"loader-label\">{label}</ProgressLabel>\n          <ProgressTrack data-kit=\"loader-track\">\n            <ProgressIndicator data-kit=\"loader-indicator\" />\n          </ProgressTrack>\n          <ProgressValue data-kit=\"loader-value\" />\n        </SdkProgress>\n        {/* Outside the progress bar, whose children assistive technology\n            may flatten. The phrase is keyed so each new one arrives with\n            the kit's change effect; the live region itself stays put. */}\n        <p data-kit=\"loader-status\" role=\"status\">\n          {phrase && (\n            <span key={phrase} data-kit=\"loader-phrase\">\n              {phrase}\n            </span>\n          )}\n        </p>\n        {code && (\n          <span data-kit=\"loader-code\" data-micro aria-hidden>\n            {code}\n          </span>\n        )}\n      </div>\n    </div>\n  )\n}\n\n// The mark: a triangle with one corner cut, the way the kit's frames are,\n// a second one nested in it point down, and a core that breathes while\n// the work is under way.\nfunction LoaderMark() {\n  return (\n    <svg data-kit=\"loader-mark\" viewBox=\"0 0 64 56\" fill=\"none\" aria-hidden>\n      <path data-part=\"outer\" d=\"M32 3 61 53H14L8.8 43Z\" />\n      <path data-part=\"inner\" d=\"M21 30h22L32 49Z\" />\n      <path data-part=\"core\" d=\"M32 33.5l3.6 6.2h-7.2Z\" />\n      <path data-part=\"tick\" d=\"M3 53h6M32 3V0\" />\n    </svg>\n  )\n}\n\nexport { Loader }\n",
      "type": "registry:ui",
      "target": "@ui/loader.tsx"
    },
    {
      "path": "registry/cyber/ui/cyber/loader.css",
      "content": "@layer ui-sdk, cyber.tokens, cyber.base, cyber.ui, cyber.blocks, cyber.fx, cyber.a11y;\n\n@layer cyber.ui {\n  /* The loader is a column, centered in whatever it's given: the mark, the\n     name, the bar, then the status line and the percentage side by side\n     under the bar, and a line of micro-print. */\n  [data-skin=\"cyber\"] [data-kit=\"loader\"] {\n    --loader-mark: 52px;\n    --loader-width: 340px;\n    /* Which way the bar fills. */\n    --_dir: 1;\n\n    display: grid;\n    justify-items: center;\n    width: 100%;\n    min-width: 0;\n\n    &:dir(rtl) {\n      --_dir: -1;\n    }\n\n    /* A whole screen: it covers its positioned parent and sits in the\n       middle, on the void, with a faint light behind the mark. */\n    &[data-fill] {\n      --loader-mark: 72px;\n      --loader-width: 420px;\n\n      position: absolute;\n      inset: 0;\n      align-content: center;\n      padding: 24px;\n      overflow: hidden;\n      background:\n        radial-gradient(ellipse 60% 50% at 50% 45%, color-mix(in srgb, var(--cy-accent) 8%, transparent), transparent),\n        var(--cy-void);\n    }\n  }\n\n  /* Two columns, so the status line and the percentage share a row. The\n     progress bar keeps its own parts (the name, the track, the percentage)\n     and lays them out on this grid's lines; the status line, which lives\n     outside the bar, takes the cell beside the percentage. */\n  [data-skin=\"cyber\"] [data-kit=\"loader-body\"] {\n    display: grid;\n    grid-template-columns: minmax(0, 1fr) auto;\n    column-gap: 12px;\n    width: 100%;\n    max-width: var(--loader-width);\n    min-width: 0;\n    text-align: start;\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"loader-mark\"] {\n    grid-column: 1 / -1;\n    justify-self: center;\n    display: block;\n    width: var(--loader-mark);\n    height: auto;\n    margin-block-end: 8px;\n    overflow: visible;\n\n    & path {\n      stroke-linecap: square;\n      stroke-linejoin: miter;\n    }\n    & [data-part=\"outer\"] {\n      stroke: var(--cy-ink);\n      stroke-width: 2;\n    }\n    & [data-part=\"inner\"] {\n      stroke: var(--cy-line-ctl);\n      stroke-width: 1.5;\n    }\n    & [data-part=\"tick\"] {\n      stroke: var(--cy-line-ctl);\n      stroke-width: 1.5;\n    }\n    & [data-part=\"core\"] {\n      fill: var(--cy-accent);\n      animation: var(--cy-fx-pulse) 1.6s var(--cy-ease-snap) infinite;\n    }\n  }\n\n  /* Done: the core stops breathing and reads as a value. */\n  [data-skin=\"cyber\"] [data-kit=\"loader\"][data-state=\"complete\"] [data-kit=\"loader-mark\"] [data-part=\"core\"] {\n    fill: var(--cy-signal);\n    animation: none;\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"loader-bar\"] {\n    grid-column: 1 / -1;\n    grid-row: 2 / span 3;\n    display: grid;\n    grid-template-columns: subgrid;\n    grid-template-rows: subgrid;\n    min-width: 0;\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"loader-label\"] {\n    grid-column: 1 / -1;\n    margin-block-end: 16px;\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    text-align: center;\n    text-wrap: balance;\n    overflow-wrap: anywhere;\n    color: var(--cy-ink);\n  }\n\n  /* A hairline. The fill is as wide as the track and scaled along it, and\n     a tick rides its end; both move in steps, like a display refreshing. */\n  [data-skin=\"cyber\"] [data-kit=\"loader-track\"] {\n    grid-column: 1 / -1;\n    position: relative;\n    height: 4px;\n    container-type: inline-size;\n    background: var(--cy-line-deco);\n\n    &::after {\n      content: \"\";\n      position: absolute;\n      inset-block: -3px;\n      inset-inline-start: 0;\n      width: 2px;\n      background: var(--cy-ink-hi);\n      translate: calc(var(--_dir) * var(--loader-part, 0) * (100cqi - 2px)) 0;\n      transition: translate var(--cy-t) var(--cy-ease-step);\n    }\n\n    &[data-indeterminate]::after {\n      content: none;\n    }\n  }\n\n  /* The SDK gives the fill a width; the minimum pins it to the whole track\n     so that only its scale changes. */\n  [data-skin=\"cyber\"] [data-kit=\"loader-indicator\"] {\n    position: relative;\n    height: 100%;\n    min-width: 100%;\n    background: var(--cy-accent);\n    transform-origin: left center;\n    transform: scaleX(var(--loader-part, 1));\n    transition: transform var(--cy-t) var(--cy-ease-step);\n\n    &:dir(rtl) {\n      transform-origin: right center;\n    }\n\n    /* Unknown: the bar is dashed from end to end, and a highlight crosses\n       it. With effects off the dashes stay, and so does the status line. */\n    &[data-indeterminate] {\n      background: repeating-linear-gradient(to right, var(--cy-accent) 0 6px, transparent 6px 10px);\n\n      &::after {\n        content: \"\";\n        position: absolute;\n        inset: 0;\n        /* Parked out of view until the sweep runs. */\n        background: linear-gradient(90deg, transparent, var(--cy-ink-hi) 50%, transparent) 150% 0 / 300% 100% no-repeat;\n        animation: var(--cy-fx-sweep) 1.6s linear infinite;\n      }\n    }\n  }\n\n  /* The percentage: a value, so the signal color. */\n  [data-skin=\"cyber\"] [data-kit=\"loader-value\"] {\n    grid-column: 2;\n    grid-row: 3;\n    margin-block-start: 8px;\n    font-size: var(--cy-text-xl);\n    font-weight: 500;\n    line-height: 1;\n    font-variant-numeric: tabular-nums;\n    color: var(--cy-signal);\n\n    &[data-indeterminate] {\n      display: none;\n    }\n  }\n\n  /* The status line, with a caret after it while the work goes on. It\n     keeps the height of the percentage beside it, so the row doesn't move\n     when the percentage comes and goes. */\n  [data-skin=\"cyber\"] [data-kit=\"loader-status\"] {\n    grid-column: 1;\n    grid-row: 4;\n    display: flex;\n    align-items: baseline;\n    gap: 4px;\n    min-width: 0;\n    min-height: var(--cy-text-xl);\n    margin-block-start: 8px;\n    font-family: var(--cy-mono);\n    font-size: var(--cy-text-xs);\n    line-height: 1.4;\n    letter-spacing: 0.04em;\n    color: var(--cy-ink-mute);\n\n    &::after {\n      content: \"\";\n      flex: none;\n      width: 6px;\n      height: 2px;\n      background: var(--cy-ink);\n      animation: var(--cy-fx-blink) 1s step-end infinite;\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"loader\"][data-state=\"indeterminate\"] [data-kit=\"loader-status\"] {\n    grid-column: 1 / -1;\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"loader\"][data-state=\"complete\"] [data-kit=\"loader-status\"] {\n    color: var(--cy-ink-hi);\n\n    &::after {\n      content: none;\n    }\n  }\n\n  /* A new phrase arrives with its channels slipping for a moment. */\n  [data-skin=\"cyber\"] [data-kit=\"loader-phrase\"] {\n    min-width: 0;\n    overflow-wrap: anywhere;\n    animation: var(--cy-fx-rgb) 240ms var(--cy-ease-snap) both;\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"loader-code\"] {\n    grid-column: 1 / -1;\n    grid-row: 5;\n    margin-block-start: 6px;\n    overflow: hidden;\n  }\n}\n",
      "type": "registry:file",
      "target": "@ui/cyber/loader.css"
    }
  ],
  "type": "registry:ui"
}
