{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"timezone-picker","type":"registry:component","title":"Timezone picker","description":"A searchable IANA timezone picker with live local clocks, exact UTC offset deltas, a spring-driven 24-hour daylight hairline and one-click Detect.","author":"Hairline UI","dependencies":["lucide-react"],"registryDependencies":["https://hairlineui.com/r/text-morph.json?as=dependency"],"files":[{"path":"registry/timezone-picker.tsx","type":"registry:component","content":"// Hairline UI · timezone-picker · MIT License\n// Copyright (c) 2026 Hairline UI · https://hairlineui.com/license#components\n\n\"use client\";\n\nimport * as React from \"react\";\nimport {\n  Check,\n  ChevronDown,\n  Clock,\n  Globe,\n  LocateFixed,\n  Moon,\n  Search,\n  Sun,\n  Sunrise,\n  X,\n} from \"lucide-react\";\nimport {\n  INTERACTION_FOCUS,\n  INTERACTION_PRESS,\n  createSpring,\n  interactionIcon,\n  useInteractionReducedMotion,\n  type Spring,\n} from \"./ui-interaction-motion\";\nimport { TextMorph } from \"./text-morph\";\nimport { playSound } from \"./ui-sounds\";\n\n/* ─────────────────────────────────────────────────────────\n * TIMEZONE PICKER: searchable IANA selector with solar hairline\n *\n *   horizon   a 24-hour daylight hairline sits across the picker,\n *             shading night, twilight and daylight bands with a\n *             subtle 09:00–17:00 working-hours mark; a spring-driven\n *             time needle glides smoothly to each highlighted city's\n *             exact local solar hour as you hover or arrow-key\n *\n *   live      uses native Intl.DateTimeFormat with zero timezone\n *             data bloat: live local clocks, accurate DST-aware UTC\n *             offsets, exact +/-Xh delta against your local browser\n *             timezone and instant one-tap Detect\n * ───────────────────────────────────────────────────────── */\n\nexport interface TimezoneEntry {\n  /** Canonical IANA identifier (e.g. \"America/New_York\", \"Asia/Kolkata\"). */\n  iana: string;\n  /** Primary city or label (e.g. \"New York\", \"Bengaluru / Mumbai\"). */\n  city: string;\n  /** Country or region label. */\n  region: string;\n  /** Extra search terms (aliases, airport codes, alternate city names). */\n  keywords?: string[];\n}\n\nexport interface TimezoneInfo {\n  iana: string;\n  offsetMinutes: number;\n  offsetLabel: string; // e.g. \"UTC+05:30\" or \"UTC-05:00\"\n  abbr: string;        // e.g. \"IST\", \"EST\", \"GMT\"\n  timeText: string;    // e.g. \"11:15 AM\" or \"11:15\"\n  hourFloat: number;   // 0..24 local solar hour\n  phase: \"day\" | \"twilight\" | \"night\";\n  inWorkHours: boolean;\n}\n\nexport interface TimezonePickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"defaultValue\" | \"onChange\"> {\n  /** Controlled IANA timezone string (e.g. \"Europe/London\"). */\n  value?: string;\n  /** Initial uncontrolled IANA timezone string (defaults to browser local timezone). */\n  defaultValue?: string;\n  /** Called when the user selects a timezone. */\n  onChange?: (iana: string, info: TimezoneInfo) => void;\n  /** Presentation mode: compact form trigger with popover, or always-open inline panel. */\n  variant?: \"popover\" | \"inline\";\n  /** Optional custom list of timezones (defaults to curated 42-city global IANA table). */\n  zones?: TimezoneEntry[];\n  /** Use 12-hour clock format (default false -> 24-hour crisp monospace). */\n  hour12?: boolean;\n  /** Show relative +/-Xh difference from the user's browser timezone (default true). */\n  showDiff?: boolean;\n  /** Show the 24-hour solar daylight hairline bar (default true). */\n  showHorizon?: boolean;\n  /** Show the one-click \"Detect\" local timezone button (default true). */\n  allowDetect?: boolean;\n  /** Accessible label (default \"Timezone\"). */\n  label?: string;\n  /** Placeholder when value is empty. */\n  placeholder?: string;\n  /** Disabled state. */\n  disabled?: boolean;\n  /** Opt-in Web Audio ticks (from ui-sounds.ts). */\n  sound?: boolean;\n}\n\nexport const COMMON_TIMEZONES: TimezoneEntry[] = [\n  { iana: \"Pacific/Honolulu\", city: \"Honolulu\", region: \"United States\", keywords: [\"hawaii\", \"hst\"] },\n  { iana: \"America/Anchorage\", city: \"Anchorage\", region: \"United States\", keywords: [\"alaska\", \"akst\"] },\n  { iana: \"America/Los_Angeles\", city: \"San Francisco\", region: \"United States\", keywords: [\"los angeles\", \"seattle\", \"pacific\", \"pst\", \"pdt\", \"sfo\", \"lax\"] },\n  { iana: \"America/Vancouver\", city: \"Vancouver\", region: \"Canada\", keywords: [\"pacific\", \"pst\", \"pdt\", \"yvr\"] },\n  { iana: \"America/Denver\", city: \"Denver\", region: \"United States\", keywords: [\"mountain\", \"mst\", \"mdt\", \"salt lake\"] },\n  { iana: \"America/Phoenix\", city: \"Phoenix\", region: \"United States\", keywords: [\"arizona\", \"mst\"] },\n  { iana: \"America/Chicago\", city: \"Chicago\", region: \"United States\", keywords: [\"central\", \"cst\", \"cdt\", \"austin\", \"dallas\"] },\n  { iana: \"America/Mexico_City\", city: \"Mexico City\", region: \"Mexico\", keywords: [\"cdmx\", \"cst\"] },\n  { iana: \"America/New_York\", city: \"New York\", region: \"United States\", keywords: [\"eastern\", \"est\", \"edt\", \"boston\", \"miami\", \"nyc\"] },\n  { iana: \"America/Toronto\", city: \"Toronto\", region: \"Canada\", keywords: [\"eastern\", \"est\", \"edt\", \"montreal\", \"yyz\"] },\n  { iana: \"America/Bogota\", city: \"Bogota\", region: \"Colombia\", keywords: [\"lima\", \"cot\"] },\n  { iana: \"America/Santiago\", city: \"Santiago\", region: \"Chile\", keywords: [\"clt\"] },\n  { iana: \"America/Sao_Paulo\", city: \"Sao Paulo\", region: \"Brazil\", keywords: [\"rio\", \"brt\", \"gru\"] },\n  { iana: \"America/Argentina/Buenos_Aires\", city: \"Buenos Aires\", region: \"Argentina\", keywords: [\"art\", \"eze\"] },\n  { iana: \"Atlantic/Reykjavik\", city: \"Reykjavik\", region: \"Iceland\", keywords: [\"gmt\", \"utc\"] },\n  { iana: \"UTC\", city: \"UTC\", region: \"Coordinated Universal Time\", keywords: [\"gmt\", \"zulu\", \"universal\"] },\n  { iana: \"Europe/London\", city: \"London\", region: \"United Kingdom\", keywords: [\"uk\", \"gmt\", \"bst\", \"lhr\", \"dublin\"] },\n  { iana: \"Europe/Lisbon\", city: \"Lisbon\", region: \"Portugal\", keywords: [\"wet\", \"west\"] },\n  { iana: \"Europe/Paris\", city: \"Paris\", region: \"France\", keywords: [\"cet\", \"cest\", \"cdg\"] },\n  { iana: \"Europe/Berlin\", city: \"Berlin\", region: \"Germany\", keywords: [\"cet\", \"cest\", \"munich\", \"frankfurt\"] },\n  { iana: \"Europe/Amsterdam\", city: \"Amsterdam\", region: \"Netherlands\", keywords: [\"cet\", \"cest\", \"ams\"] },\n  { iana: \"Europe/Zurich\", city: \"Zurich\", region: \"Switzerland\", keywords: [\"geneva\", \"cet\", \"cest\"] },\n  { iana: \"Europe/Madrid\", city: \"Madrid\", region: \"Spain\", keywords: [\"barcelona\", \"cet\", \"cest\"] },\n  { iana: \"Europe/Stockholm\", city: \"Stockholm\", region: \"Sweden\", keywords: [\"oslo\", \"copenhagen\", \"cet\"] },\n  { iana: \"Europe/Warsaw\", city: \"Warsaw\", region: \"Poland\", keywords: [\"prague\", \"cet\", \"cest\"] },\n  { iana: \"Africa/Lagos\", city: \"Lagos\", region: \"Nigeria\", keywords: [\"wat\"] },\n  { iana: \"Africa/Johannesburg\", city: \"Johannesburg\", region: \"South Africa\", keywords: [\"cape town\", \"sast\"] },\n  { iana: \"Africa/Cairo\", city: \"Cairo\", region: \"Egypt\", keywords: [\"eet\"] },\n  { iana: \"Europe/Athens\", city: \"Athens\", region: \"Greece\", keywords: [\"helsinki\", \"bucharest\", \"eet\", \"eest\"] },\n  { iana: \"Europe/Istanbul\", city: \"Istanbul\", region: \"Turkey\", keywords: [\"trt\"] },\n  { iana: \"Asia/Riyadh\", city: \"Riyadh\", region: \"Saudi Arabia\", keywords: [\"ast\", \"nairobi\"] },\n  { iana: \"Asia/Dubai\", city: \"Dubai\", region: \"United Arab Emirates\", keywords: [\"uae\", \"abu dhabi\", \"gst\", \"dxb\"] },\n  { iana: \"Asia/Karachi\", city: \"Karachi\", region: \"Pakistan\", keywords: [\"lahore\", \"pkt\"] },\n  { iana: \"Asia/Kolkata\", city: \"Bengaluru / Mumbai\", region: \"India\", keywords: [\"india\", \"delhi\", \"kolkata\", \"calcutta\", \"ist\", \"blr\", \"bom\"] },\n  { iana: \"Asia/Kathmandu\", city: \"Kathmandu\", region: \"Nepal\", keywords: [\"npt\"] },\n  { iana: \"Asia/Dhaka\", city: \"Dhaka\", region: \"Bangladesh\", keywords: [\"bst\"] },\n  { iana: \"Asia/Bangkok\", city: \"Bangkok\", region: \"Thailand\", keywords: [\"jakarta\", \"ho chi minh\", \"ict\"] },\n  { iana: \"Asia/Singapore\", city: \"Singapore\", region: \"Singapore\", keywords: [\"sgt\", \"sin\", \"kuala lumpur\"] },\n  { iana: \"Asia/Hong_Kong\", city: \"Hong Kong\", region: \"China\", keywords: [\"hkt\", \"shanghai\", \"beijing\", \"taipei\", \"cst\"] },\n  { iana: \"Asia/Tokyo\", city: \"Tokyo\", region: \"Japan\", keywords: [\"osaka\", \"jst\", \"tyo\", \"hnd\"] },\n  { iana: \"Asia/Seoul\", city: \"Seoul\", region: \"South Korea\", keywords: [\"korea\", \"kst\", \"icn\"] },\n  { iana: \"Australia/Adelaide\", city: \"Adelaide\", region: \"Australia\", keywords: [\"acst\", \"acdt\"] },\n  { iana: \"Australia/Sydney\", city: \"Sydney\", region: \"Australia\", keywords: [\"melbourne\", \"aest\", \"aedt\", \"syd\"] },\n  { iana: \"Pacific/Auckland\", city: \"Auckland\", region: \"New Zealand\", keywords: [\"wellington\", \"nzst\", \"nzdt\"] },\n];\n\nconst IANA_ALIASES: Record<string, string> = {\n  \"Asia/Calcutta\": \"Asia/Kolkata\",\n  \"Asia/Saigon\": \"Asia/Bangkok\",\n  \"Asia/Katmandu\": \"Asia/Kathmandu\",\n  \"Europe/Kiev\": \"Europe/Kyiv\",\n  \"US/Eastern\": \"America/New_York\",\n  \"US/Central\": \"America/Chicago\",\n  \"US/Mountain\": \"America/Denver\",\n  \"US/Pacific\": \"America/Los_Angeles\",\n  \"Etc/UTC\": \"UTC\",\n  \"Etc/GMT\": \"UTC\",\n};\n\nexport function detectLocalTimezone(): string {\n  try {\n    const raw = Intl.DateTimeFormat().resolvedOptions().timeZone || \"UTC\";\n    return IANA_ALIASES[raw] ?? raw;\n  } catch {\n    return \"UTC\";\n  }\n}\n\nfunction parseOffsetMinutes(iana: string, now: Date): number {\n  try {\n    // Compute exact offset by formatting UTC parts vs local zone parts\n    const fmt = new Intl.DateTimeFormat(\"en-US\", {\n      timeZone: iana,\n      year: \"numeric\",\n      month: \"2-digit\",\n      day: \"2-digit\",\n      hour: \"2-digit\",\n      minute: \"2-digit\",\n      second: \"2-digit\",\n      hourCycle: \"h23\",\n    });\n    const parts = fmt.formatToParts(now);\n    const get = (t: string) => Number(parts.find((p) => p.type === t)?.value ?? 0);\n    const asUtc = Date.UTC(get(\"year\"), get(\"month\") - 1, get(\"day\"), get(\"hour\"), get(\"minute\"), get(\"second\"));\n    const utcTrunc = Math.floor(now.getTime() / 1000) * 1000;\n    return Math.round((asUtc - utcTrunc) / 60000);\n  } catch {\n    return 0;\n  }\n}\n\nfunction formatUtcOffset(offsetMinutes: number): string {\n  const sign = offsetMinutes >= 0 ? \"+\" : \"-\";\n  const abs = Math.abs(offsetMinutes);\n  const hh = String(Math.floor(abs / 60)).padStart(2, \"0\");\n  const mm = String(abs % 60).padStart(2, \"0\");\n  return `UTC${sign}${hh}:${mm}`;\n}\n\nexport function getTimezoneInfo(iana: string, now = new Date(), hour12 = false): TimezoneInfo {\n  const offsetMinutes = parseOffsetMinutes(iana, now);\n  const offsetLabel = formatUtcOffset(offsetMinutes);\n\n  let abbr = offsetLabel;\n  let timeText = \"00:00\";\n  let hourFloat = 12;\n\n  try {\n    const abbrParts = new Intl.DateTimeFormat(\"en-US\", {\n      timeZone: iana,\n      timeZoneName: \"short\",\n    }).formatToParts(now);\n    const tzName = abbrParts.find((p) => p.type === \"timeZoneName\")?.value;\n    if (tzName) abbr = tzName;\n\n    timeText = new Intl.DateTimeFormat(\"en-US\", {\n      timeZone: iana,\n      hour: \"2-digit\",\n      minute: \"2-digit\",\n      hour12,\n    }).format(now);\n\n    const hmParts = new Intl.DateTimeFormat(\"en-US\", {\n      timeZone: iana,\n      hour: \"2-digit\",\n      minute: \"2-digit\",\n      hourCycle: \"h23\",\n    }).formatToParts(now);\n    const h = Number(hmParts.find((p) => p.type === \"hour\")?.value ?? 12);\n    const m = Number(hmParts.find((p) => p.type === \"minute\")?.value ?? 0);\n    hourFloat = (h % 24) + m / 60;\n  } catch {\n    // Fallback to UTC defaults\n  }\n\n  const phase: TimezoneInfo[\"phase\"] =\n    hourFloat >= 7.5 && hourFloat < 18\n      ? \"day\"\n      : (hourFloat >= 5.5 && hourFloat < 7.5) || (hourFloat >= 18 && hourFloat < 20.5)\n        ? \"twilight\"\n        : \"night\";\n\n  const inWorkHours = hourFloat >= 9 && hourFloat < 17;\n\n  return {\n    iana,\n    offsetMinutes,\n    offsetLabel,\n    abbr,\n    timeText,\n    hourFloat,\n    phase,\n    inWorkHours,\n  };\n}\n\nexport function formatOffsetDiff(targetOffsetMin: number, localOffsetMin: number, isSameIana = false): string {\n  const diffMin = targetOffsetMin - localOffsetMin;\n  if (diffMin === 0) return isSameIana ? \"Local\" : \"Same time\";\n  const sign = diffMin > 0 ? \"+\" : \"-\";\n  const abs = Math.abs(diffMin);\n  const hours = abs / 60;\n  if (abs % 60 === 0) return `${sign}${hours}h`;\n  if (abs % 30 === 0) return `${sign}${hours.toFixed(1)}h`;\n  return `${sign}${Math.floor(abs / 60)}h${abs % 60}m`;\n}\n\nfunction humanizeIana(iana: string): TimezoneEntry {\n  const parts = iana.split(\"/\");\n  const city = (parts[parts.length - 1] ?? iana).replace(/_/g, \" \");\n  const region = parts.length > 1 ? parts[0].replace(/_/g, \" \") : \"Timezone\";\n  return { iana, city, region };\n}\n\nfunction PhaseIcon({ phase, className = \"size-3.5\" }: { phase: TimezoneInfo[\"phase\"]; className?: string }) {\n  if (phase === \"day\") {\n    return <Sun className={`${className} text-amber-500`} strokeWidth={2} />;\n  }\n  if (phase === \"twilight\") {\n    return <Sunrise className={`${className} text-orange-500/85`} strokeWidth={2} />;\n  }\n  return <Moon className={`${className} text-indigo-400`} strokeWidth={2} />;\n}\n\n/** 24-hour solar daylight hairline with spring-driven local hour cursor needle. */\nfunction DaylightHorizon({\n  info,\n  city,\n  diffLabel,\n  reduced,\n}: {\n  info: TimezoneInfo;\n  city: string;\n  diffLabel?: string;\n  reduced: boolean;\n}) {\n  const needleRef = React.useRef<HTMLDivElement | null>(null);\n  const currentPctRef = React.useRef((info.hourFloat / 24) * 100);\n  const springRef = React.useRef<Spring | null>(null);\n\n  React.useEffect(() => {\n    const targetPct = Math.max(0, Math.min(100, (info.hourFloat / 24) * 100));\n    springRef.current?.stop();\n    const el = needleRef.current;\n    if (!el) return;\n\n    if (reduced) {\n      currentPctRef.current = targetPct;\n      el.style.left = `${targetPct.toFixed(2)}%`;\n      return;\n    }\n\n    const sp = createSpring(\n      currentPctRef.current,\n      { stiffness: 310, damping: 26 },\n      () => {\n        const v = sp.get();\n        currentPctRef.current = v;\n        if (needleRef.current) needleRef.current.style.left = `${v.toFixed(2)}%`;\n      },\n      0.05,\n    );\n    sp.set(targetPct);\n    springRef.current = sp;\n    return () => sp.stop();\n  }, [info.hourFloat, reduced]);\n\n  return (\n    <div className=\"border-b border-border/80 bg-muted/20 px-3 py-2.5\" data-daylight-horizon=\"true\">\n      <div className=\"mb-1.5 flex items-center justify-between gap-2 text-[11px]\">\n        <div className=\"flex min-w-0 items-center gap-1.5\">\n          <PhaseIcon phase={info.phase} className=\"size-3 shrink-0\" />\n          <span className=\"truncate font-medium text-foreground\">\n            <TextMorph>{city}</TextMorph>\n          </span>\n          <span className=\"font-mono text-[10.5px] text-muted-foreground\">\n            <TextMorph>{info.offsetLabel}</TextMorph>\n          </span>\n        </div>\n        <div className=\"flex shrink-0 items-center gap-1.5 font-mono tabular-nums\">\n          <span className=\"font-semibold text-foreground\">\n            <TextMorph duration={360}>{info.timeText}</TextMorph>\n          </span>\n          {diffLabel && (\n            <span className=\"rounded-[5px] border border-border/80 bg-background px-1.5 py-0 text-[10px] text-muted-foreground\">\n              <TextMorph>{diffLabel}</TextMorph>\n            </span>\n          )}\n        </div>\n      </div>\n\n      {/* 24-hour solar daylight strip: night -> dawn -> daylight (with 09–17 work tint) -> dusk -> night */}\n      <div className=\"relative h-3 w-full\">\n        <div\n          aria-hidden=\"true\"\n          className=\"absolute inset-x-0 top-1/2 h-[4px] -translate-y-1/2 overflow-hidden rounded-full border border-border/60\"\n          style={{\n            background:\n              \"linear-gradient(90deg, rgba(99,102,241,0.22) 0%, rgba(99,102,241,0.18) 22%, rgba(245,158,11,0.38) 28%, rgba(251,191,36,0.45) 50%, rgba(249,115,22,0.36) 76%, rgba(99,102,241,0.2) 84%, rgba(99,102,241,0.22) 100%)\",\n          }}\n        >\n          {/* 09:00–17:00 business-hours hairline segment (37.5% to 70.83%) */}\n          <div\n            className=\"absolute inset-y-0 border-x border-foreground/30 bg-foreground/[0.08]\"\n            style={{ left: \"37.5%\", width: \"33.33%\" }}\n          />\n        </div>\n\n        {/* Live spring-driven needle */}\n        <div\n          ref={needleRef}\n          aria-hidden=\"true\"\n          className=\"pointer-events-none absolute top-1/2 h-3 w-[2px] -translate-x-1/2 -translate-y-1/2 rounded-full bg-foreground shadow-[0_0_0_1.5px_var(--card)]\"\n          style={{ left: `${((info.hourFloat / 24) * 100).toFixed(2)}%` }}\n        />\n      </div>\n\n      <div className=\"mt-1 flex items-center justify-between font-mono text-[9.5px] tabular-nums text-muted-foreground/70\">\n        <span>00:00</span>\n        <span>06:00</span>\n        <span>12:00</span>\n        <span>18:00</span>\n        <span>24:00</span>\n      </div>\n    </div>\n  );\n}\n\nconst noopSubscribe = () => () => {};\nconst useHydrated = () => React.useSyncExternalStore(noopSubscribe, () => true, () => false);\nconst SSR_EPOCH = new Date(Date.UTC(2026, 0, 1, 12, 0, 0));\n\n/** Minute-aligned live clock tick, deterministic during SSR/hydration so visitor timezones never trigger #418. */\nfunction useMinuteNow(hydrated: boolean): Date {\n  const [tickNow, setTickNow] = React.useState<Date | null>(null);\n  React.useEffect(() => {\n    if (!hydrated) return;\n    let intervalId = 0;\n    const raf = window.requestAnimationFrame(() => setTickNow(new Date()));\n    const msUntilNextMin = 60_000 - (Date.now() % 60_000) + 120;\n    const timeoutId = window.setTimeout(() => {\n      setTickNow(new Date());\n      intervalId = window.setInterval(() => setTickNow(new Date()), 60_000);\n    }, msUntilNextMin);\n    return () => {\n      window.cancelAnimationFrame(raf);\n      window.clearTimeout(timeoutId);\n      window.clearInterval(intervalId);\n    };\n  }, [hydrated]);\n  return hydrated && tickNow ? tickNow : SSR_EPOCH;\n}\n\nexport function TimezonePicker({\n  value: controlledValue,\n  defaultValue,\n  onChange,\n  variant = \"popover\",\n  zones = COMMON_TIMEZONES,\n  hour12 = false,\n  showDiff = true,\n  showHorizon = true,\n  allowDetect = true,\n  label = \"Timezone\",\n  placeholder = \"Select timezone\",\n  disabled = false,\n  sound = false,\n  className = \"\",\n  ...props\n}: TimezonePickerProps) {\n  const reduced = useInteractionReducedMotion();\n  const hydrated = useHydrated();\n  const now = useMinuteNow(hydrated);\n  const localIana = React.useMemo(() => (hydrated ? detectLocalTimezone() : \"UTC\"), [hydrated]);\n  const localOffsetMin = React.useMemo(() => parseOffsetMinutes(localIana, now), [localIana, now]);\n\n  const [ownValue, setOwnValue] = React.useState<string | null>(() => defaultValue ?? null);\n  const selectedIana = controlledValue !== undefined ? controlledValue : (ownValue ?? localIana);\n\n  const [open, setOpen] = React.useState(variant === \"inline\");\n  const [query, setQuery] = React.useState(\"\");\n  const [activeIdx, setActiveIdx] = React.useState(() => {\n    const init = controlledValue ?? defaultValue ?? localIana;\n    const idx = zones.findIndex((z) => z.iana === init);\n    return idx >= 0 ? idx : 0;\n  });\n  const [detectedFlash, setDetectedFlash] = React.useState(false);\n\n  const rootRef = React.useRef<HTMLDivElement | null>(null);\n  const triggerRef = React.useRef<HTMLButtonElement | null>(null);\n  const searchRef = React.useRef<HTMLInputElement | null>(null);\n  const listRef = React.useRef<HTMLDivElement | null>(null);\n  const detectTimerRef = React.useRef(0);\n\n  React.useEffect(\n    () => () => {\n      window.clearTimeout(detectTimerRef.current);\n    },\n    [],\n  );\n\n  // Close popover on outside click / Escape\n  React.useEffect(() => {\n    if (variant === \"inline\" || !open) return;\n    const onDown = (e: MouseEvent) => {\n      if (rootRef.current && !rootRef.current.contains(e.target as Node)) setOpen(false);\n    };\n    const onKey = (e: KeyboardEvent) => {\n      if (e.key === \"Escape\") {\n        setOpen(false);\n        triggerRef.current?.focus();\n      }\n    };\n    document.addEventListener(\"mousedown\", onDown);\n    document.addEventListener(\"keydown\", onKey);\n    return () => {\n      document.removeEventListener(\"mousedown\", onDown);\n      document.removeEventListener(\"keydown\", onKey);\n    };\n  }, [open, variant]);\n\n  // Ensure both selectedIana and browser localIana exist in the browsable catalogue\n  const allEntries = React.useMemo(() => {\n    const map = new Map<string, TimezoneEntry>();\n    for (const z of zones) map.set(z.iana, z);\n    if (selectedIana && !map.has(selectedIana)) map.set(selectedIana, humanizeIana(selectedIana));\n    if (localIana && !map.has(localIana)) map.set(localIana, humanizeIana(localIana));\n    return Array.from(map.values()).map((entry) => ({\n      entry,\n      info: getTimezoneInfo(entry.iana, now, hour12),\n    }));\n  }, [zones, selectedIana, localIana, now, hour12]);\n\n  const filtered = React.useMemo(() => {\n    const q = query.trim().toLowerCase();\n    if (!q) return allEntries;\n    return allEntries.filter(({ entry, info }) => {\n      const hay = [\n        entry.city,\n        entry.region,\n        entry.iana,\n        entry.iana.replace(/_/g, \" \"),\n        info.abbr,\n        info.offsetLabel,\n        ...(entry.keywords ?? []),\n      ]\n        .join(\" \")\n        .toLowerCase();\n      return hay.includes(q);\n    });\n  }, [allEntries, query]);\n\n  const selectedRecord = React.useMemo(\n    () => allEntries.find((r) => r.entry.iana === selectedIana) ?? allEntries[0],\n    [allEntries, selectedIana],\n  );\n\n  const clampedIdx = filtered.length > 0 ? Math.min(activeIdx, filtered.length - 1) : 0;\n  const previewRecord = filtered[clampedIdx] ?? selectedRecord;\n\n  const commitSelection = React.useCallback(\n    (iana: string, info: TimezoneInfo) => {\n      if (controlledValue === undefined) setOwnValue(iana);\n      onChange?.(iana, info);\n      if (sound) playSound(\"tick\", 0.3);\n      if (variant === \"popover\") {\n        setOpen(false);\n        setQuery(\"\");\n      }\n    },\n    [controlledValue, onChange, sound, variant],\n  );\n\n  const handleDetectLocal = () => {\n    const detected = detectLocalTimezone();\n    const info = getTimezoneInfo(detected, now, hour12);\n    if (controlledValue === undefined) setOwnValue(detected);\n    onChange?.(detected, info);\n    setQuery(\"\");\n    setDetectedFlash(true);\n    if (sound) playSound(\"success\", 0.34);\n    window.clearTimeout(detectTimerRef.current);\n    detectTimerRef.current = window.setTimeout(() => setDetectedFlash(false), 1600);\n  };\n\n  const handleOpenPopover = () => {\n    if (disabled) return;\n    setOpen((prev) => {\n      const next = !prev;\n      if (next) {\n        setQuery(\"\");\n        const idx = allEntries.findIndex((r) => r.entry.iana === selectedIana);\n        setActiveIdx(idx >= 0 ? idx : 0);\n        window.requestAnimationFrame(() => searchRef.current?.focus());\n      }\n      return next;\n    });\n  };\n\n  const handleListKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n    if (filtered.length === 0) return;\n    if (e.key === \"ArrowDown\") {\n      e.preventDefault();\n      setActiveIdx((i) => (i + 1) % filtered.length);\n    } else if (e.key === \"ArrowUp\") {\n      e.preventDefault();\n      setActiveIdx((i) => (i - 1 + filtered.length) % filtered.length);\n    } else if (e.key === \"Home\") {\n      e.preventDefault();\n      setActiveIdx(0);\n    } else if (e.key === \"End\") {\n      e.preventDefault();\n      setActiveIdx(filtered.length - 1);\n    } else if (e.key === \"Enter\") {\n      e.preventDefault();\n      const chosen = filtered[clampedIdx];\n      if (chosen) commitSelection(chosen.entry.iana, chosen.info);\n    }\n  };\n\n  const panelBody = (\n    <div\n      className={`flex w-full flex-col overflow-hidden rounded-[14px] border border-border bg-card text-card-foreground shadow-[inset_0_0.5px_0_rgb(255_255_255/0.75)] dark:shadow-[inset_0_0.5px_0_rgb(255_255_255/0.06)] ${\n        variant === \"popover\" ? \"shadow-[0_14px_38px_-10px_rgb(0_0_0/0.26)] dark:shadow-[0_16px_42px_-10px_rgb(0_0_0/0.62)]\" : \"\"\n      }`}\n    >\n      {/* Search + Detect bar */}\n      <div className=\"flex items-center gap-1.5 border-b border-border/80 px-2.5 py-2\">\n        <Search className=\"size-3.5 shrink-0 text-muted-foreground\" strokeWidth={2} />\n        <input\n          ref={searchRef}\n          type=\"text\"\n          role=\"combobox\"\n          aria-expanded={variant === \"inline\" ? true : open}\n          aria-controls=\"tz-listbox\"\n          aria-label=\"Search city, timezone or UTC offset\"\n          placeholder=\"Search city, IANA or UTC+5:30…\"\n          value={query}\n          onChange={(e) => {\n            setQuery(e.currentTarget.value);\n            setActiveIdx(0);\n          }}\n          onKeyDown={handleListKeyDown}\n          className=\"h-6 min-w-0 flex-1 bg-transparent text-[12.5px] text-foreground placeholder:text-muted-foreground/55 focus:outline-none\"\n        />\n        {query && (\n          <button\n            type=\"button\"\n            aria-label=\"Clear search\"\n            onClick={() => {\n              setQuery(\"\");\n              setActiveIdx(0);\n              searchRef.current?.focus();\n            }}\n            className=\"inline-flex size-5 cursor-pointer items-center justify-center rounded-[5px] text-muted-foreground hover:bg-accent hover:text-foreground\"\n          >\n            <X className=\"size-3\" strokeWidth={2} />\n          </button>\n        )}\n        {allowDetect && (\n          <button\n            type=\"button\"\n            onClick={handleDetectLocal}\n            title={`Use detected timezone (${localIana})`}\n            className={`inline-flex h-6 shrink-0 cursor-pointer items-center gap-1 rounded-[7px] border border-border bg-background px-2 text-[11px] font-medium hover:bg-accent ${\n              detectedFlash ? \"border-emerald-500/40 text-emerald-700 dark:text-emerald-300\" : \"text-muted-foreground hover:text-foreground\"\n            } ${INTERACTION_PRESS} ${INTERACTION_FOCUS}`}\n          >\n            <span className=\"relative flex size-3 shrink-0 items-center justify-center\">\n              <span aria-hidden=\"true\" className=\"absolute inset-0 flex items-center justify-center\" style={interactionIcon(!detectedFlash, reduced)}>\n                <LocateFixed className=\"size-3\" strokeWidth={2} />\n              </span>\n              <span aria-hidden=\"true\" className=\"absolute inset-0 flex items-center justify-center\" style={interactionIcon(detectedFlash, reduced)}>\n                <Check className=\"size-3\" strokeWidth={2.3} />\n              </span>\n            </span>\n            <TextMorph>{detectedFlash ? \"Detected\" : \"Detect\"}</TextMorph>\n          </button>\n        )}\n      </div>\n\n      {/* Signature 24-hour solar daylight hairline reacting to the highlighted row */}\n      {showHorizon && previewRecord && (\n        <DaylightHorizon\n          info={previewRecord.info}\n          city={previewRecord.entry.city}\n          diffLabel={\n            showDiff\n              ? formatOffsetDiff(previewRecord.info.offsetMinutes, localOffsetMin, previewRecord.entry.iana === localIana)\n              : undefined\n          }\n          reduced={reduced}\n        />\n      )}\n\n      {/* Virtual-clean scrollable listbox */}\n      <div\n        ref={listRef}\n        id=\"tz-listbox\"\n        role=\"listbox\"\n        aria-label={label}\n        className=\"max-h-[264px] overflow-y-auto p-1\"\n      >\n        {filtered.length === 0 ? (\n          <div className=\"flex flex-col items-center justify-center gap-1 py-7 text-center text-[12px] text-muted-foreground\">\n            <Globe className=\"size-4 opacity-50\" strokeWidth={1.8} />\n            <span>No timezones matching &ldquo;{query}&rdquo;</span>\n          </div>\n        ) : (\n          filtered.map(({ entry, info }, idx) => {\n            const isSelected = entry.iana === selectedIana;\n            const isActive = idx === clampedIdx;\n            const diff = showDiff ? formatOffsetDiff(info.offsetMinutes, localOffsetMin, entry.iana === localIana) : null;\n\n            return (\n              <button\n                key={entry.iana}\n                type=\"button\"\n                role=\"option\"\n                aria-selected={isSelected}\n                data-tz-option={entry.iana}\n                onMouseEnter={() => setActiveIdx(idx)}\n                onClick={() => commitSelection(entry.iana, info)}\n                className={`flex w-full cursor-pointer items-center justify-between gap-2.5 rounded-[9px] px-2.5 py-2 text-left transition-colors duration-75 ${\n                  isActive ? \"bg-accent text-foreground\" : \"text-foreground/90 hover:bg-accent/60\"\n                }`}\n              >\n                <div className=\"flex min-w-0 items-center gap-2\">\n                  <PhaseIcon phase={info.phase} className=\"size-3.5 shrink-0\" />\n                  <div className=\"min-w-0\">\n                    <div className=\"flex items-center gap-1.5\">\n                      <span className=\"truncate text-[12.5px] font-medium text-foreground\">{entry.city}</span>\n                      <span className=\"truncate text-[11px] text-muted-foreground\">{entry.region}</span>\n                    </div>\n                    <div className=\"flex items-center gap-1.5 font-mono text-[10.5px] text-muted-foreground/85\">\n                      <span>{entry.iana}</span>\n                      <span>·</span>\n                      <span>{info.offsetLabel}</span>\n                    </div>\n                  </div>\n                </div>\n\n                <div className=\"flex shrink-0 items-center gap-2\">\n                  <div className=\"text-right font-mono tabular-nums\">\n                    <div className=\"text-[12px] font-medium text-foreground\">{info.timeText}</div>\n                    {diff && <div className=\"text-[10px] text-muted-foreground\">{diff}</div>}\n                  </div>\n                  <span className=\"inline-flex size-4 items-center justify-center\">\n                    {isSelected && <Check className=\"size-3.5 text-foreground\" strokeWidth={2.3} />}\n                  </span>\n                </div>\n              </button>\n            );\n          })\n        )}\n      </div>\n    </div>\n  );\n\n  if (variant === \"inline\") {\n    return (\n      <div\n        ref={rootRef}\n        role=\"region\"\n        aria-label={label}\n        data-timezone={selectedIana}\n        className={`w-full max-w-[440px] ${className}`}\n        {...props}\n      >\n        {panelBody}\n      </div>\n    );\n  }\n\n  return (\n    <div\n      ref={rootRef}\n      data-timezone={selectedIana}\n      className={`relative w-full max-w-[390px] ${className}`}\n      {...props}\n    >\n      <button\n        ref={triggerRef}\n        type=\"button\"\n        disabled={disabled}\n        aria-haspopup=\"listbox\"\n        aria-expanded={open}\n        aria-label={label}\n        onClick={handleOpenPopover}\n        className={`flex h-11 w-full cursor-pointer items-center justify-between gap-2 overflow-hidden rounded-[12px] border border-border bg-card px-3 text-left text-card-foreground shadow-[inset_0_0.5px_0_rgb(255_255_255/0.75)] transition-colors hover:border-foreground/20 disabled:cursor-not-allowed disabled:opacity-50 dark:shadow-[inset_0_0.5px_0_rgb(255_255_255/0.06)] ${INTERACTION_FOCUS}`}\n      >\n        {selectedRecord ? (\n          <>\n            <span className=\"flex min-w-0 flex-1 items-center gap-2.5 overflow-hidden\">\n              <PhaseIcon phase={selectedRecord.info.phase} className=\"size-3.5 shrink-0\" />\n              <span className=\"min-w-0 flex-1 overflow-hidden\">\n                <span className=\"block truncate text-[13px] font-medium leading-tight text-foreground\">\n                  <TextMorph animateWidth={false}>{selectedRecord.entry.city}</TextMorph>\n                </span>\n                <span className=\"block truncate font-mono text-[10.5px] leading-tight text-muted-foreground\">\n                  <TextMorph animateWidth={false}>{`${selectedRecord.info.offsetLabel} · ${selectedRecord.entry.iana}`}</TextMorph>\n                </span>\n              </span>\n            </span>\n\n            <span className=\"flex shrink-0 items-center gap-2\">\n              <span className=\"inline-flex items-center gap-1 rounded-[7px] border border-border/80 bg-background px-2 py-0.5 font-mono text-[11.5px] font-medium tabular-nums text-foreground\">\n                <Clock className=\"size-3 text-muted-foreground\" strokeWidth={2} />\n                <TextMorph duration={360}>{selectedRecord.info.timeText}</TextMorph>\n              </span>\n              <ChevronDown\n                className={`size-4 text-muted-foreground transition-transform duration-150 ${open ? \"rotate-180\" : \"\"}`}\n                strokeWidth={2}\n              />\n            </span>\n          </>\n        ) : (\n          <>\n            <span className=\"text-[13px] text-muted-foreground\">{placeholder}</span>\n            <ChevronDown className=\"size-4 text-muted-foreground\" strokeWidth={2} />\n          </>\n        )}\n      </button>\n\n      {open && <div className=\"absolute left-0 top-[calc(100%+6px)] z-40 w-full\">{panelBody}</div>}\n    </div>\n  );\n}\n\nexport default TimezonePicker;\n"},{"path":"registry/ui-interaction-motion.ts","type":"registry:component","content":"// Hairline UI · timezone-picker · MIT License\n// Copyright (c) 2026 Hairline UI · https://hairlineui.com/license#components\n\n'use client';\n\nimport * as React from 'react';\n\nexport const EASE_OUT = 'cubic-bezier(0.16, 1, 0.3, 1)';\nexport const EASE_SETTLE = 'cubic-bezier(0.22, 1.18, 0.36, 1)';\n/** Thrown things (indicators, thumbs): a slight overshoot on transform only. */\nexport const EASE_THROW = 'cubic-bezier(0.34, 1.36, 0.64, 1)';\n/**\n * The press every button primitive shares: a 3% give that eases in and settles back.\n * Tailwind v4's scale-* writes the `scale` property, so `scale` has to be in the list\n * or the press snaps.\n */\nexport const INTERACTION_PRESS =\n  'transition-[background-color,color,box-shadow,opacity,scale] duration-200 ease-[cubic-bezier(0.16,1,0.3,1)] active:scale-[0.97] motion-reduce:transition-none motion-reduce:active:scale-100';\nexport const INTERACTION_FOCUS ='focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 focus-visible:ring-offset-2 focus-visible:ring-offset-background';\n\nconst query = '(prefers-reduced-motion: reduce)';\nconst subscribe = (notify: () => void) => {\n  const media = window.matchMedia(query);\n  media.addEventListener('change', notify);\n  return () => media.removeEventListener('change', notify);\n};\nexport const useInteractionReducedMotion = () => React.useSyncExternalStore(subscribe, () => window.matchMedia(query).matches, () => false);\n\nexport function useInteractionActivity<T extends Element>() {\n  const ref = React.useRef<T>(null);\n  const [visible, setVisible] = React.useState(false);\n  const [hidden, setHidden] = React.useState(false);\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const observer = new IntersectionObserver(([entry]) => setVisible(entry.isIntersecting));\n    observer.observe(el);\n    const visibility = () => setHidden(document.hidden);\n    visibility(); document.addEventListener('visibilitychange', visibility);\n    return () => { observer.disconnect(); document.removeEventListener('visibilitychange', visibility); };\n  }, []);\n  return { ref, active: visible && !hidden };\n}\n\nexport function interactionIcon(on: boolean, reduced: boolean): React.CSSProperties {\n  return { opacity: on ? 1 : 0, transform: on ? 'none' : 'scale(0.6)', filter: on ? 'blur(0px)' : 'blur(3px)', transition: reduced ? 'none' : `opacity 220ms ${EASE_OUT}, transform 380ms ${EASE_OUT}, filter 220ms ${EASE_OUT}` };\n}\n\n/** A raised object: one tight contact shadow, one short ambient, a hairline of light on its top edge. */\nexport const MATERIAL_LIFT =\n  'shadow-[0_1px_1.5px_rgb(0_0_0/0.07),0_3px_8px_-2px_rgb(0_0_0/0.1),inset_0_0.5px_0_rgb(255_255_255/0.8)] dark:shadow-[0_1px_2px_rgb(0_0_0/0.5),0_4px_10px_-2px_rgb(0_0_0/0.35),inset_0_0.5px_0_rgb(255_255_255/0.1)]';\n/** A trough something sits in, shaded from above, lit along its bottom edge. */\nexport const MATERIAL_RECESS =\n  'shadow-[inset_0_1px_2.5px_rgb(0_0_0/0.09),inset_0_-0.5px_0_rgb(255_255_255/0.7)] dark:shadow-[inset_0_1px_3px_rgb(0_0_0/0.45),inset_0_-0.5px_0_rgb(255_255_255/0.07)]';\n\nexport type SpringConfig = { stiffness: number; damping: number; mass?: number };\nexport interface Spring {\n  get(): number;\n  getVelocity(): number;\n  getTarget(): number;\n  /** Aim somewhere new from wherever it is now, keeping its speed. */\n  set(target: number): void;\n  /** Add speed (units per second), on top of what it already has. */\n  push(velocity: number): void;\n  /** Be there now, at rest. */\n  jump(value: number): void;\n  configure(config: SpringConfig): void;\n  stop(): void;\n}\n\n// Every moving spring on the page shares one frame loop, which sleeps when the last one rests. Each spring's onFrame runs\n// once per frame after all of them have stepped, so several springs that draw one shape paint it once.\nconst SPRING_STEP = 1 / 240;\ntype Running = { step: () => void };\nconst runningSprings = new Set<Running>();\nconst springPainters = new Set<() => void>();\nlet springFrame = 0;\nlet springLast = 0;\nlet springSpare = 0;\n\nfunction springTick(now: number) {\n  // A hidden tab stops the frames, so the first one back must not count the whole gap as time passed.\n  springSpare += Math.min((now - springLast) / 1000, 0.05);\n  springLast = now;\n  while (springSpare >= SPRING_STEP) {\n    runningSprings.forEach((spring) => spring.step());\n    springSpare -= SPRING_STEP;\n  }\n  const painters = [...springPainters];\n  springPainters.clear();\n  painters.forEach((paint) => paint());\n  springFrame = runningSprings.size ? requestAnimationFrame(springTick) : 0;\n}\n\nfunction wakeSprings(spring: Running) {\n  runningSprings.add(spring);\n  if (springFrame) return;\n  springSpare = 0;\n  springFrame = requestAnimationFrame((now) => {\n    springLast = now - 1000 / 60;\n    springTick(now);\n  });\n}\n\n/**\n * A spring that carries its speed: re-aim it mid-flight and it curves on from where it is, push it while it swings and the\n * push adds to the swing. Use it for anything that can be interrupted; a curve restarts from a standstill every time.\n * `onFrame` should write straight to the DOM. `precision` is how close counts as there, in the value's own units.\n */\nexport function createSpring(initial: number, config: SpringConfig, onFrame: () => void, precision = 0.01): Spring {\n  let value = initial;\n  let velocity = 0;\n  let target = initial;\n  let { stiffness, damping, mass = 1 } = config;\n  const running: Running = {\n    step() {\n      velocity += ((-stiffness * (value - target) - damping * velocity) / mass) * SPRING_STEP;\n      value += velocity * SPRING_STEP;\n      if (Math.abs(value - target) < precision && Math.abs(velocity) < precision * 10) {\n        value = target;\n        velocity = 0;\n        runningSprings.delete(running);\n      }\n      springPainters.add(onFrame);\n    },\n  };\n  return {\n    get: () => value,\n    getVelocity: () => velocity,\n    getTarget: () => target,\n    set(next) {\n      if (next === target && !runningSprings.has(running)) return;\n      target = next;\n      wakeSprings(running);\n    },\n    push(speed) {\n      velocity += speed;\n      wakeSprings(running);\n    },\n    jump(next) {\n      value = next;\n      target = next;\n      velocity = 0;\n      runningSprings.delete(running);\n      onFrame();\n    },\n    configure(next) {\n      ({ stiffness, damping, mass = 1 } = next);\n    },\n    stop() {\n      runningSprings.delete(running);\n    },\n  };\n}\n\n/** Sample recent movement rather than averaging a long drag and losing its release velocity. */\nexport type PointerSample = { x: number; time: number };\nexport function samplePointer(samples: PointerSample[], x: number, time: number) {\n  samples.push({ x, time });\n  while (samples.length > 2 && time - samples[0].time > 100) samples.shift();\n}\nexport function releaseVelocity(samples: PointerSample[], now: number) {\n  if (samples.length < 2 || now - samples[samples.length - 1].time > 100) return 0;\n  const first = samples[0], last = samples[samples.length - 1];\n  return (last.x - first.x) / Math.max(1, last.time - first.time);\n}\n\n/** Smooth Apple/rational rubber-band curve: continuous exponential-like resistance without linear kinks. */\nexport function rubberBand(overshoot: number, dimension = 320, constant = 0.55): number {\n  const d = dimension || 320;\n  const abs = Math.abs(overshoot);\n  return Math.sign(overshoot) * (1 - 1 / ((abs * constant) / d + 1)) * d;\n}\n\n/** Projects resting travel from release velocity (velocity in px/ms; time in seconds). */\nexport function projectInertia(distance: number, velocity: number, time = 0.12): number {\n  return distance + velocity * 1000 * time;\n}\n\n/** Smooths incoming release velocity toward a boundary so springs don't slam or clip into walls. */\nexport function softenVelocity(velocity: number, distanceToTarget: number, factor = 10): number {\n  const maxAllowed = Math.abs(distanceToTarget) * factor;\n  return Math.sign(velocity) * Math.min(Math.abs(velocity), maxAllowed);\n}\n\n/** A damped spring sampled by WAAPI: tuned for organic lightness with a hint of life (3% breath). */\nexport function springFrames(\n  from: number,\n  to: number,\n  velocity = 0,\n  duration = 480,\n  config: { omega?: number; damping?: number; steps?: number } = {},\n) {\n  const { omega = 16, damping = 0.74, steps = 36 } = config;\n  const damped = omega * Math.sqrt(Math.max(0.001, 1 - damping * damping));\n  const displacement = from - to;\n  const coefficient = (velocity * 1000 + damping * omega * displacement) / damped;\n  return Array.from({ length: steps + 1 }, (_, i) => {\n    const t = (i / steps) * (duration / 1000);\n    const value = to + Math.exp(-damping * omega * t) * (displacement * Math.cos(damped * t) + coefficient * Math.sin(damped * t));\n    return { value: i === steps ? to : value, offset: i / steps };\n  });\n}\n\n"},{"path":"registry/ui-sounds.ts","type":"registry:component","content":"// Hairline UI · timezone-picker · MIT License\n// Copyright (c) 2026 Hairline UI · https://hairlineui.com/license#components\n\n/* ─────────────────────────────────────────────────────────\n * UI SOUNDS: small interface sounds, made in code\n *\n * No files and nothing to license: every sound is built from a\n * tone or a burst of noise with the Web Audio API the moment it\n * plays. They're short and quiet, made to sit under an interface,\n * and components only play them when you pass `sound`.\n *\n *   fold     paper creasing: two short crisp bursts\n *   unfold   paper opening: a soft rising sweep\n *   drop     something small landing: a low, soft knock\n *   tick     a light click\n *   pop      a quick bright blip\n *   success  two soft rising notes\n *   error    two low falling notes\n *\n * Browsers only start audio after the visitor has pressed\n * something on the page, so a sound before that stays silent.\n * ───────────────────────────────────────────────────────── */\n\nexport type UiSound = \"fold\" | \"unfold\" | \"drop\" | \"tick\" | \"pop\" | \"success\" | \"error\";\n\nlet context: AudioContext | null = null;\nlet noise: AudioBuffer | null = null;\n\nfunction audio() {\n  if (typeof window === \"undefined\") return null;\n  if (!context) {\n    const Ctx = window.AudioContext ?? (window as unknown as { webkitAudioContext?: typeof AudioContext }).webkitAudioContext;\n    if (!Ctx) return null;\n    context = new Ctx();\n  }\n  if (context.state === \"suspended\") void context.resume().catch(() => {});\n  return context;\n}\n\nfunction noiseBuffer(ctx: AudioContext) {\n  if (noise && noise.sampleRate === ctx.sampleRate) return noise;\n  noise = ctx.createBuffer(1, Math.floor(ctx.sampleRate * 0.5), ctx.sampleRate);\n  const data = noise.getChannelData(0);\n  for (let i = 0; i < data.length; i++) data[i] = Math.random() * 2 - 1;\n  return noise;\n}\n\n/** A burst of filtered noise. */\nfunction burst(ctx: AudioContext, out: AudioNode, at: number, length: number, { type = \"bandpass\", from = 2000, to = from, q = 0.9, level = 0.5 }: { type?: BiquadFilterType; from?: number; to?: number; q?: number; level?: number }) {\n  const src = ctx.createBufferSource();\n  src.buffer = noiseBuffer(ctx);\n  const filter = ctx.createBiquadFilter();\n  filter.type = type;\n  filter.Q.value = q;\n  filter.frequency.setValueAtTime(from, at);\n  filter.frequency.exponentialRampToValueAtTime(Math.max(40, to), at + length);\n  const gain = ctx.createGain();\n  gain.gain.setValueAtTime(0.0001, at);\n  gain.gain.exponentialRampToValueAtTime(level, at + Math.min(0.012, length / 3));\n  gain.gain.exponentialRampToValueAtTime(0.0001, at + length);\n  src.connect(filter).connect(gain).connect(out);\n  src.start(at, Math.random() * 0.3, length + 0.02);\n}\n\n/** A tone that glides from one pitch to another. */\nfunction tone(ctx: AudioContext, out: AudioNode, at: number, length: number, { type = \"sine\", from, to = from, level = 0.4 }: { type?: OscillatorType; from: number; to?: number; level?: number }) {\n  const osc = ctx.createOscillator();\n  osc.type = type;\n  osc.frequency.setValueAtTime(from, at);\n  osc.frequency.exponentialRampToValueAtTime(Math.max(20, to), at + length);\n  const gain = ctx.createGain();\n  gain.gain.setValueAtTime(0.0001, at);\n  gain.gain.exponentialRampToValueAtTime(level, at + 0.006);\n  gain.gain.exponentialRampToValueAtTime(0.0001, at + length);\n  osc.connect(gain).connect(out);\n  osc.start(at);\n  osc.stop(at + length + 0.02);\n}\n\n/** Plays one sound. `volume` is 0 to 1; the default sits quietly under an interface. */\nexport function playSound(name: UiSound, volume = 0.5) {\n  const ctx = audio();\n  if (!ctx) return;\n  const out = ctx.createGain();\n  out.gain.value = Math.max(0, Math.min(1, volume)) * 0.5;\n  out.connect(ctx.destination);\n  const t = ctx.currentTime + 0.005;\n  switch (name) {\n    case \"fold\":\n      burst(ctx, out, t, 0.05, { type: \"highpass\", from: 2600, q: 0.7, level: 0.45 });\n      burst(ctx, out, t + 0.07, 0.07, { type: \"bandpass\", from: 3200, to: 1800, q: 1.2, level: 0.35 });\n      break;\n    case \"unfold\":\n      burst(ctx, out, t, 0.16, { type: \"bandpass\", from: 900, to: 2800, q: 0.8, level: 0.3 });\n      break;\n    case \"drop\":\n      tone(ctx, out, t, 0.12, { from: 180, to: 70, level: 0.55 });\n      burst(ctx, out, t, 0.03, { type: \"lowpass\", from: 1200, q: 0.5, level: 0.2 });\n      break;\n    case \"tick\":\n      tone(ctx, out, t, 0.025, { type: \"triangle\", from: 1900, to: 1500, level: 0.25 });\n      break;\n    case \"pop\":\n      tone(ctx, out, t, 0.06, { from: 620, to: 980, level: 0.3 });\n      break;\n    case \"success\":\n      tone(ctx, out, t, 0.11, { from: 660, level: 0.22 });\n      tone(ctx, out, t + 0.09, 0.16, { from: 990, level: 0.22 });\n      break;\n    case \"error\":\n      tone(ctx, out, t, 0.12, { type: \"triangle\", from: 330, level: 0.25 });\n      tone(ctx, out, t + 0.1, 0.18, { type: \"triangle\", from: 247, level: 0.25 });\n      break;\n  }\n  window.setTimeout(() => out.disconnect(), 600);\n}\n"}],"css":{},"docs":"Docs and live preview: https://hairlineui.com/ui/timezone-picker. MIT licensed: https://hairlineui.com/license#components","meta":{"license":"MIT"}}