{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "application-04",
  "title": "Sign in",
  "description": "A focused Loomboard page: sign in with a one-time code, with links to create an account and to reset a password, all in one card that resizes from one flow to the next.",
  "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/otp-field.json",
    "https://ui.ndekocode.dev/r/status-orb.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/templates/auth/application-04/index.tsx",
      "content": "'use client';\n\nimport { useState } from 'react';\n\nimport { AuthFrame, StepSwap } from './auth-kit';\nimport { ResetFlow } from './reset-flow';\nimport { SignInFlow } from './sign-in-flow';\nimport { SignUpFlow } from './sign-up-flow';\n\ntype Flow = 'sign-in' | 'sign-up' | 'reset';\n\nconst FOOTERS: Record<Flow, string> = {\n  'sign-in':\n    'Trouble signing in? A workspace admin can send you a new invitation.',\n  'sign-up':\n    'By creating an account you accept the terms of service and the privacy notice',\n  reset:\n    'For your safety, this page never says whether an account uses an address',\n};\n\nexport default function Application04() {\n  const [flow, setFlow] = useState<Flow>('sign-in');\n  const [hasMoved, setHasMoved] = useState(false);\n\n  function open(nextFlow: Flow) {\n    setFlow(nextFlow);\n    setHasMoved(true);\n  }\n\n  function openSignIn() {\n    open('sign-in');\n  }\n\n  function openSignUp() {\n    open('sign-up');\n  }\n\n  function openReset() {\n    open('reset');\n  }\n\n  return (\n    <AuthFrame footer={FOOTERS[flow]}>\n      <StepSwap stepKey={flow}>\n        {flow === 'sign-in' && (\n          <SignInFlow\n            startsFocused={hasMoved}\n            onCreateAccount={openSignUp}\n            onForgotPassword={openReset}\n          />\n        )}\n        {flow === 'sign-up' && (\n          <SignUpFlow startsFocused={hasMoved} onSignIn={openSignIn} />\n        )}\n        {flow === 'reset' && (\n          <ResetFlow startsFocused={hasMoved} onSignIn={openSignIn} />\n        )}\n      </StepSwap>\n    </AuthFrame>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-04/index.tsx"
    },
    {
      "path": "registry/ndeko/templates/auth/application-04/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\nimport { LoomboardMark } from './brand-mark';\nimport { PRODUCT_NAME } from './data';\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\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        <LoomboardMark />\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/templates/application-04/auth-kit.tsx"
    },
    {
      "path": "registry/ndeko/templates/auth/application-04/brand-mark.tsx",
      "content": "import { cn } from '@/registry/ndeko/lib/utils';\n\nexport function LoomboardMark({ className }: { className?: string }) {\n  return (\n    <svg\n      viewBox='0 0 24 24'\n      aria-hidden='true'\n      className={cn('size-6 shrink-0', className)}\n    >\n      <rect width='24' height='24' rx='7' className='fill-primary' />\n      <rect x='6' y='6' width='3' height='12' rx='1.5' className='fill-white' />\n      <rect\n        x='10.5'\n        y='6'\n        width='3'\n        height='8'\n        rx='1.5'\n        className='fill-white/80'\n      />\n      <rect\n        x='15'\n        y='6'\n        width='3'\n        height='10'\n        rx='1.5'\n        className='fill-white/60'\n      />\n    </svg>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-04/brand-mark.tsx"
    },
    {
      "path": "registry/ndeko/templates/auth/application-04/sign-in-flow.tsx",
      "content": "'use client';\n\nimport { Fragment, useEffect, useRef, useState } from 'react';\n\nimport { MailIcon, ShieldCheckIcon } 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';\nimport {\n  OTPField,\n  OTPFieldInput,\n  OTPFieldSeparator,\n} from '@/registry/ndeko/ui/otp-field';\nimport { StatusOrb } from '@/registry/ndeko/ui/status-orb';\n\nimport {\n  CardHead,\n  ErrorPresence,\n  MarkTile,\n  StepSwap,\n  SubmitButton,\n  SwapLabel,\n  clockOf,\n  useCountdown,\n} from './auth-kit';\nimport {\n  CHECK_DELAY_MS,\n  CODE_LENGTH,\n  CODE_LIFETIME_MINUTES,\n  EMAIL_PLACEHOLDER,\n  PREVIEW_CODE,\n  PREVIEW_CODE_LABEL,\n  RESEND_SECONDS,\n  RESENT_NOTICE_MS,\n  PRODUCT_NAME,\n  SEND_DELAY_MS,\n} from './data';\nimport { emailProblemOf } from './email-check';\n\ntype Step = 'email' | 'code' | 'done';\n\nconst SLOTS = Array.from({ length: CODE_LENGTH }, (_, index) => index);\n\nconst SEPARATOR_AFTER = 2;\n\nfunction slotLabelOf(index: number) {\n  const position = index + 1;\n  return `Digit ${position} of ${CODE_LENGTH}`;\n}\n\nfunction resendLabelOf(seconds: number, isResent: boolean) {\n  if (isResent) {\n    return 'New code sent';\n  }\n  if (seconds > 0) {\n    const clock = clockOf(seconds);\n    return `Send a new code in ${clock}`;\n  }\n  return 'Send a new code';\n}\n\ntype SignInFlowProps = {\n  startsFocused: boolean;\n  onCreateAccount: () => void;\n  onForgotPassword: () => void;\n};\n\nexport function SignInFlow({\n  startsFocused,\n  onCreateAccount,\n  onForgotPassword,\n}: SignInFlowProps) {\n  const [step, setStep] = useState<Step>('email');\n  const [hasMoved, setHasMoved] = useState(startsFocused);\n  const [email, setEmail] = useState('');\n  const [emailError, setEmailError] = useState<string | null>(null);\n  const [isSending, setIsSending] = useState(false);\n  const [code, setCode] = useState('');\n  const [codeError, setCodeError] = useState<string | null>(null);\n  const [checkingCode, setCheckingCode] = useState<string | null>(null);\n  const [isResent, setIsResent] = useState(false);\n  const { seconds: resendSeconds, start: startCountdown } = useCountdown();\n  const emailRef = useRef<HTMLInputElement>(null);\n  const trimmedEmail = email.trim();\n  const hasEmailError = Boolean(emailError);\n  const hasCodeError = Boolean(codeError);\n  const isChecking = checkingCode !== null;\n  const isResendWaiting = resendSeconds > 0;\n  const resendLabel = resendLabelOf(resendSeconds, isResent);\n\n  useEffect(() => {\n    if (!isSending) {\n      return;\n    }\n    const timer = window.setTimeout(() => {\n      setIsSending(false);\n      setCode('');\n      setCodeError(null);\n      setStep('code');\n      setHasMoved(true);\n      startCountdown(RESEND_SECONDS);\n    }, SEND_DELAY_MS);\n    return () => window.clearTimeout(timer);\n  }, [isSending, startCountdown]);\n\n  useEffect(() => {\n    if (checkingCode === null) {\n      return;\n    }\n    const timer = window.setTimeout(() => {\n      const isRight = checkingCode === PREVIEW_CODE;\n      setCheckingCode(null);\n      if (isRight) {\n        setStep('done');\n        return;\n      }\n      setCodeError(\n        'That code does not match. Check the latest email or send a new one'\n      );\n    }, CHECK_DELAY_MS);\n    return () => window.clearTimeout(timer);\n  }, [checkingCode]);\n\n  useEffect(() => {\n    if (!isResent) {\n      return;\n    }\n    const timer = window.setTimeout(() => setIsResent(false), RESENT_NOTICE_MS);\n    return () => window.clearTimeout(timer);\n  }, [isResent]);\n\n  function changeEmail(event: React.ChangeEvent<HTMLInputElement>) {\n    setEmail(event.target.value);\n    setEmailError(null);\n  }\n\n  function submitEmail(event: React.FormEvent<HTMLFormElement>) {\n    event.preventDefault();\n    if (isSending) {\n      return;\n    }\n    const problem = emailProblemOf(email, 'Enter your work email');\n    setEmailError(problem);\n    if (problem) {\n      emailRef.current?.focus();\n      return;\n    }\n    setIsSending(true);\n  }\n\n  function changeCode(value: string) {\n    setCode(value);\n    setCodeError(null);\n  }\n\n  function completeCode(value: string) {\n    setCheckingCode(value);\n  }\n\n  function submitCode(event: React.FormEvent<HTMLFormElement>) {\n    event.preventDefault();\n    if (isChecking) {\n      return;\n    }\n    const isComplete = code.length === CODE_LENGTH;\n    if (!isComplete) {\n      setCodeError(`Enter the ${CODE_LENGTH} digits from the email`);\n      return;\n    }\n    setCheckingCode(code);\n  }\n\n  function resendCode() {\n    setCode('');\n    setCodeError(null);\n    setIsResent(true);\n    startCountdown(RESEND_SECONDS);\n  }\n\n  function switchEmail() {\n    setStep('email');\n    setHasMoved(true);\n  }\n\n  function signOut() {\n    setCode('');\n    setStep('email');\n    setHasMoved(true);\n  }\n\n  return (\n    <StepSwap stepKey={step}>\n      {step === 'email' && (\n        <>\n          <CardHead\n            mark={<MarkTile icon={MailIcon} />}\n            title={`Sign in to ${PRODUCT_NAME}`}\n          >\n            We email you a 6-digit code to sign in on this device.\n          </CardHead>\n          <form\n            noValidate\n            onSubmit={submitEmail}\n            className='flex flex-col gap-5'\n          >\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={isSending}\n                autoFocus={hasMoved}\n                onChange={changeEmail}\n              />\n              <ErrorPresence error={emailError} />\n            </Field>\n            <div className='flex flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-between'>\n              <p className='text-muted-foreground text-xs'>\n                {`Codes expire after ${CODE_LIFETIME_MINUTES} minutes`}\n              </p>\n              <SubmitButton\n                label='Send code'\n                workingLabel='Sending code'\n                isWorking={isSending}\n              />\n            </div>\n          </form>\n          <div className='text-muted-foreground flex flex-wrap items-center justify-between gap-x-4 gap-y-1 text-xs'>\n            <p>\n              {`New to ${PRODUCT_NAME}? `}\n              <Button\n                variant='link'\n                onClick={onCreateAccount}\n                className='h-auto px-0 text-xs'\n              >\n                Create an account\n              </Button>\n            </p>\n            <Button\n              variant='link'\n              onClick={onForgotPassword}\n              className='h-auto px-0 text-xs'\n            >\n              Forgot your password\n            </Button>\n          </div>\n        </>\n      )}\n      {step === 'code' && (\n        <>\n          <CardHead\n            mark={<MarkTile icon={ShieldCheckIcon} />}\n            title='Check your email'\n          >\n            Enter the code sent to{' '}\n            <span className='text-foreground font-medium break-all'>\n              {trimmedEmail}\n            </span>\n            .{' '}\n            <Button\n              variant='link'\n              onClick={switchEmail}\n              className='h-auto px-0 text-[13px]'\n            >\n              Use another email\n            </Button>\n          </CardHead>\n          <form\n            noValidate\n            onSubmit={submitCode}\n            className='flex flex-col gap-5'\n          >\n            <Field invalid={hasCodeError} className='gap-0'>\n              <FieldLabel className='mb-1.5'>\n                {`${CODE_LENGTH}-digit code`}\n              </FieldLabel>\n              <OTPField\n                length={CODE_LENGTH}\n                value={code}\n                autoComplete='one-time-code'\n                readOnly={isChecking}\n                onValueChange={changeCode}\n                onValueComplete={completeCode}\n                className='gap-1.5 sm:gap-2'\n              >\n                {SLOTS.map((index) => {\n                  const isFirst = index === 0;\n                  const isSeparated = index === SEPARATOR_AFTER;\n\n                  return (\n                    <Fragment key={index}>\n                      <OTPFieldInput\n                        autoFocus={isFirst}\n                        aria-label={slotLabelOf(index)}\n                        className='sm:size-11'\n                      />\n                      {isSeparated && <OTPFieldSeparator />}\n                    </Fragment>\n                  );\n                })}\n              </OTPField>\n              <ErrorPresence error={codeError} />\n            </Field>\n            <p className='bg-foreground/[0.03] text-muted-foreground rounded-lg px-3 py-2 text-xs'>\n              This preview sends no email. The code it accepts is{' '}\n              <span className='text-foreground font-medium tabular-nums'>\n                {PREVIEW_CODE_LABEL}\n              </span>\n            </p>\n            <div className='flex flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-between'>\n              <Button\n                type='button'\n                variant='ghost'\n                size='sm'\n                disabled={isResendWaiting}\n                onClick={resendCode}\n                className='text-muted-foreground self-center sm:self-auto'\n              >\n                <SwapLabel text={resendLabel} />\n              </Button>\n              <SubmitButton\n                label='Sign in'\n                workingLabel='Checking'\n                isWorking={isChecking}\n              />\n            </div>\n          </form>\n        </>\n      )}\n      {step === 'done' && (\n        <>\n          <CardHead\n            mark={<StatusOrb tone='success' />}\n            title='Signed in'\n            autoFocusTitle\n          >\n            <span className='text-foreground font-medium break-all'>\n              {trimmedEmail}\n            </span>{' '}\n            {`is signed in to ${PRODUCT_NAME} on this device.`}\n          </CardHead>\n          <div className='flex flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-between'>\n            <p className='text-muted-foreground text-xs'>\n              Sessions on this device last 30 days\n            </p>\n            <Button variant='outline' size='lg' onClick={signOut}>\n              Sign out\n            </Button>\n          </div>\n        </>\n      )}\n    </StepSwap>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-04/sign-in-flow.tsx"
    },
    {
      "path": "registry/ndeko/templates/auth/application-04/sign-up-flow.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  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  PRODUCT_NAME,\n} from './data';\nimport { emailProblemOf } from './email-check';\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 FIELD_ORDER: SignUpField[] = ['name', 'email', 'password'];\n\nfunction signUpEmailProblemOf(email: string) {\n  const problem = emailProblemOf(email, 'Enter your work email');\n  return problem ?? 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\ntype SignUpFlowProps = {\n  startsFocused: boolean;\n  onSignIn: () => void;\n};\n\nexport function SignUpFlow({ startsFocused, onSignIn }: SignUpFlowProps) {\n  const [step, setStep] = useState<Step>('form');\n  const [hasMoved, setHasMoved] = useState(startsFocused);\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: signUpEmailProblemOf(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    <StepSwap stepKey={step}>\n      {step === 'form' && (\n        <>\n          <CardHead\n            mark={<MarkTile icon={UserRoundPlusIcon} />}\n            title={`Create your ${PRODUCT_NAME} 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          <p className='text-muted-foreground text-xs'>\n            {'Already have an account? '}\n            <Button\n              variant='link'\n              onClick={onSignIn}\n              className='h-auto px-0 text-xs'\n            >\n              Sign in\n            </Button>\n          </p>\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 flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-between'>\n            <Button\n              variant='link'\n              onClick={onSignIn}\n              className='h-auto self-center px-0 text-xs sm:self-auto'\n            >\n              Back to sign in\n            </Button>\n            <Button variant='outline' size='lg' onClick={switchEmail}>\n              Use another email\n            </Button>\n          </div>\n        </>\n      )}\n    </StepSwap>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-04/sign-up-flow.tsx"
    },
    {
      "path": "registry/ndeko/templates/auth/application-04/reset-flow.tsx",
      "content": "'use client';\n\nimport { useEffect, useRef, useState } from 'react';\n\nimport { LockIcon, MailIcon } 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';\nimport { StatusOrb } from '@/registry/ndeko/ui/status-orb';\n\nimport {\n  CardHead,\n  ErrorPresence,\n  MarkTile,\n  StepSwap,\n  SubmitButton,\n  SwapLabel,\n  clockOf,\n  useCountdown,\n} from './auth-kit';\nimport {\n  CHANGE_DELAY_MS,\n  EMAIL_PLACEHOLDER,\n  LINK_LIFETIME_MINUTES,\n  RESEND_SECONDS,\n  RESENT_NOTICE_MS,\n  SEND_DELAY_MS,\n} from './data';\nimport { emailProblemOf } from './email-check';\nimport {\n  PasswordField,\n  PasswordRules,\n  areRulesMet,\n  personalWordsOf,\n  rulesOf,\n  type PasswordRule,\n} from './password-parts';\n\ntype Step = 'request' | 'sent' | 'choose' | 'done';\n\nfunction resendLabelOf(seconds: number, isResent: boolean) {\n  if (isResent) {\n    return 'Link sent again';\n  }\n  if (seconds > 0) {\n    const clock = clockOf(seconds);\n    return `Send it again in ${clock}`;\n  }\n  return 'Send it again';\n}\n\nfunction matchRuleOf(password: string, confirmation: string): PasswordRule {\n  const hasConfirmation = confirmation.length > 0;\n  const isSame = password === confirmation;\n  const isMatch = hasConfirmation && isSame;\n  return { id: 'match', label: 'Both fields match', isMet: isMatch };\n}\n\ntype ResetFlowProps = {\n  startsFocused: boolean;\n  onSignIn: () => void;\n};\n\nexport function ResetFlow({ startsFocused, onSignIn }: ResetFlowProps) {\n  const [step, setStep] = useState<Step>('request');\n  const [hasMoved, setHasMoved] = useState(startsFocused);\n  const [email, setEmail] = useState('');\n  const [emailError, setEmailError] = useState<string | null>(null);\n  const [isSending, setIsSending] = useState(false);\n  const [isResent, setIsResent] = useState(false);\n  const [password, setPassword] = useState('');\n  const [confirmation, setConfirmation] = useState('');\n  const [passwordError, setPasswordError] = useState<string | null>(null);\n  const [confirmationError, setConfirmationError] = useState<string | null>(\n    null\n  );\n  const [isChanging, setIsChanging] = useState(false);\n  const { seconds: resendSeconds, start: startCountdown } = useCountdown();\n  const emailRef = useRef<HTMLInputElement>(null);\n  const passwordRef = useRef<HTMLInputElement>(null);\n  const confirmationRef = useRef<HTMLInputElement>(null);\n  const trimmedEmail = email.trim();\n  const hasEmailError = Boolean(emailError);\n  const isResendWaiting = resendSeconds > 0;\n  const resendLabel = resendLabelOf(resendSeconds, isResent);\n  const personalWords = personalWordsOf('', email);\n  const passwordRules = rulesOf(password, personalWords);\n  const matchRule = matchRuleOf(password, confirmation);\n  const rules = [...passwordRules, matchRule];\n  const isPasswordReady = areRulesMet(passwordRules);\n\n  useEffect(() => {\n    if (!isSending) {\n      return;\n    }\n    const timer = window.setTimeout(() => {\n      setIsSending(false);\n      setStep('sent');\n      setHasMoved(true);\n      startCountdown(RESEND_SECONDS);\n    }, SEND_DELAY_MS);\n    return () => window.clearTimeout(timer);\n  }, [isSending, startCountdown]);\n\n  useEffect(() => {\n    if (!isChanging) {\n      return;\n    }\n    const timer = window.setTimeout(() => {\n      setIsChanging(false);\n      setPassword('');\n      setConfirmation('');\n      setStep('done');\n    }, CHANGE_DELAY_MS);\n    return () => window.clearTimeout(timer);\n  }, [isChanging]);\n\n  useEffect(() => {\n    if (!isResent) {\n      return;\n    }\n    const timer = window.setTimeout(() => setIsResent(false), RESENT_NOTICE_MS);\n    return () => window.clearTimeout(timer);\n  }, [isResent]);\n\n  function changeEmail(event: React.ChangeEvent<HTMLInputElement>) {\n    setEmail(event.target.value);\n    setEmailError(null);\n  }\n\n  function requestLink(event: React.FormEvent<HTMLFormElement>) {\n    event.preventDefault();\n    if (isSending) {\n      return;\n    }\n    const problem = emailProblemOf(email, 'Enter the email you sign in with');\n    setEmailError(problem);\n    if (problem) {\n      emailRef.current?.focus();\n      return;\n    }\n    setIsSending(true);\n  }\n\n  function resendLink() {\n    setIsResent(true);\n    startCountdown(RESEND_SECONDS);\n  }\n\n  function switchEmail() {\n    setStep('request');\n    setHasMoved(true);\n  }\n\n  function openLink() {\n    setPasswordError(null);\n    setConfirmationError(null);\n    setStep('choose');\n    setHasMoved(true);\n  }\n\n  function changePassword(value: string) {\n    setPassword(value);\n    setPasswordError(null);\n  }\n\n  function changeConfirmation(value: string) {\n    setConfirmation(value);\n    setConfirmationError(null);\n  }\n\n  function changePasswordNow(event: React.FormEvent<HTMLFormElement>) {\n    event.preventDefault();\n    if (isChanging) {\n      return;\n    }\n    if (!isPasswordReady) {\n      setPasswordError('Meet every rule below to continue');\n      passwordRef.current?.focus();\n      return;\n    }\n    if (!matchRule.isMet) {\n      setConfirmationError('Type the same password in both fields');\n      confirmationRef.current?.focus();\n      return;\n    }\n    setIsChanging(true);\n  }\n\n  return (\n    <StepSwap stepKey={step}>\n      {step === 'request' && (\n        <>\n          <CardHead\n            mark={<MarkTile icon={LockIcon} />}\n            title='Reset your password'\n          >\n            Enter the email you sign in with and we send a link to choose a new\n            password.\n          </CardHead>\n          <form\n            noValidate\n            onSubmit={requestLink}\n            className='flex flex-col gap-5'\n          >\n            <Field invalid={hasEmailError} className='gap-0'>\n              <FieldLabel className='mb-1.5'>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={isSending}\n                autoFocus={hasMoved}\n                onChange={changeEmail}\n              />\n              <ErrorPresence error={emailError} />\n            </Field>\n            <div className='flex flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-between'>\n              <p className='text-muted-foreground text-xs'>\n                {`The link works for ${LINK_LIFETIME_MINUTES} minutes`}\n              </p>\n              <SubmitButton\n                label='Send reset link'\n                workingLabel='Sending link'\n                isWorking={isSending}\n              />\n            </div>\n          </form>\n          <Button\n            variant='link'\n            onClick={onSignIn}\n            className='h-auto self-start px-0 text-xs'\n          >\n            Back to sign in\n          </Button>\n        </>\n      )}\n      {step === 'sent' && (\n        <>\n          <CardHead\n            mark={<MarkTile icon={MailIcon} />}\n            title='Check your email'\n            autoFocusTitle\n          >\n            If an account uses{' '}\n            <span className='text-foreground font-medium break-all'>\n              {trimmedEmail}\n            </span>\n            {`, a reset link is on its way. It works for ${LINK_LIFETIME_MINUTES} minutes.`}\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. Open the link from here instead.\n          </p>\n          <div className='flex flex-col gap-3'>\n            <div className='flex flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-between'>\n              <Button\n                variant='ghost'\n                size='sm'\n                disabled={isResendWaiting}\n                onClick={resendLink}\n                className='text-muted-foreground self-center sm:self-auto'\n              >\n                <SwapLabel text={resendLabel} />\n              </Button>\n              <Button size='lg' onClick={openLink} className='w-full sm:w-auto'>\n                Open the reset link\n              </Button>\n            </div>\n            <Button\n              variant='link'\n              onClick={switchEmail}\n              className='h-auto self-center px-0 text-xs sm:self-start'\n            >\n              Use another email\n            </Button>\n          </div>\n        </>\n      )}\n      {step === 'choose' && (\n        <>\n          <CardHead\n            mark={<MarkTile icon={LockIcon} />}\n            title='Choose a new password'\n          >\n            For{' '}\n            <span className='text-foreground font-medium break-all'>\n              {trimmedEmail}\n            </span>\n            . Other devices sign out once it changes.\n          </CardHead>\n          <form\n            noValidate\n            onSubmit={changePasswordNow}\n            className='flex flex-col gap-5'\n          >\n            <PasswordField\n              label='New password'\n              value={password}\n              autoComplete='new-password'\n              error={passwordError}\n              inputRef={passwordRef}\n              autoFocus\n              readOnly={isChanging}\n              onValueChange={changePassword}\n            >\n              <PasswordRules rules={rules} />\n            </PasswordField>\n            <PasswordField\n              label='Type it again'\n              value={confirmation}\n              autoComplete='new-password'\n              error={confirmationError}\n              inputRef={confirmationRef}\n              readOnly={isChanging}\n              onValueChange={changeConfirmation}\n            />\n            <SubmitButton\n              label='Change password'\n              workingLabel='Changing password'\n              isWorking={isChanging}\n            />\n          </form>\n        </>\n      )}\n      {step === 'done' && (\n        <>\n          <CardHead\n            mark={<StatusOrb tone='success' />}\n            title='Password changed'\n            autoFocusTitle\n          >\n            Your other devices are signed out. Sign in again with the new\n            password.\n          </CardHead>\n          <div className='flex justify-end'>\n            <Button variant='outline' size='lg' onClick={onSignIn}>\n              Sign in\n            </Button>\n          </div>\n        </>\n      )}\n    </StepSwap>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-04/reset-flow.tsx"
    },
    {
      "path": "registry/ndeko/templates/auth/application-04/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/templates/application-04/password-parts.tsx"
    },
    {
      "path": "registry/ndeko/templates/auth/application-04/email-check.ts",
      "content": "const EMAIL_PATTERN = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\nexport function emailProblemOf(email: string, emptyMessage: string) {\n  const trimmed = email.trim();\n  if (trimmed.length === 0) {\n    return emptyMessage;\n  }\n  const isValid = EMAIL_PATTERN.test(trimmed);\n  if (!isValid) {\n    return 'Enter an email like name@company.com';\n  }\n  return null;\n}\n",
      "type": "registry:component",
      "target": "components/templates/application-04/email-check.ts"
    },
    {
      "path": "registry/ndeko/templates/auth/application-04/data.ts",
      "content": "export const PRODUCT_NAME = 'Loomboard';\n\nexport const EMAIL_PLACEHOLDER = 'name@company.com';\n\nexport const CODE_LENGTH = 6;\n\n/** The preview sends no email, so it says which code it accepts. */\nexport const PREVIEW_CODE = '428913';\n\nexport const PREVIEW_CODE_LABEL = '428 913';\n\nexport const CODE_LIFETIME_MINUTES = 10;\n\nexport const SEND_DELAY_MS = 900;\n\nexport const CHECK_DELAY_MS = 700;\n\nexport const CREATE_DELAY_MS = 1000;\n\nexport const CHANGE_DELAY_MS = 900;\n\nexport const RESEND_SECONDS = 30;\n\nexport const RESENT_NOTICE_MS = 1600;\n\nexport const LINK_LIFETIME_HOURS = 24;\n\nexport const LINK_LIFETIME_MINUTES = 30;\n",
      "type": "registry:component",
      "target": "components/templates/application-04/data.ts"
    }
  ],
  "categories": [
    "templates",
    "auth"
  ],
  "type": "registry:block"
}