{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "components-color-picker",
  "type": "registry:component",
  "title": "Color picker",
  "description": "A swatch that opens the saturation, hue and alpha rails",
  "author": "sudo-kw <https://github.com/sudo-kw>",
  "dependencies": [
    "@gpuix/native@0.11.0",
    "@gpuix/react@0.11.0",
    "effect@4.1.2",
    "react@^19.2.4"
  ],
  "registryDependencies": [
    "https://gpuixui.sudokw.com/gpuix-icons.json",
    "https://gpuixui.sudokw.com/gpuix-motion.json",
    "https://gpuixui.sudokw.com/gpuix-primitives.json",
    "https://gpuixui.sudokw.com/gpuix-tokens.json",
    "https://gpuixui.sudokw.com/gpuix-tw.json"
  ],
  "files": [
    {
      "path": "packages/components/src/color-picker.tsx",
      "target": "@ui/gpuixui/components/color-picker.tsx",
      "type": "registry:component",
      "content": "/** @jsxImportSource @gpuix/react */\nimport type { KeyEvent, Props, PublicInstance } from \"@gpuix/react\";\nimport { useGpuix, useWindowSize } from \"@gpuix/react\";\nimport {\n  mergeStyles,\n  resolveStyle,\n  type StateStyle,\n} from \"@gpuix/react/floating\";\nimport { accessibleName } from \"../primitives/core/index.js\";\nimport { IconButton } from \"../primitives/button.js\";\nimport { Icon } from \"../icons/index.js\";\nimport { Input } from \"../primitives/components/Input.js\";\nimport {\n  cn,\n  COLOR_PICKER_FIELD,\n  COLOR_PICKER_INPUT,\n  COLOR_PICKER_PANEL,\n  COLOR_PICKER_TRIGGER,\n} from \"../tw/index.js\";\nimport * as Option from \"effect/Option\";\nimport { useCallback, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport { textOf } from \"./internal/text.js\";\nimport { isDismiss } from \"./internal/key.js\";\nimport { recipeStyle } from \"./internal/recipe.js\";\nimport {\n  controlRing,\n  disabledFade,\n  textStyle,\n  useTheme,\n} from \"./internal/theme.js\";\nimport {\n  DEFAULT_COLOR_PICKER_LABEL,\n  DEFAULT_COLOUR,\n  Hsva,\n  parseColor,\n  storedDraft,\n  storedSwatches,\n  toHex,\n} from \"./color-picker/logic.js\";\nimport {\n  AlphaSlider,\n  ColorArea,\n  ColorChip,\n  ContrastReadout,\n  HueSlider,\n  PresetRow,\n} from \"./color-picker/parts.js\";\nimport { Popover, PopoverContent, PopoverTrigger } from \"./popover.js\";\n\nconst PANEL_WIDTH = 304;\nconst WINDOW_GUTTER = 32;\n\nexport interface ColorPickerProps extends Omit<\n  Props,\n  \"children\" | \"style\" | \"onChange\"\n> {\n  readonly label: string;\n\n  readonly value?: string;\n\n  readonly defaultValue?: string;\n\n  readonly onValueChange?: (hex: string) => void;\n\n  readonly background?: string;\n\n  readonly swatches?: ReadonlyArray<string>;\n  readonly disabled?: boolean;\n\n  readonly className?: string;\n\n  readonly style?: StateStyle<ColorPickerState>;\n}\n\nexport interface ColorPickerState {\n  readonly disabled: boolean;\n  readonly valid: boolean;\n}\n\nconst defaultSwatches = (colors: {\n  readonly primary: string;\n  readonly secondary: string;\n  readonly accent: string;\n  readonly muted: string;\n  readonly destructive: string;\n  readonly foreground: string;\n}): ReadonlyArray<string> => [\n  colors.primary,\n  colors.secondary,\n  colors.accent,\n  colors.muted,\n  colors.destructive,\n  colors.foreground,\n];\n\nconst initialOf = (colour: string | undefined): Hsva =>\n  Option.getOrElse(\n    parseColor(colour ?? DEFAULT_COLOUR),\n    () => new Hsva({ h: 0, s: 0, v: 0, a: 1 }),\n  );\n\nexport const ColorPicker = ({\n  label,\n  value,\n  defaultValue = DEFAULT_COLOUR,\n  onValueChange,\n  background,\n  swatches: swatchesProp,\n  disabled = false,\n  className,\n  style,\n  testId,\n  ...rest\n}: ColorPickerProps) => {\n  const theme = useTheme();\n  const window = useWindowSize();\n  const { renderer } = useGpuix();\n  const panel = useRef<PublicInstance | null>(null);\n  const area = useRef<PublicInstance | null>(null);\n\n  const stops = useRef<Array<PublicInstance | null>>([]);\n  const stop = useMemo(\n    () =>\n      Array.from(\n        { length: 32 },\n        (_, index) =>\n          (instance: PublicInstance | null): void => {\n            stops.current[index] = instance;\n          },\n      ),\n    [],\n  );\n  const setArea = useMemo(\n    () =>\n      (instance: PublicInstance | null): void => {\n        area.current = instance;\n        stops.current[1] = instance;\n      },\n    [],\n  );\n  const setPreset = useCallback(\n    (index: number, instance: PublicInstance | null): void => {\n      stops.current[5 + index] = instance;\n    },\n    [],\n  );\n\n  const name = accessibleName(textOf(label)) ?? DEFAULT_COLOR_PICKER_LABEL;\n  const [hsva, setHsva] = useState<Hsva>(() => initialOf(defaultValue));\n  const [open, setOpen] = useState(false);\n  const [draft, setDraft] = useState<string | undefined>(undefined);\n  const [invalid, setInvalid] = useState(false);\n  const seen = useRef<Option.Option<string>>(Option.none());\n\n  const storedValue = Option.getOrUndefined(storedDraft(value));\n  useLayoutEffect(() => {\n    if (storedValue === undefined) return;\n    const same = Option.exists(seen.current, (last) => last === storedValue);\n    seen.current = Option.some(storedValue);\n    if (same) return;\n    if (storedValue === toHex(hsva)) return;\n    Option.match(parseColor(storedValue, hsva.h), {\n      onNone: () => undefined,\n      onSome: setHsva,\n    });\n  }, [storedValue, hsva]);\n\n  const swatches = Option.getOrElse(storedSwatches(swatchesProp), () =>\n    defaultSwatches(theme.colors),\n  );\n  const hex = toHex(hsva);\n  const field = draft ?? hex;\n  const surface = background ?? theme.colors.background;\n  const state: ColorPickerState = { disabled, valid: !invalid };\n\n  const commit = (next: Hsva): void => {\n    if (disabled) return;\n    const value = toHex(next);\n    setHsva(next);\n    if (value !== hex) onValueChange?.(value);\n  };\n\n  const commitDraft = (): void => {\n    if (disabled || draft === undefined) return;\n    Option.match(parseColor(draft, hsva.h), {\n      onNone: () => setInvalid(true),\n      onSome: (next) => {\n        setDraft(undefined);\n        setInvalid(false);\n        commit(next);\n      },\n    });\n  };\n\n  const greeted = useRef(false);\n  useLayoutEffect(() => {\n    if (!open) greeted.current = false;\n  }, [open]);\n\n  const focusStep = (delta: -1 | 1): void => {\n    const ids = stops.current.flatMap((entry) =>\n      entry === null ? [] : [entry.id],\n    );\n    if (ids.length === 0) return;\n    const current = renderer?.getFocusedElementId?.() ?? -1;\n    const at = ids.indexOf(current);\n    const index =\n      at < 0\n        ? delta > 0\n          ? 0\n          : ids.length - 1\n        : (at + delta + ids.length) % ids.length;\n    const next = ids[index];\n    if (next !== undefined) renderer?.focusElement?.(next);\n  };\n\n  const close = (): void => setOpen(false);\n\n  return (\n    <Popover open={open} onOpenChange={setOpen}>\n      <PopoverTrigger\n        {...rest}\n        testId={testId}\n        label={name}\n        disabled={disabled}\n        className={cn(COLOR_PICKER_TRIGGER, className)}\n        style={mergeStyles(\n          { height: theme.spacing[\"3xl\"] + theme.spacing.lg },\n          resolveStyle(style, state),\n        )}\n      >\n        <ColorChip\n          hsva={hsva}\n          size={theme.iconSize.xl + theme.spacing.xs}\n          testId={testId === undefined ? undefined : `${testId}-swatch`}\n        />\n        <div\n          style={{\n            display: \"flex\",\n            flexDirection: \"column\",\n            minWidth: 0,\n            textAlign: \"start\",\n          }}\n        >\n          <text\n            style={{\n              ...textStyle(theme, \"caption\"),\n              color: theme.colors.mutedForeground,\n            }}\n          >\n            {name}\n          </text>\n          <text style={{ ...textStyle(theme, \"bodyStrong\") }}>{hex}</text>\n        </div>\n      </PopoverTrigger>\n      <PopoverContent\n        ref={panel}\n        testId={testId === undefined ? undefined : `${testId}-panel`}\n        side=\"bottom\"\n        align=\"start\"\n        sideOffset={6}\n        className={COLOR_PICKER_PANEL}\n        style={{\n          width: Math.min(PANEL_WIDTH, window.width - WINDOW_GUTTER),\n          padding: theme.spacing.lg,\n          ...disabledFade(disabled),\n        }}\n      >\n        <div\n          onKeyDown={(event: KeyEvent) => {\n            if (event.key !== \"tab\") return;\n            event.preventDefault();\n            event.stopPropagation();\n            focusStep(event.modifiers?.shift === true ? -1 : 1);\n          }}\n          style={{\n            display: \"flex\",\n            flexDirection: \"column\",\n            gap: theme.spacing.lg,\n          }}\n        >\n          <div\n            style={{\n              display: \"flex\",\n              flexDirection: \"row\",\n              alignItems: \"center\",\n              gap: theme.spacing.sm,\n            }}\n          >\n            <ColorChip\n              hsva={hsva}\n              size={theme.iconSize.xl + theme.spacing.xs}\n            />\n            <div\n              style={{ display: \"flex\", flexDirection: \"column\", flexGrow: 1 }}\n            >\n              <text\n                style={{\n                  ...textStyle(theme, \"caption\"),\n                  color: theme.colors.mutedForeground,\n                }}\n              >\n                {name}\n              </text>\n              <text style={{ ...textStyle(theme, \"bodyStrong\") }}>{hex}</text>\n            </div>\n            <IconButton\n              ref={stop[0]}\n              label=\"Done\"\n              size=\"sm\"\n              testId={testId === undefined ? undefined : `${testId}-done`}\n              icon={\n                <Icon name=\"check\" size=\"md\" color={theme.colors.foreground} />\n              }\n              onActivate={close}\n            />\n          </div>\n\n          <ColorArea\n            ref={setArea}\n            onMeasured={() => {\n              if (!open || greeted.current) return;\n              greeted.current = true;\n              const id = area.current?.id;\n              if (id !== undefined) renderer?.focusElement?.(id);\n            }}\n            label={`${name} saturation and brightness`}\n            hsva={hsva}\n            disabled={disabled}\n            onChange={commit}\n            testId={testId === undefined ? undefined : `${testId}-area`}\n          />\n          <HueSlider\n            ref={stop[2]}\n            label={`${name} hue`}\n            hue={hsva.h}\n            disabled={disabled}\n            onChange={(hue) => commit(new Hsva({ ...hsva, h: hue }))}\n            testId={testId === undefined ? undefined : `${testId}-hue`}\n          />\n          <AlphaSlider\n            ref={stop[3]}\n            label={`${name} opacity`}\n            hsva={hsva}\n            disabled={disabled}\n            onChange={(alpha) => commit(new Hsva({ ...hsva, a: alpha }))}\n            testId={testId === undefined ? undefined : `${testId}-alpha`}\n          />\n\n          <div style={recipeStyle(COLOR_PICKER_FIELD, theme)}>\n            <Input\n              ref={stop[4]}\n              tabIndex={disabled ? -1 : 0}\n              label={`${name} hex value`}\n              testId={testId === undefined ? undefined : `${testId}-hex`}\n              value={field}\n              invalid={invalid}\n              disabled={disabled}\n              fullWidth\n              className={COLOR_PICKER_INPUT}\n              style={controlRing(theme, { disabled, invalid })}\n              onChange={(next: string) => {\n                setDraft(next);\n                setInvalid(false);\n              }}\n              onSubmit={() => commitDraft()}\n              onKeyDown={(event: KeyEvent) => {\n                if (isDismiss(event) && draft !== undefined) {\n                  setDraft(undefined);\n                  setInvalid(false);\n                }\n              }}\n              onBlur={() => {\n                if (invalid) {\n                  setDraft(undefined);\n                  setInvalid(false);\n                  return;\n                }\n                commitDraft();\n              }}\n            />\n          </div>\n          {invalid ? (\n            <text\n              testId={testId === undefined ? undefined : `${testId}-error`}\n              style={{\n                ...textStyle(theme, \"caption\"),\n                color: theme.colors.destructive,\n              }}\n            >\n              Enter a hex colour, such as #2F6BFF or #2F6BFF80\n            </text>\n          ) : undefined}\n\n          <ContrastReadout hsva={hsva} background={surface} />\n          <PresetRow\n            swatches={swatches}\n            value={hsva}\n            disabled={disabled}\n            onInstance={setPreset}\n            onSelect={(preset) => {\n              Option.match(parseColor(preset, hsva.h), {\n                onNone: () => undefined,\n                onSome: commit,\n              });\n            }}\n            testId={testId === undefined ? undefined : `${testId}-preset`}\n          />\n        </div>\n      </PopoverContent>\n    </Popover>\n  );\n};\n\nexport const colorPickerMeta = {\n  name: \"Color picker\",\n  tier: 2,\n  status: \"done\",\n  gpuixSupport: \"partial\",\n  limitations: [\n    \"no `transform`: the area's thumb is placed by the area's own measured box, not by a translated centre\",\n    \"a gradient is two stops: the area is three stacked fills and the hue rail six ramps; there is no radial or conic gradient\",\n    \"no repeating gradient: the alpha rail fades to the panel fill instead of painting a checkerboard\",\n    \"no screen sampling: the eyedropper is absent, not a button that reports nothing\",\n    \"hex is the only grammar; rgb(), hsl() and oklch() entry is not parsed\",\n    \"no `aria-roledescription` or `aria-valuenow`: the area announces saturation and brightness through `aria-valuetext`\",\n    \"presets are one `Button` per colour; there is no saved-palette add, delete or reorder\",\n    \"a blank label reads as `Color picker`, so the trigger and the field are always named\",\n  ],\n  docs: \"docs/color-picker.mdx\",\n  example: \"examples/color-picker.example.tsx\",\n  testFile: \"src/behaviour/color-picker.test.tsx\",\n} as const;\n"
    },
    {
      "path": "packages/components/src/color-picker/logic.ts",
      "target": "@ui/gpuixui/components/color-picker/logic.ts",
      "type": "registry:lib",
      "content": "import { contrastRatio } from \"../../tokens/index.js\";\nimport { pipe } from \"effect\";\nimport * as Arr from \"effect/Array\";\nimport * as Option from \"effect/Option\";\nimport * as P from \"effect/Predicate\";\nimport * as Schema from \"effect/Schema\";\nimport * as Str from \"effect/String\";\n\nexport class Hsva extends Schema.Class<Hsva>(\"Hsva\")({\n  h: Schema.Number,\n  s: Schema.Number,\n  v: Schema.Number,\n  a: Schema.Number,\n}) {}\n\nexport class OpaqueRgb extends Schema.Class<OpaqueRgb>(\"OpaqueRgb\")({\n  r: Schema.Number,\n  g: Schema.Number,\n  b: Schema.Number,\n}) {}\n\nexport type Grade = \"AAA\" | \"AA\" | \"AA large\" | \"Fails\";\n\nexport const DEFAULT_COLOUR = \"#000000\";\n\nexport const DEFAULT_COLOR_PICKER_LABEL = \"Color picker\";\n\nconst HEX_DIGITS = /^(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/;\n\nconst clamp = (value: number, min = 0, max = 1): number =>\n  Math.min(max, Math.max(min, value));\n\nconst round = (value: number, digits = 0): number => {\n  const factor = 10 ** digits;\n  return Math.round(value * factor) / factor;\n};\n\nconst byteOf = (channel: number): number => Math.round(clamp(channel) * 255);\n\nconst hexByte = (channel: number): string =>\n  byteOf(channel).toString(16).padStart(2, \"0\").toUpperCase();\n\nconst hexOf = ({ r, g, b }: OpaqueRgb): string =>\n  `#${hexByte(r)}${hexByte(g)}${hexByte(b)}`;\n\nexport const hsvToRgb = ({ h, s, v }: Hsva): OpaqueRgb => {\n  const channel = (n: number): number => {\n    const k = (n + h / 60) % 6;\n    return v - v * s * Math.max(0, Math.min(k, 4 - k, 1));\n  };\n  return new OpaqueRgb({ r: channel(5), g: channel(3), b: channel(1) });\n};\n\nexport const rgbToHsva = (\n  { r, g, b }: OpaqueRgb,\n  alpha: number,\n  hue = 0,\n): Hsva => {\n  const max = Math.max(r, g, b);\n  const min = Math.min(r, g, b);\n  const distance = max - min;\n  let h = hue;\n  if (distance > 1e-6) {\n    if (max === r) h = 60 * (((g - b) / distance) % 6);\n    else if (max === g) h = 60 * ((b - r) / distance + 2);\n    else h = 60 * ((r - g) / distance + 4);\n    if (h < 0) h += 360;\n  }\n  return new Hsva({ h, s: max === 0 ? 0 : distance / max, v: max, a: alpha });\n};\n\nexport const toHex = (hsva: Hsva): string =>\n  `${hexOf(hsvToRgb(hsva))}${hsva.a < 0.999 ? hexByte(hsva.a) : \"\"}`;\n\nexport const opaqueHex = (hsva: Hsva): string => hexOf(hsvToRgb(hsva));\n\nexport const parseColor = (input: string, hue = 0): Option.Option<Hsva> => {\n  const digits = pipe(Str.trim(input), Str.replace(/^#/, \"\"), Str.toLowerCase);\n  if (!HEX_DIGITS.test(digits)) return Option.none();\n  const expanded =\n    digits.length <= 4\n      ? pipe(\n          Str.split(\"\")(digits),\n          Arr.map((digit) => `${digit}${digit}`),\n          Arr.join(\"\"),\n        )\n      : digits;\n  const at = (index: number): number =>\n    Number.parseInt(expanded.slice(index, index + 2), 16) / 255;\n  const rgb = new OpaqueRgb({ r: at(0), g: at(2), b: at(4) });\n  return Option.some(rgbToHsva(rgb, expanded.length === 8 ? at(6) : 1, hue));\n};\n\nexport const sameColor = (left: string, right: string): boolean =>\n  pipe(\n    Option.all([parseColor(left), parseColor(right)]),\n    Option.exists(([a, b]) => toHex(a) === toHex(b)),\n  );\n\nexport const composite = (hsva: Hsva, background: Hsva): OpaqueRgb => {\n  const fg = hsvToRgb(hsva);\n  const bg = hsvToRgb(background);\n  const mix = (front: number, back: number): number =>\n    front * hsva.a + back * (1 - hsva.a);\n  return new OpaqueRgb({\n    r: mix(fg.r, bg.r),\n    g: mix(fg.g, bg.g),\n    b: mix(fg.b, bg.b),\n  });\n};\n\nexport const contrast = (\n  hsva: Hsva,\n  background: string,\n): Option.Option<number> =>\n  pipe(\n    parseColor(background),\n    Option.flatMap((parsed) =>\n      Option.fromNullishOr(\n        contrastRatio(hexOf(composite(hsva, parsed)), hexOf(hsvToRgb(parsed))),\n      ),\n    ),\n  );\n\nexport const grade = (ratio: number): Grade =>\n  ratio >= 7 ? \"AAA\" : ratio >= 4.5 ? \"AA\" : ratio >= 3 ? \"AA large\" : \"Fails\";\n\nexport const storedDraft = (value: unknown): Option.Option<string> =>\n  P.isString(value) ? Option.some(value) : Option.none();\n\nexport const storedSwatches = (\n  value: unknown,\n): Option.Option<ReadonlyArray<string>> =>\n  Arr.isArray(value)\n    ? Option.some(\n        pipe(\n          value,\n          Arr.filter(P.isString),\n          Arr.filter((entry) => Str.isNonEmpty(Str.trim(entry))),\n        ),\n      )\n    : Option.none();\n\nexport const HUE_STOPS = [\n  \"#FF0000\",\n  \"#FFFF00\",\n  \"#00FF00\",\n  \"#00FFFF\",\n  \"#0000FF\",\n  \"#FF00FF\",\n  \"#FF0000\",\n] as const;\n\nexport const hueFraction = (hue: number): number => round(clamp(hue / 360), 4);\n"
    },
    {
      "path": "packages/components/src/color-picker/parts.tsx",
      "target": "@ui/gpuixui/components/color-picker/parts.tsx",
      "type": "registry:component",
      "content": "/** @jsxImportSource @gpuix/react */\nimport type {\n  EventPayload,\n  KeyEvent,\n  PublicInstance,\n  StyleDesc,\n} from \"@gpuix/react\";\nimport { useGpuix } from \"@gpuix/react\";\nimport { mergeStyles } from \"@gpuix/react/floating\";\nimport { Button } from \"../../primitives/button.js\";\nimport { primaryButton } from \"../../primitives/core/index.js\";\nimport {\n  Slider,\n  SliderIndicator,\n  SliderThumb,\n  SliderTrack,\n} from \"../../primitives/slider.js\";\nimport {\n  COLOR_PICKER_AREA,\n  COLOR_PICKER_CELL,\n  COLOR_PICKER_CONTRAST,\n  COLOR_PICKER_ROW,\n  COLOR_PICKER_SWATCHES,\n} from \"../../tw/index.js\";\nimport * as Option from \"effect/Option\";\nimport { useMemo, useRef, useState, type Ref } from \"react\";\nimport { useMergedRef } from \"../internal/ref.js\";\nimport { recipeStyle } from \"../internal/recipe.js\";\nimport {\n  controlRing,\n  disabledFade,\n  statusTone,\n  textStyle,\n  useTheme,\n} from \"../internal/theme.js\";\nimport {\n  contrast,\n  grade,\n  HUE_STOPS,\n  Hsva,\n  opaqueHex,\n  sameColor,\n  toHex,\n  type Grade,\n} from \"./logic.js\";\n\nconst AREA_HEIGHT = 148;\n\nconst THUMB = 20;\n\nconst THUMB_RING = 3;\n\nconst AREA_STEP = 0.01;\nconst AREA_BIG_STEP = 0.1;\n\nconst clamp = (value: number, min = 0, max = 1): number =>\n  Math.min(max, Math.max(min, value));\n\nconst pureHue = (hue: number): string =>\n  opaqueHex(new Hsva({ h: hue, s: 1, v: 1, a: 1 }));\n\nconst ramp = (from: string, to: string, angle: number): StyleDesc => ({\n  background: {\n    type: \"linear-gradient\",\n    angle,\n    stops: [\n      { color: from, position: 0 },\n      { color: to, position: 1 },\n    ],\n  },\n});\n\nexport const areaLayers: ReadonlyArray<StyleDesc> = [\n  ramp(\"#FFFFFF\", \"#FFFFFF00\", 90),\n  ramp(\"#000000\", \"#00000000\", 0),\n];\n\nexport const hueLayers: ReadonlyArray<StyleDesc> = HUE_STOPS.slice(0, 6).map(\n  (stop, index) => ramp(stop, HUE_STOPS[index + 1] ?? stop, 90),\n);\n\nconst thumbStyle = (fill: string): StyleDesc => ({\n  width: THUMB,\n  height: THUMB,\n  backgroundColor: fill,\n  borderWidth: THUMB_RING,\n  borderColor: \"#FFFFFF\",\n  boxShadow: {\n    offsetX: 0,\n    offsetY: 1,\n    blurRadius: 4,\n    spreadRadius: 0,\n    color: \"#00000059\",\n  },\n});\n\nexport interface ColorChipProps {\n  readonly hsva: Hsva;\n  readonly size: number;\n  readonly testId?: string;\n}\n\nexport const ColorChip = ({ hsva, size, testId }: ColorChipProps) => {\n  const theme = useTheme();\n  return (\n    <div\n      testId={testId}\n      style={mergeStyles(recipeStyle(COLOR_PICKER_CELL, theme), {\n        width: size,\n        height: size,\n        flexShrink: 0,\n        backgroundColor: toHex(hsva),\n\n        pointerEvents: \"none\",\n      })}\n    />\n  );\n};\n\nexport interface ColorAreaProps {\n  readonly label: string;\n  readonly hsva: Hsva;\n  readonly disabled?: boolean;\n  readonly onChange: (next: Hsva) => void;\n  readonly testId?: string;\n  readonly ref?: Ref<PublicInstance>;\n\n  readonly onMeasured?: () => void;\n}\n\nexport const ColorArea = ({\n  label,\n  hsva,\n  disabled = false,\n  onChange,\n  testId,\n  ref,\n  onMeasured,\n}: ColorAreaProps) => {\n  const theme = useTheme();\n  const { renderer } = useGpuix();\n  const instance = useRef<PublicInstance | null>(null);\n  const setInstance = useMergedRef<PublicInstance | null>(instance, ref);\n  const dragging = useRef(false);\n  const [size, setSize] = useState<\n    { readonly width: number; readonly height: number } | undefined\n  >(undefined);\n\n  const read = (event: EventPayload): void => {\n    const id = instance.current?.id;\n    const box = id === undefined ? undefined : renderer?.getElementBounds?.(id);\n    if (box === null || box === undefined) return;\n    if (event.x === undefined || event.y === undefined) return;\n    onChange(\n      new Hsva({\n        ...hsva,\n        s: clamp((event.x - box.x) / box.width),\n        v: 1 - clamp((event.y - box.y) / box.height),\n      }),\n    );\n  };\n\n  const step = (event: KeyEvent): readonly [number, number] | undefined => {\n    const amount = event.modifiers?.shift === true ? AREA_BIG_STEP : AREA_STEP;\n    const key = event.key;\n    if (key === \"right\") return [amount, 0];\n    if (key === \"left\") return [-amount, 0];\n    if (key === \"up\") return [0, amount];\n    if (key === \"down\") return [0, -amount];\n    return undefined;\n  };\n\n  const left = size === undefined ? 0 : hsva.s * size.width - THUMB / 2;\n  const top = size === undefined ? 0 : (1 - hsva.v) * size.height - THUMB / 2;\n\n  return (\n    <div\n      ref={setInstance}\n      role=\"slider\"\n      aria-label={label}\n      aria-valuetext={`Saturation ${Math.round(hsva.s * 100)}%, brightness ${Math.round(hsva.v * 100)}%`}\n      tabIndex={disabled ? -1 : 0}\n      testId={testId}\n      onLayout={(event) => {\n        setSize({ width: event.width ?? 0, height: event.height ?? 0 });\n        onMeasured?.();\n      }}\n      onMouseDown={(event) => {\n        if (disabled || !primaryButton(event)) return;\n        dragging.current = true;\n        read(event);\n      }}\n      onMouseMove={(event) => {\n        if (disabled || !dragging.current) return;\n        if (event.pressedButton !== 0) {\n          dragging.current = false;\n          return;\n        }\n        read(event);\n      }}\n      onMouseUp={() => {\n        dragging.current = false;\n      }}\n      onKeyDown={(event) => {\n        const move = step(event);\n        if (disabled || move === undefined) return;\n        onChange(\n          new Hsva({\n            ...hsva,\n            s: clamp(hsva.s + move[0]),\n            v: clamp(hsva.v + move[1]),\n          }),\n        );\n      }}\n      style={mergeStyles(\n        mergeStyles(recipeStyle(COLOR_PICKER_AREA, theme), {\n          height: AREA_HEIGHT,\n          backgroundColor: pureHue(hsva.h),\n          cursor: disabled ? \"not-allowed\" : \"crosshair\",\n          ...disabledFade(disabled),\n        }),\n        controlRing(theme, { disabled }),\n      )}\n    >\n      {areaLayers.map((layer, index) => (\n        <div\n          key={index}\n          style={{\n            ...layer,\n            position: \"absolute\",\n            top: 0,\n            right: 0,\n            bottom: 0,\n            left: 0,\n            borderRadius: theme.radius.xl,\n            pointerEvents: \"none\",\n          }}\n        />\n      ))}\n      <div\n        testId={testId === undefined ? undefined : `${testId}-thumb`}\n        style={{\n          position: \"absolute\",\n          left,\n          top,\n          width: THUMB,\n          height: THUMB,\n          borderRadius: theme.radius.full,\n          backgroundColor: opaqueHex(hsva),\n          borderWidth: THUMB_RING,\n          borderColor: \"#FFFFFF\",\n          boxShadow: {\n            offsetX: 0,\n            offsetY: 2,\n            blurRadius: 8,\n            spreadRadius: 0,\n            color: \"#0000004D\",\n          },\n          pointerEvents: \"none\",\n        }}\n      />\n    </div>\n  );\n};\n\nexport interface HueSliderProps {\n  readonly label: string;\n  readonly hue: number;\n  readonly disabled?: boolean;\n  readonly onChange: (hue: number) => void;\n  readonly testId?: string;\n  readonly ref?: Ref<PublicInstance>;\n}\n\nexport const HueSlider = ({\n  label,\n  hue,\n  disabled = false,\n  onChange,\n  testId,\n  ref,\n}: HueSliderProps) => {\n  const theme = useTheme();\n  return (\n    <div style={recipeStyle(COLOR_PICKER_ROW, theme)}>\n      <Slider\n        ref={ref}\n        label={label}\n        disabled={disabled}\n        min={0}\n        max={360}\n        step={1}\n        value={Math.round(hue) % 360}\n        formatValue={(value) => `${Math.round(value)} degrees`}\n        onValueChange={(value) => onChange(value % 360)}\n        testId={testId}\n      >\n        <SliderTrack\n          style={{\n            position: \"relative\",\n            height: theme.spacing.md,\n            backgroundColor: \"transparent\",\n            borderRadius: theme.radius.full,\n            overflow: \"hidden\",\n          }}\n        >\n          {hueLayers.map((layer, index) => (\n            <div\n              key={index}\n              style={{\n                ...layer,\n                width: `${100 / hueLayers.length}%`,\n                height: \"100%\",\n                flexShrink: 0,\n                pointerEvents: \"none\",\n              }}\n            />\n          ))}\n          <SliderIndicator style={{ backgroundColor: \"transparent\" }} />\n          <SliderThumb style={thumbStyle(pureHue(hue))} />\n        </SliderTrack>\n      </Slider>\n    </div>\n  );\n};\n\nexport interface AlphaSliderProps {\n  readonly label: string;\n  readonly hsva: Hsva;\n  readonly disabled?: boolean;\n  readonly onChange: (alpha: number) => void;\n  readonly testId?: string;\n  readonly ref?: Ref<PublicInstance>;\n}\n\nexport const AlphaSlider = ({\n  label,\n  hsva,\n  disabled = false,\n  onChange,\n  testId,\n  ref,\n}: AlphaSliderProps) => {\n  const theme = useTheme();\n  const opaque = opaqueHex(hsva);\n  return (\n    <div style={recipeStyle(COLOR_PICKER_ROW, theme)}>\n      <Slider\n        ref={ref}\n        label={label}\n        disabled={disabled}\n        min={0}\n        max={100}\n        step={1}\n        value={Math.round(hsva.a * 100)}\n        formatValue={(value) => `${Math.round(value)}%`}\n        onValueChange={(value) => onChange(value / 100)}\n        testId={testId}\n      >\n        <SliderTrack\n          style={{\n            ...ramp(`${opaque}00`, opaque, 90),\n            position: \"relative\",\n            height: theme.spacing.md,\n            borderRadius: theme.radius.full,\n          }}\n        >\n          <SliderIndicator style={{ backgroundColor: \"transparent\" }} />\n          <SliderThumb style={thumbStyle(opaque)} />\n        </SliderTrack>\n      </Slider>\n    </div>\n  );\n};\n\nexport interface PresetSwatchProps {\n  readonly value: string;\n  readonly selected: boolean;\n  readonly disabled?: boolean;\n  readonly onSelect: (value: string) => void;\n  readonly testId?: string;\n  readonly ref?: Ref<PublicInstance>;\n}\n\nexport const PresetSwatch = ({\n  value,\n  selected,\n  disabled = false,\n  onSelect,\n  testId,\n  ref,\n}: PresetSwatchProps) => {\n  const theme = useTheme();\n  const size = theme.iconSize.xl;\n  return (\n    <Button\n      ref={ref}\n      testId={testId}\n      variant=\"ghost\"\n      size=\"sm\"\n      square\n      disabled={disabled}\n      label={value}\n      aria-selected={selected}\n      onActivate={() => onSelect(value)}\n      style={{\n        width: size,\n        height: size,\n        padding: 0,\n        borderRadius: theme.radius.full,\n        backgroundColor: value,\n        borderWidth: selected\n          ? theme.borderWidth.strong\n          : theme.borderWidth.thin,\n        borderColor: selected ? theme.colors.foreground : theme.colors.border,\n      }}\n    >\n      {selected ? (\n        <div\n          testId={testId === undefined ? undefined : `${testId}-marker`}\n          style={{\n            width: theme.spacing.sm,\n            height: theme.spacing.sm,\n            borderRadius: theme.radius.full,\n            backgroundColor: theme.colors.background,\n            borderWidth: theme.borderWidth.thin,\n            borderColor: theme.colors.foreground,\n          }}\n        />\n      ) : undefined}\n    </Button>\n  );\n};\n\nexport interface PresetRowProps {\n  readonly swatches: ReadonlyArray<string>;\n  readonly value: Hsva;\n  readonly disabled?: boolean;\n  readonly onSelect: (value: string) => void;\n  readonly testId?: string;\n\n  readonly onInstance?: (\n    index: number,\n    instance: PublicInstance | null,\n  ) => void;\n}\n\nexport const PresetRow = ({\n  swatches,\n  value,\n  disabled = false,\n  onSelect,\n  testId,\n  onInstance,\n}: PresetRowProps) => {\n  const theme = useTheme();\n  const current = toHex(value);\n\n  const refFor = useMemo(\n    () =>\n      swatches.map(\n        (_, index) => (instance: PublicInstance | null) =>\n          onInstance?.(index, instance),\n      ),\n    [swatches, onInstance],\n  );\n  return (\n    <div\n      role=\"group\"\n      aria-label=\"Preset colours\"\n      style={recipeStyle(COLOR_PICKER_SWATCHES, theme)}\n    >\n      {swatches.map((swatch, index) => (\n        <PresetSwatch\n          key={`${swatch}-${index}`}\n          value={swatch}\n          selected={sameColor(swatch, current)}\n          disabled={disabled}\n          onSelect={onSelect}\n          testId={testId === undefined ? undefined : `${testId}-${index}`}\n          ref={refFor[index]}\n        />\n      ))}\n    </div>\n  );\n};\n\nconst gradeTone = (value: Grade): \"success\" | \"warning\" | \"destructive\" =>\n  value === \"Fails\"\n    ? \"destructive\"\n    : value === \"AA large\"\n      ? \"warning\"\n      : \"success\";\n\nexport interface ContrastReadoutProps {\n  readonly hsva: Hsva;\n  readonly background: string;\n}\n\nexport const ContrastReadout = ({ hsva, background }: ContrastReadoutProps) => {\n  const theme = useTheme();\n  const measured = Option.getOrElse(contrast(hsva, background), () => 1);\n  const value = grade(measured);\n  const tone = statusTone(theme, gradeTone(value));\n\n  return (\n    <div style={recipeStyle(COLOR_PICKER_CONTRAST, theme)}>\n      <div\n        style={{\n          display: \"flex\",\n          alignItems: \"center\",\n          justifyContent: \"center\",\n          width: theme.spacing[\"3xl\"] + theme.spacing.xs,\n          height: theme.spacing[\"2xl\"] + theme.spacing.xs,\n          flexShrink: 0,\n          borderRadius: theme.radius.md,\n          borderWidth: theme.borderWidth.thin,\n          borderColor: theme.colors.border,\n          backgroundColor: background,\n          color: opaqueHex(hsva),\n        }}\n      >\n        <text style={{ ...textStyle(theme, \"label\") }}>Aa</text>\n      </div>\n      <text style={{ ...textStyle(theme, \"bodyStrong\") }}>\n        {`${measured.toFixed(2)}:1`}\n      </text>\n      <text\n        style={{\n          ...textStyle(theme, \"caption\"),\n          flexGrow: 1,\n          color: theme.colors.mutedForeground,\n        }}\n      >\n        against background\n      </text>\n      <div\n        style={{\n          paddingLeft: theme.spacing.sm,\n          paddingRight: theme.spacing.sm,\n          paddingTop: theme.spacing[\"2xs\"],\n          paddingBottom: theme.spacing[\"2xs\"],\n          borderRadius: theme.radius.full,\n          backgroundColor: tone.background,\n          color: tone.foreground,\n        }}\n      >\n        <text style={{ ...textStyle(theme, \"caption\") }}>{value}</text>\n      </div>\n    </div>\n  );\n};\n"
    },
    {
      "path": "packages/components/src/internal/clock.ts",
      "target": "@ui/gpuixui/components/internal/clock.ts",
      "type": "registry:lib",
      "content": "import { Effect } from \"effect\";\nimport * as Clock from \"effect/Clock\";\n\nexport const monotonicNanos = (): bigint =>\n  Effect.runSync(Clock.monotonicTimeNanos);\n\nexport const hoverDelay = (value: number, fallback: number): number =>\n  Number.isFinite(value) ? Math.max(0, value) : fallback;\n"
    },
    {
      "path": "packages/components/src/internal/controllable.ts",
      "target": "@ui/gpuixui/components/internal/controllable.ts",
      "type": "registry:lib",
      "content": "import { useCallback, useState } from \"react\";\n\nexport type ControllableState<Value> = readonly [Value, (next: Value) => void];\n\nexport interface ControllableStateOptions<Value> {\n  readonly value: Value | undefined;\n\n  readonly defaultValue: Value;\n\n  readonly onChange?: (next: Value) => void;\n}\n\nexport const useControllableState = <Value>({\n  value,\n  defaultValue,\n  onChange,\n}: ControllableStateOptions<Value>): ControllableState<Value> => {\n  const [internal, setInternal] = useState(defaultValue);\n  const controlled = value !== undefined;\n\n  const setValue = useCallback(\n    (next: Value) => {\n      if (!controlled) setInternal(next);\n      if (value !== next) onChange?.(next);\n    },\n    [controlled, value, onChange],\n  );\n\n  return [controlled ? value : internal, setValue];\n};\n"
    },
    {
      "path": "packages/components/src/internal/dismiss-layer.ts",
      "target": "@ui/gpuixui/components/internal/dismiss-layer.ts",
      "type": "registry:lib",
      "content": "import type { EventPayload } from \"@gpuix/react\";\nimport * as Arr from \"effect/Array\";\nimport * as Duration from \"effect/Duration\";\nimport * as Option from \"effect/Option\";\nimport * as Order from \"effect/Order\";\nimport { monotonicNanos } from \"./clock.js\";\n\nexport type DismissHandler = (event: EventPayload) => void;\n\ninterface Layer {\n  readonly onDismiss: DismissHandler;\n  readonly depth: number;\n}\n\nlet layers: ReadonlyArray<Layer> = [];\n\nlet dismissedKeystroke: Option.Option<number> = Option.none();\n\ninterface Press {\n  readonly shape: string;\n  readonly at: bigint;\n}\n\nlet dismissedPress: Option.Option<Press> = Option.none();\n\nexport const pointerGestureWindow: Duration.Duration = Duration.millis(64);\n\nconst PRESS_WINDOW_NANOS =\n  BigInt(Duration.toMillis(pointerGestureWindow)) * 1_000_000n;\n\nconst pressShape = (event: EventPayload): string =>\n  Arr.join(\":\")(\n    Arr.map(\n      [event.eventType, event.x, event.y, event.button, event.clickCount],\n      (part) => (part === undefined ? \"\" : `${part}`),\n    ),\n  );\n\nconst consumedPress = (event: EventPayload, now: bigint): boolean => {\n  const shape = pressShape(event);\n  const repeated = Option.exists(\n    dismissedPress,\n    (press) => press.shape === shape && now - press.at <= PRESS_WINDOW_NANOS,\n  );\n  if (!repeated) dismissedPress = Option.some({ shape, at: now });\n  return repeated;\n};\n\nlet lastDismissedPoint: Option.Option<{\n  readonly point: string;\n  readonly at: bigint;\n}> = Option.none();\n\nconst pointOf = (event: EventPayload): string =>\n  Arr.join(\":\")(\n    Arr.map([event.x, event.y, event.button], (part) =>\n      part === undefined ? \"\" : `${part}`,\n    ),\n  );\n\nexport const isDismissalClick = (\n  event: EventPayload,\n  now: bigint = monotonicNanos(),\n): boolean =>\n  Option.exists(\n    lastDismissedPoint,\n    (dismissed) =>\n      dismissed.point === pointOf(event) &&\n      now - dismissed.at <= PRESS_WINDOW_NANOS,\n  );\n\nconst consumedKeystroke = (keystrokeId: number): boolean => {\n  if (Option.contains(dismissedKeystroke, keystrokeId)) return true;\n  dismissedKeystroke = Option.some(keystrokeId);\n  return false;\n};\n\nconst consume = (event: EventPayload, now: bigint): boolean =>\n  Option.match(Option.fromNullishOr(event.keystrokeId), {\n    onNone: () => consumedPress(event, now),\n    onSome: consumedKeystroke,\n  });\n\nconst byDepth: Order.Order<Layer> = Order.mapInput(\n  Order.Number,\n  (layer: Layer) => layer.depth,\n);\n\nconst topmost = (): Option.Option<DismissHandler> =>\n  Option.map(Arr.last(Arr.sort(layers, byDepth)), (layer) => layer.onDismiss);\n\nexport const pushDismissLayer = (\n  onDismiss: DismissHandler,\n  depth: number,\n): (() => void) => {\n  const layer: Layer = { onDismiss, depth };\n  layers = Arr.append(layers, layer);\n  return () => {\n    layers = Arr.filter(layers, (candidate) => candidate !== layer);\n    if (Arr.length(layers) === 0) {\n      dismissedKeystroke = Option.none();\n      dismissedPress = Option.none();\n    }\n  };\n};\n\nexport const dismissTopLayer = (\n  event: EventPayload,\n  now: bigint = monotonicNanos(),\n): boolean => {\n  if (consume(event, now)) return false;\n  return Option.match(topmost(), {\n    onNone: () => false,\n    onSome: (onDismiss) => {\n      lastDismissedPoint = Option.some({ point: pointOf(event), at: now });\n      onDismiss(event);\n      return true;\n    },\n  });\n};\n\nexport const dismissLayerCount = (): number => Arr.length(layers);\n"
    },
    {
      "path": "packages/components/src/internal/dismiss-scope.tsx",
      "target": "@ui/gpuixui/components/internal/dismiss-scope.tsx",
      "type": "registry:component",
      "content": "/** @jsxImportSource @gpuix/react */\nimport { createContext, useContext, type ReactNode } from \"react\";\n\nconst AmbientDepth = createContext(0);\n\nexport const useDismissDepth = (): number => useContext(AmbientDepth) + 1;\n\nexport const DismissScope = ({\n  children,\n}: {\n  readonly children: ReactNode;\n}) => (\n  <AmbientDepth.Provider value={useDismissDepth()}>\n    {children}\n  </AmbientDepth.Provider>\n);\n"
    },
    {
      "path": "packages/components/src/internal/key.ts",
      "target": "@ui/gpuixui/components/internal/key.ts",
      "type": "registry:lib",
      "content": "import type { EventPayload, KeyEvent, Props } from \"@gpuix/react\";\nimport * as Option from \"effect/Option\";\n\nexport type KeyPhase = \"down\" | \"up\";\n\nexport const isActivation = (event: EventPayload, phase: KeyPhase): boolean => {\n  if (event.isHeld === true) return false;\n  if (event.key === \"enter\") return phase === \"down\";\n  return event.key === \"space\" && phase === \"up\";\n};\n\nexport const swallowsDefault = (\n  event: EventPayload,\n  phase: KeyPhase,\n): boolean => event.key === \"space\" && phase === \"down\";\n\nexport const activationHandlers = (\n  activate: (event: KeyEvent) => void,\n  observe: Pick<Props, \"onKeyDown\" | \"onKeyUp\"> = {},\n): Pick<Props, \"onKeyDown\" | \"onKeyUp\"> => ({\n  onKeyDown: (event: KeyEvent) => {\n    if (swallowsDefault(event, \"down\")) event.preventDefault();\n    if (isActivation(event, \"down\")) activate(event);\n    observe.onKeyDown?.(event);\n  },\n  onKeyUp: (event: KeyEvent) => {\n    if (isActivation(event, \"up\")) activate(event);\n    observe.onKeyUp?.(event);\n  },\n});\n\nexport const isEnter = (event: EventPayload): boolean => event.key === \"enter\";\n\nexport const isDown = (event: EventPayload): boolean =>\n  event.key === \"down\" || (event.key === \"n\" && event.modifiers?.ctrl === true);\n\nexport const isUp = (event: EventPayload): boolean =>\n  event.key === \"up\" || (event.key === \"p\" && event.modifiers?.ctrl === true);\n\nexport const isRight = (event: EventPayload): boolean => event.key === \"right\";\n\nexport const isLeft = (event: EventPayload): boolean => event.key === \"left\";\n\nexport const isFirst = (event: EventPayload): boolean => event.key === \"home\";\n\nexport const isLast = (event: EventPayload): boolean => event.key === \"end\";\n\nexport const isPageUp = (event: EventPayload): boolean =>\n  event.key === \"pageup\";\n\nexport const isPageDown = (event: EventPayload): boolean =>\n  event.key === \"pagedown\";\n\nexport const isDismiss = (event: EventPayload): boolean =>\n  event.key === \"escape\";\n\nexport const isTab = (event: EventPayload): boolean => event.key === \"tab\";\n\nexport const isSelectAll = (event: EventPayload): boolean =>\n  event.key === \"a\" &&\n  (event.modifiers?.cmd === true || event.modifiers?.ctrl === true);\n\nexport const isMenuKey = (event: EventPayload): boolean =>\n  (event.key === \"f10\" && event.modifiers?.shift === true) ||\n  event.key === \"contextmenu\";\n\nexport const axisDirection = (\n  event: EventPayload,\n  orientation: \"horizontal\" | \"vertical\",\n): Option.Option<1 | -1> => {\n  if (event.key === \"right\") return Option.some(1);\n  if (event.key === \"left\") return Option.some(-1);\n  if (orientation === \"vertical\") {\n    if (isDown(event)) return Option.some(1);\n    if (isUp(event)) return Option.some(-1);\n  }\n  return Option.none();\n};\n"
    },
    {
      "path": "packages/components/src/internal/overlay.ts",
      "target": "@ui/gpuixui/components/internal/overlay.ts",
      "type": "registry:lib",
      "content": "import type { StyleDesc } from \"@gpuix/react\";\nimport { cn } from \"../../tw/index.js\";\nimport * as Arr from \"effect/Array\";\nimport * as Option from \"effect/Option\";\nimport { recipeStyle } from \"./recipe.js\";\nimport {\n  alpha,\n  elevationShadow,\n  type BoxShadow,\n  type ElevationLevel,\n  type Theme,\n} from \"./theme.js\";\n\nexport const OVERLAY_WASH = 0.55;\n\nexport const overlayVeilColor = (theme: Theme): string =>\n  alpha(theme.colors.background, OVERLAY_WASH);\n\nconst isEdge = (shadow: BoxShadow): boolean =>\n  shadow.blurRadius === 0 && shadow.spreadRadius > 0;\n\nconst shadows = (painted: StyleDesc[\"boxShadow\"]): ReadonlyArray<BoxShadow> =>\n  Option.match(Option.fromNullishOr(painted), {\n    onNone: () => [],\n    onSome: (value) => Arr.ensure(value),\n  });\n\nexport const overlaySurfaceStyle = (\n  recipe: string,\n  className: string | undefined,\n  theme: Theme,\n  elevation?: ElevationLevel,\n): StyleDesc => {\n  const style = recipeStyle(cn(recipe, className), theme);\n  const lift = Option.fromNullishOr(elevation).pipe(\n    Option.flatMap((level) =>\n      Option.fromNullishOr(elevationShadow(theme, level)),\n    ),\n  );\n\n  return Option.match(lift, {\n    onNone: () => style,\n    onSome: (shadow) => {\n      const painted = shadows(style.boxShadow);\n      const lost = Arr.every(painted, isEdge) && painted.length > 0;\n      return lost ? { ...style, boxShadow: [shadow, ...painted] } : style;\n    },\n  });\n};\n"
    },
    {
      "path": "packages/components/src/internal/parts.ts",
      "target": "@ui/gpuixui/components/internal/parts.ts",
      "type": "registry:lib",
      "content": "import * as Arr from \"effect/Array\";\nimport * as P from \"effect/Predicate\";\nimport {\n  Children,\n  Fragment,\n  isValidElement,\n  type ReactElement,\n  type ReactNode,\n} from \"react\";\n\nexport type PartComponent = (props: never) => ReactNode;\n\nexport type PartChildren =\n  | ReactElement<unknown>\n  | boolean\n  | null\n  | undefined\n  | ReadonlyArray<PartChildren>;\n\nexport interface PartsContract {\n  readonly parent: string;\n\n  readonly family: ReadonlyArray<PartComponent>;\n\n  readonly accepts: ReadonlyArray<PartComponent>;\n\n  readonly hint?: string;\n}\n\nconst componentName = (type: unknown): string =>\n  P.isString(type)\n    ? type\n    : P.isFunction(type)\n      ? type.name || \"anonymous\"\n      : \"element\";\n\nconst fragmentChildren = (element: ReactElement<unknown>): ReactNode =>\n  hasChildren(element.props) ? element.props.children : undefined;\n\nconst hasChildren = (\n  value: unknown,\n): value is { readonly children?: ReactNode } =>\n  P.isObject(value) && \"children\" in value;\n\nconst leaves = (children: ReactNode): ReadonlyArray<unknown> =>\n  Arr.flatMap(Children.toArray(children), (child) =>\n    isValidElement<unknown>(child) && child.type === Fragment\n      ? leaves(fragmentChildren(child))\n      : [child],\n  );\n\nexport const assertParts = (\n  contract: PartsContract,\n  children: ReactNode,\n): void => {\n  Arr.forEach(leaves(children), (leaf) => {\n    if (!isValidElement(leaf)) return;\n    if (Arr.some(contract.accepts, (part) => part === leaf.type)) return;\n    if (!Arr.some(contract.family, (part) => part === leaf.type)) return;\n\n    throw new Error(\n      `${componentName(leaf.type)} cannot be used inside ${contract.parent}.` +\n        (contract.hint === undefined ? \"\" : ` ${contract.hint}`),\n    );\n  });\n};\n"
    },
    {
      "path": "packages/components/src/internal/placement.ts",
      "target": "@ui/gpuixui/components/internal/placement.ts",
      "type": "registry:lib",
      "content": "import type { FloatingAlign, FloatingSide } from \"@gpuix/react/floating\";\nimport { Match } from \"effect\";\nimport * as Schema from \"effect/Schema\";\n\nexport interface FloatingBounds {\n  readonly x: number;\n  readonly y: number;\n  readonly width: number;\n  readonly height: number;\n}\n\nexport interface WindowBounds {\n  readonly width: number;\n  readonly height: number;\n}\n\nexport interface PlacementInput {\n  readonly side: unknown;\n\n  readonly align: unknown;\n  readonly trigger: FloatingBounds;\n\n  readonly surface: FloatingBounds;\n  readonly window: WindowBounds;\n  readonly margin: number;\n}\n\nexport interface Placement {\n  readonly side: FloatingSide;\n  readonly align: FloatingAlign;\n  readonly alignOffset: number;\n}\n\nconst PlacementSide = Schema.Literals([\"top\", \"right\", \"bottom\", \"left\"]);\n\nexport const isAlign = Schema.is(Schema.Literals([\"start\", \"center\", \"end\"]));\n\nconst sideOf = (side: unknown): FloatingSide =>\n  Schema.is(PlacementSide)(side) ? side : \"bottom\";\n\nconst alignOf = (align: unknown): FloatingAlign =>\n  isAlign(align) ? align : \"start\";\n\nconst oppositeSide = (side: unknown): FloatingSide =>\n  Match.value(sideOf(side)).pipe(\n    Match.when(\"top\", () => \"bottom\" as const),\n    Match.when(\"bottom\", () => \"top\" as const),\n    Match.when(\"left\", () => \"right\" as const),\n    Match.when(\"right\", () => \"left\" as const),\n    Match.exhaustive,\n  );\n\nconst roomOn = (side: unknown, input: PlacementInput): number =>\n  Match.value(sideOf(side)).pipe(\n    Match.when(\"top\", () => input.trigger.y - input.margin),\n    Match.when(\n      \"bottom\",\n      () =>\n        input.window.height -\n        input.margin -\n        (input.trigger.y + input.trigger.height),\n    ),\n    Match.when(\"left\", () => input.trigger.x - input.margin),\n    Match.when(\n      \"right\",\n      () =>\n        input.window.width -\n        input.margin -\n        (input.trigger.x + input.trigger.width),\n    ),\n    Match.exhaustive,\n  );\n\nconst extentOn = (side: unknown, surface: FloatingBounds): number =>\n  Match.value(sideOf(side)).pipe(\n    Match.when(\"top\", () => surface.height),\n    Match.when(\"bottom\", () => surface.height),\n    Match.when(\"left\", () => surface.width),\n    Match.when(\"right\", () => surface.width),\n    Match.exhaustive,\n  );\n\nexport const resolveSide = (input: PlacementInput): FloatingSide => {\n  const side = sideOf(input.side);\n  const extent = extentOn(side, input.surface);\n  if (roomOn(side, input) >= extent) return side;\n\n  const opposite = oppositeSide(side);\n  const oppositeRoom = roomOn(opposite, input);\n  if (oppositeRoom >= extentOn(opposite, input.surface)) return opposite;\n\n  return oppositeRoom > roomOn(side, input) ? opposite : side;\n};\n\nconst alignOffsetOn = (\n  side: unknown,\n  align: unknown,\n  trigger: FloatingBounds,\n  surface: FloatingBounds,\n): number =>\n  Match.value(alignOf(align)).pipe(\n    Match.when(\"center\", () =>\n      Match.value(sideOf(side)).pipe(\n        Match.when(\"top\", () => (trigger.width - surface.width) / 2),\n        Match.when(\"bottom\", () => (trigger.width - surface.width) / 2),\n        Match.when(\"left\", () => (trigger.height - surface.height) / 2),\n        Match.when(\"right\", () => (trigger.height - surface.height) / 2),\n        Match.exhaustive,\n      ),\n    ),\n    Match.when(\"start\", () => 0),\n    Match.when(\"end\", () => 0),\n    Match.exhaustive,\n  );\n\nconst hostAlign = (align: FloatingAlign): \"start\" | \"end\" =>\n  align === \"end\" ? \"end\" : \"start\";\n\nexport const requestedPlacement = (\n  side: unknown,\n  align: unknown,\n): Placement => ({\n  side: sideOf(side),\n  align: hostAlign(alignOf(align)),\n  alignOffset: 0,\n});\n\nexport const resolvePlacement = (input: PlacementInput): Placement => {\n  const side = resolveSide(input);\n  return {\n    side,\n    align: hostAlign(alignOf(input.align)),\n    alignOffset: alignOffsetOn(side, input.align, input.trigger, input.surface),\n  };\n};\n"
    },
    {
      "path": "packages/components/src/internal/presence.tsx",
      "target": "@ui/gpuixui/components/internal/presence.tsx",
      "type": "registry:component",
      "content": "/** @jsxImportSource @gpuix/react */\nimport type { MotionProps } from \"@gpuix/react\";\nimport {\n  delayedTiming,\n  exitWindowMs,\n  fadeFrom,\n  fadeFromAnchor,\n  fadeFromSide,\n  fadeOnly,\n  presenceMotion as motionOfPresence,\n  presenceStyle,\n  transitionWindowMs,\n  type PresenceFrames,\n  type PresenceHitRule,\n  type PresenceSide,\n  type PresenceTiming,\n  type PresenceTransition,\n} from \"../../motion/presence.js\";\nimport {\n  MotionProvider,\n  useMotionPreference,\n  useSurfacePresence,\n  useSurfaceTiming,\n  type MotionProviderProps,\n  type SurfacePresence,\n} from \"../../motion/react/presence.js\";\nimport {\n  motionTiming,\n  type MotionLevel,\n  type MotionPreference,\n} from \"../../motion/timing.js\";\n\nexport { MotionProvider, useMotionPreference, type MotionProviderProps };\n\nexport type SurfaceFrames = PresenceFrames;\n\nexport type SurfaceTiming = PresenceTiming;\n\nexport type PanelSide = PresenceSide;\n\nexport {\n  delayedTiming,\n  exitWindowMs,\n  fadeFrom,\n  fadeFromAnchor,\n  fadeFromSide,\n  fadeOnly,\n  presenceStyle,\n  transitionWindowMs,\n};\nexport type { PresenceHitRule };\n\nexport { useSurfacePresence, useSurfaceTiming, type SurfacePresence };\n\nexport const moveTiming = (\n  level: MotionLevel,\n  preference: MotionPreference,\n): PresenceTransition => motionTiming(level, { phase: \"standard\", preference });\n\nexport const useMoveTiming = (level: MotionLevel): PresenceTransition =>\n  moveTiming(level, useMotionPreference());\n\nexport const presenceMotion = (\n  frames: SurfaceFrames,\n  presence: SurfacePresence,\n  timing: SurfaceTiming = presence.timing,\n): MotionProps => motionOfPresence(frames, presence.present, timing);\n\nexport const PresenceShield = ({ present }: { readonly present: boolean }) =>\n  present ? null : (\n    <div\n      testId=\"presence-shield\"\n      style={{ position: \"absolute\", top: 0, right: 0, bottom: 0, left: 0 }}\n    />\n  );\n\nexport const presenceTabStop = (\n  present: boolean,\n): { readonly tabIndex?: number } => (present ? {} : { tabIndex: -1 });\n"
    },
    {
      "path": "packages/components/src/internal/recipe.ts",
      "target": "@ui/gpuixui/components/internal/recipe.ts",
      "type": "registry:lib",
      "content": "import type { StyleDesc } from \"@gpuix/react\";\nimport { createRecipeCache } from \"../../tw/index.js\";\nimport type { Theme } from \"./theme.js\";\n\nexport const recipeStyle: (recipe: string, theme: Theme) => StyleDesc =\n  createRecipeCache(512);\n"
    },
    {
      "path": "packages/components/src/internal/ref.ts",
      "target": "@ui/gpuixui/components/internal/ref.ts",
      "type": "registry:lib",
      "content": "import type { Ref, RefCallback } from \"react\";\nimport { useCallback } from \"react\";\n\nconst assign = <T>(ref: Ref<T> | undefined, value: T): void => {\n  if (ref === null || ref === undefined) return;\n  if (typeof ref === \"function\") {\n    ref(value);\n    return;\n  }\n  ref.current = value;\n};\n\nexport const useMergedRef = <T>(\n  internal: Ref<T>,\n  caller: Ref<T> | undefined,\n): RefCallback<T> =>\n  useCallback(\n    (value: T) => {\n      assign(internal, value);\n      assign(caller, value);\n    },\n    [internal, caller],\n  );\n"
    },
    {
      "path": "packages/components/src/internal/text.ts",
      "target": "@ui/gpuixui/components/internal/text.ts",
      "type": "registry:lib",
      "content": "import { pipe } from \"effect\";\nimport * as Option from \"effect/Option\";\nimport * as Str from \"effect/String\";\n\nexport const textOf = (value: unknown): string =>\n  typeof value === \"string\" ? value : \"\";\n\nexport const nameOf = (value: unknown): string | undefined =>\n  pipe(\n    Option.some(textOf(value)),\n    Option.map(Str.trim),\n    Option.filter(Str.isNonEmpty),\n    Option.getOrUndefined,\n  );\n"
    },
    {
      "path": "packages/components/src/internal/theme.ts",
      "target": "@ui/gpuixui/components/internal/theme.ts",
      "type": "registry:lib",
      "content": "import type { StyleDesc } from \"@gpuix/react\";\nimport * as Schema from \"effect/Schema\";\nimport {\n  alpha,\n  avatarPixels,\n  avatarSize,\n  brandTextOn,\n  controlFocusRing,\n  controlHeight,\n  controlPaddingX,\n  currentPlatform,\n  darkTheme,\n  disabledAction,\n  disabledOpacity,\n  elevationShadow,\n  filledHover,\n  filledPressed,\n  findHighlight,\n  focusRing,\n  keyboardFocusRing,\n  lightTheme,\n  nativeTextTheme,\n  pointerWash,\n  selectionOn,\n  statusTone,\n  syntaxColors,\n  targetSize,\n  textStyle,\n  type BoxShadow,\n  type ElevationLevel,\n  type FindHighlightSource,\n  type NativeTextFill,\n  type PlatformName,\n  type PointerWashSurface,\n  type StatusTone,\n  type SyntaxColors,\n  type SyntaxRole,\n  type TextRole,\n  type Theme,\n  type ThemeColors,\n} from \"../../tokens/index.js\";\n\nexport {\n  alpha,\n  avatarPixels,\n  avatarSize,\n  controlFocusRing,\n  controlHeight,\n  controlPaddingX,\n  currentPlatform,\n  darkTheme,\n  disabledAction,\n  disabledOpacity,\n  elevationShadow,\n  filledHover,\n  filledPressed,\n  findHighlight,\n  focusRing,\n  keyboardFocusRing,\n  lightTheme,\n  nativeTextTheme,\n  statusTone,\n  syntaxColors,\n  targetSize,\n  textStyle,\n};\nexport type {\n  BoxShadow,\n  ElevationLevel,\n  FindHighlightSource,\n  NativeTextFill,\n  PlatformName,\n  StatusTone,\n  SyntaxColors,\n  SyntaxRole,\n  TextRole,\n  Theme,\n};\nexport { ThemeProvider, useTheme } from \"../../tokens/react.js\";\n\nexport const keyboardRing = (theme: Theme, invalid = false): StyleDesc =>\n  controlFocusRing(theme, { invalid }) ?? {};\n\nexport interface ControlRingState {\n  readonly disabled?: boolean;\n\n  readonly invalid?: boolean;\n}\n\nexport const controlRing = (\n  theme: Theme,\n  state: ControlRingState = {},\n): StyleDesc => controlFocusRing(theme, state) ?? {};\n\nexport const pressWash = (theme: Theme, replaced: PointerWashSurface): string =>\n  pointerWash(theme, \"active\", replaced) ?? theme.colors.active;\n\nexport const selectionWash = (theme: Theme): StyleDesc => ({\n  selectionColor: theme.colors.selection,\n});\n\nexport const keepContent: StyleDesc = { keyboardFocusDim: false };\n\nexport const disabledFade = (\n  disabled: boolean,\n): { readonly opacity: number } | undefined =>\n  disabled ? { opacity: disabledOpacity } : undefined;\n\nconst Tones = Schema.Literals([\"info\", \"success\", \"warning\", \"danger\"]);\n\nexport type Tone = typeof Tones.Type;\n\nexport const toneOf = (value: unknown): Tone =>\n  Schema.is(Tones)(value) ? value : \"info\";\n\nexport interface ToneStyle {\n  readonly fg: string;\n  readonly bg: string;\n  readonly border: string;\n}\n\nconst TOKEN_TONE: Readonly<Record<Tone, StatusTone>> = {\n  info: \"info\",\n  success: \"success\",\n  warning: \"warning\",\n  danger: \"destructive\",\n};\n\nexport const tone = (theme: Theme, value: Tone): ToneStyle => {\n  const { background, border, foreground } = statusTone(\n    theme,\n    TOKEN_TONE[value],\n  );\n  return { bg: background, border, fg: foreground };\n};\n\nconst softRoles: Readonly<Record<Tone, keyof ThemeColors>> = {\n  info: \"infoSoft\",\n  success: \"successSoft\",\n  warning: \"warningSoft\",\n  danger: \"destructiveSoft\",\n};\n\nexport const messageLink = (theme: Theme, value: Tone): string =>\n  brandTextOn(theme, softRoles[value]);\n\nexport const messageSelection = (theme: Theme, value: Tone): string =>\n  selectionOn(theme, softRoles[value]);\n\nexport const toneSurface = (theme: Theme, value: Tone): StyleDesc => {\n  const { bg, border, fg } = tone(theme, value);\n  return {\n    backgroundColor: bg,\n    color: fg,\n    borderWidth: theme.borderWidth.thin,\n    borderColor: border,\n  };\n};\n"
    },
    {
      "path": "packages/components/src/internal/use-placement.ts",
      "target": "@ui/gpuixui/components/internal/use-placement.ts",
      "type": "registry:lib",
      "content": "import { useGpuix, type PublicInstance } from \"@gpuix/react\";\nimport type { FloatingAlign, FloatingSide } from \"@gpuix/react/floating\";\nimport * as Option from \"effect/Option\";\nimport { useLayoutEffect, useRef, useState, type RefObject } from \"react\";\nimport {\n  requestedPlacement,\n  resolvePlacement,\n  type Placement,\n} from \"./placement.js\";\n\nexport interface UsePlacementInput {\n  readonly open: boolean;\n  readonly side: FloatingSide;\n  readonly align: FloatingAlign;\n  readonly margin: number;\n  readonly trigger: RefObject<PublicInstance | null>;\n  readonly surface: RefObject<PublicInstance | null>;\n}\n\nconst boundsOf = (\n  renderer: ReturnType<typeof useGpuix>[\"renderer\"],\n  instance: PublicInstance | null,\n): Option.Option<{ x: number; y: number; width: number; height: number }> =>\n  Option.flatMap(Option.fromNullishOr(instance), (element) =>\n    Option.fromNullishOr(renderer?.getElementBounds?.(element.id)),\n  );\n\nexport const usePlacement = ({\n  open,\n  side,\n  align,\n  margin,\n  trigger,\n  surface,\n}: UsePlacementInput): Placement => {\n  const renderer = useGpuix().renderer;\n  const [placement, setPlacement] = useState<Option.Option<Placement>>(\n    Option.none(),\n  );\n  const measuredFor = useRef<string | null>(null);\n  const key = `${side}:${align}:${margin}`;\n\n  useLayoutEffect(() => {\n    if (!open) {\n      measuredFor.current = null;\n      setPlacement(Option.none());\n      return;\n    }\n    if (measuredFor.current === key) return;\n\n    const measured = Option.all({\n      trigger: boundsOf(renderer, trigger.current),\n      surface: boundsOf(renderer, surface.current),\n      window: Option.fromNullishOr(renderer?.getWindowSize?.()),\n    });\n    if (Option.isNone(measured)) return;\n\n    measuredFor.current = key;\n    setPlacement(\n      Option.some(resolvePlacement({ ...measured.value, side, align, margin })),\n    );\n  }, [align, key, margin, open, renderer, side, surface, trigger]);\n\n  return Option.getOrElse(placement, () => requestedPlacement(side, align));\n};\n"
    },
    {
      "path": "packages/components/src/popover.tsx",
      "target": "@ui/gpuixui/components/popover.tsx",
      "type": "registry:component",
      "content": "/** @jsxImportSource @gpuix/react */\nimport type { EventPayload, PublicInstance } from \"@gpuix/react\";\nimport { useGpuix } from \"@gpuix/react\";\nimport {\n  FloatingLayer,\n  floatingRootStyle,\n  mergeStyles,\n  type FloatingAlign,\n  type FloatingContentProps,\n} from \"@gpuix/react/floating\";\nimport { POPOVER_CONTENT } from \"../tw/index.js\";\nimport {\n  Button,\n  type ButtonProps as PrimitiveButtonProps,\n} from \"../primitives/button.js\";\nimport { Match } from \"effect\";\nimport {\n  createContext,\n  useContext,\n  useLayoutEffect,\n  useMemo,\n  useRef,\n  type RefObject,\n} from \"react\";\nimport { useControllableState } from \"./internal/controllable.js\";\nimport { dismissTopLayer, pushDismissLayer } from \"./internal/dismiss-layer.js\";\nimport { DismissScope, useDismissDepth } from \"./internal/dismiss-scope.js\";\nimport { isDismiss, isTab } from \"./internal/key.js\";\nimport { overlaySurfaceStyle } from \"./internal/overlay.js\";\nimport {\n  assertParts,\n  type PartChildren,\n  type PartComponent,\n  type PartsContract,\n} from \"./internal/parts.js\";\nimport {\n  fadeFromAnchor,\n  PresenceShield,\n  presenceMotion,\n  presenceStyle,\n  useSurfacePresence,\n  useSurfaceTiming,\n} from \"./internal/presence.js\";\nimport { isAlign } from \"./internal/placement.js\";\nimport { isDismissalClick } from \"./internal/dismiss-layer.js\";\nimport { useMergedRef } from \"./internal/ref.js\";\nimport { useTheme } from \"./internal/theme.js\";\nimport { usePlacement } from \"./internal/use-placement.js\";\n\nconst popoverAlign = (align: unknown): FloatingAlign =>\n  isAlign(align) ? align : \"center\";\n\ninterface PopoverContextValue {\n  readonly open: boolean;\n  readonly setOpen: (open: boolean) => void;\n  readonly trigger: RefObject<PublicInstance | null>;\n}\n\nconst PopoverContext = createContext<PopoverContextValue | undefined>(\n  undefined,\n);\n\nconst usePopoverContext = (): PopoverContextValue => {\n  const value = useContext(PopoverContext);\n  if (value === undefined) {\n    throw new Error(\"Popover parts must be used inside Popover\");\n  }\n  return value;\n};\n\nexport interface PopoverProps {\n  readonly open?: boolean;\n\n  readonly defaultOpen?: boolean;\n  readonly onOpenChange?: (open: boolean) => void;\n  readonly children?: PartChildren;\n}\n\nexport const Popover = ({\n  open: openProp,\n  defaultOpen = false,\n  onOpenChange,\n  children,\n}: PopoverProps) => {\n  const [open, setOpen] = useControllableState({\n    value: openProp,\n    defaultValue: defaultOpen,\n    onChange: onOpenChange,\n  });\n  const trigger = useRef<PublicInstance | null>(null);\n\n  const context = useMemo<PopoverContextValue>(\n    () => ({ open, setOpen, trigger }),\n    [open, setOpen],\n  );\n\n  assertParts(popoverRoot, children);\n\n  return (\n    <PopoverContext.Provider value={context}>\n      <div style={floatingRootStyle()}>{children}</div>\n    </PopoverContext.Provider>\n  );\n};\n\nexport interface PopoverTriggerProps extends PrimitiveButtonProps {\n  readonly onClick?: (event: EventPayload) => void;\n}\n\nexport const PopoverTrigger = ({\n  onClick,\n  onActivate,\n  ref,\n  variant = \"secondary\",\n  ...rest\n}: PopoverTriggerProps) => {\n  const { open, setOpen, trigger } = usePopoverContext();\n  const setTrigger = useMergedRef<PublicInstance | null>(trigger, ref);\n\n  return (\n    <Button\n      {...rest}\n      ref={setTrigger}\n      variant={variant}\n      aria-expanded={open}\n      onActivate={(event) => {\n        (onActivate ?? onClick)?.(event);\n\n        if (isDismissalClick(event)) return;\n        setOpen(!open);\n      }}\n    />\n  );\n};\n\nexport interface PopoverContentProps extends FloatingContentProps {\n  readonly className?: string;\n\n  readonly side?: \"top\" | \"right\" | \"bottom\" | \"left\";\n\n  readonly align?: \"start\" | \"center\" | \"end\";\n\n  readonly sideOffset?: number;\n\n  readonly collisionPadding?: number;\n\n  readonly alignOffset?: number;\n}\n\nexport const PopoverContent = ({\n  className,\n  side = \"bottom\",\n  align = \"center\",\n  sideOffset = 6,\n  alignOffset = 0,\n  collisionPadding = 8,\n  children,\n  onKeyDown,\n  onMouseDownOutside,\n  style,\n  ref,\n  ...rest\n}: PopoverContentProps) => {\n  const theme = useTheme();\n  const { open, setOpen, trigger } = usePopoverContext();\n  const renderer = useGpuix().renderer;\n  const surface = useRef<PublicInstance | null>(null);\n  const setSurface = useMergedRef<PublicInstance | null>(surface, ref);\n  const timing = useSurfaceTiming(\"normal\");\n  const presence = useSurfacePresence(open, timing);\n  const placement = usePlacement({\n    open: presence.mounted,\n    side,\n    align: popoverAlign(align),\n    margin: collisionPadding,\n    trigger,\n    surface,\n  });\n\n  const close = useRef<() => void>(() => undefined);\n  useLayoutEffect(() => {\n    close.current = () => setOpen(false);\n  });\n\n  const depth = useDismissDepth();\n  useLayoutEffect(() => {\n    if (!open) return;\n    return pushDismissLayer((event) => {\n      close.current();\n      if (event.eventType === \"keyDown\") {\n        const target = trigger.current;\n        if (target !== null) renderer?.focusElement?.(target.id);\n        return;\n      }\n    }, depth);\n  }, [depth, open, renderer, trigger]);\n\n  if (!presence.mounted) return null;\n\n  return (\n    <FloatingLayer\n      motion={presenceMotion(fadeFromAnchor(placement.side, 8), presence)}\n      side={placement.side}\n      align={placement.align}\n      sideOffset={sideOffset}\n      alignOffset={placement.alignOffset + alignOffset}\n      collisionPadding={collisionPadding}\n      tabIndex={-1}\n      autoFocus\n      ref={setSurface}\n      {...rest}\n      onMouseDownOutside={(event) => {\n        onMouseDownOutside?.(event);\n        dismissTopLayer(event);\n      }}\n      onKeyDown={(event) => {\n        onKeyDown?.(event);\n        Match.value(event).pipe(\n          Match.when(isDismiss, (value) => {\n            dismissTopLayer(value);\n          }),\n\n          Match.when(isTab, () => setOpen(false)),\n          Match.orElse(() => undefined),\n        );\n      }}\n      style={mergeStyles(\n        mergeStyles(\n          overlaySurfaceStyle(POPOVER_CONTENT, className, theme, \"lg\"),\n\n          {\n            minWidth: 200,\n            position: \"relative\",\n            ...presenceStyle(presence.present),\n          },\n        ),\n        style,\n      )}\n    >\n      <DismissScope>{children}</DismissScope>\n      <PresenceShield present={presence.present} />\n    </FloatingLayer>\n  );\n};\n\nconst popoverParts: ReadonlyArray<PartComponent> = [\n  Popover,\n  PopoverTrigger,\n  PopoverContent,\n];\n\nconst popoverRoot: PartsContract = {\n  parent: \"Popover\",\n  family: popoverParts,\n  accepts: [PopoverTrigger, PopoverContent],\n  hint: \"Put PopoverTrigger and PopoverContent directly inside Popover.\",\n};\n\nexport const popoverMeta = {\n  name: \"Popovers\",\n  tier: 2,\n  status: \"done\",\n  gpuixSupport: \"partial\",\n  limitations: [\n    \"positioning is GPUix's anchored layer: it snaps but does not flip, so the component flips once when the snapped surface would cover its trigger; no arrow or custom anchor element\",\n    'the runtime\\'s `align=\"center\"` centres on the containing block, so the component maps it to a measured `start` offset; the snap margin wins near a window edge',\n    \"an outside press gives focus to whatever was pressed, so focus is not returned to the trigger (Escape is)\",\n  ],\n  docs: \"docs/popover.mdx\",\n  example: \"examples/popover.example.tsx\",\n  testFile: \"src/behaviour/popover.test.tsx\",\n} as const;\n"
    }
  ],
  "docs": "[Color picker](https://gpuixui.sudokw.com/components/color-picker) — These are GPUix native components: the files render through GPUix's reconciler against `@gpuix/react`, not the DOM, and need the per-platform `@gpuix/native` binding. The CLI installs the `@gpuixui/*` runtime the components import as registry items, so the copied tree resolves on its own; wrap it in `ThemeProvider` before it renders.",
  "meta": {
    "url": "/components/color-picker",
    "kind": "component",
    "runtime": "gpuix",
    "registry": "gpuixui"
  }
}