{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "onboarding-02",
  "title": "Setup wizard",
  "description": "Four steps on the stepper, each checked before it lets go: a refused entry says why and takes the focus, optional steps can be skipped, the card resizes from one step to the next, the review jumps back to any step with Edit, and Create workspace turns into Creating then into the workspace that now exists.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/animated-size.json",
    "https://ui.ndekocode.dev/r/brand-logos.json",
    "https://ui.ndekocode.dev/r/brand-tile.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/demonstration.json",
    "https://ui.ndekocode.dev/r/field.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/input.json",
    "https://ui.ndekocode.dev/r/label.json",
    "https://ui.ndekocode.dev/r/live-duration.json",
    "https://ui.ndekocode.dev/r/live-region.json",
    "https://ui.ndekocode.dev/r/morph-button.json",
    "https://ui.ndekocode.dev/r/motion-presets.json",
    "https://ui.ndekocode.dev/r/radio-group.json",
    "https://ui.ndekocode.dev/r/replay-button.json",
    "https://ui.ndekocode.dev/r/segments.json",
    "https://ui.ndekocode.dev/r/stepper.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/use-session.json",
    "https://ui.ndekocode.dev/r/use-timeouts.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/onboarding/onboarding-02/index.tsx",
      "content": "'use client';\n\nimport { useEffect } from 'react';\n\nimport { useSession } from '@/registry/ndeko/hooks/use-session';\nimport { useTimeouts } from '@/registry/ndeko/hooks/use-timeouts';\nimport {\n  pressedQuietOf,\n  pressedSolidOf,\n  spokenUnless,\n} from '@/registry/ndeko/lib/demonstration';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { ClockGate } from '@/registry/ndeko/ui/live-duration';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\nimport { MorphButton, type MorphState } from '@/registry/ndeko/ui/morph-button';\nimport { ReplayButton } from '@/registry/ndeko/ui/replay-button';\nimport {\n  Stepper,\n  StepperIndicator,\n  StepperItem,\n  StepperSeparator,\n  StepperTrigger,\n} from '@/registry/ndeko/ui/stepper';\n\nimport {\n  indexOfStep,\n  stepOf,\n  STEPS,\n  type Fields,\n  type RoleId,\n  type SourceId,\n  type StepId,\n} from './data';\nimport { ReviewStep, Success } from './review-step';\nimport {\n  CREATE_MS,\n  INITIAL,\n  LOOP_AFTER_MS,\n  reducer,\n  RESTING,\n  SCRIPT,\n  TOTAL,\n  type FinishStatus,\n  type WizardAction,\n} from './session';\nimport { firstErrorOf } from './validate';\nimport { SourceStep, TeamStep, WorkspaceStep } from './wizard-steps';\n\nconst SESSION = {\n  reducer,\n  initial: INITIAL,\n  resting: RESTING,\n  script: SCRIPT,\n  loopAfter: LOOP_AFTER_MS,\n};\n\nconst FINISH_STATE: Record<FinishStatus, MorphState> = {\n  idle: 'idle',\n  creating: 'busy',\n  created: 'done',\n};\n\nconst FINISH_LABELS: Record<MorphState, string> = {\n  idle: 'Create workspace',\n  busy: 'Creating',\n  done: 'Created',\n};\n\n/** What the wizard hands over once the workspace is created. */\nexport type WorkspaceSetup = {\n  name: string;\n  slug: string;\n  /** Nothing when the step was skipped. */\n  source: SourceId | null;\n  connection: string | null;\n  invites: string[];\n  role: RoleId;\n};\n\nfunction setupOf(fields: Fields, skipped: StepId[]): WorkspaceSetup {\n  const setup: WorkspaceSetup = {\n    name: fields.name.trim(),\n    slug: fields.slug,\n    source: null,\n    connection: null,\n    invites: [],\n    role: fields.role,\n  };\n  if (!skipped.includes('source')) {\n    setup.source = fields.source;\n    setup.connection = fields.connection.trim();\n  }\n  if (!skipped.includes('team')) {\n    setup.invites = fields.invites;\n  }\n  return setup;\n}\n\n/** Once the workspace exists every step counts as done: the stepper is told the step after the last. */\nfunction activeNumberOf(stepIndex: number, isCreated: boolean) {\n  if (isCreated) {\n    return TOTAL + 1;\n  }\n  return stepIndex + 1;\n}\n\nfunction currentStepOf(isCurrent: boolean): 'step' | undefined {\n  if (isCurrent) {\n    return 'step';\n  }\n  return undefined;\n}\n\n/** A step opened from the review leads back to it. */\nfunction nextLabelOf(isReturning: boolean) {\n  if (isReturning) {\n    return 'Back to review';\n  }\n  return 'Next';\n}\n\n/** The first step is there when the page loads. The ones that follow fade in. */\nfunction arrivalOf(hasMoved: boolean) {\n  if (hasMoved) {\n    return 'transition-opacity duration-200 starting:opacity-0';\n  }\n  return undefined;\n}\n\nfunction stepLineOf(stepIndex: number, isOptional: boolean) {\n  const line = `Step ${stepIndex + 1} of ${TOTAL}`;\n  if (isOptional) {\n    return `${line}, optional`;\n  }\n  return line;\n}\n\nexport type Onboarding02Props = {\n  /**\n   * Keeps the step in the hash of the address, and follows the hash when it changes. It waits for a\n   * person: the demonstration never writes to the address of the page.\n   */\n  syncHash?: boolean;\n  /** Nothing calls a network. A real app creates the workspace here. */\n  onFinish?: (setup: WorkspaceSetup) => void;\n};\n\nexport default function Onboarding02({\n  syncHash = false,\n  onFinish,\n}: Onboarding02Props) {\n  const {\n    ref,\n    isInView,\n    isAutoplaying,\n    state,\n    act,\n    pressed,\n    isFinished,\n    restart,\n  } = useSession(SESSION);\n  const { schedule, clearAll } = useTimeouts();\n  const step = stepOf(state.step);\n  const stepIndex = indexOfStep(state.step);\n  const isCreated = state.finish === 'created';\n  const isCreating = state.finish === 'creating';\n  const isEditable = state.finish === 'idle';\n  const isReview = state.step === 'review';\n  const canGoBack = stepIndex > 0;\n  const canSkip = step.isOptional;\n  const activeNumber = activeNumberOf(stepIndex, isCreated);\n  const shouldSyncHash = syncHash && !isAutoplaying;\n  const message = spokenUnless(isAutoplaying, state.spoken);\n  const canReplay = isFinished && !isAutoplaying;\n  useEffect(() => {\n    if (!shouldSyncHash) {\n      return;\n    }\n    const hash = `#${state.step}`;\n    if (window.location.hash !== hash) {\n      window.history.replaceState(null, '', hash);\n    }\n  }, [shouldSyncHash, state.step]);\n\n  useEffect(() => {\n    if (!shouldSyncHash) {\n      return;\n    }\n    function followHash() {\n      const id = window.location.hash.slice(1);\n      const target = STEPS.find((candidate) => candidate.id === id);\n      if (target) {\n        act({ type: 'jumped', step: target.id });\n      }\n    }\n    window.addEventListener('hashchange', followHash);\n    return () => window.removeEventListener('hashchange', followHash);\n  }, [shouldSyncHash, act]);\n\n  function focusLater(selector: string) {\n    requestAnimationFrame(() => {\n      const target = ref.current?.querySelector<HTMLElement>(selector);\n      target?.focus();\n    });\n  }\n\n  /**\n   * Works out where an action leads before it is sent: a step that changes takes the focus to its\n   * heading, an entry that is refused takes it to the first field at fault.\n   */\n  function actAndFollow(action: WizardAction) {\n    const after = reducer(state, action);\n    act(action);\n    if (after.step !== state.step) {\n      focusLater('[data-step-heading]');\n      return;\n    }\n    const wasRefused = after.attempts !== state.attempts;\n    const refusal = firstErrorOf(after.errors);\n    if (wasRefused && refusal) {\n      focusLater(`[data-field=\"${refusal.field}\"]`);\n    }\n  }\n\n  const stepBody = {\n    fields: state.fields,\n    errors: state.errors,\n    attempts: state.attempts,\n    pressed,\n    onAction: actAndFollow,\n  };\n\n  /** The button leaves with the review once the workspace exists: a focus that sat on it goes to the message. */\n  function create(setup: WorkspaceSetup) {\n    const finishButton = ref.current?.querySelector('[data-finish]');\n    const hadFocus = finishButton === document.activeElement;\n    act({ type: 'created' });\n    onFinish?.(setup);\n    if (finishButton && hadFocus) {\n      focusLater('[data-success]');\n    }\n  }\n\n  function finish() {\n    if (!isEditable) {\n      return;\n    }\n    const setup = setupOf(state.fields, state.skipped);\n    act({ type: 'finishPressed' });\n    schedule(() => create(setup), CREATE_MS);\n  }\n\n  function submit(event: React.FormEvent<HTMLFormElement>) {\n    event.preventDefault();\n    if (isReview) {\n      finish();\n      return;\n    }\n    actAndFollow({ type: 'nextPressed' });\n  }\n\n  function jumpToNumber(number: number) {\n    const target = STEPS[number - 1];\n    if (target) {\n      actAndFollow({ type: 'jumped', step: target.id });\n    }\n  }\n\n  /** The chip takes its button with it, so the focus goes back to the address box. */\n  function removeInvite(address: string) {\n    act({ type: 'inviteRemoved', address });\n    focusLater('[data-field=\"invites\"]');\n  }\n\n  /** A workspace on its way belongs to the round it was asked for in. */\n  function replay() {\n    clearAll();\n    restart();\n  }\n\n  return (\n    <ClockGate isActive={isInView}>\n      <div\n        ref={ref}\n        className='bg-background text-foreground @container flex min-h-dvh w-full flex-col items-center p-4 @2xl:p-8'\n      >\n        <div className='flex w-full max-w-xl flex-col gap-5 @2xl:pt-4'>\n          <header className='flex min-h-8 items-center gap-3'>\n            <h1 className='min-w-0 flex-1 text-lg font-semibold text-balance'>\n              Set up a workspace\n            </h1>\n            <ReplayButton\n              isShown={canReplay}\n              onReplay={replay}\n              label='Replay'\n            />\n          </header>\n\n          <nav aria-label='Setup steps'>\n            <Stepper value={activeNumber} onValueChange={jumpToNumber}>\n              {STEPS.map((candidate, index) => {\n                const number = index + 1;\n                const isLast = number === TOTAL;\n                const isAhead = index > state.furthest;\n                const isCurrent = index === stepIndex && !isCreated;\n                return (\n                  <StepperItem\n                    key={candidate.id}\n                    step={number}\n                    disabled={isAhead || !isEditable}\n                    loading={isCreating}\n                    className='not-last:flex-1'\n                  >\n                    <StepperTrigger\n                      aria-current={currentStepOf(isCurrent)}\n                      className='gap-2'\n                    >\n                      <StepperIndicator />\n                      <span className='sr-only text-[13px] font-medium whitespace-nowrap @md:not-sr-only'>\n                        {candidate.label}\n                      </span>\n                    </StepperTrigger>\n                    {!isLast && <StepperSeparator className='mx-2' />}\n                  </StepperItem>\n                );\n              })}\n            </Stepper>\n          </nav>\n\n          <section\n            aria-label='Workspace setup'\n            className='bg-card hairline-ring ring-border dark:bg-foreground/[0.03] rounded-xl p-5 shadow-[0_1px_2px_rgb(0_0_0/0.04)]'\n          >\n            <AnimatedSize>\n              {isCreated && (\n                <Success\n                  fields={state.fields}\n                  skipped={state.skipped}\n                  onRestart={() => actAndFollow({ type: 'restarted' })}\n                />\n              )}\n              {!isCreated && (\n                <form\n                  key={state.step}\n                  noValidate\n                  onSubmit={submit}\n                  className={cn(\n                    'flex flex-col gap-5',\n                    arrivalOf(state.moves > 0)\n                  )}\n                >\n                  <div className='flex flex-col gap-1'>\n                    <p className='text-muted-foreground text-xs tabular-nums'>\n                      {stepLineOf(stepIndex, step.isOptional)}\n                    </p>\n                    <h2\n                      data-step-heading\n                      tabIndex={-1}\n                      className='focus-visible:ring-ring/25 rounded-sm text-base font-semibold text-balance outline-none focus-visible:ring-[3px]'\n                    >\n                      {step.title}\n                    </h2>\n                    <p className='text-muted-foreground text-[13px] text-pretty'>\n                      {step.lead}\n                    </p>\n                  </div>\n\n                  {state.step === 'workspace' && (\n                    <WorkspaceStep {...stepBody} />\n                  )}\n                  {state.step === 'source' && <SourceStep {...stepBody} />}\n                  {state.step === 'team' && (\n                    <TeamStep {...stepBody} onRemoveInvite={removeInvite} />\n                  )}\n                  {isReview && (\n                    <ReviewStep\n                      fields={state.fields}\n                      skipped={state.skipped}\n                      isLocked={!isEditable}\n                      pressed={pressed}\n                      onEdit={(target) =>\n                        actAndFollow({ type: 'jumped', step: target })\n                      }\n                    />\n                  )}\n\n                  <div className='flex flex-wrap items-center gap-2'>\n                    {canGoBack && (\n                      <Button\n                        type='button'\n                        variant='ghost'\n                        disabled={!isEditable}\n                        onClick={() => actAndFollow({ type: 'backPressed' })}\n                      >\n                        Back\n                      </Button>\n                    )}\n                    <span className='flex-1' />\n                    {canSkip && (\n                      <Button\n                        type='button'\n                        variant='ghost'\n                        onClick={() => actAndFollow({ type: 'skipPressed' })}\n                        className={cn(\n                          'text-muted-foreground',\n                          pressedQuietOf(pressed === 'skip')\n                        )}\n                      >\n                        Skip\n                      </Button>\n                    )}\n                    {!isReview && (\n                      <Button\n                        type='submit'\n                        className={pressedSolidOf(pressed === 'next')}\n                      >\n                        {nextLabelOf(state.isReturning)}\n                      </Button>\n                    )}\n                    {isReview && (\n                      <MorphButton\n                        type='submit'\n                        data-finish\n                        state={FINISH_STATE[state.finish]}\n                        labels={FINISH_LABELS}\n                        className={pressedSolidOf(pressed === 'finish')}\n                      />\n                    )}\n                  </div>\n                </form>\n              )}\n            </AnimatedSize>\n          </section>\n        </div>\n        <LiveRegion message={message} />\n      </div>\n    </ClockGate>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/onboarding-02/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/onboarding/onboarding-02/wizard-steps.tsx",
      "content": "'use client';\n\nimport { useId } from 'react';\n\nimport { pressedQuietOf } from '@/registry/ndeko/lib/demonstration';\nimport { MailIcon, XIcon } from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { BrandTile } from '@/registry/ndeko/ui/brand-tile';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport {\n  Field,\n  FieldDescription,\n  FieldError,\n  FieldLabel,\n} from '@/registry/ndeko/ui/field';\nimport { Input } from '@/registry/ndeko/ui/input';\nimport { Label, LABEL_RECIPE } from '@/registry/ndeko/ui/label';\nimport { RadioGroup, RadioGroupItem } from '@/registry/ndeko/ui/radio-group';\nimport { Segments } from '@/registry/ndeko/ui/segments';\n\nimport { ROLES, SOURCES, URL_PREFIX, type Fields } from './data';\nimport type { WizardAction } from './session';\nimport type { Errors } from './validate';\n\n/** A tray inside the card, tinted when its source is the one picked. The whole tray answers the press. */\nconst CHOICE =\n  'bg-foreground/[0.04] has-data-checked:bg-primary/[0.08] relative flex items-center gap-3 rounded-lg p-3 transition-[background-color,scale] duration-150';\n\n/** Someone invited has not joined yet: a dashed slot with an envelope, since nobody is there. */\nconst INVITED =\n  'hairline-border border-foreground/25 flex h-7 max-w-full items-center gap-1.5 rounded-full border-dashed ps-2.5 pe-0.5 text-xs transition-opacity duration-200 starting:opacity-0';\n\nconst REMOVE =\n  'focus-visible:ring-ring/25 hover:bg-foreground/[0.08] text-muted-foreground hover:text-foreground flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-full transition-colors duration-150 outline-none focus-visible:ring-[3px]';\n\nconst LONE_ERROR =\n  'text-destructive-ink text-xs transition-[opacity,translate] duration-200 ease-(--ease-out-strong) starting:-translate-y-0.5 starting:opacity-0';\n\n/** A space, a comma or a semicolon ends an address as it is typed. */\nconst ENDS_AN_ADDRESS = /[\\s,;]$/;\n\nexport type StepBodyProps = {\n  fields: Fields;\n  errors: Errors;\n  /** Counts the refused entries: a message that comes back after a new try arrives again. */\n  attempts: number;\n  pressed: string | null;\n  onAction: (action: WizardAction) => void;\n};\n\nexport function WorkspaceStep({\n  fields,\n  errors,\n  attempts,\n  onAction,\n}: StepBodyProps) {\n  return (\n    <div className='flex flex-col gap-4'>\n      <Field invalid={Boolean(errors.name)}>\n        <FieldLabel>Workspace name</FieldLabel>\n        <Input\n          data-field='name'\n          autoComplete='organization'\n          placeholder='The name of your company or team'\n          value={fields.name}\n          onChange={(event) =>\n            onAction({\n              type: 'typed',\n              field: 'name',\n              value: event.target.value,\n            })\n          }\n        />\n        {errors.name && (\n          <FieldError key={attempts} match>\n            {errors.name}\n          </FieldError>\n        )}\n      </Field>\n      <Field invalid={Boolean(errors.slug)}>\n        <FieldLabel>Workspace address</FieldLabel>\n        <div className='flex items-center gap-2'>\n          <span className='text-muted-foreground shrink-0 text-[13px]'>\n            {URL_PREFIX}\n          </span>\n          <Input\n            data-field='slug'\n            autoComplete='off'\n            autoCapitalize='none'\n            spellCheck={false}\n            placeholder='your-workspace'\n            value={fields.slug}\n            onChange={(event) =>\n              onAction({\n                type: 'typed',\n                field: 'slug',\n                value: event.target.value,\n              })\n            }\n          />\n        </div>\n        {errors.slug && (\n          <FieldError key={attempts} match>\n            {errors.slug}\n          </FieldError>\n        )}\n        {!errors.slug && (\n          <FieldDescription>\n            It follows the name until you change it\n          </FieldDescription>\n        )}\n      </Field>\n    </div>\n  );\n}\n\n/** The first source carries the mark the focus goes to when no source is picked. */\nfunction fieldMarkOf(index: number) {\n  if (index === 0) {\n    return 'source';\n  }\n  return undefined;\n}\n\nfunction describedByOf(hasError: boolean, errorId: string) {\n  if (hasError) {\n    return errorId;\n  }\n  return undefined;\n}\n\nexport function SourceStep({\n  fields,\n  errors,\n  attempts,\n  pressed,\n  onAction,\n}: StepBodyProps) {\n  const groupId = useId();\n  const errorId = `${groupId}-error`;\n  const hasSourceError = Boolean(errors.source);\n\n  function pick(value: unknown) {\n    const source = SOURCES.find((candidate) => candidate.id === value);\n    if (source) {\n      onAction({ type: 'sourcePicked', source: source.id });\n    }\n  }\n\n  return (\n    <div className='flex flex-col gap-4'>\n      <div className='flex flex-col gap-2'>\n        <RadioGroup\n          aria-label='Data source'\n          aria-describedby={describedByOf(hasSourceError, errorId)}\n          value={fields.source ?? ''}\n          onValueChange={pick}\n          className='grid-cols-1 gap-2 @md:grid-cols-2'\n        >\n          {SOURCES.map((source, index) => {\n            const itemId = `${groupId}-${source.id}`;\n            return (\n              <div\n                key={source.id}\n                className={cn(\n                  CHOICE,\n                  pressedQuietOf(pressed === `source-${source.id}`)\n                )}\n              >\n                <RadioGroupItem\n                  id={itemId}\n                  value={source.id}\n                  data-field={fieldMarkOf(index)}\n                  className='order-1 after:absolute after:inset-0 after:rounded-lg'\n                />\n                <BrandTile brand={source.brand} size='lg' />\n                <div className='flex min-w-0 flex-1 flex-col gap-1'>\n                  <Label htmlFor={itemId}>{source.name}</Label>\n                  <p className='text-muted-foreground text-xs'>{source.kind}</p>\n                </div>\n              </div>\n            );\n          })}\n        </RadioGroup>\n        {errors.source && (\n          <p key={attempts} id={errorId} className={LONE_ERROR}>\n            {errors.source}\n          </p>\n        )}\n      </div>\n      <Field invalid={Boolean(errors.connection)}>\n        <FieldLabel>Connection name</FieldLabel>\n        <Input\n          data-field='connection'\n          autoComplete='off'\n          value={fields.connection}\n          onChange={(event) =>\n            onAction({\n              type: 'typed',\n              field: 'connection',\n              value: event.target.value,\n            })\n          }\n        />\n        {errors.connection && (\n          <FieldError key={attempts} match>\n            {errors.connection}\n          </FieldError>\n        )}\n      </Field>\n    </div>\n  );\n}\n\ntype TeamStepProps = StepBodyProps & {\n  onRemoveInvite: (address: string) => void;\n};\n\nexport function TeamStep({\n  fields,\n  errors,\n  attempts,\n  pressed,\n  onAction,\n  onRemoveInvite,\n}: TeamStepProps) {\n  const hasInvites = fields.invites.length > 0;\n\n  function typeAddress(value: string) {\n    onAction({ type: 'typed', field: 'inviteDraft', value });\n    if (ENDS_AN_ADDRESS.test(value)) {\n      onAction({ type: 'inviteCommitted' });\n    }\n  }\n\n  /** Enter adds what the box holds. On an empty box it is left alone, and goes on to the next step. */\n  function addOnEnter(event: React.KeyboardEvent<HTMLInputElement>) {\n    const isBoxEmpty = fields.inviteDraft.trim() === '';\n    if (event.key !== 'Enter' || isBoxEmpty) {\n      return;\n    }\n    event.preventDefault();\n    onAction({ type: 'inviteCommitted' });\n  }\n\n  function changeRole(role: Fields['role']) {\n    onAction({ type: 'rolePicked', role });\n  }\n\n  return (\n    <div className='flex flex-col gap-4'>\n      <Field invalid={Boolean(errors.invites)}>\n        <FieldLabel>Email addresses</FieldLabel>\n        <div className='flex items-center gap-2'>\n          <Input\n            data-field='invites'\n            inputMode='email'\n            autoComplete='off'\n            autoCapitalize='none'\n            spellCheck={false}\n            placeholder='name@company.com'\n            value={fields.inviteDraft}\n            onChange={(event) => typeAddress(event.target.value)}\n            onKeyDown={addOnEnter}\n          />\n          <Button\n            type='button'\n            variant='outline'\n            onClick={() => onAction({ type: 'inviteCommitted' })}\n            className={cn('shrink-0', pressedQuietOf(pressed === 'add-invite'))}\n          >\n            Add\n          </Button>\n        </div>\n        {errors.invites && (\n          <FieldError key={attempts} match>\n            {errors.invites}\n          </FieldError>\n        )}\n        {!errors.invites && (\n          <FieldDescription>\n            Press Enter after each address, or paste several at once\n          </FieldDescription>\n        )}\n      </Field>\n      <div className='flex min-h-7 items-center'>\n        {!hasInvites && (\n          <p className='text-muted-foreground text-xs'>Nobody is invited yet</p>\n        )}\n        {hasInvites && (\n          <ul\n            aria-label='People to invite'\n            className='flex min-w-0 flex-wrap gap-1.5'\n          >\n            {fields.invites.map((address) => (\n              <li key={address} className={INVITED}>\n                <MailIcon\n                  aria-hidden='true'\n                  className='text-muted-foreground size-3.5 shrink-0'\n                />\n                <span className='min-w-0 truncate'>{address}</span>\n                <button\n                  type='button'\n                  aria-label={`Remove ${address}`}\n                  onClick={() => onRemoveInvite(address)}\n                  className={REMOVE}\n                >\n                  <XIcon className='size-3.5' />\n                </button>\n              </li>\n            ))}\n          </ul>\n        )}\n      </div>\n      <div className='flex flex-col items-start gap-1.5'>\n        <p className={LABEL_RECIPE}>They join as</p>\n        <Segments\n          value={fields.role}\n          segments={ROLES}\n          onValueChange={changeRole}\n          label='Role of the people you invite'\n        />\n      </div>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/onboarding-02/wizard-steps.tsx"
    },
    {
      "path": "registry/ndeko/blocks/onboarding/onboarding-02/review-step.tsx",
      "content": "'use client';\n\nimport { pressedQuietOf } from '@/registry/ndeko/lib/demonstration';\nimport { BrandTile } from '@/registry/ndeko/ui/brand-tile';\nimport { Button } from '@/registry/ndeko/ui/button';\n\nimport { CalmCheck } from './calm-check';\nimport {\n  roleLabelOf,\n  sourceOf,\n  stepOf,\n  URL_PREFIX,\n  type Fields,\n  type StepId,\n} from './data';\n\n/** The source the workspace starts with: none when the step was skipped. */\nfunction keptSourceOf(fields: Fields, skipped: StepId[]) {\n  if (skipped.includes('source')) {\n    return null;\n  }\n  return sourceOf(fields.source);\n}\n\nfunction peopleLineOf(fields: Fields) {\n  const count = fields.invites.length;\n  const role = roleLabelOf(fields.role);\n  if (count === 1) {\n    return `1 person invited as ${role}`;\n  }\n  return `${count} people invited as ${role}`;\n}\n\ntype ReviewRowProps = {\n  step: StepId;\n  isLocked: boolean;\n  isPressed: boolean;\n  onEdit: (step: StepId) => void;\n  children: React.ReactNode;\n};\n\n/** One thing the wizard will create, with the way back to the step that sets it. */\nfunction ReviewRow({\n  step,\n  isLocked,\n  isPressed,\n  onEdit,\n  children,\n}: ReviewRowProps) {\n  const label = stepOf(step).label;\n\n  return (\n    <div className='bg-foreground/[0.04] flex flex-col gap-1 rounded-lg p-3'>\n      <dt className='text-muted-foreground text-xs'>{label}</dt>\n      <dd className='flex items-start gap-3'>\n        <div className='flex min-w-0 flex-1 flex-col gap-0.5 text-[13px]'>\n          {children}\n        </div>\n        <Button\n          type='button'\n          variant='link'\n          size='sm'\n          aria-label={`Edit ${label}`}\n          disabled={isLocked}\n          onClick={() => onEdit(step)}\n          className={pressedQuietOf(isPressed)}\n        >\n          Edit\n        </Button>\n      </dd>\n    </div>\n  );\n}\n\nfunction Skipped() {\n  return <p className='text-muted-foreground'>Skipped. You can do it later</p>;\n}\n\ntype ReviewStepProps = {\n  fields: Fields;\n  skipped: StepId[];\n  /** While the workspace is being created nothing can be changed any more. */\n  isLocked: boolean;\n  pressed: string | null;\n  onEdit: (step: StepId) => void;\n};\n\nexport function ReviewStep({\n  fields,\n  skipped,\n  isLocked,\n  pressed,\n  onEdit,\n}: ReviewStepProps) {\n  const source = keptSourceOf(fields, skipped);\n  const isTeamSkipped = skipped.includes('team') || fields.invites.length === 0;\n\n  return (\n    <dl className='flex flex-col gap-2'>\n      <ReviewRow\n        step='workspace'\n        isLocked={isLocked}\n        isPressed={pressed === 'edit-workspace'}\n        onEdit={onEdit}\n      >\n        <p className='truncate font-medium'>{fields.name.trim()}</p>\n        <p className='text-muted-foreground truncate text-xs'>\n          {URL_PREFIX}\n          {fields.slug}\n        </p>\n      </ReviewRow>\n      <ReviewRow\n        step='source'\n        isLocked={isLocked}\n        isPressed={pressed === 'edit-source'}\n        onEdit={onEdit}\n      >\n        {!source && <Skipped />}\n        {source && (\n          <p className='flex min-w-0 items-center gap-2 font-medium'>\n            <BrandTile brand={source.brand} />\n            <span className='truncate'>\n              {source.name}, as {fields.connection.trim()}\n            </span>\n          </p>\n        )}\n      </ReviewRow>\n      <ReviewRow\n        step='team'\n        isLocked={isLocked}\n        isPressed={pressed === 'edit-team'}\n        onEdit={onEdit}\n      >\n        {isTeamSkipped && <Skipped />}\n        {!isTeamSkipped && (\n          <>\n            <p className='font-medium'>{peopleLineOf(fields)}</p>\n            <p className='text-muted-foreground text-xs break-words'>\n              {fields.invites.join(', ')}\n            </p>\n          </>\n        )}\n      </ReviewRow>\n    </dl>\n  );\n}\n\n/** What the workspace starts with, in one or two short sentences. */\nfunction summaryOf(fields: Fields, skipped: StepId[]) {\n  const sentences = [`It lives at ${URL_PREFIX}${fields.slug}.`];\n  const source = keptSourceOf(fields, skipped);\n  if (source) {\n    sentences.push(`${source.name} is connected.`);\n  }\n  const hasTeam = fields.invites.length > 0 && !skipped.includes('team');\n  if (hasTeam) {\n    sentences.push(`${peopleLineOf(fields)}.`);\n  }\n  return sentences.join(' ');\n}\n\ntype SuccessProps = {\n  fields: Fields;\n  skipped: StepId[];\n  onRestart: () => void;\n};\n\nexport function Success({ fields, skipped, onRestart }: SuccessProps) {\n  return (\n    <div\n      data-success\n      tabIndex={-1}\n      className='flex flex-col items-start gap-4 py-1 transition-opacity duration-300 outline-none starting:opacity-0'\n    >\n      <CalmCheck />\n      <div className='flex flex-col gap-1'>\n        <h2 className='text-lg font-semibold text-balance'>\n          {fields.name.trim()} is ready\n        </h2>\n        <p className='text-muted-foreground text-[13px] leading-relaxed text-pretty'>\n          {summaryOf(fields, skipped)}\n        </p>\n      </div>\n      <Button type='button' variant='outline' onClick={onRestart}>\n        Set up another workspace\n      </Button>\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/onboarding-02/review-step.tsx"
    },
    {
      "path": "registry/ndeko/blocks/onboarding/onboarding-02/calm-check.tsx",
      "content": "'use client';\n\nimport { motion } from 'motion/react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { EASE_OUT_STRONG } from '@/registry/ndeko/lib/motion-presets';\n\nconst CHECK_PATH = 'M2.6 6.4 4.9 8.7 9.5 3.6';\n\nconst DRAW = { duration: 0.45, ease: EASE_OUT_STRONG, delay: 0.15 };\n\nconst DRAWN = { pathLength: 1 };\n\nconst NOT_DRAWN = { pathLength: 0 };\n\nfunction strokeStartOf(shouldReduceMotion: boolean) {\n  if (shouldReduceMotion) {\n    return DRAWN;\n  }\n  return NOT_DRAWN;\n}\n\n/** The mark of the workspace that now exists. Its stroke draws itself when it mounts; reduced motion shows it drawn. */\nexport function CalmCheck() {\n  const shouldReduceMotion = usePrefersReducedMotion();\n\n  return (\n    <span className='bg-success/10 text-success-foreground flex size-10 shrink-0 items-center justify-center rounded-full'>\n      <svg aria-hidden='true' viewBox='0 0 12 12' className='size-5'>\n        <motion.path\n          d={CHECK_PATH}\n          fill='none'\n          stroke='currentColor'\n          strokeWidth={1.4}\n          strokeLinecap='round'\n          strokeLinejoin='round'\n          initial={strokeStartOf(shouldReduceMotion)}\n          animate={DRAWN}\n          transition={DRAW}\n        />\n      </svg>\n    </span>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/onboarding-02/calm-check.tsx"
    },
    {
      "path": "registry/ndeko/blocks/onboarding/onboarding-02/validate.ts",
      "content": "import type { Fields, StepId } from './data';\n\nexport type FieldName = 'name' | 'slug' | 'source' | 'connection' | 'invites';\n\nexport type Errors = Partial<Record<FieldName, string>>;\n\n/** The order the fields are read in: the first one with an error is the one that is said and focused. */\nexport const FIELD_ORDER: FieldName[] = [\n  'name',\n  'slug',\n  'source',\n  'connection',\n  'invites',\n];\n\nconst SHORTEST_NAME = 2;\n\nconst SHORTEST_SLUG = 3;\n\nconst SLUG = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\n\nconst SEPARATORS = /[\\s,;]+/;\n\n/** Solway Books becomes solway-books: what an address can hold, and nothing else. */\nexport function slugOf(name: string) {\n  const lowered = name.toLowerCase();\n  const words = lowered.split(/[^a-z0-9]+/);\n  const kept = words.filter((word) => word !== '');\n  return kept.join('-');\n}\n\n/**\n * One @ with something before it, and a dot inside what follows. Read by hand, piece by piece,\n * so a long pasted text can never make the check slow.\n */\nfunction isEmail(text: string) {\n  const at = text.indexOf('@');\n  const hasOneAt = at > 0 && at === text.lastIndexOf('@');\n  if (!hasOneAt) {\n    return false;\n  }\n  const domain = text.slice(at + 1);\n  const dot = domain.lastIndexOf('.');\n  const lastPlace = domain.length - 1;\n  return dot > 0 && dot < lastPlace;\n}\n\nfunction nameErrorOf(name: string) {\n  const trimmed = name.trim();\n  if (trimmed.length < SHORTEST_NAME) {\n    return 'Enter a name of at least 2 characters';\n  }\n  return undefined;\n}\n\nfunction slugErrorOf(slug: string) {\n  if (slug === '') {\n    return 'Enter an address for the workspace';\n  }\n  if (!SLUG.test(slug)) {\n    return 'Use lowercase letters, numbers and single hyphens';\n  }\n  if (slug.length < SHORTEST_SLUG) {\n    return 'Use at least 3 characters';\n  }\n  return undefined;\n}\n\nfunction workspaceErrorsOf(fields: Fields): Errors {\n  return {\n    name: nameErrorOf(fields.name),\n    slug: slugErrorOf(fields.slug),\n  };\n}\n\nfunction sourceErrorsOf(fields: Fields): Errors {\n  if (fields.source === null) {\n    return { source: 'Pick a source, or skip this step' };\n  }\n  if (fields.connection.trim() === '') {\n    return { connection: 'Name this connection' };\n  }\n  return {};\n}\n\nfunction teamErrorsOf(fields: Fields): Errors {\n  if (fields.invites.length === 0) {\n    return { invites: 'Add at least one address, or skip this step' };\n  }\n  return {};\n}\n\n/** What keeps a step from being left with Next. The review step has nothing to check. */\nexport function errorsOf(step: StepId, fields: Fields): Errors {\n  if (step === 'workspace') {\n    return workspaceErrorsOf(fields);\n  }\n  if (step === 'source') {\n    return sourceErrorsOf(fields);\n  }\n  if (step === 'team') {\n    return teamErrorsOf(fields);\n  }\n  return {};\n}\n\nexport function firstErrorOf(errors: Errors) {\n  const field = FIELD_ORDER.find((name) => errors[name] !== undefined);\n  if (!field) {\n    return null;\n  }\n  return { field, message: errors[field] ?? '' };\n}\n\nexport type Committed = {\n  invites: string[];\n  /** What could not be read as an address stays in the box. */\n  inviteDraft: string;\n  error?: string;\n};\n\nfunction notAnAddressLineOf(rejected: string[]) {\n  const [first] = rejected;\n  if (rejected.length === 1) {\n    return `${first} is not an email address`;\n  }\n  return `${first} and ${rejected.length - 1} more are not email addresses`;\n}\n\n/**\n * Turns what the address box holds into addresses: several can be pasted at once, separated by\n * spaces, commas or semicolons. One that is already invited is not added twice.\n */\nexport function committedInvites(fields: Fields): Committed {\n  const pieces = fields.inviteDraft.split(SEPARATORS);\n  const typed = pieces.filter((piece) => piece !== '');\n  const invites = [...fields.invites];\n  const rejected: string[] = [];\n  for (const piece of typed) {\n    const address = piece.toLowerCase();\n    if (!isEmail(address)) {\n      rejected.push(piece);\n      continue;\n    }\n    if (!invites.includes(address)) {\n      invites.push(address);\n    }\n  }\n  if (rejected.length === 0) {\n    return { invites, inviteDraft: '' };\n  }\n  return {\n    invites,\n    inviteDraft: rejected.join(' '),\n    error: notAnAddressLineOf(rejected),\n  };\n}\n",
      "type": "registry:component",
      "target": "components/blocks/onboarding-02/validate.ts"
    },
    {
      "path": "registry/ndeko/blocks/onboarding/onboarding-02/session.ts",
      "content": "import type { SessionStep } from '@/registry/ndeko/hooks/use-session';\nimport { keyDelayOf, prefixesOf } from '@/registry/ndeko/lib/demonstration';\n\nimport {\n  EMPTY_FIELDS,\n  indexOfStep,\n  stepOf,\n  STEPS,\n  type Fields,\n  type RoleId,\n  type SourceId,\n  type StepId,\n} from './data';\nimport {\n  committedInvites,\n  errorsOf,\n  firstErrorOf,\n  slugOf,\n  type Errors,\n  type FieldName,\n} from './validate';\n\nexport type FinishStatus = 'idle' | 'creating' | 'created';\n\nexport type WizardState = {\n  step: StepId;\n  /** The furthest step reached: the stepper lets a person go back to any step up to it. */\n  furthest: number;\n  fields: Fields;\n  errors: Errors;\n  /** Counts the refused entries, so a message that comes back arrives again. */\n  attempts: number;\n  /** Counts the changes of step. The first step is there when the page loads; the next ones fade in. */\n  moves: number;\n  skipped: StepId[];\n  /** True after Edit on the review: the step then leads straight back to the review. */\n  isReturning: boolean;\n  finish: FinishStatus;\n  spoken: string;\n};\n\n/** The fields a person types into. */\nexport type TextField = 'name' | 'slug' | 'connection' | 'inviteDraft';\n\nexport type WizardAction =\n  | { type: 'typed'; field: TextField; value: string }\n  | { type: 'sourcePicked'; source: SourceId }\n  | { type: 'rolePicked'; role: RoleId }\n  | { type: 'inviteCommitted' }\n  | { type: 'inviteRemoved'; address: string }\n  | { type: 'nextPressed' }\n  | { type: 'skipPressed' }\n  | { type: 'backPressed' }\n  | { type: 'jumped'; step: StepId }\n  | { type: 'finishPressed' }\n  | { type: 'created' }\n  | { type: 'restarted' };\n\ntype Step = SessionStep<WizardState, WizardAction>;\n\nexport const TOTAL = STEPS.length;\n\nconst REVIEW_INDEX = indexOfStep('review');\n\nexport const INITIAL: WizardState = {\n  step: 'workspace',\n  furthest: 0,\n  fields: EMPTY_FIELDS,\n  errors: {},\n  attempts: 0,\n  moves: 0,\n  skipped: [],\n  isReturning: false,\n  finish: 'idle',\n  spoken: '',\n};\n\nfunction withoutError(errors: Errors, field: FieldName): Errors {\n  const next = { ...errors };\n  delete next[field];\n  return next;\n}\n\n/** The address follows the name until a person writes it themselves. */\nfunction nameTyped(state: WizardState, value: string): WizardState {\n  const errors = withoutError(state.errors, 'name');\n  if (state.fields.isSlugEdited) {\n    return { ...state, errors, fields: { ...state.fields, name: value } };\n  }\n  const fields = { ...state.fields, name: value, slug: slugOf(value) };\n  return { ...state, fields, errors: withoutError(errors, 'slug') };\n}\n\nfunction typed(\n  state: WizardState,\n  field: TextField,\n  value: string\n): WizardState {\n  if (field === 'name') {\n    return nameTyped(state, value);\n  }\n  if (field === 'slug') {\n    const fields = { ...state.fields, slug: value, isSlugEdited: true };\n    return { ...state, fields, errors: withoutError(state.errors, 'slug') };\n  }\n  if (field === 'connection') {\n    const fields = { ...state.fields, connection: value };\n    const errors = withoutError(state.errors, 'connection');\n    return { ...state, fields, errors };\n  }\n  const fields = { ...state.fields, inviteDraft: value };\n  return { ...state, fields, errors: withoutError(state.errors, 'invites') };\n}\n\nfunction refused(state: WizardState, errors: Errors): WizardState {\n  const first = firstErrorOf(errors);\n  return {\n    ...state,\n    errors,\n    attempts: state.attempts + 1,\n    spoken: first?.message ?? '',\n  };\n}\n\n/** What the address box holds becomes addresses. What cannot be one stays in the box, with the reason. */\nfunction inviteCommitted(state: WizardState): WizardState {\n  const committed = committedInvites(state.fields);\n  const fields = {\n    ...state.fields,\n    invites: committed.invites,\n    inviteDraft: committed.inviteDraft,\n  };\n  const next = { ...state, fields };\n  if (committed.error !== undefined) {\n    return refused(next, { invites: committed.error });\n  }\n  return { ...next, errors: withoutError(state.errors, 'invites') };\n}\n\nfunction inviteRemoved(state: WizardState, address: string): WizardState {\n  const invites = state.fields.invites.filter(\n    (candidate) => candidate !== address\n  );\n  return { ...state, fields: { ...state.fields, invites } };\n}\n\nfunction entered(state: WizardState, step: StepId): WizardState {\n  const index = indexOfStep(step);\n  const title = stepOf(step).title;\n  return {\n    ...state,\n    step,\n    furthest: Math.max(state.furthest, index),\n    errors: {},\n    moves: state.moves + 1,\n    spoken: `Step ${index + 1} of ${TOTAL}: ${title}`,\n  };\n}\n\n/** Next leads to the step after this one, or straight back to the review a person came from. */\nfunction advanced(state: WizardState): WizardState {\n  if (state.isReturning) {\n    return entered({ ...state, isReturning: false }, 'review');\n  }\n  const next = STEPS[indexOfStep(state.step) + 1];\n  if (!next) {\n    return state;\n  }\n  return entered(state, next.id);\n}\n\nexport type Check = {\n  state: WizardState;\n  /** The first field that keeps the step from being left, if any. */\n  refusedField: FieldName | null;\n};\n\n/**\n * What Next finds when it looks at the step: an address still in the box is read first, then the\n * fields of the step are checked. The buttons use it to know where the focus goes.\n */\nexport function checkOf(state: WizardState): Check {\n  let checked = state;\n  if (state.step === 'team') {\n    checked = inviteCommitted(state);\n    const hasBadAddress = checked.errors.invites !== undefined;\n    if (hasBadAddress) {\n      return { state: checked, refusedField: 'invites' };\n    }\n  }\n  const errors = errorsOf(checked.step, checked.fields);\n  const first = firstErrorOf(errors);\n  if (first) {\n    return { state: refused(checked, errors), refusedField: first.field };\n  }\n  return { state: checked, refusedField: null };\n}\n\nfunction isEditable(state: WizardState) {\n  return state.finish === 'idle';\n}\n\nfunction nextPressed(state: WizardState): WizardState {\n  const isOnReview = state.step === 'review';\n  if (isOnReview || !isEditable(state)) {\n    return state;\n  }\n  const check = checkOf(state);\n  if (check.refusedField !== null) {\n    return check.state;\n  }\n  const skipped = check.state.skipped.filter((step) => step !== state.step);\n  return advanced({ ...check.state, skipped });\n}\n\nfunction skipPressed(state: WizardState): WizardState {\n  const canSkip = stepOf(state.step).isOptional && isEditable(state);\n  if (!canSkip) {\n    return state;\n  }\n  const others = state.skipped.filter((step) => step !== state.step);\n  return advanced({ ...state, skipped: [...others, state.step] });\n}\n\nfunction backPressed(state: WizardState): WizardState {\n  const previous = STEPS[indexOfStep(state.step) - 1];\n  if (!previous || !isEditable(state)) {\n    return state;\n  }\n  return entered(state, previous.id);\n}\n\n/**\n * The stepper and the Edit links of the review go to a step that was already reached. Going back is\n * free; going forward checks the step that is left, as Next does. A step opened from the review\n * leads back to it.\n */\nfunction jumped(state: WizardState, step: StepId): WizardState {\n  const target = indexOfStep(step);\n  const current = indexOfStep(state.step);\n  const isReached = target <= state.furthest;\n  const isElsewhere = target !== current;\n  const isLocked = !isEditable(state);\n  if (isLocked || !isReached || !isElsewhere) {\n    return state;\n  }\n  if (target < current) {\n    const isReturning = state.step === 'review' || state.isReturning;\n    return entered({ ...state, isReturning }, step);\n  }\n  const check = checkOf(state);\n  if (check.refusedField !== null) {\n    return check.state;\n  }\n  const isReturning = check.state.isReturning && target !== REVIEW_INDEX;\n  return entered({ ...check.state, isReturning }, step);\n}\n\nfunction finishPressed(state: WizardState): WizardState {\n  const isOnReview = state.step === 'review';\n  if (!isOnReview || !isEditable(state)) {\n    return state;\n  }\n  return { ...state, finish: 'creating', spoken: 'Creating the workspace' };\n}\n\nfunction created(state: WizardState): WizardState {\n  if (state.finish !== 'creating') {\n    return state;\n  }\n  const spoken = `${state.fields.name.trim()} is ready`;\n  return { ...state, finish: 'created', spoken };\n}\n\nexport function reducer(state: WizardState, action: WizardAction): WizardState {\n  switch (action.type) {\n    case 'typed':\n      return typed(state, action.field, action.value);\n    case 'sourcePicked': {\n      const fields = { ...state.fields, source: action.source };\n      const errors = withoutError(state.errors, 'source');\n      return { ...state, fields, errors };\n    }\n    case 'rolePicked':\n      return { ...state, fields: { ...state.fields, role: action.role } };\n    case 'inviteCommitted':\n      return inviteCommitted(state);\n    case 'inviteRemoved':\n      return inviteRemoved(state, action.address);\n    case 'nextPressed':\n      return nextPressed(state);\n    case 'skipPressed':\n      return skipPressed(state);\n    case 'backPressed':\n      return backPressed(state);\n    case 'jumped':\n      return jumped(state, action.step);\n    case 'finishPressed':\n      return finishPressed(state);\n    case 'created':\n      return created(state);\n    case 'restarted':\n      return { ...INITIAL, spoken: 'A new setup starts' };\n  }\n}\n\n/** How long the workspace takes to be created. */\nexport const CREATE_MS = 1300;\n\nconst KEY_MS = 45;\n\nconst NAME = 'Solway Books';\n\nconst ADDRESS = 'ines@solwaybooks.example';\n\nfunction typingSteps(\n  field: TextField,\n  text: string,\n  startAfter: number\n): Step[] {\n  const prefixes = prefixesOf(text);\n  return prefixes.map((value, index) => ({\n    after: keyDelayOf(index, startAfter, KEY_MS),\n    by: 'demo',\n    action: { type: 'typed', field, value },\n  }));\n}\n\nfunction next(after: number): Step {\n  return {\n    after,\n    by: 'demo',\n    press: 'next',\n    action: { type: 'nextPressed' },\n  };\n}\n\n/**\n * A person does everything in a wizard, so every step is the demonstration's: it names the\n * workspace, is refused once on the data source and picks one, skips the team, comes back to it\n * from the review with Edit and adds an address. The review that follows is where the wizard rests.\n */\nconst FILLING: Step[] = [\n  ...typingSteps('name', NAME, 1200),\n  next(700),\n  next(1500),\n  {\n    after: 1500,\n    by: 'demo',\n    press: 'source-postgresql',\n    action: { type: 'sourcePicked', source: 'postgresql' },\n  },\n  next(1100),\n  { after: 1600, by: 'demo', press: 'skip', action: { type: 'skipPressed' } },\n  {\n    after: 1900,\n    by: 'demo',\n    press: 'edit-team',\n    action: { type: 'jumped', step: 'team' },\n  },\n  ...typingSteps('inviteDraft', ADDRESS, 900),\n  {\n    after: 500,\n    by: 'demo',\n    press: 'add-invite',\n    action: { type: 'inviteCommitted' },\n  },\n  next(1000),\n];\n\n/** The workspace is created on its own once the button is pressed, whoever pressed it. */\nexport const SCRIPT: Step[] = [\n  ...FILLING,\n  {\n    after: 2000,\n    by: 'demo',\n    press: 'finish',\n    action: { type: 'finishPressed' },\n  },\n  { after: CREATE_MS, action: { type: 'created' } },\n];\n\nfunction endOf(script: Step[]) {\n  let state = INITIAL;\n  for (const step of script) {\n    state = reducer(state, step.action);\n  }\n  return state;\n}\n\n/** Under reduced motion the review lists the three things the wizard will create. */\nexport const RESTING: WizardState = { ...endOf(FILLING), spoken: '' };\n\nexport const LOOP_AFTER_MS = 3600;\n",
      "type": "registry:component",
      "target": "components/blocks/onboarding-02/session.ts"
    },
    {
      "path": "registry/ndeko/blocks/onboarding/onboarding-02/data.ts",
      "content": "import type { BrandSlug } from '@/registry/ndeko/lib/brand-logos';\n\nexport type StepId = 'workspace' | 'source' | 'team' | 'review';\n\nexport type WizardStep = {\n  id: StepId;\n  /** The name of the step in the stepper. */\n  label: string;\n  /** The heading of the step, which takes the focus when the step shows. */\n  title: string;\n  lead: string;\n  /** An optional step can be skipped. */\n  isOptional: boolean;\n};\n\nexport const STEPS: WizardStep[] = [\n  {\n    id: 'workspace',\n    label: 'Workspace',\n    title: 'Name your workspace',\n    lead: 'Your team finds it under this name and this address',\n    isOptional: false,\n  },\n  {\n    id: 'source',\n    label: 'Data source',\n    title: 'Connect a data source',\n    lead: 'Agents read from it. You can connect more later',\n    isOptional: true,\n  },\n  {\n    id: 'team',\n    label: 'Team',\n    title: 'Invite your team',\n    lead: 'Each address gets an email with a link to join',\n    isOptional: true,\n  },\n  {\n    id: 'review',\n    label: 'Review',\n    title: 'Review and create',\n    lead: 'Nothing is created until you press the button',\n    isOptional: false,\n  },\n];\n\nconst FALLBACK_STEP = STEPS[0];\n\nexport function stepOf(id: StepId) {\n  const step = STEPS.find((candidate) => candidate.id === id);\n  return step ?? FALLBACK_STEP;\n}\n\nexport function indexOfStep(id: StepId) {\n  return STEPS.findIndex((candidate) => candidate.id === id);\n}\n\nexport type SourceId = 'postgresql' | 'supabase' | 'airtable' | 'hubspot';\n\nexport type Source = {\n  id: SourceId;\n  name: string;\n  kind: string;\n  brand: BrandSlug;\n};\n\n/** Known products, under their own name and mark. Nothing else is said about them. */\nexport const SOURCES: Source[] = [\n  {\n    id: 'postgresql',\n    name: 'PostgreSQL',\n    kind: 'Database',\n    brand: 'postgresql',\n  },\n  { id: 'supabase', name: 'Supabase', kind: 'Database', brand: 'supabase' },\n  { id: 'airtable', name: 'Airtable', kind: 'Tables', brand: 'airtable' },\n  { id: 'hubspot', name: 'HubSpot', kind: 'CRM', brand: 'hubspot' },\n];\n\nexport function sourceOf(id: SourceId | null) {\n  const source = SOURCES.find((candidate) => candidate.id === id);\n  return source ?? null;\n}\n\nexport type RoleId = 'member' | 'admin' | 'viewer';\n\nexport type Role = {\n  value: RoleId;\n  label: string;\n};\n\nexport const ROLES: Role[] = [\n  { value: 'member', label: 'Member' },\n  { value: 'admin', label: 'Admin' },\n  { value: 'viewer', label: 'Viewer' },\n];\n\nexport function roleLabelOf(id: RoleId) {\n  const role = ROLES.find((candidate) => candidate.value === id);\n  return role?.label ?? '';\n}\n\n/** The address a workspace is reached at, before its own part. An invented host. */\nexport const URL_PREFIX = 'app.example/';\n\nexport type Fields = {\n  name: string;\n  slug: string;\n  /** Once a person types the address themselves, it stops following the name. */\n  isSlugEdited: boolean;\n  source: SourceId | null;\n  connection: string;\n  invites: string[];\n  /** What the address box holds before it becomes a chip. */\n  inviteDraft: string;\n  role: RoleId;\n};\n\nexport const EMPTY_FIELDS: Fields = {\n  name: '',\n  slug: '',\n  isSlugEdited: false,\n  source: null,\n  connection: 'Production',\n  invites: [],\n  inviteDraft: '',\n  role: 'member',\n};\n",
      "type": "registry:component",
      "target": "components/blocks/onboarding-02/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "onboarding"
  ],
  "type": "registry:block"
}