{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"contact-section","type":"registry:block","title":"Contact section","description":"A validated contact form that morphs into a confirmation, support channels, and office cards with local times.","categories":["blocks"],"dependencies":["lucide-react","motion"],"registryDependencies":["https://uiarc.dev/r/arc-motion-tokens.json","https://uiarc.dev/r/avatar.json","https://uiarc.dev/r/button.json","https://uiarc.dev/r/copy-button.json","https://uiarc.dev/r/input.json","https://uiarc.dev/r/segmented-control.json","https://uiarc.dev/r/textarea.json"],"files":[{"path":"registry/blocks/contact-section/contact-section.tsx","type":"registry:component","target":"@components/arc/blocks/contact-section/contact-section.tsx","content":"\"use client\";\n\nimport { forwardRef, useEffect, useId, useLayoutEffect, useRef, useState } from \"react\";\nimport type { FormEvent, KeyboardEvent, ReactNode } from \"react\";\nimport { AnimatePresence, LayoutGroup, motion, useAnimate, useIsPresent, useReducedMotion } from \"motion/react\";\nimport type { Variants } from \"motion/react\";\nimport { Check, Clock, Mail, MessageCircle, Phone, Users } from \"lucide-react\";\nimport { Avatar } from \"../../avatar/avatar\";\nimport { Button } from \"../../button/button\";\nimport { CopyButton } from \"../../copy-button/copy-button\";\nimport { Input } from \"../../input/input\";\nimport SegmentedControl from \"../../segmented-control/segmented-control\";\nimport { Textarea } from \"../../textarea/textarea\";\nimport { motionTokens } from \"../../lib/motion-tokens\";\nimport { person } from \"../../lib/media\";\nimport styles from \"./contact-section.module.css\";\n\nexport type ContactSectionVariant = \"form\" | \"channels\" | \"offices\";\n\nexport interface ContactMessage {\n  name: string;\n  email: string;\n  topic: string;\n  message: string;\n}\n\nexport interface ContactChannel {\n  value: string;\n  label: string;\n  /** One line under the label in the list, such as a response time. */\n  meta: string;\n  icon?: ReactNode;\n  /** The detail shown when the channel is selected. */\n  detail: ReactNode;\n}\n\nexport interface ContactOffice {\n  city: string;\n  /** IANA time zone, used for the live local time and open status. */\n  timeZone: string;\n  address: string[];\n  email?: string;\n  /** Opening hours in local 24 hour time. Defaults to 9 to 18. */\n  hours?: [number, number];\n}\n\nexport interface ContactSectionProps {\n  /** `form` validates and morphs into a confirmation, `channels` lists ways to reach you, `offices` shows live local times. */\n  variant?: ContactSectionVariant;\n  title?: string;\n  description?: string;\n  /** Topics offered in the form. */\n  topics?: string[];\n  /** Called with a valid message. Reject to keep the form and show an error; resolve to show the confirmation. */\n  onSubmit?: (message: ContactMessage) => void | Promise<void>;\n  channels?: ContactChannel[];\n  /** Selected channel (controlled). */\n  channel?: string;\n  defaultChannel?: string;\n  onChannelChange?: (value: string) => void;\n  offices?: ContactOffice[];\n  className?: string;\n}\n\ntype Bezier = [number, number, number, number];\nconst enter = [...motionTokens.ease.enter] as Bezier;\nconst standard = [...motionTokens.ease.standard] as Bezier;\nconst EMAIL = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]{2,}$/;\nconst MAX_MESSAGE = 500;\n\n/** Faces slide along one axis in the direction of travel and settle out of a soft blur. */\nconst faceVariants: Variants = {\n  hidden: ({ direction, axis }: { direction: number; axis: \"x\" | \"y\" }) => ({ opacity: 0, x: axis === \"x\" ? direction * 18 : 0, y: axis === \"y\" ? direction * 18 : 0, filter: `blur(${motionTokens.blur.soft}px)` }),\n  shown: { opacity: 1, x: 0, y: 0, filter: \"blur(0px)\", transition: { x: motionTokens.spring.smooth, y: motionTokens.spring.smooth, opacity: { duration: motionTokens.duration.standard, ease: enter, delay: .04 }, filter: { duration: motionTokens.duration.standard, ease: enter, delay: .04 } } },\n  gone: ({ direction, axis }: { direction: number; axis: \"x\" | \"y\" }) => ({ opacity: 0, x: axis === \"x\" ? direction * -12 : 0, y: axis === \"y\" ? direction * -12 : 0, filter: `blur(${motionTokens.blur.soft}px)`, transition: { duration: motionTokens.duration.fast, ease: standard } }),\n};\nconst fadeVariants: Variants = { hidden: { opacity: 0 }, shown: { opacity: 1, transition: { duration: motionTokens.duration.fast } }, gone: { opacity: 0, transition: { duration: motionTokens.duration.instant } } };\n\nfunction Face({ children, custom, reduced, className }: { children: ReactNode; custom: { direction: number; axis: \"x\" | \"y\" }; reduced: boolean; className?: string }) {\n  const present = useIsPresent();\n  return <motion.div className={className} data-face=\"\" data-leaving={present ? undefined : \"\"} inert={!present} custom={custom} variants={reduced ? fadeVariants : faceVariants} initial=\"hidden\" animate=\"shown\" exit=\"gone\">{children}</motion.div>;\n}\n\n/**\n * One surface that springs from the height of its old content to the new one when `faceKey` changes, while the faces\n * crossfade along an axis. Between switches the height is automatic, so fields that grow inside it never get clipped.\n */\nfunction MorphPanel({ faceKey, direction = 1, axis = \"y\", reduced, className, children, ...rest }: { faceKey: string; direction?: number; axis?: \"x\" | \"y\"; reduced: boolean; className?: string; children: ReactNode; id?: string; role?: string; \"aria-labelledby\"?: string }) {\n  const [scope, animate] = useAnimate<HTMLDivElement>();\n  const lastKey = useRef(faceKey);\n  const lastHeight = useRef(0);\n  useEffect(() => {\n    const node = scope.current;\n    if (!node || typeof ResizeObserver === \"undefined\") return;\n    lastHeight.current = node.offsetHeight;\n    const observer = new ResizeObserver(() => { lastHeight.current = node.offsetHeight; });\n    observer.observe(node);\n    return () => observer.disconnect();\n  }, [scope]);\n  useLayoutEffect(() => {\n    if (lastKey.current === faceKey) return;\n    lastKey.current = faceKey;\n    const node = scope.current;\n    const face = node?.querySelector<HTMLElement>(\":scope > [data-face]:not([data-leaving])\");\n    if (!node || !face || reduced) return;\n    const from = lastHeight.current || node.offsetHeight;\n    const to = face.offsetHeight;\n    if (Math.abs(from - to) < 1) return;\n    node.style.setProperty(\"height\", `${from}px`);\n    const controls = animate(node, { height: [from, to] }, motionTokens.spring.smooth);\n    controls.then(() => node.style.removeProperty(\"height\"));\n    return () => { controls.stop(); node.style.removeProperty(\"height\"); };\n  }, [faceKey, animate, scope, reduced]);\n  return <div ref={scope} className={[styles.morph, className].filter(Boolean).join(\" \")} {...rest}>\n    <AnimatePresence initial={false} mode=\"popLayout\" custom={{ direction, axis }}>\n      <Face key={faceKey} custom={{ direction, axis }} reduced={reduced} className={styles.face}>{children}</Face>\n    </AnimatePresence>\n  </div>;\n}\n\n/** Topic chips as a radio group: a highlight glides to the choice and arrow keys move it. */\nfunction TopicPicker({ topics, value, onChange, reduced }: { topics: string[]; value: string; onChange: (topic: string) => void; reduced: boolean }) {\n  const id = useId();\n  const refs = useRef<(HTMLButtonElement | null)[]>([]);\n  function onKeyDown(event: KeyboardEvent) {\n    const delta = event.key === \"ArrowRight\" || event.key === \"ArrowDown\" ? 1 : event.key === \"ArrowLeft\" || event.key === \"ArrowUp\" ? -1 : 0;\n    if (!delta) return;\n    event.preventDefault();\n    const next = (topics.indexOf(value) + delta + topics.length) % topics.length;\n    onChange(topics[next]!);\n    refs.current[next]?.focus();\n  }\n  return <div className={styles.topicField}>\n    <span id={`${id}-label`} className={styles.fieldLabel}>Topic</span>\n    <LayoutGroup id={id}>\n      <div className={styles.topics} role=\"radiogroup\" aria-labelledby={`${id}-label`} onKeyDown={onKeyDown}>\n        {topics.map((topic, index) => <button key={topic} ref={node => { refs.current[index] = node; }} type=\"button\" role=\"radio\" aria-checked={topic === value} tabIndex={topic === value ? 0 : -1} className={styles.topic} onClick={() => onChange(topic)}>\n          {topic === value && <motion.span layoutId=\"topic\" className={styles.topicHighlight} transition={reduced ? { duration: 0 } : motionTokens.spring.morph} aria-hidden=\"true\" />}\n          <span>{topic}</span>\n        </button>)}\n      </div>\n    </LayoutGroup>\n  </div>;\n}\n\ntype Errors = Partial<Record<\"name\" | \"email\" | \"message\", string>>;\nfunction validate(values: { name: string; email: string; message: string }): Errors {\n  const errors: Errors = {};\n  if (!values.name.trim()) errors.name = \"Enter your name\";\n  if (!values.email.trim()) errors.email = \"Enter your email address\";\n  else if (!EMAIL.test(values.email.trim())) errors.email = \"Enter an email like name@example.com\";\n  if (values.message.trim().length < 20) errors.message = values.message.trim() ? \"Add a little more detail, at least 20 characters\" : \"Tell us how we can help\";\n  return errors;\n}\n\nfunction ContactForm({ topics, onSubmit, reduced }: { topics: string[]; onSubmit?: ContactSectionProps[\"onSubmit\"]; reduced: boolean }) {\n  const [values, setValues] = useState({ name: \"\", email: \"\", message: \"\" });\n  const [topic, setTopic] = useState(topics[0] ?? \"\");\n  const [errors, setErrors] = useState<Errors>({});\n  const [submitted, setSubmitted] = useState(false);\n  const [phase, setPhase] = useState<\"editing\" | \"sending\" | \"sent\">(\"editing\");\n  const [failure, setFailure] = useState<string | null>(null);\n  const [sentTo, setSentTo] = useState({ name: \"\", email: \"\" });\n  const nameRef = useRef<HTMLInputElement>(null), emailRef = useRef<HTMLInputElement>(null), messageRef = useRef<HTMLTextAreaElement>(null);\n  const restoreFocus = useRef(false);\n  const successRef = useRef<HTMLHeadingElement>(null);\n\n  useEffect(() => {\n    if (phase === \"sent\") successRef.current?.focus();\n    if (phase === \"editing\" && restoreFocus.current) { restoreFocus.current = false; nameRef.current?.focus(); }\n  }, [phase]);\n\n  const update = (field: keyof typeof values) => (event: { target: { value: string } }) => {\n    const next = { ...values, [field]: event.target.value };\n    setValues(next);\n    if (submitted) setErrors(validate(next));\n  };\n\n  async function submit(event: FormEvent) {\n    event.preventDefault();\n    if (phase !== \"editing\") return;\n    setSubmitted(true);\n    setFailure(null);\n    const found = validate(values);\n    setErrors(found);\n    if (found.name) { nameRef.current?.focus(); return; }\n    if (found.email) { emailRef.current?.focus(); return; }\n    if (found.message) { messageRef.current?.focus(); return; }\n    setPhase(\"sending\");\n    const payload = { name: values.name.trim(), email: values.email.trim(), topic, message: values.message.trim() };\n    try {\n      await (onSubmit ? onSubmit(payload) : new Promise(resolve => setTimeout(resolve, 1100)));\n      setSentTo({ name: payload.name.split(/\\s+/)[0]!, email: payload.email });\n      setPhase(\"sent\");\n    } catch {\n      setPhase(\"editing\");\n      setFailure(\"We couldn't send your message. Check your connection and try again.\");\n    }\n  }\n\n  function reset() {\n    setValues({ name: \"\", email: \"\", message: \"\" });\n    setErrors({});\n    setSubmitted(false);\n    setFailure(null);\n    restoreFocus.current = true;\n    setPhase(\"editing\");\n  }\n\n  const left = MAX_MESSAGE - values.message.length;\n  return <MorphPanel faceKey={phase === \"sent\" ? \"sent\" : \"form\"} direction={phase === \"sent\" ? 1 : -1} reduced={reduced} className={styles.formCard}>\n    {phase === \"sent\"\n      ? <div className={styles.success} aria-live=\"polite\">\n          <span className={styles.successMark} aria-hidden=\"true\">\n            <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n              <motion.path d=\"M5 12.5l4.5 4.5L19 7.5\" initial={reduced ? false : { pathLength: 0 }} animate={{ pathLength: 1 }} transition={{ duration: reduced ? 0 : motionTokens.duration.considered, ease: enter, delay: .16 }} />\n            </svg>\n          </span>\n          <h3 ref={successRef} tabIndex={-1} className={styles.successTitle}>Thanks, {sentTo.name}</h3>\n          <p className={styles.successText}>Your message is with our {topic.toLowerCase()} team. We&rsquo;ll reply to {sentTo.email} within one business day.</p>\n          <Button variant=\"secondary\" onClick={reset}>Send another message</Button>\n        </div>\n      : <form className={styles.formBody} onSubmit={submit} noValidate aria-label=\"Contact form\">\n          <div className={styles.row}>\n            <Input ref={nameRef} label=\"Name\" name=\"name\" autoComplete=\"name\" placeholder=\"Emma Collins\" value={values.name} onChange={update(\"name\")} error={errors.name} readOnly={phase === \"sending\"} />\n            <Input ref={emailRef} label=\"Work email\" name=\"email\" type=\"email\" inputMode=\"email\" autoComplete=\"email\" placeholder=\"emma@northwind.example\" value={values.email} onChange={update(\"email\")} error={errors.email} readOnly={phase === \"sending\"} />\n          </div>\n          <TopicPicker topics={topics} value={topic} onChange={setTopic} reduced={reduced} />\n          <Textarea ref={messageRef} label=\"Message\" name=\"message\" rows={4} maxLength={MAX_MESSAGE} placeholder=\"What are you building?\" value={values.message} onChange={update(\"message\")} error={errors.message} description={`${left} characters left`} readOnly={phase === \"sending\"} />\n          <AnimatePresence initial={false}>\n            {failure && <motion.p key=\"failure\" role=\"alert\" className={styles.failure} initial={{ opacity: 0, height: 0 }} animate={{ opacity: 1, height: \"auto\" }} exit={{ opacity: 0, height: 0 }} transition={reduced ? { duration: 0 } : { height: motionTokens.spring.smooth, opacity: { duration: motionTokens.duration.fast, ease: standard } }}>{failure}</motion.p>}\n          </AnimatePresence>\n          <div className={styles.submitRow}>\n            <p className={styles.fine}>We reply within one business day.</p>\n            <Button type=\"submit\" variant=\"primary\" loading={phase === \"sending\"}>Send message</Button>\n          </div>\n        </form>}\n  </MorphPanel>;\n}\n\nconst hannah = person(\"hannah-walsh\");\nconst ICON = { size: 18, strokeWidth: 1.75, \"aria-hidden\": true } as const;\n\n/** A demo action that confirms in place: the label morphs, and the result stays visible below it. */\nfunction ConfirmAction({ idle, busy, done, note }: { idle: string; busy?: boolean; done: string; note?: ReactNode }) {\n  const reduced = !!useReducedMotion();\n  const [state, setState] = useState<\"idle\" | \"busy\" | \"done\">(\"idle\");\n  const timer = useRef<number | undefined>(undefined);\n  useEffect(() => () => window.clearTimeout(timer.current), []);\n  return <div className={styles.confirm}>\n    <Button variant={state === \"done\" ? \"secondary\" : \"primary\"} loading={state === \"busy\"} onClick={() => {\n      if (state !== \"idle\") { setState(\"idle\"); return; }\n      if (busy) { setState(\"busy\"); timer.current = window.setTimeout(() => setState(\"done\"), 800); } else setState(\"done\");\n    }}>\n      {state === \"done\" ? <><Check size={15} strokeWidth={2.25} aria-hidden=\"true\" />{done}</> : idle}\n    </Button>\n    <div aria-live=\"polite\">\n      <AnimatePresence initial={false}>\n        {state === \"done\" && note && <motion.div key=\"note\" className={styles.confirmNote} initial={{ opacity: 0, height: 0 }} animate={{ opacity: 1, height: \"auto\" }} exit={{ opacity: 0, height: 0 }} transition={reduced ? { duration: 0 } : { height: motionTokens.spring.smooth, opacity: { duration: motionTokens.duration.fast, ease: standard } }}>{note}</motion.div>}\n      </AnimatePresence>\n    </div>\n  </div>;\n}\n\nexport const contactExampleChannels: ContactChannel[] = [\n  {\n    value: \"chat\", label: \"Chat with support\", meta: \"Replies in about 4 minutes\", icon: <MessageCircle {...ICON} />,\n    detail: <>\n      <h3>Chat with support</h3>\n      <p>Hannah and Jordan are online now. Chat is best for quick questions about installing, theming, or a component that misbehaves.</p>\n      <ConfirmAction idle=\"Start a chat\" busy done=\"Chat started\" note={<span className={styles.agent}><Avatar name={hannah.name} src={hannah.src} size=\"sm\" status=\"online\" /><span><strong>{hannah.name}</strong> joined the chat. Say hello.</span></span>} />\n    </>,\n  },\n  {\n    value: \"email\", label: \"Email support\", meta: \"Replies within a business day\", icon: <Mail {...ICON} />,\n    detail: <>\n      <h3>Email support</h3>\n      <p>Send screenshots, links, or a reproduction. Every message gets a reply from a person within one business day.</p>\n      <div className={styles.copyRow}><span>support@example.com</span><CopyButton value=\"support@example.com\" label=\"Copy email\" /></div>\n    </>,\n  },\n  {\n    value: \"sales\", label: \"Talk to sales\", meta: \"Weekdays, 9am to 6pm PT\", icon: <Phone {...ICON} />,\n    detail: <>\n      <h3>Talk to sales</h3>\n      <p>Licensing for a larger team, invoicing, or a security review. Tyler will walk you through it on a 20 minute call.</p>\n      <div className={styles.copyRow}><span className={styles.tabular}>+1 (415) 555-0132</span><CopyButton value=\"+14155550132\" label=\"Copy number\" /></div>\n      <ConfirmAction idle=\"Request a call\" busy done=\"Call requested\" note=\"Tyler will email you a few times that work this week.\" />\n    </>,\n  },\n  {\n    value: \"community\", label: \"Ask the community\", meta: \"4,200 members\", icon: <Users {...ICON} />,\n    detail: <>\n      <h3>Ask the community</h3>\n      <p>Designers and engineers who ship with Arc answer questions about components, theming, and motion, usually within the hour.</p>\n      <ConfirmAction idle=\"Open the forum\" done=\"Forum opened\" note=\"The forum opens in a new tab on the live site.\" />\n    </>,\n  },\n];\n\nexport const contactExampleOffices: ContactOffice[] = [\n  { city: \"San Francisco\", timeZone: \"America/Los_Angeles\", address: [\"100 Example Street, Floor 4\", \"San Francisco, CA 94000\"], email: \"sf@example.com\" },\n  { city: \"New York\", timeZone: \"America/New_York\", address: [\"200 Sample Avenue, Suite 12\", \"New York, NY 10000\"], email: \"nyc@example.com\" },\n  { city: \"Lisbon\", timeZone: \"Europe/Lisbon\", address: [\"Rua do Exemplo 10, 3º\", \"1000-000 Lisboa, Portugal\"], email: \"lisbon@example.com\" },\n];\n\nfunction useNow(intervalMs: number) {\n  const [now, setNow] = useState<Date | null>(null);\n  useEffect(() => {\n    const tick = () => setNow(new Date());\n    tick();\n    const timer = window.setInterval(tick, intervalMs);\n    return () => window.clearInterval(timer);\n  }, [intervalMs]);\n  return now;\n}\n\nfunction officeState(office: ContactOffice, now: Date | null) {\n  if (!now) return { time: \"--:--\", open: null as boolean | null };\n  const parts = new Intl.DateTimeFormat(\"en-US\", { timeZone: office.timeZone, hour: \"numeric\", minute: \"2-digit\", weekday: \"short\", hourCycle: \"h23\" }).formatToParts(now);\n  const get = (type: string) => parts.find(part => part.type === type)?.value ?? \"\";\n  const hour = Number(get(\"hour\")), weekday = get(\"weekday\");\n  const [start, end] = office.hours ?? [9, 18];\n  const time = new Intl.DateTimeFormat(\"en-US\", { timeZone: office.timeZone, hour: \"numeric\", minute: \"2-digit\" }).format(now);\n  return { time, open: weekday !== \"Sat\" && weekday !== \"Sun\" && hour >= start && hour < end };\n}\n\nconst hourLabel = (hour: number) => `${hour % 12 || 12}${hour < 12 || hour === 24 ? \"am\" : \"pm\"}`;\n\nfunction Offices({ offices }: { offices: ContactOffice[] }) {\n  const now = useNow(15000);\n  return <ul className={styles.offices}>\n    {offices.map(office => {\n      const { time, open } = officeState(office, now);\n      return <li key={office.city} className={styles.office}>\n        <div className={styles.officeHead}>\n          <h3>{office.city}</h3>\n          <span className={styles.officeTime}><Clock size={14} strokeWidth={1.75} aria-hidden=\"true\" /><span className={styles.tabular}>{time}</span></span>\n        </div>\n        <span className={styles.officeStatus} data-open={open === null ? undefined : open ? \"\" : undefined} data-closed={open === false ? \"\" : undefined}>\n          <span className={styles.statusDot} aria-hidden=\"true\" />{open === null ? \"Checking hours\" : open ? `Open until ${hourLabel((office.hours ?? [9, 18])[1])}` : \"Closed now\"}\n        </span>\n        <address className={styles.address}>{office.address.map(line => <span key={line}>{line}</span>)}</address>\n        <div className={styles.officeActions}>\n          {office.email && <a className={styles.officeLink} href={`mailto:${office.email}`}>{office.email}</a>}\n          <CopyButton value={office.address.join(\", \")} label=\"Copy address\" variant=\"plain\" />\n        </div>\n      </li>;\n    })}\n  </ul>;\n}\n\nfunction Channels({ channels, value, onChange, reduced }: { channels: ContactChannel[]; value: string; onChange: (value: string) => void; reduced: boolean }) {\n  const id = useId();\n  const [direction, setDirection] = useState(1);\n  const refs = useRef<(HTMLButtonElement | null)[]>([]);\n  const active = channels.find(channel => channel.value === value) ?? channels[0]!;\n  const choose = (next: string) => {\n    if (next === active.value) return;\n    setDirection(Math.sign(channels.findIndex(channel => channel.value === next) - channels.indexOf(active)) || 1);\n    onChange(next);\n  };\n  function onKeyDown(event: KeyboardEvent) {\n    const delta = event.key === \"ArrowDown\" || event.key === \"ArrowRight\" ? 1 : event.key === \"ArrowUp\" || event.key === \"ArrowLeft\" ? -1 : 0;\n    const edge = event.key === \"Home\" ? 0 : event.key === \"End\" ? channels.length - 1 : -1;\n    if (!delta && edge < 0) return;\n    event.preventDefault();\n    const next = edge >= 0 ? edge : (channels.indexOf(active) + delta + channels.length) % channels.length;\n    choose(channels[next]!.value);\n    refs.current[next]?.focus();\n  }\n  return <div className={styles.channels}>\n    <LayoutGroup id={id}>\n      <div className={styles.channelList} role=\"tablist\" aria-orientation=\"vertical\" aria-label=\"Ways to reach us\" onKeyDown={onKeyDown}>\n        {channels.map((channel, index) => {\n          const selected = channel.value === active.value;\n          return <button key={channel.value} ref={node => { refs.current[index] = node; }} type=\"button\" role=\"tab\" id={`${id}-tab-${channel.value}`} aria-selected={selected} aria-controls={`${id}-panel`} tabIndex={selected ? 0 : -1} className={styles.channel} onClick={() => choose(channel.value)}>\n            {selected && <motion.span layoutId=\"channel\" className={styles.channelHighlight} transition={reduced ? { duration: 0 } : motionTokens.spring.morph} aria-hidden=\"true\" />}\n            <span className={styles.channelIcon}>{channel.icon}</span>\n            <span className={styles.channelText}><span>{channel.label}</span><span>{channel.meta}</span></span>\n          </button>;\n        })}\n      </div>\n    </LayoutGroup>\n    <MorphPanel faceKey={active.value} direction={direction} axis=\"y\" reduced={reduced} className={styles.channelPanel} id={`${id}-panel`} role=\"tabpanel\" aria-labelledby={`${id}-tab-${active.value}`}>\n      <div className={styles.channelDetail}>{active.detail}</div>\n    </MorphPanel>\n  </div>;\n}\n\n/**\n * A contact section in three layouts: a validated form whose card springs into a confirmation, a list of support\n * channels whose detail panel morphs to each channel, and office cards with live local times and open status.\n */\nexport const ContactSection = forwardRef<HTMLElement, ContactSectionProps>(function ContactSection({\n  variant = \"form\",\n  title,\n  description,\n  topics = [\"Sales\", \"Support\", \"Partnerships\", \"Press\"],\n  onSubmit,\n  channels = contactExampleChannels,\n  channel: channelProp,\n  defaultChannel,\n  onChannelChange,\n  offices = contactExampleOffices,\n  className,\n}, ref) {\n  const id = useId();\n  const reduced = !!useReducedMotion();\n  const [innerChannel, setInnerChannel] = useState(defaultChannel ?? channels[0]?.value ?? \"\");\n  const activeChannel = channelProp ?? innerChannel;\n  const setChannel = (next: string) => { if (channelProp === undefined) setInnerChannel(next); onChannelChange?.(next); };\n  const copy = {\n    form: { title: \"Talk to our team\", description: \"Questions about licensing, a bug you can't pin down, or a component you wish existed. A person reads every message.\" },\n    channels: { title: \"Get help your way\", description: \"Pick whatever suits the question. Every channel reaches the same small team.\" },\n    offices: { title: \"Visit us\", description: \"We work across three time zones, so someone is usually awake. Drop by for coffee, just let us know first.\" },\n  }[variant];\n\n  return <section ref={ref} className={[styles.contact, className].filter(Boolean).join(\" \")} data-variant={variant} aria-labelledby={`${id}-title`}>\n    <div className={styles.inner}>\n      <div className={styles.intro}>\n        <h2 id={`${id}-title`} className={styles.title}>{title ?? copy.title}</h2>\n        <p className={styles.description}>{description ?? copy.description}</p>\n        {variant === \"form\" && <ul className={styles.facts}>\n          <li><Clock size={16} strokeWidth={1.75} aria-hidden=\"true\" />Replies within one business day</li>\n          <li><Mail size={16} strokeWidth={1.75} aria-hidden=\"true\" /><span>hello@example.com</span><CopyButton value=\"hello@example.com\" label=\"Copy email\" iconOnly variant=\"plain\" /></li>\n        </ul>}\n      </div>\n      {variant === \"form\" && <ContactForm topics={topics} onSubmit={onSubmit} reduced={reduced} />}\n      {variant === \"channels\" && <Channels channels={channels} value={activeChannel} onChange={setChannel} reduced={reduced} />}\n      {variant === \"offices\" && <Offices offices={offices} />}\n    </div>\n  </section>;\n});\n\nContactSection.displayName = \"ContactSection\";\n\nconst variantOptions = [{ value: \"form\", label: \"Form\" }, { value: \"channels\", label: \"Channels\" }, { value: \"offices\", label: \"Offices\" }];\n\n/** Preview: the contact section with a switch between its three layouts. Messages are simulated and never sent. */\nexport function ContactSectionBlock({ variant: initial = \"form\" }: { variant?: ContactSectionVariant }) {\n  const [variant, setVariant] = useState<ContactSectionVariant>(initial);\n  return <div className={styles.preview}>\n    <SegmentedControl label=\"Contact layout\" options={variantOptions} value={variant} onValueChange={next => setVariant(next as ContactSectionVariant)} />\n    <div className={styles.frame}>\n      <ContactSection key={variant} variant={variant} />\n    </div>\n  </div>;\n}\n\nexport default ContactSectionBlock;\n"},{"path":"registry/blocks/contact-section/contact-section.module.css","type":"registry:component","target":"@components/arc/blocks/contact-section/contact-section.module.css","content":".contact { container: contact / inline-size; background: var(--background); color: var(--foreground); font-family: var(--font-body); letter-spacing: var(--tracking-body); }\n.tabular { font-variant-numeric: tabular-nums; }\n\n.inner { display: grid; max-width: 1120px; gap: var(--space-10); margin: 0 auto; padding: var(--space-20) var(--space-8); }\n.contact[data-variant=\"form\"] .inner { grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); align-items: start; gap: var(--space-12); }\n.intro { display: grid; align-content: start; gap: var(--space-3); max-width: 520px; }\n.title { margin: 0; font-family: var(--font-display); font-size: clamp(1.75rem, 1rem + 3cqi, var(--text-4xl)); font-weight: 500; letter-spacing: var(--tracking-display); line-height: var(--leading-display); text-wrap: balance; }\n.description { margin: 0; color: var(--text-secondary); font-size: var(--text-base); line-height: 1.5; text-wrap: pretty; }\n.facts { display: grid; gap: var(--space-2); margin: var(--space-4) 0 0; padding: 0; list-style: none; }\n.facts li { display: flex; min-height: 32px; align-items: center; gap: var(--space-2); color: var(--text-secondary); font-size: var(--text-sm); }\n.facts svg { flex: none; }\n\n/* Morphing surface: height springs between faces; the leaving face floats out of flow. */\n.morph { position: relative; overflow: hidden; }\n.face { width: 100%; }\n\n.formCard { border: 1px solid var(--border); border-radius: var(--radius-panel); background: var(--surface); }\n.formCard > .face { padding: var(--space-6); }\n.formBody { display: grid; gap: var(--space-5); }\n.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }\n.topicField { display: grid; }\n.fieldLabel { margin-bottom: var(--space-2); color: var(--foreground); font-size: var(--text-sm); font-weight: 500; line-height: var(--leading-body); }\n.topics { display: flex; flex-wrap: wrap; gap: var(--space-1); }\n.topic { position: relative; isolation: isolate; height: var(--control-height-sm); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 0 var(--space-4); background: none; color: var(--text-secondary); font: inherit; font-size: var(--text-sm); font-weight: 500; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: color var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard); }\n.topic[aria-checked=\"true\"] { border-color: transparent; color: var(--control-glyph); }\n@media (hover: hover) and (pointer: fine) { .topic:not([aria-checked=\"true\"]):hover { border-color: var(--border-strong); color: var(--foreground); } }\n.topicHighlight { position: absolute; z-index: -1; inset: -1px; border-radius: inherit; background: var(--control-on); }\n.failure { overflow: hidden; margin: 0; color: var(--danger); font-size: var(--text-sm); }\n.submitRow { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3) var(--space-4); }\n.fine { margin: 0; color: var(--text-muted); font-size: var(--text-sm); }\n\n.success { display: grid; justify-items: center; gap: var(--space-3); padding: var(--space-10) var(--space-2); text-align: center; }\n.successMark { display: grid; width: 52px; height: 52px; place-items: center; margin-bottom: var(--space-2); border-radius: 50%; background: color-mix(in oklab, var(--success) 13%, transparent); color: var(--success); }\n.successMark svg { width: 26px; height: 26px; }\n.successTitle { margin: 0; font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 500; letter-spacing: var(--tracking-display); line-height: var(--leading-display); }\n.successText { max-width: 360px; margin: 0 0 var(--space-3); color: var(--text-secondary); font-size: var(--text-sm); line-height: 1.55; }\n\n/* Channels: a tab list beside one detail surface that morphs to each channel. */\n.channels { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); align-items: start; gap: var(--space-6); }\n.channelList { display: grid; gap: 2px; }\n.channel { position: relative; isolation: isolate; display: flex; align-items: center; gap: var(--space-3); border: 0; border-radius: 16px; padding: var(--space-3) var(--space-4); background: none; color: var(--foreground); font: inherit; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; }\n.channelHighlight { position: absolute; z-index: -1; inset: 0; border-radius: inherit; background: var(--surface-muted); }\n.channelIcon { display: flex; flex: none; color: var(--text-muted); transition: color var(--duration-fast) var(--ease-standard); }\n.channel[aria-selected=\"true\"] .channelIcon { color: var(--accent); }\n.channelText { display: grid; gap: 1px; min-width: 0; }\n.channelText > span:first-child { font-size: var(--text-sm); font-weight: 500; }\n.channelText > span:last-child { overflow: hidden; color: var(--text-muted); font-size: var(--text-xs); text-overflow: ellipsis; white-space: nowrap; }\n@media (hover: hover) and (pointer: fine) { .channel:hover .channelIcon { color: var(--foreground); } }\n.channelPanel { border: 1px solid var(--border); border-radius: var(--radius-panel); background: var(--surface); }\n.channelPanel > .face { padding: var(--space-6); }\n.channelDetail { display: grid; justify-items: start; gap: var(--space-3); }\n.channelDetail h3 { margin: 0; font-size: var(--text-lg); font-weight: 500; line-height: var(--leading-body); }\n.channelDetail p { max-width: 480px; margin: 0 0 var(--space-2); color: var(--text-secondary); font-size: var(--text-sm); line-height: 1.6; }\n.copyRow { display: flex; width: min(100%, 360px); align-items: center; justify-content: space-between; gap: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-control); padding: 4px 4px 4px var(--space-4); font-size: var(--text-sm); }\n.copyRow > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.confirm { display: grid; justify-items: start; gap: var(--space-2); }\n.confirmNote { overflow: hidden; color: var(--text-secondary); font-size: var(--text-sm); }\n.agent { display: flex; align-items: center; gap: var(--space-2); padding-top: var(--space-1); }\n.agent strong { color: var(--foreground); font-weight: 500; }\n\n/* Offices */\n.offices { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--space-4); margin: 0; padding: 0; list-style: none; }\n.office { display: grid; align-content: start; gap: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-panel); padding: var(--space-6); background: var(--surface); }\n.officeHead { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }\n.officeHead h3 { margin: 0; font-size: var(--text-lg); font-weight: 500; line-height: var(--leading-body); }\n/* Baseline alignment lets the time text, not the clock icon, sit on the city's baseline. */\n.officeTime { display: inline-flex; flex: none; align-items: baseline; gap: 6px; color: var(--text-secondary); font-size: var(--text-sm); }\n.officeTime svg { align-self: center; }\n.officeStatus { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--text-secondary); font-size: var(--text-sm); }\n.statusDot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); transition: background-color var(--duration-standard) var(--ease-standard); }\n.officeStatus[data-open] .statusDot { background: var(--success); box-shadow: 0 0 0 3px color-mix(in oklab, var(--success) 18%, transparent); }\n.address { display: grid; margin-top: var(--space-1); color: var(--text-secondary); font-size: var(--text-sm); font-style: normal; line-height: 1.55; }\n.officeActions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-2); border-top: 1px solid var(--border-subtle); padding-top: var(--space-3); }\n.officeLink { color: var(--foreground); font-size: var(--text-sm); text-decoration: none; }\n@media (hover: hover) and (pointer: fine) { .officeLink:hover { text-decoration: underline; text-underline-offset: 3px; } }\n\n@container contact (max-width: 820px) {\n  .contact[data-variant=\"form\"] .inner { grid-template-columns: minmax(0, 1fr); gap: var(--space-8); }\n  .channels { grid-template-columns: minmax(0, 1fr); }\n  .channelList { display: flex; overflow-x: auto; scrollbar-width: none; }\n  .channelList::-webkit-scrollbar { display: none; }\n  .channel { flex: none; }\n  .channelText > span:last-child { display: none; }\n}\n@container contact (max-width: 520px) {\n  .inner { padding: var(--space-12) var(--space-4); }\n  .row { grid-template-columns: minmax(0, 1fr); }\n  .formCard > .face, .channelPanel > .face { padding: var(--space-5); }\n  .submitRow > button { width: 100%; }\n}\n\n.preview { display: grid; width: 100%; justify-items: center; gap: var(--space-4); }\n.frame { width: 100%; overflow: hidden; border: 1px solid var(--border); border-radius: 20px; background: var(--background); }\n.previewNote { min-height: 20px; margin: 0; color: var(--text-muted); font-size: var(--text-xs); }\n\n@media (prefers-reduced-motion: reduce) {\n  .topic, .channelIcon, .statusDot { transition: none; }\n}\n"},{"path":"lib/media.ts","type":"registry:lib","target":"@components/arc/lib/media.ts","content":"/**\n * Shared demo media. Files live in `public/media/`, credits in `public/media/CREDITS.md`.\n * People are seeded gradient avatars from `npm run avatars` (400 px squares);\n * photos are 1600 px on the long side.\n */\n\nexport interface MediaPerson {\n  id: string;\n  name: string;\n  role?: string;\n  src: string;\n}\n\nexport interface MediaPhoto {\n  id: string;\n  alt: string;\n  src: string;\n  width: number;\n  height: number;\n}\n\nexport const people = [\n  { id: \"emma-collins\", name: \"Emma Collins\", role: \"Product designer\", src: \"/media/people/emma-collins.svg\" },\n  { id: \"marcus-johnson\", name: \"Marcus Johnson\", role: \"Frontend engineer\", src: \"/media/people/marcus-johnson.svg\" },\n  { id: \"jasmine-brooks\", name: \"Jasmine Brooks\", role: \"Design lead\", src: \"/media/people/jasmine-brooks.svg\" },\n  { id: \"olivia-bennett\", name: \"Olivia Bennett\", role: \"Platform engineer\", src: \"/media/people/olivia-bennett.svg\" },\n  { id: \"sofia-ramirez\", name: \"Sofia Ramirez\", role: \"Operations lead\", src: \"/media/people/sofia-ramirez.svg\" },\n  { id: \"ryan-sullivan\", name: \"Ryan Sullivan\", role: \"Account executive\", src: \"/media/people/ryan-sullivan.svg\" },\n  { id: \"hannah-walsh\", name: \"Hannah Walsh\", role: \"Customer success\", src: \"/media/people/hannah-walsh.svg\" },\n  { id: \"chloe-nguyen\", name: \"Chloe Nguyen\", role: \"Data analyst\", src: \"/media/people/chloe-nguyen.svg\" },\n  { id: \"ava-mitchell\", name: \"Ava Mitchell\", role: \"Marketing manager\", src: \"/media/people/ava-mitchell.svg\" },\n  { id: \"daniel-kim\", name: \"Daniel Kim\", role: \"Backend engineer\", src: \"/media/people/daniel-kim.svg\" },\n  { id: \"jordan-reyes\", name: \"Jordan Reyes\", role: \"Support specialist\", src: \"/media/people/jordan-reyes.svg\" },\n  { id: \"mateo-alvarez\", name: \"Mateo Alvarez\", role: \"Mobile engineer\", src: \"/media/people/mateo-alvarez.svg\" },\n  { id: \"tyler-hayes\", name: \"Tyler Hayes\", role: \"Sales lead\", src: \"/media/people/tyler-hayes.svg\" },\n  { id: \"andre-williams\", name: \"Andre Williams\", role: \"Finance partner\", src: \"/media/people/andre-williams.svg\" },\n  { id: \"nathan-cole\", name: \"Nathan Cole\", role: \"Engineering manager\", src: \"/media/people/nathan-cole.svg\" },\n  { id: \"diane-foster\", name: \"Diane Foster\", role: \"Chief operating officer\", src: \"/media/people/diane-foster.svg\" },\n] as const satisfies readonly MediaPerson[];\n\nexport const photos = [\n  { id: \"lounge-chair\", alt: \"A woven oak lounge chair with a sheepskin and linen cushion on a concrete floor\", src: \"/media/photos/lounge-chair.jpg\", width: 1280, height: 1600 },\n  { id: \"table-lamp\", alt: \"A white mushroom table lamp glowing beside books and a small vase\", src: \"/media/photos/table-lamp.jpg\", width: 1600, height: 900 },\n  { id: \"linen-throw\", alt: \"Folded natural linen throws with fringed edges in soft window light\", src: \"/media/photos/linen-throw.jpg\", width: 1067, height: 1600 },\n  { id: \"glass-carafe\", alt: \"A hand pouring water from a ribbed glass carafe into tumblers\", src: \"/media/photos/glass-carafe.jpg\", width: 1280, height: 1600 },\n  { id: \"stoneware-cups\", alt: \"Two speckled stoneware cups with a lid on a pale table\", src: \"/media/photos/stoneware-cups.jpg\", width: 1067, height: 1600 },\n  { id: \"stacked-bowls\", alt: \"Two stacked speckled ceramic bowls against a dark wall\", src: \"/media/photos/stacked-bowls.jpg\", width: 1600, height: 1067 },\n  { id: \"ceramic-lamp\", alt: \"A sculptural ceramic lamp with a linen shade on a walnut sideboard\", src: \"/media/photos/ceramic-lamp.jpg\", width: 1067, height: 1600 },\n  { id: \"living-room\", alt: \"A bright living room with timber beams, arched windows, and cream sofas\", src: \"/media/photos/living-room.jpg\", width: 1200, height: 1600 },\n  { id: \"sunroom\", alt: \"A sunroom with a round dining table, plants, and windows on three sides\", src: \"/media/photos/sunroom.jpg\", width: 1600, height: 1067 },\n  { id: \"home-office\", alt: \"A home office with a wooden desk and deep green walls\", src: \"/media/photos/home-office.jpg\", width: 1600, height: 1200 },\n  { id: \"reading-chair\", alt: \"A grey armchair and ottoman with a knit throw in a dark green room\", src: \"/media/photos/reading-chair.jpg\", width: 1600, height: 900 },\n  { id: \"bedroom\", alt: \"A made bed with striped linen pillows against an oak headboard\", src: \"/media/photos/bedroom.jpg\", width: 1067, height: 1600 },\n  { id: \"restaurant\", alt: \"A warm restaurant dining room with woven pendant lights and a tree\", src: \"/media/photos/restaurant.jpg\", width: 1067, height: 1600 },\n  { id: \"wine-bar\", alt: \"A glass carafe of red wine on a bar table in low evening light\", src: \"/media/photos/wine-bar.jpg\", width: 1600, height: 1067 },\n  { id: \"concert-hall\", alt: \"Curved stainless steel panels of the Walt Disney Concert Hall against a blue sky\", src: \"/media/photos/concert-hall.jpg\", width: 1600, height: 1143 },\n  { id: \"curved-facade\", alt: \"A white tiled building facade with curved balconies\", src: \"/media/photos/curved-facade.jpg\", width: 1600, height: 1067 },\n  { id: \"pool-house\", alt: \"A modern glass house beside a long pool under a clear sky\", src: \"/media/photos/pool-house.jpg\", width: 1600, height: 900 },\n  { id: \"terracotta-waves\", alt: \"Wavy terracotta walls rising toward a blue sky\", src: \"/media/photos/terracotta-waves.jpg\", width: 1067, height: 1600 },\n  { id: \"mountain-ridges\", alt: \"Layered mountain ridges under a warm evening sky\", src: \"/media/photos/mountain-ridges.jpg\", width: 1600, height: 1068 },\n  { id: \"alpine-lake\", alt: \"A calm alpine lake reflecting a rocky peak at golden hour\", src: \"/media/photos/alpine-lake.jpg\", width: 1067, height: 1600 },\n  { id: \"coastline\", alt: \"A long coastline with waves rolling onto a beach below green cliffs\", src: \"/media/photos/coastline.jpg\", width: 1200, height: 1600 },\n  { id: \"sea-at-dusk\", alt: \"A calm sea at dusk with a low island on the horizon\", src: \"/media/photos/sea-at-dusk.jpg\", width: 1067, height: 1600 },\n  { id: \"lisbon-tram\", alt: \"A yellow tram on a street lined with historic buildings in Lisbon\", src: \"/media/photos/lisbon-tram.jpg\", width: 1600, height: 1064 },\n  { id: \"lisbon-bridge\", alt: \"The 25 de Abril Bridge crossing the Tagus in Lisbon\", src: \"/media/photos/lisbon-bridge.jpg\", width: 1600, height: 1166 },\n  { id: \"lisbon-rooftops\", alt: \"Terracotta rooftops of Lisbon running down to the river\", src: \"/media/photos/lisbon-rooftops.jpg\", width: 1280, height: 1600 },\n  { id: \"salmon-dinner\", alt: \"Seared salmon with a bright herb salsa and a glass of red wine\", src: \"/media/photos/salmon-dinner.jpg\", width: 1067, height: 1600 },\n  { id: \"chef-plating\", alt: \"A chef spooning sauce onto a plated dish in a dark kitchen\", src: \"/media/photos/chef-plating.jpg\", width: 1600, height: 1600 },\n] as const satisfies readonly MediaPhoto[];\n\nexport type PersonId = (typeof people)[number][\"id\"];\nexport type PhotoId = (typeof photos)[number][\"id\"];\n\n/** Looks up a person by id. */\nexport function person(id: PersonId): MediaPerson {\n  return people.find(entry => entry.id === id)!;\n}\n\n/** Looks up a photo by id. */\nexport function photo(id: PhotoId): MediaPhoto {\n  return photos.find(entry => entry.id === id)!;\n}\n\n/** Square 400 px avatar path for a person id, for `src` props. */\nexport const avatar = (id: PersonId) => person(id).src;\n\n/** 800 × 1000 portrait of the same avatar, for image-led layouts. */\nexport const portrait = (id: PersonId) => `/media/people/portrait/${id}.svg`;\n\n/** The first `count` people, for avatar stacks and lists. */\nexport const peopleSample = (count: number) => people.slice(0, count);\n"}],"docs":"Use this as a starting point and replace the sample data with your own.","meta":{"tier":"free","kind":"block","builtFrom":["Motion"],"docs":"https://uiarc.dev/components/blocks/contact-section"}}