{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "auth-02",
  "title": "Sign up with live password rules",
  "description": "Name, email and password with rules that tick as they are met, a reveal button that swaps its eye, and errors that fold away once you type again.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/animated-size.json",
    "https://ui.ndekocode.dev/r/button.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/theme.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/auth/auth-02/index.tsx",
      "content": "'use client';\n\nimport { useEffect, useRef, useState } from 'react';\n\nimport { MailIcon, UserRoundPlusIcon } from '@/registry/ndeko/lib/icons';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Field, FieldLabel } from '@/registry/ndeko/ui/field';\nimport { Input } from '@/registry/ndeko/ui/input';\n\nimport {\n  AuthFrame,\n  CardHead,\n  ErrorPresence,\n  MarkTile,\n  StepSwap,\n  SubmitButton,\n} from './auth-kit';\nimport {\n  CREATE_DELAY_MS,\n  EMAIL_PLACEHOLDER,\n  LINK_LIFETIME_HOURS,\n} from './data';\nimport {\n  PasswordField,\n  PasswordRules,\n  areRulesMet,\n  personalWordsOf,\n  rulesOf,\n} from './password-parts';\n\ntype Step = 'form' | 'confirm';\n\ntype SignUpField = 'name' | 'email' | 'password';\n\ntype SignUpErrors = Partial<Record<SignUpField, string>>;\n\nconst EMAIL_PATTERN = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\nconst FIELD_ORDER: SignUpField[] = ['name', 'email', 'password'];\n\nfunction emailProblemOf(email: string) {\n  const trimmed = email.trim();\n  if (trimmed.length === 0) {\n    return 'Enter your work email';\n  }\n  const isValid = EMAIL_PATTERN.test(trimmed);\n  if (!isValid) {\n    return 'Enter an email like name@company.com';\n  }\n  return undefined;\n}\n\nfunction nameProblemOf(name: string) {\n  const trimmed = name.trim();\n  if (trimmed.length === 0) {\n    return 'Enter your name as teammates will see it';\n  }\n  return undefined;\n}\n\nfunction passwordProblemOf(isPasswordReady: boolean) {\n  if (isPasswordReady) {\n    return undefined;\n  }\n  return 'Meet every rule below to continue';\n}\n\nfunction firstErrorFieldOf(errors: SignUpErrors) {\n  const field = FIELD_ORDER.find((candidate) => Boolean(errors[candidate]));\n  if (field) {\n    return field;\n  }\n  return null;\n}\n\nfunction withoutError(errors: SignUpErrors, field: SignUpField) {\n  if (!errors[field]) {\n    return errors;\n  }\n  const next = { ...errors };\n  delete next[field];\n  return next;\n}\n\nfunction errorOf(errors: SignUpErrors, field: SignUpField) {\n  return errors[field] ?? null;\n}\n\nexport default function Auth02() {\n  const [step, setStep] = useState<Step>('form');\n  const [hasMoved, setHasMoved] = useState(false);\n  const [name, setName] = useState('');\n  const [email, setEmail] = useState('');\n  const [password, setPassword] = useState('');\n  const [errors, setErrors] = useState<SignUpErrors>({});\n  const [isCreating, setIsCreating] = useState(false);\n  const nameRef = useRef<HTMLInputElement>(null);\n  const emailRef = useRef<HTMLInputElement>(null);\n  const passwordRef = useRef<HTMLInputElement>(null);\n  const personalWords = personalWordsOf(name, email);\n  const rules = rulesOf(password, personalWords);\n  const isPasswordReady = areRulesMet(rules);\n  const trimmedEmail = email.trim();\n  const nameError = errorOf(errors, 'name');\n  const emailError = errorOf(errors, 'email');\n  const passwordError = errorOf(errors, 'password');\n  const hasNameError = Boolean(nameError);\n  const hasEmailError = Boolean(emailError);\n\n  useEffect(() => {\n    if (!isCreating) {\n      return;\n    }\n    const timer = window.setTimeout(() => {\n      setIsCreating(false);\n      setPassword('');\n      setStep('confirm');\n      setHasMoved(true);\n    }, CREATE_DELAY_MS);\n    return () => window.clearTimeout(timer);\n  }, [isCreating]);\n\n  function clearError(field: SignUpField) {\n    setErrors((previous) => withoutError(previous, field));\n  }\n\n  function changeName(event: React.ChangeEvent<HTMLInputElement>) {\n    setName(event.target.value);\n    clearError('name');\n  }\n\n  function changeEmail(event: React.ChangeEvent<HTMLInputElement>) {\n    setEmail(event.target.value);\n    clearError('email');\n  }\n\n  function changePassword(value: string) {\n    setPassword(value);\n    clearError('password');\n  }\n\n  function focusField(field: SignUpField) {\n    const refs = { name: nameRef, email: emailRef, password: passwordRef };\n    refs[field].current?.focus();\n  }\n\n  function submit(event: React.FormEvent<HTMLFormElement>) {\n    event.preventDefault();\n    if (isCreating) {\n      return;\n    }\n    const nextErrors: SignUpErrors = {\n      name: nameProblemOf(name),\n      email: emailProblemOf(email),\n      password: passwordProblemOf(isPasswordReady),\n    };\n    const firstField = firstErrorFieldOf(nextErrors);\n    setErrors(nextErrors);\n    if (firstField) {\n      focusField(firstField);\n      return;\n    }\n    setIsCreating(true);\n  }\n\n  function switchEmail() {\n    setStep('form');\n    setHasMoved(true);\n  }\n\n  return (\n    <AuthFrame footer='By creating an account you accept the terms of service and the privacy notice'>\n      <StepSwap stepKey={step}>\n        {step === 'form' && (\n          <>\n            <CardHead\n              mark={<MarkTile icon={UserRoundPlusIcon} />}\n              title='Create your Tidewell account'\n            >\n              Start a workspace for your team. You can invite people once it is\n              ready.\n            </CardHead>\n            <form noValidate onSubmit={submit} className='flex flex-col gap-5'>\n              <Field invalid={hasNameError} className='gap-0'>\n                <FieldLabel className='mb-1.5'>Full name</FieldLabel>\n                <Input\n                  ref={nameRef}\n                  autoComplete='name'\n                  placeholder='Amara Okafor'\n                  value={name}\n                  readOnly={isCreating}\n                  autoFocus={hasMoved}\n                  onChange={changeName}\n                />\n                <ErrorPresence error={nameError} />\n              </Field>\n              <Field invalid={hasEmailError} className='gap-0'>\n                <FieldLabel className='mb-1.5'>Work email</FieldLabel>\n                <Input\n                  ref={emailRef}\n                  type='email'\n                  inputMode='email'\n                  autoComplete='email'\n                  placeholder={EMAIL_PLACEHOLDER}\n                  value={email}\n                  readOnly={isCreating}\n                  onChange={changeEmail}\n                />\n                <ErrorPresence error={emailError} />\n              </Field>\n              <PasswordField\n                label='Password'\n                value={password}\n                autoComplete='new-password'\n                error={passwordError}\n                inputRef={passwordRef}\n                readOnly={isCreating}\n                onValueChange={changePassword}\n              >\n                <PasswordRules rules={rules} />\n              </PasswordField>\n              <SubmitButton\n                label='Create account'\n                workingLabel='Creating account'\n                isWorking={isCreating}\n              />\n            </form>\n          </>\n        )}\n        {step === 'confirm' && (\n          <>\n            <CardHead\n              mark={<MarkTile icon={MailIcon} />}\n              title='Confirm your email'\n              autoFocusTitle\n            >\n              We sent a link to{' '}\n              <span className='text-foreground font-medium break-all'>\n                {trimmedEmail}\n              </span>\n              {`. Open it within ${LINK_LIFETIME_HOURS} hours to finish creating your account.`}\n            </CardHead>\n            <p className='bg-foreground/[0.03] text-muted-foreground rounded-lg px-3 py-2 text-xs'>\n              This preview sends no email and keeps no password\n            </p>\n            <div className='flex justify-end'>\n              <Button variant='outline' size='lg' onClick={switchEmail}>\n                Use another email\n              </Button>\n            </div>\n          </>\n        )}\n      </StepSwap>\n    </AuthFrame>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/auth-02/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/auth/auth-02/password-parts.tsx",
      "content": "'use client';\n\nimport {\n  AnimatePresence,\n  motion,\n  type Transition,\n  type Variants,\n} from 'motion/react';\nimport { useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport {\n  CheckIcon,\n  CircleIcon,\n  EyeIcon,\n  EyeOffIcon,\n} from '@/registry/ndeko/lib/icons';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Field, FieldDescription, FieldLabel } from '@/registry/ndeko/ui/field';\nimport { Input } from '@/registry/ndeko/ui/input';\n\nimport { ErrorPresence } from './auth-kit';\n\nexport const PASSWORD_MIN_LENGTH = 10;\n\nconst PERSONAL_WORD_MIN_LENGTH = 3;\n\nconst SWAP_TRANSITION: Transition = { duration: 0.15, ease: [0.2, 0, 0, 1] };\n\nconst SWAP_VARIANTS: Variants = {\n  enter: { opacity: 0, scale: 0.6, filter: 'blur(2px)' },\n  visible: { opacity: 1, scale: 1, filter: 'blur(0px)' },\n  exit: { opacity: 0, scale: 0.6, filter: 'blur(2px)' },\n};\n\nconst FADE_VARIANTS: Variants = {\n  enter: { opacity: 0 },\n  visible: { opacity: 1 },\n  exit: { opacity: 0 },\n};\n\nconst UPPERCASE_PATTERN = /\\p{Lu}/u;\n\nconst LOWERCASE_PATTERN = /\\p{Ll}/u;\n\nconst DIGIT_PATTERN = /\\d/;\n\nexport type PasswordRule = {\n  id: string;\n  label: string;\n  isMet: boolean;\n};\n\nfunction swapVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return SWAP_VARIANTS;\n}\n\nfunction isTellingWord(word: string) {\n  return word.length >= PERSONAL_WORD_MIN_LENGTH;\n}\n\n/** Words that would make the password easy to guess: parts of the name and of the email. */\nexport function personalWordsOf(name: string, email: string) {\n  const loweredName = name.toLowerCase();\n  const loweredEmail = email.toLowerCase();\n  const [localPart] = loweredEmail.split('@');\n  const nameParts = loweredName.split(/\\s+/);\n  const words = [...nameParts, localPart];\n  return words.filter(isTellingWord);\n}\n\nexport function rulesOf(\n  password: string,\n  personalWords: string[]\n): PasswordRule[] {\n  const lowered = password.toLowerCase();\n  const hasPassword = password.length > 0;\n  const isLongEnough = password.length >= PASSWORD_MIN_LENGTH;\n  const hasDigit = DIGIT_PATTERN.test(password);\n  const hasUppercase = UPPERCASE_PATTERN.test(password);\n  const hasLowercase = LOWERCASE_PATTERN.test(password);\n  const hasBothCases = hasUppercase && hasLowercase;\n  const usesPersonalWord = personalWords.some((word) => lowered.includes(word));\n  const isImpersonal = hasPassword && !usesPersonalWord;\n  return [\n    {\n      id: 'length',\n      label: `At least ${PASSWORD_MIN_LENGTH} characters`,\n      isMet: isLongEnough,\n    },\n    { id: 'digit', label: 'One number', isMet: hasDigit },\n    {\n      id: 'cases',\n      label: 'Upper and lower case letters',\n      isMet: hasBothCases,\n    },\n    {\n      id: 'personal',\n      label: 'Not your name or email',\n      isMet: isImpersonal,\n    },\n  ];\n}\n\nexport function areRulesMet(rules: PasswordRule[]) {\n  return rules.every((rule) => rule.isMet);\n}\n\nfunction metCountLabelOf(rules: PasswordRule[]) {\n  const metCount = rules.filter((rule) => rule.isMet).length;\n  return `${metCount} of ${rules.length} password rules met`;\n}\n\nfunction RuleMark({ isMet }: { isMet: boolean }) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const variants = swapVariantsOf(shouldReduceMotion);\n  const markKey = String(isMet);\n\n  return (\n    <span aria-hidden='true' className='relative flex size-4 shrink-0'>\n      <AnimatePresence mode='popLayout' initial={false}>\n        <motion.span\n          key={markKey}\n          variants={variants}\n          initial='enter'\n          animate='visible'\n          exit='exit'\n          transition={SWAP_TRANSITION}\n          className='flex size-4 items-center justify-center'\n        >\n          {isMet && (\n            <span className='bg-success/15 text-success-foreground flex size-4 items-center justify-center rounded-full'>\n              <CheckIcon strokeWidth={2.5} className='size-2.5' />\n            </span>\n          )}\n          {!isMet && (\n            <CircleIcon className='text-muted-foreground/60 size-3.5' />\n          )}\n        </motion.span>\n      </AnimatePresence>\n    </span>\n  );\n}\n\n/** Rules tick one by one as the password meets them. Rendered inside the password `Field`. */\nexport function PasswordRules({ rules }: { rules: PasswordRule[] }) {\n  const metCountLabel = metCountLabelOf(rules);\n\n  return (\n    <FieldDescription render={<div />} className='pt-2.5'>\n      <ul className='grid gap-x-4 gap-y-1.5 sm:grid-cols-2'>\n        {rules.map((rule) => (\n          <li\n            key={rule.id}\n            className={cn(\n              'flex items-center gap-2 transition-colors duration-150',\n              rule.isMet && 'text-foreground'\n            )}\n          >\n            <RuleMark isMet={rule.isMet} />\n            {rule.label}\n          </li>\n        ))}\n      </ul>\n      <span aria-live='polite' className='sr-only'>\n        {metCountLabel}\n      </span>\n    </FieldDescription>\n  );\n}\n\nfunction inputTypeOf(isRevealed: boolean) {\n  if (isRevealed) {\n    return 'text';\n  }\n  return 'password';\n}\n\nfunction revealLabelOf(isRevealed: boolean) {\n  if (isRevealed) {\n    return 'Hide password';\n  }\n  return 'Show password';\n}\n\ntype PasswordFieldProps = {\n  label: string;\n  value: string;\n  autoComplete: 'new-password' | 'current-password';\n  error: string | null;\n  autoFocus?: boolean;\n  inputRef?: React.Ref<HTMLInputElement>;\n  readOnly?: boolean;\n  onValueChange: (value: string) => void;\n  children?: React.ReactNode;\n};\n\n/** The reveal button swaps its eye; the value never leaves the field's state. */\nexport function PasswordField({\n  label,\n  value,\n  autoComplete,\n  error,\n  autoFocus,\n  inputRef,\n  readOnly,\n  onValueChange,\n  children,\n}: PasswordFieldProps) {\n  const [isRevealed, setIsRevealed] = useState(false);\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const variants = swapVariantsOf(shouldReduceMotion);\n  const hasError = Boolean(error);\n  const inputType = inputTypeOf(isRevealed);\n  const revealLabel = revealLabelOf(isRevealed);\n  const glyphKey = String(isRevealed);\n\n  function changeValue(event: React.ChangeEvent<HTMLInputElement>) {\n    onValueChange(event.target.value);\n  }\n\n  function toggleReveal() {\n    setIsRevealed((current) => !current);\n  }\n\n  return (\n    <Field invalid={hasError} className='gap-0'>\n      <FieldLabel className='mb-1.5'>{label}</FieldLabel>\n      <div className='relative'>\n        <Input\n          ref={inputRef}\n          type={inputType}\n          value={value}\n          autoComplete={autoComplete}\n          autoCapitalize='none'\n          autoCorrect='off'\n          spellCheck={false}\n          autoFocus={autoFocus}\n          readOnly={readOnly}\n          onChange={changeValue}\n          className='pr-10'\n        />\n        <Button\n          type='button'\n          variant='ghost'\n          size='icon-sm'\n          aria-label={revealLabel}\n          aria-pressed={isRevealed}\n          onClick={toggleReveal}\n          className='text-muted-foreground absolute top-1/2 right-0.5 -translate-y-1/2'\n        >\n          <AnimatePresence mode='popLayout' initial={false}>\n            <motion.span\n              key={glyphKey}\n              variants={variants}\n              initial='enter'\n              animate='visible'\n              exit='exit'\n              transition={SWAP_TRANSITION}\n              className='flex'\n            >\n              {isRevealed && <EyeOffIcon />}\n              {!isRevealed && <EyeIcon />}\n            </motion.span>\n          </AnimatePresence>\n        </Button>\n      </div>\n      <ErrorPresence error={error} />\n      {children}\n    </Field>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/auth-02/password-parts.tsx"
    },
    {
      "path": "registry/ndeko/blocks/auth/auth-02/auth-kit.tsx",
      "content": "'use client';\n\nimport {\n  AnimatePresence,\n  motion,\n  type Transition,\n  type Variants,\n} from 'motion/react';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { LoaderCircleIcon, type Icon } from '@/registry/ndeko/lib/icons';\nimport { AnimatedSize } from '@/registry/ndeko/ui/animated-size';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { FieldError } from '@/registry/ndeko/ui/field';\n\nexport const PRODUCT_NAME = 'Tidewell';\n\nconst STEP_IN: Transition = { duration: 0.2, ease: [0.23, 1, 0.32, 1] };\n\nconst STEP_OUT: Transition = { duration: 0.15, ease: [0.23, 1, 0.32, 1] };\n\nconst SWAP_TRANSITION: Transition = { duration: 0.15, ease: [0.2, 0, 0, 1] };\n\nconst STEP_VARIANTS: Variants = {\n  enter: { opacity: 0, scale: 0.98, filter: 'blur(2px)' },\n  visible: { opacity: 1, scale: 1, filter: 'blur(0px)', transition: STEP_IN },\n  exit: { opacity: 0, scale: 0.98, filter: 'blur(2px)', transition: STEP_OUT },\n};\n\nconst SWAP_VARIANTS: Variants = {\n  enter: { opacity: 0, scale: 0.6, filter: 'blur(2px)' },\n  visible: { opacity: 1, scale: 1, filter: 'blur(0px)' },\n  exit: { opacity: 0, scale: 0.6, filter: 'blur(2px)' },\n};\n\nconst ERROR_VARIANTS: Variants = {\n  enter: { height: 0, opacity: 0 },\n  visible: { height: 'auto', opacity: 1, transition: STEP_IN },\n  exit: { height: 0, opacity: 0, transition: STEP_OUT },\n};\n\nconst FADE_VARIANTS: Variants = {\n  enter: { opacity: 0 },\n  visible: { opacity: 1, transition: STEP_IN },\n  exit: { opacity: 0, transition: STEP_OUT },\n};\n\nfunction stepVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return STEP_VARIANTS;\n}\n\nfunction swapVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return SWAP_VARIANTS;\n}\n\nfunction errorVariantsOf(shouldReduceMotion: boolean | null) {\n  if (shouldReduceMotion) {\n    return FADE_VARIANTS;\n  }\n  return ERROR_VARIANTS;\n}\n\nfunction BrandMark() {\n  return (\n    <svg viewBox='0 0 24 24' aria-hidden='true' className='size-6 shrink-0'>\n      <rect width='24' height='24' rx='6' className='fill-primary' />\n      <path\n        d='M5 10q1.75-2.6 3.5 0t3.5 0 3.5 0 3.5 0'\n        fill='none'\n        stroke='white'\n        strokeOpacity='0.7'\n        strokeWidth='1.8'\n        strokeLinecap='round'\n      />\n      <path\n        d='M5 15.5q1.75-2.6 3.5 0t3.5 0 3.5 0 3.5 0'\n        fill='none'\n        stroke='white'\n        strokeWidth='1.8'\n        strokeLinecap='round'\n      />\n    </svg>\n  );\n}\n\ntype AuthFrameProps = {\n  footer?: React.ReactNode;\n  children: React.ReactNode;\n};\n\n/** A focused page: the window colour, the mark and its name, one card in the middle. */\nexport function AuthFrame({ footer, children }: AuthFrameProps) {\n  return (\n    <div className='bg-sidebar text-foreground flex min-h-dvh w-full flex-col'>\n      <header className='flex h-14 shrink-0 items-center gap-2 px-4 sm:px-6'>\n        <BrandMark />\n        <span className='text-sm font-semibold'>{PRODUCT_NAME}</span>\n      </header>\n      <main className='flex flex-1 flex-col items-center px-4 pt-4 pb-16 sm:justify-center sm:pt-0'>\n        <div className='flex w-full max-w-[25rem] flex-col gap-4'>\n          <div className='bg-card hairline-ring ring-border dark:bg-foreground/[0.03] rounded-xl p-6 shadow-[0_1px_2px_rgb(0_0_0/0.04)] sm:p-7'>\n            <AnimatedSize contentClassName='relative'>{children}</AnimatedSize>\n          </div>\n          {footer && (\n            <p className='text-muted-foreground px-2 text-center text-xs text-balance'>\n              {footer}\n            </p>\n          )}\n        </div>\n      </main>\n    </div>\n  );\n}\n\ntype StepSwapProps = {\n  stepKey: string;\n  children: React.ReactNode;\n};\n\n/** The card resizes around it while one step gives way to the next. */\nexport function StepSwap({ stepKey, children }: StepSwapProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const variants = stepVariantsOf(shouldReduceMotion);\n\n  return (\n    <AnimatePresence mode='popLayout' initial={false}>\n      <motion.div\n        key={stepKey}\n        variants={variants}\n        initial='enter'\n        animate='visible'\n        exit='exit'\n        className='flex flex-col gap-6'\n      >\n        {children}\n      </motion.div>\n    </AnimatePresence>\n  );\n}\n\ntype MarkTileProps = { icon: Icon };\n\nexport function MarkTile({ icon: TileIcon }: MarkTileProps) {\n  return (\n    <span className='keycap-3d text-muted-foreground flex size-10 items-center justify-center rounded-lg'>\n      <TileIcon className='size-5' />\n    </span>\n  );\n}\n\ntype CardHeadProps = {\n  mark: React.ReactNode;\n  title: string;\n  /** Focuses the title when a step opens, so screen readers hear where they are. */\n  autoFocusTitle?: boolean;\n  children: React.ReactNode;\n};\n\nexport function CardHead({\n  mark,\n  title,\n  autoFocusTitle,\n  children,\n}: CardHeadProps) {\n  const titleRef = useRef<HTMLHeadingElement>(null);\n\n  useEffect(() => {\n    if (autoFocusTitle) {\n      titleRef.current?.focus();\n    }\n  }, [autoFocusTitle]);\n\n  return (\n    <div className='flex flex-col gap-4'>\n      {mark}\n      <div className='flex flex-col gap-1.5'>\n        <h1\n          ref={titleRef}\n          tabIndex={-1}\n          className='text-xl font-semibold text-balance outline-none'\n        >\n          {title}\n        </h1>\n        <p className='text-muted-foreground text-[13px] text-pretty'>\n          {children}\n        </p>\n      </div>\n    </div>\n  );\n}\n\ntype ErrorPresenceProps = {\n  error: string | null;\n};\n\n/** Rendered inside a `Field`, so the error is tied to its control. It grows in and folds away. */\nexport function ErrorPresence({ error }: ErrorPresenceProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const variants = errorVariantsOf(shouldReduceMotion);\n\n  return (\n    <AnimatePresence initial={false}>\n      {error && (\n        <motion.div\n          key='error'\n          variants={variants}\n          initial='enter'\n          animate='visible'\n          exit='exit'\n          className='overflow-hidden'\n        >\n          <FieldError match className='pt-1.5'>\n            {error}\n          </FieldError>\n        </motion.div>\n      )}\n    </AnimatePresence>\n  );\n}\n\ntype SubmitButtonProps = {\n  label: string;\n  workingLabel: string;\n  isWorking: boolean;\n};\n\n/** Becomes its working state in place: a spinner joins the label and the pill resizes to it. */\nexport function SubmitButton({\n  label,\n  workingLabel,\n  isWorking,\n}: SubmitButtonProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const variants = swapVariantsOf(shouldReduceMotion);\n  const shownLabel = workingLabelOf(isWorking, label, workingLabel);\n\n  return (\n    <Button\n      type='submit'\n      size='lg'\n      disabled={isWorking}\n      focusableWhenDisabled\n      className='w-full data-disabled:opacity-100 sm:w-auto'\n    >\n      <AnimatedSize\n        as='span'\n        axis='width'\n        contentClassName='relative flex items-center gap-2'\n      >\n        <AnimatePresence mode='popLayout' initial={false}>\n          {isWorking && (\n            <motion.span\n              key='spinner'\n              variants={variants}\n              initial='enter'\n              animate='visible'\n              exit='exit'\n              transition={SWAP_TRANSITION}\n              className='flex'\n            >\n              <LoaderCircleIcon className='animate-spin' />\n            </motion.span>\n          )}\n        </AnimatePresence>\n        <AnimatePresence mode='popLayout' initial={false}>\n          <motion.span\n            key={shownLabel}\n            variants={variants}\n            initial='enter'\n            animate='visible'\n            exit='exit'\n            transition={SWAP_TRANSITION}\n          >\n            {shownLabel}\n          </motion.span>\n        </AnimatePresence>\n      </AnimatedSize>\n    </Button>\n  );\n}\n\nfunction workingLabelOf(\n  isWorking: boolean,\n  label: string,\n  workingLabel: string\n) {\n  if (isWorking) {\n    return workingLabel;\n  }\n  return label;\n}\n\ntype SwapLabelProps = { text: string };\n\nexport function SwapLabel({ text }: SwapLabelProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const variants = swapVariantsOf(shouldReduceMotion);\n\n  return (\n    <AnimatedSize as='span' axis='width' contentClassName='relative flex'>\n      <AnimatePresence mode='popLayout' initial={false}>\n        <motion.span\n          key={text}\n          variants={variants}\n          initial='enter'\n          animate='visible'\n          exit='exit'\n          transition={SWAP_TRANSITION}\n          className='tabular-nums'\n        >\n          {text}\n        </motion.span>\n      </AnimatePresence>\n    </AnimatedSize>\n  );\n}\n\n/** Counts down once a second while it is above zero. */\nexport function useCountdown() {\n  const [seconds, setSeconds] = useState(0);\n\n  useEffect(() => {\n    if (seconds <= 0) {\n      return;\n    }\n    const timer = window.setTimeout(() => {\n      setSeconds((current) => current - 1);\n    }, 1000);\n    return () => window.clearTimeout(timer);\n  }, [seconds]);\n\n  return { seconds, start: setSeconds };\n}\n\nexport function clockOf(totalSeconds: number) {\n  const rawMinutes = totalSeconds / 60;\n  const minutes = Math.floor(rawMinutes);\n  const seconds = totalSeconds % 60;\n  const paddedSeconds = String(seconds).padStart(2, '0');\n  return `${minutes}:${paddedSeconds}`;\n}\n",
      "type": "registry:component",
      "target": "components/blocks/auth-02/auth-kit.tsx"
    },
    {
      "path": "registry/ndeko/blocks/auth/auth-02/data.ts",
      "content": "export const CREATE_DELAY_MS = 1000;\n\nexport const LINK_LIFETIME_HOURS = 24;\n\nexport const EMAIL_PLACEHOLDER = 'name@company.com';\n",
      "type": "registry:component",
      "target": "components/blocks/auth-02/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "auth"
  ],
  "type": "registry:block"
}