{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "date-picker",
  "title": "Date Picker",
  "description": "Date picker and calendar with no date library: single, range (two months side by side) and multiple modes, presets, time inputs, min/max, disabled weekdays, booked days, ISO week numbers, month/year quick switch, typed dates parsed in the locale's order via Intl with the locale's first weekday, popover or inline, six field variants, tones, solid/soft/ring selection, day shapes, sizes and slide, fade or scale month animations with APG grid keyboard.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://goodui.dev/r/goodui-motion.json",
    "https://goodui.dev/r/locale.json"
  ],
  "files": [
    {
      "path": "registry/components/core/date-picker.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { createPortal } from \"react-dom\"\nimport { AnimatePresence, motion, useIsPresent, useReducedMotion, type Transition } from \"motion/react\"\nimport { cn } from \"@/lib/utils\"\nimport { useGooduiLocale, useLabels } from \"@/lib/goodui-locale\"\nimport { GooduiTokens, spring } from \"@/lib/goodui-motion\"\n\n/*\n * Date picker and calendar with no date library, independent layers:\n *   variant    outline, filled, ghost, underline, pill, neo (field and surface)   tone       accent for selection\n *   selection  solid, soft, ring (how picked days are painted)                    shape      circle, rounded, square\n *   size       sm, md, lg                                                          shadow     surface elevation\n *   animation  none, fade, slide, scale (popover open and month change)\n *   mode       single, range (two months side by side), multiple\n * Plus min/max, disabled weekdays and dates, booked days, ISO week numbers, presets, time, month/year quick switch,\n * a text field that parses typed dates in the locale's order (Intl), first day of week from the locale, popover or inline.\n * Keyboard follows the WAI-ARIA date picker dialog: arrows move by day/week, Home/End to week edges,\n * PageUp/PageDown by month (Shift: year), Enter/Space pick, Esc closes and returns focus.\n */\n\nexport type DatePickerVariant = \"outline\" | \"filled\" | \"ghost\" | \"underline\" | \"pill\" | \"neo\"\nexport type DatePickerTone = \"primary\" | \"neutral\" | \"success\" | \"warning\" | \"danger\" | \"info\"\nexport type DatePickerSize = \"sm\" | \"md\" | \"lg\"\nexport type DatePickerShadow = \"none\" | \"sm\" | \"md\" | \"lg\"\nexport type DatePickerAnimation = \"none\" | \"fade\" | \"slide\" | \"scale\"\nexport type DatePickerSelection = \"solid\" | \"soft\" | \"ring\"\nexport type DatePickerShape = \"circle\" | \"rounded\" | \"square\"\nexport type DateRange = { from: Date; to: Date | null }\nexport type DatePickerPreset = {\n  label: string\n  /** Gets today (local midnight) and returns a date (single) or a range. */\n  value: (today: Date) => Date | DateRange\n}\n\nexport type DatePickerLabels = {\n  dialog: string\n  openCalendar: string\n  prevMonth: string\n  nextMonth: string\n  prevYear: string\n  nextYear: string\n  prevYears: string\n  nextYears: string\n  chooseMonth: string\n  chooseYear: string\n  /** Week-number column heading (short) and its full name for screen readers. */\n  week: string\n  weekColumn: string\n  weekNumber: (n: number) => string\n  today: string\n  booked: string\n  unavailable: string\n  clear: string\n  done: string\n  time: string\n  startTime: string\n  endTime: string\n  presets: string\n  invalid: string\n  /** Text for several picked dates in the field. */\n  selectedCount: (n: number) => string\n  /** Placeholder letters for the typed format. */\n  formatDay: string\n  formatMonth: string\n  formatYear: string\n  presetToday: string\n  presetTomorrow: string\n  presetNextWeek: string\n  presetLast7: string\n  presetLast30: string\n  presetThisMonth: string\n  presetLastMonth: string\n  presetNext7: string\n}\nconst DEFAULT_LABELS: DatePickerLabels = {\n  dialog: \"Choose date\",\n  openCalendar: \"Open calendar\",\n  prevMonth: \"Previous month\",\n  nextMonth: \"Next month\",\n  prevYear: \"Previous year\",\n  nextYear: \"Next year\",\n  prevYears: \"Previous 12 years\",\n  nextYears: \"Next 12 years\",\n  chooseMonth: \"Choose month and year\",\n  chooseYear: \"Choose year\",\n  week: \"Wk\",\n  weekColumn: \"Week number\",\n  weekNumber: (n) => `Week ${n}`,\n  today: \"Today\",\n  booked: \"Booked\",\n  unavailable: \"Unavailable\",\n  clear: \"Clear\",\n  done: \"Done\",\n  time: \"Time\",\n  startTime: \"Start time\",\n  endTime: \"End time\",\n  presets: \"Presets\",\n  invalid: \"Not a valid date\",\n  selectedCount: (n) => (n === 1 ? \"1 date\" : `${n} dates`),\n  formatDay: \"DD\",\n  formatMonth: \"MM\",\n  formatYear: \"YYYY\",\n  presetToday: \"Today\",\n  presetTomorrow: \"Tomorrow\",\n  presetNextWeek: \"In a week\",\n  presetLast7: \"Last 7 days\",\n  presetLast30: \"Last 30 days\",\n  presetThisMonth: \"This month\",\n  presetLastMonth: \"Last month\",\n  presetNext7: \"Next 7 days\",\n}\n\ntype Base = Omit<React.ComponentProps<\"div\">, \"defaultValue\" | \"onChange\" | \"children\"> & {\n  /** BCP 47 locale for names, digits, the typed format and the first day of the week. Defaults to the GooduiLocaleProvider language, else en-US. */\n  locale?: string\n  /** 0 = Sunday … 6 = Saturday. Defaults to the locale's first day (Intl.Locale week info), else Monday (Sunday for en-US). */\n  weekStartsOn?: number\n  /** Earliest selectable day. */\n  min?: Date\n  /** Latest selectable day. */\n  max?: Date\n  /** Days that cannot be picked: a list of dates or a test function. */\n  disabledDays?: Date[] | ((date: Date) => boolean)\n  /** Weekdays that cannot be picked (0 = Sunday), e.g. [0, 6] for weekends. */\n  disabledWeekdays?: number[]\n  /** Days shown as booked (struck through) and not pickable. A range cannot span a booked or disabled day. */\n  booked?: Date[] | ((date: Date) => boolean)\n  /** ISO week numbers in a first column. */\n  weekNumbers?: boolean\n  /** Months shown side by side. Default: 2 for range on wide screens, else 1. */\n  months?: 1 | 2\n  /** true for the built-in presets of the mode, or your own list. */\n  presets?: boolean | DatePickerPreset[]\n  /** Adds time inputs (single: one, range: start and end). */\n  time?: boolean\n  /** Minute step of the time inputs. */\n  minuteStep?: number\n  /** Render the calendar on the page instead of a field with a popover. */\n  inline?: boolean\n  /** Field placeholder. Defaults to the locale's format, e.g. MM/DD/YYYY. */\n  placeholder?: string\n  /** Field style and surface: outline (default), filled, ghost, underline, pill or neo. */\n  variant?: DatePickerVariant\n  /** Accent for picked days, range band, today dot and focus. */\n  tone?: DatePickerTone\n  /** How picked days are painted: solid fill, soft tint or ring. */\n  selection?: DatePickerSelection\n  /** Day cell shape. */\n  shape?: DatePickerShape\n  size?: DatePickerSize\n  /** Surface shadow (popover and inline calendar). */\n  shadow?: DatePickerShadow\n  /** Popover open and month change: slide (default), fade, scale or none. Reduced motion: fade only. */\n  animation?: DatePickerAnimation\n  /** × button in the field. */\n  clearable?: boolean\n  /** Close the popover after a full pick (single day, or range end) when there is no time input. */\n  closeOnSelect?: boolean\n  disabled?: boolean\n  invalid?: boolean\n  /** Displayed month (controlled), any day in it. */\n  month?: Date\n  defaultMonth?: Date\n  onMonthChange?: (month: Date) => void\n  open?: boolean\n  defaultOpen?: boolean\n  onOpenChange?: (open: boolean) => void\n  /** Hidden input(s) with ISO dates (yyyy-mm-dd, or with time yyyy-mm-ddThh:mm) for form posts. */\n  name?: string\n  /** Names the field or the inline calendar. */\n  \"aria-label\"?: string\n  /** Goes on the text input, so <label htmlFor> works. */\n  id?: string\n  /** Text for built-in controls and screen readers; pass translations here. */\n  labels?: Partial<DatePickerLabels>\n}\nexport type DatePickerSingleProps = Base & { mode?: \"single\"; value?: Date | null; defaultValue?: Date | null; onValueChange?: (value: Date | null) => void }\nexport type DatePickerRangeProps = Base & {\n  mode: \"range\"\n  /** to is null while the end is being picked. */\n  value?: DateRange | null\n  defaultValue?: DateRange | null\n  onValueChange?: (value: DateRange | null) => void\n}\nexport type DatePickerMultipleProps = Base & { mode: \"multiple\"; value?: Date[]; defaultValue?: Date[]; onValueChange?: (value: Date[]) => void }\nexport type DatePickerProps = DatePickerSingleProps | DatePickerRangeProps | DatePickerMultipleProps\n\nconst CSS = `\n.pc-dp{--pc-c:var(--primary);--pc-fg:var(--primary-foreground)}\n.pc-dp[data-tone=neutral]{--pc-c:var(--foreground);--pc-fg:var(--background)}\n.pc-dp[data-tone=success]{--pc-c:oklch(0.53 0.13 155);--pc-fg:#fff}\n.pc-dp[data-tone=warning]{--pc-c:oklch(0.75 0.16 70);--pc-fg:oklch(0.25 0.05 70)}\n.pc-dp[data-tone=danger]{--pc-c:oklch(0.56 0.21 27);--pc-fg:#fff}\n.pc-dp[data-tone=info]{--pc-c:oklch(0.55 0.17 250);--pc-fg:#fff}\n.dark .pc-dp[data-tone=success]{--pc-c:oklch(0.7 0.16 155);--pc-fg:oklch(0.2 0.05 155)}\n.dark .pc-dp[data-tone=danger]{--pc-c:oklch(0.68 0.2 25);--pc-fg:oklch(0.2 0.05 25)}\n.dark .pc-dp[data-tone=info]{--pc-c:oklch(0.7 0.15 245);--pc-fg:oklch(0.2 0.05 245)}\n.pc-dp{--pc-tint:color-mix(in oklab,var(--pc-c) 14%,transparent);--pc-ink:color-mix(in oklab,var(--pc-c) 82%,var(--foreground))}\n.pc-dp[data-tone=warning]{--pc-ink:color-mix(in oklab,var(--pc-c) 62%,var(--foreground))}\n.pc-dp{--pc-ring:color-mix(in oklab,var(--pc-c) 32%,transparent);--pc-edge:color-mix(in oklab,var(--pc-c) 55%,var(--border));--pc-muted:color-mix(in oklab,var(--muted-foreground) 80%,var(--foreground));--pc-band:color-mix(in oklab,var(--pc-c) 13%,transparent)}\n.pc-dp[data-tone=neutral],.pc-dp[data-tone=primary]{--pc-ink:var(--foreground)}\n\n.pc-dp-field{position:relative;color:var(--foreground);transition:border-color .15s,background-color .15s,box-shadow .15s,transform .12s}\n.pc-dp[data-variant=outline] .pc-dp-field,.pc-dp[data-variant=pill] .pc-dp-field{background:var(--background);border:1px solid var(--input)}\n.pc-dp[data-variant=outline] .pc-dp-field:hover,.pc-dp[data-variant=pill] .pc-dp-field:hover{border-color:color-mix(in oklab,var(--pc-c) 30%,var(--input))}\n.pc-dp[data-variant=filled] .pc-dp-field{background:var(--muted);border:1px solid transparent}\n.pc-dp[data-variant=filled] .pc-dp-field:focus-within{background:var(--background)}\n.pc-dp[data-variant=ghost] .pc-dp-field{border:1px solid transparent}\n.pc-dp[data-variant=ghost] .pc-dp-field:is(:hover,:focus-within){background:var(--pc-tint)}\n.pc-dp[data-variant=underline] .pc-dp-field{border-radius:0;border-bottom:1.5px solid var(--input);padding-inline:.125rem}\n.pc-dp[data-variant=underline] .pc-dp-field::after{content:\"\";position:absolute;inset-inline:0;bottom:-1.5px;height:2px;background:var(--pc-c);transform:scaleX(0);transition:transform .25s var(--pc-ease-out)}\n.pc-dp[data-variant=underline] .pc-dp-field:focus-within::after,.pc-dp[data-variant=underline][data-open] .pc-dp-field::after{transform:scaleX(1)}\n.pc-dp[data-variant=neo] .pc-dp-field{background:var(--background);border:2px solid var(--foreground);box-shadow:3px 3px 0 var(--foreground)}\n.pc-dp[data-variant=neo] .pc-dp-field:focus-within{outline:2px solid var(--pc-c);outline-offset:3px}\n.pc-dp:is([data-variant=outline],[data-variant=filled],[data-variant=pill]) .pc-dp-field:focus-within,.pc-dp:is([data-variant=outline],[data-variant=filled],[data-variant=pill])[data-open] .pc-dp-field{border-color:var(--pc-edge);box-shadow:0 0 0 3px var(--pc-ring)}\n.pc-dp[data-invalid] .pc-dp-field{border-color:oklch(0.56 0.21 27)}\n.pc-dp[data-variant=underline][data-invalid] .pc-dp-field::after{background:oklch(0.56 0.21 27);transform:scaleX(1)}\n.pc-dp-input::placeholder{color:var(--pc-muted);opacity:1}\n.pc-dp-muted{color:var(--pc-muted)}\n\n.pc-dp-surface{background:var(--popover);color:var(--popover-foreground);border:1px solid var(--border)}\n.pc-dp[data-inline] .pc-dp-surface{background:var(--card);color:var(--card-foreground)}\n.pc-dp[data-variant=neo] .pc-dp-surface{border:2px solid var(--foreground);box-shadow:4px 4px 0 var(--foreground)!important}\n.pc-dp[data-shadow=sm] .pc-dp-surface{box-shadow:0 2px 6px -1px rgb(0 0 0/.12)}\n.pc-dp[data-shadow=md] .pc-dp-surface{box-shadow:0 16px 40px -12px rgb(0 0 0/.25),0 4px 10px -4px rgb(0 0 0/.08)}\n.pc-dp[data-shadow=lg] .pc-dp-surface{box-shadow:0 28px 60px -16px rgb(0 0 0/.34),0 6px 14px -6px rgb(0 0 0/.12)}\n.dark .pc-dp:is([data-shadow=md],[data-shadow=lg]) .pc-dp-surface{box-shadow:0 18px 44px -12px rgb(0 0 0/.65),0 0 0 1px rgb(255 255 255/.04)}\n.pc-dp-nav{color:var(--pc-muted)}\n.pc-dp-nav:hover:not(:disabled){background:var(--accent);color:var(--foreground)}\n.pc-dp-nav:disabled{opacity:.35;cursor:not-allowed}\n.pc-dp-cap:hover{background:var(--accent)}\n.pc-dp :is(.pc-dp-nav,.pc-dp-cap,.pc-dp-chip,.pc-dp-cell-btn,.pc-dp-foot):focus-visible{outline:2px solid var(--pc-c);outline-offset:1px}\n.pc-dp-wd{color:var(--pc-muted)}\n.pc-dp-wk{color:var(--pc-muted);font-variant-numeric:tabular-nums}\n\n.pc-dp-day{color:var(--foreground);position:relative;font-variant-numeric:tabular-nums;transition:background-color .12s,color .12s,box-shadow .12s}\n.pc-dp-day:hover:not([aria-disabled=true]){background:color-mix(in oklab,var(--pc-c) 10%,var(--accent))}\n.pc-dp-day[data-outside]{color:var(--pc-muted);font-weight:400}\n.pc-dp-day[data-today]::after{content:\"\";position:absolute;bottom:14%;inset-inline-start:50%;width:4px;height:4px;margin-inline-start:-2px;border-radius:9999px;background:var(--pc-c)}\n.pc-dp-day[aria-disabled=true]{color:var(--pc-muted);opacity:.4;cursor:not-allowed}\n.pc-dp-day[data-booked]{opacity:1;color:var(--pc-muted);text-decoration:line-through;text-decoration-thickness:1.5px;text-decoration-color:color-mix(in oklab,oklch(0.6 0.2 27) 70%,transparent);background:repeating-linear-gradient(135deg,transparent 0 5px,color-mix(in oklab,var(--foreground) 6%,transparent) 5px 6px)}\n.pc-dp-day:focus-visible{outline:2px solid var(--pc-c);outline-offset:1px;z-index:1}\n.pc-dp-cell[data-band]{background:var(--pc-band)}\n.pc-dp-cell[data-band=start]{background:linear-gradient(to right,transparent 50%,var(--pc-band) 50%)}\n.pc-dp-cell[data-band=end]{background:linear-gradient(to left,transparent 50%,var(--pc-band) 50%)}\n.pc-dp-cell[data-band=start]:dir(rtl){background:linear-gradient(to left,transparent 50%,var(--pc-band) 50%)}\n.pc-dp-cell[data-band=end]:dir(rtl){background:linear-gradient(to right,transparent 50%,var(--pc-band) 50%)}\n.pc-dp-cell[data-band=solo]{background:none}\n.pc-dp-cell[data-preview]{--pc-band:color-mix(in oklab,var(--pc-c) 7%,transparent)}\n.pc-dp-cell[data-band]>.pc-dp-day{color:var(--pc-ink)}\n.pc-dp[data-sel=solid] .pc-dp-day[data-selected]{background:var(--pc-c);color:var(--pc-fg);font-weight:600}\n.pc-dp[data-sel=solid] .pc-dp-day[data-selected]::after{background:var(--pc-fg)}\n.pc-dp[data-sel=soft] .pc-dp-day[data-selected]{background:color-mix(in oklab,var(--pc-c) 24%,var(--background));color:var(--pc-ink);font-weight:600}\n.pc-dp[data-sel=ring] .pc-dp-day[data-selected]{box-shadow:inset 0 0 0 2px var(--pc-c);color:var(--pc-ink);font-weight:600;background:var(--background)}\n.pc-dp-chip{color:var(--foreground)}\n.pc-dp-chip:hover{background:var(--accent)}\n.pc-dp-chip[aria-pressed=true]{background:var(--pc-tint);color:var(--pc-ink);font-weight:500}\n.pc-dp-cell-btn{color:var(--foreground)}\n.pc-dp-cell-btn:hover:not(:disabled){background:var(--accent)}\n.pc-dp-cell-btn[aria-current=true]{box-shadow:inset 0 0 0 1px var(--pc-edge)}\n.pc-dp-cell-btn[aria-pressed=true]{background:var(--pc-c);color:var(--pc-fg)}\n.pc-dp-cell-btn:disabled{opacity:.35;cursor:not-allowed}\n.pc-dp-time{background:var(--background);border:1px solid var(--input);color:var(--foreground);color-scheme:light dark}\n.pc-dp-time:focus{outline:none;border-color:var(--pc-edge);box-shadow:0 0 0 3px var(--pc-ring)}\n.pc-dp-foot{color:var(--foreground)}\n.pc-dp-foot[data-primary]{background:var(--pc-c);color:var(--pc-fg)}\n.pc-dp-foot:not([data-primary]):hover{background:var(--accent)}\n@media (prefers-reduced-motion:reduce){.pc-dp-field,.pc-dp-field::after,.pc-dp-day{transition:none!important}}\n`\n\nconst SIZES = {\n  sm: { cell: \"size-8 text-xs\", field: \"min-h-8 px-2.5 text-sm gap-1.5\", icon: \"[&_svg]:size-3.5\", pad: \"p-2\", cap: \"text-sm\", grid: \"gap-y-0.5\", mcell: \"h-9 text-xs\" },\n  md: { cell: \"size-9 text-sm\", field: \"min-h-10 px-3 text-sm gap-2\", icon: \"[&_svg]:size-4\", pad: \"p-3\", cap: \"text-sm\", grid: \"gap-y-1\", mcell: \"h-10 text-sm\" },\n  lg: { cell: \"size-11 text-base\", field: \"min-h-12 px-4 text-base gap-2.5\", icon: \"[&_svg]:size-[18px]\", pad: \"p-4\", cap: \"text-base\", grid: \"gap-y-1\", mcell: \"h-12 text-base\" },\n} satisfies Record<DatePickerSize, Record<string, string>>\nconst SHAPES: Record<DatePickerShape, string> = { circle: \"rounded-full\", rounded: \"rounded-md\", square: \"rounded-none\" }\nconst RADIUS: Record<DatePickerVariant, string> = { outline: \"rounded-lg\", filled: \"rounded-lg\", ghost: \"rounded-lg\", underline: \"rounded-none\", pill: \"rounded-full\", neo: \"rounded-md\" }\nconst SURFACE_RADIUS: Record<DatePickerVariant, string> = { outline: \"rounded-xl\", filled: \"rounded-xl\", ghost: \"rounded-xl\", underline: \"rounded-lg\", pill: \"rounded-2xl\", neo: \"rounded-md\" }\n\n/* ---------- date math (local time, no library) ---------- */\n\nconst sod = (d: Date) => new Date(d.getFullYear(), d.getMonth(), d.getDate())\nconst addDays = (d: Date, n: number) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + n, d.getHours(), d.getMinutes())\nconst som = (d: Date) => new Date(d.getFullYear(), d.getMonth(), 1)\nconst daysIn = (y: number, m: number) => new Date(y, m + 1, 0).getDate()\nfunction addMonths(d: Date, n: number) {\n  const t = new Date(d.getFullYear(), d.getMonth() + n, 1)\n  return new Date(t.getFullYear(), t.getMonth(), Math.min(d.getDate(), daysIn(t.getFullYear(), t.getMonth())), d.getHours(), d.getMinutes())\n}\nconst num = (d: Date) => d.getFullYear() * 10000 + (d.getMonth() + 1) * 100 + d.getDate()\nconst mIndex = (d: Date) => d.getFullYear() * 12 + d.getMonth()\nconst same = (a: Date | null | undefined, b: Date | null | undefined) => !!a && !!b && num(a) === num(b)\nconst pad2 = (n: number) => String(n).padStart(2, \"0\")\nconst iso = (d: Date) => `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`\nconst hhmm = (d: Date) => `${pad2(d.getHours())}:${pad2(d.getMinutes())}`\nconst withTime = (d: Date, t: string) => {\n  const [h, m] = t.split(\":\").map(Number)\n  return new Date(d.getFullYear(), d.getMonth(), d.getDate(), h ?? 0, m ?? 0)\n}\nfunction isoWeek(d: Date) {\n  const t = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()))\n  const day = t.getUTCDay() || 7\n  t.setUTCDate(t.getUTCDate() + 4 - day)\n  const y0 = Date.UTC(t.getUTCFullYear(), 0, 1)\n  return Math.ceil(((t.getTime() - y0) / 86400000 + 1) / 7)\n}\n\nfunction localeWeekStart(locale: string) {\n  try {\n    const loc = new Intl.Locale(locale) as Intl.Locale & { getWeekInfo?: () => { firstDay: number }; weekInfo?: { firstDay: number } }\n    const info = loc.getWeekInfo?.() ?? loc.weekInfo\n    if (info) return info.firstDay % 7\n  } catch {\n    /* fall through */\n  }\n  return /-(US|CA|JP|BR|MX|IL|PH|KR|TW|HK|IN|SA|ZA)$/i.test(locale) || locale === \"en\" ? 0 : 1\n}\n\n/* ---------- Intl formatting and typed-date parsing ---------- */\n\nfunction makeIntl(locale: string) {\n  const numeric = new Intl.DateTimeFormat(locale, { year: \"numeric\", month: \"2-digit\", day: \"2-digit\" })\n  const parts = numeric.formatToParts(new Date(2026, 10, 23))\n  const order = parts.filter((p) => p.type === \"day\" || p.type === \"month\" || p.type === \"year\").map((p) => p.type as \"day\" | \"month\" | \"year\")\n  const digits = new Map<string, string>()\n  const nf = new Intl.NumberFormat(locale, { useGrouping: false })\n  for (let i = 0; i < 10; i++) digits.set(nf.format(i), String(i))\n  const toLatin = (s: string) => s.replace(/\\p{Nd}/gu, (ch) => digits.get(ch) ?? ch)\n  const fold = (s: string) => s.normalize(\"NFD\").replace(/[̀-ͯ]/g, \"\").toLowerCase().replace(/\\./g, \"\")\n  const monthNames: { name: string; m: number }[] = []\n  for (const style of [\"long\", \"short\"] as const) {\n    const f = new Intl.DateTimeFormat(locale, { month: style })\n    for (let m = 0; m < 12; m++) monthNames.push({ name: fold(f.format(new Date(2026, m, 15))), m })\n  }\n  const time = new Intl.DateTimeFormat(locale, { hour: \"2-digit\", minute: \"2-digit\" })\n\n  /** Parses \"11/23/2026\", \"23.11.2026\", \"2026-11-23\", \"Nov 23 2026\", \"23 noviembre\", optionally followed by a time. */\n  const parse = (input: string, today: Date, fallbackTime = \"00:00\"): Date | null => {\n    let s = toLatin(input).trim()\n    if (!s) return null\n    let hours: number | null = null\n    let minutes = 0\n    const tm = s.match(/(\\d{1,2})[:.h](\\d{2})\\s*([ap])?\\.?\\s*m?\\.?\\s*$/i)\n    if (tm && s.length > tm[0].length) {\n      hours = Number(tm[1]) % 24\n      minutes = Number(tm[2])\n      if (tm[3]?.toLowerCase() === \"p\" && hours < 12) hours += 12\n      if (tm[3]?.toLowerCase() === \"a\" && hours === 12) hours = 0\n      s = s.slice(0, tm.index).trim()\n    }\n    let y: number | undefined\n    let m: number | undefined\n    let d: number | undefined\n    const isoMatch = s.match(/^(\\d{4})-(\\d{1,2})-(\\d{1,2})/)\n    if (isoMatch) {\n      y = Number(isoMatch[1])\n      m = Number(isoMatch[2]) - 1\n      d = Number(isoMatch[3])\n    } else {\n      const tokens = s.split(/[^\\p{L}\\p{N}]+/u).filter(Boolean)\n      const words = tokens.filter((t) => /\\p{L}/u.test(t))\n      const nums = tokens.filter((t) => /^\\d+$/.test(t))\n      if (words.length) {\n        const w = fold(words[0]!)\n        const hit = w.length >= 3 ? monthNames.find((x) => x.name.startsWith(w) || (x.name.length >= 3 && w.startsWith(x.name))) : undefined\n        if (!hit) return null\n        m = hit.m\n        const yi = nums.findIndex((n) => n.length >= 3 || Number(n) > 31)\n        if (yi >= 0) y = Number(nums[yi])\n        d = Number(nums.find((_, i) => i !== yi))\n      } else if (nums.length === 1 && (nums[0]!.length === 8 || nums[0]!.length === 6)) {\n        const n = nums[0]!\n        const yl = n.length === 8 ? 4 : 2\n        let at = 0\n        for (const k of order) {\n          const len = k === \"year\" ? yl : 2\n          const v = Number(n.slice(at, at + len))\n          at += len\n          if (k === \"day\") d = v\n          else if (k === \"month\") m = v - 1\n          else y = v\n        }\n      } else if (nums.length >= 2) {\n        const keys = nums.length >= 3 ? order : order.filter((k) => k !== \"year\")\n        keys.forEach((k, i) => {\n          const v = Number(nums[i])\n          if (k === \"day\") d = v\n          else if (k === \"month\") m = v - 1\n          else y = v\n        })\n      } else return null\n    }\n    if (y === undefined) y = today.getFullYear()\n    else if (y < 100) y += 2000\n    if (m === undefined || d === undefined || !Number.isFinite(d) || m < 0 || m > 11 || d < 1 || d > daysIn(y, m)) return null\n    if (hours === null) return withTime(new Date(y, m, d), fallbackTime)\n    return new Date(y, m, d, hours, minutes)\n  }\n\n  return {\n    order,\n    parts,\n    parse,\n    format: (d: Date) => numeric.format(d),\n    formatTime: (d: Date) => time.format(d),\n    caption: new Intl.DateTimeFormat(locale, { month: \"long\", year: \"numeric\" }),\n    full: new Intl.DateTimeFormat(locale, { weekday: \"long\", year: \"numeric\", month: \"long\", day: \"numeric\" }),\n    short: new Intl.DateTimeFormat(locale, { month: \"short\", day: \"numeric\" }),\n    dayNum: new Intl.DateTimeFormat(locale, { day: \"numeric\" }),\n    monthShort: new Intl.DateTimeFormat(locale, { month: \"short\" }),\n    monthLong: new Intl.DateTimeFormat(locale, { month: \"long\", year: \"numeric\" }),\n    year: new Intl.DateTimeFormat(locale, { year: \"numeric\" }),\n    wdShort: new Intl.DateTimeFormat(locale, { weekday: \"short\" }),\n    wdNarrow: new Intl.DateTimeFormat(locale, { weekday: \"narrow\" }),\n    wdLong: new Intl.DateTimeFormat(locale, { weekday: \"long\" }),\n    num: (n: number) => nf.format(n),\n  }\n}\n\n/* ---------- floating placement (flip + shift, no library) ---------- */\n\ntype Rect = { top: number; left: number; right: number; bottom: number; width: number; height: number }\ntype Placement = { x: number; y: number; side: \"top\" | \"bottom\"; maxH: number }\n\nfunction place(a: Rect, w: number, h: number, rtl: boolean): Placement {\n  const pad = 8\n  const offset = 6\n  const vw = document.documentElement.clientWidth\n  const vh = window.innerHeight\n  const below = vh - a.bottom - offset - pad\n  const above = a.top - offset - pad\n  const side = below < h && above > below ? \"top\" : \"bottom\"\n  const maxH = Math.max(160, side === \"bottom\" ? below : above)\n  const hh = Math.min(h, maxH)\n  const x = rtl ? a.right - w : a.left\n  return { x: Math.max(pad, Math.min(x, vw - pad - w)), y: side === \"bottom\" ? a.bottom + offset : a.top - offset - hh, side, maxH }\n}\n\nfunction usePlacement(open: boolean, anchor: React.RefObject<HTMLElement | null>, surface: React.RefObject<HTMLElement | null>, rtl: boolean) {\n  const [p, setP] = React.useState<Placement | null>(null)\n  React.useLayoutEffect(() => {\n    if (!open) return\n    const update = () => {\n      const el = surface.current\n      const a = anchor.current?.getBoundingClientRect()\n      if (!el || !a) return\n      const next = place(a, el.offsetWidth, el.scrollHeight + (el.offsetHeight - el.clientHeight), rtl)\n      setP((prev) => (prev && Math.abs(prev.x - next.x) < 0.5 && Math.abs(prev.y - next.y) < 0.5 && prev.side === next.side && prev.maxH === next.maxH ? prev : next))\n    }\n    update()\n    let raf = 0\n    const schedule = () => {\n      cancelAnimationFrame(raf)\n      raf = requestAnimationFrame(update)\n    }\n    window.addEventListener(\"scroll\", schedule, true)\n    window.addEventListener(\"resize\", schedule)\n    const ro = typeof ResizeObserver === \"undefined\" ? null : new ResizeObserver(schedule)\n    if (surface.current) ro?.observe(surface.current)\n    return () => {\n      cancelAnimationFrame(raf)\n      window.removeEventListener(\"scroll\", schedule, true)\n      window.removeEventListener(\"resize\", schedule)\n      ro?.disconnect()\n    }\n  }, [open, anchor, surface, rtl, !!p])\n  return p\n}\n\n/* ---------- icons ---------- */\n\nconst Chevron = ({ dir, className }: { dir: \"start\" | \"end\" | \"down\"; className?: string }) => (\n  <svg viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\" className={cn(dir === \"start\" && \"rtl:rotate-180\", dir === \"end\" && \"rotate-180 rtl:rotate-0\", className)}>\n    <path d={dir === \"down\" ? \"m4 6 4 4 4-4\" : \"m10 4-4 4 4 4\"} stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n  </svg>\n)\nconst CalendarIcon = (p: React.SVGProps<SVGSVGElement>) => (\n  <svg viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\" {...p}>\n    <rect x=\"2.25\" y=\"3.25\" width=\"11.5\" height=\"10.5\" rx=\"2\" stroke=\"currentColor\" strokeWidth=\"1.4\" />\n    <path d=\"M2.5 6.5h11M5.5 2v2.5M10.5 2v2.5\" stroke=\"currentColor\" strokeWidth=\"1.4\" strokeLinecap=\"round\" />\n  </svg>\n)\nconst Cross = (p: React.SVGProps<SVGSVGElement>) => (\n  <svg viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden=\"true\" {...p}>\n    <path d=\"M4.5 4.5 11.5 11.5M11.5 4.5 4.5 11.5\" stroke=\"currentColor\" strokeWidth=\"1.75\" strokeLinecap=\"round\" />\n  </svg>\n)\n\n/* ---------- a month grid (aware of its exit animation, so focus never lands in a leaving grid) ---------- */\n\ntype DayInfo = { date: Date; outside: boolean }\ntype GridProps = {\n  month: Date\n  weekStartsOn: number\n  render: (info: DayInfo, exiting: boolean) => React.ReactNode\n  head: React.ReactNode\n  weekNumbers: boolean\n  hideOutside: boolean\n  labelledBy: string\n  fmtWeek: (n: number) => string\n  weekLabel: (n: number) => string\n  onKeyDown: (e: React.KeyboardEvent<HTMLTableElement>) => void\n  onPointerLeave: () => void\n  rowClass: string\n}\nfunction MonthGrid({ month, weekStartsOn, render, head, weekNumbers, hideOutside, labelledBy, fmtWeek, weekLabel, onKeyDown, onPointerLeave, rowClass }: GridProps) {\n  const exiting = !useIsPresent()\n  const first = som(month)\n  const lead = (first.getDay() - weekStartsOn + 7) % 7\n  const start = addDays(first, -lead)\n  const rows: DayInfo[][] = []\n  for (let r = 0; r < 6; r++) {\n    const row: DayInfo[] = []\n    for (let c = 0; c < 7; c++) {\n      const date = addDays(start, r * 7 + c)\n      row.push({ date, outside: date.getMonth() !== month.getMonth() })\n    }\n    rows.push(row)\n  }\n  return (\n    <table role=\"grid\" aria-labelledby={labelledBy} className=\"w-full border-collapse\" onKeyDown={onKeyDown} onPointerLeave={onPointerLeave} data-exiting={exiting ? \"\" : undefined} inert={exiting || undefined}>\n      <thead>{head}</thead>\n      <tbody>\n        {rows.map((row, r) => {\n          const monday = row[(1 - weekStartsOn + 7) % 7]!.date\n          const wn = isoWeek(monday)\n          return (\n            <tr key={r} className={rowClass}>\n              {weekNumbers && (\n                <th scope=\"row\" aria-label={weekLabel(wn)} className=\"pc-dp-wk w-8 text-center text-[11px] font-normal\">\n                  {fmtWeek(wn)}\n                </th>\n              )}\n              {row.map((info) => (hideOutside && info.outside ? <td key={info.date.getTime()} role=\"gridcell\" className=\"p-0\" /> : <React.Fragment key={info.date.getTime()}>{render(info, exiting)}</React.Fragment>))}\n            </tr>\n          )\n        })}\n      </tbody>\n    </table>\n  )\n}\n\n/* ---------- component ---------- */\n\nexport function DatePicker(props: DatePickerProps) {\n  const {\n    mode = \"single\",\n    locale: localeProp,\n    weekStartsOn: weekProp,\n    min,\n    max,\n    disabledDays,\n    disabledWeekdays,\n    booked,\n    weekNumbers = false,\n    months: monthsProp,\n    presets: presetsProp,\n    time = false,\n    minuteStep = 15,\n    inline = false,\n    placeholder,\n    variant = \"outline\",\n    tone = \"primary\",\n    selection = \"solid\",\n    shape = \"circle\",\n    size = \"md\",\n    shadow = \"md\",\n    animation = \"slide\",\n    clearable,\n    closeOnSelect = true,\n    disabled,\n    invalid,\n    month: monthProp,\n    defaultMonth,\n    onMonthChange,\n    open: openProp,\n    defaultOpen = false,\n    onOpenChange,\n    name,\n    value: valueProp,\n    defaultValue,\n    onValueChange,\n    \"aria-label\": ariaLabel,\n    id: idProp,\n    labels,\n    className,\n    ...rest\n  } = props\n  const l = useLabels(\"date-picker\", DEFAULT_LABELS, labels)\n  const { lang } = useGooduiLocale()\n  const locale = localeProp ?? lang\n  const prefersReduced = useReducedMotion()\n  const [mounted, setMounted] = React.useState(false)\n  const [today, setToday] = React.useState<Date | null>(null)\n  const [wide, setWide] = React.useState(true)\n  React.useEffect(() => {\n    setMounted(true)\n    setToday(sod(new Date()))\n    const mq = window.matchMedia(\"(min-width: 640px)\")\n    setWide(mq.matches)\n    const on = () => setWide(mq.matches)\n    mq.addEventListener(\"change\", on)\n    return () => mq.removeEventListener(\"change\", on)\n  }, [])\n  const reduce = mounted && !!prefersReduced\n  const uid = React.useId()\n  const inputId = idProp ?? uid + \"-input\"\n  const dialogId = uid + \"-dialog\"\n\n  const intl = React.useMemo(() => makeIntl(locale), [locale])\n  const weekStartsOn = ((weekProp ?? localeWeekStart(locale)) % 7 + 7) % 7\n  const shown = monthsProp ?? (mode === \"range\" && wide ? 2 : 1)\n\n  /* rules */\n  const listSet = (v: Date[] | ((d: Date) => boolean) | undefined) => (Array.isArray(v) ? new Set(v.map(num)) : null)\n  const disabledSet = React.useMemo(() => listSet(disabledDays), [disabledDays])\n  const bookedSet = React.useMemo(() => listSet(booked), [booked])\n  const minN = min ? num(min) : -Infinity\n  const maxN = max ? num(max) : Infinity\n  const outOfRange = (d: Date) => num(d) < minN || num(d) > maxN\n  const isDisabled = (d: Date) =>\n    outOfRange(d) || !!disabledWeekdays?.includes(d.getDay()) || (disabledSet ? disabledSet.has(num(d)) : typeof disabledDays === \"function\" && disabledDays(d))\n  const isBooked = (d: Date) => (bookedSet ? bookedSet.has(num(d)) : typeof booked === \"function\" && booked(d))\n  const blocked = (d: Date) => isDisabled(d) || isBooked(d)\n\n  /* value */\n  type V = Date | DateRange | Date[] | null\n  const [inner, setInner] = React.useState<V | undefined>(defaultValue)\n  const value: V = valueProp !== undefined ? valueProp : (inner ?? (mode === \"multiple\" ? [] : null))\n  const single = mode === \"single\" ? (value as Date | null) : null\n  const range = mode === \"range\" ? (value as DateRange | null) : null\n  const multi = mode === \"multiple\" ? ((value as Date[] | null) ?? []) : []\n  const commit = (v: V) => {\n    if (valueProp === undefined) setInner(v)\n    ;(onValueChange as ((v: V) => void) | undefined)?.(v)\n  }\n\n  /* open */\n  const [openInner, setOpenInner] = React.useState(defaultOpen)\n  const open = !inline && (openProp ?? openInner) && !disabled\n  const setOpen = (o: boolean) => {\n    if (o === open) return\n    if (openProp === undefined) setOpenInner(o)\n    onOpenChange?.(o)\n  }\n\n  /* month */\n  const valueAnchor = single ?? range?.from ?? multi[multi.length - 1] ?? null\n  const [monthInner, setMonthInner] = React.useState<Date | null>(() => (defaultMonth ? som(defaultMonth) : valueAnchor ? som(valueAnchor) : null))\n  const month = monthProp ? som(monthProp) : (monthInner ?? (today ? som(today) : null))\n  const [dir, setDir] = React.useState<1 | -1>(1)\n  const setMonth = (m: Date) => {\n    const next = som(m)\n    if (month && mIndex(next) === mIndex(month)) return\n    setDir(month && mIndex(next) < mIndex(month) ? -1 : 1)\n    if (!monthProp) setMonthInner(next)\n    onMonthChange?.(next)\n  }\n  const minMonth = min ? mIndex(min) : -Infinity\n  const maxMonth = max ? mIndex(max) : Infinity\n\n  /* focus, hover, view */\n  const [focused, setFocused] = React.useState<Date | null>(null)\n  const [hover, setHover] = React.useState<Date | null>(null)\n  const [view, setView] = React.useState<\"days\" | \"months\" | \"years\">(\"days\")\n  const [viewOffset, setViewOffset] = React.useState(0)\n  const kb = React.useRef(false)\n  const root = React.useRef<HTMLDivElement>(null)\n  const field = React.useRef<HTMLDivElement>(null)\n  const input = React.useRef<HTMLInputElement>(null)\n  const button = React.useRef<HTMLButtonElement>(null)\n  const surface = React.useRef<HTMLDivElement>(null)\n  const returnTo = React.useRef<HTMLElement | null>(null)\n  const [rtl, setRtl] = React.useState(false)\n  React.useEffect(() => {\n    if (root.current) setRtl(getComputedStyle(root.current).direction === \"rtl\")\n  }, [open, mounted])\n\n  const clampDay = (d: Date) => (min && num(d) < minN ? sod(min) : max && num(d) > maxN ? sod(max) : d)\n  const focusTarget = () => clampDay(sod(valueAnchor ?? today ?? new Date()))\n\n  const moveFocus = (next: Date) => {\n    const d = clampDay(next)\n    kb.current = true\n    setFocused(d)\n    if (!month) return\n    const first = mIndex(month)\n    const last = first + shown - 1\n    if (mIndex(d) < first) setMonth(d)\n    else if (mIndex(d) > last) setMonth(addMonths(som(d), -(shown - 1)))\n  }\n\n  // Move DOM focus to the focused day after keyboard navigation (and when the dialog opens).\n  React.useEffect(() => {\n    if (!kb.current || !focused) return\n    const scope = inline ? root.current : surface.current\n    const btn = scope?.querySelector<HTMLElement>(`table:not([data-exiting]) [data-date=\"${iso(focused)}\"]`)\n    if (btn) {\n      btn.focus({ preventScroll: true })\n      // A hidden (not yet placed) popover can't take focus; try again on the next render.\n      if (document.activeElement === btn) kb.current = false\n    }\n  })\n\n  /* text field */\n  const formatValue = (): string => {\n    const f = (d: Date) => intl.format(d) + (time ? \" \" + intl.formatTime(d) : \"\")\n    if (mode === \"single\") return single ? f(single) : \"\"\n    if (mode === \"range\") return range ? `${f(range.from)} – ${range.to ? f(range.to) : \"\"}`.trim() : \"\"\n    return multi.length > 3 ? l.selectedCount(multi.length) : multi.map((d) => intl.short.format(d)).join(\", \")\n  }\n  const display = formatValue()\n  const [text, setText] = React.useState<string | null>(null)\n  const [bad, setBad] = React.useState(false)\n  const fieldText = text ?? display\n  const fmtPlaceholder =\n    placeholder ??\n    intl.parts\n      .map((p) => (p.type === \"day\" ? l.formatDay : p.type === \"month\" ? l.formatMonth : p.type === \"year\" ? l.formatYear : p.type === \"literal\" ? p.value : \"\"))\n      .join(\"\")\n      .replace(/[‎‏]/g, \"\") + (mode === \"range\" ? \" – …\" : \"\")\n\n  const commitText = () => {\n    if (text === null) return\n    const t = text.trim()\n    if (!t) {\n      setText(null)\n      setBad(false)\n      if (mode === \"multiple\") commit([])\n      else commit(null)\n      return\n    }\n    const now = today ?? sod(new Date())\n    const ok = (d: Date | null): d is Date => !!d && !blocked(sod(d))\n    if (mode === \"single\") {\n      const d = intl.parse(t, now, single ? hhmm(single) : singleTime)\n      if (!ok(d)) return setBad(true)\n      setText(null)\n      setBad(false)\n      commit(time ? d : sod(d))\n      setMonth(d)\n    } else if (mode === \"range\") {\n      const [a, b] = t.split(/\\s*[–—]\\s*|\\s+-\\s+|\\s+(?:to|bis|à|a|al|tot)\\s+/i)\n      const from = a ? intl.parse(a, now, range ? hhmm(range.from) : rangeTime.from) : null\n      const to = b ? intl.parse(b, now, range?.to ? hhmm(range.to) : rangeTime.to) : null\n      if (!ok(from) || (b && !ok(to)) || (to && num(to) < num(from))) return setBad(true)\n      setText(null)\n      setBad(false)\n      commit({ from: time ? from : sod(from), to: to ? (time ? to : sod(to)) : null })\n      setMonth(from)\n    } else {\n      const list = t\n        .split(/\\s*[;,،]\\s*/)\n        .map((s) => intl.parse(s, now))\n        .filter((d): d is Date => ok(d))\n      if (!list.length) return setBad(true)\n      setText(null)\n      setBad(false)\n      commit(list.map(sod))\n    }\n  }\n\n  /* picking */\n  const [rangeTime, setRangeTime] = React.useState({ from: \"09:00\", to: \"17:00\" })\n  const [singleTime, setSingleTime] = React.useState(\"09:00\")\n  const close = (focusBack = true) => {\n    setOpen(false)\n    setView(\"days\")\n    setHover(null)\n    if (focusBack) (returnTo.current ?? button.current)?.focus({ preventScroll: true })\n  }\n\n  const pick = (d: Date) => {\n    if (blocked(d)) return\n    setFocused(d)\n    setBad(false)\n    setText(null)\n    if (mode === \"single\") {\n      commit(time ? withTime(d, single ? hhmm(single) : singleTime) : d)\n      if (closeOnSelect && !time && !inline) close()\n    } else if (mode === \"multiple\") {\n      commit(multi.some((x) => same(x, d)) ? multi.filter((x) => !same(x, d)) : [...multi, d].sort((a, b) => a.getTime() - b.getTime()))\n    } else {\n      const tf = (x: Date, which: \"from\" | \"to\") => (time ? withTime(x, which === \"from\" ? (range ? hhmm(range.from) : rangeTime.from) : range?.to ? hhmm(range.to) : rangeTime.to) : x)\n      if (!range || range.to || num(d) < num(range.from)) commit({ from: tf(d, \"from\"), to: null })\n      else {\n        // A range may not run across a booked or disabled day: start a new range instead.\n        for (let x = addDays(sod(range.from), 1); num(x) < num(d); x = addDays(x, 1))\n          if (blocked(x)) {\n            commit({ from: tf(d, \"from\"), to: null })\n            return\n          }\n        commit({ from: range.from, to: tf(d, \"to\") })\n        setHover(null)\n        if (closeOnSelect && !time && !inline) close()\n      }\n    }\n  }\n\n  const applyPreset = (pr: DatePickerPreset) => {\n    const now = today ?? sod(new Date())\n    const v = pr.value(now)\n    setText(null)\n    setBad(false)\n    if (v instanceof Date) {\n      if (mode === \"range\") commit({ from: v, to: v })\n      else if (mode === \"multiple\") commit([v])\n      else commit(time ? withTime(v, single ? hhmm(single) : singleTime) : v)\n      setMonth(v)\n      setFocused(v)\n    } else {\n      if (mode === \"range\") commit(v)\n      else if (mode === \"multiple\") {\n        const out: Date[] = []\n        for (let x = sod(v.from); v.to && num(x) <= num(v.to); x = addDays(x, 1)) if (!blocked(x)) out.push(x)\n        commit(out)\n      } else commit(v.from)\n      setMonth(shown === 2 && v.to && mIndex(v.to) > mIndex(v.from) ? v.from : (v.to ?? v.from))\n      setFocused(v.from)\n    }\n    if (closeOnSelect && !time && !inline && mode !== \"multiple\") close()\n  }\n\n  const presets: DatePickerPreset[] = Array.isArray(presetsProp)\n    ? presetsProp\n    : presetsProp\n      ? mode === \"range\"\n        ? [\n            { label: l.presetToday, value: (t) => ({ from: t, to: t }) },\n            { label: l.presetLast7, value: (t) => ({ from: addDays(t, -6), to: t }) },\n            { label: l.presetLast30, value: (t) => ({ from: addDays(t, -29), to: t }) },\n            { label: l.presetThisMonth, value: (t) => ({ from: som(t), to: new Date(t.getFullYear(), t.getMonth() + 1, 0) }) },\n            { label: l.presetLastMonth, value: (t) => ({ from: som(addMonths(t, -1)), to: new Date(t.getFullYear(), t.getMonth(), 0) }) },\n            { label: l.presetNext7, value: (t) => ({ from: t, to: addDays(t, 6) }) },\n          ]\n        : [\n            { label: l.presetToday, value: (t) => t },\n            { label: l.presetTomorrow, value: (t) => addDays(t, 1) },\n            { label: l.presetNextWeek, value: (t) => addDays(t, 7) },\n          ]\n      : []\n  const presetActive = (pr: DatePickerPreset) => {\n    if (!today) return false\n    const v = pr.value(today)\n    if (v instanceof Date) return mode === \"single\" ? same(single, v) : mode === \"range\" ? !!range && same(range.from, v) && same(range.to, v) : multi.length === 1 && same(multi[0], v)\n    return mode === \"range\" && !!range && same(range.from, v.from) && same(range.to, v.to)\n  }\n\n  /* open / close */\n  const openDialog = (from: HTMLElement | null) => {\n    if (disabled) return\n    returnTo.current = from\n    const target = focusTarget()\n    setView(\"days\")\n    if (!month || mIndex(target) < mIndex(month) || mIndex(target) > mIndex(month) + shown - 1) setMonth(target)\n    kb.current = true\n    setFocused(target)\n    setOpen(true)\n  }\n\n  // Outside pointer closes the popover.\n  React.useEffect(() => {\n    if (!open) return\n    const onDown = (e: PointerEvent) => {\n      const t = e.target as Node\n      if (surface.current?.contains(t) || field.current?.contains(t)) return\n      close(false)\n    }\n    document.addEventListener(\"pointerdown\", onDown, true)\n    return () => document.removeEventListener(\"pointerdown\", onDown, true)\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [open])\n\n  const p = usePlacement(open && mounted, field, surface, rtl)\n\n  /* keyboard on the day grid */\n  const onGridKey = (e: React.KeyboardEvent<HTMLTableElement>) => {\n    const t = e.target as HTMLElement\n    const k = t.dataset.date\n    if (!k) return\n    const [y, m, d] = k.split(\"-\").map(Number)\n    const cur = new Date(y!, m! - 1, d!)\n    const back = rtl ? 1 : -1\n    let next: Date | null = null\n    switch (e.key) {\n      case \"ArrowLeft\":\n        next = addDays(cur, back)\n        break\n      case \"ArrowRight\":\n        next = addDays(cur, -back)\n        break\n      case \"ArrowUp\":\n        next = addDays(cur, -7)\n        break\n      case \"ArrowDown\":\n        next = addDays(cur, 7)\n        break\n      case \"Home\":\n        next = addDays(cur, -((cur.getDay() - weekStartsOn + 7) % 7))\n        break\n      case \"End\":\n        next = addDays(cur, 6 - ((cur.getDay() - weekStartsOn + 7) % 7))\n        break\n      case \"PageUp\":\n        next = addMonths(cur, e.shiftKey ? -12 : -1)\n        break\n      case \"PageDown\":\n        next = addMonths(cur, e.shiftKey ? 12 : 1)\n        break\n      case \"Enter\":\n      case \" \":\n        e.preventDefault()\n        pick(cur)\n        return\n      default:\n        return\n    }\n    e.preventDefault()\n    moveFocus(sod(next))\n    if (mode === \"range\" && range && !range.to) setHover(sod(next))\n  }\n\n  /* rendering helpers */\n  const s = SIZES[size]\n  const weekdays = Array.from({ length: 7 }, (_, i) => new Date(2026, 0, 4 + ((weekStartsOn + i) % 7)))\n  const head = (\n    <tr>\n      {weekNumbers && (\n        <th scope=\"col\" abbr={l.weekColumn} className=\"pc-dp-wk w-8 pb-1 text-[11px] font-medium\">\n          {l.week}\n        </th>\n      )}\n      {weekdays.map((w) => (\n        <th key={w.getDay()} scope=\"col\" abbr={intl.wdLong.format(w)} className={cn(\"pc-dp-wd pb-1 text-center font-medium\", size === \"sm\" ? \"text-[11px]\" : \"text-xs\")}>\n          {size === \"sm\" ? intl.wdNarrow.format(w) : intl.wdShort.format(w)}\n        </th>\n      ))}\n    </tr>\n  )\n\n  const rangeEnd = range ? (range.to ?? (hover && num(hover) >= num(range.from) ? hover : null)) : null\n  const preview = !!range && !range.to && !!rangeEnd\n  const tabbableKey = (() => {\n    if (!month) return \"\"\n    const f = focused ?? focusTarget()\n    const first = mIndex(month)\n    if (mIndex(f) >= first && mIndex(f) < first + shown) return iso(f)\n    return iso(month)\n  })()\n\n  const renderDay = ({ date, outside }: DayInfo, exiting: boolean) => {\n    const dis = isDisabled(date)\n    const isB = isBooked(date)\n    const sel = mode === \"single\" ? same(single, date) : mode === \"multiple\" ? multi.some((x) => same(x, date)) : !!range && (same(range.from, date) || same(range.to, date))\n    let band: string | undefined\n    if (range && rangeEnd && !outside) {\n      const n = num(date)\n      const a = num(range.from)\n      const b = num(rangeEnd)\n      if (a === b) band = undefined\n      else if (n === a) band = \"start\"\n      else if (n === b) band = \"end\"\n      else if (n > a && n < b) band = \"mid\"\n    }\n    const isToday = same(today, date)\n    const label = intl.full.format(date) + (isToday ? `, ${l.today}` : \"\") + (isB ? `, ${l.booked}` : dis ? `, ${l.unavailable}` : \"\")\n    return (\n      <td role=\"gridcell\" aria-selected={sel || undefined} data-band={band} data-preview={preview && band ? \"\" : undefined} className=\"pc-dp-cell p-0 text-center\">\n        <button\n          type=\"button\"\n          data-date={iso(date)}\n          tabIndex={!exiting && !outside && iso(date) === tabbableKey ? 0 : -1}\n          aria-label={label}\n          aria-disabled={dis || isB || undefined}\n          aria-current={isToday ? \"date\" : undefined}\n          data-selected={sel ? \"\" : undefined}\n          data-today={isToday ? \"\" : undefined}\n          data-outside={outside ? \"\" : undefined}\n          data-booked={isB ? \"\" : undefined}\n          onClick={() => {\n            if (outside && month) setMonth(date)\n            pick(date)\n          }}\n          onFocus={() => setFocused(date)}\n          onPointerEnter={() => mode === \"range\" && range && !range.to && setHover(date)}\n          className={cn(\"pc-press pc-dp-day mx-auto grid place-items-center outline-none select-none\", s.cell, SHAPES[shape], dis && !isB && \"cursor-not-allowed\")}\n        >\n          {intl.dayNum.format(date)}\n        </button>\n      </td>\n    )\n  }\n\n  const t: Transition = reduce || animation === \"none\" ? { duration: 0 } : spring.ui\n  const gridVariants = {\n    enter: (d: number) => (reduce || animation === \"none\" ? { opacity: 1 } : animation === \"fade\" ? { opacity: 0 } : { opacity: 0, x: (rtl ? -d : d) * 36 }),\n    center: { opacity: 1, x: 0 },\n    exit: (d: number) => (reduce || animation === \"none\" ? { opacity: 0 } : animation === \"fade\" ? { opacity: 0 } : { opacity: 0, x: (rtl ? -d : d) * -36 }),\n  }\n\n  const caption = (m: Date, i: number) => {\n    const capId = `${uid}-cap-${i}`\n    const isFirst = i === 0\n    const isLast = i === shown - 1\n    return (\n      <div className=\"mb-2 flex items-center gap-1\">\n        {isFirst ? (\n          <button type=\"button\" className={cn(\"pc-press pc-dp-nav grid size-8 place-items-center rounded-md outline-none\", s.icon)} aria-label={l.prevMonth} disabled={mIndex(m) <= minMonth} onClick={() => setMonth(addMonths(m, -1))}>\n            <Chevron dir=\"start\" className=\"size-4\" />\n          </button>\n        ) : (\n          <span className=\"size-8\" />\n        )}\n        <button\n          type=\"button\"\n          id={capId}\n          aria-label={`${intl.caption.format(m)}, ${l.chooseMonth}`}\n          onClick={() => {\n            setViewOffset(i)\n            setView(\"months\")\n          }}\n          className={cn(\"pc-press pc-dp-cap mx-auto inline-flex items-center gap-1 rounded-md px-2 py-1 font-semibold outline-none\", s.cap)}\n        >\n          <span aria-hidden=\"true\">{intl.caption.format(m)}</span>\n          <Chevron dir=\"down\" className=\"pc-dp-muted size-3.5\" />\n        </button>\n        {isLast ? (\n          <button type=\"button\" className={cn(\"pc-press pc-dp-nav grid size-8 place-items-center rounded-md outline-none\", s.icon)} aria-label={l.nextMonth} disabled={mIndex(m) >= maxMonth} onClick={() => setMonth(addMonths(m, -(shown - 1) + 1))}>\n            <Chevron dir=\"end\" className=\"size-4\" />\n          </button>\n        ) : (\n          <span className=\"size-8\" />\n        )}\n      </div>\n    )\n  }\n\n  // Month and year quick switch grids share one keyboard handler.\n  const onPickerKey = (e: React.KeyboardEvent<HTMLDivElement>) => {\n    const btns = Array.from(e.currentTarget.querySelectorAll<HTMLButtonElement>(\"button[data-cell]\"))\n    const i = btns.indexOf(e.target as HTMLButtonElement)\n    if (i < 0) return\n    const step = e.key === \"ArrowLeft\" ? (rtl ? 1 : -1) : e.key === \"ArrowRight\" ? (rtl ? -1 : 1) : e.key === \"ArrowUp\" ? -3 : e.key === \"ArrowDown\" ? 3 : e.key === \"Home\" ? -i : e.key === \"End\" ? btns.length - 1 - i : 0\n    if (e.key === \"Escape\") {\n      e.preventDefault()\n      e.stopPropagation()\n      setView(\"days\")\n      kb.current = true\n      setFocused(focused ?? focusTarget())\n      return\n    }\n    if (!step) return\n    e.preventDefault()\n    let j = i + step\n    while (btns[j]?.disabled) j += Math.sign(step)\n    btns[Math.max(0, Math.min(btns.length - 1, j))]?.focus()\n  }\n\n  const viewMonth = month ? addMonths(month, viewOffset) : null\n  const [yearPage, setYearPage] = React.useState(0)\n  React.useEffect(() => {\n    if (view === \"years\" && viewMonth) setYearPage(viewMonth.getFullYear() - 5)\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [view])\n  // Focus the current cell when a quick-switch grid opens.\n  React.useEffect(() => {\n    if (view === \"days\") return\n    const scope = inline ? root.current : surface.current\n    scope?.querySelector<HTMLElement>(\"button[data-cell][tabindex='0']\")?.focus({ preventScroll: true })\n  }, [view, inline])\n\n  const picker =\n    viewMonth && view !== \"days\" ? (\n      <motion.div\n        key={view}\n        initial={reduce || animation === \"none\" ? false : { opacity: 0, scale: animation === \"scale\" ? 0.94 : 1 }}\n        animate={{ opacity: 1, scale: 1 }}\n        transition={reduce ? { duration: 0.12 } : t}\n        className=\"flex flex-col\"\n        onKeyDown={onPickerKey}\n      >\n        <div className=\"mb-2 flex items-center gap-1\">\n          <button\n            type=\"button\"\n            className=\"pc-press pc-dp-nav grid size-8 place-items-center rounded-md outline-none\"\n            aria-label={view === \"months\" ? l.prevYear : l.prevYears}\n            onClick={() => (view === \"months\" ? setMonth(addMonths(viewMonth, -viewOffset - 12)) : setYearPage((y) => y - 12))}\n            disabled={view === \"months\" ? viewMonth.getFullYear() - 1 < (min?.getFullYear() ?? -Infinity) : yearPage - 1 < (min?.getFullYear() ?? -Infinity)}\n          >\n            <Chevron dir=\"start\" className=\"size-4\" />\n          </button>\n          <button\n            type=\"button\"\n            aria-label={view === \"months\" ? `${intl.year.format(viewMonth)}, ${l.chooseYear}` : undefined}\n            disabled={view === \"years\"}\n            onClick={() => setView(\"years\")}\n            className={cn(\"pc-press pc-dp-cap mx-auto rounded-md px-2 py-1 font-semibold outline-none disabled:hover:bg-transparent\", s.cap)}\n          >\n            {view === \"months\" ? intl.year.format(viewMonth) : `${intl.num(yearPage)} – ${intl.num(yearPage + 11)}`}\n          </button>\n          <button\n            type=\"button\"\n            className=\"pc-press pc-dp-nav grid size-8 place-items-center rounded-md outline-none\"\n            aria-label={view === \"months\" ? l.nextYear : l.nextYears}\n            onClick={() => (view === \"months\" ? setMonth(addMonths(viewMonth, -viewOffset + 12)) : setYearPage((y) => y + 12))}\n            disabled={view === \"months\" ? viewMonth.getFullYear() + 1 > (max?.getFullYear() ?? Infinity) : yearPage + 12 > (max?.getFullYear() ?? Infinity)}\n          >\n            <Chevron dir=\"end\" className=\"size-4\" />\n          </button>\n        </div>\n        <div role=\"group\" aria-label={view === \"months\" ? l.chooseMonth : l.chooseYear} className=\"grid grid-cols-3 gap-1.5\">\n          {view === \"months\"\n            ? Array.from({ length: 12 }, (_, m) => {\n                const d = new Date(viewMonth.getFullYear(), m, 1)\n                const off = mIndex(d) < minMonth || mIndex(d) > maxMonth\n                const cur = m === viewMonth.getMonth()\n                return (\n                  <button\n                    key={m}\n                    type=\"button\"\n                    data-cell=\"\"\n                    tabIndex={cur ? 0 : -1}\n                    disabled={off}\n                    aria-pressed={cur}\n                    aria-label={intl.monthLong.format(d)}\n                    aria-current={today && mIndex(today) === mIndex(d) ? true : undefined}\n                    onClick={() => {\n                      setMonth(addMonths(d, -viewOffset))\n                      setView(\"days\")\n                      const f = focused ?? focusTarget()\n                      kb.current = true\n                      setFocused(clampDay(new Date(d.getFullYear(), m, Math.min(f.getDate(), daysIn(d.getFullYear(), m)))))\n                    }}\n                    className={cn(\"pc-press pc-dp-cell-btn rounded-md capitalize outline-none\", s.mcell)}\n                  >\n                    {intl.monthShort.format(d)}\n                  </button>\n                )\n              })\n            : Array.from({ length: 12 }, (_, k) => {\n                const y = yearPage + k\n                const off = (min && y < min.getFullYear()) || (max && y > max.getFullYear())\n                const cur = y === viewMonth.getFullYear()\n                return (\n                  <button\n                    key={y}\n                    type=\"button\"\n                    data-cell=\"\"\n                    tabIndex={cur || (k === 0 && (viewMonth.getFullYear() < yearPage || viewMonth.getFullYear() > yearPage + 11)) ? 0 : -1}\n                    disabled={!!off}\n                    aria-pressed={cur}\n                    aria-current={today && today.getFullYear() === y ? true : undefined}\n                    onClick={() => {\n                      setMonth(new Date(y, viewMonth.getMonth() - viewOffset, 1))\n                      setView(\"months\")\n                    }}\n                    className={cn(\"pc-press pc-dp-cell-btn rounded-md tabular-nums outline-none\", s.mcell)}\n                  >\n                    {intl.num(y)}\n                  </button>\n                )\n              })}\n        </div>\n      </motion.div>\n    ) : null\n\n  const calendar = (\n    <div className={cn(\"relative overflow-hidden\", s.pad)}>\n      <span aria-live=\"polite\" className=\"sr-only\">\n        {month && view === \"days\" ? Array.from({ length: shown }, (_, i) => intl.caption.format(addMonths(month, i))).join(\" – \") : \"\"}\n      </span>\n      {view !== \"days\" ? (\n        picker\n      ) : month ? (\n        <AnimatePresence initial={false} mode=\"popLayout\" custom={dir}>\n          <motion.div key={mIndex(month)} custom={dir} variants={gridVariants} initial=\"enter\" animate=\"center\" exit=\"exit\" transition={reduce ? { duration: 0.12 } : t} className=\"flex gap-6\">\n            {Array.from({ length: shown }, (_, i) => {\n              const m = addMonths(month, i)\n              return (\n                <div key={i} className=\"flex min-w-0 flex-col\">\n                  {caption(m, i)}\n                  <MonthGrid\n                    month={m}\n                    weekStartsOn={weekStartsOn}\n                    render={renderDay}\n                    head={head}\n                    weekNumbers={weekNumbers}\n                    hideOutside={shown > 1}\n                    labelledBy={`${uid}-cap-${i}`}\n                    fmtWeek={intl.num}\n                    weekLabel={l.weekNumber}\n                    onKeyDown={onGridKey}\n                    onPointerLeave={() => setHover(null)}\n                    rowClass={s.grid}\n                  />\n                </div>\n              )\n            })}\n          </motion.div>\n        </AnimatePresence>\n      ) : (\n        // Before mount there is no \"today\" to show; keep the space so nothing jumps.\n        <div aria-hidden=\"true\" className=\"flex gap-6\">\n          {Array.from({ length: shown }, (_, i) => (\n            <div key={i} className=\"flex flex-col\">\n              <div className=\"mb-2 h-8\" />\n              <div className={cn(\"grid\", weekNumbers ? \"grid-cols-8\" : \"grid-cols-7\")}>\n                {Array.from({ length: (weekNumbers ? 8 : 7) * 7 }, (_, k) => (\n                  <span key={k} className={cn(s.cell, \"m-px\")} />\n                ))}\n              </div>\n            </div>\n          ))}\n        </div>\n      )}\n    </div>\n  )\n\n  const timeRow = time && mode !== \"multiple\" && (\n    <div className={cn(\"flex flex-wrap items-center gap-3 border-t\", s.pad, \"py-2.5\")}>\n      {(mode === \"single\" ? [[\"single\", l.time]] : [[\"from\", l.startTime], [\"to\", l.endTime]]).map(([key, label]) => {\n        const val =\n          key === \"single\" ? (single ? hhmm(single) : singleTime) : key === \"from\" ? (range ? hhmm(range.from) : rangeTime.from) : range?.to ? hhmm(range.to) : rangeTime.to\n        return (\n          <label key={key} className=\"flex items-center gap-2 text-sm\">\n            <span className=\"pc-dp-muted\">{label}</span>\n            <input\n              type=\"time\"\n              step={minuteStep * 60}\n              value={val}\n              onChange={(e) => {\n                const v = e.target.value\n                if (!v) return\n                if (key === \"single\") {\n                  setSingleTime(v)\n                  if (single) commit(withTime(single, v))\n                } else if (key === \"from\") {\n                  setRangeTime((r) => ({ ...r, from: v }))\n                  if (range) commit({ ...range, from: withTime(range.from, v) })\n                } else {\n                  setRangeTime((r) => ({ ...r, to: v }))\n                  if (range?.to) commit({ ...range, to: withTime(range.to, v) })\n                }\n              }}\n              className=\"pc-dp-time h-8 rounded-md px-2 text-sm tabular-nums\"\n            />\n          </label>\n        )\n      })}\n    </div>\n  )\n\n  const presetList = presets.length > 0 && (\n    <div role=\"group\" aria-label={l.presets} className={cn(\"flex gap-1 overflow-x-auto border-b p-2 sm:flex-col sm:overflow-visible sm:border-e sm:border-b-0\", size === \"lg\" ? \"sm:w-40\" : \"sm:w-36\")}>\n      {presets.map((pr) => (\n        <button\n          key={pr.label}\n          type=\"button\"\n          aria-pressed={presetActive(pr)}\n          onClick={() => applyPreset(pr)}\n          className=\"pc-press pc-dp-chip shrink-0 rounded-md px-2.5 py-1.5 text-start text-sm whitespace-nowrap outline-none\"\n        >\n          {pr.label}\n        </button>\n      ))}\n    </div>\n  )\n\n  const footer = !inline && (time || mode === \"multiple\") && (\n    <div className=\"flex items-center justify-end gap-2 border-t px-3 py-2\">\n      <button type=\"button\" onClick={() => commit(mode === \"multiple\" ? [] : null)} className=\"pc-press pc-dp-foot rounded-md px-3 py-1.5 text-sm outline-none\">\n        {l.clear}\n      </button>\n      <button type=\"button\" data-primary=\"\" onClick={() => close()} className=\"pc-press pc-dp-foot rounded-md px-3 py-1.5 text-sm font-medium outline-none\">\n        {l.done}\n      </button>\n    </div>\n  )\n\n  const panelBody = (\n    <div className=\"flex flex-col sm:flex-row\">\n      {presetList}\n      <div className=\"flex min-w-0 flex-col\">\n        {calendar}\n        {timeRow}\n        {footer}\n      </div>\n    </div>\n  )\n\n  // Keep Tab inside the dialog (APG: the date picker dialog is modal).\n  const trap = (e: React.KeyboardEvent<HTMLDivElement>) => {\n    if (e.key === \"Escape\") {\n      e.preventDefault()\n      e.stopPropagation()\n      if (view !== \"days\") setView(\"days\")\n      else close()\n      return\n    }\n    if (e.key !== \"Tab\" || !surface.current) return\n    const items = Array.from(surface.current.querySelectorAll<HTMLElement>(\"button:not(:disabled), input, [tabindex='0']\")).filter((el) => el.tabIndex >= 0 && !el.closest(\"[inert]\"))\n    if (!items.length) return\n    const first = items[0]!\n    const last = items[items.length - 1]!\n    if (e.shiftKey && document.activeElement === first) {\n      e.preventDefault()\n      last.focus()\n    } else if (!e.shiftKey && document.activeElement === last) {\n      e.preventDefault()\n      first.focus()\n    }\n  }\n\n  const style = (\n    <>\n      <GooduiTokens />\n      <style href=\"pc-date-picker\" precedence=\"default\">\n        {CSS}\n      </style>\n    </>\n  )\n  const dataAttrs = {\n    \"data-variant\": variant,\n    \"data-tone\": tone,\n    \"data-sel\": selection,\n    \"data-shadow\": variant === \"neo\" ? \"none\" : shadow,\n  }\n  const hidden =\n    name &&\n    (() => {\n      const f = (d: Date) => (time ? `${iso(d)}T${hhmm(d)}` : iso(d))\n      if (mode === \"single\") return <input type=\"hidden\" name={name} value={single ? f(single) : \"\"} />\n      if (mode === \"range\")\n        return (\n          <>\n            <input type=\"hidden\" name={`${name}From`} value={range ? f(range.from) : \"\"} />\n            <input type=\"hidden\" name={`${name}To`} value={range?.to ? f(range.to) : \"\"} />\n          </>\n        )\n      return multi.map((d) => <input key={iso(d)} type=\"hidden\" name={name} value={f(d)} />)\n    })()\n\n  if (inline) {\n    return (\n      <>\n        {style}\n        <div\n          {...rest}\n          ref={root}\n          role=\"group\"\n          aria-label={ariaLabel ?? l.dialog}\n          data-slot=\"date-picker\"\n          data-inline=\"\"\n          {...dataAttrs}\n          className={cn(\"pc-dp inline-block max-w-full\", disabled && \"pointer-events-none opacity-55\", className)}\n        >\n          <div className={cn(\"pc-dp-surface max-w-full overflow-hidden\", SURFACE_RADIUS[variant])}>{panelBody}</div>\n          {hidden}\n        </div>\n      </>\n    )\n  }\n\n  const motionIn = reduce\n    ? { initial: { opacity: 0 }, animate: { opacity: 1 } }\n    : animation === \"none\"\n      ? { initial: false as const, animate: { opacity: 1 } }\n      : animation === \"fade\"\n        ? { initial: { opacity: 0 }, animate: { opacity: 1 } }\n        : animation === \"scale\"\n          ? { initial: { opacity: 0, scale: 0.95 }, animate: { opacity: 1, scale: 1 } }\n          : { initial: { opacity: 0, y: p?.side === \"top\" ? 8 : -8 }, animate: { opacity: 1, y: 0 } }\n  const surfaceClass = cn(\"pc-dp-surface max-w-[calc(100vw-16px)] overflow-auto overscroll-contain outline-none\", SURFACE_RADIUS[variant])\n  const surfaceProps = {\n    ref: surface,\n    id: dialogId,\n    role: \"dialog\",\n    \"aria-modal\": true,\n    \"aria-label\": l.dialog,\n    onKeyDown: trap,\n    style: { maxHeight: p?.maxH, transformOrigin: `${p?.side === \"top\" ? \"bottom\" : \"top\"} ${rtl ? \"right\" : \"left\"}` },\n    className: surfaceClass,\n  }\n\n  return (\n    <>\n      {style}\n      <div\n        {...rest}\n        ref={root}\n        data-slot=\"date-picker\"\n        {...dataAttrs}\n        data-open={open ? \"\" : undefined}\n        data-invalid={invalid || bad ? \"\" : undefined}\n        className={cn(\"pc-dp relative w-72 max-w-full\", disabled && \"pointer-events-none opacity-55\", className)}\n      >\n        <div ref={field} className={cn(\"pc-dp-field flex w-full items-center py-1\", s.field, s.icon, RADIUS[variant])}>\n          <input\n            ref={input}\n            id={inputId}\n            type=\"text\"\n            autoComplete=\"off\"\n            spellCheck={false}\n            aria-label={ariaLabel}\n            aria-invalid={invalid || bad || undefined}\n            aria-describedby={bad ? uid + \"-err\" : undefined}\n            disabled={disabled}\n            placeholder={fmtPlaceholder}\n            value={fieldText}\n            onChange={(e) => {\n              setText(e.target.value)\n              setBad(false)\n            }}\n            onBlur={commitText}\n            onKeyDown={(e) => {\n              if (e.key === \"Enter\") {\n                e.preventDefault()\n                commitText()\n              } else if (e.key === \"ArrowDown\" && (e.altKey || !text)) {\n                e.preventDefault()\n                commitText()\n                openDialog(input.current)\n              } else if (e.key === \"Escape\" && text !== null) {\n                e.preventDefault()\n                setText(null)\n                setBad(false)\n              }\n            }}\n            className=\"pc-dp-input h-7 min-w-0 flex-1 bg-transparent tabular-nums outline-none disabled:cursor-not-allowed\"\n          />\n          {bad && (\n            <span id={uid + \"-err\"} role=\"alert\" className=\"sr-only\">\n              {l.invalid}\n            </span>\n          )}\n          {clearable && (display || text) && !disabled && (\n            <button\n              type=\"button\"\n              aria-label={l.clear}\n              onClick={() => {\n                setText(null)\n                setBad(false)\n                commit(mode === \"multiple\" ? [] : null)\n                input.current?.focus()\n              }}\n              className=\"pc-press pc-dp-muted grid size-6 shrink-0 place-items-center rounded-md outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50\"\n            >\n              <Cross className=\"!size-3.5\" />\n            </button>\n          )}\n          <button\n            ref={button}\n            type=\"button\"\n            aria-label={l.openCalendar}\n            aria-haspopup=\"dialog\"\n            aria-expanded={open}\n            aria-controls={open ? dialogId : undefined}\n            disabled={disabled}\n            onClick={() => (open ? close() : openDialog(button.current))}\n            className=\"pc-press pc-dp-muted -me-1 grid size-7 shrink-0 place-items-center rounded-md outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50\"\n          >\n            <CalendarIcon className=\"!size-4\" />\n          </button>\n        </div>\n        {hidden}\n      </div>\n      {mounted &&\n        createPortal(\n          <AnimatePresence>\n            {open && (\n              <div key=\"dp\" {...dataAttrs} className=\"pc-dp fixed z-50\" style={{ left: p?.x ?? 0, top: p?.y ?? 0, visibility: p ? undefined : \"hidden\" }}>\n                {p ? (\n                  <motion.div {...surfaceProps} {...motionIn} exit={{ opacity: 0, transition: { duration: reduce || animation === \"none\" ? 0 : 0.12 } }} transition={reduce ? { duration: 0.12 } : t}>\n                    {panelBody}\n                  </motion.div>\n                ) : (\n                  <div {...surfaceProps}>{panelBody}</div>\n                )}\n              </div>\n            )}\n          </AnimatePresence>,\n          document.body,\n        )}\n    </>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/goodui/date-picker.tsx"
    }
  ],
  "categories": [
    "components",
    "core"
  ],
  "type": "registry:component"
}