{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"recurrence-editor","type":"registry:component","title":"Recurrence editor","description":"How something repeats, set in plain controls and said back in a sentence: every N days, weeks, months or years; which weekdays; in a month, on a date or on the second Tuesday (or the last Friday); ending never, on a date or after a number of times. The next dates are listed so the rule can be checked against a calendar, months without the chosen date are said, and the rule comes out as a value and an iCalendar RRULE.","categories":["forms"],"dependencies":["@radix-ui/react-direction@1.1.4","@radix-ui/react-label@2.1.15","@radix-ui/react-popover@1.1.23","@radix-ui/react-radio-group@1.4.7","@radix-ui/react-select@2.3.7","@radix-ui/react-slot@1.3.3","@radix-ui/react-toggle-group@1.1.19","@radix-ui/react-tooltip@1.2.16","clsx@^2.1.1","lucide-react@^1.48.0","motion@^13.4.4","tailwind-merge@^3.7.0"],"registryDependencies":["https://beamline.io/registry/look-prism.json"],"files":[{"path":"beamline/components/_shared/field.module.css","type":"registry:file","target":"src/ui/beamline/components/_shared/field.module.css","content":"@layer properties, theme, base, components, utilities;\n@layer components {\n  /* A field: label (with an optional aside at the end of its row), the control, then one message line. The gap under\n   the control belongs to the message (--pui-field-gap), so a message that arrives or leaves takes its gap with it. */\n  /* a column, not a grid: a message (or a fold) that leaves pulls its gap away with a negative margin, which a flex\n     column honours and a grid track does not (it would stop at zero and stretch the leaving part back open) */\n  .field {\n    --pui-field-gap: var(--pui-space-1-5);\n    /* positioned: a hidden label or a count's spoken words (sr-only, absolutely placed) stay inside the field */\n    position: relative;\n    display: flex;\n    min-width: 0;\n    flex-direction: column;\n    gap: var(--pui-field-gap);\n  }\n  .labelRow {\n    display: flex;\n    min-width: 0;\n    align-items: baseline;\n    gap: var(--pui-space-2);\n  }\n  .aside {\n    margin-inline-start: auto;\n    flex-shrink: 0;\n    color: var(--pui-ink-3);\n    font-size: var(--pui-text-xs);\n  }\n\n  /* The message: one line at a time. A new line grows in to its own height (0fr to 1fr, no measuring) while the one it\n   replaces folds away above it, so the height glides from one to the other; a line that leaves with nothing after it\n   takes the gap with it. Arrival over --pui-motion-in, departure over --pui-motion-out; reduced motion keeps the fades. */\n  .messages {\n    display: grid;\n    margin-top: calc(var(--pui-field-gap, var(--pui-space-1-5)) * -1);\n  }\n  .line {\n    display: grid;\n    grid-template-rows: 1fr;\n    opacity: 1;\n    transition:\n      grid-template-rows var(--pui-motion-in) var(--pui-ease-default),\n      opacity var(--pui-fade-in, var(--pui-motion-in)) var(--pui-ease-default);\n  }\n  @starting-style {\n    .line {\n      grid-template-rows: 0fr;\n      opacity: 0;\n    }\n  }\n  /* the line a field is first drawn with does not grow in */\n  .line[data-initial] {\n    transition: none;\n  }\n  /* a swap is one change of size: the old line folds and the new one grows over the same duration and curve, so their\n     sum (the field's height) moves straight from one to the other, with no swell between; the old words fade first */\n  .line[data-leaving] {\n    grid-template-rows: 0fr;\n    opacity: 0;\n    transition:\n      grid-template-rows var(--pui-motion-out) var(--pui-ease-default),\n      opacity var(--pui-fade-in, var(--pui-motion-in)) var(--pui-ease-default);\n    pointer-events: none;\n  }\n  .messages:has(> .line[data-leaving]) > .line:not([data-leaving], [data-initial]) {\n    transition-duration: var(--pui-motion-out), var(--pui-fade-in, var(--pui-motion-in));\n  }\n  .clip {\n    min-height: 0;\n    overflow: clip;\n    overflow-clip-margin: var(--pui-space-1);\n  }\n  .message {\n    display: flex;\n    align-items: flex-start;\n    gap: var(--pui-space-1-5);\n    padding-top: var(--pui-field-gap, var(--pui-space-1-5));\n    font-size: var(--pui-text-xs);\n    line-height: 1.375;\n  }\n  .description {\n    display: block;\n    color: var(--pui-ink-3);\n  }\n  .error {\n    color: var(--pui-red);\n  }\n  .success {\n    color: var(--pui-green);\n  }\n  .icon {\n    flex-shrink: 0;\n    width: var(--pui-icon-sm);\n    height: var(--pui-icon-sm);\n    margin-top: 1px;\n  }\n\n  /* The count in the label's row: tabular, quiet, shown with attention (.reveal) and in words near the limit. */\n  .count {\n    font-variant-numeric: tabular-nums;\n    white-space: nowrap;\n  }\n  .count[data-state=\"near\"],\n  .count[data-state=\"full\"] {\n    color: var(--pui-orange);\n  }\n  .count[data-state=\"over\"] {\n    color: var(--pui-red);\n  }\n\n  /* The status at the end of the frame: the spinner arrives scaled in from its centre, and closes into the check. */\n  .status {\n    display: inline-grid;\n    flex-shrink: 0;\n    place-items: center;\n    animation: status-in var(--pui-motion-in) var(--pui-ease-default);\n  }\n  @keyframes status-in {\n    from {\n      opacity: 0;\n      scale: calc(1 - 0.4 * var(--pui-motion-travel, 1));\n    }\n  }\n\n  /* The one frame every text-like control sits in: input, textarea, password, search, number, the select and date\n   triggers. Its paint (fill, edge, hover, focus) is the field role of the look in force (looks.css); invalid,\n   read-only and disabled are drawn here so they read the same in every look. */\n  .frame {\n    --_field-height: var(--pui-control-height-md);\n    position: relative;\n    display: flex;\n    min-width: 0; /* a grid or flex parent may make it narrower than the input's natural width */\n    align-items: center;\n    gap: var(--pui-space-2);\n    min-height: var(--_field-height);\n    padding-inline: var(--pui-space-2-5);\n    border-radius: var(--pui-field-radius, var(--pui-radius-control));\n    color: var(--pui-ink);\n    font-size: var(--pui-text-sm);\n    cursor: text;\n    transition:\n      box-shadow var(--pui-motion-out) var(--pui-ease-default),\n      background-color var(--pui-motion-out) var(--pui-ease-default);\n  }\n  .frame:hover:not([data-disabled]) {\n    transition-duration: 0ms;\n  }\n  .frame[data-state=\"open\"] {\n    box-shadow: var(--m-field-edge-focus);\n  }\n  .frame:focus-within {\n    transition: none;\n  }\n  .frame[data-disabled] {\n    opacity: var(--pui-opacity-disabled);\n    cursor: not-allowed;\n  }\n  .frame[data-readonly] {\n    --m-field-bg: transparent;\n  }\n  .sm {\n    --_field-height: var(--pui-control-height-sm);\n    padding-inline: var(--pui-space-2);\n  }\n  .lg {\n    --_field-height: var(--pui-control-height-lg);\n    padding-inline: var(--pui-space-3);\n    font-size: var(--pui-text-base);\n  }\n  .multiline {\n    align-items: stretch;\n    padding-block: var(--pui-space-2);\n  }\n\n  /* The control itself: borderless, it takes the frame's look. Focus shows on the frame, so the control's own ring is off\n   (the frame's ring is the visible focus indicator, which is always present when the control has focus). */\n  .control {\n    flex: 1;\n    min-width: 0;\n    height: 100%;\n    min-height: calc(var(--_field-height) - 2px);\n    border: 0;\n    outline: none;\n    background: transparent;\n    color: inherit;\n    font: inherit;\n    letter-spacing: inherit;\n    padding: 0;\n  }\n  .control:focus-visible {\n    outline: none;\n  }\n  .control::placeholder {\n    color: var(--pui-ink-3);\n    opacity: 1;\n  }\n  .control:disabled {\n    cursor: not-allowed;\n  }\n  textarea.control {\n    min-height: 0;\n    resize: none;\n    line-height: 1.5;\n    field-sizing: content;\n  }\n  .adornment {\n    display: inline-flex;\n    align-items: center;\n    flex-shrink: 0;\n    color: var(--pui-ink-3);\n  }\n  .adornment :where(svg) {\n    width: var(--pui-icon-md);\n    height: var(--pui-icon-md);\n  }\n}\n/* CSS-module composition only; visual rules stay in the component layer. */\n.frame {\n  composes: m-field nest-corner from global;\n}\n"},{"path":"beamline/components/_shared/field.tsx","type":"registry:file","target":"src/ui/beamline/components/_shared/field.tsx","content":"\"use client\";\nimport { useMessages } from \"../../runtime/localization\";\nimport { english } from \"./messages\";\n\nimport {\n  useEffect,\n  useId,\n  useRef,\n  useState,\n  type CSSProperties,\n  type PointerEvent as ReactPointerEvent,\n  type ReactNode,\n  type Ref,\n  type TransitionEvent,\n} from \"react\";\nimport { AlertCircle, CircleCheck } from \"lucide-react\";\nimport { Label } from \"../label/label\";\nimport { Spinner } from \"../spinner/spinner\";\nimport { cn } from \"../../lib/utils\";\nimport styles from \"./field.module.css\";\n\nexport type FieldSize = \"sm\" | \"md\" | \"lg\";\nexport type FieldClassNames = Partial<\n  Record<\"root\" | \"label\" | \"frame\" | \"leading\" | \"trailing\" | \"description\" | \"error\" | \"success\" | \"aside\", string>\n>;\n\nexport interface FieldOptions {\n  /** Visible label, also the accessible name. */\n  label?: ReactNode;\n  /** Keep the label for assistive tech only (dense rows, toolbars). */\n  hideLabel?: boolean;\n  /** One line of help under the control. */\n  description?: ReactNode;\n  /** The problem and its fix; replaces the description and marks the control invalid. */\n  error?: ReactNode;\n  /** The confirmation that the value works (\"@mira is available\"): replaces the description, with a check. */\n  success?: ReactNode;\n  required?: boolean;\n  size?: FieldSize;\n}\n\n/** Ids and aria wiring for one field: the control gets these spread onto it. */\nexport function useFieldIds(\n  id?: string,\n  { description, error, success }: Pick<FieldOptions, \"description\" | \"error\" | \"success\"> = {},\n) {\n  const auto = useId();\n  const controlId = id ?? `field-${auto}`;\n  // the line under the field is one of three, and the control points at whichever is there\n  const descriptionId = (success || description) && !error ? `${controlId}-description` : undefined;\n  const errorId = error ? `${controlId}-error` : undefined;\n  return {\n    controlId,\n    descriptionId,\n    errorId,\n    aria: {\n      id: controlId,\n      \"aria-describedby\": [descriptionId, errorId].filter(Boolean).join(\" \") || undefined,\n      \"aria-invalid\": error ? true : undefined,\n      \"aria-errormessage\": errorId,\n    },\n  };\n}\n\n/** Label above (with an optional aside at the end of its row: a counter, a link), control frame, then the message. */\nexport function Field({\n  label,\n  hideLabel,\n  description,\n  error,\n  success,\n  required,\n  controlId,\n  descriptionId,\n  errorId,\n  aside,\n  className,\n  classNames,\n  style,\n  slot = \"field\",\n  requiredOnControl,\n  children,\n}: FieldOptions & {\n  controlId: string;\n  descriptionId?: string;\n  errorId?: string;\n  /** At the end of the label's row: a character count, \"Forgot password?\", \"Optional\". */\n  aside?: ReactNode;\n  className?: string;\n  classNames?: FieldClassNames;\n  style?: CSSProperties;\n  slot?: string;\n  /** The control carries `required` itself, so the label does not repeat it in the control's name. */\n  requiredOnControl?: boolean;\n  children: ReactNode;\n}) {\n  const labelNode = label != null && (\n    <Label\n      htmlFor={controlId}\n      required={required}\n      requiredOnControl={requiredOnControl}\n      className={cn(\"text-label\", hideLabel && \"sr-only\", classNames?.label)}\n    >\n      {label}\n    </Label>\n  );\n  return (\n    <div\n      data-slot={slot}\n      data-invalid={error ? \"\" : undefined}\n      style={style}\n      className={cn(styles.field, aside != null && \"reveal-host\", classNames?.root, className)}\n    >\n      {aside != null ? (\n        <div data-slot=\"field-label-row\" className={styles.labelRow}>\n          {labelNode}\n          <span data-slot=\"field-aside\" className={cn(styles.aside, classNames?.aside)}>\n            {aside}\n          </span>\n        </div>\n      ) : (\n        labelNode\n      )}\n      {children}\n      <FieldMessage\n        error={error}\n        success={success}\n        description={description}\n        errorId={errorId}\n        descriptionId={descriptionId}\n        classNames={classNames}\n      />\n    </div>\n  );\n}\n\ntype Tone = \"error\" | \"success\" | \"description\";\ninterface Line {\n  key: string;\n  tone: Tone;\n  content: ReactNode;\n}\nconst ICON = { error: AlertCircle, success: CircleCheck } as const;\n\n/**\n * The line under a field: its problem when there is one, else its confirmation, else its help. Shared by every field\n * and choice group. A change of line keeps its path: the new line grows in under the control while the old one folds\n * away above it, so what sits below glides instead of jumping, and a quick reversal turns around from where it is.\n * The leaving line is a still copy, hidden from assistive tech and inert; ids and aria point only at the line that is\n * there. It is gone when its fold ends, and by the clock as well: a line that leaves in the frame it arrived has no\n * fold to run, so no end is reported.\n */\nexport function FieldMessage({\n  error,\n  success,\n  description,\n  errorId,\n  descriptionId,\n  slot = \"field\",\n  classNames,\n}: Pick<FieldOptions, \"error\" | \"description\" | \"success\"> & {\n  errorId?: string;\n  descriptionId?: string;\n  /** The slot names' prefix: \"checkbox\" names the lines checkbox-error, checkbox-description. */\n  slot?: string;\n  classNames?: Pick<FieldClassNames, \"error\" | \"description\" | \"success\">;\n}) {\n  const tone: Tone | null = error ? \"error\" : success ? \"success\" : description ? \"description\" : null;\n  const content = error || success || description;\n  // a new text is a new line (one problem replacing another also folds and grows); rich content changes in place\n  const text = typeof content === \"string\" || typeof content === \"number\" ? String(content) : \"\";\n  const current: Line | null = tone ? { key: `${tone}\\u0000${text}`, tone, content } : null;\n  const [last, setLast] = useState<Line | null>(current);\n  const [leaving, setLeaving] = useState<Line | null>(null);\n  // the line a field is drawn with is simply there; only a change of line moves\n  const [changed, setChanged] = useState(false);\n  if ((last?.key ?? null) !== (current?.key ?? null)) {\n    // the line that was there leaves (one at a time: a line already leaving is gone at once)\n    setLeaving(last && last.key !== current?.key ? last : null);\n    setLast(current);\n    setChanged(true);\n  }\n  const box = useRef<HTMLDivElement>(null);\n  useEffect(() => {\n    if (!leaving) return;\n    // the clock is the leaving line's own longest transition, read once as it starts to leave (the fold's end event\n    // usually comes first), so a field resolves no motion tokens of its own\n    const el = box.current?.querySelector<HTMLElement>(\"[data-leaving]\");\n    const longest = el\n      ? Math.max(\n          0,\n          ...getComputedStyle(el)\n            .transitionDuration.split(\",\")\n            .map((t) => parseFloat(t) * (t.trim().endsWith(\"ms\") ? 1 : 1000) || 0),\n        )\n      : 0;\n    const id = window.setTimeout(() => setLeaving((l) => (l === leaving ? null : l)), longest + 250);\n    return () => window.clearTimeout(id);\n  }, [leaving]);\n  if (!current && !leaving) return null;\n  const shown = leaving && leaving.key === current?.key ? null : leaving;\n  const ids = { error: errorId, success: descriptionId, description: descriptionId };\n  const line = (l: Line, gone: boolean) => {\n    const Icon = l.tone === \"description\" ? null : ICON[l.tone];\n    return (\n      <div\n        key={l.key}\n        data-slot=\"field-message-line\"\n        data-leaving={gone ? \"\" : undefined}\n        data-initial={changed ? undefined : \"\"}\n        aria-hidden={gone || undefined}\n        inert={gone || undefined}\n        className={styles.line}\n        onTransitionEnd={\n          gone\n            ? (e: TransitionEvent<HTMLDivElement>) => {\n                if (e.target === e.currentTarget && e.propertyName === \"grid-template-rows\") setLeaving(null);\n              }\n            : undefined\n        }\n      >\n        <div className={styles.clip}>\n          <p\n            id={gone ? undefined : ids[l.tone]}\n            data-slot={`${slot}-${l.tone}`}\n            className={cn(styles.message, styles[l.tone], classNames?.[l.tone])}\n          >\n            {Icon && <Icon aria-hidden className={styles.icon} />}\n            {l.content}\n          </p>\n        </div>\n      </div>\n    );\n  };\n  return (\n    <div ref={box} data-slot=\"field-message\" className={styles.messages}>\n      {shown && line(shown, true)}\n      {current && line(current, false)}\n    </div>\n  );\n}\n\n/** What the end of a text field says about its work: a spinner while a value is checked, a drawn check when it works. */\nexport type FieldStatus = \"busy\" | \"success\";\n\n/** The frame a text-like control sits in; clicking anywhere on it focuses the control. */\nexport function FieldFrame({\n  size = \"md\",\n  invalid,\n  disabled,\n  readOnly,\n  multiline,\n  status,\n  statusLabel: statusLabelProp,\n  leading,\n  trailing,\n  className,\n  classNames,\n  children,\n  onPointerDown,\n  ref,\n}: {\n  size?: FieldSize;\n  invalid?: boolean;\n  disabled?: boolean;\n  readOnly?: boolean;\n  multiline?: boolean;\n  /** busy: a spinner at the end while the value is checked or saved; success: the ring closes into a check. */\n  status?: FieldStatus;\n  /** What the spinner says while busy (\"Checking\", \"Saving\"). */\n  statusLabel?: string;\n  leading?: ReactNode;\n  trailing?: ReactNode;\n  className?: string;\n  classNames?: FieldClassNames;\n  children: ReactNode;\n  onPointerDown?: (e: ReactPointerEvent<HTMLDivElement>) => void;\n  /** The frame itself, for a control that lays out by the frame's width (useWidthAs). */\n  ref?: Ref<HTMLDivElement>;\n}) {\n  const i18n = useMessages(\"_shared\", english);\n  const statusLabel = statusLabelProp === undefined ? i18n(\"statusLabel\") : statusLabelProp;\n\n  return (\n    <div\n      ref={ref}\n      data-slot=\"field-control\"\n      data-invalid={invalid ? \"\" : undefined}\n      data-disabled={disabled ? \"\" : undefined}\n      data-readonly={readOnly ? \"\" : undefined}\n      data-status={status}\n      className={cn(styles.frame, styles[size], multiline && styles.multiline, classNames?.frame, className)}\n      onPointerDown={(e) => {\n        onPointerDown?.(e);\n        // a click on the frame's padding or an adornment that is not itself interactive focuses the control\n        const t = e.target as HTMLElement;\n        if (t === e.currentTarget || (t.closest(\"[data-adornment]\") && !t.closest(\"button, a, input, [role=button]\"))) {\n          e.preventDefault();\n          e.currentTarget.querySelector<HTMLElement>(\"input, textarea\")?.focus();\n        }\n      }}\n    >\n      {leading && (\n        <span\n          data-slot=\"field-adornment\"\n          data-adornment=\"leading\"\n          className={cn(styles.adornment, classNames?.leading)}\n        >\n          {leading}\n        </span>\n      )}\n      {children}\n      {status && (\n        // one ring for both: it spins while the value is checked and closes into the check when it works\n        <span data-slot=\"field-status\" data-adornment=\"status\" className={styles.status}>\n          <Spinner size=\"sm\" state={status === \"busy\" ? \"loading\" : \"success\"} label={statusLabel} />\n        </span>\n      )}\n      {trailing && (\n        <span\n          data-slot=\"field-adornment\"\n          data-adornment=\"trailing\"\n          className={cn(styles.adornment, classNames?.trailing)}\n        >\n          {trailing}\n        </span>\n      )}\n    </div>\n  );\n}\n\n/**\n * A character count for the label's row (Field `aside`): quiet (\"58/140\") and shown while the field has attention,\n * then always shown and in words as the limit nears (\"12 left\", \"Limit reached\", \"3 over\"), so it never competes with\n * the label at rest. Assistive tech hears it only when it crosses into those words, not at every key.\n */\nexport function FieldCount({\n  length,\n  max,\n  near: nearAt,\n  slot = \"field-count\",\n  className,\n}: {\n  length: number;\n  max: number;\n  /** How many left turns it into words: by default 10 % of the limit, at least 5 (characters); 1 suits a few tags. */\n  near?: number;\n  slot?: string;\n  className?: string;\n}) {\n  const i18n = useMessages(\"_shared\", english);\n  const left = max - length;\n  const near = left <= (nearAt ?? Math.max(5, Math.ceil(max * 0.1)));\n  const state = left < 0 ? \"over\" : left === 0 ? \"full\" : near ? \"near\" : \"room\";\n  const words =\n    state === \"over\"\n      ? i18n(\"fieldOver\", { count: -left })\n      : state === \"full\"\n        ? i18n(\"fieldFull\")\n        : i18n(\"fieldLeft\", { count: left });\n  return (\n    <span\n      data-slot={slot}\n      data-state={state}\n      data-shown={state === \"room\" ? undefined : \"\"}\n      className={cn(\"reveal\", styles.count, className)}\n    >\n      <span aria-hidden>{state === \"room\" ? `${i18n.number(length)}/${i18n.number(max)}` : words}</span>\n      <span className=\"sr-only\" aria-live=\"polite\">\n        {state === \"room\" ? \"\" : words}\n      </span>\n    </span>\n  );\n}\n\n/** The class a native input or textarea needs inside a FieldFrame. */\nexport const fieldControlClass = styles.control;\n\n/** What a choice group (segmented control, radio cards) spreads onto its own root when it is a form field. */\nexport interface ChoiceFieldAria {\n  \"aria-labelledby\": string;\n  \"aria-describedby\"?: string;\n  \"aria-invalid\"?: true;\n}\n\n/**\n * Whether a choice control (segmented control, radio cards, chip group) is laid out as a form field, its label shown\n * above like every field's: when asked (`field`), when it has a description, error or required mark, and whenever its\n * label is not hidden. A view switch or a quick filter passes `hideLabel`: its label stays for assistive tech only.\n * (Trials t16 and t19: agents wrote <SegmentedControl label=\"Catering needed\" …> and the question never showed.)\n */\nexport function choiceIsField(\n  field: boolean | undefined,\n  label: ReactNode,\n  hideLabel: boolean | undefined,\n  marked: boolean,\n) {\n  return field ?? (marked || (label != null && label !== \"\" && !hideLabel));\n}\n\n/**\n * A choice group as a form field: the visible label above (with the required marker), the group, then its help or its\n * problem — the same frame and message every text field has. Groups that name themselves only for assistive tech\n * (a view switch in a toolbar) do not use it.\n */\nexport function ChoiceField({\n  slot,\n  label,\n  hideLabel,\n  required,\n  description,\n  error,\n  className,\n  style,\n  classNames,\n  requiredOnControl,\n  children,\n}: Omit<FieldOptions, \"size\" | \"success\"> & {\n  slot: string;\n  /** The group carries `aria-required` itself (a radiogroup), so the label does not repeat it in the group's name. */\n  requiredOnControl?: boolean;\n  className?: string;\n  style?: CSSProperties;\n  classNames?: Pick<FieldClassNames, \"label\" | \"description\" | \"error\">;\n  children: (aria: ChoiceFieldAria) => ReactNode;\n}) {\n  const auto = useId();\n  const labelId = `choice-${auto}-label`;\n  const messageId = error || description ? `choice-${auto}-message` : undefined;\n  return (\n    <div data-slot={slot} data-invalid={error ? \"\" : undefined} style={style} className={cn(styles.field, className)}>\n      <Label\n        id={labelId}\n        required={required}\n        requiredOnControl={requiredOnControl}\n        className={cn(\"text-label\", hideLabel && \"sr-only\", classNames?.label)}\n      >\n        {label}\n      </Label>\n      {children({\n        \"aria-labelledby\": labelId,\n        ...(messageId ? { \"aria-describedby\": messageId } : {}),\n        ...(error ? { \"aria-invalid\": true as const } : {}),\n      })}\n      <FieldMessage\n        error={error}\n        description={description}\n        errorId={messageId}\n        descriptionId={messageId}\n        classNames={classNames}\n      />\n    </div>\n  );\n}\n"},{"path":"beamline/components/_shared/glide.tsx","type":"registry:file","target":"src/ui/beamline/components/_shared/glide.tsx","content":"\"use client\";\n\nimport { useEffect, useLayoutEffect, useRef, useState, type RefObject } from \"react\";\nimport { cn } from \"../../lib/utils\";\nimport overlay from \"./overlay.module.css\";\n\n/**\n * The gliding highlight for a list whose active row is tracked in state (command menu, listbox): one plate travels to\n * the active row for the arrow keys and the pointer alike, over --pui-duration-fast. It appears in place (no travel)\n * the first time and whenever `reset` changes (a new page or a new query), so typing never sends it flying.\n * The list must be the plate's offset parent (position: relative); rows stay above it (overlay.item is z-index 1).\n */\nexport function GlidePlate({\n  list,\n  selector,\n  reset,\n  axis = \"y\",\n  className,\n}: {\n  list: RefObject<HTMLElement | null>;\n  /** Finds the active row inside `list`; null when nothing is active. */\n  selector: string | null;\n  reset?: unknown;\n  /** \"y\" for a list (the plate spans the width); \"xy\" for a row or grid of cells (it takes each cell's size). */\n  axis?: \"y\" | \"xy\";\n  className?: string;\n}) {\n  const [plate, setPlate] = useState<{ x: number; y: number; w: number; h: number; jump: boolean } | null>(null);\n  const lastReset = useRef(reset);\n  const self = useRef<HTMLSpanElement>(null);\n  // eslint-disable-next-line react-hooks/exhaustive-deps -- every render on purpose; setPlate bails out when unchanged\n  useLayoutEffect(() => {\n    // the list holds the plate, and React attaches a parent's ref only after its children's layout effects: on the\n    // first commit the list is the plate's own parent (it placed itself only when something rendered again later)\n    const host = list.current ?? self.current?.parentElement;\n    const row = selector ? host?.querySelector<HTMLElement>(selector) : null;\n    const fresh = lastReset.current !== reset;\n    lastReset.current = reset;\n    if (!row) {\n      setPlate((p) => (p && p.h ? { ...p, h: 0 } : p));\n      return;\n    }\n    const x = row.offsetLeft,\n      y = row.offsetTop,\n      w = row.offsetWidth,\n      h = row.offsetHeight;\n    setPlate((p) =>\n      p && p.x === x && p.y === y && p.w === w && p.h === h && !fresh ? p : { x, y, w, h, jump: fresh || !p?.h },\n    );\n    // every render: rows can arrive or change height without the selector changing; an unchanged place keeps the state\n  });\n  return (\n    <span\n      ref={self}\n      aria-hidden\n      data-slot=\"list-highlight\"\n      className={cn(overlay.glide, className)}\n      data-on={plate?.h ? \"\" : undefined}\n      data-jump={plate?.jump ? \"\" : undefined}\n      data-axis={axis}\n      style={\n        !plate\n          ? undefined\n          : axis === \"y\"\n            ? { transform: `translateY(${plate.y}px)`, height: plate.h || undefined }\n            : { transform: `translate(${plate.x}px, ${plate.y}px)`, width: plate.w, height: plate.h || undefined }\n      }\n    />\n  );\n}\n\n/**\n * A GlidePlate for lists whose highlight is the pointer or keyboard focus rather than state (time picker, plain option\n * lists): it follows the row under the pointer or holding focus, and fades when neither is in the list. Rows drop\n * their own hover and focus tint.\n */\nexport function FollowPlate({\n  list,\n  rows,\n  className,\n}: {\n  list: RefObject<HTMLElement | null>;\n  /** Matches a row inside `list`, e.g. \"[role=option]\". */\n  rows: string;\n  className?: string;\n}) {\n  const [hot, setHot] = useState<string | null>(null);\n  // after the commit, when the list's ref is attached (a layout effect here ran before it and never listened)\n  useEffect(() => {\n    const el = list.current;\n    if (!el) return;\n    let n = 0;\n    const mark = (target: EventTarget | null) => {\n      const row = (target as HTMLElement | null)?.closest?.<HTMLElement>(rows);\n      if (!row || !el.contains(row)) return;\n      row.dataset.glideKey ??= String(++n);\n      setHot(row.dataset.glideKey);\n    };\n    const over = (e: Event) => mark(e.target);\n    const leave = () => {\n      if (!el.contains(document.activeElement)) setHot(null);\n    };\n    const blur = (e: FocusEvent) => {\n      if (!el.contains(e.relatedTarget as Node)) setHot(null);\n    };\n    el.addEventListener(\"pointerover\", over);\n    el.addEventListener(\"focusin\", over);\n    el.addEventListener(\"pointerleave\", leave);\n    el.addEventListener(\"focusout\", blur);\n    return () => {\n      el.removeEventListener(\"pointerover\", over);\n      el.removeEventListener(\"focusin\", over);\n      el.removeEventListener(\"pointerleave\", leave);\n      el.removeEventListener(\"focusout\", blur);\n    };\n  }, [list, rows]);\n  return <GlidePlate list={list} selector={hot ? `[data-glide-key=\"${hot}\"]` : null} className={className} />;\n}\n"},{"path":"beamline/components/_shared/icon-action.module.css","type":"registry:file","target":"src/ui/beamline/components/_shared/icon-action.module.css","content":"@layer properties, theme, base, components, utilities;\n/* The small square action that sits inside another element: a field's clear and open buttons, a chip's remove, a\n   toast's close, a carousel's previous and next. One recipe so every one of them answers alike: quiet ink at rest,\n   the hover plate at once, the press at once, both let go over --pui-motion-out. Its corner is the chip radius: under\n   the nested-corner rule (.nest-corner) a part whose own corner is the chip never changes inside a rounded frame. */\n@layer components {\n  .root {\n    position: relative;\n    display: grid;\n    flex-shrink: 0;\n    place-items: center;\n    inline-size: var(--_size);\n    block-size: var(--_size);\n    border-radius: var(--pui-radius-chip);\n    color: var(--pui-ink-3);\n    /* opacity and translate stay in the list so a .reveal action keeps its own arrival whichever rule wins */\n    transition:\n      background-color var(--pui-motion-out) var(--pui-ease-default),\n      color var(--pui-motion-out) var(--pui-ease-default),\n      transform var(--pui-motion-out) var(--pui-ease-default),\n      opacity var(--pui-motion-out) var(--pui-ease-default),\n      translate var(--pui-motion-out) var(--pui-ease-default);\n  }\n  .root:hover:not(:disabled),\n  .root[data-pressed] {\n    background-color: var(--pui-hover);\n    color: var(--pui-ink);\n  }\n  .root:hover {\n    transition-duration: 0ms;\n  }\n  .root:active:not(:disabled) {\n    transform: scale(var(--pui-press-scale));\n    transition-duration: 0ms;\n  }\n  .root:disabled {\n    cursor: default;\n    opacity: 0.4;\n  }\n  .root[data-tone=\"ink-2\"] {\n    color: var(--pui-ink-2);\n  }\n  .root[data-tone=\"inherit\"] {\n    color: inherit;\n  }\n  .root[data-tone=\"inherit\"]:hover:not(:disabled) {\n    color: inherit;\n  }\n  /* on an inverted (ink) surface: inverse ink, a faint inverse plate */\n  .root[data-tone=\"inverse\"] {\n    color: color-mix(in oklab, var(--pui-ink-inverse) 72%, transparent);\n  }\n  .root[data-tone=\"inverse\"]:hover:not(:disabled),\n  .root[data-tone=\"inverse\"][data-pressed] {\n    background-color: color-mix(in oklab, var(--pui-ink-inverse) 12%, transparent);\n    color: var(--pui-ink-inverse);\n  }\n\n  .xs {\n    --_size: 1.25rem;\n  }\n  /* a 20px action still takes a 24px hit (WCAG 2.5.8): the bleed is outside the drawn square */\n  .xs::after {\n    position: absolute;\n    inset: calc((var(--pui-hit-min) - 1.25rem) / -2);\n    content: \"\";\n  }\n  .sm {\n    --_size: 1.5rem;\n  }\n  .md {\n    --_size: 1.75rem;\n  }\n  .lg {\n    --_size: 2rem;\n  }\n}\n"},{"path":"beamline/components/_shared/icon-action.tsx","type":"registry:file","target":"src/ui/beamline/components/_shared/icon-action.tsx","content":"\"use client\";\n// organism-allow-file: raw-control -- the shared part every element draws this control from\n\nimport type { ButtonHTMLAttributes, Ref } from \"react\";\nimport { cn } from \"../../lib/utils\";\nimport styles from \"./icon-action.module.css\";\n\n/** 20 · 24 · 28 · 32 px. A 20px action keeps a 24px hit outside its square. */\nexport type IconActionSize = \"xs\" | \"sm\" | \"md\" | \"lg\";\n\nexport interface IconActionProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n  /** The action's name: the button holds only an icon. */\n  \"aria-label\": string;\n  size?: IconActionSize;\n  /** Rest ink: ink-3 (the default, an action beside content), ink-2 (an action that is the row's point), inverse (on\n   *  an inverted ink surface) or inherit (on a painted surface that brings its own colours). */\n  tone?: \"ink-3\" | \"ink-2\" | \"inverse\" | \"inherit\";\n  /** Holds the hover plate while what it opens is open, or while it is switched on. */\n  pressed?: boolean;\n  ref?: Ref<HTMLButtonElement>;\n}\n\n/**\n * The small square icon action inside another element (clear, remove, dismiss, previous, next, retry). One recipe for\n * all of them; a full-size action with words is a Button, and Button with iconOnly is the standalone square.\n */\nexport function IconAction({\n  size = \"sm\",\n  tone = \"ink-3\",\n  pressed,\n  type = \"button\",\n  className,\n  ref,\n  ...props\n}: IconActionProps) {\n  return (\n    <button\n      ref={ref}\n      type={type}\n      data-tone={tone === \"ink-3\" ? undefined : tone}\n      data-pressed={pressed ? \"\" : undefined}\n      className={cn(styles.root, styles[size], className)}\n      {...props}\n    />\n  );\n}\n"},{"path":"beamline/components/_shared/messages.ts","type":"registry:file","target":"src/ui/beamline/components/_shared/messages.ts","content":"import type { MessageDefinitions } from \"../../runtime/messages\";\n/** Built-in English copy for this helper only. */\nexport const english = {\n  results: {\n    one: \"{count} result\",\n    other: \"{count} results\",\n  },\n  noMatch: \"No match for {query}\",\n  fieldOver: \"{count} over\",\n  fieldFull: \"Limit reached\",\n  fieldLeft: \"{count} left\",\n  foldMore: \"{list} and {count} more\",\n  foldShow: \"Show {count} more {noun}: {list}\",\n  statusLabel: \"Checking\",\n} satisfies MessageDefinitions;\n"},{"path":"beamline/components/_shared/overlay.module.css","type":"registry:file","target":"src/ui/beamline/components/_shared/overlay.module.css","content":"@layer properties, theme, base, components, utilities;\n/* the source morph's moving parts: the clip's four sides, the radius and the offset back to the trigger */\n@property --ci-t {\n  syntax: \"<length-percentage>\";\n  inherits: false;\n  initial-value: -48px;\n}\n@property --ci-r {\n  syntax: \"<length-percentage>\";\n  inherits: false;\n  initial-value: -48px;\n}\n@property --ci-b {\n  syntax: \"<length-percentage>\";\n  inherits: false;\n  initial-value: -48px;\n}\n@property --ci-l {\n  syntax: \"<length-percentage>\";\n  inherits: false;\n  initial-value: -48px;\n}\n@property --ci-x {\n  syntax: \"<length>\";\n  inherits: false;\n  initial-value: 0px;\n}\n@property --ci-y {\n  syntax: \"<length>\";\n  inherits: false;\n  initial-value: 0px;\n}\n@layer components {\n  /* Every floating layer in the system: one surface (painted by the overlay role of the look in force), one menu-item\n   look, one scrim, one enter and exit. A layer placed against a trigger opens out of it (the source morph below); one\n   without a placement arrives in --pui-motion-in scaling from its origin. Each leaves in --pui-motion-out; Radix keeps\n   it mounted until the exit animation ends. Reduced motion makes both instant (the duration tokens become 1ms). */\n  .surface {\n    z-index: var(--pui-z-popover);\n    min-width: 8rem;\n    /* never past the screen: as wide and as tall as the room beside the trigger (Radix measures it) */\n    max-width: var(--radix-popper-available-width, none);\n    max-height: var(--radix-popper-available-height, 70vh);\n    overflow: auto;\n    border-radius: var(--pui-overlay-radius, var(--pui-radius-card));\n    color: var(--pui-ink);\n    transform-origin: var(--radix-popper-transform-origin, var(--radix-dropdown-menu-content-transform-origin, center));\n    outline: none;\n  }\n  .surface[data-state=\"open\"],\n  .surface[data-state=\"delayed-open\"],\n  .surface[data-state=\"instant-open\"] {\n    animation: pop-in var(--pui-motion-in) var(--pui-ease-default);\n  }\n  .surface[data-state=\"closed\"] {\n    animation: pop-out var(--pui-motion-out) var(--pui-ease-default) forwards;\n  }\n\n  /* The source morph (research/morphing-interfaces-2026-10-04, M3): a layer placed against a trigger does not fade in\n     beside it, it opens out of it. It starts as the trigger's own box (Radix gives its size and the side and alignment\n     it was placed on), offset back onto the trigger, and grows: the side nearest the trigger is there at once, the\n     sides across follow, the far side arrives last (~200 ms), so the rows by the trigger are readable within the\n     ruled 90 ms while the outline settles. Content fades in over those 90 ms. It closes back into the trigger in the\n     ruled 180 ms. The clip ends 48px outside the box so the layer's shadow is never cut. Reduced motion: instant. */\n  .surface[data-side] {\n    --_aw: var(--radix-popper-anchor-width, 0px);\n    --_ah: var(--radix-popper-anchor-height, 0px);\n    --_gap: 6px;\n    --from-t: -48px;\n    --from-r: -48px;\n    --from-b: -48px;\n    --from-l: -48px;\n    --from-x: 0px;\n    --from-y: 0px;\n    --d-near: calc(var(--pui-duration-standard) * 0.55);\n    --d-cross: calc(var(--pui-duration-standard) * 0.85);\n    --d-far: var(--pui-duration-standard);\n    clip-path: inset(\n      var(--ci-t) var(--ci-r) var(--ci-b) var(--ci-l) round var(--pui-overlay-radius, var(--pui-radius-card))\n    );\n    translate: var(--ci-x) var(--ci-y);\n  }\n  .surface[data-side=\"bottom\"] {\n    --from-t: 0px;\n    --from-b: calc(100% - var(--_ah));\n    --from-y: calc(-1 * (var(--_ah) + var(--_gap)));\n    --d-t: var(--d-near);\n    --d-b: var(--d-far);\n    --d-l: var(--d-cross);\n    --d-r: var(--d-cross);\n  }\n  .surface[data-side=\"top\"] {\n    --from-b: 0px;\n    --from-t: calc(100% - var(--_ah));\n    --from-y: calc(var(--_ah) + var(--_gap));\n    --d-b: var(--d-near);\n    --d-t: var(--d-far);\n    --d-l: var(--d-cross);\n    --d-r: var(--d-cross);\n  }\n  .surface[data-side=\"right\"] {\n    --from-l: 0px;\n    --from-r: calc(100% - var(--_aw));\n    --from-x: calc(-1 * (var(--_aw) + var(--_gap)));\n    --d-l: var(--d-near);\n    --d-r: var(--d-far);\n    --d-t: var(--d-cross);\n    --d-b: var(--d-cross);\n  }\n  .surface[data-side=\"left\"] {\n    --from-r: 0px;\n    --from-l: calc(100% - var(--_aw));\n    --from-x: calc(var(--_aw) + var(--_gap));\n    --d-r: var(--d-near);\n    --d-l: var(--d-far);\n    --d-t: var(--d-cross);\n    --d-b: var(--d-cross);\n  }\n  /* alignment along the trigger: which part of the layer the trigger sits over */\n  .surface:is([data-side=\"bottom\"], [data-side=\"top\"])[data-align=\"start\"] {\n    --from-l: 0px;\n    --from-r: calc(100% - var(--_aw));\n  }\n  .surface:is([data-side=\"bottom\"], [data-side=\"top\"])[data-align=\"end\"] {\n    --from-l: calc(100% - var(--_aw));\n    --from-r: 0px;\n  }\n  .surface:is([data-side=\"bottom\"], [data-side=\"top\"])[data-align=\"start\"]:dir(rtl) {\n    --from-l: calc(100% - var(--_aw));\n    --from-r: 0px;\n  }\n  .surface:is([data-side=\"bottom\"], [data-side=\"top\"])[data-align=\"end\"]:dir(rtl) {\n    --from-l: 0px;\n    --from-r: calc(100% - var(--_aw));\n  }\n  .surface:is([data-side=\"bottom\"], [data-side=\"top\"])[data-align=\"center\"] {\n    --from-l: calc((100% - var(--_aw)) / 2);\n    --from-r: calc((100% - var(--_aw)) / 2);\n  }\n  .surface:is([data-side=\"left\"], [data-side=\"right\"])[data-align=\"start\"] {\n    --from-t: 0px;\n    --from-b: calc(100% - var(--_ah));\n  }\n  .surface:is([data-side=\"left\"], [data-side=\"right\"])[data-align=\"end\"] {\n    --from-t: calc(100% - var(--_ah));\n    --from-b: 0px;\n  }\n  .surface:is([data-side=\"left\"], [data-side=\"right\"])[data-align=\"center\"] {\n    --from-t: calc((100% - var(--_ah)) / 2);\n    --from-b: calc((100% - var(--_ah)) / 2);\n  }\n  .surface[data-side]:is([data-state=\"open\"], [data-state=\"delayed-open\"], [data-state=\"instant-open\"]) {\n    animation:\n      grow-t var(--d-t) var(--pui-ease-out-strong),\n      grow-r var(--d-r) var(--pui-ease-out-strong),\n      grow-b var(--d-b) var(--pui-ease-out-strong),\n      grow-l var(--d-l) var(--pui-ease-out-strong),\n      grow-xy var(--d-cross) var(--pui-ease-out-strong),\n      settling var(--d-far) step-end;\n  }\n  .surface[data-side]:is([data-state=\"open\"], [data-state=\"delayed-open\"], [data-state=\"instant-open\"]) > * {\n    animation: content-in var(--pui-motion-in) var(--pui-ease-default) both;\n  }\n  /* one duration for every part of the exit: the layer unmounts when the first of them ends */\n  .surface[data-side][data-state=\"closed\"] {\n    animation: shrink var(--pui-motion-out) var(--pui-ease-exit) forwards;\n  }\n  .surface[data-side][data-state=\"closed\"] > * {\n    animation: content-out var(--pui-motion-in) var(--pui-ease-default) forwards;\n  }\n  @keyframes grow-t {\n    from {\n      --ci-t: var(--from-t);\n    }\n  }\n  @keyframes grow-r {\n    from {\n      --ci-r: var(--from-r);\n    }\n  }\n  @keyframes grow-b {\n    from {\n      --ci-b: var(--from-b);\n    }\n  }\n  @keyframes grow-l {\n    from {\n      --ci-l: var(--from-l);\n    }\n  }\n  @keyframes grow-xy {\n    from {\n      --ci-x: var(--from-x);\n      --ci-y: var(--from-y);\n    }\n  }\n  /* it starts over its own trigger: until it has grown, the press that opened it must not land on a row */\n  @keyframes settling {\n    0%,\n    100% {\n      pointer-events: none;\n    }\n  }\n  @keyframes shrink {\n    to {\n      --ci-t: var(--from-t);\n      --ci-r: var(--from-r);\n      --ci-b: var(--from-b);\n      --ci-l: var(--from-l);\n      --ci-x: var(--from-x);\n      --ci-y: var(--from-y);\n      opacity: 0;\n    }\n  }\n  @keyframes content-in {\n    from {\n      opacity: 0;\n    }\n  }\n  @keyframes content-out {\n    to {\n      opacity: 0;\n    }\n  }\n  .padded {\n    padding: var(--pui-pad-popover);\n  }\n  .menu {\n    padding: var(--pui-space-1);\n  }\n  @keyframes pop-in {\n    from {\n      opacity: 0;\n      transform: scale(0.97);\n    }\n  }\n  @keyframes pop-out {\n    to {\n      opacity: 0;\n      transform: scale(0.98);\n    }\n  }\n\n  /* rows (and the gliding plate) nest in the list: its radius minus its padding, never rounder than a chip; on the\n     row itself, so any list that uses .item gets it */\n  .item,\n  .glide {\n    --_item-radius: min(\n      var(--pui-radius-chip),\n      calc(var(--pui-overlay-radius, var(--pui-radius-card)) - var(--pui-space-1))\n    );\n  }\n\n  /* menu rows: shared by dropdown, context menu, menubar, select, combobox lists */\n  .item {\n    position: relative;\n    z-index: 1;\n    display: flex;\n    align-items: center;\n    gap: var(--pui-space-2);\n    min-height: var(--pui-control-height-sm);\n    padding: 0 var(--pui-space-2);\n    /* nested in the list: the overlay's radius minus its padding, never rounder than a chip */\n    border-radius: var(--_item-radius);\n    color: var(--pui-ink);\n    font-size: var(--pui-text-sm);\n    cursor: default;\n    user-select: none;\n    outline: none;\n  }\n  /* on a touch screen a row is a finger's target: the touch height (44px) from the tokens; a mouse keeps the dense row */\n  @media (pointer: coarse) {\n    .item {\n      min-height: var(--pui-control-height-touch);\n    }\n  }\n  /* a destructive row speaks in the danger ink only while it can be used: disabled wins (muted ink, no alarm for an\n     action that cannot happen) */\n  .item[data-tone=\"danger\"]:not([data-disabled]) {\n    color: var(--pui-red);\n  }\n  .item[data-disabled] {\n    color: var(--pui-ink-3);\n    pointer-events: none;\n  }\n  .item :where(svg) {\n    width: var(--pui-icon-md);\n    height: var(--pui-icon-md);\n    flex-shrink: 0;\n    color: var(--pui-ink-3);\n  }\n  .item[data-tone=\"danger\"]:not([data-disabled]) :where(svg) {\n    color: currentColor;\n  }\n  .item[data-highlighted]:not([data-glide]) {\n    background: var(--pui-hover-2);\n  }\n  /* a press is acknowledged at once, over the plate, before the menu closes or the row toggles */\n  .item:active:not([data-disabled]) {\n    background: var(--pui-hover);\n  }\n  .shortcut {\n    margin-inline-start: auto;\n    padding-inline-start: var(--pui-space-4);\n    color: var(--pui-ink-3);\n    font-size: var(--pui-text-xs);\n    letter-spacing: var(--pui-tracking-mono-caps);\n  }\n  .heading {\n    padding: var(--pui-space-1-5) var(--pui-space-2) var(--pui-space-1);\n    color: var(--pui-ink-3);\n    font-size: var(--pui-text-xs);\n    font-weight: var(--pui-weight-medium);\n  }\n  .separator {\n    height: 1px;\n    margin: var(--pui-space-1) calc(var(--pui-space-1) * -1);\n    background: var(--pui-line);\n  }\n  .check {\n    margin-inline-start: auto;\n    color: var(--pui-accent) !important;\n  }\n  /* a check arrives in its row as the value changes (at once): it grows from the middle over the arrival */\n  .check :where(svg) {\n    animation: check-in var(--pui-motion-in) var(--pui-ease-out-strong);\n  }\n  @keyframes check-in {\n    from {\n      opacity: 0;\n      scale: calc(1 - 0.5 * var(--pui-motion-travel, 1));\n    }\n  }\n  /* the gliding highlight: one plate moves between rows for the pointer and the arrow keys; it appears in place */\n  .glide {\n    position: absolute;\n    z-index: 0;\n    inset-inline: var(--pui-space-1);\n    top: 0;\n    border-radius: var(--_item-radius);\n    background: var(--pui-hover-2);\n    pointer-events: none;\n    opacity: 0;\n    transition: opacity var(--pui-motion-out) var(--pui-ease-default);\n  }\n  .glide[data-on] {\n    opacity: 1;\n    transition:\n      transform var(--pui-duration-fast) var(--pui-ease-standard),\n      height var(--pui-duration-fast) var(--pui-ease-standard),\n      opacity 0ms;\n  }\n  .glide[data-jump] {\n    transition: opacity 0ms;\n  }\n  /* a plate over a row or grid of cells takes each cell's size and travels both ways */\n  .glide[data-axis=\"xy\"] {\n    inset-inline: auto;\n    left: 0;\n  }\n  .glide[data-axis=\"xy\"][data-on] {\n    transition:\n      transform var(--pui-duration-fast) var(--pui-ease-standard),\n      width var(--pui-duration-fast) var(--pui-ease-standard),\n      height var(--pui-duration-fast) var(--pui-ease-standard),\n      opacity 0ms;\n  }\n\n  /* a layer that has begun to close is out of the way at once: for the length of its exit it takes no pointer, so a tap\n     meant for the page behind (the next row, the button the panel covered) lands there, never on the leaving ghost.\n     Focus has already gone back (Radix) and it unmounts when the exit ends. */\n  .scrim[data-state=\"closed\"],\n  .surface[data-state=\"closed\"],\n  .dialog[data-state=\"closed\"],\n  .sheet[data-state=\"closed\"] {\n    pointer-events: none;\n  }\n\n  /* modal layers */\n  .scrim {\n    position: fixed;\n    inset: 0;\n    z-index: var(--pui-z-overlay);\n    background: var(--pui-scrim);\n    backdrop-filter: blur(var(--pui-blur-overlay));\n  }\n  .scrim[data-state=\"open\"] {\n    animation: fade-in var(--pui-fade-in) var(--pui-ease-default);\n  }\n  .scrim[data-state=\"closed\"] {\n    animation: fade-out var(--pui-fade-out) var(--pui-ease-default) forwards;\n  }\n  @keyframes fade-in {\n    from {\n      opacity: 0;\n    }\n  }\n  @keyframes fade-out {\n    to {\n      opacity: 0;\n    }\n  }\n  .dialog {\n    /* the content answers to the dialog's own width (a footer's buttons share the row on a phone) */\n    container-type: inline-size;\n    position: fixed;\n    z-index: var(--pui-z-modal);\n    left: 50%;\n    top: 50%;\n    width: min(calc(100vw - var(--pui-space-8)), var(--pui-dialog-width, var(--_dialog-width, 440px)));\n    max-height: calc(100dvh - var(--pui-space-12));\n    overflow: hidden;\n    translate: -50% -50%;\n    border-radius: var(--pui-dialog-radius, var(--pui-radius-window));\n    color: var(--pui-ink);\n    outline: none;\n    /* a size chosen while open (a step that needs more room) eases the width in place, centred */\n    transition: width var(--pui-duration-standard) var(--pui-ease-standard);\n  }\n  .dialog[data-state=\"open\"] {\n    animation: dialog-in var(--pui-duration-standard) var(--pui-ease-enter);\n  }\n  .dialog[data-state=\"closed\"] {\n    animation: dialog-out var(--pui-motion-out) var(--pui-ease-default) forwards;\n  }\n  /* A dialog opened from something (use-open-from.ts) grows out of it: it starts as the opener's box, offset back onto\n     it, and grows to its own place over the considered duration while its content fades in; it closes back into the\n     opener in the ruled 180 ms. Shares the source morph's moving parts and guard with .surface. */\n  .dialog[data-open-from] {\n    clip-path: inset(\n      var(--ci-t) var(--ci-r) var(--ci-b) var(--ci-l) round var(--pui-dialog-radius, var(--pui-radius-window))\n    );\n    transform: translate(var(--ci-x), var(--ci-y));\n  }\n  .dialog[data-open-from][data-state=\"open\"] {\n    animation:\n      grow-t var(--pui-duration-considered) var(--pui-ease-out-strong),\n      grow-r var(--pui-duration-considered) var(--pui-ease-out-strong),\n      grow-b var(--pui-duration-considered) var(--pui-ease-out-strong),\n      grow-l var(--pui-duration-considered) var(--pui-ease-out-strong),\n      grow-xy calc(var(--pui-duration-considered) * 0.9) var(--pui-ease-out-strong),\n      settling var(--pui-duration-considered) step-end;\n  }\n  .dialog[data-open-from][data-state=\"open\"] > * {\n    animation: content-in var(--pui-duration-standard) var(--pui-ease-default) calc(var(--pui-duration-standard) * 0.35)\n      both;\n  }\n  .dialog[data-open-from][data-state=\"closed\"] {\n    animation: shrink var(--pui-motion-out) var(--pui-ease-exit) forwards;\n  }\n  .dialog[data-open-from][data-state=\"closed\"] > * {\n    animation: content-out var(--pui-motion-in) var(--pui-ease-default) forwards;\n  }\n  /* A sheet: a panel from an edge. It slides in from its edge over the considered duration on the drawer curve and\n     goes back out to that edge in the ruled departure (a layer closes back into where it came from). The edge is\n     logical: an end (\"right\") sheet comes from the left in a right-to-left page. Its content answers to its width. */\n  .sheet {\n    --_sx: 0px;\n    --_sy: 0px;\n    container-type: inline-size;\n    /* where a finger has swiped it toward its edge (sheet.tsx); it settles back over the departure */\n    translate: var(--_swipe, 0px) 0;\n  }\n  /* a side panel leaves sideways pans to the swipe and keeps vertical scrolling native, in its body too */\n  .sheet:is([data-side=\"left\"], [data-side=\"right\"]),\n  .sheet:is([data-side=\"left\"], [data-side=\"right\"]) [data-slot=\"sheet-body\"] {\n    touch-action: pan-y;\n  }\n  .sheet:is([data-side=\"left\"], [data-side=\"right\"]) {\n    transition:\n      var(--m-transition),\n      translate var(--pui-motion-out) var(--pui-ease-default);\n  }\n  .sheet[data-swiping] {\n    transition: none;\n  }\n  .sheet[data-side=\"right\"] {\n    --_sx: 100%;\n  }\n  .sheet[data-side=\"left\"] {\n    --_sx: -100%;\n  }\n  .sheet[data-side=\"right\"]:dir(rtl) {\n    --_sx: -100%;\n  }\n  .sheet[data-side=\"left\"]:dir(rtl) {\n    --_sx: 100%;\n  }\n  .sheet[data-side=\"top\"] {\n    --_sy: -100%;\n  }\n  .sheet[data-side=\"bottom\"] {\n    --_sy: 100%;\n  }\n  .sheet[data-state=\"open\"] {\n    animation: sheet-in var(--pui-duration-considered) var(--pui-ease-drawer) both;\n  }\n  .sheet[data-state=\"closed\"] {\n    animation: sheet-out var(--pui-motion-out) var(--pui-ease-exit) forwards;\n  }\n  @keyframes sheet-in {\n    from {\n      translate: var(--_sx) var(--_sy);\n    }\n  }\n  @keyframes sheet-out {\n    to {\n      translate: var(--_sx) var(--_sy);\n    }\n  }\n  @keyframes dialog-in {\n    from {\n      opacity: 0;\n      transform: scale(0.96);\n    }\n  }\n  @keyframes dialog-out {\n    to {\n      opacity: 0;\n      transform: scale(0.98);\n    }\n  }\n}\n\n/* Reduced motion: surfaces and dialogs fade without scaling or growing, over the fade tokens (restrained under reduced,\n   1ms under none; APPEARANCE A06). */\n@media (prefers-reduced-motion: reduce) {\n  .surface,\n  .dialog,\n  .sheet {\n    animation-name: fade-in !important;\n    animation-duration: var(--pui-fade-in) !important;\n  }\n  .surface[data-state=\"closed\"],\n  .dialog[data-state=\"closed\"],\n  .sheet[data-state=\"closed\"] {\n    animation-name: fade-out !important;\n    animation-duration: var(--pui-fade-out) !important;\n  }\n}\n@layer components {\n  :global(.pui[data-motion=\"reduced\"]) .surface,\n  :global(.pui[data-motion=\"none\"]) .surface,\n  :global(.pui[data-motion=\"reduced\"]) .dialog,\n  :global(.pui[data-motion=\"none\"]) .dialog,\n  :global(.pui[data-motion=\"reduced\"]) .sheet,\n  :global(.pui[data-motion=\"none\"]) .sheet {\n    animation-name: fade-in;\n    animation-duration: var(--pui-fade-in);\n  }\n  :global(.pui[data-motion=\"reduced\"]) .surface[data-state=\"closed\"],\n  :global(.pui[data-motion=\"none\"]) .surface[data-state=\"closed\"],\n  :global(.pui[data-motion=\"reduced\"]) .dialog[data-state=\"closed\"],\n  :global(.pui[data-motion=\"none\"]) .dialog[data-state=\"closed\"],\n  :global(.pui[data-motion=\"reduced\"]) .sheet[data-state=\"closed\"],\n  :global(.pui[data-motion=\"none\"]) .sheet[data-state=\"closed\"] {\n    animation-name: fade-out;\n    animation-duration: var(--pui-fade-out);\n  }\n}\n/* CSS-module composition only; visual rules stay in the component layer. */\n.surface {\n  composes: m-overlay from global;\n}\n.dialog {\n  composes: m-overlay from global;\n}\n"},{"path":"beamline/components/_shared/roll.ts","type":"registry:file","target":"src/ui/beamline/components/_shared/roll.ts","content":"/**\n * Rolls the text of a field or any text part from one value to the next (number field steps, a time segment): the old text leaves up and the new one\n * arrives from below for an increase, the other way for a decrease. The field's value changes at once; a still copy of\n * each text is drawn over the field for the roll and removed after, so typing and the caret are never touched.\n */\nconst running = new WeakMap<HTMLElement, () => void>();\n\nexport function rollText(\n  input: HTMLElement | null,\n  from: string,\n  to: string,\n  direction: 1 | -1,\n  { duration, easing }: { duration: number; easing: string },\n) {\n  if (!input || from === to || duration < 2 || !input.offsetParent) return;\n  running.get(input)?.();\n  const host = input.offsetParent as HTMLElement;\n  const cs = getComputedStyle(input);\n  const box = document.createElement(\"span\");\n  box.setAttribute(\"aria-hidden\", \"true\");\n  Object.assign(box.style, {\n    position: \"absolute\",\n    left: `${input.offsetLeft}px`,\n    top: `${input.offsetTop}px`,\n    width: `${input.offsetWidth}px`,\n    height: `${input.offsetHeight}px`,\n    overflow: \"hidden\",\n    pointerEvents: \"none\",\n  });\n  const line = (text: string) => {\n    const s = document.createElement(\"span\");\n    s.textContent = text;\n    Object.assign(s.style, {\n      position: \"absolute\",\n      inset: \"0\",\n      display: \"flex\",\n      alignItems: \"center\",\n      justifyContent:\n        cs.textAlign === \"right\" || cs.textAlign === \"end\"\n          ? \"flex-end\"\n          : cs.textAlign === \"center\"\n            ? \"center\"\n            : \"flex-start\",\n      paddingInline: `${cs.paddingLeft} ${cs.paddingRight}`,\n      font: cs.font,\n      fontVariantNumeric: cs.fontVariantNumeric,\n      letterSpacing: cs.letterSpacing,\n      color: cs.color,\n      whiteSpace: \"pre\",\n    });\n    return s;\n  };\n  const old = line(from),\n    next = line(to);\n  box.append(old, next);\n  host.appendChild(box);\n  const color = input.style.color;\n  input.style.color = \"transparent\";\n  const shift = 0.7 * direction;\n  const a = old.animate(\n    [\n      { transform: \"none\", opacity: 1 },\n      { transform: `translateY(${-shift * 100}%)`, opacity: 0 },\n    ],\n    { duration, easing },\n  );\n  next.animate(\n    [\n      { transform: `translateY(${shift * 100}%)`, opacity: 0 },\n      { transform: \"none\", opacity: 1 },\n    ],\n    { duration, easing },\n  );\n  const done = () => {\n    running.delete(input);\n    box.remove();\n    input.style.color = color;\n  };\n  running.set(input, done);\n  a.finished.then(done, done);\n}\n"},{"path":"beamline/components/button/button-variants.ts","type":"registry:file","target":"src/ui/beamline/components/button/button-variants.ts","content":"import { cn } from \"../../lib/utils\";\nimport styles from \"./button.module.css\";\n\nexport type ButtonVariant = \"primary\" | \"secondary\" | \"outline\" | \"ghost\" | \"danger\" | \"accent\";\n/** sm 32 · md 36 · lg 40 · touch 44 (a bottom action bar on a phone). */\nexport type ButtonSize = \"sm\" | \"md\" | \"lg\" | \"touch\";\n/** Market side: buy fills with --pui-up, sell with --pui-down (a red-up market flips the two tokens, not the code). */\nexport type ButtonTone = \"up\" | \"down\";\n\n/** Which paint role paints each variant: filled variants are solids, the quiet ones keep their own light paint. */\nconst ROLE: Record<ButtonVariant, string | undefined> = {\n  primary: \"m-solid\",\n  accent: \"m-solid\",\n  secondary: \"m-control\",\n  outline: undefined,\n  ghost: undefined,\n  danger: undefined,\n};\n\n/** A variant's paint without the button's layout, for a group that wears one button's look (SplitButton paints the\n *  pair as one button and leaves its halves transparent). */\nexport function buttonPaint(variant: ButtonVariant = \"primary\", tone?: ButtonTone) {\n  return cn(ROLE[variant], styles[variant], tone && styles[tone]);\n}\n\n/** The classes that make any element look like a Button, for parts that render their own element. */\nexport function buttonClassName({\n  variant = \"primary\",\n  size = \"md\",\n  tone,\n  className,\n}: { variant?: ButtonVariant; size?: ButtonSize; tone?: ButtonTone; className?: string } = {}) {\n  return cn(styles.root, ROLE[variant], styles[variant], tone && styles[tone], styles[size], className);\n}\n"},{"path":"beamline/components/button/button.module.css","type":"registry:file","target":"src/ui/beamline/components/button/button.module.css","content":"@layer properties, theme, base, components, utilities;\n@layer components {\n  /* Button. Every colour, size and duration is a token; a variant only sets the four local properties below. */\n  .root {\n    --_button-bg: transparent;\n    --_button-bg-hover: var(--pui-hover);\n    --_button-fg: var(--pui-ink);\n    --_button-edge: none;\n    --_button-height: var(--pui-control-height-md);\n    --_button-pad: 14px;\n    position: relative;\n    isolation: isolate;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: var(--pui-space-1-5);\n    flex-shrink: 0;\n    height: var(--_button-height);\n    min-width: var(--_button-height);\n    /* never wider than its room: in a narrow card the label ends in an ellipsis instead of spilling (the full words\n       stay the accessible name) */\n    max-width: 100%;\n    padding-inline: var(--_button-pad);\n    border: 0;\n    /* Nested context: inside a frame that sets --pui-nest-radius and --pui-nest-inset (and --pui-nest-ceiling for pills)\n       the corner is the shared nested corner (.nest-corner, utilities.css: radius − inset, or the button's own radius\n       where that would fall under the chip radius); elsewhere the control radius. --pui-button-radius wins over both. */\n    border-radius: var(--pui-button-radius, var(--pui-nested, var(--pui-radius-control)));\n    color: var(--_button-fg);\n    font-family: var(--pui-font-body);\n    font-size: var(--pui-text-sm);\n    font-weight: var(--pui-weight-medium);\n    line-height: 1;\n    letter-spacing: var(--pui-tracking-body);\n    white-space: nowrap;\n    text-decoration: none;\n    cursor: pointer;\n    user-select: none;\n    -webkit-tap-highlight-color: transparent;\n    /* frequency law: hover arrives at 0ms (below), leaves over the ruled departure; opacity and translate are listed\n       so a button that waits for attention (.reveal) fades away like every reveal instead of vanishing */\n    transition:\n      var(--m-transition),\n      background-color var(--pui-motion-out) var(--pui-ease-default),\n      color var(--pui-motion-out) var(--pui-ease-default),\n      opacity var(--pui-motion-out) var(--pui-ease-default),\n      translate var(--pui-motion-out) var(--pui-ease-default);\n  }\n  /* the quiet variants paint themselves; filled and secondary variants are painted by their look role (m-solid,\n   m-control), which these zero-specificity rules can never override */\n  :where(.root) {\n    background: var(--_button-bg);\n    box-shadow: var(--_button-edge);\n  }\n  :where(.root:hover:not(:disabled, [aria-disabled=\"true\"])) {\n    background: var(--_button-bg-hover);\n  }\n  .root:hover:not(:disabled, [aria-disabled=\"true\"]) {\n    transition-duration: 0ms;\n  }\n  /* the asChild form has no motion: a CSS press instead */\n  .root:not(button):active {\n    transform: scale(0.97);\n  }\n  .root:disabled,\n  .root[aria-disabled=\"true\"]:not([data-loading]) {\n    opacity: var(--pui-opacity-disabled);\n    cursor: not-allowed;\n  }\n  .root[data-loading] {\n    cursor: progress;\n  }\n\n  /* Icons: 16px unless the icon says otherwise (zero specificity, so size-5 or an inline size wins) */\n  :where(.root) :where(svg) {\n    width: var(--pui-icon-md);\n    height: var(--pui-icon-md);\n    flex-shrink: 0;\n  }\n\n  .sm {\n    --_button-height: var(--pui-control-height-sm);\n    --_button-pad: var(--pui-space-2-5);\n    /* the base gap (--pui-space-1-5); 5px had no scale step, and 6px also lets the loader's negative margin cancel\n       the gap exactly at every size */\n  }\n  .md {\n    --_button-height: var(--pui-control-height-md);\n    --_button-pad: 14px;\n  }\n  .lg {\n    --_button-height: var(--pui-control-height-lg);\n    --_button-pad: var(--pui-space-4);\n    font-size: var(--pui-text-base);\n  }\n  /* a bottom action bar on a phone: the 44 px touch target (a platform minimum, not a spacing step, so it holds when\n     the spacing parameter changes — O1 §14.2), the large label */\n  .touch {\n    --_button-height: calc(var(--pui-control-height-lg) + 0.25rem);\n    --_button-pad: var(--pui-space-5);\n    font-size: var(--pui-text-base);\n  }\n  .root[data-icon-only] {\n    padding-inline: 0;\n    width: var(--_button-height);\n  }\n\n  /* the main action: ink on the page, inverted per theme */\n  .primary {\n    --m-color: var(--pui-ink);\n    --_button-fg: var(--pui-ink-inverse);\n  }\n  .secondary {\n    --_button-fg: var(--pui-ink);\n  }\n  .outline {\n    --_button-edge: inset 0 0 0 1px var(--pui-line-strong);\n    --_button-bg-hover: var(--pui-hover);\n  }\n  .ghost {\n    --_button-fg: var(--pui-ink-2);\n    --_button-bg-hover: var(--pui-hover);\n  }\n  .ghost:hover:not(:disabled) {\n    color: var(--pui-ink);\n  }\n  .danger {\n    --_button-fg: var(--pui-red);\n    --_button-edge: inset 0 0 0 1px color-mix(in oklab, var(--pui-red) 42%, transparent);\n    --_button-bg-hover: var(--pui-red-tint);\n  }\n  .accent {\n    --m-color: var(--pui-accent);\n    --_button-fg: var(--pui-accent-foreground);\n  }\n\n  /* Market side. Declared after the variants so it wins: a filled variant takes the side's colour and its on-colour\n     ink; a quiet variant keeps its paint and colours the label. */\n  .up {\n    --m-color: var(--pui-up);\n    --_button-fg: var(--pui-up);\n  }\n  .down {\n    --m-color: var(--pui-down);\n    --_button-fg: var(--pui-down);\n  }\n  .ghost:is(.up, .down):hover:not(:disabled) {\n    color: var(--_button-fg);\n  }\n  .primary.up,\n  .accent.up {\n    --_button-fg: var(--pui-on-up);\n  }\n  .primary.down,\n  .accent.down {\n    --_button-fg: var(--pui-on-down);\n  }\n\n  /* The main actions' light, where the look provides one, as a spectrum. Glow spills a soft light in the brand's\n     spectrum from under the button's bottom edge (clipped at it, so it never tints the face) that brightens under the\n     pointer. Prism keeps it inside the glass (--m-solid-glow-fit: 1): the face the light leaves by, the bottom edge,\n     splits it into a crisp line with a faint wash rising into the face, only while pointed at. Every other look\n     leaves --m-solid-glow at none, so the layer does not exist. */\n  .primary::after,\n  .accent::after {\n    --_fit: var(--m-solid-glow-fit, 0);\n    content: var(--m-solid-glow);\n    position: absolute;\n    z-index: -1;\n    top: calc((1 - var(--_fit)) * (100% + var(--m-solid-glow-gap, 0px)));\n    inset-inline: var(--m-solid-glow-inset, 14%);\n    height: var(--m-solid-glow-height, 14px);\n    border-radius: calc(\n      var(--_fit) * var(--pui-button-radius, var(--pui-nested, var(--pui-radius-control))) + (1 - var(--_fit)) *\n        var(--pui-radius-pill)\n    );\n    background: var(--m-spectrum);\n    background-size: var(--m-spectrum-size, 100% 100%);\n    /* the part of the spectrum that shows: this button's own angle (--m-prism-seed, new at every press), turned by\n       where the pointer is across the face (--m-prism-x) in a look that turns it (--m-solid-glow-turn) */\n    background-position: calc((var(--m-prism-seed, 0.3) + var(--m-prism-x, 0.5) * var(--m-solid-glow-turn, 0)) * 100%) 0;\n    filter: blur(var(--m-solid-glow-blur, 9px));\n    clip-path: var(--m-solid-glow-clip, inset(0 -32px -32px -32px));\n    mask: var(--m-solid-glow-mask, none);\n    mask-position:\n      0 0,\n      calc(var(--m-prism-seed, 0.3) * 100%) 0;\n    mask-composite: intersect;\n    opacity: var(--m-solid-glow-rest, 0.75);\n    scale: var(--m-solid-glow-scale, 1) 1;\n    pointer-events: none;\n    transition:\n      opacity var(--pui-motion-out) var(--pui-ease-default),\n      scale var(--pui-motion-out) var(--pui-ease-default),\n      background-position var(--pui-duration-considered) var(--pui-ease-default),\n      mask-position var(--pui-duration-considered) var(--pui-ease-default);\n  }\n  /* pointed at: the light brightens (glow) or grows out from the centre and drifts along while the pointer stays\n     (prism) */\n  .primary:hover::after,\n  .accent:hover::after {\n    opacity: 1;\n    scale: 1 1;\n    transition-duration: var(--m-solid-glow-in, 0ms);\n    animation: var(--m-solid-glow-flow, none);\n  }\n  /* A change of word or colour (Save → Saved, a tone turning green) passes a band of split light across the face once,\n     in a look that has one (prism: --m-solid-shift-light; the pen hook's ::before is free on a solid otherwise). */\n  .primary[data-shift]::before,\n  .accent[data-shift]::before {\n    content: var(--m-solid-shift-light, none);\n    position: absolute;\n    inset: 0;\n    z-index: -1;\n    border: 0;\n    border-radius: inherit;\n    background: var(--m-spectrum) 0 0 / var(--m-spectrum-size, 100% 100%);\n    mask: linear-gradient(105deg, transparent 39%, #000 47.5%, #000 52.5%, transparent 61%) 0 0 / 300% 100% no-repeat;\n    opacity: 0;\n    animation: prism-shift calc(var(--pui-duration-considered) * 2.2) var(--pui-ease-default);\n    pointer-events: none;\n  }\n  @keyframes prism-shift {\n    from {\n      mask-position: 100% 0;\n      opacity: 0.25;\n    }\n    35% {\n      opacity: 0.55;\n    }\n    to {\n      mask-position: 0 0;\n      opacity: 0;\n    }\n  }\n  @media (prefers-reduced-motion: reduce) {\n    .primary::after,\n    .accent::after {\n      transition: none;\n      animation: none !important;\n    }\n    .primary[data-shift]::before,\n    .accent[data-shift]::before {\n      content: none;\n    }\n  }\n  .root:disabled::after,\n  .root[aria-disabled=\"true\"]::after {\n    content: none;\n  }\n\n  /* The loader opens its own width, and the negative margin cancels the gap so the label does not jump */\n  .loader {\n    display: inline-flex;\n    overflow: hidden;\n    margin-inline-end: calc(var(--pui-space-1-5) * -1);\n  }\n  .loader > * {\n    margin-inline-end: var(--pui-space-1-5);\n  }\n  .spinner {\n    color: currentColor;\n  }\n  .root[data-icon-only] .loader {\n    margin-inline-end: 0;\n  }\n  .root[data-icon-only] .loader > * {\n    margin-inline-end: 0;\n  }\n\n  /* The label holds its place while the text inside swaps; the leaving text pops out of flow against it */\n  .label {\n    position: relative;\n    display: inline-flex;\n    justify-content: center;\n    min-width: 0;\n    overflow: visible;\n  }\n  /* the clip box is let out by a little over a line so descenders are never cut, without changing the layout */\n  .text {\n    display: inline-block;\n    max-width: 100%;\n    margin-block: -0.2em;\n    padding-block: 0.2em;\n    overflow: hidden;\n    text-overflow: ellipsis;\n    white-space: nowrap;\n  }\n  .label[data-morphing] > .text {\n    overflow: visible;\n    text-overflow: clip;\n  }\n}\n\n@layer components {\n  :global(.pui[data-motion=\"reduced\"]) .root:not(button):active,\n  :global(.pui[data-motion=\"none\"]) .root:not(button):active {\n    transform: none;\n  }\n  @media (prefers-reduced-motion: reduce) {\n    .root:not(button):active {\n      transform: none;\n    }\n  }\n}\n/* CSS-module composition only; visual rules stay in the component layer. */\n.root {\n  composes: nest-corner from global;\n}\n"},{"path":"beamline/components/button/button.tsx","type":"registry:file","target":"src/ui/beamline/components/button/button.tsx","content":"\"use client\";\n\nimport { useMessages } from \"../../runtime/localization\";\nimport { english as englishMessages } from \"./messages\";\nimport {\n  Children,\n  Fragment,\n  isValidElement,\n  useLayoutEffect,\n  useRef,\n  type ButtonHTMLAttributes,\n  type PointerEvent,\n  type ReactNode,\n  type Ref,\n  type RefObject,\n  type ComponentProps,\n} from \"react\";\nimport { AnimatePresence, LazyMotion, m, spring, useIsPresent } from \"motion/react\";\nimport { animate } from \"motion/mini\";\nimport * as Slot from \"@radix-ui/react-slot\";\nimport { Spinner } from \"../spinner/spinner\";\nimport type { BuiltInLook as Look } from \"../../runtime/preset\";\nimport { useComposedRef } from \"../../hooks/use-composed-ref\";\nimport { useMotionTokens } from \"../../hooks/use-motion-tokens\";\nimport { cn } from \"../../lib/utils\";\nimport styles from \"./button.module.css\";\n\nexport type { ButtonVariant, ButtonSize, ButtonTone } from \"./button-variants\";\nexport { buttonPaint, buttonClassName } from \"./button-variants\";\nimport { buttonClassName, type ButtonVariant, type ButtonSize, type ButtonTone } from \"./button-variants\";\nimport type { ButtonDefaults } from \"./defaults\";\nexport type { ButtonDefaults } from \"./defaults\";\nimport { useComponentDefaults } from \"../../runtime/appearance\";\nimport { useReducedMotionSafe } from \"../../hooks/use-reduced-motion-safe\";\n\ntype NativeProps = Omit<\n  ButtonHTMLAttributes<HTMLButtonElement>,\n  \"onDrag\" | \"onDragEnd\" | \"onDragStart\" | \"onAnimationStart\"\n>;\n\nexport interface ButtonProps extends NativeProps {\n  /** Visual weight: primary (ink-filled), secondary, outline, ghost, danger, or accent (filled with the brand). */\n  variant?: ButtonVariant;\n  /** Height 32 / 36 / 40 px; touch 44 px for a bottom action bar on a phone. */\n  size?: ButtonSize;\n  /** Market side. On primary/accent the fill becomes --pui-up (buy) or --pui-down (sell); on the quiet variants the\n   *  label takes that colour. Pair it with a word or arrow: colour is never the only signal. */\n  tone?: ButtonTone;\n  /** Shows a loader in front of the label, sets aria-busy and ignores clicks; size and focus stay. */\n  loading?: boolean;\n  classNames?: Partial<Record<\"root\" | \"label\" | \"loader\", string>>;\n  /** Paint this button in another look than the one in force around it (DESIGN-LANGUAGE.md \"Looks\"). */\n  look?: Look;\n  /** Render the single child (a link, a Radix trigger) with the button's look instead of a <button>. */\n  asChild?: boolean;\n  /** A square button holding only an icon (give it an aria-label). Decided by the children when left out: icon-only when\n   *  no words sit anywhere among them (an icon, or a frame of icons), so `<span>Close</span>` is a label. */\n  iconOnly?: boolean;\n  ref?: Ref<HTMLButtonElement>;\n}\n\n// Motion's animation features arrive in a deferred chunk (AT11): the button renders and works at once, and its press,\n// loader and label motion run once they land, a frame or two after mount. Buttons that mount after that get the\n// loaded features directly, so they render once instead of again when a lazy load resolves.\ntype Features = typeof import(\"./motion-features\").default;\nlet loaded: Features | null = null;\nconst features = () =>\n  import(\"./motion-features\").then((module) => {\n    loaded = module.default;\n    return loaded;\n  });\n\n/** Children with fragments opened up, so `{busy ? <><Icon />Saving</> : …}` reads as icon plus text. */\nconst flat = (children: ReactNode): ReactNode[] =>\n  Children.toArray(children).flatMap((c) =>\n    isValidElement<{ children?: ReactNode }>(c) && c.type === Fragment ? flat(c.props.children) : [c],\n  );\n\n/** Whether any words sit anywhere inside (an icon, or a frame of icons, has none). */\nfunction hasText(node: ReactNode): boolean {\n  if (typeof node === \"string\") return node.trim() !== \"\";\n  if (typeof node === \"number\") return true;\n  if (Array.isArray(node)) return node.some(hasText);\n  return isValidElement<{ children?: ReactNode }>(node) && hasText(node.props.children);\n}\n\n/** Splits children into the text run (the label that can change) and everything else (icons), in order, and says\n *  whether any element carries content of its own (a `<span>Close</span>` label, unlike an icon). */\nfunction split(children: ReactNode) {\n  const parts = flat(children);\n  const text = parts\n    .filter((p) => typeof p === \"string\" || typeof p === \"number\")\n    .join(\"\")\n    .trim();\n  const firstText = parts.findIndex((p) => typeof p === \"string\" || typeof p === \"number\");\n  const before = firstText === -1 ? parts : parts.slice(0, firstText).filter(isValidElement);\n  const after = firstText === -1 ? [] : parts.slice(firstText).filter(isValidElement);\n  const content = parts.some((p) => isValidElement<{ children?: ReactNode }>(p) && hasText(p.props.children));\n  return { text, before, after, content };\n}\n\n/**\n * The action control. Hover answers at once and lets go over --pui-motion-out; a press scales down at once, or swells\n * on the snappy spring where the look's --pui-press-scale is above 1 (glass), never on a trigger that anchors a\n * floating layer, which would measure a resized box; a changed label slides in while the\n * width follows on a critically damped spring; loading keeps the size and the focus.\n */\nexport function Button({\n  variant: variantProp,\n  size: sizeProp,\n  tone: toneProp,\n  loading = false,\n  look,\n  asChild = false,\n  iconOnly: iconOnlyProp,\n  className,\n  classNames,\n  children,\n  type,\n  onClick,\n  onPointerMove,\n  onPointerDown,\n  disabled,\n  ref,\n  ...props\n}: ButtonProps) {\n  const i18n = useMessages(\"button\", englishMessages);\n\n  const defaults = useComponentDefaults<ButtonDefaults>(\"button\", [\"variant\", \"size\", \"tone\"]);\n  const variant = variantProp ?? defaults.variant ?? \"primary\";\n  const size = sizeProp ?? defaults.size ?? \"md\";\n  const tone = toneProp ?? defaults.tone;\n  const host = useRef<HTMLButtonElement>(null);\n  const attach = useComposedRef(host, ref);\n  const motionTokens = useMotionTokens(host);\n  const requestedReduced = useReducedMotionSafe();\n  const reduced = requestedReduced || motionTokens.reduced;\n  // Reduced motion keeps a restrained fade; none removes it (APPEARANCE A06).\n  const fade = motionTokens.mode === \"none\" ? 0 : motionTokens.fade.in;\n  // a caller's aria-disabled keeps the button focusable (focus never drops after Save resolves) but inert to presses\n  const softDisabled = props[\"aria-disabled\"] === true || props[\"aria-disabled\"] === \"true\";\n  const { text, before, after, content } = split(children);\n  const prism = usePrismLight(host, variant === \"primary\" || variant === \"accent\", `${text}|${tone}|${variant}`);\n  // with asChild the text sits inside the child (the link), not among our own children\n  const inner = asChild && isValidElement<{ children?: ReactNode }>(children) ? split(children.props.children) : null;\n  const iconOnly = iconOnlyProp ?? (inner ? !inner.text && !inner.content : !text && !content);\n  const anchor =\n    (props[\"aria-haspopup\"] != null && props[\"aria-haspopup\"] !== false && props[\"aria-haspopup\"] !== \"false\") ||\n    \"data-state\" in props;\n  const shared = {\n    \"data-slot\": \"button\",\n    \"data-variant\": variant,\n    \"data-size\": size,\n    \"data-tone\": tone,\n    \"data-icon-only\": iconOnly ? \"\" : undefined,\n    \"data-loading\": loading ? \"\" : undefined,\n    \"data-look\": look,\n    className: buttonClassName({ variant, size, tone, className: cn(classNames?.root, className) }),\n  };\n\n  if (asChild)\n    return (\n      <Slot.Root {...shared} {...props} ref={attach}>\n        {children}\n      </Slot.Root>\n    );\n\n  const button = (\n    <m.button\n      ref={attach}\n      type={type ?? \"button\"}\n      {...shared}\n      {...props}\n      disabled={disabled}\n      aria-busy={loading || undefined}\n      aria-disabled={loading || softDisabled || undefined}\n      onPointerMove={(e) => {\n        prism.turn(e);\n        onPointerMove?.(e);\n      }}\n      onPointerDown={(e) => {\n        prism.press();\n        onPointerDown?.(e);\n      }}\n      onClick={(e) => {\n        if (loading || softDisabled) {\n          e.preventDefault();\n          return;\n        }\n        onClick?.(e);\n      }}\n      whileTap={\n        reduced || anchor || disabled || loading || softDisabled\n          ? undefined\n          : {\n              scale: motionTokens.pressScale,\n              // a press that sinks lands at once; one that swells toward the finger (glass) grows on the spring\n              transition: motionTokens.pressScale > 1 ? motionTokens.spring.snappy : { duration: 0 },\n            }\n      }\n      transition={{ scale: motionTokens.spring.snappy }}\n    >\n      <AnimatePresence initial={false}>\n        {loading && (\n          <m.span\n            key=\"loader\"\n            data-slot=\"button-loader\"\n            className={cn(styles.loader, classNames?.loader)}\n            initial={reduced ? { opacity: 0 } : { width: 0, opacity: 0 }}\n            animate={{ width: \"auto\", opacity: 1 }}\n            exit={reduced ? { opacity: 0 } : { width: 0, opacity: 0 }}\n            transition={{ duration: reduced ? fade : motionTokens.duration.standard, ease: motionTokens.ease.default }}\n          >\n            <Spinner size=\"sm\" label={i18n(\"working\")} className={styles.spinner} />\n          </m.span>\n        )}\n      </AnimatePresence>\n      {iconOnly ? !loading && before : before}\n      {!iconOnly && text && (\n        <Label text={text} reduced={!!reduced} fade={fade} motionTokens={motionTokens} className={classNames?.label} />\n      )}\n      {after}\n    </m.button>\n  );\n  return <LazyMotion features={loaded ?? features}>{button}</LazyMotion>;\n}\n\n/**\n * The main action's light inside the glass, in a look that draws one (prism): its own angle from the start, turned by\n * where the pointer is across the face, a new angle at every press, and a sweep of split light (data-shift) when the\n * button's word, tone or variant changes after it first appears. Writes two style properties and one attribute on the\n * button; nothing runs at rest. Looks without this light ignore all three.\n */\nfunction usePrismLight(host: RefObject<HTMLButtonElement | null>, solid: boolean, state: string) {\n  const frame = useRef(0);\n  const shown = useRef(state);\n  const ending = useRef(0);\n  useLayoutEffect(() => {\n    const el = host.current;\n    if (el && solid) el.style.setProperty(\"--m-prism-seed\", Math.random().toFixed(3));\n  }, [host, solid]);\n  useLayoutEffect(() => {\n    const el = host.current;\n    if (!el || !solid || shown.current === state) return;\n    shown.current = state;\n    // restart the sweep if it is still running\n    delete el.dataset.shift;\n    void el.offsetWidth;\n    el.dataset.shift = \"\";\n    clearTimeout(ending.current);\n    ending.current = window.setTimeout(() => delete el.dataset.shift, 1200);\n  }, [host, solid, state]);\n  useLayoutEffect(\n    () => () => {\n      clearTimeout(ending.current);\n      cancelAnimationFrame(frame.current);\n    },\n    [],\n  );\n  return {\n    turn: (e: PointerEvent<HTMLButtonElement>) => {\n      if (!solid || e.pointerType !== \"mouse\" || frame.current) return;\n      const el = e.currentTarget;\n      const x = e.clientX;\n      frame.current = requestAnimationFrame(() => {\n        frame.current = 0;\n        const r = el.getBoundingClientRect();\n        if (r.width) el.style.setProperty(\"--m-prism-x\", ((x - r.left) / r.width).toFixed(3));\n      });\n    },\n    press: () => {\n      if (solid) host.current?.style.setProperty(\"--m-prism-seed\", Math.random().toFixed(3));\n    },\n  };\n}\n\n/** The text run. When it changes, the old words leave upward and the new ones rise in, while the width moves from the\n *  old measure to the new one; no measuring happens while the label is unchanged. */\nfunction Label({\n  text,\n  reduced,\n  fade,\n  motionTokens,\n  className,\n}: {\n  text: string;\n  reduced: boolean;\n  /** Seconds of the label crossfade under reduced motion (0 under none). */\n  fade: number;\n  /** The button's own, resolved at the button: the label sits inside it, in the same look and motion. */\n  motionTokens: ReturnType<typeof useMotionTokens>;\n  className?: string;\n}) {\n  const slot = useRef<HTMLSpanElement>(null);\n  const latest = useRef(motionTokens);\n  useLayoutEffect(() => {\n    latest.current = motionTokens;\n  }, [motionTokens]);\n  const last = useRef<{ text: string; width: number } | null>(null);\n  useLayoutEffect(() => {\n    const el = slot.current;\n    if (!el) return;\n    const prev = last.current;\n    // first mount: read the width after paint, when layout is already clean, instead of forcing a layout per button\n    if (!prev) {\n      last.current = { text, width: Number.NaN };\n      const id = requestAnimationFrame(() => {\n        if (last.current?.text === text) last.current = { text, width: el.getBoundingClientRect().width };\n      });\n      return () => cancelAnimationFrame(id);\n    }\n    el.style.width = \"\";\n    const width = el.getBoundingClientRect().width;\n    last.current = { text, width };\n    // a label that is not rendered (a hidden toolbar on a phone) has nothing to animate\n    if (prev.text === text || reduced || Number.isNaN(prev.width) || !el.getClientRects().length) return;\n    // The same spring, played natively: motion/mini samples the generator into a linear() easing.\n    const { visualDuration, bounce } = latest.current.spring.morph;\n    // while the width eases the words are clipped, not cut short with an ellipsis (that is for a room too narrow)\n    el.dataset.morphing = \"\";\n    const run = animate(el, { width: [`${prev.width}px`, `${width}px`] }, { type: spring, visualDuration, bounce });\n    run.then(() => {\n      el.style.width = \"\";\n      delete el.dataset.morphing;\n    });\n    // cancel, not stop: stop commits the running value, which throws once the element stops being rendered, and the\n    // next change measures afresh anyway\n    return () => {\n      run.cancel();\n      el.style.width = \"\";\n      delete el.dataset.morphing;\n    };\n  }, [text, reduced]);\n  // A label that changes faster than its words can rise in (a count read live while a hand drags) shows each new\n  // value at once: otherwise every value would start invisible and the button would read blank for the whole drag.\n  const rapid = useRapid(text, motionTokens.duration.standard * 1000);\n  const enter = reduced ? { opacity: 0 } : { opacity: 0, y: \"0.45em\", filter: `blur(${motionTokens.blur.subtle}px)` };\n  const leave = reduced\n    ? { opacity: 0 }\n    : {\n        opacity: 0,\n        y: \"-0.45em\",\n        filter: `blur(${motionTokens.blur.subtle}px)`,\n        transition: { duration: motionTokens.duration.fast },\n      };\n  return (\n    <span ref={slot} data-slot=\"button-label\" className={cn(styles.label, className)}>\n      <AnimatePresence mode=\"popLayout\" initial={false} custom={rapid}>\n        <Words\n          key={text}\n          className={styles.text}\n          custom={rapid}\n          variants={{\n            enter: (fast: boolean) => (fast ? { opacity: 1, y: \"0em\", filter: \"blur(0px)\" } : enter),\n            shown: { opacity: 1, y: \"0em\", filter: \"blur(0px)\" },\n            leave: (fast: boolean) => (fast ? { opacity: 0, transition: { duration: 0 } } : leave),\n          }}\n          initial=\"enter\"\n          animate=\"shown\"\n          exit=\"leave\"\n          transition={{ duration: reduced ? fade : motionTokens.duration.standard, ease: motionTokens.ease.default }}\n        >\n          {text}\n        </Words>\n      </AnimatePresence>\n    </span>\n  );\n}\n\n/** Whether `text` changed again within `ms` of its last change. Read in render: the answer belongs to this text. */\nfunction useRapid(text: string, ms: number) {\n  const seen = useRef({ text, at: Number.NEGATIVE_INFINITY, rapid: false });\n  if (seen.current.text !== text) {\n    const at = performance.now();\n    seen.current = { text, at, rapid: at - seen.current.at < ms };\n  }\n  return seen.current.rapid;\n}\n\n/** One label's words. Leaving, they are already gone for assistive tech: the button's name is the new label at once,\n *  not both while the old words animate away (or for good, where time stands still in a test). */\nfunction Words(props: ComponentProps<typeof m.span>) {\n  const present = useIsPresent();\n  return <m.span {...props} aria-hidden={present ? undefined : true} />;\n}\n\nexport default Button;\n"},{"path":"beamline/components/button/defaults.ts","type":"registry:file","target":"src/ui/beamline/components/button/defaults.ts","content":"import type { ButtonSize, ButtonTone, ButtonVariant } from \"./button-variants\";\n/** Scoped design choices only; no loading, events or domain state. */\nexport interface ButtonDefaults {\n  variant?: ButtonVariant;\n  size?: ButtonSize;\n  tone?: ButtonTone;\n}\n"},{"path":"beamline/components/button/messages.ts","type":"registry:file","target":"src/ui/beamline/components/button/messages.ts","content":"import type { MessageDefinitions } from \"../../runtime/messages\";\n/** Built-in English copy; stable keys are the public translation API. */\nexport const english = {\n  working: \"Working\",\n} satisfies MessageDefinitions;\n"},{"path":"beamline/components/button/motion-features.ts","type":"registry:file","target":"src/ui/beamline/components/button/motion-features.ts","content":"// REASON: Motion's DOM animation features (tween, spring, presence, press) are loaded after the first paint, so a\n// Button costs a small part of Motion on first load; LazyMotion in button.tsx renders until they arrive.\nimport { domAnimation } from \"motion/react\";\n\nexport default domAnimation;\n"},{"path":"beamline/components/calendar/calendar.module.css","type":"registry:file","target":"src/ui/beamline/components/calendar/calendar.module.css","content":"@layer properties, theme, base, components, utilities;\n@layer components {\n  /* Arrows sit above the month grid; the space between them leaves the title reachable. */\n  .navigation {\n    z-index: 1;\n    pointer-events: none;\n  }\n  .navigation > button {\n    pointer-events: auto;\n  }\n  /* The day's square: 36px, or a seventh of a narrower room (a side panel, a small card) down to 28px, so a month\n     never spills its room (cqi reads the nearest size container; with none it is the viewport and the days keep 36px). */\n  .months {\n    --_cell: clamp(28px, calc((100cqi - var(--pui-space-4)) / 7), 36px);\n  }\n  .square {\n    width: var(--_cell);\n    height: var(--_cell);\n  }\n  /* A day: a square with the date in tabular figures. Disabled days are struck through; the chosen day is a solid. */\n  .day {\n    position: relative;\n    display: grid;\n    width: var(--_cell);\n    height: var(--_cell);\n    place-items: center;\n    border-radius: var(--pui-radius-control);\n    font-family: var(--pui-font-numeric);\n    font-size: var(--pui-text-sm);\n    font-variant-numeric: tabular-nums;\n    outline-offset: -2px;\n    /* hover arrives at 0 ms and leaves over --pui-motion-out; a press is acknowledged at 0 ms */\n    transition:\n      background-color var(--pui-motion-out) var(--pui-ease-default),\n      color var(--pui-motion-out) var(--pui-ease-default),\n      scale var(--pui-motion-out) var(--pui-ease-default);\n  }\n  .day:hover,\n  .day:active {\n    transition: none;\n  }\n  .day:active {\n    scale: var(--pui-press-scale);\n  }\n  .free {\n    color: var(--pui-ink-2);\n  }\n  .free:hover {\n    background: var(--pui-hover);\n    color: var(--pui-ink);\n  }\n  /* inside a chosen range */\n  .between {\n    color: var(--pui-ink);\n  }\n  .between:hover {\n    background: var(--pui-hover-2);\n  }\n  .on {\n    position: relative;\n    z-index: 1;\n    color: var(--pui-accent-foreground);\n  }\n  /* while the solid is still on its way the new day keeps the page's ink, so its number never disappears */\n  [data-slot=\"calendar-months\"]:has(> [data-morphing]) .on:not(.m-solid) {\n    color: var(--pui-ink);\n  }\n  /* the chosen day's solid, apart from the day so it can travel to the next one picked (calendar.tsx, contour) */\n  .chosen {\n    position: absolute;\n    top: 0;\n    left: 0;\n    border-radius: var(--pui-radius-control);\n    pointer-events: none;\n  }\n  .day:disabled {\n    color: var(--pui-ink-3);\n    text-decoration-line: line-through;\n    opacity: var(--pui-opacity-disabled);\n    pointer-events: none;\n  }\n\n  /* the month title: it opens the years (and from the months, the years again) */\n  .title {\n    display: inline-flex;\n    align-items: center;\n    gap: var(--pui-space-1);\n    height: var(--pui-control-height-sm);\n    padding-inline: var(--pui-space-2-5) var(--pui-space-2);\n    border-radius: var(--pui-radius-control);\n    color: var(--pui-ink);\n    font-weight: var(--pui-weight-medium);\n    outline-offset: -2px;\n    transition: background-color var(--pui-motion-out) var(--pui-ease-default);\n  }\n  .title:hover {\n    background: var(--pui-hover);\n    transition: none;\n  }\n  .title svg {\n    width: var(--pui-icon-sm);\n    height: var(--pui-icon-sm);\n    color: var(--pui-ink-3);\n    transition: rotate var(--pui-duration-feedback) var(--pui-ease-out-strong);\n  }\n  .title[aria-expanded=\"true\"] svg {\n    rotate: 180deg;\n  }\n  /* years or months in the space the days took, at the same width */\n  .picker {\n    display: grid;\n    align-content: start;\n    gap: var(--pui-space-1);\n    height: calc(var(--_cell) * 7);\n    padding: var(--pui-space-0-5);\n    overflow-y: auto;\n    overscroll-behavior: contain;\n    scrollbar-width: thin;\n  }\n  .years {\n    grid-template-columns: repeat(4, minmax(0, 1fr));\n    grid-auto-rows: 40px;\n  }\n  .monthGrid {\n    grid-template-columns: repeat(3, minmax(0, 1fr));\n    grid-auto-rows: 58px;\n  }\n  .pick {\n    position: relative;\n    display: grid;\n    place-items: center;\n    border-radius: var(--pui-radius-control);\n    color: var(--pui-ink-2);\n    font-family: var(--pui-font-numeric);\n    font-size: var(--pui-text-sm);\n    font-variant-numeric: tabular-nums;\n    outline-offset: -2px;\n  }\n  .pick {\n    transition:\n      background-color var(--pui-motion-out) var(--pui-ease-default),\n      color var(--pui-motion-out) var(--pui-ease-default);\n  }\n  .pick:not(.pickOn):hover {\n    background: var(--pui-hover);\n    color: var(--pui-ink);\n    transition: none;\n  }\n  .pickOn {\n    color: var(--pui-accent-foreground);\n  }\n  .pick:disabled {\n    color: var(--pui-ink-3);\n    opacity: var(--pui-opacity-disabled);\n    pointer-events: none;\n  }\n  .pickToday {\n    position: absolute;\n    bottom: 5px;\n    width: 4px;\n    height: 4px;\n    border-radius: 50%;\n    background: var(--pui-accent);\n  }\n  .pickOn .pickToday {\n    background: var(--pui-accent-foreground);\n  }\n  /* A page turn (the arrows, Page Up/Down, focus walking off the month): the new month arrives from the side it lies\n     on, 10px over --pui-duration-feedback, so the eye knows which way it went. Two identical keyframes take turns so\n     each turn restarts the arrival without remounting the grid (focus and the chosen day's solid stay). Reduced\n     motion: no travel (--pui-motion-travel 0) and the duration token is 1 ms. Live data is not involved: a pick never\n     moves anything but the solid. */\n  .months:dir(rtl) {\n    --_flip: -1;\n  }\n  .months[data-turn=\"a\"] > [data-slot=\"calendar-month\"] {\n    animation: turn-a var(--pui-duration-feedback) var(--pui-ease-out-strong) both;\n  }\n  .months[data-turn=\"b\"] > [data-slot=\"calendar-month\"] {\n    animation: turn-b var(--pui-duration-feedback) var(--pui-ease-out-strong) both;\n  }\n  @keyframes turn-a {\n    from {\n      opacity: 0.4;\n      translate: calc(10px * var(--_dir, 1) * var(--_flip, 1) * var(--pui-motion-travel, 1)) 0;\n    }\n  }\n  @keyframes turn-b {\n    from {\n      opacity: 0.4;\n      translate: calc(10px * var(--_dir, 1) * var(--_flip, 1) * var(--pui-motion-travel, 1)) 0;\n    }\n  }\n  /* a view swap: the new view fades up from 98% (reduced motion: the duration token is 1 ms) */\n  .viewIn {\n    animation: calendar-view-in var(--pui-duration-feedback) var(--pui-ease-out-strong) both;\n  }\n  @keyframes calendar-view-in {\n    from {\n      opacity: 0;\n      transform: scale(0.98);\n    }\n  }\n  /* how many records a day holds: dots in the day's own ink (a count, one hue), three and a plus past that */\n  .marks {\n    position: absolute;\n    bottom: 3px;\n    display: flex;\n    align-items: center;\n    gap: 2px;\n    color: inherit;\n    pointer-events: none;\n  }\n  .markDot {\n    width: 4px;\n    height: 4px;\n    border-radius: 50%;\n    background: currentColor;\n  }\n  .markMore {\n    font-size: 8px;\n    line-height: 1;\n  }\n  /* a day never recorded: faint and hatched, never read as a day with none */\n  .day[data-unrecorded] {\n    color: var(--pui-ink-3);\n    background-image: repeating-linear-gradient(\n      135deg,\n      color-mix(in oklab, var(--pui-ink) 8%, transparent) 0 1px,\n      transparent 1px 5px\n    );\n  }\n}\n/* CSS-module composition only; visual rules stay in the component layer. */\n.chosen {\n  composes: m-solid from global;\n}\n"},{"path":"beamline/components/calendar/calendar.tsx","type":"registry:file","target":"src/ui/beamline/components/calendar/calendar.tsx","content":"\"use client\";\nimport { dateFormatter, useMessages } from \"../../runtime/localization\";\nimport { english as englishMessages } from \"./messages\";\nimport { useLocale } from \"../../runtime/localization\";\n\nimport { useDeprecatedProp } from \"../../hooks/use-deprecated-prop\";\n\nimport type { CSSProperties, Ref } from \"react\";\n\nimport { useEffect, useLayoutEffect, useMemo, useRef, useState, type KeyboardEvent } from \"react\";\nimport { ChevronDown, ChevronLeft, ChevronRight } from \"lucide-react\";\nimport { Button } from \"../button/button\";\nimport { useComposedRef } from \"../../hooks/use-composed-ref\";\nimport { useIndicator } from \"../../hooks/use-indicator\";\nimport { useContour } from \"../../hooks/use-contour\";\nimport { cn } from \"../../lib/utils\";\nimport { useControllable } from \"../../hooks/use-controllable\";\nimport { useToday } from \"../../lib/now\";\nimport styles from \"./calendar.module.css\";\n\nexport interface DateRange {\n  /** First date included in the range. Required. */\n  start: Date;\n  /** Last date included in the range. Required. */\n  end: Date;\n}\n/** Days that cannot be picked: a list, or a test. */\nexport type CalendarDateMatcher = Date[] | ((date: Date) => boolean);\n\nconst DAY = 86400000;\nexport const startOfDay = (d: Date) => new Date(d.getFullYear(), d.getMonth(), d.getDate());\nexport const sameDay = (a?: Date | null, b?: Date | null) =>\n  !!a && !!b && a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();\nconst addDays = (d: Date, n: number) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + n);\nconst addMonths = (d: Date, n: number) => {\n  const t = new Date(d.getFullYear(), d.getMonth() + n, 1);\n  return new Date(\n    t.getFullYear(),\n    t.getMonth(),\n    Math.min(d.getDate(), new Date(t.getFullYear(), t.getMonth() + 1, 0).getDate()),\n  );\n};\nconst firstOfMonth = (d: Date) => new Date(d.getFullYear(), d.getMonth(), 1);\n\nexport type CalendarClassNames = Partial<\n  Record<\n    | \"month\"\n    | \"monthTitle\"\n    | \"grid\"\n    | \"weekday\"\n    | \"blank\"\n    | \"cell\"\n    | \"day\"\n    | \"today\"\n    | \"root\"\n    | \"navigation\"\n    | \"months\"\n    | \"announcement\"\n    | \"title\"\n    | \"picker\"\n    | \"pick\",\n    string\n  >\n>;\n\ninterface Common {\n  /** Classes for the named visual parts; no part overrides by default. */\n  classNames?: CalendarClassNames;\n  /** Which month shows first (controlled), and its change. */\n  month?: Date;\n  /** Initial month; defaults to the selected day or range start, then today within the allowed bounds. */\n  defaultMonth?: Date;\n  /** Reports month after a change; no callback by default. */\n  onMonthChange?: (month: Date) => void;\n  /** The first day that can be picked: a date, or \"today\" (read in the browser, so a server-rendered page stays valid). */\n  minDate?: Date | \"today\";\n  /** The last day that can be picked: a date, or \"today\" (a date of birth, a report period). */\n  maxDate?: Date | \"today\";\n  /** Dates that cannot be selected, or a predicate that identifies them. Defaults to no additional disabled dates. */\n  disabledDates?: CalendarDateMatcher;\n  /** Locale used for number, date or text formatting. Defaults to the runtime locale. */\n  locale?: string;\n  /** 0 Sunday, 1 Monday. Default 1. */\n  weekStartsOn?: 0 | 1;\n  /** Months side by side. Default 1. */\n  months?: 1 | 2;\n  /** Mark today with a dot. Default true. */\n  showToday?: boolean;\n  /** How many records a day holds, drawn as one to three dots (three and a plus past that) and said in the day's\n   *  name: a number (0 is a day recorded with none), or null for a day never recorded, drawn faint and hatched so\n   *  it doesn't read as an empty one. */\n  marks?: (date: Date) => number | null | undefined;\n  /** What `marks` counts, singular and plural, for the day's name (\"Tue 14 Oct, 2 workouts\"). */\n  markNoun?: [string, string];\n  /** Where it opens: the days, or the years for a date of birth or another far date. The month title switches\n   *  between them either way. Default \"days\". */\n  defaultView?: \"days\" | \"years\";\n  /** Controlled picker view; omitted by default to keep navigation local. */\n  view?: \"days\" | \"months\" | \"years\";\n  /** Reports navigation between day, month and year choices; no callback by default. */\n  onViewChange?: (view: \"days\" | \"months\" | \"years\") => void;\n  /** Inline styles on the documented visual root; no inline overrides by default. */\n  style?: CSSProperties;\n  /** Receives the documented root element; no ref by default. */\n  ref?: Ref<HTMLDivElement>;\n  /** Classes on the documented visual root; no override by default. */\n  className?: string;\n}\nexport interface CalendarSingleProps extends Common {\n  /** Selects single-day selection. Defaults to single. */\n  mode?: \"single\";\n  /** Controlled day or date range; null clears the selection; omit to use defaultValue. */\n  value?: Date | null;\n  /** Initial selected day when value is omitted; defaults to no selection. */\n  defaultValue?: Date | null;\n  /** Legacy value-change callback; omitted by default. Prefer onValueChange.\n   *  @deprecated Use onValueChange; this value callback remains supported and is omitted by default. */\n  onChange?: (date: Date) => void;\n  /** The picked day: the name every Beamline field uses. */\n  onValueChange?: (date: Date) => void;\n}\nexport interface CalendarRangeProps extends Common {\n  /** Selects date-range selection. Required; pass range. */\n  mode: \"range\";\n  /** Controlled day or date range; null clears the selection; omit to use defaultValue. */\n  value?: DateRange | null;\n  /** Initial selected range when value is omitted; defaults to no selection. */\n  defaultValue?: DateRange | null;\n  /** Legacy value-change callback; omitted by default. Prefer onValueChange.\n   *  @deprecated Use onValueChange; this value callback remains supported and is omitted by default. */\n  onChange?: (range: DateRange) => void;\n  /** The picked range: the name every Beamline field uses. */\n  onValueChange?: (range: DateRange) => void;\n  /** While a range is half chosen: the span from the first pick to the day under the pointer or keyboard focus, and\n   *  null once it is closed or cancelled (a summary can count the days as they are swept). */\n  onPendingChange?: (span: DateRange | null) => void;\n}\nexport type CalendarProps = CalendarSingleProps | CalendarRangeProps;\n\n/**\n * Month grids for picking a day or a range. The grid is a real table: arrows move by day and week, Page Up/Down by\n * month (Shift by year), Home/End to the week's ends, T back to today, Enter picks. In range mode the second pick closes the range and\n * the span follows the pointer until it does. The month title opens the years, a year its months, a month its days:\n * far dates (a date of birth) take three picks instead of hundreds of pages.\n */\nexport function Calendar(props: CalendarProps) {\n  useDeprecatedProp(\"Calendar\", \"onChange\", \"onValueChange\", props.onChange !== undefined);\n  // today is known only in the browser: rendered on a server (a Next.js prerender) the calendar holds its place, empty,\n  // and the browser fills it in before the first paint\n  const today = useToday();\n  if (!today)\n    return (\n      <div\n        ref={props.ref}\n        data-slot=\"calendar\"\n        aria-busy\n        style={{ minWidth: 252 * (props.months ?? 1), minHeight: 300, ...props.style }}\n        className={cn(\"relative inline-grid\", props.classNames?.root, props.className)}\n      />\n    );\n  return <CalendarMonths {...props} today={today} />;\n}\n\nfunction CalendarMonths({ today, ...props }: CalendarProps & { today: Date }) {\n  const i18n = useMessages(\"calendar\", englishMessages);\n\n  const minDate = props.minDate === \"today\" ? today : props.minDate;\n  const maxDate = props.maxDate === \"today\" ? today : props.maxDate;\n  const {\n    disabledDates,\n    locale: localeProp,\n    weekStartsOn = 1,\n    months = 1,\n    showToday = true,\n    marks,\n    markNoun,\n    className,\n    classNames,\n    style,\n    ref,\n  } = props;\n  const locale = useLocale(localeProp);\n\n  const range = props.mode === \"range\";\n  // one hook for both modes; each mode reports through its own typed callbacks\n  const [value, setValue] = useControllable<Date | DateRange | null>(props.value, props.defaultValue ?? null);\n  // A mode change can leave the uncontrolled value in the previous mode's shape.\n  const selected = !range && value instanceof Date ? value : null;\n  const rangeValue = range && value !== null && !(value instanceof Date) ? value : null;\n  const [shown, setShownMonth] = useControllable(\n    props.month ? firstOfMonth(props.month) : undefined,\n    () => {\n      // with nothing chosen it opens on today, kept inside the dates that can be picked (a date of birth ends years ago)\n      let start = props.month ?? props.defaultMonth ?? selected ?? rangeValue?.start ?? today;\n      if (!props.month && !props.defaultMonth && !selected && !rangeValue) {\n        if (maxDate && start > maxDate) start = maxDate;\n        if (minDate && start < minDate) start = minDate;\n      }\n      return firstOfMonth(start);\n    },\n    props.onMonthChange,\n  );\n  const setShown = (m: Date) => setShownMonth(firstOfMonth(m));\n  const [focus, setFocus] = useState<Date>(() => {\n    const preferred = startOfDay(selected ?? rangeValue?.start ?? today);\n    const end = addMonths(shown, months);\n    return preferred >= shown && preferred < end ? preferred : shown;\n  });\n  const [anchor, setAnchor] = useState<Date | null>(null);\n  const [hover, setHover] = useState<Date | null>(null);\n  // which view shows: the days, or the years and months the month title opens\n  type View = \"days\" | \"months\" | \"years\";\n  const [view, setViewValue] = useControllable<View>(props.view, props.defaultView ?? \"days\", props.onViewChange);\n  const grid = useRef<HTMLDivElement>(null);\n  const attach = useComposedRef(grid, ref);\n  // the chosen day (single mode) is one solid that travels to the next day picked, across weeks and months\n  const [monthsRef, chosen] = useIndicator<HTMLDivElement>(\n    \"[data-slot=calendar-day][data-chosen]\",\n    `${selected?.getTime()}:${shown.getTime()}:${view}`,\n    undefined,\n    \"rect\",\n  );\n  const chosenRef = useContour<HTMLSpanElement>(chosen);\n  const moved = useRef(false);\n  // a page turn on the days (not a return from the years or months, which has its own fade): which way, and a parity\n  // that restarts the arrival (calendar.module.css .months[data-turn])\n  const [turn, setTurn] = useState({ n: 0, dir: 1, at: shown.getTime(), view });\n  if (turn.at !== shown.getTime() || turn.view !== view)\n    setTurn({\n      n: view === \"days\" && turn.view === \"days\" && turn.at !== shown.getTime() ? turn.n + 1 : turn.n,\n      dir: shown.getTime() > turn.at ? 1 : -1,\n      at: shown.getTime(),\n      view,\n    });\n\n  // the years and months: the title opens them, a pick narrows down, Escape returns to the days\n  const [pickYear, setPickYear] = useState(() => shown.getFullYear());\n  const chosenDate = selected ?? rangeValue?.start ?? null;\n  const thisYear = today.getFullYear();\n  const yearFrom = minDate ? minDate.getFullYear() : thisYear - 120;\n  const yearTo = maxDate ? maxDate.getFullYear() : thisYear + 30;\n  const defaultPickFocus =\n    view === \"months\"\n      ? chosenDate && chosenDate.getFullYear() === pickYear\n        ? chosenDate.getMonth()\n        : shown.getMonth()\n      : Math.min(yearTo, Math.max(yearFrom, (chosenDate ?? shown).getFullYear()));\n  const [pickerFocus, setPickerFocus] = useState(() => ({ view, value: defaultPickFocus }));\n  // A parent can switch views without openYears/openMonths. A year is never a month index.\n  const pickFocus = pickerFocus.view === view ? pickerFocus.value : defaultPickFocus;\n  const setPickFocus = (value: number, mode: View = view) => setPickerFocus({ view: mode, value });\n  const focusAfter = useRef<\"picker\" | \"days\" | null>(view !== \"days\" ? \"picker\" : null);\n  // the days fade back in only after the years or months, never on an ordinary open (frequent use: no motion)\n  const [swapped, setSwapped] = useState(false);\n  const setView = (next: View, focusTo: \"picker\" | \"days\") => {\n    focusAfter.current = focusTo;\n    setSwapped(true);\n    setViewValue(next);\n  };\n  const monthOff = (y: number, m: number) =>\n    (!!minDate && new Date(y, m + 1, 0) < startOfDay(minDate)) ||\n    (!!maxDate && new Date(y, m, 1) > startOfDay(maxDate));\n  const openYears = () => {\n    setPickFocus(Math.min(yearTo, Math.max(yearFrom, (chosenDate ?? shown).getFullYear())), \"years\");\n    setView(\"years\", \"picker\");\n  };\n  const openMonths = (y: number) => {\n    setPickYear(y);\n    setPickFocus(chosenDate && chosenDate.getFullYear() === y ? chosenDate.getMonth() : shown.getMonth(), \"months\");\n    setView(\"months\", \"picker\");\n  };\n  const toDays = (y: number, m: number) => {\n    const last = new Date(y, m + 1, 0).getDate();\n    const next = new Date(y, m, Math.min(focus.getDate(), last));\n    setShown(new Date(y, m, 1));\n    setFocus(next);\n    setView(\"days\", \"days\");\n  };\n  // focus moves in the same commit as the view: a frame later, the clicked year is already gone and focus sits on the\n  // page, so an Escape in that frame reached the popover as \"close\" instead of \"back to the days\"\n  useLayoutEffect(() => {\n    const to = focusAfter.current;\n    focusAfter.current = null;\n    if (!to) return;\n    const root = grid.current;\n    const target = root?.querySelector<HTMLElement>(\n      to === \"days\" ? \"[data-day][tabindex='0']\" : \"[data-pick][tabindex='0']\",\n    );\n    target?.focus({ preventScroll: true });\n    // the chosen year sits in the middle of its scrolling list, without moving the page\n    const list = target?.closest<HTMLElement>(\"[data-slot=calendar-picker]\");\n    if (target && list) list.scrollTop = target.offsetTop - list.clientHeight / 2 + target.offsetHeight / 2;\n  }, [view, pickYear]);\n  const onPickKey = (e: KeyboardEvent<HTMLDivElement>) => {\n    if (e.key === \"Escape\") {\n      e.preventDefault();\n      e.stopPropagation();\n      setView(\"days\", \"days\");\n      return;\n    }\n    const cols = view === \"years\" ? 4 : 3;\n    const rtl = getComputedStyle(e.currentTarget).direction === \"rtl\";\n    const step: Record<string, number> = {\n      ArrowLeft: rtl ? 1 : -1,\n      ArrowRight: rtl ? -1 : 1,\n      ArrowUp: -cols,\n      ArrowDown: cols,\n    };\n    const [lo, hi] = view === \"years\" ? [yearFrom, yearTo] : [0, 11];\n    let next: number | null = null;\n    if (step[e.key] !== undefined) next = pickFocus + step[e.key];\n    if (e.key === \"Home\") next = lo;\n    if (e.key === \"End\") next = hi;\n    if (next === null) return;\n    e.preventDefault();\n    next = Math.min(hi, Math.max(lo, next));\n    setPickFocus(next);\n    const box = e.currentTarget;\n    requestAnimationFrame(() => box.querySelector<HTMLElement>(`[data-pick=\"${next}\"]`)?.focus());\n  };\n\n  const off = (d: Date) =>\n    (minDate && d < startOfDay(minDate)) ||\n    (maxDate && d > startOfDay(maxDate)) ||\n    (Array.isArray(disabledDates) ? disabledDates.some((x) => sameDay(x, d)) : !!disabledDates?.(d));\n  const end = addMonths(shown, months);\n  const tabDay =\n    focus >= shown && focus < end && !off(focus)\n      ? focus\n      : Array.from({ length: Math.round((end.getTime() - shown.getTime()) / DAY) }, (_, i) => addDays(shown, i)).find(\n          (d) => !off(d),\n        );\n  const fmtMonth = dateFormatter(locale, { month: \"long\", year: \"numeric\" });\n  const fmtDay = dateFormatter(locale, { weekday: \"long\", day: \"numeric\", month: \"long\", year: \"numeric\" });\n  const weekdays = useMemo(\n    () =>\n      Array.from({ length: 7 }, (_, i) => {\n        const d = new Date(2024, 0, 7 + weekStartsOn + i);\n        return {\n          short: dateFormatter(locale, { weekday: \"narrow\" }).format(d),\n          long: dateFormatter(locale, { weekday: \"long\" }).format(d),\n        };\n      }),\n    [locale, weekStartsOn],\n  );\n\n  // keyboard focus that leaves the shown months turns the page\n  useEffect(() => {\n    const last = addMonths(shown, months - 1);\n    if (focus < shown || focus > new Date(last.getFullYear(), last.getMonth() + 1, 0)) setShown(focus);\n  }, [focus]); // eslint-disable-line react-hooks/exhaustive-deps -- follows focus only\n  // ...and the focused day takes focus in the commit that shows it (a frame later the page might not have turned yet,\n  // and the old month's button, gone, had handed focus to the page)\n  useLayoutEffect(() => {\n    if (!moved.current) return;\n    const el = grid.current?.querySelector<HTMLElement>(`[data-day=\"${focus.getTime()}\"]`);\n    if (!el) return;\n    moved.current = false;\n    if (document.activeElement !== el) el.focus({ preventScroll: true });\n  });\n\n  const pick = (d: Date) => {\n    if (off(d)) return;\n    setFocus(d);\n    if (!range) {\n      setValue(d);\n      (props as CalendarSingleProps).onChange?.(d);\n      (props as CalendarSingleProps).onValueChange?.(d);\n      return;\n    }\n    if (!anchor) {\n      setAnchor(d);\n      return;\n    }\n    const [start, end] = d < anchor ? [d, anchor] : [anchor, d];\n    setAnchor(null);\n    setHover(null);\n    setValue({ start, end });\n    (props as CalendarRangeProps).onChange?.({ start, end });\n    (props as CalendarRangeProps).onValueChange?.({ start, end });\n  };\n  /** The first day from `d` on (stepping `dir`, a year at most) that can be picked; null when there is none. */\n  const openDay = (d: Date, dir: 1 | -1) => {\n    for (let i = 0, x = d; i < 366; i++, x = addDays(x, dir)) if (!off(x)) return x;\n    return null;\n  };\n  const onKey = (e: KeyboardEvent<HTMLDivElement>) => {\n    if (!(e.target instanceof HTMLElement) || !e.target.matches(\"button[data-day]\")) return;\n    const rtl = getComputedStyle(e.currentTarget).direction === \"rtl\";\n    const map: Record<string, () => Date> = {\n      ArrowLeft: () => addDays(focus, rtl ? 1 : -1),\n      ArrowRight: () => addDays(focus, rtl ? -1 : 1),\n      ArrowUp: () => addDays(focus, -7),\n      ArrowDown: () => addDays(focus, 7),\n      PageUp: () => addMonths(focus, e.shiftKey ? -12 : -1),\n      PageDown: () => addMonths(focus, e.shiftKey ? 12 : 1),\n      Home: () => addDays(focus, -((focus.getDay() - weekStartsOn + 7) % 7)),\n      End: () => addDays(focus, 6 - ((focus.getDay() - weekStartsOn + 7) % 7)),\n    };\n    if (map[e.key]) {\n      e.preventDefault();\n      const raw = map[e.key]();\n      // a closed day (a weekend, past the limits) cannot hold focus: walk on to the next open one the way the key went\n      // (Home and End inward, toward where focus was), or stay\n      const toward = e.key === \"Home\" || e.key === \"End\" ? (raw < focus ? 1 : -1) : raw < focus ? -1 : 1;\n      const next = openDay(raw, toward);\n      if (!next) return;\n      moved.current = true;\n      setFocus(next);\n      if (anchor) setHover(next);\n      return;\n    }\n    if (e.key === \"Enter\" || e.key === \" \") {\n      e.preventDefault();\n      pick(focus);\n    }\n    // T: back to today from wherever the pages have gone (focus moves there; Enter picks it)\n    if (e.key === \"t\" || e.key === \"T\") {\n      if (e.metaKey || e.ctrlKey || e.altKey) return;\n      e.preventDefault();\n      const next = openDay(startOfDay(today), 1) ?? openDay(startOfDay(today), -1);\n      if (!next) return;\n      moved.current = true;\n      setFocus(next);\n      if (anchor) setHover(next);\n      return;\n    }\n    if (e.key === \"Escape\" && anchor) {\n      e.preventDefault();\n      e.stopPropagation();\n      setAnchor(null);\n      setHover(null);\n    }\n  };\n\n  const span = anchor\n    ? hover\n      ? hover < anchor\n        ? { start: hover, end: anchor }\n        : { start: anchor, end: hover }\n      : { start: anchor, end: anchor }\n    : rangeValue;\n  const inSpan = (d: Date) => !!span && d >= startOfDay(span.start) && d <= startOfDay(span.end);\n  // the half-chosen span, told to the caller as it changes (keyed by its two ends, so a render alone never reports)\n  const pendingKey = anchor && span ? `${span.start.getTime()}:${span.end.getTime()}` : \"\";\n  const onPending = range ? (props as CalendarRangeProps).onPendingChange : undefined;\n  useEffect(() => {\n    if (!onPending) return;\n    const [a, b] = pendingKey ? pendingKey.split(\":\").map(Number) : [];\n    onPending(pendingKey ? { start: new Date(a), end: new Date(b) } : null);\n  }, [pendingKey]); // eslint-disable-line react-hooks/exhaustive-deps -- reports changes of the span only\n  const month = (offset: number) => {\n    const first = addMonths(shown, offset);\n    const lead = (first.getDay() - weekStartsOn + 7) % 7;\n    const start = addDays(first, -lead);\n    const weeks = Math.ceil((lead + new Date(first.getFullYear(), first.getMonth() + 1, 0).getDate()) / 7);\n    return (\n      <div\n        key={offset}\n        data-slot=\"calendar-month\"\n        className={cn(\"grid content-start gap-2\", swapped && styles.viewIn, classNames?.month)}\n      >\n        <div\n          data-slot=\"calendar-monthTitle\"\n          className={cn(\"flex h-8 items-center justify-center text-sm font-medium text-ink\", classNames?.monthTitle)}\n          aria-live=\"polite\"\n        >\n          {offset === 0 ? (\n            <button\n              type=\"button\"\n              data-slot=\"calendar-title\"\n              aria-expanded={false}\n              aria-label={i18n(\"chooseAnotherMonthOrYear\", { value: fmtMonth.format(first) })}\n              onClick={openYears}\n              className={cn(styles.title, classNames?.title)}\n            >\n              {fmtMonth.format(first)}\n              <ChevronDown aria-hidden />\n            </button>\n          ) : (\n            fmtMonth.format(first)\n          )}\n        </div>\n        <table\n          data-slot=\"calendar-grid\"\n          role=\"grid\"\n          aria-label={fmtMonth.format(first)}\n          className={cn(\"border-collapse\", classNames?.grid)}\n        >\n          <thead>\n            <tr>\n              {weekdays.map((w) => (\n                <th\n                  data-slot=\"calendar-weekday\"\n                  key={w.long}\n                  scope=\"col\"\n                  abbr={w.long}\n                  className={cn(styles.square, \"text-2xs font-normal text-ink-3\", classNames?.weekday)}\n                >\n                  {w.short}\n                </th>\n              ))}\n            </tr>\n          </thead>\n          <tbody>\n            {Array.from({ length: weeks }, (_, w) => (\n              <tr key={w}>\n                {Array.from({ length: 7 }, (_, i) => {\n                  const d = addDays(start, w * 7 + i);\n                  const outside = d.getMonth() !== first.getMonth();\n                  if (outside)\n                    return (\n                      <td data-slot=\"calendar-blank\" key={`b${i}`} className={cn(styles.square, classNames?.blank)} />\n                    );\n                  const isOn = range\n                    ? !!span && (sameDay(d, span.start) || sameDay(d, span.end))\n                    : sameDay(d, selected);\n                  const mid = range && inSpan(d) && !isOn;\n                  const edgeStart = range && span && sameDay(d, span.start) && !sameDay(span.start, span.end);\n                  const edgeEnd = range && span && sameDay(d, span.end) && !sameDay(span.start, span.end);\n                  const disabled = off(d);\n                  const mark = marks ? marks(d) : undefined;\n                  const recorded = !marks || (mark !== null && mark !== undefined);\n                  const dayName = !marks\n                    ? fmtDay.format(d)\n                    : !recorded\n                      ? i18n(\"dayNotRecorded\", { day: fmtDay.format(d) })\n                      : mark === 0\n                        ? i18n(\"dayNone\", { day: fmtDay.format(d) })\n                        : i18n(\"dayCount\", {\n                            day: fmtDay.format(d),\n                            count: mark!,\n                            noun: markNoun ? markNoun[mark === 1 ? 0 : 1] : i18n(mark === 1 ? \"record\" : \"records\"),\n                          });\n                  return (\n                    <td\n                      data-slot=\"calendar-cell\"\n                      // keyed by its date: a page turn never hands the focused button to another day\n                      key={d.getTime()}\n                      role=\"gridcell\"\n                      aria-selected={isOn || mid || undefined}\n                      className={cn(\n                        \"relative p-0\",\n                        (mid || edgeStart || edgeEnd) && \"bg-accent-tint\",\n                        edgeStart && \"rounded-s-control\",\n                        edgeEnd && \"rounded-e-control\",\n                        mid && i === 0 && \"rounded-s-control\",\n                        mid && i === 6 && \"rounded-e-control\",\n                        classNames?.cell,\n                      )}\n                    >\n                      <button\n                        data-slot=\"calendar-day\"\n                        type=\"button\"\n                        data-day={d.getTime()}\n                        data-chosen={isOn && !range ? \"\" : undefined}\n                        tabIndex={sameDay(d, tabDay) ? 0 : -1}\n                        disabled={disabled}\n                        aria-label={dayName}\n                        data-unrecorded={recorded ? undefined : \"\"}\n                        aria-current={sameDay(d, today) ? \"date\" : undefined}\n                        onClick={() => pick(d)}\n                        onPointerEnter={() => {\n                          if (anchor) setHover(d);\n                        }}\n                        onFocus={() => setFocus(d)}\n                        className={cn(\n                          styles.day,\n                          isOn ? (range ? cn(\"m-solid\", styles.on) : styles.on) : mid ? styles.between : styles.free,\n                          classNames?.day,\n                        )}\n                      >\n                        {d.getDate()}\n                        {!!mark && mark > 0 && (\n                          <span aria-hidden data-slot=\"calendar-marks\" className={styles.marks}>\n                            {Array.from({ length: Math.min(3, mark) }, (_, k) => (\n                              <span key={k} className={styles.markDot} />\n                            ))}\n                            {mark > 3 && <span className={styles.markMore}>+</span>}\n                          </span>\n                        )}\n                        {showToday && sameDay(d, today) && !(mark && mark > 0) && (\n                          <span\n                            data-slot=\"calendar-today\"\n                            aria-hidden\n                            className={cn(\n                              \"absolute bottom-1 size-1 rounded-full\",\n                              isOn ? \"bg-[var(--pui-accent-foreground)]\" : \"bg-accent\",\n                              classNames?.today,\n                            )}\n                          />\n                        )}\n                      </button>\n                    </td>\n                  );\n                })}\n              </tr>\n            ))}\n          </tbody>\n        </table>\n      </div>\n    );\n  };\n  const canBack = view === \"months\" ? pickYear > yearFrom : !minDate || addMonths(shown, -1) >= firstOfMonth(minDate);\n  const canFwd = view === \"months\" ? pickYear < yearTo : !maxDate || addMonths(shown, months) <= startOfDay(maxDate);\n  const fmtShortMonth = dateFormatter(locale, { month: \"short\" });\n  const fmtLongMonth = dateFormatter(locale, { month: \"long\", year: \"numeric\" });\n  const picker = view !== \"days\" && (\n    <div\n      data-slot=\"calendar-month\"\n      className={cn(\"grid content-start gap-2\", styles.viewIn, classNames?.month)}\n      style={{ width: `calc(var(--_cell) * ${7 * months} + ${(months - 1) * 24}px)` }}\n    >\n      <div\n        data-slot=\"calendar-monthTitle\"\n        className={cn(\"flex h-8 items-center justify-center text-sm font-medium text-ink\", classNames?.monthTitle)}\n        aria-live=\"polite\"\n      >\n        <button\n          type=\"button\"\n          data-slot=\"calendar-title\"\n          aria-expanded\n          aria-label={view === \"years\" ? i18n(\"backToTheDays\") : i18n(\"chooseAnotherYear\", { pickYear: pickYear })}\n          onClick={() => (view === \"years\" ? setView(\"days\", \"days\") : openYears())}\n          className={cn(styles.title, classNames?.title)}\n        >\n          {view === \"years\" ? fmtMonth.format(shown) : pickYear}\n          <ChevronDown aria-hidden />\n        </button>\n      </div>\n      <div\n        data-slot=\"calendar-picker\"\n        data-view={view}\n        role=\"group\"\n        aria-label={view === \"years\" ? i18n(\"years\") : i18n(\"monthsOf\", { pickYear: pickYear })}\n        onKeyDown={onPickKey}\n        className={cn(styles.picker, view === \"years\" ? styles.years : styles.monthGrid, classNames?.picker)}\n      >\n        {view === \"years\"\n          ? Array.from({ length: yearTo - yearFrom + 1 }, (_, i) => yearFrom + i).map((y) => {\n              const on = chosenDate?.getFullYear() === y;\n              return (\n                <button\n                  key={y}\n                  type=\"button\"\n                  data-pick={y}\n                  data-slot=\"calendar-pick\"\n                  tabIndex={y === pickFocus ? 0 : -1}\n                  aria-pressed={on}\n                  onClick={() => openMonths(y)}\n                  onFocus={() => setPickFocus(y)}\n                  className={cn(styles.pick, on && cn(\"m-solid\", styles.pickOn), classNames?.pick)}\n                >\n                  {y}\n                  {showToday && y === thisYear && <span aria-hidden className={styles.pickToday} />}\n                </button>\n              );\n            })\n          : Array.from({ length: 12 }, (_, m) => {\n              const on = chosenDate?.getFullYear() === pickYear && chosenDate.getMonth() === m;\n              return (\n                <button\n                  key={m}\n                  type=\"button\"\n                  data-pick={m}\n                  data-slot=\"calendar-pick\"\n                  tabIndex={m === pickFocus ? 0 : -1}\n                  disabled={monthOff(pickYear, m)}\n                  aria-pressed={on}\n                  aria-label={fmtLongMonth.format(new Date(pickYear, m, 1))}\n                  onClick={() => toDays(pickYear, m)}\n                  onFocus={() => setPickFocus(m)}\n                  className={cn(styles.pick, on && cn(\"m-solid\", styles.pickOn), classNames?.pick)}\n                >\n                  {fmtShortMonth.format(new Date(pickYear, m, 1))}\n                  {showToday && pickYear === thisYear && m === today.getMonth() && (\n                    <span aria-hidden className={styles.pickToday} />\n                  )}\n                </button>\n              );\n            })}\n      </div>\n    </div>\n  );\n  return (\n    <div\n      ref={attach}\n      style={style}\n      data-slot=\"calendar\"\n      onKeyDown={onKey}\n      onPointerLeave={() => setHover(null)}\n      className={cn(\"relative inline-grid\", classNames?.root, className)}\n    >\n      <div\n        data-slot=\"calendar-navigation\"\n        className={cn(styles.navigation, \"absolute inset-x-0 top-0 flex justify-between\", classNames?.navigation)}\n      >\n        {view !== \"years\" && (\n          <>\n            <Button\n              variant=\"ghost\"\n              size=\"sm\"\n              aria-label={view === \"months\" ? i18n(\"previousYear\") : i18n(\"previousMonth\")}\n              disabled={!canBack}\n              onClick={() => (view === \"months\" ? openMonths(pickYear - 1) : setShown(addMonths(shown, -1)))}\n            >\n              <ChevronLeft className=\"rtl:rotate-180\" />\n            </Button>\n            <Button\n              variant=\"ghost\"\n              size=\"sm\"\n              aria-label={view === \"months\" ? i18n(\"nextYear\") : i18n(\"nextMonth\")}\n              disabled={!canFwd}\n              onClick={() => (view === \"months\" ? openMonths(pickYear + 1) : setShown(addMonths(shown, 1)))}\n            >\n              <ChevronRight className=\"rtl:rotate-180\" />\n            </Button>\n          </>\n        )}\n      </div>\n      {/* months sit side by side and wrap onto the next row when the container is too narrow for both */}\n      <div\n        ref={monthsRef}\n        data-slot=\"calendar-months\"\n        data-turn={turn.n ? (turn.n % 2 ? \"a\" : \"b\") : undefined}\n        style={{ \"--_dir\": turn.dir } as CSSProperties}\n        // at rest there is no turn: a grid mounted later (back from the years) must not replay the last one\n        onAnimationEnd={(e) => {\n          if (turn.n && e.animationName.includes(\"turn-\")) setTurn((t) => ({ ...t, n: 0 }));\n        }}\n        className={cn(\n          styles.months,\n          \"relative isolate flex flex-wrap justify-center gap-x-6 gap-y-4\",\n          classNames?.months,\n        )}\n      >\n        {view === \"days\" && chosen && (\n          <span ref={chosenRef} aria-hidden data-slot=\"calendar-chosen\" className={styles.chosen} />\n        )}\n        {view === \"days\" ? Array.from({ length: months }, (_, i) => month(i)) : picker}\n      </div>\n      {range && anchor && (\n        <p data-slot=\"calendar-announcement\" className={cn(\"sr-only\", classNames?.announcement)} aria-live=\"polite\">\n          {i18n(\"startChosenChooseTheEnd\", { value: fmtDay.format(anchor) })}\n        </p>\n      )}\n    </div>\n  );\n}\n\nexport { DAY };\nexport default Calendar;\n"},{"path":"beamline/components/calendar/messages.ts","type":"registry:file","target":"src/ui/beamline/components/calendar/messages.ts","content":"import type { MessageDefinitions } from \"../../runtime/messages\";\n/** Built-in English copy; stable keys are the public translation API. */\nexport const english = {\n  chooseAnotherMonthOrYear: \"{value}: choose another month or year\",\n  backToTheDays: \"Back to the days\",\n  chooseAnotherYear: \"{pickYear}: choose another year\",\n  years: \"Years\",\n  monthsOf: \"Months of {pickYear}\",\n  previousYear: \"Previous year\",\n  previousMonth: \"Previous month\",\n  nextYear: \"Next year\",\n  nextMonth: \"Next month\",\n  startChosenChooseTheEnd: \"Start {value} chosen; choose the end.\",\n  dayCount: \"{day}, {count} {noun}\",\n  dayNone: \"{day}, none\",\n  dayNotRecorded: \"{day}, not recorded\",\n  record: \"record\",\n  records: \"records\",\n} satisfies MessageDefinitions;\n"},{"path":"beamline/components/date-picker/date-picker.tsx","type":"registry:file","target":"src/ui/beamline/components/date-picker/date-picker.tsx","content":"\"use client\";\nimport { dateFormatter, relativeTimeFormatter, useMessages } from \"../../runtime/localization\";\nimport { english as englishMessages } from \"./messages\";\nimport { useLocale } from \"../../runtime/localization\";\n\nimport { useDeprecatedProp } from \"../../hooks/use-deprecated-prop\";\n\nimport { useComposedRef } from \"../../hooks/use-composed-ref\";\n\nimport { useComponentDefaults } from \"../../runtime/appearance\";\nimport type { DatePickerDefaults } from \"./defaults\";\nexport type { DatePickerDefaults } from \"./defaults\";\n\nimport { useRef, useState, type Ref, type CSSProperties, type ReactNode } from \"react\";\nimport { CalendarDays, X } from \"lucide-react\";\nimport * as RadixPopover from \"@radix-ui/react-popover\";\nimport { Button } from \"../button/button\";\nimport { Calendar, startOfDay, type CalendarDateMatcher } from \"../calendar/calendar\";\nimport { Field, useFieldIds, type FieldClassNames, type FieldSize } from \"../_shared/field\";\nimport { usePortalContainer } from \"../../runtime/appearance\";\nimport { cn } from \"../../lib/utils\";\nimport { useControllable } from \"../../hooks/use-controllable\";\nimport { IconAction } from \"../_shared/icon-action\";\nimport { useToday } from \"../../lib/now\";\nimport field from \"../_shared/field.module.css\";\nimport overlay from \"../_shared/overlay.module.css\";\n\nexport interface DatePickerProps {\n  /** Visible label or accessible name for the control. Required. */\n  label: ReactNode;\n  /** Shows the label visually while keeping its accessible name; defaults to true. Takes precedence over hideLabel. */\n  showLabel?: boolean;\n  /** Hides the label; defaults to false. @deprecated Use showLabel={false} instead. */\n  hideLabel?: boolean;\n  /** Controlled selected date; null clears the field; omit to use defaultValue. */\n  value?: Date | null;\n  /** Initial selected date when uncontrolled. Defaults to null. */\n  defaultValue?: Date | null;\n  /** Legacy value-change callback; omitted by default. Prefer onValueChange.\n   *  @deprecated Use onValueChange; this value callback remains supported and is omitted by default. */\n  onChange?: (date: Date | undefined) => void;\n  /** The new date (undefined when cleared): the name every Beamline field uses. */\n  onValueChange?: (date: Date | undefined) => void;\n  /** Supporting text beneath the label or heading. Defaults to no supporting text. */\n  description?: ReactNode;\n  /** Error message shown in place of the usual supporting text. Defaults to no error message. */\n  error?: ReactNode;\n  /** Text shown before a value is entered or selected. Defaults to \"Pick a date\". */\n  placeholder?: string;\n  /** The first day that can be picked: a date, or \"today\" (read in the browser, so a server-rendered page stays valid). */\n  minDate?: Date | \"today\";\n  /** The last day that can be picked: a date, or \"today\" (a date of birth, a report period). */\n  maxDate?: Date | \"today\";\n  /** Dates that cannot be selected, or a predicate that identifies them. Defaults to no additional disabled dates. */\n  disabledDates?: CalendarDateMatcher;\n  /** Locale used for number, date or text formatting. Defaults to the runtime locale. */\n  locale?: string;\n  /** How the chosen day reads in the field. Default \"14 Oct 2026\" in the locale. */\n  format?: Intl.DateTimeFormatOptions;\n  /** First weekday in the picker: 0 Sunday or 1 Monday. Defaults to Monday. */\n  weekStartsOn?: 0 | 1;\n  /** A × in the field that clears the date. It shows while the field is hovered or holds focus (always on touch). */\n  clearable?: boolean;\n  /** How far the day is from today (Tomorrow, in 4 days, 2 days ago) beside it, within 30 days and only while the field\n   *  has room for it whole. Default true. */\n  relative?: boolean;\n  /** Marks the current day in the calendar. Defaults to true. */\n  showToday?: boolean;\n  /** Open on the years instead of the days while empty: a date of birth or another far date (pair it with maxDate). */\n  openTo?: \"days\" | \"years\";\n  /** Control size within the supported size steps. Defaults to \"md\". */\n  size?: FieldSize;\n  /** Prevents interaction with the control. Defaults to false. */\n  disabled?: boolean;\n  /** Marks the field as required for form submission. Defaults to false. */\n  required?: boolean;\n  /** DOM id used to connect the control and its label. Defaults to an automatically generated control id. */\n  id?: string;\n  /** Classes on the documented visual root; no override by default. */\n  className?: string;\n  /** Classes for documented field parts; root style does not replace native behavior. */\n  classNames?: FieldClassNames & Partial<Record<\"trigger\" | \"value\" | \"icon\" | \"clear\" | \"content\", string>>;\n  /** Inline styles on the documented visual root; no inline overrides by default. */\n  style?: CSSProperties;\n  /** Receives the button or trigger; no ref by default. */\n  ref?: Ref<HTMLButtonElement>;\n}\n\n/** One date in a form: the field opens a month grid under it, focus moves into the grid, and picking a day closes it.\n *  Today and Clear sit under the grid. */\nexport function DatePicker({\n  label,\n  hideLabel: hideLabelProp,\n  showLabel,\n  value: valueProp,\n  defaultValue = null,\n  onChange,\n  onValueChange,\n  description,\n  error,\n  placeholder: placeholderProp,\n  minDate: minProp,\n  maxDate: maxProp,\n  disabledDates,\n  locale: localeProp,\n  format = { day: \"numeric\", month: \"short\", year: \"numeric\" },\n  weekStartsOn,\n  clearable,\n  relative = true,\n  showToday = true,\n  openTo = \"days\",\n  size: sizeProp,\n  disabled,\n  required,\n  id,\n  className,\n  classNames,\n  style,\n  ref,\n}: DatePickerProps) {\n  const i18n = useMessages(\"date-picker\", englishMessages);\n  const placeholder = placeholderProp === undefined ? i18n(\"placeholder\") : placeholderProp;\n\n  const locale = useLocale(localeProp);\n\n  useDeprecatedProp(\"DatePicker\", \"hideLabel\", \"showLabel={false}\", hideLabelProp !== undefined);\n  const hideLabel = showLabel === undefined ? hideLabelProp : !showLabel;\n  useDeprecatedProp(\"DatePicker\", \"onChange\", \"onValueChange\", onChange !== undefined);\n  const scopeDefaults = useComponentDefaults<DatePickerDefaults>(\"date-picker\", [\"size\"]);\n  const size = sizeProp ?? scopeDefaults.size ?? \"md\";\n\n  const trigger = useRef<HTMLButtonElement>(null);\n  const attach = useComposedRef(trigger, ref);\n  // the value is null once cleared, while onChange reports a clear as undefined (its documented contract)\n  const [value, setValue] = useControllable<Date | null>(valueProp, defaultValue);\n  const set = (d: Date | undefined) => {\n    setValue(d ?? null);\n    onChange?.(d);\n    onValueChange?.(d);\n  };\n  const [open, setOpen] = useState(false);\n  const { controlId, descriptionId, errorId, aria } = useFieldIds(id, { description, error });\n  const container = usePortalContainer();\n  const today = useToday();\n  const minDate = minProp === \"today\" ? (today ?? undefined) : minProp;\n  const maxDate = maxProp === \"today\" ? (today ?? undefined) : maxProp;\n  const todayOff = !today || (minDate && today < startOfDay(minDate)) || (maxDate && today > startOfDay(maxDate));\n  // the day's distance from today, when it helps a decision (a renewal in 4 days), not for a far date (a birthday)\n  const away = value && today ? Math.round((startOfDay(value).getTime() - today.getTime()) / 864e5) : null;\n  const near =\n    relative && away !== null && Math.abs(away) <= 30\n      ? relativeTimeFormatter(locale, { numeric: \"auto\" }).format(away, \"day\")\n      : null;\n  return (\n    <Field\n      label={label}\n      hideLabel={hideLabel}\n      description={description}\n      error={error}\n      required={required}\n      controlId={controlId}\n      descriptionId={descriptionId}\n      errorId={errorId}\n      className={className}\n      classNames={classNames}\n      style={style}\n    >\n      <RadixPopover.Root open={open} onOpenChange={setOpen}>\n        <div className={cn(\"relative\", clearable && \"reveal-host\")}>\n          <RadixPopover.Trigger asChild>\n            <button\n              ref={attach}\n              type=\"button\"\n              data-slot=\"date-picker\"\n              {...aria}\n              disabled={disabled}\n              aria-haspopup=\"dialog\"\n              className={cn(\n                field.frame,\n                field[size],\n                \"w-full cursor-pointer justify-between text-start focus-visible:outline-none disabled:cursor-not-allowed\",\n                !value && \"text-ink-3\",\n                clearable && value && \"pe-[calc(var(--pui-space-1)*9)]\",\n                classNames?.frame,\n                classNames?.trigger,\n              )}\n              data-invalid={error ? \"\" : undefined}\n              data-disabled={disabled ? \"\" : undefined}\n            >\n              {/* the day, then how far it is: the second wraps out of sight (one line, clipped) when the field is too\n                  narrow to show it whole, so a narrow field shows the date alone and never half a hint */}\n              <span\n                data-slot=\"date-picker-value\"\n                className={cn(\n                  \"flex h-[1lh] min-w-0 flex-wrap items-baseline gap-x-2 overflow-hidden\",\n                  classNames?.value,\n                )}\n              >\n                <span className=\"max-w-full truncate\">\n                  {value ? dateFormatter(locale, format).format(value) : placeholder}\n                </span>\n                {near && (\n                  <span data-slot=\"date-picker-relative\" className=\"whitespace-nowrap text-ink-3\">\n                    {near}\n                  </span>\n                )}\n              </span>\n              <CalendarDays\n                data-slot=\"date-picker-icon\"\n                aria-hidden\n                className={cn(\"size-4 shrink-0 text-ink-3\", classNames?.icon)}\n              />\n            </button>\n          </RadixPopover.Trigger>\n          {clearable && value && !disabled && (\n            <IconAction\n              aria-label={i18n(\"clearDate\")}\n              onClick={() => {\n                set(undefined);\n                trigger.current?.focus();\n              }}\n              data-slot=\"date-picker-clear\"\n              className={cn(\"reveal absolute inset-y-0 end-8 my-auto\", classNames?.clear)}\n            >\n              <X className=\"size-3.5\" />\n            </IconAction>\n          )}\n        </div>\n        {container !== null && (\n          <RadixPopover.Portal container={container}>\n            <RadixPopover.Content\n              onEscapeKeyDown={(e) => {\n                // in the years or months, Escape returns to the days (the calendar handles it), not out of the picker\n                if ((e.target as Element | null)?.closest?.(\"[data-slot=calendar-picker]\")) e.preventDefault();\n              }}\n              data-slot=\"date-picker-calendar\"\n              align=\"start\"\n              sideOffset={6}\n              collisionPadding={8}\n              aria-label={i18n(\"chooseADate\")}\n              className={cn(overlay.surface, overlay.padded, \"grid gap-[var(--pui-space-3)]\", classNames?.content)}\n              onOpenAutoFocus={(e) => {\n                e.preventDefault();\n                (e.currentTarget as HTMLElement)\n                  .querySelector<HTMLElement>(\"[data-day][tabindex='0'], [data-pick][tabindex='0']\")\n                  ?.focus({ preventScroll: true });\n              }}\n            >\n              <Calendar\n                value={value}\n                onValueChange={(d) => {\n                  set(d);\n                  setOpen(false);\n                }}\n                minDate={minDate}\n                maxDate={maxDate}\n                disabledDates={disabledDates}\n                locale={locale}\n                weekStartsOn={weekStartsOn}\n                showToday={showToday}\n                defaultView={openTo === \"years\" && !value ? \"years\" : \"days\"}\n              />\n              <div className=\"flex justify-between border-t border-line-soft pt-[var(--pui-space-2)]\">\n                <Button\n                  variant=\"ghost\"\n                  size=\"sm\"\n                  disabled={!!todayOff}\n                  onClick={() => {\n                    if (today) set(today);\n                    setOpen(false);\n                  }}\n                >\n                  {i18n(\"today\")}\n                </Button>\n                {value && (\n                  <Button\n                    variant=\"ghost\"\n                    size=\"sm\"\n                    onClick={() => {\n                      set(undefined);\n                      setOpen(false);\n                    }}\n                  >\n                    {i18n(\"clear\")}\n                  </Button>\n                )}\n              </div>\n            </RadixPopover.Content>\n          </RadixPopover.Portal>\n        )}\n      </RadixPopover.Root>\n    </Field>\n  );\n}\n\nexport default DatePicker;\n"},{"path":"beamline/components/date-picker/defaults.ts","type":"registry:file","target":"src/ui/beamline/components/date-picker/defaults.ts","content":"/** Pure allowed presentation defaults for DatePicker; no component or runtime imports. */\nexport interface DatePickerDefaults {\n  /** Shared size setting; omit to inherit the surrounding scope or the component default. */\n  size?: \"sm\" | \"md\" | \"lg\";\n}\n"},{"path":"beamline/components/date-picker/messages.ts","type":"registry:file","target":"src/ui/beamline/components/date-picker/messages.ts","content":"import type { MessageDefinitions } from \"../../runtime/messages\";\n/** Built-in English copy; stable keys are the public translation API. */\nexport const english = {\n  placeholder: \"Pick a date\",\n  clearDate: \"Clear date\",\n  chooseADate: \"Choose a date\",\n  today: \"Today\",\n  clear: \"Clear\",\n} satisfies MessageDefinitions;\n"},{"path":"beamline/components/label/label.tsx","type":"registry:file","target":"src/ui/beamline/components/label/label.tsx","content":"\"use client\";\n\nimport { useMessages } from \"../../runtime/localization\";\nimport { english as englishMessages } from \"./messages\";\nimport type { ComponentProps } from \"react\";\nimport * as RadixLabel from \"@radix-ui/react-label\";\nimport { cn } from \"../../lib/utils\";\n\nexport interface LabelProps extends ComponentProps<typeof RadixLabel.Root> {\n  /** Shows the marker and announces \"required\". */\n  required?: boolean;\n  /** The control says \"required\" itself (a native required input, a radiogroup with aria-required): the label shows\n   * the marker only, so the control's name stays the label's words and the state is announced once. */\n  requiredOnControl?: boolean;\n}\n\n/** The text label tied to a form control. It dims with a disabled control next to it (peer) or inside it (group). */\nexport function Label({ required = false, requiredOnControl = false, className, children, ...props }: LabelProps) {\n  const i18n = useMessages(\"label\", englishMessages);\n\n  return (\n    <RadixLabel.Root\n      data-slot=\"label\"\n      {...props}\n      className={cn(\n        \"inline-flex items-center gap-[var(--pui-space-1)] text-sm leading-tight font-medium text-ink select-none group-data-[disabled]:opacity-[var(--pui-opacity-disabled)] peer-disabled:opacity-[var(--pui-opacity-disabled)]\",\n        className,\n      )}\n    >\n      {children}\n      {required && (\n        <>\n          <span aria-hidden className=\"text-red\">\n            *\n          </span>\n          {!requiredOnControl && <span className=\"sr-only\">{i18n(\"required\")}</span>}\n        </>\n      )}\n    </RadixLabel.Root>\n  );\n}\n\nexport default Label;\n"},{"path":"beamline/components/label/messages.ts","type":"registry:file","target":"src/ui/beamline/components/label/messages.ts","content":"import type { MessageDefinitions } from \"../../runtime/messages\";\n/** Built-in English copy; stable keys are the public translation API. */\nexport const english = {\n  required: \"required\",\n} satisfies MessageDefinitions;\n"},{"path":"beamline/components/number-field/defaults.ts","type":"registry:file","target":"src/ui/beamline/components/number-field/defaults.ts","content":"/** Pure allowed presentation defaults for NumberField; no component or runtime imports. */\nexport interface NumberFieldDefaults {\n  size?: \"sm\" | \"md\" | \"lg\";\n}\n"},{"path":"beamline/components/number-field/messages.ts","type":"registry:file","target":"src/ui/beamline/components/number-field/messages.ts","content":"import type { MessageDefinitions } from \"../../runtime/messages\";\n/** Built-in English copy; stable keys are the public translation API. */\nexport const english = {\n  useTheSuggested: \"Use the suggested {value}\",\n  use: \"Use\",\n  decrease: \"Decrease\",\n  increase: \"Increase\",\n  theLowestIs: \"The lowest is {value}.\",\n  theHighestIs: \"The highest is {value}.\",\n  suggestedEnterUsesIt: \"Suggested {value}; Enter uses it\",\n  useConverted: \"Use {value}\",\n  convertsTo: \"{typed} is {value}; Enter uses it\",\n  convertsRounded: \"{typed} is {value}; the field takes {used}, Enter uses it\",\n  convertsOver: \"{typed} is {value}, over the highest, {limit}; Enter uses {limit}\",\n  convertsUnder: \"{typed} is {value}, under the lowest, {limit}; Enter uses {limit}\",\n  overLimit: \"over {limit}\",\n  underLimit: \"under {limit}\",\n  /** While editing a field that takes other units (and has no description of its own). */\n  alsoIn: \"Also in {units}\",\n  unknownUnit: \"Use {units}\",\n} satisfies MessageDefinitions;\n"},{"path":"beamline/components/number-field/number-field.module.css","type":"registry:file","target":"src/ui/beamline/components/number-field/number-field.module.css","content":"@layer properties, theme, base, components, utilities;\n@layer components {\n  /* The − and + at the end of the frame: a press steps at once (and repeats while held), acknowledged at 0 ms. */\n  /* a suggested value waits in the empty field: written in the second ink (readable, not yet the value), with Use\n     beside it */\n  [data-suggested]::placeholder {\n    color: var(--pui-ink-2);\n    opacity: 1;\n  }\n  .use {\n    height: var(--pui-space-6);\n    padding-inline: var(--pui-space-1-5);\n    border-radius: var(--pui-radius-chip);\n    font-size: var(--pui-text-xs);\n    font-weight: var(--pui-weight-medium);\n    color: var(--pui-ink-2);\n    user-select: none;\n    transition:\n      background-color var(--pui-motion-out) var(--pui-ease-default),\n      color var(--pui-motion-out) var(--pui-ease-default);\n  }\n  .use:hover {\n    background: var(--pui-hover);\n    color: var(--pui-ink);\n    transition-duration: 0ms;\n  }\n  /* the conversion reads as part of the number (\"= 5,000\" before the unit), so it keeps the value's ink */\n  .convert {\n    display: inline-flex;\n    align-items: center;\n    gap: var(--pui-space-1);\n    color: var(--pui-ink);\n    background: var(--pui-hover);\n  }\n  .convertLimit {\n    color: var(--pui-ink-3);\n    font-weight: var(--pui-weight-regular);\n  }\n  .convert[data-beyond] {\n    color: var(--pui-ink-2);\n  }\n  .use:active {\n    scale: var(--pui-press-scale);\n  }\n  .stepper {\n    display: grid;\n    width: var(--pui-space-6);\n    height: var(--pui-space-6);\n    place-items: center;\n    border-radius: var(--pui-radius-chip);\n    color: var(--pui-ink-3);\n    touch-action: none;\n    user-select: none;\n    transition:\n      background-color var(--pui-motion-out) var(--pui-ease-default),\n      color var(--pui-motion-out) var(--pui-ease-default),\n      scale var(--pui-motion-out) var(--pui-ease-default);\n  }\n  .stepper:hover {\n    background: var(--pui-hover);\n    color: var(--pui-ink);\n    transition-duration: 0ms;\n  }\n  .stepper:active {\n    scale: var(--pui-press-scale);\n    transition-duration: 0ms;\n  }\n  .stepper:disabled {\n    opacity: var(--pui-opacity-disabled);\n    pointer-events: none;\n  }\n  .stepper :where(svg) {\n    width: var(--pui-icon-sm);\n    height: var(--pui-icon-sm);\n  }\n\n  /* scrub: the label is a handle; its sideways mark is the shared reveal (with attention, always on touch) */\n  .scrub {\n    display: inline-flex;\n    align-items: center;\n    gap: var(--pui-space-1);\n    cursor: ew-resize;\n    /* dragged sideways: the page keeps vertical scrolling over the label (useDrag drops a drag that starts vertically) */\n    touch-action: pan-y;\n    user-select: none;\n  }\n  .scrubMark {\n    width: var(--pui-icon-sm);\n    height: var(--pui-icon-sm);\n    color: var(--pui-ink-3);\n  }\n}\n"},{"path":"beamline/components/number-field/number-field.tsx","type":"registry:file","target":"src/ui/beamline/components/number-field/number-field.tsx","content":"\"use client\";\nimport { listFormatter, numberFormatter, useMessages } from \"../../runtime/localization\";\nimport { english as englishMessages } from \"./messages\";\nimport { useLocale } from \"../../runtime/localization\";\n\nimport { useComponentDefaults } from \"../../runtime/appearance\";\nimport type { NumberFieldDefaults } from \"./defaults\";\nimport { cssEase } from \"../../lib/motion-tokens\";\nexport type { NumberFieldDefaults } from \"./defaults\";\n\nimport {\n  useEffect,\n  useMemo,\n  useLayoutEffect,\n  useRef,\n  useState,\n  type KeyboardEvent,\n  type PointerEvent as ReactPointerEvent,\n  type Ref,\n  type CSSProperties,\n  type ReactNode,\n} from \"react\";\nimport { Minus, MoveHorizontal, Plus } from \"lucide-react\";\nimport {\n  Field,\n  FieldFrame,\n  fieldControlClass,\n  useFieldIds,\n  type FieldClassNames,\n  type FieldSize,\n} from \"../_shared/field\";\nimport { parseLocaleNumber } from \"../../lib/number\";\nimport { rollText } from \"../_shared/roll\";\nimport { useComposedRef } from \"../../hooks/use-composed-ref\";\nimport { useWidthAs } from \"../../hooks/use-content-width\";\nimport { useMotionTokens } from \"../../hooks/use-motion-tokens\";\nimport { cn } from \"../../lib/utils\";\nimport { useControllable } from \"../../hooks/use-controllable\";\nimport { useDrag } from \"../../hooks/use-drag\";\nimport styles from \"./number-field.module.css\";\n\nexport type NumberFieldSize = FieldSize;\nexport type NumberFieldAffix = ReactNode;\n\nexport interface NumberFieldProps {\n  label: ReactNode;\n  hideLabel?: boolean;\n  value?: number | null;\n  defaultValue?: number | null;\n  onValueChange?: (value: number | null) => void;\n  /** The number as it is typed, before the field is left (read in the locale and its units, not yet clamped; null\n   *  while empty), for words beside the field that follow the typing. Unreadable text is skipped. Commits still go to\n   *  onValueChange. */\n  onValueInput?: (value: number | null) => void;\n  min?: number;\n  max?: number;\n  step?: number;\n  /** Shift+arrow and Page Up/Down. Default 10 × step. */\n  largeStep?: number;\n  description?: ReactNode;\n  error?: ReactNode;\n  /** Before the number: \"$\". */\n  prefix?: NumberFieldAffix;\n  /** After the number: \"×\", \"seats\". */\n  suffix?: NumberFieldAffix;\n  /** Drag the label sideways to change the value. */\n  scrub?: boolean;\n  /** false: no − and + at any width, for dense rows of values (a set's weight, reps and rest); arrows, scrub and\n   *  typing still change it. Default: the steppers show while the frame has room for them beside the value. */\n  steppers?: boolean;\n  locale?: string;\n  /** Intl options for the number shown (`{ minimumFractionDigits: 1 }`); the decimals shown otherwise follow `step`. */\n  formatOptions?: Intl.NumberFormatOptions;\n  /** Shown in the empty field. */\n  placeholder?: string;\n  /** A proposed value awaiting confirmation (a machine estimate): while the field is empty it shows as the placeholder\n   *  with Use beside it; Use, Enter or a step takes it, typing replaces it. Never sent as the value until taken. */\n  suggested?: number | null;\n  /** Say when a limit is reached (\"Up to 500 seats\"); true uses a default sentence. */\n  limitHint?: boolean | ((edge: \"min\" | \"max\", limit: number) => string);\n  /** Other units a typed value may carry, each as how many of the field's own unit (its `suffix`) one of it is:\n   *  `{ mL: 1000, L: 1e6 }` in a µL field. Typing \"5 mL\" offers \"= 5,000\" beside the number; Enter, leaving the field\n   *  or the offer takes it, and the digits roll to the converted value. The value is rounded to the decimals the field shows, as any typed number is\n   *  (shown \"≈\", the exact amount said) and held at the limits (the true amount shown \"over 20,000\"); a unit it does not\n   *  know keeps the value and names the units it takes. Without `units` letters are ignored (\"5 mL\" reads as 5). */\n  units?: Record<string, number>;\n  size?: NumberFieldSize;\n  disabled?: boolean;\n  required?: boolean;\n  name?: string;\n  id?: string;\n  className?: string;\n  /** Classes for documented field parts; root style does not replace native behavior. */\n  classNames?: FieldClassNames & Partial<Record<\"input\" | \"decrease\" | \"increase\" | \"use\" | \"convert\", string>>;\n  style?: CSSProperties;\n  ref?: Ref<HTMLInputElement>;\n}\n\nconst decimals = (n: number) => (String(n).split(\".\")[1] ?? \"\").length;\n// holding a stepper: one step at once, then after a pause a run that quickens to a floor (pacing, not motion)\nconst HOLD_PAUSE = 400;\nconst HOLD_FIRST = 120;\nconst HOLD_FLOOR = 40;\n// the room the steppers need (two 24px buttons and their gaps) and a tabular digit's width, at the default type size\nconst STEPPERS = 60;\nconst DIGIT = 8;\n\n/**\n * A bounded number with − and + beside it. ↑ ↓ step, Shift or Page Up/Down take large steps, Home and End go to the\n * limits; typing is free and the value is read (in the locale) and clamped when the field is left. With `scrub` the\n * label drags the value.\n */\nexport function NumberField({\n  label,\n  hideLabel,\n  value: valueProp,\n  defaultValue = null,\n  onValueChange,\n  onValueInput,\n  min = -Infinity,\n  max = Infinity,\n  step = 1,\n  largeStep,\n  description,\n  error,\n  prefix,\n  suffix,\n  scrub,\n  steppers = true,\n  locale: localeProp,\n  formatOptions,\n  placeholder,\n  suggested,\n  limitHint,\n  units,\n  size: sizeProp,\n  disabled,\n  required,\n  name,\n  id,\n  className,\n  classNames,\n  style,\n  ref,\n}: NumberFieldProps) {\n  const i18n = useMessages(\"number-field\", englishMessages);\n\n  const locale = useLocale(localeProp);\n\n  const scopeDefaults = useComponentDefaults<NumberFieldDefaults>(\"number-field\", [\"size\"]);\n  const size = sizeProp ?? scopeDefaults.size ?? \"md\";\n\n  // a commit that lands on the same number is not a change, so the hook holds the value and the report is guarded\n  const [value, setValue] = useControllable<number | null>(valueProp, defaultValue);\n  const fmt = useMemo(\n    () => numberFormatter(locale, { maximumFractionDigits: Math.max(decimals(step), 0), ...formatOptions }),\n    [locale, step, formatOptions],\n  );\n  const [text, setText] = useState(value == null ? \"\" : fmt.format(value));\n  const [editing, setEditing] = useState(false);\n  const [edge, setEdge] = useState<\"min\" | \"max\" | null>(null);\n  const scrubbing = useRef<{ from: number } | null>(null);\n  const scrubRef = useRef<HTMLSpanElement>(null);\n  const field = useRef<HTMLInputElement>(null);\n  const attach = useComposedRef(field, ref);\n  const frame = useRef<HTMLDivElement>(null);\n  // the value outranks the steppers: in a frame too narrow for both, the steppers fold away (arrows, scrub and typing\n  // still change it) and come back as the room grows\n  const roomy = useWidthAs(frame, (w) => w >= STEPPERS + (Math.max(text.length, 3) + 1) * DIGIT, true, text.length);\n  const latest = useRef(value);\n  useLayoutEffect(() => {\n    latest.current = value;\n  });\n  const holding = useRef<{ timer: number; stop: () => void } | null>(null);\n  // a run still going when the field leaves the page stops with it\n  useEffect(() => {\n    const run = holding;\n    return () => run.current?.stop();\n  }, []);\n  const hint =\n    edge && limitHint\n      ? typeof limitHint === \"function\"\n        ? limitHint(edge, edge === \"min\" ? min : max)\n        : edge === \"min\"\n          ? i18n(\"theLowestIs\", { value: fmt.format(min) })\n          : i18n(\"theHighestIs\", { value: fmt.format(max) })\n      : undefined;\n  // words the field could not read lead, then a limit reached, then (while editing) the units it also takes; the input\n  // is described by whichever shows\n  const [unknownUnit, setUnknownUnit] = useState(false);\n  const own = typeof suffix === \"string\" ? suffix : undefined;\n  const unitList = units\n    ? listFormatter(locale, { type: \"disjunction\" }).format([...Object.keys(units), ...(own ? [own] : [])])\n    : \"\";\n  const fieldDescription = unknownUnit\n    ? i18n(\"unknownUnit\", { units: unitList })\n    : (hint ?? (units && editing && !description ? i18n(\"alsoIn\", { units: unitList }) : description));\n  const { controlId, descriptionId, errorId, aria } = useFieldIds(id, { description: fieldDescription, error });\n  useEffect(() => {\n    if (!editing) setText(value == null ? \"\" : fmt.format(value));\n  }, [value, editing, fmt]);\n\n  const clamp = (n: number) => Math.min(max, Math.max(min, Number(n.toFixed(Math.max(decimals(step), 6)))));\n  const commit = (n: number | null) => {\n    const next = n === null ? null : clamp(n);\n    // at or past a limit, judged against the limit itself (22.1 + 0.1 is 22.200000000000003 in floating point, which\n    // the clamp tidies; that tidying is not a limit)\n    setEdge(\n      next === null || n === null ? null : n <= min || next === min ? \"min\" : n >= max || next === max ? \"max\" : null,\n    );\n    setValue(next);\n    if (next !== value) onValueChange?.(next);\n    setText(next == null ? \"\" : fmt.format(next));\n  };\n  // a suggestion stands in the empty field until it is taken (Use, Enter, a step) or replaced by typing\n  const offer = value == null && suggested != null && Number.isFinite(suggested) ? clamp(suggested) : null;\n  const suggesting = offer !== null && !text.trim();\n  // a number typed with another unit (\"5 mL\" in a µL field) is read in that unit and converted to the field's\n  const typedUnit = (s: string): { n: number; number: string; unit: string; per: number } | null => {\n    if (!units) return null;\n    const m = s.trim().match(/^([+\\-\\u2212]?[\\p{Nd}.,'\\s\\u202f\\u00a0]*\\p{Nd}(?:e[+\\-\\u2212]?\\d+)?)\\s*(\\S.*)$/iu);\n    if (!m) return null;\n    // the Greek mu (U+03BC) and the micro sign (U+00B5) look alike; either names micro\n    const token = m[2].trim().replace(/\\u03bc/g, \"\\u00b5\");\n    const table: Record<string, number> = own ? { ...units, [own]: 1 } : units;\n    let unit = token in table ? token : undefined;\n    if (!unit) {\n      // case is forgiven only where it names one unit (\"ml\" is mL; \"m\" never guesses between mL and ML), and a \"u\"\n      // stands for \"µ\", which most keyboards lack (\"5 ul\" is 5 µL)\n      for (const tok of [token, token.replace(/^u/i, \"µ\")]) {\n        const near = Object.keys(table).filter((k) => k.toLowerCase() === tok.toLowerCase());\n        if (near.length === 1) {\n          unit = near[0];\n          break;\n        }\n      }\n    }\n    const n = parseLocaleNumber(m[1], locale);\n    if (!unit || n === null || !Number.isFinite(table[unit])) return null;\n    // the typed number is said as typed: the field's precision belongs to the converted value (\"1.5 h\", not \"2 h\")\n    return { n, number: m[1].trim(), unit, per: table[unit] };\n  };\n  const typed = editing ? typedUnit(text) : null;\n  // a conversion in the field's precision: what Enter will use (the exact amount is said beside it when they differ)\n  // the decimals the field shows: what it holds is what it shows, whichever unit typed it (5.55 µL and 5550 nL both\n  // hold the 5.6 they show); rounded in decimal, after dropping binary noise, so 5.55 goes up as written\n  const places = fmt.resolvedOptions().maximumFractionDigits ?? decimals(step);\n  const toPrecision = (n: number) =>\n    Number((Math.round(Number((n * 10 ** places).toPrecision(12))) / 10 ** places).toFixed(places));\n  // the offer shows only when it changes the number: \"5 µL\" in a µL field is just 5\n  // twelve significant digits drop binary noise (1.005 × 1000 is 1004.9999999999999 in floating point)\n  const product = (t: { n: number; per: number }) => Number((t.n * t.per).toPrecision(12));\n  const exact = typed && typed.per !== 1 ? product(typed) : null;\n  const converted = exact === null ? null : clamp(toPrecision(exact));\n  // the exact amount keeps its significant digits, however small (0.00005 nL is 0.00000005 µL, never 0)\n  const loose = useMemo(() => numberFormatter(locale, { maximumSignificantDigits: 9 }), [locale]);\n  // the conversion said truly: past a limit it says so, and a rounded one says what Enter will use\n  const beyond = exact === null ? null : exact > max ? \"max\" : exact < min ? \"min\" : null;\n  const unitText = (n: number) => `${loose.format(n)}${own ? ` ${own}` : \"\"}`;\n  const conversion =\n    exact === null || !typed\n      ? \"\"\n      : beyond\n        ? i18n(beyond === \"max\" ? \"convertsOver\" : \"convertsUnder\", {\n            typed: `${typed.number} ${typed.unit}`,\n            value: unitText(exact),\n            limit: unitText(beyond === \"max\" ? max : min),\n          })\n        : converted !== exact\n          ? i18n(\"convertsRounded\", {\n              typed: `${typed.number} ${typed.unit}`,\n              value: unitText(exact),\n              used: unitText(converted!),\n            })\n          : i18n(\"convertsTo\", { typed: `${typed.number} ${typed.unit}`, value: unitText(exact) });\n  // words with letters that name no unit the field knows: nothing is guessed, the value stays and the hint says why\n  // what typing reads so far, without the state parse keeps: undefined when it can't be read yet\n  const readTyped = (s: string): number | null | undefined => {\n    if (!s.trim()) return null;\n    const t = typedUnit(s);\n    if (t) return toPrecision(t.per === 1 ? t.n : product(t));\n    const n = parseLocaleNumber(s, locale);\n    return n === null ? undefined : toPrecision(n);\n  };\n  const parse = (s: string): number | null => {\n    if (!s.trim()) return null;\n    const t = typedUnit(s);\n    // a number in exponent form (\"1e3\") is a number, not a unit\n    if (units && /\\p{L}/u.test(s) && !t && !/^\\s*[+\\u2212-]?[\\d.,]+e[+-]?\\d+\\s*$/i.test(s)) {\n      setUnknownUnit(true);\n      return value;\n    }\n    setUnknownUnit(false);\n    if (t) return toPrecision(t.per === 1 ? t.n : product(t));\n    const n = parseLocaleNumber(s, locale);\n    return n === null ? value : toPrecision(n);\n  };\n  const motion = useMotionTokens(field);\n  // a step rolls the digits: up for more, down for less (typing never rolls)\n  const by = (delta: number) => {\n    setUnknownUnit(false);\n    const before = text;\n    const from = value ?? offer ?? (Number.isFinite(min) ? min : 0);\n    commit(from + delta);\n    const to = clamp(from + delta);\n    if (motion.reduced || to === value) return;\n    const ease = motion.ease.standard;\n    rollText(field.current, before, fmt.format(to), delta > 0 ? 1 : -1, {\n      duration: motion.duration.standard * 1000,\n      // the standard curve as CSS; a curve given as a function has no CSS form and steps evenly\n      easing: cssEase(ease, \"linear\"),\n    });\n  };\n  // taking a conversion rolls the typed \"5 mL\" over to \"5,000\": the field visibly changed the number, not the user\n  const take = (n: number | null) => {\n    const before = text;\n    commit(n);\n    if (n === null || motion.reduced || !typedUnit(before) || typedUnit(before)!.per === 1) return;\n    const to = clamp(n);\n    rollText(field.current, before, fmt.format(to), to >= typedUnit(before)!.n ? 1 : -1, {\n      duration: motion.duration.standard * 1000,\n      easing: cssEase(motion.ease.standard, \"linear\"),\n    });\n  };\n  // a held stepper runs without rolling: the digits change too fast to read as travel\n  const quiet = (delta: number) => {\n    const from = latest.current ?? (Number.isFinite(min) ? min : 0);\n    const to = clamp(from + delta);\n    if (to === latest.current) return false;\n    commit(to);\n    latest.current = to;\n    return true;\n  };\n  const hold = (delta: number, e: ReactPointerEvent<HTMLButtonElement>) => {\n    if (e.button !== 0 || disabled) return;\n    // the field takes (or keeps) focus, so the arrow keys carry on from the press\n    e.preventDefault();\n    field.current?.focus({ preventScroll: true });\n    holding.current?.stop();\n    by(delta);\n    let wait = HOLD_PAUSE;\n    let next = HOLD_FIRST;\n    const stop = () => {\n      window.clearTimeout(holding.current?.timer);\n      holding.current = null;\n      window.removeEventListener(\"pointerup\", stop);\n      window.removeEventListener(\"pointercancel\", stop);\n      window.removeEventListener(\"blur\", stop);\n    };\n    const run = () => {\n      if (!quiet(delta)) return stop();\n      wait = next;\n      next = Math.max(HOLD_FLOOR, next * 0.8);\n      holding.current = { timer: window.setTimeout(run, wait), stop };\n    };\n    holding.current = { timer: window.setTimeout(run, wait), stop };\n    window.addEventListener(\"pointerup\", stop);\n    window.addEventListener(\"pointercancel\", stop);\n    window.addEventListener(\"blur\", stop);\n  };\n  const big = largeStep ?? step * 10;\n  const onKey = (e: KeyboardEvent<HTMLInputElement>) => {\n    const map: Record<string, () => void> = {\n      ArrowUp: () => by(e.shiftKey ? big : step),\n      ArrowDown: () => by(-(e.shiftKey ? big : step)),\n      PageUp: () => by(big),\n      PageDown: () => by(-big),\n      Home: () => {\n        if (Number.isFinite(min)) commit(min);\n      },\n      End: () => {\n        if (Number.isFinite(max)) commit(max);\n      },\n      Enter: () => {\n        setEditing(false);\n        if (suggesting) commit(offer);\n        else take(parse(text));\n      },\n    };\n    const run = map[e.key];\n    if (run) {\n      e.preventDefault();\n      run();\n    }\n  };\n  // the label is a handle on the shared drag (threshold, capture, Escape and a lost pointer put the value back)\n  useDrag(\n    scrubRef,\n    {\n      onPress: () => {\n        if (!scrub || disabled) return false;\n        scrubbing.current = { from: value ?? 0 };\n      },\n      onMove: (p) => {\n        const s = scrubbing.current;\n        if (s) commit(s.from + Math.round(p.dx / 4) * step * (p.shift ? 10 : 1));\n      },\n      onEnd: () => {\n        scrubbing.current = null;\n      },\n      onTap: () => {\n        scrubbing.current = null;\n      },\n      onCancel: () => {\n        const s = scrubbing.current;\n        scrubbing.current = null;\n        if (s) commit(s.from);\n      },\n      onAbandon: () => {\n        scrubbing.current = null;\n      },\n    },\n    { axis: \"x\", disabled: !scrub || disabled },\n  );\n  return (\n    <Field\n      label={\n        scrub ? (\n          // the label is a handle: a sideways arrow arrives beside it with attention (the field hovered or focused),\n          // so dragging is discoverable without a tooltip\n          <span\n            ref={scrubRef}\n            data-slot=\"number-field-scrub\"\n            className={styles.scrub}\n            // a press on the handle neither selects its words nor focuses the field through the label\n            onPointerDown={(e) => e.button === 0 && e.preventDefault()}\n          >\n            {label}\n            <MoveHorizontal aria-hidden className={cn(\"reveal\", styles.scrubMark)} />\n          </span>\n        ) : (\n          label\n        )\n      }\n      hideLabel={hideLabel}\n      description={fieldDescription}\n      error={error}\n      required={required}\n      requiredOnControl\n      controlId={controlId}\n      descriptionId={descriptionId}\n      errorId={errorId}\n      className={cn(scrub && \"reveal-host\", className)}\n      classNames={classNames}\n      style={style}\n    >\n      <FieldFrame\n        ref={frame}\n        classNames={classNames}\n        size={size}\n        invalid={!!error}\n        disabled={disabled}\n        leading={prefix}\n        trailing={\n          <span className=\"flex items-center gap-1\">\n            {converted !== null && (\n              <button\n                type=\"button\"\n                tabIndex={-1}\n                data-slot=\"number-field-convert\"\n                data-beyond={beyond ?? undefined}\n                // \"= 5,000\" is a formula: it reads left to right in every writing direction\n                dir=\"ltr\"\n                aria-label={i18n(\"useConverted\", { value: `${fmt.format(converted)}${own ? ` ${own}` : \"\"}` })}\n                disabled={disabled}\n                onPointerDown={(e) => e.preventDefault()}\n                onClick={() => {\n                  setEditing(false);\n                  take(converted);\n                }}\n                className={cn(styles.use, styles.convert, \"animate-enter-fade\", classNames?.convert)}\n              >\n                <span aria-hidden>{beyond || converted === exact ? \"=\" : \"≈\"}</span>\n                <span className=\"font-numeric tabular-nums\">{loose.format(beyond ? exact! : converted)}</span>\n                {beyond && (\n                  <span data-slot=\"number-field-convert-limit\" className={styles.convertLimit}>\n                    {i18n(beyond === \"max\" ? \"overLimit\" : \"underLimit\", {\n                      limit: fmt.format(beyond === \"max\" ? max : min),\n                    })}\n                  </span>\n                )}\n              </button>\n            )}\n            {suffix && <span className=\"me-1\">{suffix}</span>}\n            {suggesting && (\n              <button\n                type=\"button\"\n                tabIndex={-1}\n                data-slot=\"number-field-use\"\n                aria-label={i18n(\"useTheSuggested\", { value: fmt.format(offer!) })}\n                disabled={disabled}\n                onPointerDown={(e) => e.preventDefault()}\n                onClick={() => commit(offer)}\n                className={cn(styles.use, \"animate-enter-fade\", classNames?.use)}\n              >\n                {i18n(\"use\")}\n              </button>\n            )}\n            {roomy && steppers && (\n              <>\n                <button\n                  type=\"button\"\n                  tabIndex={-1}\n                  data-slot=\"number-field-decrease\"\n                  aria-label={i18n(\"decrease\")}\n                  disabled={disabled || (value ?? -Infinity) <= min}\n                  onPointerDown={(e) => hold(-step, e)}\n                  // a pointer steps on press (and repeats while held); a click without a pointer (assistive tech) steps once\n                  onClick={(e) => e.detail === 0 && by(-step)}\n                  className={cn(styles.stepper, classNames?.decrease)}\n                >\n                  <Minus />\n                </button>\n                <button\n                  type=\"button\"\n                  tabIndex={-1}\n                  data-slot=\"number-field-increase\"\n                  aria-label={i18n(\"increase\")}\n                  disabled={disabled || (value ?? Infinity) >= max}\n                  onPointerDown={(e) => hold(step, e)}\n                  onClick={(e) => e.detail === 0 && by(step)}\n                  className={cn(styles.stepper, classNames?.increase)}\n                >\n                  <Plus />\n                </button>\n              </>\n            )}\n          </span>\n        }\n      >\n        <input\n          ref={attach}\n          data-slot=\"number-field\"\n          {...aria}\n          name={name}\n          required={required}\n          disabled={disabled}\n          inputMode={decimals(step) ? \"decimal\" : \"numeric\"}\n          autoComplete=\"off\"\n          role=\"spinbutton\"\n          aria-valuenow={value ?? undefined}\n          aria-valuemin={Number.isFinite(min) ? min : undefined}\n          aria-valuemax={Number.isFinite(max) ? max : undefined}\n          aria-valuetext={\n            value == null\n              ? undefined\n              : `${typeof prefix === \"string\" ? prefix : \"\"}${fmt.format(value)}${typeof suffix === \"string\" ? ` ${suffix}` : \"\"}`\n          }\n          value={text}\n          placeholder={suggesting ? fmt.format(offer!) : placeholder}\n          data-suggested={suggesting ? \"\" : undefined}\n          aria-description={\n            suggesting ? i18n(\"suggestedEnterUsesIt\", { value: fmt.format(offer!) }) : conversion || undefined\n          }\n          // typed with a unit, the text keeps its own direction (\"5 mL\" in a right-to-left page)\n          dir={units ? \"auto\" : undefined}\n          onChange={(e) => {\n            setEditing(true);\n            setText(e.target.value);\n            setUnknownUnit(false);\n            if (onValueInput) {\n              const typed = readTyped(e.target.value);\n              if (typed !== undefined) onValueInput(typed);\n            }\n          }}\n          onFocus={() => setEditing(true)}\n          onBlur={() => {\n            setEditing(false);\n            take(parse(text));\n          }}\n          onKeyDown={onKey}\n          className={cn(fieldControlClass, \"font-numeric tabular-nums\", classNames?.input)}\n        />\n      </FieldFrame>\n      {/* the conversion is announced as it appears (the description alone is read only on focus) */}\n      {units && (\n        <span className=\"sr-only\" aria-live=\"polite\">\n          {conversion}\n        </span>\n      )}\n    </Field>\n  );\n}\n\nexport default NumberField;\n"},{"path":"beamline/components/radio-group/radio-group.module.css","type":"registry:file","target":"src/ui/beamline/components/radio-group/radio-group.module.css","content":"@layer properties, theme, base, components, utilities;\n@layer components {\n  /* Radio group: a column (or row) of options; the dot grows into the chosen ring. The message line's gap is the\n     group's own (--pui-field-gap), so a problem that arrives or leaves takes its gap with it. */\n  .root {\n    --pui-field-gap: var(--pui-space-2);\n    display: flex;\n    min-width: 0;\n    flex-direction: column;\n    gap: var(--pui-field-gap);\n  }\n  /* options keep their natural width in both arrangements, so a row measures the same as a column (orientation auto) */\n  .group {\n    position: relative;\n    display: flex;\n    flex-direction: column;\n    gap: var(--pui-space-2-5) var(--pui-space-5);\n  }\n  .group[data-orientation-mode=\"auto\"] {\n    align-items: flex-start;\n  }\n  .across {\n    flex-direction: row;\n    flex-wrap: wrap;\n    align-items: flex-start;\n  }\n  .item {\n    display: flex;\n    align-items: flex-start;\n    gap: var(--pui-space-2-5);\n    cursor: pointer;\n  }\n  .item[data-disabled] {\n    cursor: not-allowed;\n    opacity: var(--pui-opacity-disabled);\n  }\n  /* the toggle role paints it: a well with a 3:1 ring that fills when chosen */\n  .dot {\n    --m-color: var(--pui-control-on);\n    --m-toggle-off: var(--pui-field);\n    --m-toggle-off-hover: var(--pui-field);\n    --m-toggle-ring: var(--pui-edge-control);\n    --m-toggle-ring-hover: color-mix(in oklab, var(--pui-edge-control) 60%, var(--pui-ink));\n    flex-shrink: 0;\n    display: grid;\n    place-items: center;\n    width: 16px;\n    height: 16px;\n    margin-top: calc(var(--pui-space-0-5) / 2);\n    border-radius: 50%;\n    cursor: inherit;\n    transition: var(--m-transition);\n  }\n  /* the whole row is the hit area, so pointing anywhere on it lights the ring; a press is acknowledged at once */\n  .item:hover .dot:not(:disabled) {\n    --m-toggle-ring: var(--m-toggle-ring-hover);\n    transition-duration: 0ms;\n  }\n  .item:active .dot:not(:disabled) {\n    scale: var(--pui-press-scale);\n  }\n  .indicator {\n    width: 6px;\n    height: 6px;\n    border-radius: 50%;\n    background: var(--pui-control-glyph);\n    animation: grow var(--pui-duration-fast) var(--pui-ease-enter);\n  }\n  /* the chosen fill as one bead on top of the rings: it leaves the old choice and flows into the new one as matter\n     (radio-group.tsx), carrying its centre dot, so the per-option fill and dot stand aside while it is there */\n  .bead {\n    /* painted exactly as a chosen option is, by the toggle role of the look in force */\n    --m-color: var(--pui-control-on);\n    position: absolute;\n    top: 0;\n    left: 0;\n    z-index: 1;\n    border-radius: 50%;\n    pointer-events: none;\n  }\n  .bead::after {\n    content: \"\";\n    position: absolute;\n    inset: 0;\n    margin: auto;\n    width: 6px;\n    height: 6px;\n    border-radius: 50%;\n    background: var(--pui-control-glyph);\n  }\n  [data-bead] .indicator {\n    visibility: hidden;\n  }\n  [data-bead] .dot[data-state=\"checked\"] {\n    --pui-m-c: var(--m-toggle-off);\n    background: var(--m-inset-shade), var(--pui-m-c);\n    box-shadow:\n      inset 0 0 0 1px var(--m-toggle-ring, transparent),\n      var(--m-inset-edge);\n  }\n  @keyframes grow {\n    from {\n      transform: scale(0.2);\n    }\n    to {\n      transform: scale(1);\n    }\n  }\n}\n/* CSS-module composition only; visual rules stay in the component layer. */\n.dot {\n  composes: m-toggle from global;\n}\n.bead {\n  composes: m-toggle from global;\n}\n"},{"path":"beamline/components/radio-group/radio-group.tsx","type":"registry:file","target":"src/ui/beamline/components/radio-group/radio-group.tsx","content":"\"use client\";\n\nimport { useDeprecatedProp } from \"../../hooks/use-deprecated-prop\";\n\nimport { useId, useMemo, useState, type CSSProperties, type Ref, type ReactNode } from \"react\";\nimport * as RadixRadioGroup from \"@radix-ui/react-radio-group\";\nimport { useScopeDirection } from \"../../hooks/use-scope-direction\";\nimport { useComposedRef } from \"../../hooks/use-composed-ref\";\nimport { useFit } from \"../../hooks/use-fit\";\nimport { useFlip } from \"../../hooks/use-flip\";\nimport { useIndicator } from \"../../hooks/use-indicator\";\nimport { useContour } from \"../../hooks/use-contour\";\nimport { cn } from \"../../lib/utils\";\nimport { FieldMessage } from \"../_shared/field\";\nimport { Label } from \"../label/label\";\nimport styles from \"./radio-group.module.css\";\n\nexport interface RadioOption {\n  /** Value represented by this item. Required. */\n  value: string;\n  /** Text displayed for this item. Required. */\n  label: ReactNode;\n  /** Supporting content describing this item. Omitted by default. */\n  description?: ReactNode;\n  /** Whether this option is unavailable for selection. Omitted by default. */\n  disabled?: boolean;\n}\n\nexport type RadioGroupClassNames = Partial<\n  Record<\n    | \"root\"\n    | \"label\"\n    | \"group\"\n    | \"option\"\n    | \"control\"\n    | \"indicator\"\n    | \"text\"\n    | \"optionLabel\"\n    | \"description\"\n    | \"groupDescription\"\n    | \"error\",\n    string\n  >\n>;\n\nexport interface RadioGroupProps {\n  /** The question the options answer; the group's accessible name. */\n  label: ReactNode;\n  /** Shows the label visually while keeping its accessible name; defaults to true. Takes precedence over hideLabel. */\n  showLabel?: boolean;\n  /** Hides the label; defaults to false. @deprecated Use showLabel={false} instead. */\n  hideLabel?: boolean;\n  /** One line of help under the options (like every field's description). */\n  description?: ReactNode;\n  /** The problem and its fix (a required choice not made); replaces the description and marks the group invalid. */\n  error?: ReactNode;\n  /** Available choices with their labels and values. Required. */\n  options: RadioOption[];\n  /** Controlled value of the chosen option; omit to use defaultValue. */\n  value?: string;\n  /** Initial value of the chosen option when uncontrolled. Defaults to no selected option. */\n  defaultValue?: string;\n  /** Reports value of the chosen option after an edit; no callback by default. */\n  onValueChange?: (value: string) => void;\n  /** vertical (default) or horizontal; auto: a row while every option fits the group's room on one line, a column\n   *  when it does not (the options slide between the two). */\n  orientation?: \"vertical\" | \"horizontal\" | \"auto\";\n  /** Field name used in native form submission. Defaults to no form field name. */\n  name?: string;\n  /** Prevents interaction with the control. Defaults to false. */\n  disabled?: boolean;\n  /** Marks the field as required for form submission. Defaults to false. */\n  required?: boolean;\n  /** Classes on the documented visual root; no override by default. */\n  className?: string;\n  /** Inline styles on the documented visual root; no inline overrides by default. */\n  style?: CSSProperties;\n  /** Receives the documented root element; no ref by default. */\n  ref?: Ref<HTMLDivElement>;\n  /** Reading direction; inherits the surrounding direction when omitted. Defaults to the surrounding reading direction. */\n  dir?: \"ltr\" | \"rtl\";\n  /** Classes for the named visual parts; no part overrides by default. */\n  classNames?: RadioGroupClassNames;\n}\n\n/** One choice from a short, visible set. Arrow keys move and select; Tab leaves the group. */\nexport function RadioGroup({\n  label,\n  hideLabel: hideLabelProp,\n  showLabel,\n  description,\n  error,\n  options,\n  value,\n  defaultValue,\n  onValueChange,\n  orientation = \"vertical\",\n  name,\n  disabled,\n  required,\n  className,\n  classNames,\n  style,\n  ref,\n  dir,\n}: RadioGroupProps) {\n  useDeprecatedProp(\"RadioGroup\", \"hideLabel\", \"showLabel={false}\", hideLabelProp !== undefined);\n  const hideLabel = showLabel === undefined ? hideLabelProp : !showLabel;\n  // one bead of colour travels from the old choice to the new one as matter (ui/lib/contour.ts). It follows the chosen\n  // option's row and sits where that row's dot is: a row's own place is never thrown off by the row sliding (useFlip\n  // moves rows with a transform, which makes a moving row its dot's offset parent), and the dot is found inside it\n  const [dot, setDot] = useState<{ x: number; y: number; w: number; h: number } | null>(null);\n  const [control, row] = useIndicator<HTMLDivElement>(\n    \"[data-slot=radio-option]:has([data-slot=radio-control][data-state=checked])\",\n    undefined,\n    (item) => {\n      const d = item.querySelector<HTMLElement>(\"[data-slot=radio-control]\")?.getBoundingClientRect();\n      const r = item.getBoundingClientRect();\n      if (!d) return;\n      const next = { x: d.left - r.left, y: d.top - r.top, w: d.width, h: d.height };\n      setDot((p) => (p && p.x === next.x && p.y === next.y && p.w === next.w && p.h === next.h ? p : next));\n    },\n  );\n  const chosen = useMemo(\n    () => (row && dot ? { ...row, x: row.x + dot.x, y: row.y + dot.y, w: dot.w, h: dot.h } : null),\n    [row, dot],\n  );\n  const bead = useContour<HTMLSpanElement>(chosen);\n  const [groupRef, direction] = useScopeDirection(useComposedRef(control, ref), dir);\n  // auto: the options are measured once at their natural width and laid out as a row only while all of them fit on one\n  // line of the room; a change between row and column carries each option to its new place\n  const optionSet = options.map((o) => o.value).join(\"\\u0000\");\n  const fits = useFit(control, { items: options.length, lines: 1, enabled: orientation === \"auto\" }, optionSet);\n  const across = orientation === \"horizontal\" || (orientation === \"auto\" && fits >= options.length);\n  useFlip(control, { ghost: false, enter: false });\n  const auto = useId();\n  const labelId = `radio-${auto}-label`;\n  const messageId = error || description ? `radio-${auto}-message` : undefined;\n  return (\n    <div\n      data-slot=\"radio-group\"\n      data-invalid={error ? \"\" : undefined}\n      dir={dir}\n      style={style}\n      className={cn(styles.root, classNames?.root, className)}\n    >\n      {/* the same label (and required marker) every field has; the group itself says \"required\" */}\n      <Label\n        id={labelId}\n        data-slot=\"radio-group-label\"\n        required={required}\n        requiredOnControl\n        className={cn(\"text-label\", hideLabel && \"sr-only\", classNames?.label)}\n      >\n        {label}\n      </Label>\n      <RadixRadioGroup.Root\n        ref={groupRef}\n        dir={direction}\n        data-slot=\"radio-group-control\"\n        aria-labelledby={labelId}\n        aria-describedby={messageId}\n        aria-invalid={error ? true : undefined}\n        value={value}\n        defaultValue={defaultValue}\n        onValueChange={onValueChange}\n        orientation={across ? \"horizontal\" : \"vertical\"}\n        data-orientation-mode={orientation}\n        name={name}\n        disabled={disabled}\n        required={required}\n        data-bead={chosen ? \"\" : undefined}\n        className={cn(styles.group, across && styles.across, classNames?.group)}\n      >\n        {chosen && <span ref={bead} aria-hidden data-slot=\"radio-bead\" data-state=\"checked\" className={styles.bead} />}\n        {options.map((o) => {\n          const id = `radio-${auto}-${o.value}`;\n          return (\n            <label\n              key={o.value}\n              htmlFor={id}\n              data-fit-item\n              data-flip={o.value}\n              data-slot=\"radio-option\"\n              data-disabled={o.disabled || disabled ? \"\" : undefined}\n              className={cn(styles.item, classNames?.option)}\n            >\n              <RadixRadioGroup.Item\n                id={id}\n                value={o.value}\n                disabled={o.disabled}\n                data-slot=\"radio-control\"\n                className={cn(styles.dot, classNames?.control)}\n              >\n                <RadixRadioGroup.Indicator\n                  data-slot=\"radio-indicator\"\n                  className={cn(styles.indicator, classNames?.indicator)}\n                />\n              </RadixRadioGroup.Item>\n              <span data-slot=\"radio-text\" className={cn(\"grid gap-0.5\", classNames?.text)}>\n                <span\n                  data-slot=\"radio-label\"\n                  className={cn(\n                    \"text-sm leading-[var(--pui-leading-body)] font-medium text-ink\",\n                    classNames?.optionLabel,\n                  )}\n                >\n                  {o.label}\n                </span>\n                {o.description && (\n                  <span\n                    data-slot=\"radio-description\"\n                    className={cn(\"text-xs leading-snug text-ink-3\", classNames?.description)}\n                  >\n                    {o.description}\n                  </span>\n                )}\n              </span>\n            </label>\n          );\n        })}\n      </RadixRadioGroup.Root>\n      <FieldMessage\n        error={error}\n        description={description}\n        errorId={messageId}\n        descriptionId={messageId}\n        classNames={{ error: classNames?.error, description: classNames?.groupDescription }}\n      />\n    </div>\n  );\n}\n\nexport default RadioGroup;\n"},{"path":"beamline/components/recurrence-editor/messages.ts","type":"registry:file","target":"src/ui/beamline/components/recurrence-editor/messages.ts","content":"import type { MessageDefinitions } from \"../../runtime/messages\";\n/** Built-in English defaults; instance labels take precedence. */\nexport const english = {\n  moreOccurrences: \"and {count} more\",\n  timesUnit: { one: \"time\", other: \"times\" },\n  endCount: { one: \", once\", other: \", {count} times\" },\n  repeats: \"Repeats\",\n  every: \"Every\",\n  everyHowMany: \"Every how many {value}\",\n  on: \"On\",\n  day: \"Day {value}\",\n  the: \"The {value} {value2}\",\n  monthsWithoutAAreSkippedForThe:\n    \"Months without a {value} are skipped. For the end of every month, choose the last weekday or day 28.\",\n  ends: \"Ends\",\n  never: \"Never\",\n  onADate: \"On a date\",\n  after: \"After\",\n  endDate: \"End date\",\n  theEndIsBeforeTheFirstDate: \"The end is before the first date.\",\n  times: \"Times\",\n  time: \"time\",\n  times2: \"times\",\n  nextDates: \"Next dates\",\n  and: \"and\",\n  more: \"more\",\n  noDatesTheEndIsBeforeThe: \"No dates: the end is before the first date.\",\n  monday: \"Monday\",\n  tuesday: \"Tuesday\",\n  wednesday: \"Wednesday\",\n  thursday: \"Thursday\",\n  friday: \"Friday\",\n  saturday: \"Saturday\",\n  sunday: \"Sunday\",\n  every2: \"Every {value}\",\n  every3: \"Every {interval} {value}\",\n  everyDay: \"Every day\",\n  everyWeekday: \"Every weekday\",\n  onThe: \"{every} on the {value}\",\n  on2: \"{every} on {value}\",\n  until: \", until {value}\",\n  once: \", once\",\n  times3: \", {count} times\",\n  first: \"first\",\n  second: \"second\",\n  third: \"third\",\n  fourth: \"fourth\",\n  last: \"last\",\n  ordinalOne: \"{number}st\",\n  ordinalTwo: \"{number}nd\",\n  ordinalFew: \"{number}rd\",\n  ordinalOther: \"{number}th\",\n  everyDays: {\n    one: \"Every day\",\n    other: \"Every {count} days\",\n  },\n  howManyDays: \"Every how many days\",\n  dayUnit: {\n    one: \"day\",\n    other: \"days\",\n  },\n  everyWeeks: {\n    one: \"Every week\",\n    other: \"Every {count} weeks\",\n  },\n  howManyWeeks: \"Every how many weeks\",\n  weekUnit: {\n    one: \"week\",\n    other: \"weeks\",\n  },\n  everyMonths: {\n    one: \"Every month\",\n    other: \"Every {count} months\",\n  },\n  howManyMonths: \"Every how many months\",\n  monthUnit: {\n    one: \"month\",\n    other: \"months\",\n  },\n  everyYears: {\n    one: \"Every year\",\n    other: \"Every {count} years\",\n  },\n  howManyYears: \"Every how many years\",\n  yearUnit: {\n    one: \"year\",\n    other: \"years\",\n  },\n  dailyFrequency: \"Daily\",\n  weeklyFrequency: \"Weekly\",\n  monthlyFrequency: \"Monthly\",\n  yearlyFrequency: \"Yearly\",\n} satisfies MessageDefinitions;\n"},{"path":"beamline/components/recurrence-editor/recurrence-editor.module.css","type":"registry:file","target":"src/ui/beamline/components/recurrence-editor/recurrence-editor.module.css","content":"@layer properties, theme, base, components, utilities;\n@layer components {\n  .root {\n    container-type: inline-size;\n    display: grid;\n    gap: var(--pui-space-4);\n    min-width: min(17rem, 100%);\n  }\n  .root[data-disabled] {\n    opacity: 0.6;\n  }\n  .summary {\n    display: flex;\n    align-items: flex-start;\n    gap: var(--pui-space-2);\n    color: var(--pui-ink);\n    font-size: var(--pui-text-base);\n    font-weight: var(--pui-weight-medium);\n    line-height: 1.4;\n  }\n  .summary > :where(svg) {\n    width: 1.125rem;\n    height: 1.125rem;\n    flex: none;\n    margin-top: 0.0625rem;\n    color: var(--pui-accent-ink);\n  }\n  .sentence {\n    min-width: 0;\n    animation: arrive var(--pui-duration-standard) var(--pui-ease-enter);\n  }\n  .frequency {\n    display: grid;\n  }\n  .body {\n    display: grid;\n    gap: var(--pui-space-4);\n  }\n  .interval {\n    display: flex;\n    align-items: center;\n    gap: var(--pui-space-2);\n  }\n  .word {\n    color: var(--pui-ink-2);\n    font-size: var(--pui-text-sm);\n  }\n  .count {\n    width: 6.5rem;\n  }\n  .section {\n    display: grid;\n    gap: var(--pui-space-2);\n    animation: arrive var(--pui-duration-standard) var(--pui-ease-enter);\n  }\n  .sectionLabel {\n    color: var(--pui-ink-2);\n    font-size: var(--pui-text-sm);\n    font-weight: var(--pui-weight-medium);\n  }\n  .days {\n    flex-wrap: wrap;\n  }\n  .endField {\n    max-width: 14rem;\n    animation: arrive var(--pui-duration-standard) var(--pui-ease-enter);\n  }\n  .note {\n    display: flex;\n    gap: var(--pui-space-1-5);\n    color: var(--pui-ink-2);\n    font-size: var(--pui-text-xs);\n    line-height: 1.45;\n  }\n  .note :where(svg) {\n    width: 0.875rem;\n    height: 0.875rem;\n    flex: none;\n    margin-top: 0.125rem;\n    color: var(--pui-blue);\n  }\n  .next {\n    display: grid;\n    gap: var(--pui-space-2);\n    padding: var(--pui-space-3);\n    border-radius: var(--pui-radius-card);\n  }\n  .dates {\n    display: grid;\n    gap: var(--pui-space-1);\n    color: var(--pui-ink);\n    font-size: var(--pui-text-sm);\n    font-variant-numeric: tabular-nums;\n  }\n  .dates > li {\n    display: flex;\n    align-items: center;\n    gap: var(--pui-space-2);\n  }\n  .dates > li::before {\n    width: 0.375rem;\n    height: 0.375rem;\n    flex: none;\n    border-radius: var(--pui-radius-pill);\n    background: var(--pui-accent);\n    content: \"\";\n  }\n  .dates > li.more {\n    color: var(--pui-ink-3);\n  }\n  .dates > li.more::before {\n    background: var(--pui-line-strong);\n  }\n  .none {\n    color: var(--pui-ink-3);\n    font-size: var(--pui-text-sm);\n  }\n  @container (min-width: 40rem) {\n    .root {\n      grid-template-columns: minmax(0, 1fr) 15rem;\n      align-items: start;\n    }\n    .summary,\n    .frequency {\n      grid-column: 1 / -1;\n    }\n    .next {\n      grid-column: 2;\n      grid-row: 3;\n    }\n  }\n  @keyframes arrive {\n    from {\n      opacity: 0;\n    }\n  }\n}\n"},{"path":"beamline/components/recurrence-editor/recurrence-editor.tsx","type":"registry:file","target":"src/ui/beamline/components/recurrence-editor/recurrence-editor.tsx","content":"\"use client\";\nimport { createTranslator } from \"../../runtime/messages\";\nimport { type Translator } from \"../../runtime/messages\";\nimport { dateFormatter, useMessages } from \"../../runtime/localization\";\nimport { english as englishMessages } from \"./messages\";\nimport { useLocale, resolveLocale } from \"../../runtime/localization\";\n\nimport { useId, useMemo, useRef, type CSSProperties, type Ref } from \"react\";\nimport { CalendarClock, Info } from \"lucide-react\";\nimport { DatePicker } from \"../date-picker/date-picker\";\nimport { NumberField } from \"../number-field/number-field\";\nimport { RadioGroup } from \"../radio-group/radio-group\";\nimport { SegmentedControl } from \"../segmented-control/segmented-control\";\nimport { ToggleGroup, ToggleGroupItem } from \"../toggle-group/toggle-group\";\nimport { useComposedRef } from \"../../hooks/use-composed-ref\";\nimport { useFlip } from \"../../hooks/use-flip\";\nimport { useHeightMorph } from \"../../hooks/use-height-morph\";\nimport { cn } from \"../../lib/utils\";\nimport { useControllable } from \"../../hooks/use-controllable\";\nimport styles from \"./recurrence-editor.module.css\";\n\nexport type RecurrenceFrequency = \"daily\" | \"weekly\" | \"monthly\" | \"yearly\";\nexport type Weekday = \"MO\" | \"TU\" | \"WE\" | \"TH\" | \"FR\" | \"SA\" | \"SU\";\nexport type RecurrenceEnd = { type: \"never\" } | { type: \"until\"; date: string } | { type: \"count\"; count: number };\nexport interface Recurrence {\n  freq: RecurrenceFrequency;\n  /** Every n days, weeks, months or years. */\n  interval: number;\n  /** Weekly: the days it happens on. */\n  byDay?: Weekday[];\n  /** Monthly: on a date, or on the nth weekday (-1: the last). */\n  monthly?: { mode: \"day\"; day: number } | { mode: \"weekday\"; nth: 1 | 2 | 3 | 4 | -1; day: Weekday };\n  end: RecurrenceEnd;\n}\n\nexport type RecurrenceEditorClassNames = Partial<\n  Record<\"root\" | \"summary\" | \"frequency\" | \"interval\" | \"weekdays\" | \"monthly\" | \"end\" | \"note\" | \"next\", string>\n>;\n\nexport interface RecurrenceEditorProps {\n  /** The first time it happens; defaults (weekday, day of month) are read from it. */\n  start: Date;\n  value?: Recurrence;\n  defaultValue?: Recurrence;\n  onValueChange?: (value: Recurrence) => void;\n  /** How many next dates to list. Default 5; 0 hides the list. */\n  preview?: number;\n  frequencies?: RecurrenceFrequency[];\n  /** Order of the weekday toggles. Default 1 (Monday). */\n  weekStartsOn?: 0 | 1;\n  locale?: string;\n  disabled?: boolean;\n  className?: string;\n  classNames?: RecurrenceEditorClassNames;\n  style?: CSSProperties;\n  ref?: Ref<HTMLDivElement>;\n}\n\nconst DAYS: Weekday[] = [\"SU\", \"MO\", \"TU\", \"WE\", \"TH\", \"FR\", \"SA\"];\nfunction localizedDAY_NAME(i18n: Translator<typeof englishMessages>): Record<Weekday, string> {\n  return {\n    MO: i18n(\"monday\"),\n    TU: i18n(\"tuesday\"),\n    WE: i18n(\"wednesday\"),\n    TH: i18n(\"thursday\"),\n    FR: i18n(\"friday\"),\n    SA: i18n(\"saturday\"),\n    SU: i18n(\"sunday\"),\n  };\n}\nconst NTH = { \"1\": \"first\", \"2\": \"second\", \"3\": \"third\", \"4\": \"fourth\", \"-1\": \"last\" } as const;\nconst UNIT = { daily: \"dayUnit\", weekly: \"weekUnit\", monthly: \"monthUnit\", yearly: \"yearUnit\" } as const;\nconst pad = (n: number) => String(n).padStart(2, \"0\");\nconst iso = (d: Date) => `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;\nconst fromIso = (s: string) => {\n  const [y, m, d] = s.split(\"-\").map(Number);\n  return new Date(y, m - 1, d);\n};\nconst ordinal = (n: number, i18n: Translator<typeof englishMessages>) => {\n  const category = new Intl.PluralRules(i18n.locale, { type: \"ordinal\" }).select(n);\n  const keys = {\n    one: \"ordinalOne\",\n    two: \"ordinalTwo\",\n    few: \"ordinalFew\",\n    other: \"ordinalOther\",\n    zero: \"ordinalOther\",\n    many: \"ordinalOther\",\n  } as const;\n  return i18n(keys[category], { number: n });\n};\nconst weekdayOf = (d: Date) => DAYS[d.getDay()];\n/** Which occurrence of its weekday a date is in its month: 1–4, or -1 when it is the last (a fifth is always last). */\nconst nthOf = (d: Date): 1 | 2 | 3 | 4 | -1 => {\n  const n = Math.ceil(d.getDate() / 7);\n  return n >= 5 ? -1 : (n as 1 | 2 | 3 | 4);\n};\n\n/** The default rule for a start date: weekly on its weekday, never ending. */\nexport function defaultRecurrence(start: Date): Recurrence {\n  return { freq: \"weekly\", interval: 1, byDay: [weekdayOf(start)], end: { type: \"never\" } };\n}\n\n/** The rule as an RFC 5545 RRULE value (without the \"RRULE:\" prefix). */\nexport function toRRule(r: Recurrence): string {\n  const parts = [`FREQ=${r.freq.toUpperCase()}`];\n  if (r.interval > 1) parts.push(`INTERVAL=${r.interval}`);\n  if (r.freq === \"weekly\" && r.byDay?.length) parts.push(`BYDAY=${r.byDay.join(\",\")}`);\n  if (r.freq === \"monthly\" && r.monthly)\n    parts.push(r.monthly.mode === \"day\" ? `BYMONTHDAY=${r.monthly.day}` : `BYDAY=${r.monthly.nth}${r.monthly.day}`);\n  if (r.end.type === \"until\") parts.push(`UNTIL=${r.end.date.replace(/-/g, \"\")}`);\n  if (r.end.type === \"count\") parts.push(`COUNT=${r.end.count}`);\n  return parts.join(\";\");\n}\n\n/** The rule in one plain sentence. */\nexport function describeRecurrence(\n  r: Recurrence,\n  start: Date,\n  locale = resolveLocale(),\n  i18n: Translator<typeof englishMessages> = createTranslator(\"recurrence-editor\", englishMessages, { locale }),\n): string {\n  const everyKeys = { daily: \"everyDays\", weekly: \"everyWeeks\", monthly: \"everyMonths\", yearly: \"everyYears\" } as const;\n  const every = i18n(everyKeys[r.freq], { count: r.interval });\n  let s = every;\n  if (r.freq === \"daily\" && r.interval === 1) s = i18n(\"everyDay\");\n  if (r.freq === \"weekly\") {\n    const days = DAYS.filter((d) => (r.byDay ?? [weekdayOf(start)]).includes(d));\n    const ordered = [...days.filter((d) => d !== \"SU\"), ...days.filter((d) => d === \"SU\")];\n    const weekdays = ordered.length === 5 && !ordered.includes(\"SA\") && !ordered.includes(\"SU\");\n    s =\n      weekdays && r.interval === 1\n        ? i18n(\"everyWeekday\")\n        : ordered.length === 7 && r.interval === 1\n          ? i18n(\"everyDay\")\n          : i18n(\"on2\", { every: every, value: i18n.list(ordered.map((d) => localizedDAY_NAME(i18n)[d])) });\n  }\n  if (r.freq === \"monthly\") {\n    const m = r.monthly ?? { mode: \"day\", day: start.getDate() };\n    s = i18n(\"onThe\", {\n      every: every,\n      value:\n        m.mode === \"day\"\n          ? ordinal(m.day, i18n)\n          : `${i18n(NTH[String(m.nth) as keyof typeof NTH])} ${localizedDAY_NAME(i18n)[m.day]}`,\n    });\n  }\n  if (r.freq === \"yearly\")\n    s = i18n(\"on2\", {\n      every: every,\n      value: dateFormatter(locale, { month: \"long\", day: \"numeric\" }).format(start),\n    });\n  if (r.end.type === \"until\")\n    s += i18n(\"until\", {\n      value: dateFormatter(locale, { day: \"numeric\", month: \"short\", year: \"numeric\" }).format(fromIso(r.end.date)),\n    });\n  if (r.end.type === \"count\") s += i18n(\"endCount\", { count: r.end.count });\n  return s;\n}\n\n/** The first `n` dates the rule gives from `start` (start itself counts when it matches). */\nexport function occurrences(r: Recurrence, start: Date, n: number): Date[] {\n  const out: Date[] = [];\n  const s0 = new Date(start.getFullYear(), start.getMonth(), start.getDate());\n  const until = r.end.type === \"until\" ? fromIso(r.end.date) : null;\n  const max = r.end.type === \"count\" ? Math.min(n, r.end.count) : n;\n  const push = (d: Date) => {\n    if (d < s0 || (until && d > until) || out.length >= max) return false;\n    out.push(d);\n    return true;\n  };\n  const step = Math.max(1, Math.floor(r.interval) || 1);\n  for (let k = 0, guard = 0; out.length < max && guard < 2000; k++, guard++) {\n    if (r.freq === \"daily\") {\n      const d = new Date(s0);\n      d.setDate(d.getDate() + k * step);\n      if (until && d > until) break;\n      push(d);\n    } else if (r.freq === \"weekly\") {\n      // weeks counted from the start's week (weeks start on Monday, as RFC 5545's default WKST)\n      const monday = new Date(s0);\n      monday.setDate(monday.getDate() - ((monday.getDay() + 6) % 7) + k * step * 7);\n      if (until && monday > until) break;\n      const days = r.byDay?.length ? r.byDay : [weekdayOf(start)];\n      for (let i = 0; i < 7; i++) {\n        const d = new Date(monday);\n        d.setDate(monday.getDate() + i);\n        if (days.includes(weekdayOf(d))) push(d);\n      }\n    } else if (r.freq === \"monthly\") {\n      const first = new Date(s0.getFullYear(), s0.getMonth() + k * step, 1);\n      if (until && first > until) break;\n      const m = r.monthly ?? { mode: \"day\" as const, day: s0.getDate() };\n      if (m.mode === \"day\") {\n        const last = new Date(first.getFullYear(), first.getMonth() + 1, 0).getDate();\n        if (m.day <= last) push(new Date(first.getFullYear(), first.getMonth(), m.day)); // a month without it is skipped\n      } else {\n        const want = DAYS.indexOf(m.day);\n        if (m.nth === -1) {\n          const d = new Date(first.getFullYear(), first.getMonth() + 1, 0);\n          while (d.getDay() !== want) d.setDate(d.getDate() - 1);\n          push(d);\n        } else {\n          const d = new Date(first);\n          while (d.getDay() !== want) d.setDate(d.getDate() + 1);\n          d.setDate(d.getDate() + (m.nth - 1) * 7);\n          push(d);\n        }\n      }\n    } else {\n      const y = s0.getFullYear() + k * step;\n      if (until && new Date(y, 0, 1) > until) break;\n      const d = new Date(y, s0.getMonth(), s0.getDate());\n      if (d.getMonth() === s0.getMonth()) push(d); // 29 February only in leap years\n    }\n  }\n  return out;\n}\n\n/**\n * How something repeats, in plain controls and said back in a sentence, with the next dates to check it against and\n * the rule as a value and an RRULE (toRRule). Controls for one frequency grow in as it is chosen.\n */\nexport function RecurrenceEditor({\n  start,\n  value: valueProp,\n  defaultValue,\n  onValueChange,\n  preview = 5,\n  frequencies = [\"daily\", \"weekly\", \"monthly\", \"yearly\"],\n  weekStartsOn = 1,\n  locale: localeProp,\n  disabled,\n  className,\n  classNames,\n  style,\n  ref,\n}: RecurrenceEditorProps) {\n  const i18n = useMessages(\"recurrence-editor\", englishMessages);\n\n  const locale = useLocale(localeProp);\n\n  const [r, setValue] = useControllable<Recurrence>(\n    valueProp,\n    () => defaultValue ?? defaultRecurrence(start),\n    onValueChange,\n  );\n  const onId = useId();\n  const set = (patch: Partial<Recurrence>) => setValue({ ...r, ...patch });\n\n  const root = useRef<HTMLDivElement>(null);\n  const attach = useComposedRef(root, ref);\n  const body = useRef<HTMLDivElement>(null);\n  useHeightMorph(body, `${r.freq}|${r.end.type}`);\n  const nextList = useRef<HTMLOListElement>(null);\n  useFlip(nextList);\n\n  const chooseFreq = (freq: RecurrenceFrequency) => {\n    const next: Recurrence = { ...r, freq };\n    if (freq === \"weekly\" && !r.byDay?.length) next.byDay = [weekdayOf(start)];\n    if (freq === \"monthly\" && !r.monthly) next.monthly = { mode: \"day\", day: start.getDate() };\n    setValue(next);\n  };\n\n  const order = weekStartsOn === 1 ? [...DAYS.slice(1), DAYS[0]] : DAYS;\n  const short = dateFormatter(locale, { weekday: \"short\" });\n  const dayLabel = (d: Weekday) => short.format(new Date(2024, 0, 7 + DAYS.indexOf(d))); // 7 Jan 2024 is a Sunday\n  const startDay = weekdayOf(start);\n  const nth = nthOf(start);\n  const monthly = r.monthly ?? { mode: \"day\" as const, day: start.getDate() };\n\n  const until = r.end.type === \"until\" ? fromIso(r.end.date) : null;\n  const endBeforeStart = !!until && until < new Date(start.getFullYear(), start.getMonth(), start.getDate());\n  const sentence = describeRecurrence(r, start, locale, i18n);\n  const dates = useMemo(\n    () => (preview && !endBeforeStart ? occurrences(r, start, preview) : []),\n    [r, start, preview, endBeforeStart],\n  );\n  const skipped = r.freq === \"monthly\" && monthly.mode === \"day\" && monthly.day > 28;\n  const longDate = dateFormatter(locale, {\n    weekday: \"short\",\n    day: \"numeric\",\n    month: \"short\",\n    year: \"numeric\",\n  });\n\n  return (\n    <div\n      ref={attach}\n      data-slot=\"recurrence-editor\"\n      data-freq={r.freq}\n      data-disabled={disabled ? \"\" : undefined}\n      style={style}\n      className={cn(styles.root, classNames?.root, className)}\n    >\n      <p\n        data-slot=\"recurrence-editor-summary\"\n        role=\"status\"\n        aria-live=\"polite\"\n        className={cn(styles.summary, classNames?.summary)}\n      >\n        <CalendarClock aria-hidden />\n        {/* a sentence that wraps: the new one fades in where the old one was */}\n        <span key={sentence} className={styles.sentence}>\n          {sentence}\n        </span>\n      </p>\n\n      <div data-slot=\"recurrence-editor-frequency\" className={cn(styles.frequency, classNames?.frequency)}>\n        <SegmentedControl\n          label={i18n(\"repeats\")}\n          hideLabel\n          value={r.freq}\n          onValueChange={(v) => chooseFreq(v as RecurrenceFrequency)}\n          options={frequencies.map((f) => ({\n            value: f,\n            label: i18n(\n              (\n                {\n                  daily: \"dailyFrequency\",\n                  weekly: \"weeklyFrequency\",\n                  monthly: \"monthlyFrequency\",\n                  yearly: \"yearlyFrequency\",\n                } as const\n              )[f],\n            ),\n            disabled,\n          }))}\n        />\n      </div>\n\n      <div ref={body} className={styles.body}>\n        <div data-slot=\"recurrence-editor-interval\" className={cn(styles.interval, classNames?.interval)}>\n          <span className={styles.word}>{i18n(\"every\")}</span>\n          <NumberField\n            label={i18n(\n              (\n                {\n                  daily: \"howManyDays\",\n                  weekly: \"howManyWeeks\",\n                  monthly: \"howManyMonths\",\n                  yearly: \"howManyYears\",\n                } as const\n              )[r.freq],\n            )}\n            hideLabel\n            size=\"sm\"\n            min={1}\n            max={r.freq === \"daily\" ? 365 : r.freq === \"weekly\" ? 52 : r.freq === \"monthly\" ? 24 : 10}\n            value={r.interval}\n            onValueChange={(v) => set({ interval: Math.max(1, Math.round(v ?? 1)) })}\n            disabled={disabled}\n            className={styles.count}\n          />\n          <span className={styles.word}>{i18n(UNIT[r.freq], { count: r.interval })}</span>\n        </div>\n\n        {r.freq === \"weekly\" && (\n          <div data-slot=\"recurrence-editor-weekdays\" className={cn(styles.section, classNames?.weekdays)}>\n            <span className={styles.sectionLabel} id={onId}>\n              {i18n(\"on\")}\n            </span>\n            <ToggleGroup\n              type=\"multiple\"\n              variant=\"outline\"\n              size=\"sm\"\n              aria-labelledby={onId}\n              value={r.byDay ?? [startDay]}\n              // at least one day stays on: the last one cannot be turned off\n              onValueChange={(v: string[]) => v.length && set({ byDay: DAYS.filter((d) => v.includes(d)) })}\n              disabled={disabled}\n              className={styles.days}\n            >\n              {order.map((d) => (\n                <ToggleGroupItem key={d} value={d} aria-label={localizedDAY_NAME(i18n)[d]}>\n                  {dayLabel(d)}\n                </ToggleGroupItem>\n              ))}\n            </ToggleGroup>\n          </div>\n        )}\n\n        {r.freq === \"monthly\" && (\n          <div data-slot=\"recurrence-editor-monthly\" className={cn(styles.section, classNames?.monthly)}>\n            <RadioGroup\n              label={i18n(\"on\")}\n              value={monthly.mode}\n              onValueChange={(m) =>\n                set({\n                  monthly:\n                    m === \"day\" ? { mode: \"day\", day: start.getDate() } : { mode: \"weekday\", nth, day: startDay },\n                })\n              }\n              disabled={disabled}\n              options={[\n                { value: \"day\", label: i18n(\"day\", { value: start.getDate() }) },\n                {\n                  value: \"weekday\",\n                  label: i18n(\"the\", {\n                    value: i18n(NTH[String(nth) as keyof typeof NTH]),\n                    value2: localizedDAY_NAME(i18n)[startDay],\n                  }),\n                },\n              ]}\n            />\n            {skipped && (\n              <p data-slot=\"recurrence-editor-note\" className={cn(styles.note, classNames?.note)}>\n                <Info aria-hidden />\n                {i18n(\"monthsWithoutAAreSkippedForThe\", { value: ordinal(monthly.day, i18n) })}\n              </p>\n            )}\n          </div>\n        )}\n\n        <div data-slot=\"recurrence-editor-end\" className={cn(styles.section, classNames?.end)}>\n          <RadioGroup\n            label={i18n(\"ends\")}\n            orientation=\"horizontal\"\n            value={r.end.type}\n            onValueChange={(t) => {\n              if (t === \"never\") set({ end: { type: \"never\" } });\n              else if (t === \"count\") set({ end: { type: \"count\", count: r.end.type === \"count\" ? r.end.count : 10 } });\n              else {\n                const d = new Date(start);\n                d.setMonth(d.getMonth() + 3);\n                set({ end: { type: \"until\", date: r.end.type === \"until\" ? r.end.date : iso(d) } });\n              }\n            }}\n            disabled={disabled}\n            options={[\n              { value: \"never\", label: i18n(\"never\") },\n              { value: \"until\", label: i18n(\"onADate\") },\n              { value: \"count\", label: i18n(\"after\") },\n            ]}\n          />\n          {r.end.type === \"until\" && (\n            <DatePicker\n              label={i18n(\"endDate\")}\n              hideLabel\n              size=\"sm\"\n              value={fromIso(r.end.date)}\n              onValueChange={(d) => d && set({ end: { type: \"until\", date: iso(d) } })}\n              minDate={start}\n              error={endBeforeStart ? i18n(\"theEndIsBeforeTheFirstDate\") : undefined}\n              disabled={disabled}\n              className={styles.endField}\n            />\n          )}\n          {r.end.type === \"count\" && (\n            <NumberField\n              label={i18n(\"times\")}\n              hideLabel\n              size=\"sm\"\n              min={1}\n              max={999}\n              value={r.end.count}\n              onValueChange={(v) => set({ end: { type: \"count\", count: Math.max(1, Math.round(v ?? 1)) } })}\n              suffix={i18n(\"timesUnit\", { count: r.end.count })}\n              disabled={disabled}\n              className={styles.endField}\n            />\n          )}\n        </div>\n      </div>\n\n      {preview > 0 && (\n        <div data-slot=\"recurrence-editor-next\" className={cn(\"m-inset\", styles.next, classNames?.next)}>\n          <span className={styles.sectionLabel}>{i18n(\"nextDates\")}</span>\n          {dates.length ? (\n            <ol ref={nextList} className={styles.dates}>\n              {dates.map((d) => (\n                <li key={iso(d)} data-flip={iso(d)}>\n                  <time dateTime={iso(d)}>{longDate.format(d)}</time>\n                </li>\n              ))}\n              {r.end.type === \"count\" && r.end.count > preview && (\n                <li data-flip=\"more\" className={styles.more}>\n                  {i18n(\"moreOccurrences\", { count: r.end.count - preview })}\n                </li>\n              )}\n            </ol>\n          ) : (\n            <p className={styles.none}>{i18n(\"noDatesTheEndIsBeforeThe\")}</p>\n          )}\n        </div>\n      )}\n    </div>\n  );\n}\n\nexport default RecurrenceEditor;\n"},{"path":"beamline/components/segmented-control/defaults.ts","type":"registry:file","target":"src/ui/beamline/components/segmented-control/defaults.ts","content":"/** Pure allowed presentation defaults for SegmentedControl; no component or runtime imports. */\nexport interface SegmentedControlDefaults {\n  /** Shared size setting; omit to inherit the surrounding scope or the component default. */\n  size?: \"sm\" | \"md\";\n}\n"},{"path":"beamline/components/segmented-control/messages.ts","type":"registry:file","target":"src/ui/beamline/components/segmented-control/messages.ts","content":"import type { MessageDefinitions } from \"../../runtime/messages\";\n/** Built-in English copy; stable keys are the public translation API. */\nexport const english = {\n  chooseOne: \"Choose one\",\n} satisfies MessageDefinitions;\n"},{"path":"beamline/components/segmented-control/segmented-control.module.css","type":"registry:file","target":"src/ui/beamline/components/segmented-control/segmented-control.module.css","content":"@layer properties, theme, base, components, utilities;\n@layer components {\n  /* Segmented control: a well (the inset role of the look in force) with one raised thumb (the control role) that\n   slides to the chosen segment. The segments themselves are transparent text buttons on top. */\n  .root {\n    --pui-segment-height: 32px;\n    --pui-segment-pad: 12px;\n    position: relative;\n    isolation: isolate;\n    display: inline-flex;\n    align-items: center;\n    gap: var(--pui-space-0-5);\n    /* the well's inset is size, not spacing: a control keeps its height when the Spacing parameter changes (O1 §14.2) */\n    padding: var(--pui-size-0-5, 0.125rem);\n    border-radius: var(--pui-radius-control);\n    /* never wider than its room: what does not fit folds (segmented-control.tsx tries full, compact, icons, scroll) */\n    max-width: 100%;\n    min-width: 0;\n  }\n  .fill {\n    display: flex;\n    width: 100%;\n  }\n  /* As a form field the well carries the field's 1px ring (3:1 in every look), so an unanswered choice reads as a\n     control beside the inputs, and turns red with the field's error like they do. */\n  .root[data-field] {\n    box-shadow:\n      inset 0 0 0 1px var(--m-field-ring),\n      var(--m-inset-edge, 0 0 transparent);\n  }\n  .root[data-field][aria-invalid=\"true\"] {\n    box-shadow:\n      inset 0 0 0 1px var(--pui-red),\n      var(--m-inset-edge, 0 0 transparent);\n  }\n  .sm {\n    --pui-segment-height: 28px;\n    --pui-segment-pad: 10px;\n  }\n\n  /* placed and moved by the contour engine (ui/lib/contour.ts), which sets its box and, while it travels, its outline */\n  .thumb {\n    position: absolute;\n    z-index: -1;\n    top: 0;\n    left: 0;\n    border-radius: calc(var(--pui-radius-control) - 2px);\n  }\n\n  .segment {\n    position: relative;\n    flex-shrink: 0;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    gap: var(--pui-space-1-5);\n    height: var(--pui-segment-height);\n    padding-inline: var(--pui-segment-pad);\n    border-radius: calc(var(--pui-radius-control) - 2px);\n    color: var(--pui-ink-3);\n    font-size: var(--pui-text-sm);\n    font-weight: var(--pui-weight-medium);\n    white-space: nowrap;\n    transition:\n      color var(--pui-motion-out) var(--pui-ease-default),\n      scale var(--pui-motion-out) var(--pui-ease-default);\n  }\n  .sm .segment {\n    font-size: var(--pui-text-xs);\n  }\n  .fill .segment {\n    flex: 1;\n  }\n  /* compact: tighter segments, and accessories (a \"New\" badge) fold first */\n  .root[data-fold=\"compact\"],\n  .root[data-fold=\"words\"],\n  .root[data-fold=\"icons\"],\n  .root[data-fold=\"scroll\"] {\n    --pui-segment-pad: var(--pui-space-2);\n  }\n  .sm[data-fold=\"compact\"],\n  .sm[data-fold=\"words\"],\n  .sm[data-fold=\"icons\"],\n  .sm[data-fold=\"scroll\"] {\n    --pui-segment-pad: var(--pui-space-1-5);\n  }\n  .root:is([data-fold=\"compact\"], [data-fold=\"words\"], [data-fold=\"icons\"], [data-fold=\"scroll\"]) .accessory {\n    display: none;\n  }\n  /* words: the icons give way before the words, which carry the meaning (an icon is the segment's one unnamed part) */\n  .root[data-fold=\"words\"] .segment > :not([data-slot]) {\n    display: none;\n  }\n  /* icons: each segment a square; its words stay as its name for assistive tech and its tooltip */\n  .root[data-fold=\"icons\"] .segment {\n    width: var(--pui-segment-height);\n    padding-inline: 0;\n  }\n  .root[data-fold=\"icons\"] .label {\n    position: absolute;\n    width: 1px;\n    height: 1px;\n    overflow: hidden;\n    clip-path: inset(50%);\n    white-space: nowrap;\n  }\n  /* scroll: the row scrolls under soft edges (no bar), and the choice is kept in view; only an edge with more past it\n     fades (data-edge, kept by segmented-control.tsx), so the row says which way the rest lies */\n  .root[data-fold=\"scroll\"] {\n    --_fade-start: 0px;\n    --_fade-end: 0px;\n    overflow-x: auto;\n    overscroll-behavior-x: contain;\n    scrollbar-width: none; /* organism-allow: paint-recipe-copy -- a state selector cannot compose */\n    mask-image: linear-gradient(\n      to right,\n      transparent,\n      currentColor var(--_fade-start),\n      currentColor calc(100% - var(--_fade-end)),\n      transparent\n    );\n  }\n  .root[data-fold=\"scroll\"][data-edge~=\"start\"] {\n    --_fade-start: var(--pui-space-6);\n  }\n  .root[data-fold=\"scroll\"][data-edge~=\"end\"] {\n    --_fade-end: var(--pui-space-6);\n  }\n  .root[data-fold=\"scroll\"]:dir(rtl) {\n    --_fade-start: 0px;\n    --_fade-end: 0px;\n  }\n  .root[data-fold=\"scroll\"]:dir(rtl)[data-edge~=\"start\"] {\n    --_fade-end: var(--pui-space-6);\n  }\n  .root[data-fold=\"scroll\"]:dir(rtl)[data-edge~=\"end\"] {\n    --_fade-start: var(--pui-space-6);\n  }\n  .root[data-fold=\"scroll\"]::-webkit-scrollbar {\n    display: none;\n  }\n  /* select (a form field at its narrowest): the select below takes over; the segments stay laid out but unseen and take\n     no room (no height, and their gap given back), so a wider room can be measured and bring them back */\n  .root[data-fold=\"select\"] {\n    height: 0;\n    min-height: 0;\n    margin-block-start: calc(var(--pui-field-gap, 0px) * -1);\n    padding-block: 0;\n    overflow: hidden;\n    visibility: hidden;\n    box-shadow: none;\n  }\n  .label,\n  .accessory {\n    display: inline-flex;\n    align-items: center;\n  }\n  .segment:hover:not(:disabled),\n  .segment[aria-checked=\"true\"] {\n    color: var(--pui-ink);\n    transition-duration: 0ms;\n  }\n  /* a press is acknowledged at once on the words; the choice (and the thumb) follows on release */\n  .segment:active:not(:disabled) {\n    scale: var(--pui-press-scale);\n    transition-duration: 0ms;\n  }\n  .segment:disabled {\n    opacity: var(--pui-opacity-disabled);\n    pointer-events: none;\n  }\n  /* the whole group off: the well and its thumb dim once, as one control, with the choice still readable */\n  .root[data-disabled] {\n    opacity: var(--pui-opacity-disabled);\n  }\n  .root[data-disabled] .segment:disabled {\n    opacity: 1;\n  }\n  .segment :where(svg) {\n    width: var(--pui-icon-md);\n    height: var(--pui-icon-md);\n    flex-shrink: 0;\n  }\n}\n/* CSS-module composition only; visual rules stay in the component layer. */\n.root {\n  composes: m-inset from global;\n}\n.thumb {\n  composes: m-control from global;\n}\n"},{"path":"beamline/components/segmented-control/segmented-control.tsx","type":"registry:file","target":"src/ui/beamline/components/segmented-control/segmented-control.tsx","content":"\"use client\";\n\nimport { useMessages } from \"../../runtime/localization\";\nimport { english as englishMessages } from \"./messages\";\nimport { useDeprecatedProp } from \"../../hooks/use-deprecated-prop\";\n\nimport { useComponentDefaults } from \"../../runtime/appearance\";\nimport type { SegmentedControlDefaults } from \"./defaults\";\nexport type { SegmentedControlDefaults } from \"./defaults\";\n\nimport {\n  Fragment,\n  useLayoutEffect,\n  useRef,\n  useState,\n  type CSSProperties,\n  type Ref,\n  type KeyboardEvent,\n  type ReactNode,\n} from \"react\";\nimport { useComposedRef } from \"../../hooks/use-composed-ref\";\nimport { useIndicator } from \"../../hooks/use-indicator\";\nimport { useContour } from \"../../hooks/use-contour\";\nimport { cn } from \"../../lib/utils\";\nimport { useControllable } from \"../../hooks/use-controllable\";\nimport { ChoiceField, choiceIsField, type ChoiceFieldAria } from \"../_shared/field\";\nimport { Select } from \"../select/select\";\nimport { TextMorph } from \"../text-morph/text-morph\";\nimport { Tooltip } from \"../tooltip/tooltip\";\nimport styles from \"./segmented-control.module.css\";\n\nexport interface Segment {\n  /** Value represented by this item. Required. */\n  value: string;\n  /** Text displayed for this item. Required. */\n  label: string;\n  /** Icon element displayed with this item. Omitted by default. */\n  icon?: ReactNode;\n  /** Content after the label, such as a badge. */\n  accessory?: ReactNode;\n  /** A short note beside the label in a tinted chip, such as a saving (\"−20%\"); it folds with the accessories in a\n   *  narrow room. */\n  note?: string;\n  /** The note while this segment is chosen (\"Saving 20%\"): the letters it shares with `note` stay and the rest arrive,\n   *  so the choice reads as what it gains (a billing period: Monthly · Yearly −20%). */\n  activeNote?: string;\n  /** Whether this option is unavailable for selection. Omitted by default. */\n  disabled?: boolean;\n}\n\nexport type SegmentedControlClassNames = Partial<\n  Record<\"root\" | \"thumb\" | \"segment\" | \"note\" | \"field\" | \"label\" | \"description\" | \"error\", string>\n>;\n\n/** How the segments meet a room narrower than they are: full, compact (tighter, accessories folded), words (the icons\n *  give way, the words carry the meaning), icons only (when every segment has one), then, as a form field, a select listing every choice (a view switch in a toolbar scrolls\n *  instead, keeping the choice in view). The thumb travels in every fold but the select. */\ntype Fold = \"full\" | \"compact\" | \"words\" | \"icons\" | \"scroll\" | \"select\";\n\nconst segmentFor = (root: HTMLElement | null, value: string) =>\n  [...(root?.querySelectorAll<HTMLElement>(\"[data-slot=segmented-item]\") ?? [])].find(\n    (item) => item.getAttribute(\"data-value\") === value,\n  );\n\nexport interface SegmentedControlProps {\n  /** Available choices with their labels and values. Required. */\n  options: Segment[];\n  /** Controlled value of the chosen segment; omit to use defaultValue. */\n  value?: string;\n  /** Initial value of the chosen segment when uncontrolled. Defaults to the first option value. */\n  defaultValue?: string;\n  /** Reports value of the chosen segment after an edit; no callback by default. */\n  onValueChange?: (value: string) => void;\n  /** The group's name or question (\"Range\", \"View\", \"Gender\"), shown above it like every field's label; `hideLabel` keeps it for\n   *  assistive tech only (a view switch). */\n  label: string;\n  /** Lay it out as a form field (label above, description or error below). On unless the label is hidden and there is\n   *  no description, error or required mark. */\n  field?: boolean;\n  /** Shows the label visually while keeping its accessible name; defaults to true. Takes precedence over hideLabel. */\n  showLabel?: boolean;\n  /** Hides the label; defaults to false. @deprecated Use showLabel={false} instead. */\n  hideLabel?: boolean;\n  /** One line of help under the segments (makes it a field). */\n  description?: ReactNode;\n  /** The problem and its fix, e.g. a required choice not made (makes it a field and marks the group invalid). */\n  error?: ReactNode;\n  /** Marks the field's label as required (makes it a field). */\n  required?: boolean;\n  /** Submitted with a native form as name=value. */\n  name?: string;\n  /** Prevents interaction with every segment; the choice stays shown. Defaults to false. */\n  disabled?: boolean;\n  /** Runs when a segment is pointed at or focused, before it is chosen: prefetch its data. */\n  onOptionIntent?: (value: string) => void;\n  /** Control size within the supported size steps. Defaults to \"md\". */\n  size?: \"sm\" | \"md\";\n  /** Stretch to the container and share the width equally. */\n  fill?: boolean;\n  /** Show each segment's icon alone, as a square; its label stays the accessible name and the tooltip. */\n  iconOnly?: boolean;\n  /** Classes on the documented visual root; no override by default. */\n  className?: string;\n  /** Inline styles on the documented visual root; no inline overrides by default. */\n  style?: CSSProperties;\n  /** Reading direction; inherits the surrounding direction when omitted. Defaults to the surrounding reading direction. */\n  dir?: \"ltr\" | \"rtl\";\n  /** Receives the documented root element; no ref by default. */\n  ref?: Ref<HTMLDivElement>;\n  /** Classes for the named visual parts; no part overrides by default. */\n  classNames?: SegmentedControlClassNames;\n}\n\n/**\n * Two to five views or ranges of the same content: 1D / 1W / 1M, List / Board. One raised thumb slides to the chosen\n * segment as matter (ui/lib/contour.ts, shaped by the look): it leads, rounds its front and gathers, never bouncing. It is\n * a radio group: Tab enters at the chosen one, arrows move and choose; the choice is made at once, only the thumb settles.\n */\nexport function SegmentedControl({\n  options,\n  value: valueProp,\n  defaultValue,\n  onValueChange,\n  label,\n  field,\n  hideLabel: hideLabelProp,\n  showLabel,\n  description,\n  error,\n  required,\n  name,\n  disabled = false,\n  onOptionIntent,\n  size: sizeProp,\n  fill = false,\n  iconOnly = false,\n  className,\n  style,\n  dir,\n  ref,\n  classNames,\n}: SegmentedControlProps) {\n  const i18n = useMessages(\"segmented-control\", englishMessages);\n\n  useDeprecatedProp(\"SegmentedControl\", \"hideLabel\", \"showLabel={false}\", hideLabelProp !== undefined);\n  const hideLabel = showLabel === undefined ? hideLabelProp : !showLabel;\n  const scopeDefaults = useComponentDefaults<SegmentedControlDefaults>(\"segmented-control\", [\"size\"]);\n  const size = sizeProp ?? scopeDefaults.size ?? \"md\";\n\n  const [value, choose] = useControllable(valueProp, defaultValue ?? options[0]?.value, onValueChange);\n  const [root, thumb] = useIndicator<HTMLDivElement>(\"[role=radio][aria-checked=true]\", `${value}:${options.length}`);\n  const thumbRef = useContour<HTMLSpanElement>(thumb);\n  const rootRef = useComposedRef(root, ref);\n  // the room decides how much of each segment shows: every fold is tried in order on the control itself (an attribute,\n  // read before paint) and the first that fits is kept; a change of the room tries again from full, so it comes back\n  const [fold, setFold] = useState<Fold>(iconOnly ? \"icons\" : \"full\");\n  const refocus = useRef<string | undefined>(undefined);\n  const withTips = useRef(false);\n  useLayoutEffect(() => {\n    withTips.current = fold === \"icons\";\n    const el = root.current;\n    if (!el) return;\n    const v = refocus.current;\n    refocus.current = undefined;\n    if (v !== undefined) segmentFor(el, v)?.focus({ preventScroll: true });\n  }, [fold, root]);\n  const asField = choiceIsField(field, label, hideLabel, description != null || error != null || !!required);\n  const allIcons = options.length > 0 && options.every((o) => o.icon != null);\n  const someIcons = options.some((o) => o.icon != null);\n  const optionSet = options.map((o) => `${o.value}\\u0000${o.label}`).join(\"\\u0001\");\n  useLayoutEffect(() => {\n    const el = root.current;\n    if (!el) return;\n    const folds: Fold[] = iconOnly\n      ? [\"icons\"]\n      : allIcons\n        ? [\"full\", \"compact\", \"words\", \"icons\"]\n        : someIcons\n          ? [\"full\", \"compact\", \"words\"]\n          : [\"full\", \"compact\"];\n    const pick = () => {\n      // the thumb still stands where the last fold put it: out of the measure, so only the segments decide\n      const thumbEl = el.querySelector<HTMLElement>(\"[data-slot=segmented-thumb]\");\n      if (thumbEl) thumbEl.style.display = \"none\";\n      let chosen: Fold = asField ? \"select\" : \"scroll\";\n      for (const f of folds) {\n        el.dataset.fold = f;\n        if (el.scrollWidth <= el.clientWidth + 1) {\n          chosen = f;\n          break;\n        }\n      }\n      el.dataset.fold = chosen;\n      if (thumbEl) thumbEl.style.display = \"\";\n      // into or out of the icon fold the segments are mounted again (only there do they carry a tooltip): the one\n      // holding focus is noted, to be focused again where it now stands\n      const held = el.contains(document.activeElement)\n        ? (document.activeElement as HTMLElement).dataset.value\n        : undefined;\n      if (held !== undefined && (chosen === \"icons\") !== withTips.current) refocus.current = held;\n      setFold((f) => (f === chosen ? f : chosen));\n    };\n    // a scrolling row fades only the edges that have more past them, so the row says which way it goes on\n    const edges = () => {\n      const start = Math.abs(el.scrollLeft) > 1;\n      const end = Math.abs(el.scrollLeft) + el.clientWidth < el.scrollWidth - 1;\n      const v = el.dataset.fold === \"scroll\" ? [start && \"start\", end && \"end\"].filter(Boolean).join(\" \") : \"\";\n      if ((el.dataset.edge ?? \"\") !== v) el.dataset.edge = v;\n    };\n    const pickAndEdge = () => {\n      pick();\n      edges();\n    };\n    pickAndEdge();\n    el.addEventListener(\"scroll\", edges, { passive: true });\n    if (typeof ResizeObserver === \"undefined\") return () => el.removeEventListener(\"scroll\", edges);\n    // the room is the parent's; a pass waits for the next frame so its own change of width never loops back\n    let frame = 0;\n    const observer = new ResizeObserver(() => {\n      cancelAnimationFrame(frame);\n      frame = requestAnimationFrame(pickAndEdge);\n    });\n    if (el.parentElement) observer.observe(el.parentElement);\n    return () => {\n      observer.disconnect();\n      cancelAnimationFrame(frame);\n      el.removeEventListener(\"scroll\", edges);\n    };\n  }, [root, optionSet, iconOnly, allIcons, someIcons, size, fill, asField]);\n  // folded into a scrolling row, the choice is kept in view\n  useLayoutEffect(() => {\n    const el = root.current;\n    if (fold !== \"scroll\" || !el) return;\n    const on = el.querySelector<HTMLElement>(\"[role=radio][aria-checked=true]\");\n    if (!on) return;\n    // by how far its centre is from the row's centre, which reads the same in a right-to-left row\n    const a = on.getBoundingClientRect();\n    const b = el.getBoundingClientRect();\n    el.scrollBy({ left: a.left + a.width / 2 - (b.left + b.width / 2), behavior: \"instant\" as ScrollBehavior });\n  }, [fold, value, root]);\n  const enabled = disabled ? [] : options.filter((o) => !o.disabled);\n  const onKey = (e: KeyboardEvent<HTMLDivElement>) => {\n    const rtl = getComputedStyle(e.currentTarget).direction === \"rtl\";\n    const dir = { ArrowRight: rtl ? -1 : 1, ArrowDown: 1, ArrowLeft: rtl ? 1 : -1, ArrowUp: -1 }[e.key];\n    let next: Segment | undefined;\n    if (dir) {\n      const i = enabled.findIndex((o) => o.value === value);\n      next = enabled[(i + dir + enabled.length) % enabled.length];\n    } else if (e.key === \"Home\") next = enabled[0];\n    else if (e.key === \"End\") next = enabled.at(-1);\n    if (!next) return;\n    e.preventDefault();\n    choose(next.value);\n    segmentFor(root.current, next.value)?.focus();\n  };\n  const chosenAny = options.some((o) => o.value === value);\n  const control = (aria?: ChoiceFieldAria) => (\n    <div\n      ref={rootRef}\n      dir={dir}\n      style={asField ? undefined : style}\n      role=\"radiogroup\"\n      aria-label={aria ? undefined : label}\n      aria-required={required || undefined}\n      aria-disabled={disabled || undefined}\n      {...aria}\n      data-disabled={disabled ? \"\" : undefined}\n      data-field={asField ? \"\" : undefined}\n      data-slot=\"segmented-control\"\n      data-size={size}\n      data-fold={fold}\n      // folded into a select, the segments stay laid out (unseen, out of reach) only so the room can be measured\n      aria-hidden={fold === \"select\" || undefined}\n      inert={fold === \"select\" || undefined}\n      onKeyDown={onKey}\n      className={cn(\n        styles.root,\n        size === \"sm\" && styles.sm,\n        fill && styles.fill,\n\n        // inside a field's grid the control keeps its own width unless it fills\n        asField && !fill && \"self-start justify-self-start\",\n        classNames?.root,\n        !asField && className,\n      )}\n    >\n      {name && <input type=\"hidden\" name={name} value={value ?? \"\"} />}\n      {thumb && (\n        <span ref={thumbRef} aria-hidden data-slot=\"segmented-thumb\" className={cn(styles.thumb, classNames?.thumb)} />\n      )}\n      {options.map((o) => {\n        const on = o.value === value;\n        const segment = (\n          <button\n            type=\"button\"\n            role=\"radio\"\n            aria-checked={on}\n            data-value={o.value}\n            disabled={disabled || o.disabled}\n            // with nothing chosen yet (a required form choice) the first enabled segment takes Tab\n            tabIndex={on || (!chosenAny && o.value === enabled[0]?.value) ? 0 : -1}\n            data-slot=\"segmented-item\"\n            // until the thumb is first placed (a page drawn on a server), the chosen segment wears its paint itself\n            className={cn(styles.segment, on && !thumb && \"m-control\", classNames?.segment)}\n            onClick={() => choose(o.value)}\n            onPointerEnter={() => onOptionIntent?.(o.value)}\n            onFocus={() => onOptionIntent?.(o.value)}\n          >\n            {o.icon}\n            {/* folded to icons the words stay: the segment's name for assistive tech and its tooltip */}\n            <span data-slot=\"segmented-label\" className={styles.label}>\n              {o.label}\n            </span>\n            {(on ? (o.activeNote ?? o.note) : o.note) && (\n              <span\n                data-slot=\"segmented-note\"\n                className={cn(\n                  styles.accessory,\n                  \"inline-grid h-4.5 place-items-center rounded-pill bg-green-tint px-1.5 text-2xs leading-none font-medium text-green\",\n                  classNames?.note,\n                )}\n              >\n                <TextMorph>{(on ? (o.activeNote ?? o.note) : o.note) as string}</TextMorph>\n              </span>\n            )}\n            {o.accessory != null && (\n              <span data-slot=\"segmented-accessory\" className={styles.accessory}>\n                {o.accessory}\n              </span>\n            )}\n          </button>\n        );\n        // folded to icons, a segment names itself in the system tooltip; in every other fold it carries none, since a\n        // closed tooltip on each segment re-rendered with the control (on the landing: 689 renders more at load)\n        return fold === \"icons\" ? (\n          <Tooltip key={o.value} content={o.label}>\n            {segment}\n          </Tooltip>\n        ) : (\n          <Fragment key={o.value}>{segment}</Fragment>\n        );\n      })}\n    </div>\n  );\n  if (!asField) return control();\n  // the select comes first, so in a split form it takes the control's place beside the label; the measured segments\n  // keep their position among the children (and their state) in every fold\n  const narrowest = (aria: ChoiceFieldAria) => (\n    <>\n      {fold === \"select\" && (\n        <Select\n          label={label}\n          showLabel={false}\n          placeholder={i18n(\"chooseOne\")}\n          required={required}\n          size={size === \"sm\" ? \"sm\" : \"md\"}\n          value={value}\n          disabled={disabled}\n          onValueChange={choose}\n          options={options.map((o) => ({ value: o.value, label: o.label, icon: o.icon, disabled: o.disabled }))}\n          className=\"animate-enter-fade\"\n        />\n      )}\n      {control(aria)}\n    </>\n  );\n  return (\n    <ChoiceField\n      slot=\"segmented-control-field\"\n      label={label}\n      hideLabel={hideLabel}\n      required={required}\n      requiredOnControl\n      description={description}\n      error={error}\n      className={cn(classNames?.field, className)}\n      style={style}\n      classNames={classNames}\n    >\n      {narrowest}\n    </ChoiceField>\n  );\n}\n\nexport default SegmentedControl;\n"},{"path":"beamline/components/select/defaults.ts","type":"registry:file","target":"src/ui/beamline/components/select/defaults.ts","content":"export interface SelectDefaults {\n  /** Shared size setting; omit to inherit the surrounding scope or the component default. */\n  size?: \"sm\" | \"md\" | \"lg\";\n}\n"},{"path":"beamline/components/select/messages.ts","type":"registry:file","target":"src/ui/beamline/components/select/messages.ts","content":"import type { MessageDefinitions } from \"../../runtime/messages\";\n/** Built-in English copy; stable keys are the public translation API. */\nexport const english = {\n  placeholder: \"Select\",\n} satisfies MessageDefinitions;\n"},{"path":"beamline/components/select/select.module.css","type":"registry:file","target":"src/ui/beamline/components/select/select.module.css","content":"@layer properties, theme, base, components, utilities;\n@layer components {\n  /* The trigger is a field frame (paint, hover, focus edge, invalid, disabled at --pui-opacity-disabled all come from\n     _shared/field); it adds only what a button-like frame needs. */\n  .trigger {\n    width: 100%;\n    justify-content: space-between;\n    text-align: start;\n    cursor: pointer;\n  }\n  .trigger:focus-visible {\n    outline: none;\n  }\n  .trigger:disabled {\n    cursor: not-allowed;\n  }\n  .trigger[data-placeholder] {\n    color: var(--pui-ink-3);\n  }\n  /* the value line: label, then the detail on the same line or wrapped out of sight */\n  .value {\n    display: flex;\n    min-width: 0;\n    flex: 1;\n    flex-wrap: wrap;\n    align-items: baseline;\n    column-gap: var(--pui-space-2);\n    height: 1lh;\n    overflow: hidden;\n  }\n  .valueDetail {\n    color: var(--pui-ink-3);\n    font-size: var(--pui-text-xs);\n    white-space: nowrap;\n  }\n  .chevron {\n    flex-shrink: 0;\n    width: var(--pui-icon-md);\n    height: var(--pui-icon-md);\n    color: var(--pui-ink-3);\n  }\n\n  /* list rows: a detail at the end, the check after it at the inline end */\n  .detail {\n    flex-shrink: 0;\n    margin-inline-start: auto;\n    padding-inline-start: var(--pui-space-3);\n    color: var(--pui-ink-3);\n    font-size: var(--pui-text-xs);\n  }\n  .check {\n    position: absolute;\n    inset-inline-end: var(--pui-space-2);\n    display: inline-flex;\n  }\n  .check > svg {\n    color: var(--pui-accent);\n  }\n}\n"},{"path":"beamline/components/select/select.tsx","type":"registry:file","target":"src/ui/beamline/components/select/select.tsx","content":"\"use client\";\n\nimport { useMessages } from \"../../runtime/localization\";\nimport { english as englishMessages } from \"./messages\";\nimport { useDeprecatedProp } from \"../../hooks/use-deprecated-prop\";\n\nimport { Fragment, useRef, type CSSProperties, type ReactNode, type Ref } from \"react\";\nimport { FollowPlate } from \"../_shared/glide\";\nimport { Check, ChevronsUpDown } from \"lucide-react\";\nimport * as RadixSelect from \"@radix-ui/react-select\";\nimport { Field, useFieldIds, type FieldSize, type FieldClassNames } from \"../_shared/field\";\nimport { usePortalContainer, useComponentDefaults } from \"../../runtime/appearance\";\nimport type { SelectDefaults } from \"./defaults\";\nexport type { SelectDefaults } from \"./defaults\";\nimport { cn } from \"../../lib/utils\";\nimport { useControllable } from \"../../hooks/use-controllable\";\nimport field from \"../_shared/field.module.css\";\nimport overlay from \"../_shared/overlay.module.css\";\nimport styles from \"./select.module.css\";\n\nexport interface SelectOption {\n  /** Value represented by this item. Required. */\n  value: string;\n  /** Text displayed for this item. Required. */\n  label: ReactNode;\n  /** Icon element displayed with this item. Omitted by default. */\n  icon?: ReactNode;\n  /** A short detail at the end of the row (an offset, a plan); the field shows it beside the chosen label while it has\n   *  room for it whole. */\n  description?: ReactNode;\n  /** Whether this option is unavailable for selection. Omitted by default. */\n  disabled?: boolean;\n}\nexport interface SelectGroup {\n  /** Text displayed for this item. Required. */\n  label: string;\n  /** Choices available for this question or field. Required. */\n  options: SelectOption[];\n}\n\nexport interface SelectProps {\n  /** Visible label or accessible name for the control. Required. */\n  label: ReactNode;\n  /** Shows the label visually while keeping its accessible name; defaults to true. Takes precedence over hideLabel. */\n  showLabel?: boolean;\n  /** Hides the label; defaults to false. @deprecated Use showLabel={false} instead. */\n  hideLabel?: boolean;\n  /** Supporting text beneath the label or heading. Defaults to no supporting text. */\n  description?: ReactNode;\n  /** Error message shown in place of the usual supporting text. Defaults to no error message. */\n  error?: ReactNode;\n  /** Text shown before a value is entered or selected. Defaults to \"Select\". */\n  placeholder?: string;\n  /** Options, or groups of options with a heading. */\n  options: (SelectOption | SelectGroup)[];\n  /** Controlled value of the chosen option; omit to use defaultValue. */\n  value?: string;\n  /** Initial value of the chosen option when uncontrolled. Defaults to no selected option. */\n  defaultValue?: string;\n  /** Reports value of the chosen option after an edit; no callback by default. */\n  onValueChange?: (value: string) => void;\n  /** Control size within the supported size steps. Defaults to \"md\". */\n  size?: FieldSize;\n  /** Prevents interaction with the control. Defaults to false. */\n  disabled?: boolean;\n  /** Marks the field as required for form submission. Defaults to false. */\n  required?: boolean;\n  /** Field name used in native form submission. Defaults to no form field name. */\n  name?: string;\n  /** DOM id used to connect the control and its label. Defaults to an automatically generated control id. */\n  id?: string;\n  /** Classes on the documented visual root; no override by default. */\n  className?: string;\n  /** Inline styles on the documented visual root; no inline overrides by default. */\n  style?: CSSProperties;\n  /** Classes for the named visual parts; no part overrides by default. */\n  classNames?: FieldClassNames &\n    Partial<Record<\"trigger\" | \"value\" | \"icon\" | \"list\" | \"viewport\" | \"item\" | \"groupLabel\" | \"separator\", string>>;\n  /** Controlled open state; omit to use defaultOpen. */\n  open?: boolean;\n  /** Initial open state when uncontrolled. Defaults to false. */\n  defaultOpen?: boolean;\n  /** Reports open state after a change; no callback by default. */\n  onOpenChange?: (open: boolean) => void;\n  /** Receives the button or trigger; no ref by default. */\n  ref?: Ref<HTMLButtonElement>;\n}\n\nconst isGroup = (o: SelectOption | SelectGroup): o is SelectGroup => \"options\" in o;\n\n/** One choice from a short known list, in the same frame as every text field. Type to jump; the list opens under the\n *  field at its width. */\nexport function Select({\n  label,\n  hideLabel: hideLabelProp,\n  showLabel,\n  description,\n  error,\n  placeholder: placeholderProp,\n  options,\n  value,\n  defaultValue,\n  onValueChange,\n  size: sizeProp,\n  disabled,\n  required,\n  name,\n  id,\n  className,\n  classNames,\n  style,\n  open,\n  defaultOpen,\n  onOpenChange,\n  ref,\n}: SelectProps) {\n  const i18n = useMessages(\"select\", englishMessages);\n  const placeholder = placeholderProp === undefined ? i18n(\"placeholder\") : placeholderProp;\n\n  useDeprecatedProp(\"Select\", \"hideLabel\", \"showLabel={false}\", hideLabelProp !== undefined);\n  const hideLabel = showLabel === undefined ? hideLabelProp : !showLabel;\n  const defaults = useComponentDefaults<SelectDefaults>(\"select\", [\"size\"]);\n  const size = sizeProp ?? defaults.size ?? \"md\";\n  const { controlId, descriptionId, errorId, aria } = useFieldIds(id, { description, error });\n  const container = usePortalContainer();\n  const viewport = useRef<HTMLDivElement>(null);\n  // the choice, kept here too (Radix keeps its own), so the field can show the chosen option's detail\n  const [current, setCurrent] = useControllable(value, defaultValue, onValueChange);\n  const chosen = options.flatMap((o) => (isGroup(o) ? o.options : [o])).find((o) => o.value === current);\n  const item = (o: SelectOption) => (\n    <RadixSelect.Item\n      key={o.value}\n      value={o.value}\n      disabled={o.disabled}\n      data-menu-item=\"\"\n      data-glide=\"\"\n      data-slot=\"select-item\"\n      className={cn(overlay.item, \"pe-8\", classNames?.item)}\n    >\n      {o.icon}\n      <span className=\"min-w-0 truncate\">\n        <RadixSelect.ItemText>{o.label}</RadixSelect.ItemText>\n      </span>\n      {o.description && <span className={styles.detail}>{o.description}</span>}\n      <RadixSelect.ItemIndicator className={styles.check}>\n        <Check />\n      </RadixSelect.ItemIndicator>\n    </RadixSelect.Item>\n  );\n  return (\n    <Field\n      label={label}\n      hideLabel={hideLabel}\n      description={description}\n      error={error}\n      required={required}\n      requiredOnControl\n      controlId={controlId}\n      descriptionId={descriptionId}\n      errorId={errorId}\n      className={className}\n      classNames={classNames}\n      style={style}\n    >\n      <RadixSelect.Root\n        open={open}\n        defaultOpen={defaultOpen}\n        onOpenChange={onOpenChange}\n        value={value}\n        defaultValue={defaultValue}\n        onValueChange={(v) => {\n          setCurrent(v);\n        }}\n        disabled={disabled}\n        required={required}\n        name={name}\n      >\n        <RadixSelect.Trigger\n          ref={ref}\n          data-slot=\"select\"\n          {...aria}\n          className={cn(field.frame, field[size], styles.trigger, classNames?.trigger)}\n          data-invalid={error ? \"\" : undefined}\n        >\n          {/* the label, then the chosen option's detail (UTC+3, Pro plan): the detail wraps out of sight (one line,\n              clipped) when the field is too narrow to show it whole, so a narrow field shows the label alone */}\n          <span data-slot=\"select-value\" className={cn(styles.value, classNames?.value)}>\n            <span className=\"max-w-full truncate\">\n              <RadixSelect.Value placeholder={placeholder} />\n            </span>\n            {chosen?.description && (\n              <span data-slot=\"select-detail\" className={styles.valueDetail}>\n                {chosen.description}\n              </span>\n            )}\n          </span>\n          <RadixSelect.Icon data-slot=\"select-icon\" className={classNames?.icon}>\n            <ChevronsUpDown className={styles.chevron} />\n          </RadixSelect.Icon>\n        </RadixSelect.Trigger>\n        {container !== null && (\n          <RadixSelect.Portal container={container}>\n            <RadixSelect.Content\n              data-slot=\"select-list\"\n              position=\"popper\"\n              sideOffset={6}\n              collisionPadding={8}\n              className={cn(\n                overlay.surface,\n                overlay.menu,\n                classNames?.list,\n                \"max-h-[min(360px,var(--radix-select-content-available-height))] w-[var(--radix-select-trigger-width)]\",\n              )}\n            >\n              <RadixSelect.Viewport\n                ref={viewport}\n                data-slot=\"select-viewport\"\n                className={cn(\"relative\", classNames?.viewport)}\n              >\n                <FollowPlate list={viewport} rows=\"[data-slot=select-item]\" />\n                {options.map((o, i) =>\n                  isGroup(o) ? (\n                    <Fragment key={o.label}>\n                      {i > 0 && (\n                        <RadixSelect.Separator\n                          data-slot=\"select-separator\"\n                          className={cn(overlay.separator, classNames?.separator)}\n                        />\n                      )}\n                      <RadixSelect.Group>\n                        <RadixSelect.Label\n                          data-slot=\"select-group-label\"\n                          className={cn(overlay.heading, classNames?.groupLabel)}\n                        >\n                          {o.label}\n                        </RadixSelect.Label>\n                        {o.options.map(item)}\n                      </RadixSelect.Group>\n                    </Fragment>\n                  ) : (\n                    item(o)\n                  ),\n                )}\n              </RadixSelect.Viewport>\n            </RadixSelect.Content>\n          </RadixSelect.Portal>\n        )}\n      </RadixSelect.Root>\n    </Field>\n  );\n}\n\nexport default Select;\n"},{"path":"beamline/components/spinner/defaults.ts","type":"registry:file","target":"src/ui/beamline/components/spinner/defaults.ts","content":"/** Pure allowed presentation defaults for Spinner; no component or runtime imports. */\nexport interface SpinnerDefaults {\n  /** Shared size setting; omit to inherit the surrounding scope or the component default. */\n  size?: \"sm\" | \"md\" | \"lg\";\n}\n"},{"path":"beamline/components/spinner/messages.ts","type":"registry:file","target":"src/ui/beamline/components/spinner/messages.ts","content":"import type { MessageDefinitions } from \"../../runtime/messages\";\n/** Built-in English copy; stable keys are the public translation API. */\nexport const english = {\n  label: \"Loading\",\n  done: \"Done\",\n  error: \"Failed\",\n} satisfies MessageDefinitions;\n"},{"path":"beamline/components/spinner/spinner.module.css","type":"registry:file","target":"src/ui/beamline/components/spinner/spinner.module.css","content":"@layer properties, theme, base, components, utilities;\n@layer components {\n  /* With a delay the ring waits unseen and then fades in, so quick work never flashes it; the result (a check or a\n     cross) always shows at once. */\n  .root[data-delay] {\n    animation: appear var(--pui-fade-in) var(--pui-ease-default) var(--_delay) both;\n  }\n  @keyframes appear {\n    from {\n      opacity: 0;\n    }\n  }\n  /* The turn runs on the compositor (a CSS animation on the svg box) and costs no JS per frame. When the work ends the\n     arc closes into a full ring over the standard duration, so stopping the turn is invisible, and the check or cross\n     draws itself a beat later. All timing comes from the motion tokens; the loop period follows --pui-motion-scale. */\n  .svg[data-state=\"loading\"] {\n    animation: turn calc(0.8s * var(--pui-motion-scale, 1) * var(--pui-motion-look, 1)) linear infinite;\n  }\n  .track {\n    stroke-opacity: 0.18;\n  }\n  .arc {\n    stroke-dasharray: 0.3 1;\n    transition: stroke-dasharray var(--pui-duration-standard) var(--pui-ease-enter);\n  }\n  .svg:not([data-state=\"loading\"]) .arc {\n    stroke-dasharray: 1 1;\n  }\n  .mark {\n    stroke-dasharray: 1 1;\n    animation: draw var(--pui-duration-standard) var(--pui-ease-enter) var(--pui-duration-fast) both;\n  }\n  @keyframes turn {\n    to {\n      transform: rotate(1turn);\n    }\n  }\n  @keyframes draw {\n    from {\n      stroke-dashoffset: 1;\n    }\n    to {\n      stroke-dashoffset: 0;\n    }\n  }\n  .svg[data-paused] {\n    animation-play-state: paused;\n  }\n  .svg[data-reduced],\n  .svg[data-reduced] .mark {\n    animation: none;\n  }\n  /* Reduction retains the loading/result shape without a decorative loop. */\n  @media (prefers-reduced-motion: reduce) {\n    .svg[data-state=\"loading\"],\n    .mark {\n      animation: none;\n    }\n  }\n}\n"},{"path":"beamline/components/spinner/spinner.tsx","type":"registry:file","target":"src/ui/beamline/components/spinner/spinner.tsx","content":"\"use client\";\n\nimport { useMessages } from \"../../runtime/localization\";\nimport { english as englishMessages } from \"./messages\";\nimport { useComponentDefaults } from \"../../runtime/appearance\";\nimport type { SpinnerDefaults } from \"./defaults\";\nexport type { SpinnerDefaults } from \"./defaults\";\n\nimport { useRef, type CSSProperties, type Ref } from \"react\";\nimport { useComposedRef } from \"../../hooks/use-composed-ref\";\nimport { useActive } from \"../../hooks/use-active\";\nimport { useMotionTokens } from \"../../hooks/use-motion-tokens\";\nimport { useReducedMotionSafe } from \"../../hooks/use-reduced-motion-safe\";\nimport { cn } from \"../../lib/utils\";\nimport styles from \"./spinner.module.css\";\n\nexport interface SpinnerClassNames {\n  /** Classes for the root part; no override by default. */\n  root?: string;\n  /** Classes for the svg part; no override by default. */\n  svg?: string;\n  /** Classes for the track part; no override by default. */\n  track?: string;\n  /** Classes for the arc part; no override by default. */\n  arc?: string;\n  /** Classes for the mark part; no override by default. */\n  mark?: string;\n}\n\nexport interface SpinnerProps {\n  /** `success` draws a check out of the ring, `error` a cross; both stop spinning. */\n  state?: \"loading\" | \"success\" | \"error\";\n  /** Control size within the supported size steps. Defaults to \"md\". */\n  size?: \"sm\" | \"md\" | \"lg\";\n  /** Accessible name while loading. */\n  label?: string;\n  /** ms to wait before it shows: work that ends sooner never flashes a spinner (about 300 is a good start). Default 0. */\n  delay?: number;\n  /** Classes on the documented visual root; no override by default. */\n  className?: string;\n  /** Receives the documented root element; no ref by default. */\n  ref?: Ref<HTMLSpanElement>;\n  /** Inline styles on the documented visual root; no inline overrides by default. */\n  style?: CSSProperties;\n  /** Classes for the named visual parts; no part overrides by default. */\n  classNames?: SpinnerClassNames;\n}\n\n/** Icon box from the foundation icon steps (§14.2): sm 14, md 16, lg 20. */\nconst PX = { sm: \"var(--pui-icon-sm)\", md: \"var(--pui-icon-md)\", lg: \"var(--pui-icon-lg)\" } as const;\n\n/**\n * A ring that spins while work runs and closes into a drawn check (or cross) when it ends — the result is a shape as\n * well as a colour. With reduced motion the loading ring holds still.\n */\nexport function Spinner({\n  state = \"loading\",\n  size: sizeProp,\n  label: labelProp,\n  delay = 0,\n  className,\n  classNames,\n  style,\n  ref,\n}: SpinnerProps) {\n  const i18n = useMessages(\"spinner\", englishMessages);\n  const label = labelProp === undefined ? i18n(\"label\") : labelProp;\n\n  const scopeDefaults = useComponentDefaults<SpinnerDefaults>(\"spinner\", [\"size\"]);\n  const size = sizeProp ?? scopeDefaults.size ?? \"md\";\n  const host = useRef<HTMLSpanElement>(null);\n  const attach = useComposedRef(host, ref);\n  const active = useActive(host);\n  const tokens = useMotionTokens(host);\n  const managedReduced = useReducedMotionSafe();\n  const reduced = tokens.reduced || managedReduced;\n\n  const box = PX[size];\n  const done = state !== \"loading\";\n  const tone = state === \"success\" ? \"text-green\" : state === \"error\" ? \"text-red\" : \"text-ink-2\";\n  return (\n    <span\n      ref={attach}\n      data-slot=\"spinner\"\n      data-state={state}\n      data-delay={delay > 0 && state === \"loading\" ? \"\" : undefined}\n      role={done ? \"img\" : \"status\"}\n      aria-label={state === \"success\" ? i18n(\"done\") : state === \"error\" ? i18n(\"error\") : label}\n      className={cn(styles.root, \"relative inline-grid shrink-0 place-items-center\", tone, classNames?.root, className)}\n      style={{ width: box, height: box, \"--_delay\": `${delay}ms`, ...style } as CSSProperties}\n    >\n      <svg\n        viewBox=\"0 0 24 24\"\n        width=\"100%\"\n        height=\"100%\"\n        fill=\"none\"\n        aria-hidden=\"true\"\n        data-state={state}\n        data-slot=\"spinner-svg\"\n        data-reduced={reduced ? \"\" : undefined}\n        data-paused={active ? undefined : \"\"}\n        className={cn(styles.svg, classNames?.svg)}\n      >\n        <circle\n          data-slot=\"spinner-track\"\n          className={cn(styles.track, classNames?.track)}\n          cx=\"12\"\n          cy=\"12\"\n          r=\"9.5\"\n          stroke=\"currentColor\"\n          strokeWidth=\"2.5\"\n        />\n        <circle\n          data-slot=\"spinner-arc\"\n          className={cn(styles.arc, classNames?.arc)}\n          cx=\"12\"\n          cy=\"12\"\n          r=\"9.5\"\n          pathLength={1}\n          stroke=\"currentColor\"\n          strokeWidth=\"2.5\"\n          strokeLinecap=\"round\"\n          transform=\"rotate(-90 12 12)\"\n        />\n        {state === \"success\" && (\n          <path\n            data-slot=\"spinner-mark\"\n            className={cn(styles.mark, classNames?.mark)}\n            d=\"M7.5 12.5l3 3 6-6.5\"\n            pathLength={1}\n            stroke=\"currentColor\"\n            strokeWidth=\"2.5\"\n            strokeLinecap=\"round\"\n            strokeLinejoin=\"round\"\n          />\n        )}\n        {state === \"error\" && (\n          <path\n            data-slot=\"spinner-mark\"\n            className={cn(styles.mark, classNames?.mark)}\n            d=\"M8.5 8.5l7 7M15.5 8.5l-7 7\"\n            pathLength={1}\n            stroke=\"currentColor\"\n            strokeWidth=\"2.5\"\n            strokeLinecap=\"round\"\n          />\n        )}\n      </svg>\n    </span>\n  );\n}\n\nexport default Spinner;\n"},{"path":"beamline/components/text-morph/text-morph.tsx","type":"registry:file","target":"src/ui/beamline/components/text-morph/text-morph.tsx","content":"\"use client\";\n\nimport { useMemo, useRef, type CSSProperties, type Ref } from \"react\";\nimport { AnimatePresence, LayoutGroup, motion } from \"motion/react\";\nimport { useComposedRef } from \"../../hooks/use-composed-ref\";\nimport { useMotionTokens } from \"../../hooks/use-motion-tokens\";\nimport { useReducedMotionSafe } from \"../../hooks/use-reduced-motion-safe\";\nimport { useWidthMorph } from \"../../hooks/use-width-morph\";\nimport { cn } from \"../../lib/utils\";\n\nexport interface TextMorphClassNames {\n  /** Classes for the root part; no override by default. */\n  root?: string;\n  /** Classes for the letter part; no override by default. */\n  letter?: string;\n}\n\nexport interface TextMorphProps {\n  /** A short label; when it changes, letters it shares with the old one slide into place and the rest fade. */\n  children: string;\n  /** HTML element used for the text or container. Defaults to \"span\". */\n  as?: \"span\" | \"div\" | \"p\" | \"strong\" | \"h1\" | \"h2\" | \"h3\";\n  /** Classes on the documented visual root; no override by default. */\n  className?: string;\n  /** DOM id on the animated text root; omitted by default. */\n  id?: string;\n  /** Classes for the named visual parts; no part overrides by default. */\n  classNames?: TextMorphClassNames;\n  /** Inline styles on the documented visual root; no inline overrides by default. */\n  style?: CSSProperties;\n  /** Receives the documented root element; no ref by default. */\n  ref?: Ref<HTMLElement>;\n}\n\n/** A short label that becomes its next state letter by letter: shared letters glide, new ones arrive, old ones leave,\n *  and the label's width eases with them, so whatever sits after it (a button, a counter) glides instead of jumping.\n *  Reduced motion swaps the text. Assistive tech reads the label once, not the letters. */\nexport function TextMorph({ children, as = \"span\", className, classNames, style, ref, id }: TextMorphProps) {\n  const host = useRef<HTMLElement>(null);\n  const attach = useComposedRef(host, ref);\n  const motionTokens = useMotionTokens(host);\n  const managedReduced = useReducedMotionSafe();\n  const reduced = motionTokens.reduced || managedReduced;\n  const Tag = motion[as];\n  useWidthMorph(host, reduced ? null : children);\n  // key each letter by its character and how many times it has appeared so far, so repeats map in order\n  const letters = useMemo(() => {\n    const seen: Record<string, number> = {};\n    return [...children].map((ch) => {\n      seen[ch] = (seen[ch] ?? 0) + 1;\n      return { ch, key: `${ch}-${seen[ch]}` };\n    });\n  }, [children]);\n  // a script written right to left is joined letter to letter and can't be split into glyphs: it swaps whole, like\n  // reduced motion; everything else keeps its own left-to-right letter order even on a right-to-left page\n  const rtlScript = /[\\u0590-\\u08FF\\uFB1D-\\uFDFF\\uFE70-\\uFEFF]/.test(children);\n  if (reduced || rtlScript)\n    return (\n      <Tag ref={attach} id={id} data-slot=\"text-morph\" className={cn(classNames?.root, className)} style={style}>\n        {children}\n      </Tag>\n    );\n  return (\n    <Tag\n      ref={attach}\n      id={id}\n      data-slot=\"text-morph\"\n      aria-label={children}\n      dir=\"ltr\"\n      className={cn(\"inline-flex overflow-x-clip whitespace-pre\", classNames?.root, className)}\n      style={style}\n    >\n      <LayoutGroup>\n        <AnimatePresence mode=\"popLayout\" initial={false}>\n          {letters.map(({ ch, key }) => (\n            <motion.span\n              key={key}\n              aria-hidden\n              layout=\"position\"\n              // the letters move only when the text changes: a re-render with the same words (a scroll, a resize, a\n              // parent's update) leaves them still\n              layoutDependency={children}\n              data-slot=\"text-morph-letter\"\n              className={cn(\"inline-block\", classNames?.letter)}\n              initial={{ opacity: 0, filter: `blur(${motionTokens.blur.subtle}px)`, y: 3 }}\n              animate={{ opacity: 1, filter: \"blur(0px)\", y: 0 }}\n              exit={{ opacity: 0, filter: `blur(${motionTokens.blur.subtle}px)`, y: -3 }}\n              transition={motionTokens.spring.morph}\n            >\n              {ch === \" \" ? \" \" : ch}\n            </motion.span>\n          ))}\n        </AnimatePresence>\n      </LayoutGroup>\n    </Tag>\n  );\n}\n\nexport default TextMorph;\n"},{"path":"beamline/components/toggle-group/defaults.ts","type":"registry:file","target":"src/ui/beamline/components/toggle-group/defaults.ts","content":"/** Pure allowed presentation defaults for ToggleGroup; no component or runtime imports. */\nexport interface ToggleGroupDefaults {\n  /** Shared variant setting; omit to inherit the surrounding scope or the component default. */\n  variant?: \"outline\" | \"ghost\" | \"default\";\n  /** Shared size setting; omit to inherit the surrounding scope or the component default. */\n  size?: \"sm\" | \"md\" | \"lg\" | \"default\";\n}\n"},{"path":"beamline/components/toggle-group/toggle-group.module.css","type":"registry:file","target":"src/ui/beamline/components/toggle-group/toggle-group.module.css","content":"@layer properties, theme, base, components, utilities;\n@layer components {\n  /* Toggle group: bare toggles (ghost) or a framed row (outline). A toggle that is on sits pressed in: it takes the\n     paint of the look's inset well, so on reads as \"held down\" in every look. Sizes are set on the group. */\n  .root {\n    --pui-toggle-h: 32px;\n    --pui-toggle-pad: 8px;\n    position: relative;\n    isolation: isolate;\n    display: inline-flex;\n    max-width: 100%;\n    flex-wrap: wrap; /* in a room narrower than the row, toggles wrap rather than spill */\n    align-items: center;\n    gap: var(--pui-space-0-5);\n  }\n  .outline {\n    /* the well's inset is size, not spacing: a control keeps its height when the Spacing parameter changes (O1 §14.2) */\n    padding: var(--pui-size-0-5, 0.125rem);\n    border-radius: var(--pui-radius-control);\n    box-shadow: inset 0 0 0 1px var(--pui-line-strong);\n  }\n  .sm {\n    --pui-toggle-h: 28px;\n    --pui-toggle-pad: 6px;\n  }\n  .lg {\n    --pui-toggle-h: 40px;\n    --pui-toggle-pad: 10px;\n  }\n  .item {\n    display: inline-flex;\n    height: var(--pui-toggle-h);\n    min-width: var(--pui-toggle-h);\n    align-items: center;\n    justify-content: center;\n    gap: var(--pui-space-1-5);\n    padding-inline: var(--pui-toggle-pad);\n    border-radius: calc(var(--pui-radius-control) - 2px);\n    color: var(--pui-ink-3);\n    font-size: var(--pui-text-sm);\n    font-weight: var(--pui-weight-medium);\n    transition:\n      background-color var(--pui-motion-out) var(--pui-ease-default),\n      box-shadow var(--pui-motion-out) var(--pui-ease-default),\n      color var(--pui-motion-out) var(--pui-ease-default);\n  }\n  .item:hover {\n    background: var(--pui-hover);\n    color: var(--pui-ink);\n    transition-duration: 0ms;\n  }\n  .item:active:not(:disabled) {\n    scale: var(--pui-press-scale);\n  }\n  /* \"On\" is read from the ARIA state (aria-pressed for several, aria-checked for one): a tooltip around a toggle\n     names its own open state in data-state, so that attribute is not the toggle's. The pressed well is a layer under\n     the toggle, so neighbours that are both on can merge into one run: the facing corners square off and each well\n     reaches into the gap, its own edge clipped at the seam, so a run of Bold Italic Underline reads as one held-down\n     strip; turning one off splits it again (research/morphing-interfaces-2026-10-04, merge). Corners and reach move\n     on the morph spring; nothing overshoots. */\n  .item {\n    position: relative;\n    isolation: isolate;\n  }\n  .item::before {\n    content: \"\";\n    position: absolute;\n    inset: 0;\n    z-index: -1;\n    border-radius: inherit;\n    background: var(--m-inset-shade), var(--pui-inset);\n    /* the look's pressed rim over the well's own edge (first shadow on top), so the eye finds the pressed toggle in every look */\n    box-shadow: var(--m-pressed-rim, 0 0 transparent), var(--m-inset-edge);\n    opacity: 0;\n    transition:\n      opacity var(--pui-motion-out) var(--pui-ease-default),\n      inset var(--pui-duration-morph) var(--pui-ease-standard),\n      border-radius var(--pui-duration-morph) var(--pui-ease-standard),\n      clip-path var(--pui-duration-morph) var(--pui-ease-standard);\n    clip-path: inset(0);\n  }\n  .item:is([aria-pressed=\"true\"], [aria-checked=\"true\"]) {\n    color: var(--pui-ink);\n  }\n  .item:is([aria-pressed=\"true\"], [aria-checked=\"true\"])::before {\n    opacity: 1;\n    transition-duration: 0ms, var(--pui-duration-morph), var(--pui-duration-morph), var(--pui-duration-morph);\n  }\n  /* joined to the next toggle */\n  .item:is([aria-pressed=\"true\"], [aria-checked=\"true\"]):has(\n      + .item:is([aria-pressed=\"true\"], [aria-checked=\"true\"])\n    )::before {\n    inset-inline-end: calc(-1 * var(--pui-space-0-5));\n    border-start-end-radius: 0;\n    border-end-end-radius: 0;\n    clip-path: inset(0 1px 0 0);\n  }\n  .item:is([aria-pressed=\"true\"], [aria-checked=\"true\"]):has(\n      + .item:is([aria-pressed=\"true\"], [aria-checked=\"true\"])\n    ):dir(rtl)::before {\n    clip-path: inset(0 0 0 1px);\n  }\n  /* joined to the previous toggle */\n  .item:is([aria-pressed=\"true\"], [aria-checked=\"true\"])\n    + .item:is([aria-pressed=\"true\"], [aria-checked=\"true\"])::before {\n    inset-inline-start: calc(-1 * var(--pui-space-0-5));\n    border-start-start-radius: 0;\n    border-end-start-radius: 0;\n    clip-path: inset(0 0 0 1px);\n  }\n  .item:is([aria-pressed=\"true\"], [aria-checked=\"true\"])\n    + .item:is([aria-pressed=\"true\"], [aria-checked=\"true\"]):dir(rtl)::before {\n    clip-path: inset(0 1px 0 0);\n  }\n  /* joined on both sides */\n  .item:is([aria-pressed=\"true\"], [aria-checked=\"true\"])\n    + .item:is([aria-pressed=\"true\"], [aria-checked=\"true\"]):has(\n      + .item:is([aria-pressed=\"true\"], [aria-checked=\"true\"])\n    )::before {\n    clip-path: inset(0 1px);\n  }\n  .item:disabled {\n    opacity: var(--pui-opacity-disabled);\n    pointer-events: none;\n  }\n\n  /* one choice: a single pressed well under the toggles travels to the new choice as matter (ui/lib/contour.ts, placed\n     by the contour engine like the segmented thumb); the toggles' own wells stand aside */\n  .well {\n    position: absolute;\n    z-index: -1;\n    top: 0;\n    left: 0;\n    border-radius: calc(var(--pui-radius-control) - 2px);\n    background: var(--m-inset-shade), var(--pui-inset);\n    box-shadow: var(--m-pressed-rim, 0 0 transparent), var(--m-inset-edge);\n    pointer-events: none;\n  }\n  .root[data-type=\"single\"] .item::before {\n    display: none;\n  }\n  .root[data-type=\"single\"] .item {\n    isolation: auto;\n  }\n  .root[data-type=\"single\"] .item:hover:is([aria-pressed=\"true\"], [aria-checked=\"true\"]) {\n    background: transparent;\n  }\n  .item :where(svg) {\n    width: var(--pui-icon-md);\n    height: var(--pui-icon-md);\n  }\n}\n"},{"path":"beamline/components/toggle-group/toggle-group.tsx","type":"registry:file","target":"src/ui/beamline/components/toggle-group/toggle-group.tsx","content":"\"use client\";\n\nimport { useDeprecatedProp } from \"../../hooks/use-deprecated-prop\";\n\nimport { useComponentDefaults } from \"../../runtime/appearance\";\nimport type { ToggleGroupDefaults } from \"./defaults\";\nexport type { ToggleGroupDefaults } from \"./defaults\";\n\nimport type { ComponentProps, ReactNode } from \"react\";\nimport * as RadixToggleGroup from \"@radix-ui/react-toggle-group\";\nimport { Tooltip } from \"../tooltip/tooltip\";\nimport { useComposedRef } from \"../../hooks/use-composed-ref\";\nimport { useContour } from \"../../hooks/use-contour\";\nimport { useIndicator } from \"../../hooks/use-indicator\";\nimport { cn } from \"../../lib/utils\";\nimport styles from \"./toggle-group.module.css\";\n\ntype Variant = \"ghost\" | \"outline\";\ntype Size = \"sm\" | \"md\" | \"lg\";\n\nexport type ToggleGroupProps = ComponentProps<typeof RadixToggleGroup.Root> & {\n  /** Visual weight; defaults to ghost. @deprecated The value \"default\" aliases \"ghost\"; use \"ghost\" instead. */\n  variant?: Variant | \"default\";\n  /** Control size; defaults to md. @deprecated The value \"default\" aliases \"md\"; use \"md\" instead. */\n  size?: Size | \"default\";\n};\n\n/**\n * Pressable toggles where one (type=\"single\") or several (type=\"multiple\") can be on: alignment, bold / italic,\n * view options. ← → move between them; Space or Enter presses. A toggle that is on sits pressed in: with one choice the\n * pressed well travels to the new one as matter; with several, neighbours that are both on merge into one run.\n */\nexport function ToggleGroup({\n  variant: variantProp,\n  size: sizeProp,\n  className,\n  children,\n  ref,\n  ...props\n}: ToggleGroupProps) {\n  const scopeDefaults = useComponentDefaults<ToggleGroupDefaults>(\"toggle-group\", [\"variant\", \"size\"]);\n  const variant = variantProp ?? scopeDefaults.variant ?? \"ghost\";\n  const size = sizeProp ?? scopeDefaults.size ?? \"md\";\n\n  useDeprecatedProp(\"ToggleGroup\", 'variant=\"default\"', 'variant=\"ghost\"', variant === \"default\");\n  useDeprecatedProp(\"ToggleGroup\", 'size=\"default\"', 'size=\"md\"', size === \"default\");\n  const look = variant === \"default\" ? \"ghost\" : variant;\n  const scale = size === \"default\" ? \"md\" : size;\n  const single = props.type === \"single\";\n  // one choice: a single pressed well follows it (the segmented thumb's contour), so a change travels instead of\n  // fading out here and in there\n  const [root, well] = useIndicator<HTMLDivElement>(\"[data-slot=toggle-group-item][aria-checked=true]\", single);\n  const wellRef = useContour<HTMLSpanElement>(single ? well : null);\n  const attach = useComposedRef(root, ref);\n  return (\n    <RadixToggleGroup.Root\n      ref={attach}\n      data-slot=\"toggle-group\"\n      data-variant={look}\n      data-size={scale}\n      data-type={props.type}\n      className={cn(styles.root, look === \"outline\" && styles.outline, scale !== \"md\" && styles[scale], className)}\n      {...props}\n    >\n      {single && well && <span ref={wellRef} aria-hidden data-slot=\"toggle-group-well\" className={styles.well} />}\n      {children}\n    </RadixToggleGroup.Root>\n  );\n}\n\nexport type ToggleGroupItemProps = ComponentProps<typeof RadixToggleGroup.Item> & {\n  /** What the toggle does, in a few words, shown on hover and focus; it also names an icon-only toggle. */\n  tooltip?: ReactNode;\n  /** A shortcut shown in the tooltip, e.g. \"⌘B\". */\n  shortcut?: string;\n};\n\nexport function ToggleGroupItem({ className, tooltip, shortcut, ...props }: ToggleGroupItemProps) {\n  const item = (\n    <RadixToggleGroup.Item\n      data-slot=\"toggle-group-item\"\n      aria-label={props[\"aria-label\"] ?? (typeof tooltip === \"string\" ? tooltip : undefined)}\n      className={cn(styles.item, className)}\n      {...props}\n    />\n  );\n  if (tooltip == null) return item;\n  return (\n    <Tooltip content={tooltip} shortcut={shortcut}>\n      {item}\n    </Tooltip>\n  );\n}\n\nexport default ToggleGroup;\n"},{"path":"beamline/components/tooltip/defaults.ts","type":"registry:file","target":"src/ui/beamline/components/tooltip/defaults.ts","content":"/** Pure allowed presentation defaults for Tooltip; no component or runtime imports. */\nexport interface TooltipDefaults {\n  /** Shared align setting; omit to inherit the surrounding scope or the component default. */\n  align?: \"start\" | \"center\" | \"end\";\n}\n"},{"path":"beamline/components/tooltip/tooltip.module.css","type":"registry:file","target":"src/ui/beamline/components/tooltip/tooltip.module.css","content":"@layer properties, theme, base, components, utilities;\n@layer components {\n  /* A tooltip arrives from its control: it starts a step toward the control on the side it opens on and moves away\n     into place as it fades in (--pui-motion-in), so on any side it reads as coming out of what it explains. Inside a\n     group, the next one opens at once where the last one stood and travels to its own control (--pui-duration-fast),\n     while the last one goes in the arrival time: one tooltip moving along the toolbar, not two blinking. It leaves\n     over the departure fade. Reduced motion keeps the fades and drops the travel (--pui-motion-travel is 0). */\n  .tip {\n    --_dx: 0px;\n    --_dy: 0px;\n    --_tx: 0px;\n    --_ty: 0px;\n    z-index: var(--pui-z-tooltip);\n    transform-origin: var(--radix-tooltip-content-transform-origin);\n  }\n  .tip[data-side=\"top\"] {\n    --_dy: var(--pui-space-1);\n  }\n  .tip[data-side=\"bottom\"] {\n    --_dy: calc(-1 * var(--pui-space-1));\n  }\n  .tip[data-side=\"left\"] {\n    --_dx: var(--pui-space-1);\n  }\n  .tip[data-side=\"right\"] {\n    --_dx: calc(-1 * var(--pui-space-1));\n  }\n  .tip[data-state=\"delayed-open\"] {\n    animation: tip-in var(--pui-motion-in) var(--pui-ease-default);\n  }\n  .tip[data-state=\"instant-open\"] {\n    animation: tip-fade var(--pui-fade-in) var(--pui-ease-default);\n  }\n  .tip[data-state=\"instant-open\"][data-travel] {\n    animation: tip-travel var(--pui-duration-fast) var(--pui-ease-standard);\n  }\n  .tip[data-state=\"closed\"] {\n    animation: tip-out var(--pui-fade-out) var(--pui-ease-default) forwards;\n  }\n  .tip[data-grouped][data-state=\"closed\"] {\n    animation-duration: var(--pui-fade-in);\n  }\n}\n@keyframes tip-in {\n  from {\n    opacity: 0;\n    translate: calc(var(--_dx) * var(--pui-motion-travel, 1)) calc(var(--_dy) * var(--pui-motion-travel, 1));\n  }\n}\n@keyframes tip-fade {\n  from {\n    opacity: 0;\n  }\n}\n@keyframes tip-travel {\n  from {\n    translate: calc(var(--_tx) * var(--pui-motion-travel, 1)) calc(var(--_ty) * var(--pui-motion-travel, 1));\n  }\n}\n@keyframes tip-out {\n  to {\n    opacity: 0;\n  }\n}\n"},{"path":"beamline/components/tooltip/tooltip.tsx","type":"registry:file","target":"src/ui/beamline/components/tooltip/tooltip.tsx","content":"\"use client\";\n\nimport { useComponentDefaults } from \"../../runtime/appearance\";\nimport type { TooltipDefaults } from \"./defaults\";\nexport type { TooltipDefaults } from \"./defaults\";\n\nimport {\n  createContext,\n  useContext,\n  useRef,\n  useState,\n  type CSSProperties,\n  type Ref,\n  type ReactElement,\n  type ReactNode,\n  type RefObject,\n} from \"react\";\nimport * as RadixTooltip from \"@radix-ui/react-tooltip\";\nimport { usePortalContainer } from \"../../runtime/appearance\";\nimport { cn } from \"../../lib/utils\";\nimport styles from \"./tooltip.module.css\";\n\n/** How long after one tooltip of a group closes the next opens at once (and travels from where the last one was). */\nconst SKIP = 400;\n/** The last control of a group whose tooltip showed: its centre and when its tooltip opened or closed. */\ntype Last = { el: Element; x: number; y: number; at: number };\nconst Grouped = createContext<RefObject<Last | null> | null>(null);\n\n/** Tooltips inside a group open instantly one after another (a toolbar): only the first waits, and each next one\n *  travels from where the last one stood. */\nexport function TooltipGroup({\n  children,\n  delay = 500,\n}: {\n  /** Content rendered inside the component. Required. */\n  children: ReactNode;\n  /** Milliseconds before the first tooltip in the group opens. Defaults to 500. */\n  delay?: number;\n}) {\n  const last = useRef<Last | null>(null);\n  return (\n    <RadixTooltip.Provider delayDuration={delay} skipDelayDuration={SKIP}>\n      <Grouped.Provider value={last}>{children}</Grouped.Provider>\n    </RadixTooltip.Provider>\n  );\n}\n\nexport interface TooltipClassNames {\n  /** Classes for the root part; no override by default. */\n  root?: string;\n  /** Classes for the trigger part; no override by default. */\n  trigger?: string;\n  /** Classes for the shortcut part; no override by default. */\n  shortcut?: string;\n}\n\nexport interface TooltipProps {\n  /** What the control does; a few words. */\n  content: ReactNode;\n  /** A keyboard shortcut shown after the text, e.g. \"⌘B\". */\n  shortcut?: string;\n  /** The control: one element that can take a ref (a button). */\n  children: ReactElement;\n  /** Edge from which the panel or anchored content opens. Defaults to \"top\". */\n  side?: \"top\" | \"right\" | \"bottom\" | \"left\";\n  /** Alignment within the available space. Defaults to \"center\". */\n  align?: \"start\" | \"center\" | \"end\";\n  /** Open state, controlled or uncontrolled; the tooltip opens on hover and on keyboard focus either way. */\n  open?: boolean;\n  /** Initial open state when uncontrolled. Defaults to false. */\n  defaultOpen?: boolean;\n  /** Reports open state after a change; no callback by default. */\n  onOpenChange?: (open: boolean) => void;\n  /** Classes on the documented visual root; no override by default. */\n  className?: string;\n  /** Classes for the named visual parts; no part overrides by default. */\n  classNames?: TooltipClassNames;\n  /** Inline styles on the documented visual root; no inline overrides by default. */\n  style?: CSSProperties;\n  /** Receives the documented root element; no ref by default. */\n  ref?: Ref<HTMLDivElement>;\n}\n\n/**\n * Short supporting text for a control: it opens on hover after a moment and at once on keyboard focus, and closes on\n * Escape. It arrives out of its control on whichever side it opens. Inside a TooltipGroup the next one opens instantly\n * and travels from where the last one stood. Never put essential information or anything clickable in a tooltip.\n */\nexport function Tooltip({\n  content,\n  shortcut,\n  children,\n  side = \"top\",\n  align: alignProp,\n  open,\n  defaultOpen,\n  onOpenChange,\n  className,\n  classNames,\n  style,\n  ref,\n}: TooltipProps) {\n  const scopeDefaults = useComponentDefaults<TooltipDefaults>(\"tooltip\", [\"align\"]);\n  const align = alignProp ?? scopeDefaults.align ?? \"center\";\n\n  const group = useContext(Grouped);\n  const container = usePortalContainer();\n  const trigger = useRef<HTMLButtonElement>(null); // the control, whatever element it is (Radix types it as a button)\n  // in a group, how far this tooltip is from the last one, so it can start there and travel to its own control\n  const [travel, setTravel] = useState<{ x: number; y: number } | null>(null);\n  const change = (next: boolean) => {\n    const el = trigger.current;\n    if (group && el) {\n      const r = el.getBoundingClientRect();\n      const x = r.left + r.width / 2;\n      const y = r.top + r.height / 2;\n      const last = group.current;\n      if (next) {\n        const near = last && last.el !== el && performance.now() - last.at < SKIP;\n        setTravel(near ? { x: last.x - x, y: last.y - y } : null);\n        group.current = { el, x, y, at: Infinity };\n      } else if (last?.el === el) last.at = performance.now();\n    }\n    onOpenChange?.(next);\n  };\n  const tip = (\n    <RadixTooltip.Root open={open} defaultOpen={defaultOpen} onOpenChange={change}>\n      <RadixTooltip.Trigger ref={trigger} asChild data-slot=\"tooltip-trigger\" className={classNames?.trigger}>\n        {children}\n      </RadixTooltip.Trigger>\n      {container !== null && (\n        <RadixTooltip.Portal container={container}>\n          <RadixTooltip.Content\n            data-slot=\"tooltip\"\n            data-grouped={group ? \"\" : undefined}\n            data-travel={travel ? \"\" : undefined}\n            style={travel ? ({ \"--_tx\": `${travel.x}px`, \"--_ty\": `${travel.y}px`, ...style } as CSSProperties) : style}\n            ref={ref}\n            side={side}\n            align={align}\n            sideOffset={6}\n            collisionPadding={8}\n            className={cn(\n              \"flex max-w-[min(260px,calc(100vw-16px))] items-center gap-2 rounded-chip bg-tooltip px-2 py-1 text-xs leading-snug text-tooltip-fg shadow-overlay\",\n              styles.tip,\n              classNames?.root,\n              className,\n            )}\n          >\n            {content}\n            {shortcut && (\n              <kbd\n                data-slot=\"tooltip-shortcut\"\n                className={cn(\"font-mono text-2xs text-[var(--pui-tooltip-muted)]\", classNames?.shortcut)}\n              >\n                {shortcut}\n              </kbd>\n            )}\n          </RadixTooltip.Content>\n        </RadixTooltip.Portal>\n      )}\n    </RadixTooltip.Root>\n  );\n  return group ? tip : <RadixTooltip.Provider delayDuration={500}>{tip}</RadixTooltip.Provider>;\n}\n\nexport default Tooltip;\n"},{"path":"beamline/hooks/use-active.ts","type":"registry:file","target":"src/ui/beamline/hooks/use-active.ts","content":"\"use client\";\n\nimport { useContext, useEffect, useState, type RefObject } from \"react\";\n\nimport { ActivityContext } from \"../runtime/activity\";\n\n/**\n * Whether an animated element should be doing work: it is (nearly) on screen and the tab is visible. Every\n * continuously animated component gates its loop, shader or CSS animation on this, so an effect scrolled out of view,\n * behind another tab, or in a collapsed panel costs nothing. One IntersectionObserver per element; no polling.\n */\nexport function useActive(\n  ref: RefObject<Element | null>,\n  {\n    margin = \"120px\",\n    key,\n    idle = true,\n  }: {\n    margin?: string;\n    /** Re-attach when this changes (an element that mounts later). */\n    key?: unknown;\n    /** Pause continuous work at the host idle boundary. Finite sequences set false so they finish. */\n    idle?: boolean;\n  } = {},\n) {\n  const active = useContext(ActivityContext);\n  const [inView, setInView] = useState(false);\n  const [visible, setVisible] = useState(\n    () => typeof document === \"undefined\" || document.visibilityState === \"visible\",\n  );\n  useEffect(() => {\n    const el = ref.current;\n    if (!el || typeof IntersectionObserver === \"undefined\") {\n      setInView(true);\n      return;\n    }\n    const io = new IntersectionObserver(([e]) => setInView(e.isIntersecting), { rootMargin: margin });\n    io.observe(el);\n    return () => io.disconnect();\n  }, [ref, margin, key]);\n  useEffect(() => {\n    const on = () => setVisible(document.visibilityState === \"visible\");\n    document.addEventListener(\"visibilitychange\", on);\n    return () => document.removeEventListener(\"visibilitychange\", on);\n  }, []);\n  return (!idle || active) && inView && visible;\n}\n"},{"path":"beamline/hooks/use-composed-ref.ts","type":"registry:file","target":"src/ui/beamline/hooks/use-composed-ref.ts","content":"\"use client\";\n\nimport { useCallback, type Ref, type RefObject } from \"react\";\n\n/** Keep a control's measurement/focus ref and the caller's ref, including React 19 callback cleanup. */\nexport function useComposedRef<T>(internal: RefObject<T | null>, external?: Ref<T>) {\n  return useCallback(\n    (node: T | null) => {\n      internal.current = node;\n      if (typeof external === \"function\") {\n        const cleanup = external(node);\n        if (typeof cleanup === \"function\")\n          return () => {\n            internal.current = null;\n            cleanup();\n          };\n      } else if (external) external.current = node;\n    },\n    [internal, external],\n  );\n}\n"},{"path":"beamline/hooks/use-content-width.ts","type":"registry:file","target":"src/ui/beamline/hooks/use-content-width.ts","content":"\"use client\";\n\nimport { useLayoutEffect, useRef, useState, type RefObject } from \"react\";\n\nconst same = (width: number) => width;\n\n/**\n * The width of an element's content box, kept current with a ResizeObserver. It is first read in a layout effect, so\n * a layout chosen by width (a narrow mode, a chart's scale) is right in the first frame instead of jumping a frame\n * later. `fallback` stands in on the server and until the element exists; `key` re-measures when the element is\n * replaced (one that exists only in one view).\n */\nexport function useContentWidth(ref: RefObject<HTMLElement | null>, fallback: number, key?: unknown): number {\n  return useWidthAs(ref, same, fallback, key);\n}\n\n/**\n * The same width, kept as what a part needs from it (`(w) => w < 640` for a narrow mode): the part renders again only\n * when that changes, not at every pixel.\n */\nexport function useWidthAs<T>(\n  ref: RefObject<HTMLElement | null>,\n  read: (width: number) => T,\n  fallback: T,\n  key?: unknown,\n): T {\n  const [value, setValue] = useState(fallback);\n  const latest = useRef(read);\n  latest.current = read;\n  useLayoutEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    // the computed width is fractional and ignores transforms, like the observer's content box\n    const s = getComputedStyle(el);\n    const edges = [\"paddingLeft\", \"paddingRight\", \"borderLeftWidth\", \"borderRightWidth\"] as const;\n    const box = parseFloat(s.width);\n    const outer = Number.isFinite(box) ? box : el.offsetWidth;\n    const inner =\n      Number.isFinite(box) && s.boxSizing !== \"border-box\" ? 0 : edges.reduce((w, k) => w + parseFloat(s[k]), 0);\n    setValue(latest.current(outer - inner));\n    if (typeof ResizeObserver === \"undefined\") return;\n    const ro = new ResizeObserver(([e]) => setValue(latest.current(e.contentRect.width)));\n    ro.observe(el);\n    return () => ro.disconnect();\n  }, [ref, key]);\n  return value;\n}\n\n/**\n * The height of an element's content box, kept current like `useContentWidth`: for parts that lay out at whatever\n * height their parent gives them (a chart, a map or a book that fills its panel). Read in a layout effect, so the first\n * frame is right; with `enabled` false nothing is measured and the fallback stands.\n */\nexport function useContentHeight(\n  ref: RefObject<HTMLElement | null>,\n  fallback: number,\n  key?: unknown,\n  enabled = true,\n): number {\n  const [value, setValue] = useState(fallback);\n  useLayoutEffect(() => {\n    const el = ref.current;\n    if (!enabled || !el) return;\n    const s = getComputedStyle(el);\n    setValue(el.clientHeight - (parseFloat(s.paddingTop) || 0) - (parseFloat(s.paddingBottom) || 0));\n    if (typeof ResizeObserver === \"undefined\") return;\n    const ro = new ResizeObserver(([e]) => setValue(e.contentRect.height));\n    ro.observe(el);\n    return () => ro.disconnect();\n  }, [ref, key, enabled]);\n  return enabled ? value : fallback;\n}\n"},{"path":"beamline/hooks/use-contour.ts","type":"registry:file","target":"src/ui/beamline/hooks/use-contour.ts","content":"\"use client\";\n\nimport { useCallback, useLayoutEffect, useRef } from \"react\";\nimport { createContour, type Contour } from \"../lib/contour\";\nimport type { IndicatorBox } from \"./use-indicator\";\n\n/**\n * Puts a decorative surface (a segmented thumb, a tab's pill or line) on the contour engine and moves it to `box`\n * whenever the box changes: the first placement is instant, later ones travel as matter (ui/lib/contour.ts). Returns a\n * ref for the surface. The surface stays aria-hidden; the control's own state has already changed by the time it moves.\n */\nexport function useContour<T extends HTMLElement>(box: IndicatorBox | null) {\n  const contour = useRef<Contour | null>(null);\n  const ref = useCallback((el: T | null) => {\n    contour.current?.destroy();\n    contour.current = el ? createContour(el) : null;\n  }, []);\n  useLayoutEffect(() => {\n    // a choice travels; the first placement and a reflow of the same choice are simply there\n    if (box) contour.current?.to(box, { instant: !box.ready || box.cause === \"layout\" });\n  }, [box]);\n  return ref;\n}\n"},{"path":"beamline/hooks/use-controllable.ts","type":"registry:file","target":"src/ui/beamline/hooks/use-controllable.ts","content":"\"use client\";\n\nimport { useCallback, useRef, useState } from \"react\";\n\n/**\n * One value in both forms (rules/CONVENTIONS.md): the prop while it is passed, otherwise the element's own copy that\n * starts at `initial` (a value, or a function that makes it once). The setter takes a value or an updater; an updater\n * reads the latest value even twice in one event, and every change reaches `onChange`, controlled or not.\n * `Next` is what a change can carry when it is narrower than the state: a range that starts empty (null) but is only\n * ever changed to a range.\n */\nexport function useControllable<T, Next extends T = T>(\n  value: T | undefined,\n  initial: T | (() => T),\n  onChange?: (next: Next) => void,\n) {\n  const [own, setOwn] = useState<T>(initial);\n  const current = value !== undefined ? value : own;\n  const latest = useRef(current);\n  latest.current = current;\n  const set = useCallback(\n    (next: Next | ((was: T) => Next)) => {\n      const resolved = typeof next === \"function\" ? (next as (was: T) => Next)(latest.current) : next;\n      latest.current = resolved;\n      if (value === undefined) setOwn(resolved);\n      onChange?.(resolved);\n    },\n    [value, onChange],\n  );\n  return [current, set] as const;\n}\n"},{"path":"beamline/hooks/use-deprecated-prop.ts","type":"registry:file","target":"src/ui/beamline/hooks/use-deprecated-prop.ts","content":"\"use client\";\n\nimport { useEffect } from \"react\";\n\n// Bundlers replace NODE_ENV for browser builds; this declaration emits no Node dependency.\ndeclare const process: { env: { NODE_ENV?: string } };\n\nconst warned = new Set<string>();\n\n/** Report a legacy prop once after mount in development; production and server renders stay silent. */\nexport function useDeprecatedProp(component: string, prop: string, replacement: string, supplied: boolean) {\n  useEffect(() => {\n    if (process.env.NODE_ENV !== \"development\" || !supplied) return;\n    const key = `${component}.${prop}`;\n    if (warned.has(key)) return;\n    warned.add(key);\n    console.warn(`[Beamline] ${key} is deprecated. Use ${replacement} instead; the legacy prop still works.`);\n  }, [component, prop, replacement, supplied]);\n}\n"},{"path":"beamline/hooks/use-drag.ts","type":"registry:file","target":"src/ui/beamline/hooks/use-drag.ts","content":"\"use client\";\n\nimport { useEffect, useRef, useState, type RefObject } from \"react\";\nimport { VelocityTracker } from \"../lib/gesture\";\n\n/** Where the pointer is during a drag, relative to where it was pressed, with its velocity (px/s) over the last 100 ms. */\nexport interface DragPoint {\n  /** Pointer position in client coordinates. */\n  x: number;\n  y: number;\n  /** Distance from the press. */\n  dx: number;\n  dy: number;\n  /** Velocity in px/s (read from the last 100 ms, so a release carries the flick, not the whole drag). */\n  vx: number;\n  vy: number;\n  pointerType: string;\n  /** Shift was held (a part may offer a second mode on it: move one task alone, a finer step). */\n  shift: boolean;\n}\n\nexport interface DragHandlers {\n  /** A press landed on the element. Return false to leave it alone (a press on a nested button or link). */\n  onPress?: (point: DragPoint, event: PointerEvent) => boolean | void;\n  /** The pointer moved past the threshold: the drag begins (the press point is in `point.x - point.dx`). */\n  onStart?: (point: DragPoint) => void;\n  /** The pointer moved during a drag. `event` is the browser's own, for what a point does not carry: a pen's pressure,\n   *  the coalesced samples a fast stroke packs into one event (a drawing surface). */\n  onMove?: (point: DragPoint, event: PointerEvent) => void;\n  /** Released after a drag, with the release velocity. */\n  onEnd?: (point: DragPoint) => void;\n  /** Released without moving past the threshold: a tap or click (the part's tap route, WCAG 2.5.7). */\n  onTap?: (point: DragPoint) => void;\n  /** Escape, a lost pointer or the browser taking the gesture (a page scroll): put things back as they were. */\n  onCancel?: () => void;\n  /** A press that ended as neither a drag nor a tap: a finger that went on to scroll the page, or a pointer the browser\n   *  took before the threshold. Undo whatever `onPress` prepared. */\n  onAbandon?: () => void;\n}\n\nexport interface DragOptions {\n  /** The axis the part moves on. On touch, a drag that starts mostly across it is left to the page (a scroll). */\n  axis?: \"x\" | \"y\" | \"both\";\n  /** Pixels before a press becomes a drag: 3 for a mouse, 8 for a finger or pen unless given. */\n  threshold?: number;\n  disabled?: boolean;\n}\n\n/**\n * The pointer side of a hand on a part, shared by everything dragged, thrown or pulled (a thumb, a puck, a stub, a\n * task, a cable). It listens natively on the element, so moves never render React: the part writes positions in its\n * handlers (a spring, a transform, a custom property) and only `dragging`, which changes at the start and end, is\n * state (for `data-state`).\n *\n * A press becomes a drag past a small threshold, then the pointer is captured so the drag continues outside the\n * element; a release without moving is a tap (`onTap`), the route every drag needs for people who cannot drag. Escape,\n * `pointercancel` and a lost capture call `onCancel`, and the part restores what it showed before the press. On touch the\n * element needs a `touch-action` that leaves the other axis to the page (`pan-y` for a part dragged sideways; never\n * `none` on more than the dragged surface, which would block zoom), and a drag that starts across its axis is dropped\n * so the page can scroll.\n */\nexport function useDrag<T extends HTMLElement | SVGElement>(\n  ref: RefObject<T | null>,\n  handlers: DragHandlers,\n  { axis = \"both\", threshold, disabled = false }: DragOptions = {},\n): { dragging: boolean } {\n  const [dragging, setDragging] = useState(false);\n  const latest = useRef(handlers);\n  latest.current = handlers;\n\n  useEffect(() => {\n    // an SVG part (a chart's brush) is dragged the same way; its pointer events are typed as an HTML element's\n    const el = ref.current as HTMLElement | null;\n    if (!el || disabled) return;\n    const doc = el.ownerDocument;\n    // Escape during a drag belongs to the drag: listened on the window's capture phase, it runs before any dialog or\n    // popover listening on the document, which would otherwise also close around the cancelled drag\n    const win = doc.defaultView ?? window;\n    let active: {\n      id: number;\n      x0: number;\n      y0: number;\n      type: string;\n      started: boolean;\n      tracker: VelocityTracker;\n    } | null = null;\n\n    const point = (e: PointerEvent): DragPoint => {\n      const a = active!;\n      const [vx, vy] = a.tracker.velocity(e.timeStamp);\n      return {\n        x: e.clientX,\n        y: e.clientY,\n        dx: e.clientX - a.x0,\n        dy: e.clientY - a.y0,\n        vx,\n        vy,\n        pointerType: e.pointerType,\n        shift: e.shiftKey,\n      };\n    };\n\n    const finish = () => {\n      if (active?.started && el.hasPointerCapture?.(active.id)) el.releasePointerCapture(active.id);\n      active = null;\n      doc.removeEventListener(\"pointermove\", move);\n      doc.removeEventListener(\"pointerup\", up);\n      doc.removeEventListener(\"pointercancel\", cancel);\n      win.removeEventListener(\"keydown\", key, true);\n      doc.removeEventListener(\"selectstart\", hold, true);\n      doc.removeEventListener(\"dragstart\", hold, true);\n      el.removeEventListener(\"lostpointercapture\", lost);\n      setDragging(false);\n    };\n\n    const cancel = () => {\n      if (!active) return;\n      const started = active.started;\n      finish();\n      if (started) latest.current.onCancel?.();\n      else latest.current.onAbandon?.();\n    };\n\n    // only the part's own capture ending cancels: a finger's press is captured by the child it landed on, and moving\n    // the capture to the part fires lostpointercapture on that child, which bubbles here\n    const lost = (e: PointerEvent) => {\n      if (e.target === el && active?.started && e.pointerId === active.id) cancel();\n    };\n\n    const key = (e: KeyboardEvent) => {\n      if (e.key !== \"Escape\" || !active?.started) return;\n      e.preventDefault();\n      e.stopImmediatePropagation();\n      cancel();\n    };\n\n    // while the hand holds the part, the page neither selects text nor starts its own drag and drop (a selection left\n    // by an earlier drag would otherwise be dragged, and the browser cancels the pointer)\n    const hold = (e: Event) => e.preventDefault();\n\n    const move = (e: PointerEvent) => {\n      if (!active || e.pointerId !== active.id) return;\n      active.tracker.add(e.timeStamp, e.clientX, e.clientY);\n      const p = point(e);\n      if (!active.started) {\n        const limit = threshold ?? (active.type === \"mouse\" ? 3 : 8);\n        if (Math.hypot(p.dx, p.dy) < limit) return;\n        // a finger that starts across the part's axis is scrolling the page\n        const across = axis === \"x\" ? Math.abs(p.dy) > Math.abs(p.dx) : axis === \"y\" && Math.abs(p.dx) > Math.abs(p.dy);\n        if (active.type !== \"mouse\" && across) {\n          finish();\n          latest.current.onAbandon?.();\n          return;\n        }\n        active.started = true;\n        doc.getSelection()?.removeAllRanges();\n        el.setPointerCapture?.(active.id);\n        el.addEventListener(\"lostpointercapture\", lost);\n        setDragging(true);\n        latest.current.onStart?.(p);\n      }\n      latest.current.onMove?.(p, e);\n    };\n\n    const up = (e: PointerEvent) => {\n      if (!active || e.pointerId !== active.id) return;\n      active.tracker.add(e.timeStamp, e.clientX, e.clientY);\n      const p = point(e);\n      const started = active.started;\n      finish();\n      if (started) latest.current.onEnd?.(p);\n      else latest.current.onTap?.(p);\n    };\n\n    const down = (e: PointerEvent) => {\n      if (active || !e.isPrimary || (e.pointerType === \"mouse\" && e.button !== 0)) return;\n      const tracker = new VelocityTracker();\n      tracker.add(e.timeStamp, e.clientX, e.clientY);\n      active = { id: e.pointerId, x0: e.clientX, y0: e.clientY, type: e.pointerType, started: false, tracker };\n      if (latest.current.onPress?.(point(e), e) === false) {\n        active = null;\n        return;\n      }\n      doc.addEventListener(\"pointermove\", move);\n      doc.addEventListener(\"pointerup\", up);\n      doc.addEventListener(\"pointercancel\", cancel);\n      win.addEventListener(\"keydown\", key, true);\n      doc.addEventListener(\"selectstart\", hold, true);\n      doc.addEventListener(\"dragstart\", hold, true);\n    };\n\n    el.addEventListener(\"pointerdown\", down);\n    return () => {\n      el.removeEventListener(\"pointerdown\", down);\n      if (active) finish();\n    };\n  }, [ref, axis, threshold, disabled]);\n\n  return { dragging };\n}\n"},{"path":"beamline/hooks/use-fit.ts","type":"registry:file","target":"src/ui/beamline/hooks/use-fit.ts","content":"\"use client\";\n\nimport { useLayoutEffect, useRef, useState, type RefObject } from \"react\";\n\n/**\n * How many of a row's items fit its room: the one fold every element that lists things in a line uses (chips,\n * avatars, breadcrumbs, filters, tags, actions), so a narrow panel shows fewer and a \"+N\" for the rest, and the rest\n * come back as the room grows. Content-sized items keep their natural width; the row decides how many. Items never\n * change order (a fold that reshuffles breaks the reader's memory of where things are): the last ones fold first.\n *\n * Mark each item `data-fit-item` (direct children of the row) and the overflow control (the \"+N\") `data-fit-more`.\n * Every item is measured once at its natural width — all of them render on the first pass and again whenever `items`\n * or `key` changes, read in a layout effect, so nothing is painted half-measured — and then each change of the row's\n * width lays the widths out with the row's own column gap into `lines` lines, keeping room on the last line for the\n * overflow control. Nothing runs at rest: one ResizeObserver on the row.\n *\n * `key` names the item set and must be a stable primitive (a string of the items' ids and labels), never an array or\n * object built during render: a new identity each render would measure again each render, for ever.\n * `keep[i]` marks items that always show (a chosen chip, the current crumb); room for them is taken first.\n * Returns how many of the other items show, in order (all of them while measuring, when off, and when they fit).\n */\nexport function useFit(\n  row: RefObject<HTMLElement | null>,\n  {\n    items,\n    lines = 1,\n    enabled = true,\n    min = 1,\n    keep,\n    from = \"start\",\n  }: {\n    /** How many items there are; a change (or a different `key`) measures them again. */\n    items: number;\n    /** Lines the row may take before it folds. */\n    lines?: number;\n    enabled?: boolean;\n    /** Never show fewer than this many of the other items. */\n    min?: number;\n    keep?: readonly boolean[];\n    /** Which of the other items the room shows: the first that fit (start, the default: the last fold first), or the\n     *  last that fit (end: a breadcrumb folds the levels nearest the top and keeps the parent). The count returned is\n     *  how many show either way; the caller shows them from its end. */\n    from?: \"start\" | \"end\";\n  },\n  key?: string | number,\n): number {\n  const free = keep ? keep.filter((k) => !k).length : items;\n  const [count, setCount] = useState(free);\n  const widths = useRef<number[] | null>(null);\n  const moreWidth = useRef(0);\n  const measuring = useRef(true);\n  const kept = useRef(keep);\n  kept.current = keep;\n  const end = useRef(from === \"end\");\n  end.current = from === \"end\";\n  const recent = useRef<number[]>([]);\n  const last = useRef(free);\n\n  // a new set of items: show them all for one (unpainted) pass so their natural widths can be read\n  useLayoutEffect(() => {\n    widths.current = null;\n    measuring.current = true;\n    setCount(free);\n  }, [items, key, enabled, free]);\n\n  useLayoutEffect(() => {\n    const el = row.current;\n    if (!el || !enabled || typeof ResizeObserver === \"undefined\") return;\n    const layout = () => {\n      if (!widths.current) return;\n      const cs = getComputedStyle(el);\n      const gap = parseFloat(cs.columnGap) || 0;\n      const room = roomOf(el, cs) - (parseFloat(cs.paddingLeft) || 0) - (parseFloat(cs.paddingRight) || 0);\n      // counted from the end, the same placement is read backwards: the last items are the ones that stay\n      const w = end.current ? [...widths.current].reverse() : widths.current;\n      const k = end.current && kept.current ? [...kept.current].reverse() : kept.current;\n      let next = fit(w, room, gap, moreWidth.current, lines, min, k);\n      // a backstop: a row whose room still moves with its own fold (a layout the room reading can't see) settles on\n      // the folded side instead of flipping every frame\n      const now = performance.now();\n      const flips = recent.current.filter((t) => now - t < 500);\n      if (flips.length >= 6) next = Math.min(next, last.current);\n      if (next !== last.current) recent.current = [...flips, now];\n      last.current = next;\n      setCount((c) => (c === next ? c : next));\n    };\n    if (measuring.current) {\n      const found = [...el.querySelectorAll<HTMLElement>(\":scope > [data-fit-item]\")];\n      if (found.length >= items) {\n        widths.current = found.slice(0, items).map((n) => n.getBoundingClientRect().width);\n        const more = el.querySelector<HTMLElement>(\":scope > [data-fit-more]\");\n        // the \"+N\" is not on screen while everything fits: assume a short chip until it has been seen\n        moreWidth.current = more ? more.getBoundingClientRect().width : Math.max(moreWidth.current, 56);\n        measuring.current = false;\n      }\n    }\n    layout();\n    const observer = new ResizeObserver(() => {\n      const more = el.querySelector<HTMLElement>(\":scope > [data-fit-more]\");\n      if (more) moreWidth.current = more.getBoundingClientRect().width;\n      layout();\n    });\n    observer.observe(el);\n    // the room is the parent's line as much as the row's own box: a content-sized row only learns it can grow there\n    if (el.parentElement) observer.observe(el.parentElement);\n    return () => observer.disconnect();\n  });\n\n  return enabled ? count : free;\n}\n\n/**\n * The width a row may take: its own box, or, when it sits content-sized in a flex row (a tab row beside a title in a\n * space-between bar), the line's width less what shares that line with it. Read this way the room never depends on\n * how many items the row shows, so folding can't change the room it was decided by (and flip back).\n */\nfunction roomOf(el: HTMLElement, cs: CSSStyleDeclaration) {\n  const own = el.clientWidth;\n  const parent = el.parentElement;\n  if (!parent) return own;\n  const ps = getComputedStyle(parent);\n  if (!ps.display.includes(\"flex\") || !ps.flexDirection.startsWith(\"row\")) return own;\n  const box = el.getBoundingClientRect();\n  let others = 0;\n  let count = 0;\n  for (const sib of parent.children) {\n    if (sib === el || !(sib instanceof HTMLElement)) continue;\n    const ss = getComputedStyle(sib);\n    if (ss.position === \"absolute\" || ss.position === \"fixed\" || ss.display === \"none\") continue;\n    const r = sib.getBoundingClientRect();\n    // on the row's own line (a wrapped bar puts the others above or below)\n    if (r.bottom <= box.top + 0.5 || r.top >= box.bottom - 0.5) continue;\n    others += r.width + (parseFloat(ss.marginLeft) || 0) + (parseFloat(ss.marginRight) || 0);\n    count++;\n  }\n  const line =\n    parent.clientWidth -\n    (parseFloat(ps.paddingLeft) || 0) -\n    (parseFloat(ps.paddingRight) || 0) -\n    others -\n    count * (parseFloat(ps.columnGap) || 0) -\n    (parseFloat(cs.marginLeft) || 0) -\n    (parseFloat(cs.marginRight) || 0) -\n    // the line is measured outside the row's border; clientWidth is inside it\n    (parseFloat(cs.borderLeftWidth) || 0) -\n    (parseFloat(cs.borderRightWidth) || 0);\n  const cap = cs.maxWidth.endsWith(\"px\") ? parseFloat(cs.maxWidth) : Infinity;\n  return Math.max(own, Math.min(line, cap));\n}\n\n/**\n * How many of the items not kept fit, in order, when the shown ones are laid into `lines` lines of `room` with `gap`\n * between them and `more` kept free on the last line whenever something folds.\n */\nexport function fit(\n  widths: readonly number[],\n  room: number,\n  gap: number,\n  more: number,\n  lines: number,\n  min: number,\n  keep?: readonly boolean[],\n) {\n  const fits = (show: (i: number) => boolean, reserve: number) => {\n    let line = 1;\n    let x = 0;\n    for (let i = 0; i < widths.length; i++) {\n      if (!show(i)) continue;\n      const w = widths[i];\n      const cap = line === lines ? room - reserve : room;\n      const need = x === 0 ? w : x + gap + w;\n      if (need <= cap + 0.5) {\n        x = need;\n        continue;\n      }\n      if (x === 0 || line === lines) return false;\n      line++;\n      if (w > (line === lines ? room - reserve : room) + 0.5) return false;\n      x = w;\n    }\n    return true;\n  };\n  const rank: number[] = [];\n  let free = 0;\n  for (let i = 0; i < widths.length; i++) rank.push(keep?.[i] ? -1 : free++);\n  if (fits(() => true, 0)) return free;\n  // with items that always show, the floor is none of the others (they are what keeps the row from being empty)\n  const floor = keep?.some(Boolean) ? 0 : Math.min(min, free);\n  for (let n = free - 1; n > floor; n--) if (fits((i) => rank[i] < 0 || rank[i] < n, more + gap)) return n;\n  return floor;\n}\n"},{"path":"beamline/hooks/use-flip.ts","type":"registry:file","target":"src/ui/beamline/hooks/use-flip.ts","content":"\"use client\";\n\nimport { useLayoutEffect, useRef, type RefObject } from \"react\";\nimport { useMotionTokens } from \"./use-motion-tokens\";\nimport { cssEase } from \"../lib/motion-tokens\";\n\ntype Seen = { el: HTMLElement; x: number; y: number; w: number; h: number };\n\n/**\n * Items of a collection keep their path (the morph grammar's \"changes keep their size and their path\"): mark each item\n * with `data-flip=\"<stable key>\"` inside `container`. After a change, an item that is new grows in, items that moved\n * slide from where they were, and an item that left fades out as a ghost where it stood (a still copy, inert and\n * hidden from assistive tech, removed when it has faded). The data and focus change at once; only the picture\n * settles. Nothing runs at rest; reduced motion places at once. Positions are kept in the container's own content\n * (relative to it, plus its scroll) and read at rest, so neither a scroll of the page, nor a scroll of the container\n * itself, nor an item still settling reads as movement.\n *\n * `resize`: an item whose box changed size also scales from its old box (for marks without text, a bar or a segment, so a\n * new value glides on transforms instead of laying out every frame). `origin(key)`: an element a new item grows out of\n * (a ribbon's segment becoming a column, a shared chip dividing into pieces); with `originFirst` it applies on the\n * container's first render too, so a panel that opens unfolds its items from what was already on screen. `inner`: items\n * inside another item that lies outside the container (a merge's rows inside a card that moves itself) are this\n * container's own; nesting is judged inside the container only.\n */\nexport function useFlip(\n  container: RefObject<HTMLElement | null> | (() => HTMLElement | null),\n  {\n    ghost = true,\n    enter = true,\n    resize = false,\n    origin,\n    originFirst = false,\n    inner = false,\n  }: {\n    ghost?: boolean;\n    enter?: boolean;\n    resize?: boolean;\n    origin?: (key: string) => Element | null | undefined;\n    originFirst?: boolean;\n    inner?: boolean;\n  } = {},\n) {\n  const get = typeof container === \"function\" ? container : () => container.current;\n  // timing read at the container itself, found when the commit has attached it (a function container has no ref of its\n  // own; without a host the timing stayed unresolved where no UIRoot is around, then rendered again to say so)\n  const host =\n    typeof container === \"function\"\n      ? {\n          get current() {\n            return container();\n          },\n        }\n      : container;\n  const motion = useMotionTokens(host);\n  const last = useRef<Map<string, Seen> | null>(null);\n  const lastWidth = useRef(0);\n  const flying = useRef(new Set<Animation>());\n  // where every item stands, in the container's own content (relative to it, plus its scroll): a list scrolled since the\n  // last render has moved nothing (a row that slid back by the scroll would leave the finger that is tapping it). The\n  // items' own grow-ins and slides still in flight are lifted while they are read, so each box is where the layout puts\n  // it: a render mid-flight (a live price ticking while a new row grows in) is not a move.\n  const read = (root: HTMLElement) => {\n    const lifted = [...flying.current].map((a) => a.effect as KeyframeEffect).map((e) => [e, e.target] as const);\n    for (const [effect] of lifted) effect.target = null;\n    const box = root.getBoundingClientRect();\n    const now = new Map<string, Seen>();\n    for (const el of root.querySelectorAll<HTMLElement>(\"[data-flip]\")) {\n      // only the outermost items move (with `inner`, outermost inside this container)\n      const outer = el.parentElement?.closest(\"[data-flip]\");\n      if (outer && (!inner || (outer !== root && root.contains(outer)))) continue;\n      const r = el.getBoundingClientRect();\n      now.set(el.dataset.flip!, {\n        el,\n        x: r.left - box.left + root.scrollLeft,\n        y: r.top - box.top + root.scrollTop,\n        w: r.width,\n        h: r.height,\n      });\n    }\n    for (const [effect, target] of lifted) effect.target = target;\n    return { box, now };\n  };\n  // a container that changes size at rest, with no render (fonts arriving, a scrollbar appearing, a window resized), has\n  // its places read again then: else the first change after it would take the new width for a reflow and move nothing\n  const watched = useRef<{ el: HTMLElement; observer: ResizeObserver } | null>(null);\n  useLayoutEffect(() => () => watched.current?.observer.disconnect(), []);\n  // every render on purpose: a collection changes through its parent's state, not through anything we can depend on\n  useLayoutEffect(() => {\n    const root = get();\n    // a container that is gone (a panel folded) starts over when it comes back: its items are new, not moved\n    if (!root) {\n      last.current = null;\n      return;\n    }\n    if (watched.current?.el !== root && typeof ResizeObserver !== \"undefined\") {\n      watched.current?.observer.disconnect();\n      const observer = new ResizeObserver(() => {\n        if (flying.current.size || !last.current || !root.isConnected) return;\n        const seen = read(root);\n        last.current = seen.now;\n        lastWidth.current = seen.box.width;\n      });\n      observer.observe(root);\n      watched.current = { el: root, observer };\n    }\n    const { box, now } = read(root);\n    // a container that changed width since the last render reflowed its items by itself (a panel resized, a room\n    // step crossed): that is placement, not a change a person made, so this render records the new places and moves\n    // nothing (a reflow places, only a choice travels)\n    const reflowed = Math.abs(box.width - lastWidth.current) > 0.5;\n    lastWidth.current = box.width;\n    const before = reflowed ? null : last.current;\n    last.current = now;\n    const ms = motion.duration.standard * 1000;\n    // the first render moves nothing, except items that grow out of an origin already on screen\n    if ((!before && !(origin && originFirst)) || motion.reduced || ms < 2) return;\n    const easing = cssEase(motion.ease.standard, \"ease-out\");\n    // an item in flight says so (`data-flip-flight`: \"far\" when it crosses more than its own size, a slide between groups or\n    // a share growing out of another item; \"near\" for a neighbour's step), so a part can lift what travels over other\n    // text onto a surface of its own instead of drawing words over words\n    const fly = (el: HTMLElement, keyframes: Keyframe[], far = false) => {\n      const flight = el.animate(keyframes, { duration: ms, easing });\n      flying.current.add(flight);\n      if (far || el.dataset.flipFlight !== \"far\") el.dataset.flipFlight = far ? \"far\" : \"near\";\n      const land = () => {\n        flying.current.delete(flight);\n        if (![...flying.current].some((a) => (a.effect as KeyframeEffect | null)?.target === el))\n          delete el.dataset.flipFlight;\n      };\n      flight.finished.then(land, land);\n    };\n    const boxOf = (key: string) => {\n      const from = origin?.(key);\n      if (!from || !from.isConnected) return null;\n      const r = from.getBoundingClientRect();\n      return { x: r.left - box.left + root.scrollLeft, y: r.top - box.top + root.scrollTop, w: r.width, h: r.height };\n    };\n    // from a box to where the item stands: translate and scale about the top-left corner\n    const morph = (was: { x: number; y: number; w: number; h: number }, at: Seen): Keyframe[] => [\n      {\n        transformOrigin: \"0 0\",\n        transform: `translate(${was.x - at.x}px, ${was.y - at.y}px) scale(${was.w / Math.max(at.w, 0.5)}, ${was.h / Math.max(at.h, 0.5)})`,\n      },\n      { transformOrigin: \"0 0\", transform: \"none\" },\n    ];\n    for (const [key, at] of now) {\n      const was = before?.get(key);\n      if (!was) {\n        const from = boxOf(key);\n        if (from) fly(at.el, morph(from, at), true);\n        else if (enter && before)\n          fly(at.el, [\n            { opacity: 0, transform: \"scale(0.86)\" },\n            { opacity: 1, transform: \"none\" },\n          ]);\n        continue;\n      }\n      const dx = was.x - at.x,\n        dy = was.y - at.y;\n      const resized = resize && (Math.abs(was.w - at.w) > 0.5 || Math.abs(was.h - at.h) > 0.5);\n      const far = Math.abs(dx) > at.w * 0.5 || Math.abs(dy) > at.h * 1.5;\n      if (resized) fly(at.el, morph(was, at), far);\n      else if (Math.abs(dx) > 0.5 || Math.abs(dy) > 0.5)\n        fly(at.el, [{ transform: `translate(${dx}px, ${dy}px)` }, { transform: \"none\" }], far);\n    }\n    if (!ghost || !before) return;\n    for (const [key, was] of before) {\n      if (now.has(key) || was.el.isConnected) continue;\n      const copy = was.el.cloneNode(true) as HTMLElement;\n      copy.removeAttribute(\"data-flip\");\n      // the ghost is a picture of the item, not the item: nothing that finds parts by slot or id may find it\n      for (const n of [copy, ...copy.querySelectorAll(\"[id], [data-slot]\")]) {\n        n.removeAttribute(\"id\");\n        n.removeAttribute(\"data-slot\");\n      }\n      copy.setAttribute(\"data-ghost\", \"\");\n      copy.setAttribute(\"aria-hidden\", \"true\");\n      copy.inert = true;\n      if (getComputedStyle(root).position === \"static\") root.style.position = \"relative\";\n      Object.assign(copy.style, {\n        position: \"absolute\",\n        left: `${was.x}px`,\n        top: `${was.y}px`,\n        width: `${was.w}px`,\n        height: `${was.h}px`,\n        margin: \"0\",\n        pointerEvents: \"none\",\n      });\n      root.appendChild(copy);\n      // the ghost is gone by the time a neighbour slides into its place, so their texts never mix. The clock runs\n      // straight and an even curve shapes only the fade: the front-loaded standard curve on the whole timeline passed\n      // 0.45 inside the first frame, so what left read as a pop instead of a fade\n      const fade = copy.animate(\n        [\n          { opacity: 1, transform: \"none\", easing: cssEase(motion.ease.default, \"ease-in-out\") },\n          { opacity: 0, transform: \"scale(0.9)\", offset: 0.6 },\n          { opacity: 0, transform: \"scale(0.86)\" },\n        ],\n        {\n          duration: motion.duration.standard * 1000,\n          easing: \"linear\",\n        },\n      );\n      const drop = () => copy.remove();\n      fade.finished.then(drop, drop);\n      // and by the clock as well: a fade that never reports its end (the page hidden, an animation cancelled from\n      // outside) must not leave a copy behind for a person or a test to find\n      setTimeout(drop, motion.duration.standard * 1000 + 250);\n    }\n  });\n}\n"},{"path":"beamline/hooks/use-height-morph.ts","type":"registry:file","target":"src/ui/beamline/hooks/use-height-morph.ts","content":"\"use client\";\n\nimport { useLayoutEffect, useRef, type RefObject } from \"react\";\nimport { useMotionTokens } from \"./use-motion-tokens\";\nimport { cssEase } from \"../lib/motion-tokens\";\n\n/**\n * The step tray: a card whose content is replaced (a sign-in step, the sign-up card, a form step) keeps its path. When\n * `key` changes, the element's height eases from what it was to what the new content needs, so the card's edge and\n * everything under it glide instead of jumping (the morph grammar's \"modes change size in place\"). The element clips\n * while it eases, with room for focus rings, unless `clip` is false (a slot whose ease only moves what is around it, like\n * the auth page re-centring its card, shows its content whole). Nothing runs at rest; reduced motion, motion \"none\" and a card off screen\n * switch at once; a change mid-way starts from where the card is. The height twin of hooks/use-width-morph; any element whose\n * content is replaced in place uses it (the auth cards, the step form, a dialog's stepped tray, the command menu's pages).\n */\nexport function useHeightMorph(\n  ref: RefObject<HTMLElement | null>,\n  key: unknown,\n  {\n    clip = true,\n    duration = \"morph\",\n    reduced: reducedOverride = false,\n  }: {\n    clip?: boolean;\n    /** The semantic duration the ease takes: a mode change morphs, a content swap (a skeleton) takes the standard. */\n    duration?: \"morph\" | \"standard\";\n    /** Also place at once when the caller knows motion is reduced by its own policy. */\n    reduced?: boolean;\n  } = {},\n) {\n  const motion = useMotionTokens(ref);\n  const last = useRef<number | null>(null);\n  const easing = useRef<Animation | null>(null);\n  // the height it last rested at, kept current when it changes on its own (an error line, a bot check) so the next ease\n  // starts where the card really is; the ease's own frames are not a resting height\n  useLayoutEffect(() => {\n    const el = ref.current;\n    if (!el || typeof ResizeObserver === \"undefined\") return;\n    const observer = new ResizeObserver(() => {\n      if (!easing.current) last.current = el.getBoundingClientRect().height;\n    });\n    observer.observe(el);\n    return () => observer.disconnect();\n  }, [ref]);\n  useLayoutEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const from = easing.current ? el.getBoundingClientRect().height : last.current;\n    easing.current?.cancel();\n    easing.current = null;\n    const box = el.getBoundingClientRect();\n    const to = box.height;\n    last.current = to;\n    const ms = motion.duration[duration] * 1000;\n    if (from === null || Math.abs(from - to) < 0.5 || motion.reduced || reducedOverride || ms < 2) return;\n    // off screen nobody sees the glide: the card takes its height at once and no frame is spent on it\n    if (box.bottom < 0 || box.top > innerHeight) return;\n    // the ease runs between measured heights: a keyframe to \"auto\" (even with interpolate-size, or calc-size) does not\n    // interpolate in Chromium's Web Animations, it jumps at once; at the end the element is back on its own height\n    // the clip below leaves room for a focus ring or a control's shadow at the content's edge (inert at rest); a plain\n    // length, because Chromium computes any calc() here (and so the space tokens) as 0\n    el.style.setProperty(\"overflow-clip-margin\", \"8px\");\n    const ease = motion.ease.default;\n    const overflow = clip ? \"clip\" : \"visible\";\n    const animation = el.animate(\n      [\n        { height: `${from}px`, overflow },\n        { height: `${to}px`, overflow },\n      ],\n      { duration: ms, easing: cssEase(ease, \"ease-in-out\") },\n    );\n    easing.current = animation;\n    void animation.finished.then(\n      () => {\n        if (easing.current !== animation) return;\n        easing.current = null;\n        last.current = el.getBoundingClientRect().height;\n      },\n      () => {},\n    );\n  }, [key]); // eslint-disable-line react-hooks/exhaustive-deps -- eases on a change of the step it stands for\n}\n"},{"path":"beamline/hooks/use-indicator.ts","type":"registry:file","target":"src/ui/beamline/hooks/use-indicator.ts","content":"\"use client\";\n\nimport { APPEARANCE_EVENT } from \"../lib/motion-tokens\";\nimport { useLayoutEffect, useRef, useState, type CSSProperties, type RefObject } from \"react\";\n\nexport interface IndicatorBox {\n  x: number;\n  y: number;\n  w: number;\n  h: number;\n  /** False on the first placement, so the indicator appears in place instead of sliding in from the corner. */\n  ready: boolean;\n  /** Which way the last move went on each axis (-1 left or up, 1 right or down, 0 still), for the edge that leads. */\n  dx: -1 | 0 | 1;\n  dy: -1 | 0 | 1;\n  /** choice: a selection changed; layout: the same choice moved because the page reflowed (a resize, a font, a\n   *  type scale). A surface may travel for a choice and should simply be there after a reflow. */\n  cause: \"choice\" | \"layout\";\n}\n\ntype Box = Pick<IndicatorBox, \"x\" | \"y\" | \"w\" | \"h\">;\nconst same = (a: IndicatorBox | null, b: Box) => a !== null && a.x === b.x && a.y === b.y && a.w === b.w && a.h === b.h;\n\n/**\n * Follows the chosen item inside a container: the thumb of a segmented control, the pill or line of tabs, the ring of\n * radio cards. Returns a ref for the container and the box of the first element matching `selector` in it, relative\n * to the container (null when nothing matches). It measures before paint whenever `key` changes, and again when the\n * container resizes or a selection attribute changes inside it (for parts whose choice lives in a library, like tabs).\n */\nexport function useIndicator<T extends HTMLElement>(\n  selector: string,\n  key?: unknown,\n  onPlace?: (item: HTMLElement, container: T) => void,\n  /** offset (default): the item's offset box, for items whose offset parent is the container. rect: measured on screen\n   *  relative to the container, for items nested in positioned cells (a calendar day in its table cell). */\n  measure: \"offset\" | \"rect\" = \"offset\",\n): [RefObject<T | null>, IndicatorBox | null] {\n  const ref = useRef<T>(null);\n  const [box, setBox] = useState<IndicatorBox | null>(null);\n  const placed = useRef(onPlace);\n  useLayoutEffect(() => {\n    placed.current = onPlace;\n  });\n  useLayoutEffect(() => {\n    const container = ref.current;\n    if (!container) return;\n    const place = (cause: IndicatorBox[\"cause\"] = \"choice\") => {\n      const item = container.querySelector<HTMLElement>(selector);\n      if (!item) {\n        setBox(null);\n        return;\n      }\n      let next = { x: item.offsetLeft, y: item.offsetTop, w: item.offsetWidth, h: item.offsetHeight };\n      if (measure === \"rect\") {\n        const a = item.getBoundingClientRect();\n        const c = container.getBoundingClientRect();\n        next = {\n          x: Math.round(a.left - c.left - container.clientLeft + container.scrollLeft),\n          y: Math.round(a.top - c.top - container.clientTop + container.scrollTop),\n          w: item.offsetWidth,\n          h: item.offsetHeight,\n        };\n      }\n      setBox((b) =>\n        same(b, next)\n          ? b\n          : {\n              ...next,\n              cause,\n              ready: b !== null,\n              dx: b ? (Math.sign(next.x - b.x) as IndicatorBox[\"dx\"]) : 0,\n              dy: b ? (Math.sign(next.y - b.y) as IndicatorBox[\"dy\"]) : 0,\n            },\n      );\n      placed.current?.(item, container);\n    };\n    const resizes = typeof ResizeObserver === \"undefined\" ? null : new ResizeObserver(() => place(\"layout\"));\n    resizes?.observe(container);\n    const observed = new Set<Element>();\n    const observeItems = () => {\n      // A full-width fixed-height list can stay the same size while its tabs/radio choices grow with type or labels.\n      // Ignore the decorative indicator itself, whose own dimensions are the output of this measurement.\n      const items = new Set([...container.children].filter((child) => child.getAttribute(\"aria-hidden\") !== \"true\"));\n      for (const old of observed)\n        if (!items.has(old)) {\n          resizes?.unobserve(old);\n          observed.delete(old);\n        }\n      for (const item of items)\n        if (!observed.has(item)) {\n          resizes?.observe(item);\n          observed.add(item);\n        }\n    };\n    observeItems();\n    place();\n    const mutations = new MutationObserver(() => {\n      observeItems();\n      place(\"choice\");\n    });\n    mutations.observe(container, {\n      subtree: true,\n      childList: true,\n      attributes: true,\n      attributeFilter: [\"data-state\", \"aria-checked\", \"aria-selected\", \"aria-current\", \"data-active\", \"data-open\"],\n    });\n    const reflow = () => place(\"layout\");\n    container.ownerDocument.addEventListener(APPEARANCE_EVENT, reflow);\n    container.ownerDocument.fonts?.addEventListener(\"loadingdone\", reflow);\n    return () => {\n      mutations.disconnect();\n      resizes?.disconnect();\n      container.ownerDocument.removeEventListener(APPEARANCE_EVENT, reflow);\n      container.ownerDocument.fonts?.removeEventListener(\"loadingdone\", reflow);\n    };\n  }, [selector, key, measure]);\n  return [ref, box];\n}\n\n/** The box as custom properties, for a stylesheet to place the indicator with: --pui-indicator-x/-y/-w/-h, and its\n *  four edges --pui-glide-l/-r/-t/-b, which the `glide` class moves one at a time. */\nexport function indicatorStyle(box: IndicatorBox): CSSProperties {\n  return {\n    \"--pui-indicator-x\": `${box.x}px`,\n    \"--pui-indicator-y\": `${box.y}px`,\n    \"--pui-indicator-w\": `${box.w}px`,\n    \"--pui-indicator-h\": `${box.h}px`,\n    \"--pui-glide-l\": `${box.x}px`,\n    \"--pui-glide-r\": `${box.x + box.w}px`,\n    \"--pui-glide-t\": `${box.y}px`,\n    \"--pui-glide-b\": `${box.y + box.h}px`,\n  } as CSSProperties;\n}\n\nconst AXIS = { x: [\"left\", undefined, \"right\"], y: [\"up\", undefined, \"down\"] } as const;\n\n/** Everything an indicator wearing the `glide` class needs (utilities.css): its place, whether it may move yet, and\n *  which way it is going, so the edge on that side leads and the other follows: it stretches toward the new choice and\n *  gathers there. */\nexport function glideProps(box: IndicatorBox) {\n  return {\n    style: indicatorStyle(box),\n    \"data-ready\": box.ready ? \"\" : undefined,\n    \"data-glide-x\": AXIS.x[box.dx + 1],\n    \"data-glide-y\": AXIS.y[box.dy + 1],\n  };\n}\n"},{"path":"beamline/hooks/use-media-query.ts","type":"registry:file","target":"src/ui/beamline/hooks/use-media-query.ts","content":"\"use client\";\n\nimport { useSyncExternalStore } from \"react\";\n\n// one MediaQueryList per query: React reads the snapshot on every render, and a part that renders thirty times a\n// second (a playing audio player's clock) would otherwise ask the browser for a new list each time\nconst lists = new Map<string, MediaQueryList>();\nconst list = (query: string) => {\n  if (typeof window === \"undefined\" || typeof window.matchMedia !== \"function\") return undefined;\n  let m = lists.get(query);\n  if (!m) lists.set(query, (m = window.matchMedia(query)));\n  return m;\n};\n\n/** True while the media query matches; false on the server and in the first client render of SSR output. */\nexport function useMediaQuery(query: string): boolean {\n  return useSyncExternalStore(\n    (notify) => {\n      const m = list(query);\n      m?.addEventListener(\"change\", notify);\n      return () => m?.removeEventListener(\"change\", notify);\n    },\n    () => list(query)?.matches ?? false,\n    () => false,\n  );\n}\n\n/** Phone-width layouts: below 768px. */\nexport const usePhone = () => useMediaQuery(\"(max-width: 767px)\");\n"},{"path":"beamline/hooks/use-motion-tokens.ts","type":"registry:file","target":"src/ui/beamline/hooks/use-motion-tokens.ts","content":"\"use client\";\n\nimport { useMemo, type RefObject } from \"react\";\nimport { useAppearanceRoot } from \"../runtime/appearance\";\nimport { useResolvedAppearance } from \"./use-resolved-appearance\";\nimport { motionAt, motionEase, motionTokens, type MotionTokens } from \"../lib/motion-tokens\";\nimport { semanticMotion } from \"../lib/motion-source\";\n\nconst durationToken = (name: string) =>\n  name === \"exit\" ? \"motion-out\" : name === \"in\" || name === \"out\" ? `motion-${name}` : `duration-${name}`;\nconst easeToken = (name: string) => `ease-${name === \"inOut\" ? \"in-out\" : name}`;\nconst REQUEST = {\n  times: [\n    ...Object.keys(semanticMotion.duration).map(durationToken),\n    ...Object.keys(semanticMotion.spring).map((name) => `spring-${name}`),\n    ...Object.keys(semanticMotion.stagger).map((name) => `stagger-${name}`),\n    \"fade-in\",\n    \"fade-out\",\n  ],\n  easings: [...Object.keys(semanticMotion.ease).map(easeToken), \"ease-spring\", \"ease-spring-bounce\", \"ease-overshoot\"],\n  numbers: [\"motion-scale\", \"motion-look\", \"press-scale\"],\n  // timing only: the host's own type would make every control resolve differently from the page around it\n  typography: false,\n};\n\n/**\n * Resolve each timing at the actual host; omitted host uses the nearest managed root. The first/server snapshot is\n * the pure foundation default. Local CSS values, scope changes, font readiness, OS preference and explicit refresh\n * update the same consumer; no document-wide first-root fallback or persistent global listener.\n */\nexport function useMotionTokens(hostRef?: RefObject<HTMLElement | null>): MotionTokens & {\n  ready: boolean;\n  /** Reduced or none: movement, springs and staggers are instant. */\n  reduced: boolean;\n  mode: \"full\" | \"reduced\" | \"none\";\n  /** Opacity-only arrival and departure (seconds): kept under reduced, instant under none (APPEARANCE A06). */\n  fade: { in: number; out: number };\n} {\n  const root = useAppearanceRoot();\n  const scopeRef = useMemo(() => ({ current: root }), [root]);\n  const resolved = useResolvedAppearance(hostRef ?? scopeRef, REQUEST);\n  return useMemo(() => {\n    if (!resolved.ready)\n      return {\n        ...motionTokens,\n        ready: false,\n        reduced: false,\n        mode: \"full\" as const,\n        fade: { in: motionTokens.duration.in, out: motionTokens.duration.out },\n      };\n    const reduced = resolved.reducedMotion;\n    const speed = (resolved.numbers[\"motion-scale\"] ?? 1) * (resolved.numbers[\"motion-look\"] ?? 1);\n    const fade =\n      resolved.motionMode === \"none\"\n        ? { in: 0.001, out: 0.001 }\n        : {\n            in: resolved.times[\"fade-in\"] ?? semanticMotion.duration.in * speed,\n            out: resolved.times[\"fade-out\"] ?? semanticMotion.duration.out * speed,\n          };\n    const factor = reduced ? 0.001 / semanticMotion.duration.standard : speed;\n    const base = motionAt(factor);\n    const duration = Object.fromEntries(\n      Object.entries(base.duration).map(([name, fallback]) => [\n        name,\n        reduced ? 0.001 : (resolved.times[durationToken(name)] ?? fallback),\n      ]),\n    ) as MotionTokens[\"duration\"];\n    const stagger = Object.fromEntries(\n      Object.entries(base.stagger).map(([name, fallback]) => [\n        name,\n        reduced ? 0 : (resolved.times[`stagger-${name}`] ?? fallback),\n      ]),\n    ) as MotionTokens[\"stagger\"];\n    const ease = Object.fromEntries(\n      Object.entries(base.ease).map(([name, fallback]) => [\n        name,\n        motionEase(resolved.easings[easeToken(name)], fallback),\n      ]),\n    ) as MotionTokens[\"ease\"];\n    const spring = { ...base.spring };\n    for (const name of Object.keys(semanticMotion.spring) as (keyof typeof semanticMotion.spring)[])\n      spring[name] = {\n        ...base.spring[name],\n        visualDuration: reduced ? 0.001 : (resolved.times[`spring-${name}`] ?? base.spring[name].visualDuration),\n        bounce: reduced ? 0 : base.spring[name].bounce,\n      };\n    return {\n      ...base,\n      ready: true,\n      reduced,\n      mode: resolved.motionMode,\n      fade,\n      duration,\n      stagger,\n      ease,\n      spring,\n      pressScale: resolved.numbers[\"press-scale\"] ?? base.pressScale,\n      css: {\n        spring: resolved.easings[\"ease-spring\"] ?? base.css.spring,\n        springBounce: resolved.easings[\"ease-spring-bounce\"] ?? base.css.springBounce,\n        overshoot: resolved.easings[\"ease-overshoot\"] ?? base.css.overshoot,\n      },\n    };\n  }, [resolved]);\n}\n"},{"path":"beamline/hooks/use-reduced-motion-safe.ts","type":"registry:file","target":"src/ui/beamline/hooks/use-reduced-motion-safe.ts","content":"\"use client\";\n\nimport { useMediaQuery } from \"./use-media-query\";\nimport { useScopeMotion } from \"../runtime/appearance\";\n\n/** Managed motion policy plus the OS preference, with a stable server snapshot. */\nexport function useReducedMotionSafe() {\n  const requested = useScopeMotion();\n  const os = useMediaQuery(\"(prefers-reduced-motion: reduce)\");\n  return requested !== \"auto\" || os;\n}\n"},{"path":"beamline/hooks/use-scope-direction.ts","type":"registry:file","target":"src/ui/beamline/hooks/use-scope-direction.ts","content":"\"use client\";\n\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState, type Ref } from \"react\";\nimport { useDirection } from \"@radix-ui/react-direction\";\nimport { useAppearance, useAppearanceRoot } from \"../runtime/appearance\";\nimport { APPEARANCE_EVENT } from \"../lib/motion-tokens\";\n\nconst useIsoLayoutEffect = typeof window === \"undefined\" ? useEffect : useLayoutEffect;\n\n/** Preserve Radix direction in managed scopes and read the actual parent in static scopes before Radix stamps dir. */\nexport function useScopeDirection<T extends HTMLElement>(ref?: Ref<T>, explicit?: \"ltr\" | \"rtl\") {\n  const root = useRef<T | null>(null);\n  const provided = useDirection(explicit);\n  const appearance = useAppearance();\n  const managedRoot = useAppearanceRoot();\n  const [inherited, setInherited] = useState<\"ltr\" | \"rtl\">();\n  const read = useCallback(() => {\n    const around = root.current?.parentElement;\n    if (around)\n      setInherited(around.ownerDocument.defaultView?.getComputedStyle(around).direction === \"rtl\" ? \"rtl\" : \"ltr\");\n  }, []);\n  useIsoLayoutEffect(read, [read, provided, appearance]);\n  useEffect(() => {\n    const doc = root.current?.ownerDocument;\n    doc?.addEventListener(APPEARANCE_EVENT, read);\n    return () => doc?.removeEventListener(APPEARANCE_EVENT, read);\n  }, [read]);\n  const attach = useCallback(\n    (node: T | null) => {\n      root.current = node;\n      if (typeof ref === \"function\") {\n        const cleanup = ref(node);\n        if (typeof cleanup === \"function\")\n          return () => {\n            root.current = null;\n            cleanup();\n          };\n      } else if (ref) ref.current = node;\n    },\n    [ref],\n  );\n  return [\n    attach,\n    explicit ?? (managedRoot ? provided : provided === \"rtl\" ? provided : (inherited ?? provided)),\n  ] as const;\n}\n"},{"path":"beamline/hooks/use-width-morph.ts","type":"registry:file","target":"src/ui/beamline/hooks/use-width-morph.ts","content":"\"use client\";\n\nimport { useLayoutEffect, useRef, type RefObject } from \"react\";\nimport { useMotionTokens } from \"./use-motion-tokens\";\nimport { cssEase } from \"../lib/motion-tokens\";\n\n/**\n * A label whose text changes keeps its path: when `key` changes, the element's width eases from what it was to what the\n * new text needs, so whatever sits after it (a chevron, a counter) glides instead of jumping. The element clips while it\n * eases (give it `overflow-clip whitespace-nowrap`). Nothing runs at rest; reduced motion and motion \"none\" switch at\n * once, and so does a label off screen.\n */\nexport function useWidthMorph(ref: RefObject<HTMLElement | null>, key: unknown) {\n  const motion = useMotionTokens(ref);\n  const last = useRef<number | null>(null);\n  const easing = useRef<Animation | null>(null);\n  // the width it last rested at, kept current when it changes on its own (a web font arriving) so the next ease starts\n  // where the label really is; the ease's own frames are not a resting width\n  useLayoutEffect(() => {\n    const el = ref.current;\n    if (!el || typeof ResizeObserver === \"undefined\") return;\n    const observer = new ResizeObserver(() => {\n      if (!easing.current) last.current = el.getBoundingClientRect().width;\n    });\n    observer.observe(el);\n    return () => observer.disconnect();\n  }, [ref]);\n  useLayoutEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    // mid-way through an earlier change, it starts from where it is now, not from where that change was going\n    const from = easing.current ? el.getBoundingClientRect().width : last.current;\n    easing.current?.cancel();\n    easing.current = null;\n    const box = el.getBoundingClientRect();\n    const to = box.width;\n    last.current = to;\n    const ms = motion.duration.morph * 1000;\n    if (from === null || Math.abs(from - to) < 0.5 || motion.reduced || ms < 2) return;\n    // off screen nobody sees the glide: the label takes its width at once and no frame is spent on it\n    if (box.bottom < 0 || box.top > innerHeight || box.right < 0 || box.left > innerWidth) return;\n    const ease = motion.ease.default;\n    // pixel to pixel: a Web Animations keyframe to \"auto\" (with interpolate-size, or calc-size) jumps straight to the\n    // end in Chromium 153 instead of easing (measured: 537 of 537 px at 300 of 1000 ms); a late change of the natural\n    // width is caught by the observer above when the ease ends\n    const animation = el.animate([{ width: `${from}px` }, { width: `${to}px` }], {\n      duration: ms,\n      // even in and out: the glide never moves a neighbour more than a pixel or two in one frame\n      easing: cssEase(ease, \"ease-in-out\"),\n    });\n    easing.current = animation;\n    void animation.finished.then(\n      () => {\n        if (easing.current !== animation) return;\n        easing.current = null;\n        last.current = el.getBoundingClientRect().width;\n      },\n      () => {},\n    );\n  }, [key]); // eslint-disable-line react-hooks/exhaustive-deps -- eases on a change of the text it stands for\n}\n"},{"path":"beamline/lib/contour.ts","type":"registry:file","target":"src/ui/beamline/lib/contour.ts","content":"import { readMotionFactor } from \"./motion-tokens\";\n\n/**\n * Contour: a surface whose outline moves like matter instead of a box that resizes. Beamline's own model (research/\n * morphing-interfaces-2026-10-04): a rounded quadrilateral whose four corners each follow their target on a critically\n * damped spring. The corner facing the way it travels answers fastest and the far one slowest, so it leads and gathers;\n * each edge's midpoint heads for where its edge will be a little ahead of its corners and may only bulge outward (the\n * leading edge rounds out like the front of a drop, the tail stays smooth), and while the shape is longer than its target the long edges\n * pinch toward the centre, so a fast move draws a neck; while it is stretched its corners round toward a capsule, as a moving drop does. No spring overshoots: the elasticity is the parts arriving at\n * different moments, never bounce. At rest the surface is its plain CSS box with no clip and no frames.\n *\n * The look decides the material through four inputs on the element (preset-source.css): --m-morph-spread (how unevenly\n * the corners answer; 0 is rigid travel), --m-morph-front (px the leading edge may round out), --m-morph-waist (how much\n * a stretch pinches) and --m-morph-weight (a multiplier on the response time).\n */\nexport interface ContourBox {\n  x: number;\n  y: number;\n  w: number;\n  h: number;\n}\n\nexport interface Contour {\n  /** Move the surface to `box` (in its offset parent's coordinates). `instant` places it with no motion. */\n  to(box: ContourBox, options?: { instant?: boolean }): void;\n  /** Stop and leave the surface at its target. */\n  destroy(): void;\n}\n\ntype Point = [number, number];\ntype Corner = \"tl\" | \"tr\" | \"br\" | \"bl\";\ntype Edge = \"t\" | \"r\" | \"b\" | \"l\";\nconst CORNERS: Corner[] = [\"tl\", \"tr\", \"br\", \"bl\"];\nconst EDGES: Edge[] = [\"t\", \"r\", \"b\", \"l\"];\n/** Outward direction of each corner, for deciding which one leads. */\nconst OUT: Record<Corner, Point> = { tl: [-1, -1], tr: [1, -1], br: [1, 1], bl: [-1, 1] };\n/** Outward direction of each edge. */\nconst NORMAL: Record<Edge, Point> = { t: [0, -1], r: [1, 0], b: [0, 1], l: [-1, 0] };\n/** Settles at the motion-token morph spring at the foundation default. */\nconst BASE_RESPONSE = 0.26;\n\ninterface Mechanics {\n  spread: number;\n  front: number;\n  waist: number;\n  weight: number;\n  /** The colour of the edge drawn along a non-rectangular outline (the look's hairline, which a clip would cut off). */\n  rim: string;\n  rimWidth: number;\n}\n\n/** One step of a critically damped spring with response time `t` (s), in closed form so a long frame cannot explode. */\nfunction step(x: number, v: number, target: number, t: number, dt: number): [number, number] {\n  const w = (2 * Math.PI) / (t * 1.2);\n  const d = x - target;\n  const e = Math.exp(-w * dt);\n  return [target + (d + (v + w * d) * dt) * e, (v - w * (v + w * d) * dt) * e];\n}\n\nconst cornersOf = (b: ContourBox): Record<Corner, Point> => ({\n  tl: [b.x, b.y],\n  tr: [b.x + b.w, b.y],\n  br: [b.x + b.w, b.y + b.h],\n  bl: [b.x, b.y + b.h],\n});\nconst midsOf = (c: Record<Corner, Point>): Record<Edge, Point> => ({\n  t: [(c.tl[0] + c.tr[0]) / 2, (c.tl[1] + c.tr[1]) / 2],\n  r: [(c.tr[0] + c.br[0]) / 2, (c.tr[1] + c.br[1]) / 2],\n  b: [(c.br[0] + c.bl[0]) / 2, (c.br[1] + c.bl[1]) / 2],\n  l: [(c.bl[0] + c.tl[0]) / 2, (c.bl[1] + c.tl[1]) / 2],\n});\nconst zero = <K extends string>(keys: K[]) => Object.fromEntries(keys.map((k) => [k, [0, 0]])) as Record<K, Point>;\nconst num = (style: CSSStyleDeclaration, name: string, fallback: number) => {\n  const value = Number.parseFloat(style.getPropertyValue(name));\n  return Number.isFinite(value) ? value : fallback;\n};\n\n/** All moving contours share one frame loop, which stops when the last one settles. */\nconst moving = new Set<(dt: number) => boolean>();\nlet frame = 0;\nlet last = 0;\nfunction tick(now: number) {\n  const dt = Math.min(0.032, Math.max(0.001, (now - last) / 1000));\n  last = now;\n  for (const advance of moving) if (!advance(dt)) moving.delete(advance);\n  frame = moving.size ? requestAnimationFrame(tick) : 0;\n}\nfunction run(advance: (dt: number) => boolean) {\n  moving.add(advance);\n  if (!frame) {\n    last = performance.now();\n    frame = requestAnimationFrame(tick);\n  }\n}\n\n/** One contour per element, so a remount (or React's development double mount) keeps its place and keeps moving. */\nconst contours = new WeakMap<HTMLElement, Contour>();\nexport function createContour(el: HTMLElement): Contour {\n  const existing = contours.get(el);\n  if (existing) return existing;\n  let target: ContourBox | null = null;\n  let pos: Record<Corner, Point> | null = null;\n  let vel = zero(CORNERS);\n  let mid: Record<Edge, Point> = { t: [0, 0], r: [0, 0], b: [0, 0], l: [0, 0] };\n  let midVel = zero(EDGES);\n  let mech: Mechanics = { spread: 0.35, front: 5, waist: 0.16, weight: 1, rim: \"none\", rimWidth: 1 };\n  let rimPath: SVGPathElement | null = null;\n  const rim = (d: string | null, w = 0, h = 0) => {\n    if (!d || mech.rim === \"none\") {\n      if (rimPath) (rimPath.ownerSVGElement as SVGSVGElement).style.display = \"none\";\n      return;\n    }\n    if (!rimPath) {\n      const ns = \"http://www.w3.org/2000/svg\";\n      const svg = el.ownerDocument.createElementNS(ns, \"svg\");\n      svg.setAttribute(\"aria-hidden\", \"true\");\n      svg.setAttribute(\"data-contour-rim\", \"\");\n      svg.style.cssText = \"position:absolute;left:0;top:0;z-index:2;overflow:visible;pointer-events:none\";\n      rimPath = el.ownerDocument.createElementNS(ns, \"path\");\n      rimPath.setAttribute(\"fill\", \"none\");\n      svg.appendChild(rimPath);\n      el.appendChild(svg);\n    }\n    const svg = rimPath.ownerSVGElement as SVGSVGElement;\n    svg.style.display = \"\";\n    svg.setAttribute(\"width\", String(w));\n    svg.setAttribute(\"height\", String(h));\n    rimPath.setAttribute(\"d\", d);\n    // the clip keeps the inner half of the stroke: an edge of rimWidth inside the outline\n    rimPath.setAttribute(\"stroke-width\", String(mech.rimWidth * 2));\n    rimPath.style.stroke = mech.rim;\n  };\n  let response = BASE_RESPONSE;\n  let radius = 0;\n  let running = false;\n\n  const rest = () => {\n    if (!target) return;\n    el.style.transform = `translate(${target.x}px, ${target.y}px)`;\n    el.style.width = `${target.w}px`;\n    el.style.height = `${target.h}px`;\n    el.style.clipPath = \"\";\n    rim(null);\n    delete el.dataset.morphing;\n  };\n\n  const draw = () => {\n    if (!pos || !target) return;\n    const c = pos;\n    const w = (c.tr[0] - c.tl[0] + c.br[0] - c.bl[0]) / 2;\n    const h = (c.bl[1] - c.tl[1] + c.br[1] - c.tr[1]) / 2;\n    // the long edges pinch while the shape is longer than its target (area kept, roughly)\n    const pinchY = Math.min(h * mech.waist * 0.5, 4, h * Math.max(0, w / target.w - 1) * mech.waist);\n    const pinchX = Math.min(w * mech.waist * 0.5, 4, w * Math.max(0, h / target.h - 1) * mech.waist);\n    const edges: Record<Edge, Point> = {\n      t: [mid.t[0], mid.t[1] + pinchY],\n      b: [mid.b[0], mid.b[1] - pinchY],\n      l: [mid.l[0] + pinchX, mid.l[1]],\n      r: [mid.r[0] - pinchX, mid.r[1]],\n    };\n    // still a rectangle (a rigid look, or a straight move): move the box itself and keep every bit of the look's paint\n    const flat = (a: number, b: number) => Math.abs(a - b) < 0.35;\n    const corners = midsOf(c);\n    if (\n      flat(c.tl[1], c.tr[1]) &&\n      flat(c.bl[1], c.br[1]) &&\n      flat(c.tl[0], c.bl[0]) &&\n      flat(c.tr[0], c.br[0]) &&\n      EDGES.every((k) => flat(edges[k][0], corners[k][0]) && flat(edges[k][1], corners[k][1]))\n    ) {\n      el.style.transform = `translate(${c.tl[0]}px, ${c.tl[1]}px)`;\n      el.style.width = `${c.tr[0] - c.tl[0]}px`;\n      el.style.height = `${c.bl[1] - c.tl[1]}px`;\n      el.style.clipPath = \"\";\n      rim(null);\n      return;\n    }\n    const all = [...CORNERS.map((k) => c[k]), ...EDGES.map((k) => edges[k])];\n    const minX = Math.floor(Math.min(...all.map((p) => p[0]))) - 1;\n    const minY = Math.floor(Math.min(...all.map((p) => p[1]))) - 1;\n    const maxX = Math.ceil(Math.max(...all.map((p) => p[0]))) + 1;\n    const maxY = Math.ceil(Math.max(...all.map((p) => p[1]))) + 1;\n    const local = (p: Point): Point => [p[0] - minX, p[1] - minY];\n    const C = CORNERS.map((k) => local(c[k]));\n    const E = ([\"t\", \"r\", \"b\", \"l\"] as Edge[]).map((k) => local(edges[k]));\n    const len = (a: Point, b: Point) => Math.hypot(b[0] - a[0], b[1] - a[1]) || 1;\n    const toward = (a: Point, b: Point, d: number): Point => {\n      const l = len(a, b);\n      return [a[0] + ((b[0] - a[0]) / l) * d, a[1] + ((b[1] - a[1]) / l) * d];\n    };\n    // each corner backs off its radius along both of its real edges and turns through the corner itself, so a sheared\n    // shape never folds over; each edge bows through its midpoint\n    // a moving drop is round: corners grow toward a capsule while the shape is stretched or far from home\n    const away = Math.max(w / target.w - 1, h / target.h - 1, 0);\n    const round = mech.front > 0 ? Math.min(1, away * 2.5) : 0;\n    const r = radius + (Math.min(w, h) / 2 - radius) * Math.max(0, round);\n    const rr = C.map((p, i) => Math.min(r, len(p, C[(i + 1) % 4]) / 2.2, len(p, C[(i + 3) % 4]) / 2.2));\n    const into = C.map((p, i) => toward(p, C[(i + 3) % 4], rr[i]));\n    const out = C.map((p, i) => toward(p, C[(i + 1) % 4], rr[i]));\n    const through = (a: Point, m: Point, b: Point): Point => [\n      2 * m[0] - (a[0] + b[0]) / 2,\n      2 * m[1] - (a[1] + b[1]) / 2,\n    ];\n    const f = (p: Point) => `${p[0].toFixed(1)} ${p[1].toFixed(1)}`;\n    let d = `M${f(out[0])}`;\n    for (let i = 0; i < 4; i++) {\n      const j = (i + 1) % 4;\n      // an edge the rounded corners have nearly used up can only bow a little, or its middle would point\n      const a = out[i];\n      const b = into[j];\n      const chord: Point = [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2];\n      const bow: Point = [E[i][0] - chord[0], E[i][1] - chord[1]];\n      const most = len(a, b) * 0.18;\n      const bowLen = Math.hypot(bow[0], bow[1]);\n      const m: Point =\n        bowLen > most ? [chord[0] + (bow[0] / bowLen) * most, chord[1] + (bow[1] / bowLen) * most] : E[i];\n      d += ` Q${f(through(a, m, b))} ${f(b)} Q${f(C[j])} ${f(out[j])}`;\n    }\n    el.style.transform = `translate(${minX}px, ${minY}px)`;\n    el.style.width = `${maxX - minX}px`;\n    el.style.height = `${maxY - minY}px`;\n    el.style.clipPath = `path(\"${d}Z\")`;\n    rim(`${d}Z`, maxX - minX, maxY - minY);\n  };\n\n  const advance = (dt: number) => {\n    if (!pos || !target || !el.isConnected) return (running = false);\n    const goal = cornersOf(target);\n    let busy = false;\n    for (const k of CORNERS) {\n      const p = pos[k];\n      const v = vel[k];\n      const g = goal[k];\n      const dx = g[0] - p[0];\n      const dy = g[1] - p[1];\n      const dist = Math.hypot(dx, dy);\n      // -1 … 1: how squarely this corner faces the way it is going\n      const along = dist > 0.5 ? (OUT[k][0] * dx + OUT[k][1] * dy) / (dist * Math.SQRT2) : 0;\n      const t = response * (1 + mech.spread * 0.4 - mech.spread * along);\n      for (const a of [0, 1] as const) {\n        [p[a], v[a]] = step(p[a], v[a], g[a], t, dt);\n        if (Math.abs(p[a] - g[a]) > 0.2 || Math.abs(v[a]) > 4) busy = true;\n      }\n    }\n    const now = midsOf(pos);\n    const aim = midsOf(goal);\n    for (const k of EDGES) {\n      for (const a of [0, 1] as const)\n        [mid[k][a], midVel[k][a]] = step(mid[k][a], midVel[k][a], aim[k][a], response * 0.75, dt);\n      // the lead is a few pixels at most, and never more than a fraction of the edge or of the shape's depth\n      const across = k === \"t\" || k === \"b\" ? target.h : target.w;\n      const edge =\n        k === \"t\" ? [pos.tl, pos.tr] : k === \"b\" ? [pos.br, pos.bl] : k === \"l\" ? [pos.bl, pos.tl] : [pos.tr, pos.br];\n      const limit = Math.min(\n        mech.front,\n        across * 0.3,\n        Math.hypot(edge[1][0] - edge[0][0], edge[1][1] - edge[0][1]) * 0.15,\n      );\n      // edges only ever bulge outward: the front rounds out, the tail stays smooth instead of curling in\n      let ox = mid[k][0] - now[k][0];\n      let oy = mid[k][1] - now[k][1];\n      const [nx, ny] = NORMAL[k];\n      const inward = ox * nx + oy * ny;\n      if (inward < 0) {\n        ox -= inward * nx;\n        oy -= inward * ny;\n        mid[k][0] = now[k][0] + ox;\n        mid[k][1] = now[k][1] + oy;\n      }\n      const off = Math.hypot(ox, oy);\n      if (off > limit) {\n        mid[k][0] = now[k][0] + (ox / off) * limit;\n        mid[k][1] = now[k][1] + (oy / off) * limit;\n      }\n      if (Math.abs(mid[k][0] - aim[k][0]) > 0.2 || Math.abs(mid[k][1] - aim[k][1]) > 0.2) busy = true;\n    }\n    if (!busy) {\n      pos = goal;\n      vel = zero(CORNERS);\n      mid = midsOf(goal);\n      midVel = zero(EDGES);\n      rest();\n      return (running = false);\n    }\n    draw();\n    return true;\n  };\n\n  const contour: Contour = {\n    to(box, options) {\n      const same = target && target.x === box.x && target.y === box.y && target.w === box.w && target.h === box.h;\n      if (same && !options?.instant) return;\n      target = { ...box };\n      const style = getComputedStyle(el);\n      const r = style.borderTopLeftRadius;\n      radius = r.endsWith(\"%\") ? (Number.parseFloat(r) / 100) * Math.min(box.w, box.h) : Number.parseFloat(r) || 0;\n      mech = {\n        spread: num(style, \"--m-morph-spread\", 0.35),\n        front: num(style, \"--m-morph-front\", 6),\n        waist: num(style, \"--m-morph-waist\", 0.18),\n        weight: num(style, \"--m-morph-weight\", 1),\n        rim: style.getPropertyValue(\"--m-morph-rim\").trim() || \"none\",\n        rimWidth: num(style, \"--m-morph-rim-width\", 1),\n      };\n      const factor = readMotionFactor(el);\n      response = BASE_RESPONSE * mech.weight * factor;\n      // first placement, reduced motion, or a hidden surface: be there, with nothing to watch\n      if (!pos || options?.instant || factor < 0.05 || !el.getClientRects().length) {\n        pos = cornersOf(target);\n        vel = zero(CORNERS);\n        mid = midsOf(pos);\n        midVel = zero(EDGES);\n        moving.delete(advance);\n        running = false;\n        rest();\n        return;\n      }\n      el.dataset.morphing = \"\";\n      if (!running) {\n        running = true;\n        run(advance);\n      }\n    },\n    destroy() {\n      moving.delete(advance);\n      running = false;\n      if (target) rest();\n    },\n  };\n  contours.set(el, contour);\n  return contour;\n}\n"},{"path":"beamline/lib/gesture.ts","type":"registry:file","target":"src/ui/beamline/lib/gesture.ts","content":"import { readMotionFactor } from \"./motion-tokens\";\n\n/**\n * The arithmetic of a hand on a part, shared by every part that is dragged, thrown or pulled (useDrag is the pointer\n * side). Three pieces, each from how real interfaces feel (Apple, \"Designing Fluid Interfaces\", WWDC 2018):\n *\n * - velocity: read from the last ~100 ms of movement, so the release carries the speed of the flick, not of the whole drag;\n * - projection: where a thrown thing would come to rest if it slid on with the look's carry (`project`), so a part\n *   can decide on release (the nearest value, step or preset to that point) instead of after an animation;\n * - give: past a limit the part follows the hand less and less (`rubberband`) instead of stopping dead, and springs back.\n *\n * How much a part carries and gives is the look's material, read once per gesture from the element (`readHand`):\n * `--m-hand-carry`, `--m-hand-give` and `--m-hand-bounce` (preset-source.css), with `--m-morph-weight` scaling how\n * long things take to settle (times a motion token's duration, which carries the speed setting). Reduced motion\n * carries nothing, gives nothing and never bounces.\n */\n\nexport interface Hand {\n  /** How far a release carries: 0 stops where the hand let go, 1 slides on freely (see `project`). */\n  carry: number;\n  /** How much a part follows the hand past a limit: 0 is a hard stop, 0.55 a phone's rubber band. */\n  give: number;\n  /** Bounce of a released held object (0 critically damped). Only for what the pointer held. */\n  bounce: number;\n  /** The look's weight (`--m-morph-weight`): multiply a motion token's duration by it. The token already carries the\n   *  speed setting, so the weight never does. */\n  weight: number;\n  /** Reduced or no motion: land at once. */\n  reduced: boolean;\n}\n\n/** The hand the defaults describe; also what a server or a test without styles gets. */\nexport const DEFAULT_HAND: Hand = { carry: 0.8, give: 0.45, bounce: 0.14, weight: 1, reduced: false };\n\nconst num = (style: CSSStyleDeclaration, name: string, fallback: number) => {\n  const v = Number.parseFloat(style.getPropertyValue(name));\n  return Number.isFinite(v) ? v : fallback;\n};\n\n/** The look's physics at `el`, read once at the start of a gesture (never per frame). */\nexport function readHand(el: Element | null | undefined): Hand {\n  if (!el || typeof getComputedStyle === \"undefined\") return DEFAULT_HAND;\n  const style = getComputedStyle(el);\n  const factor = readMotionFactor(el);\n  // the motion factor is ~0.005 under reduced motion and 1 at the foundation default\n  const reduced = factor < 0.05;\n  if (reduced) return { carry: 0, give: 0, bounce: 0, weight: 1, reduced: true };\n  return {\n    carry: num(style, \"--m-hand-carry\", DEFAULT_HAND.carry),\n    give: num(style, \"--m-hand-give\", DEFAULT_HAND.give),\n    bounce: num(style, \"--m-hand-bounce\", DEFAULT_HAND.bounce),\n    weight: num(style, \"--m-morph-weight\", 1),\n    reduced: false,\n  };\n}\n\n/** Samples of a pointer's path, kept for the last `window` ms, to read its velocity at release. */\nexport class VelocityTracker {\n  private samples: { t: number; x: number; y: number }[] = [];\n  // a declared field, not a parameter property: shipped source must also compile under erasableSyntaxOnly (Vite's\n  // TypeScript template turns it on), where TypeScript-only syntax with runtime meaning is refused\n  private readonly window: number;\n  constructor(window = 100) {\n    this.window = window;\n  }\n\n  add(t: number, x: number, y: number) {\n    this.samples.push({ t, x, y });\n    const from = t - this.window;\n    while (this.samples.length > 2 && this.samples[0].t < from) this.samples.shift();\n  }\n\n  /** Units per second over the kept window; 0 when the hand stopped before letting go (a pause of more than the window). */\n  velocity(now = this.samples.at(-1)?.t ?? 0): [number, number] {\n    const s = this.samples.filter((p) => p.t >= now - this.window);\n    if (s.length < 2) return [0, 0];\n    // least squares slope over the window: one jittery last sample does not decide the throw\n    const n = s.length;\n    const mt = s.reduce((a, p) => a + p.t, 0) / n;\n    const mx = s.reduce((a, p) => a + p.x, 0) / n;\n    const my = s.reduce((a, p) => a + p.y, 0) / n;\n    let tt = 0;\n    let tx = 0;\n    let ty = 0;\n    for (const p of s) {\n      tt += (p.t - mt) ** 2;\n      tx += (p.t - mt) * (p.x - mx);\n      ty += (p.t - mt) * (p.y - my);\n    }\n    if (tt === 0) return [0, 0];\n    return [(tx / tt) * 1000, (ty / tt) * 1000];\n  }\n\n  reset() {\n    this.samples = [];\n  }\n}\n\n/**\n * How far something released at `velocity` (units/s) slides before friction stops it, with the look's carry. `rate` is\n * the speed kept per millisecond: 0.99 (the default) suits controls on a short scale (a thumb, a puck, a cut), where a\n * flick should carry a little way; 0.998 is a phone list's deceleration, for long scrolling content.\n */\nexport function project(velocity: number, carry: number, rate = 0.99): number {\n  if (carry <= 0) return 0;\n  return (((velocity / 1000) * rate) / (1 - rate)) * carry;\n}\n\n/**\n * Where a part drawn `overshoot` units past its limit sits, given the room `extent` it moves in: it follows less and\n * less the further it goes and never reaches `extent`. `give` 0 is a hard stop.\n */\nexport function rubberband(overshoot: number, extent: number, give: number): number {\n  if (give <= 0 || extent <= 0) return 0;\n  const sign = Math.sign(overshoot);\n  const x = Math.abs(overshoot);\n  return sign * (1 - 1 / ((x * give) / extent + 1)) * extent;\n}\n\n/** `value` held inside [min, max], with the part's give past either end. */\nexport function within(value: number, min: number, max: number, extent: number, give: number): number {\n  if (value < min) return min + rubberband(value - min, extent, give);\n  if (value > max) return max + rubberband(value - max, extent, give);\n  return value;\n}\n\n/** The nearest of `stops` to `value` (a projected landing point picks its step or preset this way). */\nexport function nearest(value: number, stops: readonly number[]): number {\n  let best = stops[0];\n  for (const s of stops) if (Math.abs(s - value) < Math.abs(best - value)) best = s;\n  return best;\n}\n"},{"path":"beamline/lib/now.ts","type":"registry:file","target":"src/ui/beamline/lib/now.ts","content":"import { useContext, useLayoutEffect, useMemo, useState, useSyncExternalStore } from \"react\";\nimport { ActivityContext } from \"../runtime/activity\";\n\n/*\n * The time, read only in the browser. A component that reads the clock while it renders breaks server rendering:\n * Next.js refuses to prerender a page that does (\"encountered the unstable value `new Date()` in a Client Component\",\n * create-next-app's default since 16), and any server's time differs from the browser's at hydration. These hooks give\n * null on the server and while hydrating, and the real value in the browser before the first paint.\n */\n\nconst still = () => () => {};\nconst startOfToday = () => {\n  const d = new Date();\n  return new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();\n};\nconst onServer = () => null;\n\n/** Today at 00:00 local time; null on the server and while hydrating. */\nexport function useToday(): Date | null {\n  const day = useSyncExternalStore(still, startOfToday, onServer);\n  return useMemo(() => (day === null ? null : new Date(day)), [day]);\n}\n\n/** The time in ms, read before the first paint and again every `every` ms while `ticking`; null on the server. */\nexport function useNow(ticking = false, every = 1000, until?: number): number | null {\n  const active = useContext(ActivityContext);\n  const [now, setNow] = useState<number | null>(null);\n  // A finite deadline must reach its completion callback even when the host is idle, then stop ticking.\n  const running = ticking && (until === undefined ? active : now === null || now < until);\n  useLayoutEffect(() => {\n    setNow(Date.now());\n    if (!running) return;\n    const id = setInterval(() => setNow(Date.now()), every);\n    return () => clearInterval(id);\n  }, [running, every, until]);\n  return now;\n}\n"},{"path":"beamline/lib/number.ts","type":"registry:file","target":"src/ui/beamline/lib/number.ts","content":"import { createFormatters, FALLBACK_LOCALE } from \"../runtime/messages\";\n/** Reads a number typed in `locale` (\"1.234,5\" in de, \"1,234.5\" in en): group separators dropped, the locale's decimal\n *  mark read as the point, currency signs and units ignored. Empty or unreadable text is null; nothing is clamped. */\nexport function parseLocaleNumber(text: string, locale?: string): number | null {\n  if (!text.trim()) return null;\n  // exponent form: \"1e3\" is a thousand and \"2.5e-3\" a fraction (the digits are never run together into 13)\n  const exp = text.trim().match(/^(.*\\d)\\s*e\\s*([+\\u2212-]?\\d+)$/i);\n  if (exp) {\n    const base = parseLocaleNumber(exp[1], locale);\n    return base === null ? null : Number((base * 10 ** Number(exp[2].replace(\"\\u2212\", \"-\"))).toPrecision(15));\n  }\n  const parts = new Intl.NumberFormat(locale).formatToParts(12345.6);\n  const group = parts.find((p) => p.type === \"group\")?.value ?? \",\";\n  const decimal = parts.find((p) => p.type === \"decimal\")?.value ?? \".\";\n  let ascii = text;\n  // one grouping mark that cannot group (not three digits after it) and no decimal mark: the decimal was written the\n  // other locale's way (\"1,5\" in English is one and a half, never fifteen)\n  const marks = text.split(group).length - 1;\n  if (marks === 1 && !text.includes(decimal) && !new RegExp(`\\\\${group}\\\\d{3}(?!\\\\d)`).test(text))\n    ascii = text.replace(group, decimal);\n  if (/[^\\p{ASCII}]/u.test(text)) {\n    const digits = new Intl.NumberFormat(locale, { useGrouping: false });\n    for (let value = 0; value < 10; value++) ascii = ascii.replaceAll(digits.format(value), String(value));\n  }\n  const normalized = ascii\n    .replaceAll(group, \"\")\n    .replaceAll(\"\\u202f\", \"\")\n    .replace(decimal, \".\")\n    .replace(/[\\u2212\\u2013]/g, \"-\")\n    .replace(/[^\\d.-]/g, \"\");\n  if (!/\\d/.test(normalized)) return null;\n  const n = Number(normalized);\n  return Number.isFinite(n) ? n : null;\n}\n\nconst formatters = new Map<string, Intl.NumberFormat>();\n/** A number written from serializable settings, so a server component can pass them where a `format` function cannot\n *  cross: Intl options in a locale, with words before and after (\"$\" … \" / mo\"). One Intl.NumberFormat per setting. */\nexport function formatNumber(\n  value: number,\n  { locale, formatOptions, prefix = \"\", suffix = \"\" }: NumberFormatSettings = {},\n): string {\n  const key = `${locale ?? \"\"}|${JSON.stringify(formatOptions ?? {})}`;\n  let f = formatters.get(key);\n  if (!f) formatters.set(key, (f = new Intl.NumberFormat(locale, formatOptions)));\n  return `${prefix}${f.format(value)}${suffix}`;\n}\n\nexport interface NumberFormatSettings {\n  locale?: string;\n  formatOptions?: Intl.NumberFormatOptions;\n  /** Written before the number: \"$\". */\n  prefix?: string;\n  /** Written after the number: \" ms\", \" / mo\". */\n  suffix?: string;\n}\n\n/** Binary-scaled file sizes; the digits and unit names follow the supplied locale. */\nexport function formatByteSize(bytes: number, locale = FALLBACK_LOCALE, maximumUnit = 3, fractionDigits?: number) {\n  const units = [\"byte\", \"kilobyte\", \"megabyte\", \"gigabyte\"];\n  let value = bytes,\n    unit = 0;\n  while (value >= 1024 && unit < maximumUnit) {\n    value /= 1024;\n    unit++;\n  }\n  const digits = fractionDigits ?? (value < 10 && unit > 0 ? 1 : 0);\n  return createFormatters(locale).number(value, {\n    style: \"unit\",\n    unit: units[unit],\n    unitDisplay: \"short\",\n    minimumFractionDigits: digits,\n    maximumFractionDigits: digits,\n  });\n}\n"},{"path":"beamline/lib/utils.ts","type":"registry:file","target":"src/ui/beamline/lib/utils.ts","content":"import { clsx, type ClassValue } from \"clsx\";\nimport { extendTailwindMerge } from \"tailwind-merge\";\n\n/* The type roles (utilities.css) and the 2xs step are sizes, not text colours: without this, tailwind-merge reads\n   `text-overline` as a colour and drops it next to `text-ink-3`. A role and a size step still replace each other.\n   Likewise `font-title` is the look's title weight, not a family: read as a family it dropped `font-display` beside it,\n   and every merged page title lost the look's display face. */\nconst twMerge = extendTailwindMerge({\n  extend: {\n    classGroups: {\n      \"font-weight\": [{ font: [\"title\"] }],\n      \"font-family\": [{ font: [\"display\", \"numeric\", \"figure\"] }],\n      \"font-size\": [\n        {\n          text: [\n            \"2xs\",\n            \"display\",\n            \"title\",\n            \"heading\",\n            \"subheading\",\n            \"body\",\n            \"body-sm\",\n            \"reading\",\n            \"label\",\n            \"caption\",\n            \"overline\",\n            \"numeric\",\n            \"code\",\n          ],\n        },\n      ],\n    },\n  },\n});\n\n/** Merge class names, letting later Tailwind utilities win over earlier ones. */\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\n/** A small seeded random generator (LCG): the same seed gives the same sequence, for stable sample data and jitter. */\nexport function rng(seed = 1) {\n  let s = seed >>> 0 || 1;\n  return () => (s = (s * 1664525 + 1013904223) >>> 0) / 2 ** 32;\n}\n\nexport const clamp = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value));\n"}],"docs":"Recurrence editor is in src/ui/beamline/components/recurrence-editor/recurrence-editor.tsx. The source is in src/ui/beamline (ui/beamline in a project without src/). After Tailwind, import its styles/beamline.css once, then styles/look-prism.css in your app stylesheet (use relative paths). Keep the shared base before all chosen looks. Wrap your app in <UIRoot preset={prism}> with UIRoot from its runtime/appearance and prism from its looks/prism.  shadcn replaces files when asked; use the Beamline managed-source CLI from the start for three-way upgrades that preserve edits.","meta":{"free":true,"version":"0.2.0-rc.42","library":"https://beamline.io/components/recurrence-editor"}}