{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"booking-calendar","type":"registry:component","title":"Date Picker Booking Calendar","description":"Two-month stay picker with nightly prices under each day and the cheapest days tinted, booked nights struck through, a minimum stay, and a footer with dates, nights, total and a Reserve button.","author":"kara <ztzyrant@gmail.com>","dependencies":["clsx","lucide-react","motion","tailwind-merge"],"registryDependencies":[],"files":[{"path":"components/motion/booking-calendar.tsx","type":"registry:component","target":"@components/motion/booking-calendar.tsx","content":"\"use client\";\n// karaui.kamisama-v0.my.id/components/motion/date-picker\n\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { useCallback, useMemo, useState } from \"react\";\nimport { Button } from \"@/components/motion/button\";\nimport {\n  Calendar,\n  type CalendarDayMeta,\n  type DateRange,\n} from \"@/components/motion/calendar\";\nimport { EASE_OUT } from \"@/lib/ease\";\nimport { cn } from \"@/lib/utils\";\n\nexport type BookingSummary = {\n  from: Date;\n  to: Date;\n  nights: number;\n  /** Sum of the nightly prices, check-in night through the last night. */\n  total: number;\n};\n\nexport interface BookingCalendarProps {\n  /** Nightly price keyed by \"YYYY-MM-DD\" (the night's check-in date), or a\n   * function. Nights without a price can't be booked. */\n  prices: Record<string, number> | ((date: Date) => number | null | undefined);\n  /** Nights already taken, as dates or \"YYYY-MM-DD\". They render struck\n   * through; the first one after a check-in still works as the check-out. */\n  booked?: (Date | string)[];\n  /** Fewest nights per stay. Default 1. */\n  minNights?: number;\n  /** Most nights per stay. */\n  maxNights?: number;\n  /** ISO 4217 code for prices and the total. Default \"USD\". */\n  currency?: string;\n  /** BCP 47 locale. Default \"en-US\" so server and client output match. */\n  locale?: string;\n  /** Earliest check-in, typically today (read it after mount). */\n  minDate?: Date;\n  maxDate?: Date;\n  value?: DateRange | null;\n  defaultValue?: DateRange | null;\n  onValueChange?: (range: DateRange | null) => void;\n  /** Uncontrolled first visible month. */\n  defaultMonth?: Date;\n  /** Months side by side. Default 2. */\n  numberOfMonths?: number;\n  weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;\n  /** Called by the Reserve button with the finished stay. */\n  onReserve?: (booking: BookingSummary) => void;\n  /** Reserve button text. Default \"Reserve\". */\n  reserveLabel?: string;\n  className?: string;\n}\n\nconst dayKey = (d: Date) =>\n  `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, \"0\")}-${String(d.getDate()).padStart(2, \"0\")}`;\nconst addDays = (d: Date, n: number) =>\n  new Date(d.getFullYear(), d.getMonth(), d.getDate() + n);\nconst sameDay = (a: Date, b: Date) => dayKey(a) === dayKey(b);\nconst nightsBetween = (a: Date, b: Date) =>\n  Math.round(\n    (new Date(b.getFullYear(), b.getMonth(), b.getDate()).getTime() -\n      new Date(a.getFullYear(), a.getMonth(), a.getDate()).getTime()) /\n      86_400_000,\n  );\nconst toDate = (d: Date | string) => {\n  if (d instanceof Date) return d;\n  const [y, m, day] = d.split(\"-\").map(Number);\n  return new Date(y, m - 1, day);\n};\n\n/** Share of each month's open nights tinted as the cheapest. */\nconst CHEAP_SHARE = 0.25;\n/** How far ahead to look for the next taken night after a check-in. */\nconst SCAN_LIMIT = 366;\n\nconst SWAP = { duration: 0.2, ease: EASE_OUT } as const;\n\n/**\n * Stay picker block: a two-month range `Calendar` with nightly prices under\n * each day (each month's cheapest quarter tinted), booked nights struck\n * through and unselectable, a stay can't run across a booked night, minimum\n * and maximum nights, and a summary footer with dates, nights, the\n * `Intl`-formatted total and a Reserve button. Controlled or uncontrolled.\n */\nexport function BookingCalendar({\n  prices,\n  booked,\n  minNights = 1,\n  maxNights,\n  currency = \"USD\",\n  locale = \"en-US\",\n  minDate,\n  maxDate,\n  value: controlledValue,\n  defaultValue = null,\n  onValueChange,\n  defaultMonth,\n  numberOfMonths = 2,\n  weekStartsOn = 0,\n  onReserve,\n  reserveLabel = \"Reserve\",\n  className,\n}: BookingCalendarProps) {\n  const reduce = useReducedMotion();\n  const [internalValue, setInternalValue] = useState<DateRange | null>(\n    defaultValue,\n  );\n  const value =\n    controlledValue !== undefined ? controlledValue : internalValue;\n  const setValue = (next: DateRange | null) => {\n    if (controlledValue === undefined) setInternalValue(next);\n    onValueChange?.(next);\n  };\n\n  const bookedKeys = useMemo(\n    () => new Set((booked ?? []).map((d) => dayKey(toDate(d)))),\n    [booked],\n  );\n  const priceOf = useCallback(\n    (d: Date) => {\n      const p = typeof prices === \"function\" ? prices(d) : prices[dayKey(d)];\n      return p ?? null;\n    },\n    [prices],\n  );\n  const nightOpen = useCallback(\n    (d: Date) => !bookedKeys.has(dayKey(d)) && priceOf(d) !== null,\n    [bookedKeys, priceOf],\n  );\n\n  // Cheapest-quarter threshold per month, computed once per month shown.\n  const cheapThreshold = useMemo(() => {\n    const cache = new Map<string, number>();\n    return (d: Date) => {\n      const key = dayKey(d).slice(0, 7);\n      const hit = cache.get(key);\n      if (hit !== undefined) return hit;\n      const open: number[] = [];\n      const last = new Date(d.getFullYear(), d.getMonth() + 1, 0).getDate();\n      for (let i = 1; i <= last; i++) {\n        const day = new Date(d.getFullYear(), d.getMonth(), i);\n        const p = priceOf(day);\n        if (p !== null && !bookedKeys.has(dayKey(day))) open.push(p);\n      }\n      open.sort((a, b) => a - b);\n      const t = open.length\n        ? open[Math.floor((open.length - 1) * CHEAP_SHARE)]\n        : Number.NEGATIVE_INFINITY;\n      cache.set(key, t);\n      return t;\n    };\n  }, [bookedKeys, priceOf]);\n\n  // While the check-out is being picked, the stay can't cross a taken night:\n  // the first one caps the length, and its day still works as the check-out.\n  const choosingEnd = !!value && !value.to;\n  const reach = useMemo(() => {\n    if (!value || value.to) return null;\n    const cap = maxNights ?? SCAN_LIMIT;\n    for (let n = 1; n <= cap; n++)\n      if (!nightOpen(addDays(value.from, n))) return n;\n    return cap;\n  }, [value, maxNights, nightOpen]);\n  const checkoutOnly =\n    choosingEnd && value && reach !== null && !nightOpen(addDays(value.from, reach))\n      ? addDays(value.from, reach)\n      : null;\n\n  const priceLabel = useMemo(\n    () =>\n      new Intl.NumberFormat(locale, {\n        style: \"currency\",\n        currency,\n        notation: \"compact\",\n        maximumFractionDigits: 0,\n      }),\n    [locale, currency],\n  );\n  const money = useMemo(\n    () =>\n      new Intl.NumberFormat(locale, {\n        style: \"currency\",\n        currency,\n        maximumFractionDigits: 0,\n      }),\n    [locale, currency],\n  );\n  const shortDate = useMemo(\n    () =>\n      new Intl.DateTimeFormat(locale, {\n        weekday: \"short\",\n        month: \"short\",\n        day: \"numeric\",\n      }),\n    [locale],\n  );\n\n  const getDayMeta = (d: Date): CalendarDayMeta => {\n    if (checkoutOnly && sameDay(d, checkoutOnly))\n      return { label: \"Out\", tone: \"muted\" };\n    const price = priceOf(d);\n    if (bookedKeys.has(dayKey(d)) || price === null) return { disabled: true };\n    return {\n      label: priceLabel.format(price),\n      tone: price <= cheapThreshold(d) ? \"accent\" : undefined,\n    };\n  };\n\n  const stay: BookingSummary | null = useMemo(() => {\n    if (!value?.to) return null;\n    const nights = nightsBetween(value.from, value.to);\n    let total = 0;\n    for (let i = 0; i < nights; i++) total += priceOf(addDays(value.from, i)) ?? 0;\n    return { from: value.from, to: value.to, nights, total };\n  }, [value, priceOf]);\n\n  const hint = stay\n    ? `${shortDate.format(stay.from)} – ${shortDate.format(stay.to)}`\n    : value\n      ? `Check-in ${shortDate.format(value.from)} · pick check-out`\n      : \"Pick a check-in date\";\n  const detail = stay\n    ? `${stay.nights} night${stay.nights === 1 ? \"\" : \"s\"} · ${money.format(stay.total)}`\n    : minNights > 1\n      ? `${minNights}-night minimum`\n      : \"Prices per night\";\n\n  return (\n    <div\n      className={cn(\n        \"w-fit rounded-2xl border border-border bg-card text-foreground\",\n        className,\n      )}\n    >\n      <Calendar\n        mode=\"range\"\n        value={value}\n        onValueChange={setValue}\n        numberOfMonths={numberOfMonths}\n        minNights={minNights}\n        maxNights={reach ?? maxNights}\n        getDayMeta={getDayMeta}\n        minDate={minDate}\n        maxDate={maxDate}\n        defaultMonth={defaultMonth}\n        weekStartsOn={weekStartsOn}\n        locale={locale}\n        aria-label=\"Stay dates\"\n        className=\"border-0 bg-transparent\"\n      />\n      <div className=\"flex items-center justify-between gap-4 border-t border-border px-4 py-3\">\n        <div aria-live=\"polite\" className=\"min-w-0\">\n          <AnimatePresence initial={false} mode=\"popLayout\">\n            <motion.p\n              key={hint}\n              initial={{ opacity: 0, y: reduce ? 0 : 6 }}\n              animate={{ opacity: 1, y: 0, transition: SWAP }}\n              exit={{ opacity: 0, y: reduce ? 0 : -6, transition: SWAP }}\n              className=\"truncate text-sm font-medium tabular-nums\"\n            >\n              {hint}\n            </motion.p>\n          </AnimatePresence>\n          <p className=\"truncate text-xs text-muted-foreground tabular-nums\">\n            {detail}\n          </p>\n        </div>\n        <div className=\"flex shrink-0 items-center gap-1\">\n          {value && (\n            <Button variant=\"ghost\" size=\"sm\" onClick={() => setValue(null)}>\n              Clear\n            </Button>\n          )}\n          <Button\n            size=\"sm\"\n            disabled={!stay}\n            onClick={() => stay && onReserve?.(stay)}\n          >\n            {reserveLabel}\n          </Button>\n        </div>\n      </div>\n    </div>\n  );\n}\n"},{"path":"components/motion/button/index.tsx","type":"registry:component","target":"@components/motion/button/index.tsx","content":"export type {\n  ButtonLinkProps,\n  ButtonProps,\n  ButtonSize,\n  ButtonVariant,\n} from \"./base\";\nexport { Button, ButtonLink } from \"./base\";\nexport type { MagneticButtonProps } from \"./magnetic\";\nexport { MagneticButton } from \"./magnetic\";\nexport type { ButtonState, StatefulButtonProps } from \"./stateful\";\nexport { StatefulButton } from \"./stateful\";\n"},{"path":"components/motion/calendar.tsx","type":"registry:component","target":"@components/motion/calendar.tsx","content":"\"use client\";\n\nimport { ChevronLeft, ChevronRight } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport {\n  type KeyboardEvent,\n  useCallback,\n  useEffect,\n  useId,\n  useMemo,\n  useRef,\n  useState,\n} from \"react\";\nimport { EASE_OUT, SPRING_LAYOUT, SPRING_PRESS } from \"@/lib/ease\";\nimport { cn } from \"@/lib/utils\";\n\nexport type DateRange = { from: Date; to?: Date };\n/** A whole week row: `from` is its first day, `to` its seventh. */\nexport type WeekRange = { from: Date; to: Date };\n\n/** Per-day extras from `getDayMeta`. */\nexport type CalendarDayMeta = {\n  /** Short text under the day number (a price, a count). Cells grow taller\n   * when any day has meta; the label is also read after the date. */\n  label?: string;\n  /** \"accent\" tints the label (deals, highlights); \"muted\" fades it. */\n  tone?: \"muted\" | \"accent\";\n  /** Blocks the day and strikes it through, like `isDateDisabled`. */\n  disabled?: boolean;\n};\n\ntype CalendarBaseProps = {\n  /** Earliest selectable day (inclusive). */\n  minDate?: Date;\n  /** Latest selectable day (inclusive). */\n  maxDate?: Date;\n  /** Extra per-day rule, e.g. weekends or booked dates. */\n  isDateDisabled?: (date: Date) => boolean;\n  /** 0 = Sunday … 6 = Saturday. Default 0. */\n  weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;\n  /** BCP 47 locale for month, weekday and day labels. Default \"en-US\" — a\n   * fixed default keeps server and client output identical for hydration. */\n  locale?: string;\n  /** Controlled visible month (any day inside it). */\n  month?: Date;\n  /** Uncontrolled initial visible month. Default: the selection or today. */\n  defaultMonth?: Date;\n  onMonthChange?: (month: Date) => void;\n  /** Months shown side by side (stacked below `sm`). Default 1. With more\n   * than one, days outside each month are left blank so none repeats. */\n  numberOfMonths?: number;\n  /** Adds an ISO 8601 week-number column (\"Wk\") before each row. */\n  showWeekNumber?: boolean;\n  /** Per-day label, tone and blocking, e.g. nightly prices or booked days.\n   * Passing it switches the grid to taller cells that fit the label. */\n  getDayMeta?: (date: Date) => CalendarDayMeta | null | undefined;\n  className?: string;\n  \"aria-label\"?: string;\n};\n\nexport type CalendarSingleProps = CalendarBaseProps & {\n  mode?: \"single\";\n  value?: Date | null;\n  defaultValue?: Date | null;\n  onValueChange?: (date: Date) => void;\n};\n\nexport type CalendarRangeProps = CalendarBaseProps & {\n  mode: \"range\";\n  value?: DateRange | null;\n  defaultValue?: DateRange | null;\n  onValueChange?: (range: DateRange) => void;\n  /** Fewest nights (days between start and end) a finished range may span.\n   * While the end is being chosen, days too close are blocked. */\n  minNights?: number;\n  /** Most nights a finished range may span; farther days are blocked. */\n  maxNights?: number;\n};\n\nexport type CalendarWeekProps = CalendarBaseProps & {\n  mode: \"week\";\n  value?: WeekRange | null;\n  defaultValue?: WeekRange | null;\n  /** Called with the picked day's whole row, honouring `weekStartsOn`. */\n  onValueChange?: (week: WeekRange) => void;\n};\n\nexport type CalendarMultipleProps = CalendarBaseProps & {\n  mode: \"multiple\";\n  value?: Date[] | null;\n  defaultValue?: Date[] | null;\n  /** Called with the selection sorted by date. */\n  onValueChange?: (dates: Date[]) => void;\n  /** Most days that can be picked; further picks are ignored. */\n  max?: number;\n};\n\nexport type CalendarProps =\n  | CalendarSingleProps\n  | CalendarRangeProps\n  | CalendarWeekProps\n  | CalendarMultipleProps;\n\n// ── date helpers (local time, day precision) ──────────────────────────────\n\nconst startOfDay = (d: Date) =>\n  new Date(d.getFullYear(), d.getMonth(), d.getDate());\nconst startOfMonth = (d: Date) => new Date(d.getFullYear(), d.getMonth(), 1);\nconst addDays = (d: Date, n: number) =>\n  new Date(d.getFullYear(), d.getMonth(), d.getDate() + n);\n/** Adds months, clamping the day so Jan 31 + 1 month lands on Feb 28/29. */\nfunction addMonths(d: Date, n: number) {\n  const target = new Date(d.getFullYear(), d.getMonth() + n, 1);\n  const lastDay = new Date(\n    target.getFullYear(),\n    target.getMonth() + 1,\n    0,\n  ).getDate();\n  target.setDate(Math.min(d.getDate(), lastDay));\n  return target;\n}\nconst sameDay = (a?: Date | null, b?: Date | null) =>\n  !!a &&\n  !!b &&\n  a.getFullYear() === b.getFullYear() &&\n  a.getMonth() === b.getMonth() &&\n  a.getDate() === b.getDate();\nconst sameMonth = (a: Date, b: Date) =>\n  a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth();\nconst dayKey = (d: Date) =>\n  `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, \"0\")}-${String(d.getDate()).padStart(2, \"0\")}`;\nconst monthKey = (d: Date) =>\n  `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, \"0\")}`;\n/** Whole days from `a` to `b`; rounding absorbs DST hour shifts. */\nconst daysBetween = (a: Date, b: Date) =>\n  Math.round((startOfDay(b).getTime() - startOfDay(a).getTime()) / 86_400_000);\n/** ISO 8601 week number: weeks start Monday, week 1 holds Jan 4. */\nfunction isoWeek(d: Date) {\n  const thursday = addDays(d, 3 - ((d.getDay() + 6) % 7));\n  const jan4 = new Date(thursday.getFullYear(), 0, 4);\n  const firstThursday = addDays(jan4, 3 - ((jan4.getDay() + 6) % 7));\n  return 1 + Math.round(daysBetween(firstThursday, thursday) / 7);\n}\n\n/** Always 6 weeks, so the panel never changes height between months. */\nfunction buildWeeks(month: Date, weekStartsOn: number) {\n  const first = startOfMonth(month);\n  const offset = (first.getDay() - weekStartsOn + 7) % 7;\n  const start = addDays(first, -offset);\n  return Array.from({ length: 6 }, (_, w) =>\n    Array.from({ length: 7 }, (_, d) => addDays(start, w * 7 + d)),\n  );\n}\n\n// Month swap is a short directional slide; the exit is quicker than the entry.\nconst MONTH_ENTER = { duration: 0.26, ease: EASE_OUT } as const;\nconst MONTH_EXIT = { duration: 0.16, ease: EASE_OUT } as const;\n\n/**\n * Month-grid calendar for single dates, ranges, whole weeks or several\n * separate days, one or more months wide. The selected day is a pill that\n * glides between days on a shared-layout spring; a picked week is one pill\n * across its row; months slide in from the direction you travel. Optional ISO\n * week numbers, per-day labels (`getDayMeta`) and night limits for ranges.\n * Full keyboard grid navigation (arrows, Home/End, PageUp/PageDown,\n * Shift+Page for years). Controlled or uncontrolled for both the selection\n * and the visible month; reduced-motion safe.\n */\nexport function Calendar(props: CalendarProps) {\n  const {\n    minDate,\n    maxDate,\n    isDateDisabled,\n    weekStartsOn = 0,\n    locale = \"en-US\",\n    month: controlledMonth,\n    defaultMonth,\n    onMonthChange,\n    numberOfMonths = 1,\n    showWeekNumber = false,\n    getDayMeta,\n    className,\n    \"aria-label\": ariaLabel,\n  } = props;\n  const isRange = props.mode === \"range\";\n  const isWeek = props.mode === \"week\";\n  const isMultiple = props.mode === \"multiple\";\n  const count = Math.max(1, Math.floor(numberOfMonths));\n  const minNights = isRange ? ((props as CalendarRangeProps).minNights ?? 0) : 0;\n  const maxNights = isRange ? (props as CalendarRangeProps).maxNights : undefined;\n  // Taller cells only when there is something to put under the number.\n  const tall = !!getDayMeta;\n\n  const uid = useId();\n  const reduce = useReducedMotion();\n\n  // ── selection ──\n  const [internalValue, setInternalValue] = useState<\n    Date | DateRange | WeekRange | Date[] | null\n  >(props.defaultValue ?? null);\n  const valueControlled = props.value !== undefined;\n  const value = valueControlled ? (props.value ?? null) : internalValue;\n  const single =\n    isRange || isWeek || isMultiple ? null : (value as Date | null);\n  const range = isRange ? (value as DateRange | null) : null;\n  const week = isWeek ? (value as WeekRange | null) : null;\n  const picked = isMultiple ? ((value as Date[] | null) ?? []) : [];\n  const isPicked = (d: Date) => picked.some((p) => sameDay(p, d));\n\n  // ── visible months ──\n  const anchor = single ?? range?.from ?? week?.from ?? picked[0] ?? null;\n  const [internalMonth, setInternalMonth] = useState(() =>\n    startOfMonth(defaultMonth ?? anchor ?? new Date()),\n  );\n  const month = controlledMonth\n    ? startOfMonth(controlledMonth)\n    : internalMonth;\n  const [direction, setDirection] = useState(1);\n  const lastMonth = addMonths(month, count - 1);\n  const inWindow = (d: Date) => {\n    const m = startOfMonth(d);\n    return m >= month && m <= lastMonth;\n  };\n\n  const setMonth = useCallback(\n    (next: Date) => {\n      const m = startOfMonth(next);\n      if (sameMonth(m, month)) return;\n      setDirection(m > month ? 1 : -1);\n      if (!controlledMonth) setInternalMonth(m);\n      onMonthChange?.(m);\n    },\n    [month, controlledMonth, onMonthChange],\n  );\n\n  // \"Today\" is read after mount: the server's clock and timezone can disagree\n  // with the viewer's, and a mismatched marker would break hydration.\n  const [today, setToday] = useState<Date | null>(null);\n  useEffect(() => setToday(startOfDay(new Date())), []);\n\n  // ── roving focus ──\n  const [focused, setFocused] = useState<Date>(() =>\n    startOfDay(anchor ?? defaultMonth ?? new Date()),\n  );\n  const gridRef = useRef<HTMLDivElement>(null);\n  const shouldFocus = useRef(false);\n  // Range hover preview: the band follows the pointer until the end is picked.\n  // In week mode it is the row under the pointer or keyboard focus.\n  const [hovered, setHovered] = useState<Date | null>(null);\n\n  // Keep the tab stop inside the visible months when they change by buttons.\n  const focusInMonth = inWindow(focused)\n    ? focused\n    : anchor && inWindow(anchor)\n      ? anchor\n      : month;\n\n  useEffect(() => {\n    if (!shouldFocus.current) return;\n    shouldFocus.current = false;\n    gridRef.current\n      ?.querySelector<HTMLButtonElement>(\n        `[data-month=\"${monthKey(focusInMonth)}\"] [data-date=\"${dayKey(focusInMonth)}\"]`,\n      )\n      ?.focus();\n  }, [focusInMonth]);\n\n  const isDisabled = useCallback(\n    (d: Date) =>\n      (minDate && d < startOfDay(minDate)) ||\n      (maxDate && d > startOfDay(maxDate)) ||\n      !!isDateDisabled?.(d) ||\n      !!getDayMeta?.(d)?.disabled,\n    [minDate, maxDate, isDateDisabled, getDayMeta],\n  );\n\n  // While a range end is being chosen, days that would make it too short or\n  // too long are blocked (earlier days stay open: they restart the range).\n  const choosingEnd = !!range && !range.to;\n  const nightsAllowed = (n: number) =>\n    n >= minNights && (maxNights === undefined || n <= maxNights);\n  const blockedByNights = (d: Date) =>\n    choosingEnd &&\n    !!range &&\n    d > range.from &&\n    !nightsAllowed(daysBetween(range.from, d));\n\n  const weekStart = (d: Date) =>\n    addDays(d, -((d.getDay() - weekStartsOn + 7) % 7));\n\n  const select = (d: Date) => {\n    if (isDisabled(d) || blockedByNights(d)) return;\n    if (!inWindow(d)) setMonth(d);\n    setFocused(d);\n\n    if (isWeek) {\n      const from = weekStart(d);\n      const next: WeekRange = { from, to: addDays(from, 6) };\n      if (!valueControlled) setInternalValue(next);\n      (props as CalendarWeekProps).onValueChange?.(next);\n      return;\n    }\n\n    if (isMultiple) {\n      const max = (props as CalendarMultipleProps).max;\n      const next = isPicked(d)\n        ? picked.filter((p) => !sameDay(p, d))\n        : max !== undefined && picked.length >= max\n          ? null\n          : [...picked, d].sort((a, b) => a.getTime() - b.getTime());\n      if (!next) return;\n      if (!valueControlled) setInternalValue(next);\n      (props as CalendarMultipleProps).onValueChange?.(next);\n      return;\n    }\n    if (!isRange) {\n      if (!valueControlled) setInternalValue(d);\n      (props as CalendarSingleProps).onValueChange?.(d);\n      return;\n    }\n    // First click starts a range; a later day closes it; an earlier day, the\n    // start again when it would be too short, or a click on a finished range\n    // starts over.\n    const next: DateRange =\n      range &&\n      !range.to &&\n      d >= range.from &&\n      nightsAllowed(daysBetween(range.from, d))\n        ? { from: range.from, to: d }\n        : { from: d };\n    if (!valueControlled) setInternalValue(next);\n    (props as CalendarRangeProps).onValueChange?.(next);\n  };\n\n  const onGridKeyDown = (e: KeyboardEvent) => {\n    const base = focusInMonth;\n    let next: Date | null = null;\n    switch (e.key) {\n      case \"ArrowLeft\":\n        next = addDays(base, -1);\n        break;\n      case \"ArrowRight\":\n        next = addDays(base, 1);\n        break;\n      case \"ArrowUp\":\n        next = addDays(base, -7);\n        break;\n      case \"ArrowDown\":\n        next = addDays(base, 7);\n        break;\n      case \"Home\":\n        next = addDays(base, -((base.getDay() - weekStartsOn + 7) % 7));\n        break;\n      case \"End\":\n        next = addDays(base, 6 - ((base.getDay() - weekStartsOn + 7) % 7));\n        break;\n      case \"PageUp\":\n        next = addMonths(base, e.shiftKey ? -12 : -1);\n        break;\n      case \"PageDown\":\n        next = addMonths(base, e.shiftKey ? 12 : 1);\n        break;\n      default:\n        return;\n    }\n    e.preventDefault();\n    shouldFocus.current = true;\n    setFocused(next);\n    // Scroll the window only when focus leaves it, by as little as needed.\n    if (!inWindow(next))\n      setMonth(next < month ? next : addMonths(startOfMonth(next), 1 - count));\n  };\n\n  // ── labels ──\n  const monthFormat = useMemo(\n    () => new Intl.DateTimeFormat(locale, { month: \"long\", year: \"numeric\" }),\n    [locale],\n  );\n  const weekdays = useMemo(() => {\n    const short = new Intl.DateTimeFormat(locale, { weekday: \"short\" });\n    const long = new Intl.DateTimeFormat(locale, { weekday: \"long\" });\n    // 2023-01-01 was a Sunday.\n    return Array.from({ length: 7 }, (_, i) => {\n      const d = new Date(2023, 0, 1 + ((i + weekStartsOn) % 7));\n      return { short: short.format(d).slice(0, 2), long: long.format(d) };\n    });\n  }, [locale, weekStartsOn]);\n  const dayLabel = useMemo(\n    () =>\n      new Intl.DateTimeFormat(locale, {\n        weekday: \"long\",\n        day: \"numeric\",\n        month: \"long\",\n        year: \"numeric\",\n      }),\n    [locale],\n  );\n\n  const prevDisabled =\n    !!minDate && startOfMonth(minDate) >= month;\n  const nextDisabled =\n    !!maxDate && startOfMonth(maxDate) <= lastMonth;\n\n  // Range band end: the picked end, or the hovered day while choosing one.\n  // A day that can't close the range doesn't stretch the band to it.\n  const bandEnd =\n    range &&\n    !range.to &&\n    hovered &&\n    hovered > range.from &&\n    !isDisabled(hovered) &&\n    !blockedByNights(hovered)\n      ? hovered\n      : range?.to;\n  // Week mode: the row being previewed (pointer or keyboard focus).\n  const previewWeek = isWeek && hovered ? weekStart(hovered) : null;\n\n  const navButton =\n    \"inline-flex size-8 items-center justify-center rounded-lg text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-40\";\n\n  const months = Array.from({ length: count }, (_, i) => addMonths(month, i));\n  // Weekday index of the column, so connecting bands stop at the row ends.\n  const column = (d: Date) => (d.getDay() - weekStartsOn + 7) % 7;\n  const cellSize = tall ? \"h-12 w-10\" : \"size-9\";\n\n  return (\n    <div\n      className={cn(\n        \"w-fit rounded-2xl border border-border bg-card p-3 text-foreground\",\n        className,\n      )}\n    >\n      <div\n        ref={gridRef}\n        onPointerLeave={() => setHovered(null)}\n        className=\"flex flex-col gap-x-6 gap-y-4 sm:flex-row\"\n      >\n        {months.map((m, i) => {\n          const mk = monthKey(m);\n          const weeks = buildWeeks(m, weekStartsOn);\n          const labelId = `${uid}-label-${i}`;\n          return (\n            <div\n              // biome-ignore lint/suspicious/noArrayIndexKey: columns are positional; each keeps its own month transition.\n              key={i}\n              className=\"min-w-0\"\n            >\n              <div className=\"mb-2 flex items-center justify-between gap-2 px-1\">\n                {i === 0 ? (\n                  <button\n                    type=\"button\"\n                    aria-label=\"Previous month\"\n                    disabled={prevDisabled}\n                    onClick={() => setMonth(addMonths(month, -1))}\n                    className={navButton}\n                  >\n                    <ChevronLeft className=\"h-4 w-4\" />\n                  </button>\n                ) : (\n                  <span aria-hidden className=\"size-8\" />\n                )}\n                <h2\n                  id={labelId}\n                  aria-live={i === 0 ? \"polite\" : undefined}\n                  className=\"text-sm font-medium tabular-nums\"\n                >\n                  {monthFormat.format(m)}\n                </h2>\n                {i === count - 1 ? (\n                  <button\n                    type=\"button\"\n                    aria-label=\"Next month\"\n                    disabled={nextDisabled}\n                    onClick={() => setMonth(addMonths(month, 1))}\n                    className={navButton}\n                  >\n                    <ChevronRight className=\"h-4 w-4\" />\n                  </button>\n                ) : (\n                  <span aria-hidden className=\"size-8\" />\n                )}\n              </div>\n\n              <div className=\"relative overflow-hidden\">\n                <AnimatePresence\n                  initial={false}\n                  mode=\"popLayout\"\n                  custom={direction}\n                >\n                  <motion.table\n                    key={mk}\n                    data-month={mk}\n                    custom={direction}\n                    aria-labelledby={ariaLabel ? undefined : labelId}\n                    aria-label={ariaLabel ? `${ariaLabel}, ${monthFormat.format(m)}` : undefined}\n                    onKeyDown={onGridKeyDown}\n                    variants={{\n                      enter: (dir: number) => ({\n                        opacity: 0,\n                        x: reduce ? 0 : dir * 28,\n                        filter: reduce ? \"blur(0px)\" : \"blur(4px)\",\n                      }),\n                      center: {\n                        opacity: 1,\n                        x: 0,\n                        filter: \"blur(0px)\",\n                        transition: MONTH_ENTER,\n                      },\n                      exit: (dir: number) => ({\n                        opacity: 0,\n                        x: reduce ? 0 : dir * -28,\n                        filter: reduce ? \"blur(0px)\" : \"blur(4px)\",\n                        transition: MONTH_EXIT,\n                      }),\n                    }}\n                    initial=\"enter\"\n                    animate=\"center\"\n                    exit=\"exit\"\n                    className=\"border-collapse\"\n                  >\n                    <thead>\n                      <tr>\n                        {showWeekNumber && (\n                          <th\n                            scope=\"col\"\n                            abbr=\"Week\"\n                            className=\"h-8 w-8 text-[11px] font-medium text-muted-foreground/70\"\n                          >\n                            Wk\n                          </th>\n                        )}\n                        {weekdays.map((w) => (\n                          <th\n                            key={w.long}\n                            scope=\"col\"\n                            abbr={w.long}\n                            className={cn(\n                              \"h-8 text-[11px] font-medium text-muted-foreground\",\n                              tall ? \"w-10\" : \"w-9\",\n                            )}\n                          >\n                            {w.short}\n                          </th>\n                        ))}\n                      </tr>\n                    </thead>\n                    <tbody>\n                      {weeks.map((row) => {\n                        // Days this row actually draws: side-by-side months\n                        // leave the other month's days blank.\n                        const shown =\n                          count > 1 ? row.filter((d) => sameMonth(d, m)) : row;\n                        const weekSelected =\n                          !!week && sameDay(row[0], weekStart(week.from));\n                        const weekPreview =\n                          !weekSelected && sameDay(row[0], previewWeek);\n                        // ISO weeks run Monday–Sunday; the row's Thursday\n                        // decides which one a differently started row is.\n                        const thursday =\n                          row.find((d) => d.getDay() === 4) ?? row[0];\n                        return (\n                          <tr key={dayKey(row[0])}>\n                            {showWeekNumber && (\n                              <th\n                                scope=\"row\"\n                                className={cn(\n                                  \"p-0 text-center text-[11px] font-normal tabular-nums transition-colors\",\n                                  weekSelected\n                                    ? \"font-medium text-foreground\"\n                                    : \"text-muted-foreground/70\",\n                                )}\n                              >\n                                {shown.length > 0 ? isoWeek(thursday) : null}\n                              </th>\n                            )}\n                            {row.map((d) => {\n                              const outside = !sameMonth(d, m);\n                              // Side-by-side months would show these days twice.\n                              if (outside && count > 1)\n                                return (\n                                  <td key={dayKey(d)} className=\"p-0\">\n                                    <span className={cn(\"block\", cellSize)} />\n                                  </td>\n                                );\n                              const meta = getDayMeta?.(d) ?? null;\n                              const disabled = isDisabled(d);\n                              const nightsBlocked =\n                                !disabled && blockedByNights(d);\n                              const isToday = sameDay(d, today);\n                              const isFrom = sameDay(d, range?.from);\n                              const isTo = sameDay(d, bandEnd);\n                              const inBand =\n                                !!range?.from &&\n                                !!bandEnd &&\n                                d > range.from &&\n                                d < bandEnd;\n                              const chosen = isMultiple && isPicked(d);\n                              const inWeek =\n                                !!week &&\n                                d >= startOfDay(week.from) &&\n                                d <= startOfDay(week.to);\n                              const selected = isRange\n                                ? isFrom || (isTo && !!range?.to)\n                                : isWeek\n                                  ? inWeek\n                                  : isMultiple\n                                    ? chosen\n                                    : sameDay(d, single);\n                              const endpoint = isFrom || isTo;\n                              // Picked neighbours in the same row merge into one\n                              // pill, so a run of days reads as a block.\n                              const joinPrev =\n                                chosen &&\n                                column(d) > 0 &&\n                                sameMonth(addDays(d, -1), m) &&\n                                isPicked(addDays(d, -1));\n                              const joinNext =\n                                chosen &&\n                                column(d) < 6 &&\n                                sameMonth(addDays(d, 1), m) &&\n                                isPicked(addDays(d, 1));\n                              // The week pill lives in the row's first drawn\n                              // cell and spans every drawn day after it.\n                              const weekPill =\n                                isWeek &&\n                                (weekSelected || weekPreview) &&\n                                sameDay(d, shown[0]);\n\n                              return (\n                                <td key={dayKey(d)} className=\"relative p-0\">\n                                  {(inBand ||\n                                    (endpoint &&\n                                      bandEnd &&\n                                      !sameDay(range?.from, bandEnd))) && (\n                                    <span\n                                      aria-hidden\n                                      className={cn(\n                                        \"absolute inset-y-0.5 bg-primary/10\",\n                                        inBand && \"inset-x-0\",\n                                        isFrom && \"left-1/2 right-0\",\n                                        isTo && \"left-0 right-1/2\",\n                                      )}\n                                    />\n                                  )}\n                                  {weekPill && (\n                                    <motion.span\n                                      aria-hidden\n                                      // Selected and previewed rows each glide\n                                      // between weeks, scoped per month.\n                                      layoutId={`${uid}-${mk}-${weekSelected ? \"week\" : \"week-preview\"}`}\n                                      transition={\n                                        reduce ? { duration: 0 } : SPRING_LAYOUT\n                                      }\n                                      style={{ width: `${shown.length * 100}%` }}\n                                      className={cn(\n                                        \"pointer-events-none absolute inset-y-0 left-0 rounded-lg\",\n                                        weekSelected ? \"bg-primary\" : \"bg-muted\",\n                                      )}\n                                    />\n                                  )}\n                                  <button\n                                    type=\"button\"\n                                    data-date={dayKey(d)}\n                                    tabIndex={\n                                      sameDay(d, focusInMonth) && !outside\n                                        ? 0\n                                        : -1\n                                    }\n                                    aria-label={\n                                      meta?.label\n                                        ? `${dayLabel.format(d)}, ${meta.label}`\n                                        : dayLabel.format(d)\n                                    }\n                                    aria-pressed={selected}\n                                    aria-disabled={\n                                      disabled || nightsBlocked || undefined\n                                    }\n                                    aria-current={isToday ? \"date\" : undefined}\n                                    title={\n                                      nightsBlocked\n                                        ? daysBetween(range?.from ?? d, d) <\n                                          minNights\n                                          ? `Minimum ${minNights} nights`\n                                          : `Maximum ${maxNights} nights`\n                                        : undefined\n                                    }\n                                    onClick={() => select(d)}\n                                    onFocus={() => {\n                                      setFocused(d);\n                                      if (isWeek) setHovered(d);\n                                    }}\n                                    onBlur={() => isWeek && setHovered(null)}\n                                    onPointerEnter={() =>\n                                      (isRange || isWeek) && setHovered(d)\n                                    }\n                                    className={cn(\n                                      \"relative isolate flex items-center justify-center rounded-lg text-sm tabular-nums outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring\",\n                                      cellSize,\n                                      tall && \"flex-col gap-0.5\",\n                                      outside\n                                        ? \"text-muted-foreground/50\"\n                                        : \"text-foreground\",\n                                      !selected &&\n                                        !disabled &&\n                                        !nightsBlocked &&\n                                        !isWeek &&\n                                        \"hover:bg-muted\",\n                                      selected && \"text-primary-foreground\",\n                                      selected &&\n                                        outside &&\n                                        \"text-primary-foreground/60\",\n                                      isTo && !range?.to && \"text-foreground\",\n                                      nightsBlocked &&\n                                        \"cursor-not-allowed text-muted-foreground/40\",\n                                      disabled &&\n                                        \"cursor-not-allowed text-muted-foreground/40 line-through\",\n                                    )}\n                                  >\n                                    {selected &&\n                                      !isWeek &&\n                                      (isRange || isMultiple ? (\n                                        <motion.span\n                                          aria-hidden\n                                          initial={\n                                            reduce ? false : { scale: 0.7 }\n                                          }\n                                          animate={{ scale: 1 }}\n                                          transition={SPRING_PRESS}\n                                          className={cn(\n                                            \"absolute inset-0 -z-10 rounded-lg bg-primary\",\n                                            joinPrev && \"rounded-l-none\",\n                                            joinNext && \"rounded-r-none\",\n                                          )}\n                                        />\n                                      ) : (\n                                        <motion.span\n                                          aria-hidden\n                                          // Scoped per month so the pill glides\n                                          // between days but never across the\n                                          // sliding grids.\n                                          layoutId={`${uid}-${mk}-selected`}\n                                          transition={\n                                            reduce\n                                              ? { duration: 0 }\n                                              : SPRING_LAYOUT\n                                          }\n                                          className=\"absolute inset-0 -z-10 rounded-lg bg-primary\"\n                                        />\n                                      ))}\n                                    {isTo && !range?.to && (\n                                      <span\n                                        aria-hidden\n                                        className=\"absolute inset-0 -z-10 rounded-lg border border-primary/40\"\n                                      />\n                                    )}\n                                    {tall ? (\n                                      <span className=\"leading-none\">\n                                        {d.getDate()}\n                                      </span>\n                                    ) : (\n                                      d.getDate()\n                                    )}\n                                    {tall && (\n                                      <span\n                                        aria-hidden\n                                        className={cn(\n                                          \"h-2.5 text-[10px] leading-none\",\n                                          meta?.tone === \"accent\"\n                                            ? // Tinted toward the foreground so\n                                              // the green keeps contrast on\n                                              // light and dark cards.\n                                              \"font-medium text-[color:color-mix(in_oklab,var(--chart-3)_70%,var(--foreground))]\"\n                                            : meta?.tone === \"muted\"\n                                              ? \"text-muted-foreground/60\"\n                                              : \"text-muted-foreground\",\n                                          selected &&\n                                            \"text-primary-foreground/75\",\n                                          (disabled || nightsBlocked) &&\n                                            \"text-muted-foreground/40\",\n                                        )}\n                                      >\n                                        {meta?.label}\n                                      </span>\n                                    )}\n                                    {isToday && (\n                                      <span\n                                        aria-hidden\n                                        className={cn(\n                                          \"absolute size-1 rounded-full\",\n                                          tall ? \"top-1.5 right-1.5\" : \"bottom-1\",\n                                          selected\n                                            ? \"bg-primary-foreground\"\n                                            : \"bg-primary\",\n                                        )}\n                                      />\n                                    )}\n                                  </button>\n                                </td>\n                              );\n                            })}\n                          </tr>\n                        );\n                      })}\n                    </tbody>\n                  </motion.table>\n                </AnimatePresence>\n              </div>\n            </div>\n          );\n        })}\n      </div>\n    </div>\n  );\n}\n"},{"path":"lib/ease.ts","type":"registry:lib","target":"@lib/ease.ts","content":"// Shared motion tokens. Easing curves mirror the CSS custom properties in\n// globals.css; springs are the canonical physics used across components.\n// Strong custom variants — defaults like `ease-in`/`ease-out` feel weak.\n\nexport const EASE_OUT = [0.16, 1, 0.3, 1] as const;\nexport const EASE_IN_OUT = [0.77, 0, 0.175, 1] as const;\nexport const EASE_DRAWER = [0.32, 0.72, 0, 1] as const;\n\n/** CSS string form of EASE_OUT for inline style transitions. */\nexport const EASE_OUT_CSS = \"cubic-bezier(0.16, 1, 0.3, 1)\";\n\n/** Press feedback on buttons and other tappable surfaces. */\nexport const SPRING_PRESS = {\n  type: \"spring\",\n  stiffness: 500,\n  damping: 30,\n  mass: 0.6,\n} as const;\n\n/** Content swaps — label/icon slots trading places inside a control. */\nexport const SPRING_SWAP = {\n  type: \"spring\",\n  stiffness: 460,\n  damping: 30,\n  mass: 0.55,\n} as const;\n\n/** Overlay panel entrances — modals and sheets summoned by pointer. */\nexport const SPRING_PANEL = {\n  type: \"spring\",\n  stiffness: 420,\n  damping: 40,\n  mass: 0.5,\n} as const;\n\n/** Shared-layout glides — pills, indicators and panels morphing between positions. */\nexport const SPRING_LAYOUT = {\n  type: \"spring\",\n  stiffness: 360,\n  damping: 32,\n  mass: 0.6,\n} as const;\n\n/** Cursor-follow physics for decorative mouse tracking (magnetic, tilt, dock). */\nexport const SPRING_MOUSE = {\n  stiffness: 200,\n  damping: 15,\n  mass: 0.3,\n} as const;\n\n/** Dragged handles and fills (sliders) — critically damped `useSpring` config,\n * so the value follows the pointer butterily and never rebounds off an end. */\nexport const SPRING_GLIDE = {\n  stiffness: 700,\n  damping: 50,\n  mass: 0.5,\n} as const;\n"},{"path":"lib/utils.ts","type":"registry:lib","target":"@lib/utils.ts","content":"import { clsx, type ClassValue } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs))\n}\n"},{"path":"components/motion/button/base.tsx","type":"registry:component","target":"@components/motion/button/base.tsx","content":"\"use client\";\n\nimport {\n  AnimatePresence,\n  type HTMLMotionProps,\n  motion,\n  useReducedMotion,\n} from \"motion/react\";\nimport {\n  forwardRef,\n  type PointerEvent,\n  type ReactNode,\n  useCallback,\n  useRef,\n  useState,\n} from \"react\";\nimport { EASE_OUT, SPRING_PRESS } from \"@/lib/ease\";\nimport { useHoverCapable } from \"@/lib/hooks/use-hover-capable\";\nimport { TOUCH_TARGET_CLASS } from \"@/lib/touch\";\nimport { cn } from \"@/lib/utils\";\n\nexport type ButtonVariant = \"primary\" | \"secondary\" | \"ghost\" | \"outline\";\nexport type ButtonSize = \"sm\" | \"md\" | \"lg\" | \"icon\";\n\nexport interface ButtonProps extends Omit<\n  HTMLMotionProps<\"button\">,\n  \"children\"\n> {\n  variant?: ButtonVariant;\n  size?: ButtonSize;\n  pressScale?: number;\n  /** Spawn a Material-style ripple from the press point. Off by default. */\n  ripple?: boolean;\n  children?: ReactNode;\n}\n\nexport interface ButtonLinkProps extends Omit<\n  HTMLMotionProps<\"a\">,\n  \"children\"\n> {\n  variant?: ButtonVariant;\n  size?: ButtonSize;\n  pressScale?: number;\n  children?: ReactNode;\n}\n\ntype Ripple = { id: number; x: number; y: number; size: number };\n\nconst VARIANT_CLASS: Record<ButtonVariant, string> = {\n  primary: \"bg-primary text-primary-foreground hover:bg-primary/90\",\n  secondary: \"border border-border bg-card text-foreground hover:border-border\",\n  ghost: \"text-muted-foreground hover:text-foreground hover:bg-primary/5\",\n  outline:\n    \"border border-border bg-transparent text-foreground hover:bg-primary/5\",\n};\n\nconst SIZE_CLASS: Record<ButtonSize, string> = {\n  sm: \"h-8 px-3 text-xs gap-1.5 rounded-full\",\n  md: \"h-10 px-5 text-sm gap-2 rounded-full\",\n  lg: \"h-12 px-6 text-base gap-2 rounded-full\",\n  icon: \"h-8 w-8 rounded-lg\",\n};\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n  function Button(\n    {\n      variant = \"primary\",\n      size = \"md\",\n      pressScale = 0.93,\n      ripple = false,\n      className,\n      children,\n      onPointerDown,\n      ...rest\n    },\n    ref,\n  ) {\n    const reduce = useReducedMotion();\n    const canHover = useHoverCapable();\n    const [ripples, setRipples] = useState<Ripple[]>([]);\n    const nextId = useRef(0);\n\n    const handlePointerDown = useCallback(\n      (event: PointerEvent<HTMLButtonElement>) => {\n        if (ripple && !reduce) {\n          const rect = event.currentTarget.getBoundingClientRect();\n          const size = Math.max(rect.width, rect.height) * 2;\n          const id = nextId.current++;\n          setRipples((prev) => [\n            ...prev,\n            {\n              id,\n              x: event.clientX - rect.left,\n              y: event.clientY - rect.top,\n              size,\n            },\n          ]);\n        }\n        onPointerDown?.(event);\n      },\n      [ripple, reduce, onPointerDown],\n    );\n\n    return (\n      <motion.button\n        ref={ref}\n        type=\"button\"\n        whileTap={reduce ? undefined : { scale: pressScale }}\n        whileHover={reduce || !canHover ? undefined : { scale: 1.02 }}\n        transition={SPRING_PRESS}\n        onPointerDown={handlePointerDown}\n        className={cn(\n          \"relative inline-flex items-center justify-center font-medium select-none\",\n          \"transition-colors\",\n          \"disabled:pointer-events-none disabled:opacity-50\",\n          // The ripple layer clips itself, so on a touch screen the button can\n          // stop clipping and let its enlarged hit area overhang.\n          ripple && \"overflow-hidden pointer-coarse:overflow-visible\",\n          TOUCH_TARGET_CLASS,\n          VARIANT_CLASS[variant],\n          SIZE_CLASS[size],\n          className,\n        )}\n        {...rest}\n      >\n        {ripple && !reduce ? (\n          <span className=\"pointer-events-none absolute inset-0 overflow-hidden rounded-[inherit]\">\n            <AnimatePresence>\n              {ripples.map((r) => (\n                <motion.span\n                  key={r.id}\n                  className=\"absolute rounded-full bg-current\"\n                  style={{\n                    left: r.x,\n                    top: r.y,\n                    width: r.size,\n                    height: r.size,\n                    x: \"-50%\",\n                    y: \"-50%\",\n                  }}\n                  initial={{ scale: 0.05, opacity: 0.3 }}\n                  animate={{ scale: 1, opacity: 0 }}\n                  exit={{ opacity: 0 }}\n                  transition={{ duration: 1.6, ease: EASE_OUT }}\n                  onAnimationComplete={() =>\n                    setRipples((prev) => prev.filter((x) => x.id !== r.id))\n                  }\n                />\n              ))}\n            </AnimatePresence>\n          </span>\n        ) : null}\n        {children}\n      </motion.button>\n    );\n  },\n);\n\nexport const ButtonLink = forwardRef<HTMLAnchorElement, ButtonLinkProps>(\n  function ButtonLink(\n    {\n      variant = \"primary\",\n      size = \"md\",\n      pressScale = 0.93,\n      className,\n      children,\n      ...rest\n    },\n    ref,\n  ) {\n    const reduce = useReducedMotion();\n    const canHover = useHoverCapable();\n\n    return (\n      <motion.a\n        ref={ref}\n        whileTap={reduce ? undefined : { scale: pressScale }}\n        whileHover={reduce || !canHover ? undefined : { scale: 1.02 }}\n        transition={SPRING_PRESS}\n        className={cn(\n          \"relative inline-flex items-center justify-center font-medium select-none\",\n          \"transition-colors\",\n          TOUCH_TARGET_CLASS,\n          VARIANT_CLASS[variant],\n          SIZE_CLASS[size],\n          className,\n        )}\n        {...rest}\n      >\n        {children}\n      </motion.a>\n    );\n  },\n);\n"},{"path":"components/motion/button/magnetic.tsx","type":"registry:component","target":"@components/motion/button/magnetic.tsx","content":"\"use client\";\n\nimport { forwardRef } from \"react\";\nimport { Magnetic } from \"../magnetic\";\nimport { Button, type ButtonProps } from \"./base\";\n\nexport interface MagneticButtonProps extends ButtonProps {\n  /** Magnetic pull strength. Default 0.25. */\n  strength?: number;\n  /** Class applied to the magnetic wrapper. */\n  magneticClassName?: string;\n}\n\nexport const MagneticButton = forwardRef<HTMLButtonElement, MagneticButtonProps>(function MagneticButton(\n  { strength = 0.25, magneticClassName, children, ...rest },\n  ref,\n) {\n  return (\n    <Magnetic strength={strength} className={magneticClassName}>\n      <Button ref={ref} {...rest}>\n        {children}\n      </Button>\n    </Magnetic>\n  );\n});\n"},{"path":"components/motion/button/stateful.tsx","type":"registry:component","target":"@components/motion/button/stateful.tsx","content":"\"use client\";\n\nimport { Check, Loader2, X } from \"lucide-react\";\nimport {\n  AnimatePresence,\n  motion,\n  useReducedMotion,\n  type Variants,\n} from \"motion/react\";\nimport {\n  forwardRef,\n  type ReactNode,\n  useLayoutEffect,\n  useRef,\n  useState,\n} from \"react\";\nimport { EASE_OUT, SPRING_SWAP } from \"@/lib/ease\";\nimport { Button, type ButtonProps } from \"./base\";\n\nexport type ButtonState = \"idle\" | \"loading\" | \"success\" | \"error\";\n\nexport interface StatefulButtonProps extends Omit<ButtonProps, \"children\"> {\n  state?: ButtonState;\n  children: ReactNode;\n  loadingText?: ReactNode;\n  successText?: ReactNode;\n  errorText?: ReactNode;\n  icon?: ReactNode;\n}\n\nconst CASCADE_STAGGER = 0.025;\nconst ROLL_BLUR = \"blur(6px)\";\n\nconst CASCADE_LETTER_VARIANTS: Variants = {\n  initial: { opacity: 0, y: \"105%\", filter: ROLL_BLUR },\n  animate: (delay: number = 0) => ({\n    opacity: 1,\n    y: \"0%\",\n    filter: \"blur(0px)\",\n    transition: { ...SPRING_SWAP, delay },\n  }),\n  exit: (delay: number = 0) => ({\n    opacity: 0,\n    y: \"-105%\",\n    filter: ROLL_BLUR,\n    transition: { duration: 0.16, ease: EASE_OUT, delay: delay * 0.5 },\n  }),\n};\n\nconst ICON_VARIANTS: Variants = {\n  // Width collapses too, so the icon adds/removes its own space smoothly\n  // instead of popping the row width in a single frame.\n  initial: { opacity: 0, width: 0, scale: 0.7, filter: ROLL_BLUR },\n  animate: {\n    opacity: 1,\n    width: \"1.5rem\",\n    scale: 1,\n    filter: \"blur(0px)\",\n    transition: SPRING_SWAP,\n  },\n  exit: {\n    opacity: 0,\n    width: 0,\n    scale: 0.7,\n    filter: ROLL_BLUR,\n    transition: { duration: 0.16, ease: EASE_OUT },\n  },\n};\n\nfunction IconSlot({ keyId, children }: { keyId: string; children: ReactNode }) {\n  const reduce = useReducedMotion();\n  return (\n    <motion.span\n      key={keyId}\n      variants={ICON_VARIANTS}\n      initial={reduce ? { opacity: 0 } : \"initial\"}\n      animate={reduce ? { opacity: 1 } : \"animate\"}\n      exit={reduce ? { opacity: 0 } : \"exit\"}\n      transition={reduce ? { duration: 0.15 } : undefined}\n      className=\"inline-grid shrink-0 place-items-center overflow-hidden\"\n    >\n      {children}\n    </motion.span>\n  );\n}\n\nfunction TextSlot({\n  value,\n  children,\n}: {\n  value: string;\n  children: ReactNode;\n}) {\n  const reduce = useReducedMotion();\n  const measureRef = useRef<HTMLSpanElement>(null);\n  const [width, setWidth] = useState<number>();\n  const label = typeof children === \"string\" ? children : null;\n  const cascade = label !== null && !reduce;\n\n  // Measure strings with the same per-letter layout as the cascade. Measuring\n  // the whole string preserves kerning, which can make it narrower than the\n  // inline-block letters and clip the final glyph during the width animation.\n  useLayoutEffect(() => {\n    const nextWidth = measureRef.current?.offsetWidth;\n    if (!nextWidth) return;\n    setWidth((current) => (current === nextWidth ? current : nextWidth));\n  });\n\n  return (\n    <motion.span\n      initial={false}\n      animate={{ width }}\n      transition={reduce ? { duration: 0 } : SPRING_SWAP}\n      className=\"relative inline-block overflow-hidden whitespace-nowrap align-bottom\"\n    >\n      <span\n        ref={measureRef}\n        aria-hidden\n        className=\"invisible inline-block whitespace-nowrap\"\n      >\n        {cascade\n          ? label.split(\"\").map((char, index) => (\n              <span\n                // biome-ignore lint/suspicious/noArrayIndexKey: position is the slot identity.\n                key={index}\n                className=\"inline-block whitespace-pre\"\n              >\n                {char}\n              </span>\n            ))\n          : children}\n      </span>\n\n      {cascade ? (\n        <>\n          <span className=\"sr-only\">{label}</span>\n          <AnimatePresence initial={false}>\n            <motion.span\n              key={`cascade-${value}`}\n              aria-hidden\n              initial=\"initial\"\n              animate=\"animate\"\n              exit=\"exit\"\n              className=\"absolute left-0 top-0 inline-block whitespace-pre\"\n            >\n              {label.split(\"\").map((char, index) => (\n                <motion.span\n                  // biome-ignore lint/suspicious/noArrayIndexKey: position is the slot identity.\n                  key={index}\n                  custom={index * CASCADE_STAGGER}\n                  variants={CASCADE_LETTER_VARIANTS}\n                  className=\"inline-block whitespace-pre will-change-[opacity,filter,transform]\"\n                >\n                  {char}\n                </motion.span>\n              ))}\n            </motion.span>\n          </AnimatePresence>\n        </>\n      ) : (\n        <AnimatePresence initial={false}>\n          <motion.span\n            key={`text-${value}`}\n            initial={reduce ? { opacity: 0 } : { opacity: 0, y: 14, filter: ROLL_BLUR }}\n            animate={reduce ? { opacity: 1 } : { opacity: 1, y: 0, filter: \"blur(0px)\" }}\n            exit={reduce ? { opacity: 0 } : { opacity: 0, y: -14, filter: ROLL_BLUR }}\n            transition={reduce ? { duration: 0.15 } : SPRING_SWAP}\n            className=\"absolute left-0 top-0 inline-block will-change-[opacity,filter,transform]\"\n          >\n            {children}\n          </motion.span>\n        </AnimatePresence>\n      )}\n    </motion.span>\n  );\n}\n\nexport const StatefulButton = forwardRef<HTMLButtonElement, StatefulButtonProps>(function StatefulButton(\n  {\n    state = \"idle\",\n    children,\n    loadingText = \"Loading\",\n    successText = \"Done\",\n    errorText = \"Try again\",\n    icon,\n    disabled,\n    ...rest\n  },\n  ref,\n) {\n  const isBusy = state === \"loading\";\n  const stateText =\n    state === \"loading\"\n      ? loadingText\n      : state === \"success\"\n        ? successText\n        : state === \"error\"\n        ? errorText\n        : children;\n  const textKey =\n    typeof stateText === \"string\" ? `${state}-${stateText}` : state;\n\n  return (\n    <Button ref={ref} disabled={disabled || isBusy} aria-busy={isBusy} whileHover={undefined} {...rest}>\n      <span\n        aria-live=\"polite\"\n        className=\"relative inline-flex items-center justify-center overflow-hidden\"\n      >\n        <AnimatePresence initial={false}>\n          {state === \"loading\" ? (\n            <IconSlot keyId=\"loading-icon\">\n              <Loader2 className=\"h-4 w-4 animate-spin\" />\n            </IconSlot>\n          ) : null}\n          {state === \"success\" ? (\n            <IconSlot keyId=\"success-icon\">\n              <Check className=\"h-4 w-4\" />\n            </IconSlot>\n          ) : null}\n          {state === \"error\" ? (\n            <IconSlot keyId=\"error-icon\">\n              <X className=\"h-4 w-4\" />\n            </IconSlot>\n          ) : null}\n        </AnimatePresence>\n\n        <TextSlot value={textKey}>{stateText}</TextSlot>\n\n        <AnimatePresence initial={false}>\n          {state === \"idle\" && icon ? (\n            <IconSlot keyId=\"idle-icon\">{icon}</IconSlot>\n          ) : null}\n        </AnimatePresence>\n      </span>\n    </Button>\n  );\n});\n"},{"path":"lib/hooks/use-hover-capable.ts","type":"registry:hook","target":"@lib/hooks/use-hover-capable.ts","content":"\"use client\";\n\nimport { useEffect, useState } from \"react\";\n\n/**\n * Returns true only on devices that have a true hover (mouse / trackpad).\n * Touch devices fire phantom `:hover` on tap that sticks until tap-elsewhere\n * — gate hover-only effects (scale lifts, magnetic pulls) behind this.\n */\nexport function useHoverCapable() {\n  const [canHover, setCanHover] = useState(false);\n\n  useEffect(() => {\n    if (typeof window === \"undefined\" || !window.matchMedia) return;\n    const mq = window.matchMedia(\"(hover: hover) and (pointer: fine)\");\n    const update = () => setCanHover(mq.matches);\n    update();\n    mq.addEventListener?.(\"change\", update);\n    return () => mq.removeEventListener?.(\"change\", update);\n  }, []);\n\n  return canHover;\n}\n"},{"path":"lib/touch.ts","type":"registry:lib","target":"@lib/touch.ts","content":"// Shared touch primitives. iOS and iPadOS run their own gestures on top of the\n// page — the long-press selection callout and the selection it drags in with\n// it — and they win: once the platform claims a touch it cancels ours\n// mid-gesture, so a press-and-hold or a drag simply dies. Surfaces that own\n// their gesture have to opt out.\n//\n// What the two classes below cover, precisely:\n// - `-webkit-touch-callout: none` stops iOS's long-press callout. WebKit-only:\n//   it is not a property other engines have, so it is inert everywhere else.\n// - `user-select: none` stops the long-press selection on every engine,\n//   Android included, and stops a drag from painting a selection under the\n//   cursor. It is inherited, so it reaches every descendant — which is why the\n//   two classes differ only in whether they apply it unconditionally.\n// What neither covers:\n// - Chrome for Android's long-press menu on a link or an image. No CSS\n//   suppresses it; a gesture surface that wraps one needs its own\n//   `onContextMenu` with `preventDefault()`.\n// - The native drag of an `<img>` or `<a>` descendant. `-webkit-user-drag` is\n//   not inherited and plain divs and buttons are not drag sources, so setting\n//   it on the surface does nothing — the child itself needs `draggable={false}`.\n\n/**\n * Classes for a surface that *is* the control: a thumb, a drum, a stage, a\n * handle, a hold button. Selection is suppressed on every input, because a\n * drag that highlights the control's own label is wrong on a mouse too.\n * Compose with `touch-none` when the surface also owns the scroll axis — leave\n * it off when the page must still scroll from there.\n */\nexport const TOUCH_GESTURE_CLASS = \"select-none [-webkit-touch-callout:none]\";\n\n/**\n * The same opt-out for a gesture surface that wraps content the consumer owns:\n * a scroller, a context-menu trigger, a sheet header, a list row. Selection is\n * suppressed only where the platform runs its own press gestures — a coarse\n * pointer — so a mouse user can still select and copy that content. If the\n * gesture itself would paint a selection under the cursor, add `select-none`\n * for the duration of the gesture rather than reaching for\n * `TOUCH_GESTURE_CLASS`.\n *\n * `pointer: coarse` describes the *primary* pointer and nothing else, so a\n * hybrid machine reads it wrong in both directions: a tablet with a mouse\n * plugged in keeps touch as primary and loses mouse selection, and a laptop\n * with a touchscreen keeps the mouse as primary and leaves selection live\n * under a finger. No media query can answer per interaction — the query is\n * about the device, and the question is about the gesture in progress. The\n * default stays here because it is right on the machines that are one thing or\n * the other, and losing a selection is a nuisance; where the miss costs a\n * *gesture* instead, the surface pairs it with `holdSelection` on the press.\n */\nexport const TOUCH_GESTURE_CONTENT_CLASS =\n  \"[-webkit-touch-callout:none] pointer-coarse:select-none\";\n\n/**\n * Grow a small control's *hit area* to at least 44×44px (WCAG 2.5.5, Apple\n * HIG) on a coarse pointer, without changing what it looks like or the space\n * it takes in layout. An invisible `::after` box, centered on the control and\n * `max(100%, 2.75rem)` on each axis, catches the taps: a 32px icon button\n * reaches 6px past each edge, a wide 40px button only grows vertically, and a\n * control already 44px or larger is left as it is. Hit-testing a pseudo\n * element lands on its owner, so handlers, focus and `:active` all behave.\n *\n * Mouse and trackpad rendering is untouched — nothing here applies outside\n * `pointer: coarse`. Requirements on the element it goes on:\n * - It must be the containing block: add `relative` (and keep it mergeable, so\n *   a consumer's `absolute` still wins through `cn`).\n * - It must not clip itself (`overflow-hidden`), or the overhang is clipped\n *   away along with its hit area.\n * - It must render children: `<input>` and other void elements have no\n *   `::after`. Put it on the wrapper or label instead.\n * - It must not already use `::after` for something visible.\n *\n * Centered 44px means two 32px buttons with a 4px gap overlap by 8px; the\n * later one wins that strip, which still ends well short of the earlier\n * button's visual center. Below a ~32px pitch the later neighbour starts\n * eating into that center — use `TOUCH_TARGET_Y_CLASS` for such dense rows.\n *\n * The overhang is real geometry: inside a scroll container it counts as\n * scrollable overflow, so a control flush against a scroller's edge can add a\n * few pixels of scroll on touch screens. Give such a scroller a little padding\n * on that side.\n */\nexport const TOUCH_TARGET_CLASS =\n  \"pointer-coarse:after:absolute pointer-coarse:after:top-1/2 pointer-coarse:after:left-1/2 pointer-coarse:after:size-[max(100%,2.75rem)] pointer-coarse:after:-translate-x-1/2 pointer-coarse:after:-translate-y-1/2 pointer-coarse:after:content-['']\";\n\n/**\n * `TOUCH_TARGET_CLASS` on the vertical axis only, for controls packed tighter\n * than ~32px apart in a row (pagination dots, dense swatches), where growing\n * sideways would hand most of each control to its neighbour. Same rules.\n */\nexport const TOUCH_TARGET_Y_CLASS =\n  \"pointer-coarse:after:absolute pointer-coarse:after:inset-x-0 pointer-coarse:after:top-1/2 pointer-coarse:after:h-[max(100%,2.75rem)] pointer-coarse:after:-translate-y-1/2 pointer-coarse:after:content-['']\";\n\n/**\n * Suppress selection on `element` for as long as a gesture is running on it,\n * whatever the primary pointer of the machine happens to be. Returns the\n * release. Inline, so it wins over the class above and is gone again the\n * moment the gesture ends.\n *\n * For the press gestures a native selection would otherwise steal — a\n * long-press that opens a menu. Elsewhere prefer the classes: a surface that\n * takes selection away for the whole session is a surface whose text nobody\n * can copy.\n */\nexport function holdSelection(element: HTMLElement) {\n  element.style.setProperty(\"user-select\", \"none\");\n  element.style.setProperty(\"-webkit-user-select\", \"none\");\n  return () => {\n    element.style.removeProperty(\"user-select\");\n    element.style.removeProperty(\"-webkit-user-select\");\n  };\n}\n\n/**\n * Pointer capture, best effort. WebKit throws `NotFoundError` when the pointer\n * is already gone by the time the handler runs — routine on iOS, where the\n * system can claim the touch first — and an uncaught throw takes the rest of\n * the handler, the gesture included, down with it. Touch pointers carry\n * implicit capture anyway, so losing it is never fatal.\n */\nexport function capturePointer(element: Element, pointerId: number) {\n  try {\n    element.setPointerCapture(pointerId);\n  } catch {\n    // Pointer is no longer active — implicit capture still applies on touch.\n  }\n}\n\n/** Release a capture taken with `capturePointer`, ignoring a stale pointer. */\nexport function releasePointer(element: Element, pointerId: number) {\n  try {\n    if (element.hasPointerCapture(pointerId)) {\n      element.releasePointerCapture(pointerId);\n    }\n  } catch {\n    // Capture was already dropped by the browser.\n  }\n}\n\n/**\n * Whether this event came from a pointer that is *hovering*: not a touch, and\n * not currently pressed. Which input the user is holding right now is not\n * something a device capability can answer — a touchscreen laptop hovers and\n * taps, and iPadOS reports a fine hovering pointer for a finger — so both\n * paths stay live and each handler branches on the event it was given.\n *\n * A pen resting on the glass is making contact, not hovering: `buttons` is the\n * tell, and it sends a pen tap down the same route a finger takes.\n *\n * This answers what an *enter* asks. A leave is the other half of a pair and\n * has to be read against the enter that started it — `useHoverGesture` in\n * `lib/hooks/use-hover-gesture` does that, and hover surfaces should use it\n * rather than asking this question twice.\n */\nexport const isHoveringPointer = (event: {\n  pointerType: string;\n  buttons: number;\n}) => event.pointerType !== \"touch\" && event.buttons === 0;\n"},{"path":"components/motion/magnetic.tsx","type":"registry:component","target":"@components/motion/magnetic.tsx","content":"\"use client\";\n\nimport { motion, useMotionValue, useReducedMotion, useSpring } from \"motion/react\";\nimport { useRef, type ReactNode } from \"react\";\nimport { SPRING_MOUSE } from \"@/lib/ease\";\nimport { useHoverCapable } from \"@/lib/hooks/use-hover-capable\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface MagneticProps {\n  children: ReactNode;\n  strength?: number;\n  className?: string;\n}\n\nexport function Magnetic({ children, strength = 0.35, className }: MagneticProps) {\n  const ref = useRef<HTMLDivElement>(null);\n  const reduce = useReducedMotion();\n  const canHover = useHoverCapable();\n  // Decorative cursor-follow: skip on touch (phantom hover) and reduced motion.\n  const enabled = !reduce && canHover;\n  const x = useMotionValue(0);\n  const y = useMotionValue(0);\n  const sx = useSpring(x, SPRING_MOUSE);\n  const sy = useSpring(y, SPRING_MOUSE);\n\n  const onMove = (e: React.MouseEvent<HTMLDivElement>) => {\n    const el = ref.current;\n    if (!el || !enabled) return;\n    const rect = el.getBoundingClientRect();\n    x.set((e.clientX - rect.left - rect.width / 2) * strength);\n    y.set((e.clientY - rect.top - rect.height / 2) * strength);\n  };\n\n  const onLeave = () => {\n    x.set(0);\n    y.set(0);\n  };\n\n  return (\n    <motion.div\n      ref={ref}\n      onMouseMove={onMove}\n      onMouseLeave={onLeave}\n      style={{ x: sx, y: sy }}\n      className={cn(\"inline-block\", className)}\n    >\n      {children}\n    </motion.div>\n  );\n}\n"}]}