{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "components-glyph",
  "type": "registry:component",
  "title": "Glyph",
  "description": "A wall of generated characters for its own box",
  "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-motion.json",
    "https://gpuixui.sudokw.com/gpuix-tokens.json",
    "https://gpuixui.sudokw.com/gpuix-tw.json"
  ],
  "files": [
    {
      "path": "packages/components/src/glyph.tsx",
      "target": "@ui/gpuixui/components/glyph.tsx",
      "type": "registry:component",
      "content": "/** @jsxImportSource @gpuix/react */\nimport type { Props } from \"@gpuix/react\";\nimport type { StateStyle } from \"@gpuix/react/floating\";\nimport type { MotionLevel } from \"../motion/timing.js\";\nimport * as Arr from \"effect/Array\";\nimport type { ReactNode } from \"react\";\nimport { glyphField } from \"./glyph/logic.js\";\nimport {\n  DecorativeField,\n  type PatternFieldState,\n} from \"./internal/pattern-field.js\";\nimport { useTheme } from \"./internal/theme.js\";\n\nexport type GlyphState = PatternFieldState;\n\nexport interface GlyphProps extends Omit<Props, \"children\" | \"style\"> {\n  readonly marks?: string;\n\n  readonly cellSize?: number;\n\n  readonly density?: number;\n\n  readonly seed?: number;\n\n  readonly color?: string;\n\n  readonly breatheMs?: number;\n\n  readonly level?: MotionLevel;\n\n  readonly className?: string;\n\n  readonly style?: StateStyle<GlyphState>;\n\n  readonly children?: ReactNode;\n}\n\nexport const Glyph = ({\n  marks,\n  cellSize,\n  density,\n  seed,\n  color,\n  breatheMs,\n  level,\n  className,\n  style,\n  children,\n  ...rest\n}: GlyphProps) => {\n  const theme = useTheme();\n  const ink = color ?? theme.colors.border;\n\n  return (\n    <DecorativeField\n      {...rest}\n      art={(box, id) => {\n        const field = glyphField({ ...box, cellSize, density, seed, marks });\n        const size = Math.round(field.cell * 0.6);\n        return (\n          <>\n            {Arr.map(field.cells, (cell) => (\n              <text\n                key={cell.key}\n                testId={`${id}-cell-${cell.key}`}\n                role=\"presentation\"\n                style={{\n                  position: \"absolute\",\n                  left: cell.x,\n                  top: cell.y,\n                  fontSize: size,\n                  color: ink,\n                  opacity: cell.opacity,\n                  pointerEvents: \"none\",\n                }}\n              >\n                {cell.text}\n              </text>\n            ))}\n          </>\n        );\n      }}\n      breatheMs={breatheMs}\n      level={level}\n      className={className}\n      style={style}\n    >\n      {children}\n    </DecorativeField>\n  );\n};\n\nexport const glyphMeta = {\n  name: \"Glyph\",\n  tier: 5,\n  status: \"done\",\n  gpuixSupport: \"partial\",\n  limitations: [\n    \"the wall is one `<text>` host per painted cell: the runtime has no text pattern and no canvas host, so the cell count is capped at 240 and a wall is a node per glyph rather than one mask\",\n    'a glyph publishes no accessibility node because the runtime maps `role=\"presentation\"` to none (measured); the wall therefore says nothing, and the content above it has to carry the name',\n    \"the wall cannot drift, zoom or rotate — the runtime has no `transform` (upstream issue #102) — so the only motion is a slow opacity breath\",\n    \"the grid covers whole cells, so a strip narrower than one cell at the right or bottom edge stays empty, and a box that would need more than the cell cap grows the cell instead of painting part of the wall\",\n    \"the field measures its own box, so the caller must bound it; before the first layout it paints nothing\",\n    \"a hidden wall keeps breathing (the runtime exposes no visibility query), so unmount it when it is off screen\",\n  ],\n  docs: \"docs/glyph.mdx\",\n  example: \"examples/glyph.example.tsx\",\n  testFile: \"src/behaviour/glyph.test.tsx\",\n} as const;\n"
    },
    {
      "path": "packages/components/src/glyph/logic.ts",
      "target": "@ui/gpuixui/components/glyph/logic.ts",
      "type": "registry:lib",
      "content": "import * as Arr from \"effect/Array\";\nimport * as Option from \"effect/Option\";\nimport * as Result from \"effect/Result\";\nimport { seededUnit, seedOf, tenth } from \"../internal/scatter.js\";\nimport { paintableBox, type PatternBox } from \"../internal/svg-pattern.js\";\n\nexport const glyphCell = 22;\n\nexport const glyphMinCell = 10;\nexport const glyphMaxCell = 72;\n\nexport const glyphMaxCells = 240;\n\nexport const glyphDensity = 0.55;\n\nexport const glyphDim = 0.3;\n\nexport const glyphMarks = \".+*/\\\\<>[]{}~\";\n\nexport const glyphSeed = 1;\n\nexport interface GlyphCell {\n  readonly key: string;\n  readonly text: string;\n  readonly x: number;\n  readonly y: number;\n  readonly opacity: number;\n}\n\nexport interface GlyphField {\n  readonly cell: number;\n  readonly columns: number;\n  readonly rows: number;\n  readonly cells: ReadonlyArray<GlyphCell>;\n}\n\nexport interface GlyphFieldOptions extends PatternBox {\n  readonly cellSize?: number;\n  readonly density?: number;\n  readonly seed?: number;\n  readonly marks?: string;\n}\n\nexport const glyphCellOf = (cell: Option.Option<number>): number =>\n  Option.getOrElse(\n    Option.map(\n      Option.filter(\n        cell,\n        (value) => Number.isFinite(value) && value >= glyphMinCell,\n      ),\n      (value) => Math.min(Math.round(value), glyphMaxCell),\n    ),\n    () => glyphCell,\n  );\n\nexport const glyphDensityOf = (density: Option.Option<number>): number =>\n  Option.getOrElse(\n    Option.map(\n      Option.filter(density, (value) => Number.isFinite(value) && value >= 0),\n      (value) => Math.min(value, 1),\n    ),\n    () => glyphDensity,\n  );\n\nexport const glyphMarksOf = (\n  marks: Option.Option<string>,\n): ReadonlyArray<string> => {\n  const given = Option.match(marks, {\n    onNone: () => [],\n    onSome: (value) => Arr.fromIterable(value),\n  });\n  return Arr.match(given, {\n    onEmpty: () => Arr.fromIterable(glyphMarks),\n    onNonEmpty: (values) => values,\n  });\n};\n\nconst gridOf = (\n  box: PatternBox,\n  cell: number,\n): { readonly columns: number; readonly rows: number } => ({\n  columns: Math.max(1, Math.floor(box.width / cell)),\n  rows: Math.max(1, Math.floor(box.height / cell)),\n});\n\nconst cellForCap = (box: PatternBox): number =>\n  Math.max(\n    Math.ceil(Math.sqrt((box.width * box.height) / glyphMaxCells)),\n    Math.ceil(box.width / glyphMaxCells),\n    Math.ceil(box.height / glyphMaxCells),\n  );\n\nconst cellAt = (\n  index: number,\n  columns: number,\n  cell: number,\n): { readonly key: string; readonly x: number; readonly y: number } => {\n  const column = index % columns;\n  const row = Math.floor(index / columns);\n  return {\n    key: `${column}-${row}`,\n\n    x: tenth(column * cell + cell * 0.3),\n    y: tenth(row * cell + cell * 0.2),\n  };\n};\n\nexport const glyphField = ({\n  width,\n  height,\n  cellSize,\n  density,\n  seed,\n  marks,\n}: GlyphFieldOptions): GlyphField => {\n  const requested = glyphCellOf(Option.fromNullishOr(cellSize));\n  if (!paintableBox({ width, height })) {\n    return { cell: requested, columns: 0, rows: 0, cells: [] };\n  }\n\n  const box = { width, height };\n  const cell = Math.max(requested, cellForCap(box));\n  const { columns, rows } = gridOf(box, cell);\n  const share = glyphDensityOf(Option.fromNullishOr(density));\n  const alphabet = glyphMarksOf(Option.fromNullishOr(marks));\n  const value = seedOf(Option.fromNullishOr(seed));\n\n  const cells = Arr.filterMap(Arr.range(0, columns * rows - 1), (index) => {\n    if (seededUnit(value, index, 0) >= share) return Result.failVoid;\n    const mark =\n      alphabet[Math.floor(seededUnit(value, index, 1) * alphabet.length)];\n    if (mark === undefined) return Result.failVoid;\n    const place = cellAt(index, columns, cell);\n    return Result.succeed({\n      ...place,\n      text: mark,\n      opacity: tenth(glyphDim + (1 - glyphDim) * seededUnit(value, index, 2)),\n    });\n  });\n\n  return { cell, columns, rows, cells };\n};\n"
    },
    {
      "path": "packages/components/src/internal/local-state.ts",
      "target": "@ui/gpuixui/components/internal/local-state.ts",
      "type": "registry:lib",
      "content": "import { Effect } from \"effect\";\nimport * as Arr from \"effect/Array\";\nimport * as Duration from \"effect/Duration\";\nimport * as Fiber from \"effect/Fiber\";\nimport * as Option from \"effect/Option\";\nimport * as Ref from \"effect/Ref\";\nimport * as SubscriptionRef from \"effect/SubscriptionRef\";\nimport { useEffect, useState, useSyncExternalStore } from \"react\";\n\nexport interface LocalState<A> {\n  readonly state: SubscriptionRef.SubscriptionRef<A>;\n\n  readonly read: () => A;\n\n  readonly subscribe: (listener: () => void) => () => void;\n\n  readonly write: (next: A) => Effect.Effect<void>;\n\n  readonly after: (\n    millis: number,\n    effect: Effect.Effect<void>,\n  ) => Effect.Effect<void>;\n\n  readonly cancel: Effect.Effect<void>;\n\n  readonly running: () => boolean;\n}\n\nexport const makeLocalState = <A>(initial: A): Effect.Effect<LocalState<A>> =>\n  Effect.gen(function* () {\n    const state = yield* SubscriptionRef.make(initial);\n    const timer = yield* Ref.make(Option.none<Fiber.Fiber<void>>());\n    const listeners = yield* Ref.make<ReadonlyArray<() => void>>(Arr.empty());\n\n    const write = Effect.fnUntraced(function* (next: A) {\n      yield* SubscriptionRef.set(state, next);\n      const subscribers = yield* Ref.get(listeners);\n      yield* Effect.sync(() => {\n        Arr.forEach(subscribers, (listener) => listener());\n      });\n    });\n\n    const cancel = Effect.gen(function* () {\n      const held = yield* Ref.getAndSet(timer, Option.none());\n      yield* Option.match(held, {\n        onNone: () => Effect.void,\n        onSome: Fiber.interrupt,\n      });\n    });\n\n    const after = Effect.fnUntraced(function* (\n      millis: number,\n      effect: Effect.Effect<void>,\n    ) {\n      yield* cancel;\n      const fiber = yield* Effect.forkDetach(\n        Effect.sleep(Duration.millis(millis)).pipe(Effect.andThen(effect)),\n      );\n      yield* Ref.set(timer, Option.some(fiber));\n    });\n\n    const running = (): boolean =>\n      Option.exists(\n        Ref.getUnsafe(timer),\n        (fiber) => fiber.pollUnsafe() === undefined,\n      );\n\n    const subscribe = (listener: () => void): (() => void) => {\n      Effect.runSync(\n        Ref.update(listeners, (current) => Arr.append(current, listener)),\n      );\n      return () => {\n        Effect.runSync(\n          Ref.update(listeners, (current) =>\n            Arr.filter(current, (held) => held !== listener),\n          ),\n        );\n      };\n    };\n\n    return {\n      state,\n\n      read: () => SubscriptionRef.getUnsafe(state),\n      subscribe,\n      write,\n      after,\n      cancel,\n      running,\n    };\n  });\n\ninterface Teardown {\n  readonly local: { readonly cancel: Effect.Effect<void> };\n}\n\nexport const useLocalStore = <Store extends Teardown>(\n  make: Effect.Effect<Store>,\n): Store => {\n  const [store] = useState(() => Effect.runSync(make));\n  useEffect(() => () => send(store.local.cancel), [store]);\n  return store;\n};\n\nexport const send = (command: Effect.Effect<void>): void => {\n  Effect.runFork(command);\n};\n\nexport const useLocalState = <A>(local: LocalState<A>): A =>\n  useSyncExternalStore(local.subscribe, local.read, local.read);\n\nexport const useLocalSlice = <A, B>(\n  local: LocalState<A>,\n  select: (state: A) => B,\n): B =>\n  useSyncExternalStore(\n    local.subscribe,\n    () => select(local.read()),\n    () => select(local.read()),\n  );\n"
    },
    {
      "path": "packages/components/src/internal/measure.ts",
      "target": "@ui/gpuixui/components/internal/measure.ts",
      "type": "registry:lib",
      "content": "import type { EventPayload } from \"@gpuix/react\";\nimport * as Option from \"effect/Option\";\n\nexport interface MeasuredBox {\n  readonly x: number;\n  readonly y: number;\n  readonly width: number;\n  readonly height: number;\n}\n\nconst measurable = (value: number | undefined): Option.Option<number> =>\n  Option.filter(Option.fromNullishOr(value), Number.isFinite);\n\nexport const measuredBox = (event: EventPayload): Option.Option<MeasuredBox> =>\n  Option.all({\n    x: measurable(event.x),\n    y: measurable(event.y),\n    width: measurable(event.width),\n    height: measurable(event.height),\n  });\n\nexport const measuredHeight = (event: EventPayload): Option.Option<number> =>\n  measurable(event.height);\n\nexport interface MeasuredPoint {\n  readonly x: number;\n  readonly y: number;\n}\n\nexport const measuredPoint = (\n  event: EventPayload,\n): Option.Option<MeasuredPoint> =>\n  Option.all({\n    x: measurable(event.x),\n    y: measurable(event.y),\n  });\n"
    },
    {
      "path": "packages/components/src/internal/pattern-field.tsx",
      "target": "@ui/gpuixui/components/internal/pattern-field.tsx",
      "type": "registry:component",
      "content": "/** @jsxImportSource @gpuix/react */\nimport type { EventPayload, MotionProps, Props } from \"@gpuix/react\";\nimport {\n  mergeStyles,\n  resolveStyle,\n  type StateStyle,\n} from \"@gpuix/react/floating\";\nimport type { MotionLevel } from \"../../motion/timing.js\";\nimport { cn } from \"../../tw/index.js\";\nimport * as Option from \"effect/Option\";\nimport type { ReactNode } from \"react\";\nimport { send, useLocalState, useLocalStore } from \"./local-state.js\";\nimport { measuredBox } from \"./measure.js\";\nimport { makeFieldStore } from \"./pattern-field/store.js\";\nimport { fadeOnly, useMotionPreference, useSurfaceTiming } from \"./presence.js\";\nimport { recipeStyle } from \"./recipe.js\";\nimport { durationOf } from \"./scatter.js\";\nimport { paintableBox, type PatternBox } from \"./svg-pattern.js\";\nimport { useTheme } from \"./theme.js\";\n\nexport const patternBreatheMs = 8_000;\n\nexport const patternBreatheFloor = 1_000;\n\nexport const patternBreatheCap = 60_000;\n\nexport const patternDim = 0.55;\n\nexport interface PatternFieldState {\n  readonly width: number;\n  readonly height: number;\n  readonly reducedMotion: boolean;\n}\n\nexport type FieldArt = (box: PatternBox, testId: string) => ReactNode;\n\nexport interface PatternFieldProps extends Omit<Props, \"children\" | \"style\"> {\n  readonly markup: (box: PatternBox) => string;\n\n  readonly color: string;\n\n  readonly breatheMs?: number;\n\n  readonly level?: MotionLevel;\n\n  readonly className?: string;\n\n  readonly style?: StateStyle<PatternFieldState>;\n\n  readonly children?: ReactNode;\n}\n\nexport interface DecorativeFieldProps extends Omit<\n  Props,\n  \"children\" | \"style\"\n> {\n  readonly art: FieldArt;\n\n  readonly breatheMs?: number;\n\n  readonly level?: MotionLevel;\n\n  readonly className?: string;\n\n  readonly style?: StateStyle<PatternFieldState>;\n\n  readonly children?: ReactNode;\n}\n\nconst Breath = ({\n  art,\n  legMs,\n  id,\n  lit,\n  onLanded,\n}: {\n  readonly art: ReactNode;\n  readonly legMs: number;\n  readonly id: string;\n  readonly lit: boolean;\n  readonly onLanded: () => void;\n}) => {\n  const motion: MotionProps = {\n    initial: { opacity: patternDim },\n    animate: { opacity: lit ? patternDim : 1 },\n    transition: { duration: legMs / 1000, ease: \"easeInOut\" },\n  };\n\n  return (\n    <div\n      testId={`${id}-breath`}\n      motion={motion}\n      onMotionComplete={onLanded}\n      style={{\n        position: \"absolute\",\n        top: 0,\n        right: 0,\n        bottom: 0,\n        left: 0,\n        opacity: patternDim,\n        pointerEvents: \"none\",\n      }}\n    >\n      {art}\n    </div>\n  );\n};\n\nexport const DecorativeField = ({\n  art,\n  breatheMs,\n  level = \"slow\",\n  className,\n  style,\n  testId,\n  children,\n  ...rest\n}: DecorativeFieldProps) => {\n  const theme = useTheme();\n  const preference = useMotionPreference();\n  const timing = useSurfaceTiming(level);\n  const still = preference === \"reduced\";\n  const legMs = durationOf(\n    Option.fromNullishOr(breatheMs),\n    patternBreatheMs,\n    patternBreatheFloor,\n    patternBreatheCap,\n  );\n  const store = useLocalStore(makeFieldStore);\n  const field = useLocalState(store.local);\n\n  const noteBox = (event: EventPayload): void => {\n    Option.match(measuredBox(event), {\n      onNone: () => undefined,\n      onSome: (next) =>\n        send(store.note({ width: next.width, height: next.height })),\n    });\n  };\n\n  const measured: PatternBox = Option.getOrElse(field.box, () => ({\n    width: 0,\n    height: 0,\n  }));\n  const painted = paintableBox(measured);\n  const id = testId ?? \"pattern\";\n\n  const state: PatternFieldState = {\n    width: measured.width,\n    height: measured.height,\n    reducedMotion: still,\n  };\n\n  return (\n    <div\n      {...rest}\n      testId={testId}\n      onLayout={noteBox}\n      motion={{ ...fadeOnly, transition: timing.enter }}\n      style={mergeStyles(\n        mergeStyles(recipeStyle(cn(className), theme), {\n          position: \"relative\",\n          overflow: \"hidden\",\n        }),\n        resolveStyle(style, state),\n      )}\n    >\n      {painted ? (\n        still ? (\n          art(measured, id)\n        ) : (\n          <Breath\n            art={art(measured, id)}\n            legMs={legMs}\n            id={id}\n            lit={field.lit}\n            onLanded={() => send(store.breathe)}\n          />\n        )\n      ) : undefined}\n      {children}\n    </div>\n  );\n};\n\nexport const PatternField = ({ markup, color, ...rest }: PatternFieldProps) => (\n  <DecorativeField\n    {...rest}\n    art={(box, id) => (\n      <svg\n        testId={`${id}-lines`}\n        source={markup(box)}\n        role=\"presentation\"\n        style={{\n          width: box.width,\n          height: box.height,\n          color,\n          opacity: 1,\n          pointerEvents: \"none\",\n        }}\n      />\n    )}\n  />\n);\n"
    },
    {
      "path": "packages/components/src/internal/pattern-field/store.ts",
      "target": "@ui/gpuixui/components/internal/pattern-field/store.ts",
      "type": "registry:lib",
      "content": "import { Effect } from \"effect\";\nimport * as Option from \"effect/Option\";\nimport * as SubscriptionRef from \"effect/SubscriptionRef\";\nimport { makeLocalState, type LocalState } from \"../local-state.js\";\nimport type { PatternBox } from \"../svg-pattern.js\";\n\nexport interface FieldStoreState {\n  readonly box: Option.Option<PatternBox>;\n\n  readonly lit: boolean;\n}\n\nexport interface FieldStore {\n  readonly local: LocalState<FieldStoreState>;\n\n  readonly note: (box: PatternBox) => Effect.Effect<void>;\n\n  readonly breathe: Effect.Effect<void>;\n}\n\nconst resting: FieldStoreState = { box: Option.none(), lit: false };\n\nexport const makeFieldStore: Effect.Effect<FieldStore> = Effect.gen(\n  function* () {\n    const local = yield* makeLocalState<FieldStoreState>(resting);\n\n    const note = Effect.fnUntraced(function* (box: PatternBox) {\n      const current = yield* SubscriptionRef.get(local.state);\n      if (\n        Option.exists(\n          current.box,\n          (held) => held.width === box.width && held.height === box.height,\n        )\n      )\n        return;\n      yield* local.write({ ...current, box: Option.some(box) });\n    });\n\n    const breathe = Effect.gen(function* () {\n      const current = yield* SubscriptionRef.get(local.state);\n      yield* local.write({ ...current, lit: !current.lit });\n    });\n\n    return { local, note, breathe };\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/scatter.ts",
      "target": "@ui/gpuixui/components/internal/scatter.ts",
      "type": "registry:lib",
      "content": "import * as Option from \"effect/Option\";\n\nexport const seededUnit = (\n  seed: number,\n  index: number,\n  slot: number,\n): number => {\n  let value =\n    Math.imul(seed ^ 0x9e3779b9, 0x85ebca6b) ^\n    Math.imul((index + 1) * 8 + slot, 0xc2b2ae35);\n  value ^= value >>> 15;\n  value = Math.imul(value, 0x2c1b3c6d);\n  value ^= value >>> 13;\n  return (value >>> 0) / 0x100000000;\n};\n\nexport const tenth = (value: number): number => Math.round(value * 10) / 10;\n\nexport const paintable = (value: number): boolean =>\n  Number.isFinite(value) && value > 0;\n\nexport const seedOf = (seed: Option.Option<number>): number =>\n  Option.getOrElse(\n    Option.filter(seed, (value) => Number.isFinite(value)),\n    () => 1,\n  );\n\nexport const countOf = (\n  count: Option.Option<number>,\n  fallback: number,\n  cap: number,\n): number =>\n  Option.getOrElse(\n    Option.map(\n      Option.filter(count, (value) => Number.isFinite(value) && value >= 0),\n      (value) => Math.min(Math.round(value), cap),\n    ),\n    () => fallback,\n  );\n\nexport const sizeRangeOf = (\n  min: Option.Option<number>,\n  max: Option.Option<number>,\n  fallbackMin: number,\n  fallbackMax: number,\n): { readonly min: number; readonly max: number } => {\n  const floor = sizeOf(min, fallbackMin);\n  const ceiling = sizeOf(max, fallbackMax);\n  return floor <= ceiling\n    ? { min: floor, max: ceiling }\n    : { min: ceiling, max: floor };\n};\n\nconst sizeOf = (size: Option.Option<number>, fallback: number): number =>\n  Option.getOrElse(\n    Option.map(\n      Option.filter(size, (value) => Number.isFinite(value) && value >= 1),\n      Math.round,\n    ),\n    () => fallback,\n  );\n\nexport const durationOf = (\n  duration: Option.Option<number>,\n  fallback: number,\n  floor: number,\n  cap: number,\n): number =>\n  Option.getOrElse(\n    Option.map(\n      Option.filter(\n        duration,\n        (value) => Number.isFinite(value) && value >= floor,\n      ),\n      (value) => Math.min(Math.round(value), cap),\n    ),\n    () => fallback,\n  );\n"
    },
    {
      "path": "packages/components/src/internal/svg-pattern.ts",
      "target": "@ui/gpuixui/components/internal/svg-pattern.ts",
      "type": "registry:lib",
      "content": "export interface PatternBox {\n  readonly width: number;\n  readonly height: number;\n}\n\nexport const svgPatternMarkup = (\n  box: PatternBox,\n  path: string,\n  stroke: number,\n): string =>\n  `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${box.width}\" height=\"${box.height}\" viewBox=\"0 0 ${box.width} ${box.height}\"><path d=\"${path}\" fill=\"none\" stroke=\"#000000\" stroke-width=\"${stroke}\"/></svg>`;\n\nexport const paintableBox = (box: PatternBox): boolean =>\n  Number.isFinite(box.width) &&\n  Number.isFinite(box.height) &&\n  box.width > 0 &&\n  box.height > 0;\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"
    }
  ],
  "docs": "[Glyph](https://gpuixui.sudokw.com/components/glyph) — 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/glyph",
    "kind": "component",
    "runtime": "gpuix",
    "registry": "gpuixui"
  }
}