{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "fader",
  "title": "Fader",
  "description": "A volume fader in decibels: linear or console taper, detents, a scale, reset, an editable value, silence at the bottom, horizontal or vertical.",
  "dependencies": [
    "@base-ui/react",
    "class-variance-authority"
  ],
  "registryDependencies": [
    "@audiocn/core",
    "@audiocn/use-audio-config",
    "@audiocn/db-scale"
  ],
  "files": [
    {
      "path": "components/ui/fader.tsx",
      "content": "\"use client\";\n\nimport { mergeProps } from \"@base-ui/react/merge-props\";\nimport { Slider as SliderPrimitive } from \"@base-ui/react/slider\";\nimport { useRender } from \"@base-ui/react/use-render\";\nimport { cva } from \"class-variance-authority\";\nimport {\n  createContext,\n  useCallback,\n  useContext,\n  useEffect,\n  useEffectEvent,\n  useLayoutEffect,\n  useMemo,\n  useRef,\n  useState,\n} from \"react\";\nimport type {\n  ComponentProps,\n  CSSProperties,\n  KeyboardEvent,\n  RefObject,\n} from \"react\";\n\nimport { DbScale } from \"@/components/ui/db-scale\";\nimport type { DbScaleProps } from \"@/components/ui/db-scale\";\nimport { useAudioConfig } from \"@/hooks/use-audio-config\";\nimport type { AudioSize } from \"@/hooks/use-audio-config\";\nimport { clamp, formatDb, SILENCE_DB } from \"@/lib/audio/decibels\";\nimport { resolveTaper } from \"@/lib/audio/taper\";\nimport type { TaperInput } from \"@/lib/audio/taper\";\nimport type { Orientation, Taper } from \"@/lib/audio/types\";\nimport { cn } from \"@/lib/utils\";\n\nconst DEFAULT_MIN_DB = -60;\nconst DEFAULT_MAX_DB = 6;\nconst POSITION_STEP = 0.0005;\nconst DETENT_SNAP = 0.012;\nconst PRECISION = 1e6;\nconst DEFAULT_DETENTS = [0];\nconst DB_SUFFIX = /db/iu;\nconst INFINITY_TEXT = /^-?(?:inf|infinity|∞)$/iu;\n\nexport type FaderChangeReason =\n  | \"drag\"\n  | \"track-press\"\n  | \"keyboard\"\n  | \"wheel\"\n  | \"reset\"\n  | \"input\";\n\nexport interface FaderChangeDetails {\n  reason: FaderChangeReason;\n  event?: Event;\n}\n\ninterface FaderContextValue {\n  ariaLabel?: string;\n  ariaLabelledBy?: string;\n  value: number;\n  position: number;\n  originPosition: number;\n  min: number;\n  max: number;\n  resetValue: number;\n  orientation: Orientation;\n  variant: \"default\" | \"console\";\n  size: AudioSize;\n  disabled: boolean;\n  taper: Taper;\n  format: (db: number) => string;\n  change: (db: number, details: FaderChangeDetails) => void;\n  commit: (db: number) => void;\n  handleKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void;\n}\n\nconst FaderContext = createContext<FaderContextValue | null>(null);\n\nconst useFader = (part: string) => {\n  const context = useContext(FaderContext);\n  if (!context) {\n    throw new Error(`${part} must be used inside Fader.`);\n  }\n  return context;\n};\n\nconst defaultFormat = (db: number) =>\n  db === SILENCE_DB ? \"Silent\" : formatDb(db);\n\nconst roundValue = (value: number) => Math.round(value * PRECISION) / PRECISION;\n\n/** A ref that always holds the latest value, for event handlers. */\nconst useLatest = <T,>(value: T): RefObject<T> => {\n  const ref = useRef(value);\n  useLayoutEffect(() => {\n    ref.current = value;\n  });\n  return ref;\n};\n\nexport const FaderLabel = ({\n  className,\n  ...props\n}: SliderPrimitive.Label.Props) => (\n  <SliderPrimitive.Label\n    className={cn(\"text-sm font-medium\", className)}\n    data-slot=\"fader-label\"\n    {...props}\n  />\n);\n\nexport const FaderTrack = ({\n  className,\n  children,\n  ...props\n}: SliderPrimitive.Control.Props) => {\n  const { orientation } = useFader(\"FaderTrack\");\n  const horizontal = orientation === \"horizontal\";\n\n  return (\n    <SliderPrimitive.Control\n      className={cn(\n        \"relative flex min-h-0 min-w-0 items-center\",\n        horizontal\n          ? \"h-(--fader-thumb-size) w-full px-[calc(var(--fader-thumb-size)/2)] before:absolute before:inset-x-0 before:-inset-y-1.5 pointer-coarse:before:-inset-y-3\"\n          : \"h-full w-(--fader-thumb-size) flex-col py-[calc(var(--fader-thumb-size)/2)] before:absolute before:-inset-x-1.5 before:inset-y-0 pointer-coarse:before:-inset-x-3\"\n      )}\n      data-slot=\"fader-control\"\n      {...props}\n    >\n      <SliderPrimitive.Track\n        className={cn(\n          \"bg-input/90 relative grow rounded-full\",\n          horizontal\n            ? \"h-(--fader-track-size) w-full\"\n            : \"h-full w-(--fader-track-size)\",\n          className\n        )}\n        data-slot=\"fader-track\"\n      >\n        {children}\n      </SliderPrimitive.Track>\n    </SliderPrimitive.Control>\n  );\n};\n\nexport const FaderRange = ({\n  className,\n  style,\n  ...props\n}: ComponentProps<\"div\">) => {\n  const { orientation, originPosition, position } = useFader(\"FaderRange\");\n  const start = Math.min(originPosition, position) * 100;\n  const end = Math.max(originPosition, position) * 100;\n\n  return (\n    <div\n      className={cn(\n        \"bg-primary absolute rounded-full\",\n        orientation === \"horizontal\"\n          ? \"inset-y-0 left-(--fader-range-start) w-(--fader-range-size)\"\n          : \"inset-x-0 bottom-(--fader-range-start) h-(--fader-range-size)\",\n        className\n      )}\n      data-slot=\"fader-range\"\n      style={\n        {\n          \"--fader-range-size\": `${end - start}%`,\n          \"--fader-range-start\": `${start}%`,\n          ...style,\n        } as CSSProperties\n      }\n      {...props}\n    />\n  );\n};\n\nconst thumbVariants = cva(\n  \"bg-background ring-foreground/15 hover:ring-ring/30 focus-visible:ring-ring/40 data-dragging:ring-ring/30 block shrink-0 shadow-sm ring-1 outline-hidden transition-[box-shadow] hover:ring-4 focus-visible:ring-4 data-disabled:pointer-events-none data-dragging:ring-4\",\n  {\n    compoundVariants: [\n      {\n        className:\n          \"h-[calc(var(--fader-thumb-size)*1.6)] w-[calc(var(--fader-thumb-size)*0.7)] bg-[linear-gradient(to_right,transparent_calc(50%-0.5px),var(--foreground)_calc(50%-0.5px),var(--foreground)_calc(50%+0.5px),transparent_calc(50%+0.5px))]\",\n        orientation: \"horizontal\",\n        variant: \"console\",\n      },\n      {\n        className:\n          \"h-[calc(var(--fader-thumb-size)*0.7)] w-[calc(var(--fader-thumb-size)*1.8)] bg-[linear-gradient(to_bottom,transparent_calc(50%-0.5px),var(--foreground)_calc(50%-0.5px),var(--foreground)_calc(50%+0.5px),transparent_calc(50%+0.5px))]\",\n        orientation: \"vertical\",\n        variant: \"console\",\n      },\n    ],\n    defaultVariants: {\n      orientation: \"horizontal\",\n      variant: \"default\",\n    },\n    variants: {\n      orientation: {\n        horizontal: \"\",\n        vertical: \"\",\n      },\n      variant: {\n        console: \"border-border rounded-sm border\",\n        default: \"size-(--fader-thumb-size) rounded-full\",\n      },\n    },\n  }\n);\n\nexport type FaderThumbProps = Omit<\n  SliderPrimitive.Thumb.Props,\n  \"getAriaValueText\" | \"onKeyDown\"\n>;\n\nexport const FaderThumb = ({\n  className,\n  onDoubleClick,\n  ...props\n}: FaderThumbProps) => {\n  const {\n    ariaLabel,\n    ariaLabelledBy,\n    change,\n    commit,\n    format,\n    handleKeyDown,\n    orientation,\n    resetValue,\n    value,\n    variant,\n  } = useFader(\"FaderThumb\");\n\n  return (\n    <SliderPrimitive.Thumb\n      aria-label={ariaLabel}\n      aria-labelledby={ariaLabelledBy}\n      className={cn(thumbVariants({ orientation, variant }), className)}\n      data-slot=\"fader-thumb\"\n      getAriaValueText={() => format(value)}\n      onDoubleClick={(event) => {\n        onDoubleClick?.(event);\n        change(resetValue, { event: event.nativeEvent, reason: \"reset\" });\n        commit(resetValue);\n      }}\n      onKeyDown={handleKeyDown}\n      {...props}\n    />\n  );\n};\n\nexport type FaderScaleProps = Omit<\n  DbScaleProps,\n  \"minDb\" | \"maxDb\" | \"taper\" | \"orientation\"\n>;\n\nexport const FaderScale = ({ className, ...props }: FaderScaleProps) => {\n  const { max, min, orientation, taper } = useFader(\"FaderScale\");\n  const horizontal = orientation === \"horizontal\";\n\n  return (\n    <div\n      className={cn(\n        horizontal\n          ? \"px-[calc(var(--fader-thumb-size)/2)]\"\n          : \"py-[calc(var(--fader-thumb-size)/2)]\",\n        className\n      )}\n      data-slot=\"fader-scale\"\n    >\n      <DbScale\n        maxDb={max}\n        minDb={min}\n        orientation={orientation}\n        taper={taper}\n        {...props}\n      />\n    </div>\n  );\n};\n\nconst parseDb = (text: string): number | null => {\n  const normalized = text.replaceAll(\"−\", \"-\").replace(DB_SUFFIX, \"\").trim();\n  if (INFINITY_TEXT.test(normalized)) {\n    return SILENCE_DB;\n  }\n  if (normalized === \"\") {\n    return null;\n  }\n  const parsed = Number(normalized);\n  return Number.isNaN(parsed) ? null : parsed;\n};\n\nexport interface FaderValueProps extends ComponentProps<\"span\"> {\n  /** Click to type a value. Default false. */\n  editable?: boolean;\n}\n\n/** Levels whose text is as wide as any a fader shows: two digits either side of 0. */\nconst WIDTH_SAMPLES_DB = [-88.8, -8.8, 8.8, 88.8];\n\n/** Characters in the widest value this fader can show. */\nconst widestValue = (\n  format: (db: number) => string,\n  min: number,\n  max: number\n) =>\n  Math.max(\n    ...[\n      SILENCE_DB,\n      min,\n      min + 0.1,\n      max,\n      max - 0.1,\n      ...WIDTH_SAMPLES_DB.filter((db) => db > min && db < max),\n    ].map((db) => format(db).length)\n  );\n\nexport const FaderValue = ({\n  editable = false,\n  className,\n  style,\n  ...props\n}: FaderValueProps) => {\n  const { change, commit, disabled, format, max, min, value } =\n    useFader(\"FaderValue\");\n  // A fixed width, so moving the fader never shifts the layout around it.\n  const widthStyle = {\n    \"--fader-value-width\": `${widestValue(format, min, max)}ch`,\n    ...style,\n  } as CSSProperties;\n  const [editing, setEditing] = useState(false);\n  const [draft, setDraft] = useState(\"\");\n  const focusInput = useCallback((node: HTMLInputElement | null) => {\n    node?.focus();\n    node?.select();\n  }, []);\n\n  const finish = (apply: boolean) => {\n    setEditing(false);\n    if (!apply) {\n      return;\n    }\n    const parsed = parseDb(draft);\n    if (parsed === null) {\n      return;\n    }\n    const next = parsed === SILENCE_DB ? min : clamp(parsed, min, max);\n    change(next, { reason: \"input\" });\n    commit(next);\n  };\n\n  if (editing) {\n    return (\n      <input\n        aria-label=\"Value in dB\"\n        className={cn(\n          \"bg-background focus-visible:ring-ring/30 h-6 w-[calc(var(--fader-value-width)+0.75rem)] rounded-md border px-[calc(0.375rem-1px)] text-end font-mono text-xs tabular-nums outline-none focus-visible:ring-3\",\n          className\n        )}\n        data-slot=\"fader-value-input\"\n        onBlur={() => finish(true)}\n        onChange={(event) => setDraft(event.target.value)}\n        onKeyDown={(event) => {\n          if (event.key === \"Enter\") {\n            finish(true);\n          } else if (event.key === \"Escape\") {\n            finish(false);\n          }\n        }}\n        ref={focusInput}\n        style={widthStyle}\n        value={draft}\n      />\n    );\n  }\n\n  const text = format(value);\n\n  if (editable) {\n    return (\n      <button\n        className={cn(\n          \"text-muted-foreground hover:bg-muted focus-visible:ring-ring/30 h-6 w-[calc(var(--fader-value-width)+0.75rem)] shrink-0 rounded-md text-end font-mono text-xs tabular-nums outline-none focus-visible:ring-3\",\n          \"px-1.5\",\n          className\n        )}\n        data-slot=\"fader-value\"\n        disabled={disabled}\n        onClick={() => {\n          setDraft(value === SILENCE_DB ? \"-inf\" : String(value));\n          setEditing(true);\n        }}\n        style={widthStyle}\n        type=\"button\"\n      >\n        {text}\n      </button>\n    );\n  }\n\n  return (\n    <span\n      className={cn(\n        \"text-muted-foreground inline-block w-(--fader-value-width) shrink-0 text-end font-mono text-xs whitespace-nowrap tabular-nums\",\n        className\n      )}\n      data-slot=\"fader-value\"\n      style={widthStyle}\n      {...props}\n    >\n      {text}\n    </span>\n  );\n};\n\nexport type FaderResetProps = useRender.ComponentProps<\"button\">;\n\nexport const FaderReset = ({\n  render,\n  className,\n  children,\n  ...props\n}: FaderResetProps) => {\n  const { change, commit, disabled, resetValue, value } =\n    useFader(\"FaderReset\");\n  const modified = value !== resetValue;\n\n  return useRender({\n    defaultTagName: \"button\",\n    props: mergeProps<\"button\">(\n      {\n        \"aria-label\": \"Reset\",\n        children: children ?? \"Reset\",\n        className: cn(\n          \"text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:ring-ring/30 inline-flex h-6 items-center rounded-md px-1.5 text-xs outline-none focus-visible:ring-3 disabled:pointer-events-none disabled:opacity-0\",\n          className\n        ),\n        disabled: disabled || !modified,\n        onClick: () => {\n          change(resetValue, { reason: \"reset\" });\n          commit(resetValue);\n        },\n        type: \"button\",\n      },\n      props\n    ),\n    render,\n    state: {\n      modified,\n      slot: \"fader-reset\",\n    },\n  });\n};\n\nconst faderVariants = cva(\n  \"group/fader relative flex touch-none gap-2 select-none data-disabled:opacity-50\",\n  {\n    defaultVariants: {\n      orientation: \"horizontal\",\n      size: \"default\",\n    },\n    variants: {\n      orientation: {\n        horizontal: \"w-full flex-col\",\n        vertical: \"h-full min-h-32 flex-row justify-center\",\n      },\n      size: {\n        default: \"[--fader-thumb-size:1rem] [--fader-track-size:0.25rem]\",\n        lg: \"[--fader-thumb-size:1.25rem] [--fader-track-size:0.375rem]\",\n        sm: \"[--fader-thumb-size:0.75rem] [--fader-track-size:0.1875rem]\",\n      },\n    },\n  }\n);\n\ntype SliderRootProps = SliderPrimitive.Root.Props<number>;\n\nexport interface FaderProps extends Omit<\n  SliderRootProps,\n  | \"value\"\n  | \"defaultValue\"\n  | \"onValueChange\"\n  | \"onValueCommitted\"\n  | \"min\"\n  | \"max\"\n  | \"step\"\n  | \"largeStep\"\n  | \"format\"\n  | \"orientation\"\n> {\n  /** The value in dB. */\n  value?: number;\n  defaultValue?: number;\n  onValueChange?: (value: number, details: FaderChangeDetails) => void;\n  /** Fires when a drag ends, after keyboard input, and on reset. */\n  onValueCommitted?: (value: number) => void;\n  /** Bottom of the range in dB. Default −60. */\n  min?: number;\n  /** Top of the range in dB. Default +6. */\n  max?: number;\n  /** Arrow keys and drag resolution in dB. Default 0.5. */\n  step?: number;\n  /** Shift+arrow and Page Up/Down, in dB. Default 6. */\n  largeStep?: number;\n  /** Alt+arrow and Alt+drag resolution, in dB. Default 0.1. */\n  fineStep?: number;\n  /** Value restored by double-clicking the thumb. Default 0. */\n  resetValue?: number;\n  /** Position law. Default `linear`. */\n  taper?: TaperInput;\n  /** Where the range fill starts. Set 0 for a bipolar gain. Default `min`. */\n  origin?: number;\n  /** Values the thumb snaps to while dragging. Default `[0]`. */\n  detents?: number[];\n  /** The bottom position reports `-Infinity`. Default false. */\n  silenceAtMin?: boolean;\n  /** The mouse wheel adjusts the value while the fader is focused. Default false. */\n  allowWheel?: boolean;\n  orientation?: Orientation;\n  /** `console` has a wide cap thumb. Default `default`. */\n  variant?: \"default\" | \"console\";\n  size?: AudioSize;\n  /** Formats the value for `FaderValue` and assistive technology. */\n  format?: (db: number) => string;\n}\n\ninterface FaderValueOptions {\n  value: number | undefined;\n  defaultValue: number | undefined;\n  resetValue: number;\n  min: number;\n  max: number;\n  onValueChange: FaderProps[\"onValueChange\"];\n  onValueCommitted: FaderProps[\"onValueCommitted\"];\n}\n\n/** Controlled or uncontrolled value, with change and commit callbacks. */\nconst useFaderValue = ({\n  value: valueProp,\n  defaultValue,\n  resetValue,\n  min,\n  max,\n  onValueChange,\n  onValueCommitted,\n}: FaderValueOptions) => {\n  const [uncontrolled, setUncontrolled] = useState(\n    defaultValue ?? clamp(resetValue, min, max)\n  );\n  const value = valueProp ?? uncontrolled;\n  const latestRef = useLatest(value);\n  const controlled = valueProp !== undefined;\n\n  const change = useCallback(\n    (db: number, details: FaderChangeDetails) => {\n      if (db === latestRef.current) {\n        return;\n      }\n      latestRef.current = db;\n      if (!controlled) {\n        setUncontrolled(db);\n      }\n      onValueChange?.(db, details);\n    },\n    [controlled, latestRef, onValueChange]\n  );\n\n  const commit = useCallback(\n    (db: number) => {\n      onValueCommitted?.(db);\n    },\n    [onValueCommitted]\n  );\n\n  return { change, commit, latestRef, value };\n};\n\ninterface FaderSteppingOptions {\n  min: number;\n  max: number;\n  step: number;\n  largeStep: number;\n  fineStep: number;\n  silenceAtMin: boolean;\n  detents: number[];\n  taper: TaperInput;\n  latestRef: RefObject<number>;\n  change: (db: number, details: FaderChangeDetails) => void;\n  commit: (db: number) => void;\n}\n\nconst incrementFor = (\n  event: { altKey: boolean; shiftKey: boolean },\n  step: number,\n  fineStep: number,\n  largeStep: number\n) => {\n  if (event.altKey) {\n    return fineStep;\n  }\n  return event.shiftKey ? largeStep : step;\n};\n\n/** Maps positions to dB and handles keyboard stepping. */\nconst useFaderStepping = ({\n  min,\n  max,\n  step,\n  largeStep,\n  fineStep,\n  silenceAtMin,\n  detents,\n  taper,\n  latestRef,\n  change,\n  commit,\n}: FaderSteppingOptions) => {\n  const taperFn = useMemo(\n    () => resolveTaper(taper, min, max),\n    [taper, min, max]\n  );\n\n  const toPosition = useCallback(\n    (db: number) => (db === SILENCE_DB ? 0 : taperFn.toPosition(db)),\n    [taperFn]\n  );\n\n  const quantize = useCallback(\n    (db: number, increment: number) => {\n      if (db === SILENCE_DB) {\n        return silenceAtMin ? SILENCE_DB : min;\n      }\n      const stepped = min + Math.round((db - min) / increment) * increment;\n      return roundValue(clamp(stepped, min, max));\n    },\n    [max, min, silenceAtMin]\n  );\n\n  const fromPosition = useCallback(\n    (position: number, fine: boolean) => {\n      if (silenceAtMin && position <= 0) {\n        return SILENCE_DB;\n      }\n      for (const detent of detents) {\n        if (Math.abs(position - toPosition(detent)) < DETENT_SNAP) {\n          return detent;\n        }\n      }\n      return quantize(taperFn.toValue(position), fine ? fineStep : step);\n    },\n    [detents, fineStep, quantize, silenceAtMin, step, taperFn, toPosition]\n  );\n\n  const nudge = useCallback(\n    (direction: number, increment: number) => {\n      const { current } = latestRef;\n      if (current === SILENCE_DB) {\n        return direction > 0 ? min : SILENCE_DB;\n      }\n      if (silenceAtMin && direction < 0 && current <= min) {\n        return SILENCE_DB;\n      }\n      return quantize(\n        current + direction * increment,\n        Math.min(increment, step)\n      );\n    },\n    [latestRef, min, quantize, silenceAtMin, step]\n  );\n\n  const handleKeyDown = useCallback(\n    (event: KeyboardEvent<HTMLInputElement>) => {\n      const increment = incrementFor(event, step, fineStep, largeStep);\n      const targets: Record<string, () => number> = {\n        ArrowDown: () => nudge(-1, increment),\n        ArrowLeft: () => nudge(-1, increment),\n        ArrowRight: () => nudge(1, increment),\n        ArrowUp: () => nudge(1, increment),\n        End: () => max,\n        Home: () => (silenceAtMin ? SILENCE_DB : min),\n        PageDown: () => nudge(-1, largeStep),\n        PageUp: () => nudge(1, largeStep),\n      };\n      const target = targets[event.key];\n      if (!target) {\n        return;\n      }\n      event.preventDefault();\n      const next = target();\n      change(next, { event: event.nativeEvent, reason: \"keyboard\" });\n      commit(next);\n    },\n    [change, commit, fineStep, largeStep, max, min, nudge, silenceAtMin, step]\n  );\n\n  return { fromPosition, handleKeyDown, nudge, taperFn, toPosition };\n};\n\n/** Mouse-wheel adjustment while focused, with a non-passive listener. */\nconst useFaderWheel = (\n  rootRef: RefObject<HTMLDivElement | null>,\n  enabled: boolean,\n  handlers: {\n    disabled: boolean;\n    fineStep: number;\n    step: number;\n    nudge: (direction: number, increment: number) => number;\n    change: (db: number, details: FaderChangeDetails) => void;\n    commit: (db: number) => void;\n  }\n) => {\n  const onWheel = useEffectEvent(\n    (event: globalThis.WheelEvent, root: HTMLDivElement) => {\n      const focused = root.contains(document.activeElement);\n      if (handlers.disabled || !focused || event.deltaY === 0) {\n        return;\n      }\n      event.preventDefault();\n      const next = handlers.nudge(\n        event.deltaY < 0 ? 1 : -1,\n        event.altKey ? handlers.fineStep : handlers.step\n      );\n      handlers.change(next, { event, reason: \"wheel\" });\n      handlers.commit(next);\n    }\n  );\n\n  useEffect(() => {\n    const root = rootRef.current;\n    if (!(root && enabled)) {\n      return;\n    }\n    const listener = (event: globalThis.WheelEvent) => {\n      onWheel(event, root);\n    };\n    root.addEventListener(\"wheel\", listener, { passive: false });\n    return () => {\n      root.removeEventListener(\"wheel\", listener);\n    };\n  }, [enabled, rootRef]);\n};\n\n/** Orientation, size and disabled, from props or the surrounding strip. */\nconst useControlSettings = (props: {\n  orientation?: Orientation;\n  size?: AudioSize;\n  disabled?: boolean;\n}) => {\n  const config = useAudioConfig();\n  return {\n    disabled: props.disabled ?? config.disabled ?? false,\n    orientation: props.orientation ?? config.orientation ?? \"horizontal\",\n    size: props.size ?? config.size ?? \"default\",\n  };\n};\n\nexport const Fader = ({\n  \"aria-label\": ariaLabel,\n  \"aria-labelledby\": ariaLabelledBy,\n  value: valueProp,\n  defaultValue,\n  onValueChange,\n  onValueCommitted,\n  min = DEFAULT_MIN_DB,\n  max = DEFAULT_MAX_DB,\n  step = 0.5,\n  largeStep = 6,\n  fineStep = 0.1,\n  resetValue = 0,\n  taper = \"linear\",\n  origin,\n  detents = DEFAULT_DETENTS,\n  silenceAtMin = false,\n  allowWheel = false,\n  orientation: orientationProp,\n  variant = \"default\",\n  size: sizeProp,\n  format = defaultFormat,\n  disabled: disabledProp,\n  className,\n  children,\n  ref,\n  ...props\n}: FaderProps) => {\n  const { disabled, orientation, size } = useControlSettings({\n    disabled: disabledProp,\n    orientation: orientationProp,\n    size: sizeProp,\n  });\n  const { change, commit, latestRef, value } = useFaderValue({\n    defaultValue,\n    max,\n    min,\n    onValueChange,\n    onValueCommitted,\n    resetValue,\n    value: valueProp,\n  });\n  const { fromPosition, handleKeyDown, nudge, taperFn, toPosition } =\n    useFaderStepping({\n      change,\n      commit,\n      detents,\n      fineStep,\n      largeStep,\n      latestRef,\n      max,\n      min,\n      silenceAtMin,\n      step,\n      taper,\n    });\n\n  const rootRef = useRef<HTMLDivElement | null>(null);\n  useFaderWheel(rootRef, allowWheel, {\n    change,\n    commit,\n    disabled,\n    fineStep,\n    nudge,\n    step,\n  });\n\n  const setRootRef = useCallback(\n    (node: HTMLDivElement | null) => {\n      rootRef.current = node;\n      if (typeof ref === \"function\") {\n        ref(node);\n      } else if (ref) {\n        ref.current = node;\n      }\n    },\n    [ref]\n  );\n\n  const position = toPosition(value);\n  const originPosition = toPosition(clamp(origin ?? min, min, max));\n\n  const contextValue = useMemo<FaderContextValue>(\n    () => ({\n      ariaLabel,\n      ariaLabelledBy,\n      change,\n      commit,\n      disabled,\n      format,\n      handleKeyDown,\n      max,\n      min,\n      orientation,\n      originPosition,\n      position,\n      resetValue,\n      size,\n      taper: taperFn,\n      value,\n      variant,\n    }),\n    [\n      ariaLabel,\n      ariaLabelledBy,\n      change,\n      commit,\n      disabled,\n      format,\n      handleKeyDown,\n      max,\n      min,\n      orientation,\n      originPosition,\n      position,\n      resetValue,\n      size,\n      taperFn,\n      value,\n      variant,\n    ]\n  );\n\n  return (\n    <FaderContext.Provider value={contextValue}>\n      <SliderPrimitive.Root\n        className={cn(faderVariants({ orientation, size }), className)}\n        data-at-detent={detents.includes(value) ? \"\" : undefined}\n        data-silent={value === SILENCE_DB ? \"\" : undefined}\n        data-size={size}\n        data-slot=\"fader\"\n        data-variant={variant}\n        disabled={disabled}\n        max={1}\n        min={0}\n        onValueChange={(next, details) => {\n          const fine =\n            \"altKey\" in details.event &&\n            Boolean((details.event as MouseEvent).altKey);\n          const reason: FaderChangeReason =\n            details.reason === \"track-press\" ? \"track-press\" : \"drag\";\n          change(fromPosition(next, fine), { event: details.event, reason });\n        }}\n        onValueCommitted={() => {\n          commit(latestRef.current);\n        }}\n        orientation={orientation}\n        ref={setRootRef}\n        step={POSITION_STEP}\n        value={position}\n        {...props}\n      >\n        {children ?? (\n          <FaderTrack>\n            <FaderRange />\n            <FaderThumb />\n          </FaderTrack>\n        )}\n      </SliderPrimitive.Root>\n    </FaderContext.Provider>\n  );\n};\n\nexport { faderVariants };\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}