{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ai-product-04",
  "title": "Launch perks",
  "description": "Three perks of a launch offer under a live countdown: as people join, each claimed count rolls while its bar fills, and a claim turns its button into a drawn check.",
  "dependencies": [],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/agent-run.json",
    "https://ui.ndekocode.dev/r/badge.json",
    "https://ui.ndekocode.dev/r/button.json",
    "https://ui.ndekocode.dev/r/chat-motion.json",
    "https://ui.ndekocode.dev/r/demonstration.json",
    "https://ui.ndekocode.dev/r/drawn-check.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/live-duration.json",
    "https://ui.ndekocode.dev/r/live-region.json",
    "https://ui.ndekocode.dev/r/motion-number.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-agent-run.json",
    "https://ui.ndekocode.dev/r/use-autoplay.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/blocks/ai-product/ai-product-04/index.tsx",
      "content": "'use client';\n\nimport { useState } from 'react';\n\nimport { useAutoplay } from '@/registry/ndeko/hooks/use-autoplay';\nimport {\n  PRESS_LEAD_MS,\n  spokenUnless,\n  usePress,\n} from '@/registry/ndeko/lib/demonstration';\nimport { TicketPercentIcon } from '@/registry/ndeko/lib/icons';\nimport { Badge } from '@/registry/ndeko/ui/badge';\nimport { ClockGate } from '@/registry/ndeko/ui/live-duration';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\n\nimport { Countdown } from './countdown';\nimport {\n  CLAIMED_AT_LOAD,\n  DEMO_CLAIM,\n  JOINS,\n  OFFER,\n  PERKS,\n  perkOf,\n  type Claimed,\n  type PerkId,\n} from './data';\nimport { PerkCard } from './perk-card';\n\nconst JOIN_EVERY_MS = 1300;\n\nconst LOOP_AFTER_MS = 3600;\n\nfunction withJoin(claimed: Claimed, id: PerkId, count: number): Claimed {\n  const perk = perkOf(id);\n  const next = Math.min(perk.cap, claimed[id] + count);\n  return { ...claimed, [id]: next };\n}\n\nfunction withClaim(mine: PerkId[], id: PerkId) {\n  if (mine.includes(id)) {\n    return mine;\n  }\n  return [...mine, id];\n}\n\nexport default function AiProduct04() {\n  const [claimed, setClaimed] = useState<Claimed>(CLAIMED_AT_LOAD);\n  const [mine, setMine] = useState<PerkId[]>([]);\n  const [message, setMessage] = useState('');\n  const { pressed, press } = usePress<string>();\n\n  function join(id: PerkId, count: number) {\n    setClaimed((current) => withJoin(current, id, count));\n  }\n\n  function claim(id: PerkId) {\n    const isMine = mine.includes(id);\n    const perk = perkOf(id);\n    const isFull = claimed[id] >= perk.cap;\n    if (isMine || isFull) {\n      return;\n    }\n    setClaimed((current) => withJoin(current, id, 1));\n    setMine((current) => withClaim(current, id));\n    setMessage(`${perk.title} claimed`);\n  }\n\n  function resetDemonstration() {\n    setClaimed(CLAIMED_AT_LOAD);\n    setMine([]);\n    setMessage('');\n  }\n\n  const joinSteps = JOINS.map((entry) => ({\n    after: JOIN_EVERY_MS,\n    run: () => join(entry.id, entry.count),\n  }));\n  const steps = [\n    ...joinSteps,\n    { after: 1500, run: () => press(`claim-${DEMO_CLAIM}`) },\n    { after: PRESS_LEAD_MS, run: () => claim(DEMO_CLAIM) },\n  ];\n  const { ref, isInView, isAutoplaying } = useAutoplay<HTMLElement>(steps, {\n    loopAfter: LOOP_AFTER_MS,\n    onReset: resetDemonstration,\n  });\n  const spoken = spokenUnless(isAutoplaying, message);\n\n  return (\n    <ClockGate isActive={isInView}>\n      <section ref={ref} className='@container'>\n        <div className='mx-auto flex max-w-6xl flex-col gap-10 px-4 py-16 @2xl:px-6 @2xl:py-24 @5xl:px-8'>\n          <header className='flex flex-wrap items-end justify-between gap-x-6 gap-y-4'>\n            <div className='flex max-w-2xl flex-col gap-3'>\n              <p className='text-primary-ink flex items-center gap-1.5 text-[13px] font-medium'>\n                <TicketPercentIcon className='size-4' />\n                {OFFER.product} {OFFER.label}\n              </p>\n              <h2 className='text-2xl font-semibold text-balance @2xl:text-3xl'>\n                {OFFER.title}\n              </h2>\n              <p className='text-muted-foreground text-base text-pretty'>\n                {OFFER.lead}\n              </p>\n            </div>\n            <div className='flex flex-wrap items-center gap-2'>\n              <Countdown />\n              <Badge variant='secondary'>Illustrative</Badge>\n            </div>\n          </header>\n          <div className='grid gap-3 @3xl:grid-cols-3'>\n            {PERKS.map((perk) => (\n              <PerkCard\n                key={perk.id}\n                perk={perk}\n                claimed={claimed[perk.id]}\n                hasClaimed={mine.includes(perk.id)}\n                pressed={pressed}\n                onClaim={claim}\n              />\n            ))}\n          </div>\n        </div>\n        <LiveRegion message={spoken} />\n      </section>\n    </ClockGate>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/ai-product-04/index.tsx"
    },
    {
      "path": "registry/ndeko/blocks/ai-product/ai-product-04/perk-card.tsx",
      "content": "'use client';\n\nimport { MotionNumber } from '@/components/core/motion-number';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { seriesColorOf } from '@/registry/ndeko/lib/agent-run';\nimport { pressedQuietOf } from '@/registry/ndeko/lib/demonstration';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Button } from '@/registry/ndeko/ui/button';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\nimport { DrawnCheck } from '@/registry/ndeko/ui/drawn-check';\n\nimport { shareOf, type Perk } from './data';\nimport { PerkMark } from './perk-marks';\n\ntype TintStyle = React.CSSProperties & { '--tint': string; '--gem': string };\n\nfunction easedOf(shouldReduceMotion: boolean) {\n  if (shouldReduceMotion) {\n    return 'transition-none';\n  }\n  return 'transition-transform duration-700 ease-(--ease-out-strong)';\n}\n\ntype ClaimPhase = 'open' | 'claimed' | 'full';\n\nfunction phaseOf(hasClaimed: boolean, isFull: boolean): ClaimPhase {\n  if (hasClaimed) {\n    return 'claimed';\n  }\n  if (isFull) {\n    return 'full';\n  }\n  return 'open';\n}\n\ntype PerkCardProps = {\n  perk: Perk;\n  claimed: number;\n  hasClaimed: boolean;\n  pressed: string | null;\n  onClaim: (id: Perk['id']) => void;\n};\n\nexport function PerkCard({\n  perk,\n  claimed,\n  hasClaimed,\n  pressed,\n  onClaim,\n}: PerkCardProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const eased = easedOf(shouldReduceMotion);\n  const share = shareOf(claimed, perk.cap);\n  const isFull = claimed >= perk.cap;\n  const left = perk.cap - claimed;\n  const phase = phaseOf(hasClaimed, isFull);\n  const open = 1 - share;\n  const remaining = open * 100;\n  const fillStyle = { transform: `translateX(-${remaining}%)` };\n  const color = seriesColorOf(perk.series);\n  const tint: TintStyle = { '--tint': color, '--gem': color };\n  const isPressed = pressed === `claim-${perk.id}`;\n\n  return (\n    <article\n      style={tint}\n      className='hairline-ring ring-border flex flex-col gap-5 rounded-xl bg-[color-mix(in_oklab,var(--tint)_7%,var(--card))] p-5 @2xl:p-6'\n    >\n      <header className='flex items-center gap-3'>\n        <span className='gem-plate inline-flex size-9 shrink-0 items-center justify-center rounded-lg'>\n          <PerkMark perk={perk.id} className='size-5' />\n        </span>\n        <h3 className='text-sm font-medium'>{perk.title}</h3>\n      </header>\n      <p className='text-muted-foreground text-[13px] leading-relaxed text-pretty'>\n        {perk.detail}\n      </p>\n      <div className='mt-auto flex flex-col gap-3'>\n        <div className='flex flex-col gap-2'>\n          <p className='flex items-baseline gap-1.5'>\n            <MotionNumber value={claimed} className='text-3xl font-semibold' />\n            <span className='text-muted-foreground text-[13px] tabular-nums'>\n              of {perk.cap} claimed\n            </span>\n          </p>\n          <div\n            role='meter'\n            aria-label={`${perk.title}: spots claimed`}\n            aria-valuemin={0}\n            aria-valuemax={perk.cap}\n            aria-valuenow={claimed}\n            className='bg-foreground/10 h-2 overflow-hidden rounded-full'\n          >\n            <span\n              style={fillStyle}\n              className={cn('block h-full rounded-full bg-(--tint)', eased)}\n            />\n          </div>\n          <p className='text-muted-foreground flex items-baseline gap-1 text-xs'>\n            <MotionNumber value={left} />\n            left\n          </p>\n        </div>\n        <Swap swapKey={phase} className='self-start'>\n          {phase === 'open' && (\n            <Button\n              type='button'\n              variant='outline'\n              onClick={() => onClaim(perk.id)}\n              className={pressedQuietOf(isPressed)}\n            >\n              Claim this perk\n            </Button>\n          )}\n          {phase === 'claimed' && (\n            <span className='text-success-foreground flex h-8 items-center gap-1.5 text-[13px] font-medium'>\n              <DrawnCheck tone='success' entrance='draw' />\n              Claimed\n            </span>\n          )}\n          {phase === 'full' && (\n            <Button type='button' variant='outline' disabled>\n              All spots claimed\n            </Button>\n          )}\n        </Swap>\n      </div>\n    </article>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/ai-product-04/perk-card.tsx"
    },
    {
      "path": "registry/ndeko/blocks/ai-product/ai-product-04/perk-marks.tsx",
      "content": "import type { PerkId } from './data';\n\nconst STROKE: React.SVGAttributes<SVGElement> = {\n  fill: 'none',\n  stroke: 'currentColor',\n  strokeWidth: 1.75,\n  strokeLinecap: 'round',\n  strokeLinejoin: 'round',\n};\n\nconst PRICE = (\n  <>\n    <path\n      {...STROKE}\n      d='M3.5 12.2V5.5a2 2 0 0 1 2-2h6.7a2 2 0 0 1 1.4.6l6.3 6.3a2 2 0 0 1 0 2.8l-6.7 6.7a2 2 0 0 1-2.8 0l-6.3-6.3a2 2 0 0 1-.6-1.4Z'\n    />\n    <circle {...STROKE} cx='8.2' cy='8.2' r='1.3' />\n    <path {...STROKE} d='m11 14 3-3' />\n  </>\n);\n\nconst CALL = (\n  <>\n    <path\n      {...STROKE}\n      d='M20 11.5a7.5 7.5 0 0 1-11 6.6L4 19.5l1.4-4.4A7.5 7.5 0 1 1 20 11.5Z'\n    />\n    <path {...STROKE} d='M9 11.5h.01M12.5 11.5h.01M16 11.5h.01' />\n  </>\n);\n\nconst CREDITS = (\n  <>\n    <ellipse {...STROKE} cx='12' cy='6.5' rx='6.5' ry='2.8' />\n    <path\n      {...STROKE}\n      d='M5.5 6.5v5.2c0 1.5 2.9 2.8 6.5 2.8s6.5-1.3 6.5-2.8V6.5'\n    />\n    <path\n      {...STROKE}\n      d='M5.5 11.7v5.1c0 1.5 2.9 2.7 6.5 2.7s6.5-1.2 6.5-2.7v-5.1'\n    />\n  </>\n);\n\nconst MARKS: Record<PerkId, React.ReactNode> = {\n  price: PRICE,\n  call: CALL,\n  credits: CREDITS,\n};\n\ntype PerkMarkProps = {\n  perk: PerkId;\n  className?: string;\n};\n\nexport function PerkMark({ perk, className }: PerkMarkProps) {\n  return (\n    <svg\n      aria-hidden='true'\n      viewBox='0 0 24 24'\n      focusable='false'\n      className={className}\n    >\n      {MARKS[perk]}\n    </svg>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/ai-product-04/perk-marks.tsx"
    },
    {
      "path": "registry/ndeko/blocks/ai-product/ai-product-04/countdown.tsx",
      "content": "'use client';\n\nimport { useNow } from '@/registry/ndeko/hooks/use-agent-run';\n\nimport { OFFER_LENGTH_MS } from './data';\n\nconst SECOND_MS = 1000;\nconst MINUTE_MS = 60 * SECOND_MS;\nconst HOUR_MS = 60 * MINUTE_MS;\nconst DAY_MS = 24 * HOUR_MS;\n\nconst LOADED_AT = Date.now();\n\nconst ENDS_AT = LOADED_AT + OFFER_LENGTH_MS;\n\nfunction twoDigits(value: number) {\n  return String(value).padStart(2, '0');\n}\n\nfunction clockTextOf(remainingMs: number) {\n  const days = Math.floor(remainingMs / DAY_MS);\n  const sinceDay = remainingMs % DAY_MS;\n  const hours = Math.floor(sinceDay / HOUR_MS);\n  const sinceHour = remainingMs % HOUR_MS;\n  const minutes = Math.floor(sinceHour / MINUTE_MS);\n  const sinceMinute = remainingMs % MINUTE_MS;\n  const seconds = Math.floor(sinceMinute / SECOND_MS);\n  const time = [hours, minutes, seconds].map(twoDigits).join(':');\n  return `${days}d ${time}`;\n}\n\n/**\n * The only part of the block that ticks. Until the browser has a clock the length of the offer\n * stands in, so the page and its first paint agree.\n */\nexport function Countdown() {\n  const now = useNow(SECOND_MS);\n  const hasClock = now > 0;\n  let remaining = OFFER_LENGTH_MS;\n  if (hasClock) {\n    remaining = Math.max(0, ENDS_AT - now);\n  }\n  const isOver = remaining === 0;\n\n  return (\n    <p className='flex items-center gap-2 text-[13px]'>\n      <span className='text-muted-foreground'>Ends in</span>\n      <span\n        role='timer'\n        aria-label='Time left in the offer'\n        className='bg-foreground/[0.06] inline-block w-28 rounded-md px-2 py-1 text-center font-medium tabular-nums'\n      >\n        {clockTextOf(remaining)}\n      </span>\n      {isOver && <span className='text-muted-foreground'>The offer ended</span>}\n    </p>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/blocks/ai-product-04/countdown.tsx"
    },
    {
      "path": "registry/ndeko/blocks/ai-product/ai-product-04/data.ts",
      "content": "import type { SeriesSlot } from '@/registry/ndeko/lib/agent-run';\n\nexport const OFFER = {\n  product: 'Lumo',\n  label: 'Launch offer',\n  title: 'Founding members get three perks',\n  lead: 'The offer closes when the clock runs out or the spots are claimed, whichever comes first.',\n};\n\nconst HOUR_MS = 3_600_000;\n\nconst MINUTE_MS = 60_000;\n\nconst SECOND_MS = 1000;\n\nconst OFFER_HOURS_MS = 54 * HOUR_MS;\n\nconst OFFER_MINUTES_MS = 41 * MINUTE_MS;\n\nconst OFFER_SECONDS_MS = 12 * SECOND_MS;\n\nexport const OFFER_LENGTH_MS =\n  OFFER_HOURS_MS + OFFER_MINUTES_MS + OFFER_SECONDS_MS;\n\nexport type PerkId = 'price' | 'call' | 'credits';\n\nexport type Perk = {\n  id: PerkId;\n  title: string;\n  detail: string;\n  cap: number;\n  claimedAtLoad: number;\n  series: SeriesSlot;\n};\n\nexport const PERKS: Perk[] = [\n  {\n    id: 'price',\n    title: 'Founding price',\n    detail: 'Keep $12 a month for as long as you stay, instead of $24',\n    cap: 500,\n    claimedAtLoad: 396,\n    series: 1,\n  },\n  {\n    id: 'call',\n    title: 'Setup call',\n    detail: 'A 30 minute call with the team to wire your first agent',\n    cap: 60,\n    claimedAtLoad: 34,\n    series: 2,\n  },\n  {\n    id: 'credits',\n    title: 'Bonus credits',\n    detail: '5,000 credits added to your first month',\n    cap: 400,\n    claimedAtLoad: 255,\n    series: 3,\n  },\n];\n\nexport type Join = { id: PerkId; count: number };\n\nexport const JOINS: Join[] = [\n  { id: 'price', count: 9 },\n  { id: 'credits', count: 14 },\n  { id: 'call', count: 2 },\n  { id: 'price', count: 11 },\n  { id: 'credits', count: 8 },\n  { id: 'call', count: 3 },\n  { id: 'price', count: 7 },\n];\n\nexport const DEMO_CLAIM: PerkId = 'call';\n\nexport type Claimed = Record<PerkId, number>;\n\nfunction claimedAtLoadOf() {\n  const claimed: Claimed = { price: 0, call: 0, credits: 0 };\n  for (const perk of PERKS) {\n    claimed[perk.id] = perk.claimedAtLoad;\n  }\n  return claimed;\n}\n\nexport const CLAIMED_AT_LOAD = claimedAtLoadOf();\n\nexport function perkOf(id: PerkId) {\n  const perk = PERKS.find((candidate) => candidate.id === id);\n  return perk ?? PERKS[0];\n}\n\nexport function shareOf(claimed: number, cap: number) {\n  if (cap <= 0) {\n    return 0;\n  }\n  const share = claimed / cap;\n  return Math.min(1, share);\n}\n",
      "type": "registry:component",
      "target": "components/blocks/ai-product-04/data.ts"
    }
  ],
  "categories": [
    "blocks",
    "ai-product"
  ],
  "type": "registry:block"
}