{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "faq-section",
  "title": "FAQ Section",
  "description": "A frequently asked questions section: heading and contact card on the left, an animated accordion on the right, optional category tabs and search, and FAQPage structured data for search engines.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/faq-section/faq-section.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, AnimatePresence, useReducedMotion } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport interface FaqItem {\n  question: string;\n  /** Plain text also goes into the FAQPage JSON-LD; a node is shown as is. */\n  answer: React.ReactNode;\n  /** Groups the item under a tab. Tabs only show when two or more categories exist. */\n  category?: string;\n}\n\nexport interface FaqSectionProps {\n  items?: FaqItem[];\n  eyebrow?: string;\n  title?: string;\n  description?: string;\n  /** Let more than one answer be open at once. */\n  allowMultiple?: boolean;\n  /** Index (in items) of the answer open on load. Pass -1 for none. */\n  defaultOpen?: number;\n  /** Show a search box that filters questions and answers. */\n  searchable?: boolean;\n  /** The \"still have questions\" card. Hidden when contactHref is not set. */\n  contactTitle?: string;\n  contactText?: string;\n  contactLabel?: string;\n  contactHref?: string;\n  /** Add schema.org FAQPage JSON-LD for the items with plain-text answers. */\n  jsonLd?: boolean;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst DEFAULT_ITEMS: FaqItem[] = [\n  { category: \"General\", question: \"What is included in the free plan?\", answer: \"The free plan includes one project, up to 1,000 events a month and community support. It never expires, so you can stay on it as long as you like.\" },\n  { category: \"General\", question: \"Do I need a credit card to start?\", answer: \"No. You can sign up and use the free plan without a card. We only ask for payment details when you upgrade.\" },\n  { category: \"Billing\", question: \"Can I change plans later?\", answer: \"Yes, you can upgrade or downgrade at any time from your billing settings. Changes take effect right away and we prorate the difference.\" },\n  { category: \"Billing\", question: \"Do you offer refunds?\", answer: \"If you're not happy within the first 14 days of a paid plan, contact us and we'll refund you in full, no questions asked.\" },\n  { category: \"Account\", question: \"How do I invite my team?\", answer: \"Open Settings, then Members, and send invites by email. Team members join your workspace as soon as they accept.\" },\n  { category: \"Account\", question: \"Can I export my data?\", answer: \"Yes. You can export everything as CSV or JSON from Settings at any time, including after you cancel.\" },\n];\n\nconst PALETTES = {\n  dark: {\n    text: \"#F5F4F1\",\n    muted: \"rgba(245,244,241,0.6)\",\n    faint: \"rgba(245,244,241,0.35)\",\n    line: \"rgba(255,255,255,0.1)\",\n    card: \"rgba(255,255,255,0.03)\",\n    hover: \"rgba(255,255,255,0.03)\",\n    field: \"rgba(255,255,255,0.03)\",\n    fieldBorder: \"rgba(255,255,255,0.12)\",\n    tab: \"rgba(255,255,255,0.05)\",\n    thumb: \"#F5F4F1\",\n    onThumb: \"#0A0A0A\",\n    primary: \"#F5F4F1\",\n    onPrimary: \"#0A0A0A\",\n  },\n  light: {\n    text: \"#0A0A0A\",\n    muted: \"rgba(10,10,10,0.6)\",\n    faint: \"rgba(10,10,10,0.35)\",\n    line: \"rgba(10,10,10,0.1)\",\n    card: \"#FFFFFF\",\n    hover: \"rgba(10,10,10,0.025)\",\n    field: \"#FFFFFF\",\n    fieldBorder: \"rgba(10,10,10,0.14)\",\n    tab: \"rgba(10,10,10,0.05)\",\n    thumb: \"#0A0A0A\",\n    onThumb: \"#FFFFFF\",\n    primary: \"#0A0A0A\",\n    onPrimary: \"#FFFFFF\",\n  },\n};\n\nfunction PlusIcon({ open, color, reduce }: { open: boolean; color: string; reduce: boolean | null }) {\n  return (\n    <motion.svg\n      width=\"18\"\n      height=\"18\"\n      viewBox=\"0 0 24 24\"\n      fill=\"none\"\n      stroke={color}\n      strokeWidth={2}\n      strokeLinecap=\"round\"\n      aria-hidden=\"true\"\n      animate={{ rotate: open ? 45 : 0 }}\n      transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 380, damping: 26 }}\n    >\n      <path d=\"M12 5v14M5 12h14\" />\n    </motion.svg>\n  );\n}\n\nfunction textOf(node: React.ReactNode): string | null {\n  if (typeof node === \"string\" || typeof node === \"number\") return String(node);\n  return null;\n}\n\nexport function FaqSection({\n  items = DEFAULT_ITEMS,\n  eyebrow = \"FAQ\",\n  title = \"Frequently asked questions\",\n  description = \"Everything you need to know about the product and billing. Can't find what you're looking for? Get in touch.\",\n  allowMultiple = false,\n  defaultOpen = 0,\n  searchable = false,\n  contactTitle = \"Still have questions?\",\n  contactText = \"Our team usually replies within a few hours.\",\n  contactLabel = \"Contact support\",\n  contactHref,\n  jsonLd = false,\n  theme = \"dark\",\n  className,\n}: FaqSectionProps) {\n  const p = PALETTES[theme];\n  const reduce = useReducedMotion();\n  const uid = React.useId();\n\n  const categories = React.useMemo(() => {\n    const seen: string[] = [];\n    for (const it of items) if (it.category && !seen.includes(it.category)) seen.push(it.category);\n    return seen;\n  }, [items]);\n  const showTabs = categories.length > 1;\n\n  const [tab, setTab] = React.useState(\"All\");\n  const [query, setQuery] = React.useState(\"\");\n  const [open, setOpen] = React.useState<number[]>(defaultOpen >= 0 && defaultOpen < items.length ? [defaultOpen] : []);\n\n  const q = query.trim().toLowerCase();\n  const visible = items\n    .map((it, index) => ({ ...it, index }))\n    .filter((it) => tab === \"All\" || it.category === tab)\n    .filter((it) => !q || it.question.toLowerCase().includes(q) || (textOf(it.answer) ?? \"\").toLowerCase().includes(q));\n\n  const toggle = (index: number) =>\n    setOpen((cur) => (cur.includes(index) ? cur.filter((i) => i !== index) : allowMultiple ? [...cur, index] : [index]));\n\n  const schema = React.useMemo(() => {\n    if (!jsonLd) return null;\n    const entries = items\n      .map((it) => ({ q: it.question, a: textOf(it.answer) }))\n      .filter((it): it is { q: string; a: string } => it.a !== null)\n      .map((it) => ({ \"@type\": \"Question\", name: it.q, acceptedAnswer: { \"@type\": \"Answer\", text: it.a } }));\n    return entries.length ? JSON.stringify({ \"@context\": \"https://schema.org\", \"@type\": \"FAQPage\", mainEntity: entries }) : null;\n  }, [items, jsonLd]);\n\n  return (\n    <section className={cn(\"w-full\", className)} style={{ color: p.text }}>\n      {schema && <script type=\"application/ld+json\" dangerouslySetInnerHTML={{ __html: schema }} />}\n      <div className=\"grid grid-cols-1 gap-10 lg:grid-cols-[minmax(0,1fr)_minmax(0,1.6fr)] lg:gap-16\">\n        <div className=\"flex flex-col\">\n          {eyebrow && (\n            <span className=\"text-xs font-semibold uppercase tracking-[0.14em]\" style={{ color: p.faint }}>\n              {eyebrow}\n            </span>\n          )}\n          <h2 className=\"mt-3 text-3xl font-semibold leading-tight tracking-tight sm:text-4xl\">{title}</h2>\n          {description && (\n            <p className=\"mt-4 max-w-md text-[15px] leading-6\" style={{ color: p.muted }}>\n              {description}\n            </p>\n          )}\n          {contactHref && (\n            <div className=\"mt-8 hidden max-w-sm rounded-2xl p-5 lg:block\" style={{ background: p.card, border: `1px solid ${p.line}` }}>\n              <p className=\"text-sm font-semibold\">{contactTitle}</p>\n              <p className=\"mt-1 text-sm\" style={{ color: p.muted }}>\n                {contactText}\n              </p>\n              <a href={contactHref} className=\"mt-4 inline-flex h-10 items-center rounded-xl px-4 text-sm font-semibold transition-[filter] hover:brightness-110\" style={{ background: p.primary, color: p.onPrimary }}>\n                {contactLabel}\n              </a>\n            </div>\n          )}\n        </div>\n\n        <div className=\"min-w-0\">\n          {(showTabs || searchable) && (\n            <div className=\"mb-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between\">\n              {showTabs && (\n                <div role=\"tablist\" aria-label=\"FAQ categories\" className=\"-mx-1 flex gap-1 overflow-x-auto px-1 [scrollbar-width:none]\">\n                  {[\"All\", ...categories].map((c) => {\n                    const active = tab === c;\n                    return (\n                      <button\n                        key={c}\n                        type=\"button\"\n                        role=\"tab\"\n                        aria-selected={active}\n                        onClick={() => setTab(c)}\n                        className=\"relative h-8 shrink-0 rounded-full px-3.5 text-sm font-medium outline-none transition-colors focus-visible:ring-2\"\n                        style={{ color: active ? p.onThumb : p.muted, background: active ? undefined : p.tab }}\n                      >\n                        {active && (\n                          <motion.span\n                            layoutId={`${uid}-tab`}\n                            className=\"absolute inset-0 rounded-full\"\n                            style={{ background: p.thumb }}\n                            transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 420, damping: 34 }}\n                          />\n                        )}\n                        <span className=\"relative\">{c}</span>\n                      </button>\n                    );\n                  })}\n                </div>\n              )}\n              {searchable && (\n                <label className=\"relative block sm:w-60\">\n                  <span className=\"sr-only\">Search questions</span>\n                  <svg className=\"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2\" width=\"15\" height=\"15\" viewBox=\"0 0 24 24\" fill=\"none\" stroke={p.faint} strokeWidth={2} strokeLinecap=\"round\" aria-hidden=\"true\">\n                    <circle cx=\"11\" cy=\"11\" r=\"7\" />\n                    <path d=\"m20 20-3.5-3.5\" />\n                  </svg>\n                  <input\n                    type=\"search\"\n                    value={query}\n                    onChange={(e) => setQuery(e.target.value)}\n                    placeholder=\"Search questions\"\n                    className=\"h-9 w-full rounded-full pl-9 pr-3 text-sm outline-none transition-colors placeholder:opacity-100 focus-visible:ring-2\"\n                    style={{ background: p.field, border: `1px solid ${p.fieldBorder}`, color: p.text }}\n                  />\n                </label>\n              )}\n            </div>\n          )}\n\n          <div style={{ borderTop: `1px solid ${p.line}` }}>\n            {visible.length === 0 && (\n              <p className=\"py-10 text-center text-sm\" style={{ color: p.muted }}>\n                No questions match &ldquo;{query}&rdquo;.\n              </p>\n            )}\n            {visible.map((it) => {\n              const isOpen = open.includes(it.index);\n              const btnId = `${uid}-q${it.index}`;\n              const panelId = `${uid}-a${it.index}`;\n              return (\n                <div key={it.index} style={{ borderBottom: `1px solid ${p.line}` }}>\n                  <h3>\n                    <button\n                      id={btnId}\n                      type=\"button\"\n                      aria-expanded={isOpen}\n                      aria-controls={panelId}\n                      onClick={() => toggle(it.index)}\n                      className=\"group flex w-full items-center justify-between gap-6 py-5 text-left text-[15px] font-medium outline-none focus-visible:ring-2\"\n                    >\n                      <span className=\"transition-opacity group-hover:opacity-80\">{it.question}</span>\n                      <span className=\"shrink-0\">\n                        <PlusIcon open={isOpen} color={isOpen ? p.text : p.muted} reduce={reduce} />\n                      </span>\n                    </button>\n                  </h3>\n                  <AnimatePresence initial={false}>\n                    {isOpen && (\n                      <motion.div\n                        id={panelId}\n                        role=\"region\"\n                        aria-labelledby={btnId}\n                        initial={{ height: 0, opacity: 0 }}\n                        animate={{ height: \"auto\", opacity: 1 }}\n                        exit={{ height: 0, opacity: 0 }}\n                        transition={reduce ? { duration: 0 } : { duration: 0.28, ease: [0.22, 1, 0.36, 1] }}\n                        className=\"overflow-hidden\"\n                      >\n                        <div className=\"pb-5 pr-10 text-[15px] leading-6\" style={{ color: p.muted }}>\n                          {it.answer}\n                        </div>\n                      </motion.div>\n                    )}\n                  </AnimatePresence>\n                </div>\n              );\n            })}\n          </div>\n\n          {contactHref && (\n            <div className=\"mt-8 rounded-2xl p-5 lg:hidden\" style={{ background: p.card, border: `1px solid ${p.line}` }}>\n              <p className=\"text-sm font-semibold\">{contactTitle}</p>\n              <p className=\"mt-1 text-sm\" style={{ color: p.muted }}>\n                {contactText}\n              </p>\n              <a href={contactHref} className=\"mt-4 inline-flex h-10 items-center rounded-xl px-4 text-sm font-semibold\" style={{ background: p.primary, color: p.onPrimary }}>\n                {contactLabel}\n              </a>\n            </div>\n          )}\n        </div>\n      </div>\n    </section>\n  );\n}\n\nexport default FaqSection;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}