{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "order-history-block",
  "title": "Order History Block",
  "description": "An account orders page: status tabs with counts, search by order number or product, order cards with stacked thumbnails and colored status pills (a pulsing dot for orders on the way), expandable details with a delivery progress timeline, tracking number, line items and actions to track, buy again, return, cancel or download the invoice.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/order-history-block/order-history-block.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, 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\ntype Status = \"processing\" | \"shipped\" | \"delivered\" | \"returned\";\n\nexport interface OrderLine {\n  title: string;\n  variant: string;\n  price: number;\n  quantity: number;\n  image?: string;\n}\n\nexport interface PastOrder {\n  id: string;\n  date: string;\n  status: Status;\n  /** Index of the current step in the timeline (0 ordered … 3 delivered). */\n  step: number;\n  steps: string[];\n  eta?: string;\n  carrier?: string;\n  lines: OrderLine[];\n}\n\nexport interface OrderHistoryBlockProps {\n  orders?: PastOrder[];\n  currency?: string;\n  onBuyAgain?: (order: PastOrder) => void;\n  onReturn?: (order: PastOrder) => void;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { bg: \"#0A0A0A\", title: \"#FFFFFF\", muted: \"rgba(255,255,255,0.45)\", body: \"rgba(255,255,255,0.62)\", line: \"rgba(255,255,255,0.12)\", card: \"#141414\", well: \"rgba(255,255,255,0.04)\", photo: \"#F1F1F1\", input: \"#0F0F0F\", buttonBg: \"#FFFFFF\", buttonText: \"#111111\", green: \"#7CDE6A\", amber: \"#F5B544\", blue: \"#6FA8FF\", grey: \"rgba(255,255,255,0.5)\", ring: \"rgba(255,255,255,0.5)\" },\n  light: { bg: \"#FFFFFF\", title: \"#111111\", muted: \"rgba(0,0,0,0.45)\", body: \"rgba(0,0,0,0.62)\", line: \"rgba(0,0,0,0.1)\", card: \"#F7F7F6\", well: \"rgba(0,0,0,0.03)\", photo: \"#F1F1F1\", input: \"#FFFFFF\", buttonBg: \"#111111\", buttonText: \"#FFFFFF\", green: \"#2F9E44\", amber: \"#B7791F\", blue: \"#2563EB\", grey: \"rgba(0,0,0,0.5)\", ring: \"rgba(0,0,0,0.45)\" },\n};\nconst L = (title: string, variant: string, price: number, quantity: number, image: string): OrderLine => ({ title, variant, price, quantity, image });\nconst ORDERS: PastOrder[] = [\n  { id: \"NL-48213\", date: \"Nov 1, 2026\", status: \"shipped\", step: 2, steps: [\"Ordered · Nov 1\", \"Shipped · Nov 2\", \"Out for delivery · today\", \"Delivered\"], eta: \"Arrives today by 6 pm\", carrier: \"Parcelwise 7731 0042 18\", lines: [L(\"Wireless Earbuds\", \"Black\", 129, 1, \"/demo/wireless-earbuds.webp\"), L(\"Insulated Water Bottle\", \"750 ml\", 39, 2, \"/demo/insulated-water-bottle.webp\")] },\n  { id: \"NL-47106\", date: \"Oct 30, 2026\", status: \"processing\", step: 0, steps: [\"Ordered · Oct 30\", \"Shipped\", \"Out for delivery\", \"Delivered\"], eta: \"Ships within 1 business day\", lines: [L(\"Laptop Stand\", \"Space black\", 49, 1, \"/demo/laptop-stand.webp\")] },\n  { id: \"NL-45520\", date: \"Oct 12, 2026\", status: \"delivered\", step: 3, steps: [\"Ordered · Oct 12\", \"Shipped · Oct 13\", \"Out for delivery · Oct 15\", \"Delivered · Oct 15\"], carrier: \"Parcelwise 7720 9981 03\", lines: [L(\"Minimal Watch\", \"Black · 40mm\", 79, 1, \"/demo/minimal-watch.webp\"), L(\"Premium Notebook\", \"A5 · Dotted\", 24, 3, \"/demo/notebook.webp\"), L(\"Running Shoes\", \"White · EU 42\", 99, 1, \"/demo/running-shoes.webp\")] },\n  { id: \"NL-43987\", date: \"Sep 21, 2026\", status: \"returned\", step: 3, steps: [\"Ordered · Sep 21\", \"Shipped · Sep 22\", \"Delivered · Sep 24\", \"Refunded · Oct 2\"], lines: [L(\"Running Shoes\", \"White · EU 43\", 99, 1, \"/demo/running-shoes.webp\")] },\n];\nconst TABS: { id: \"all\" | Status; label: string }[] = [\n  { id: \"all\", label: \"All\" },\n  { id: \"processing\", label: \"Processing\" },\n  { id: \"shipped\", label: \"On the way\" },\n  { id: \"delivered\", label: \"Delivered\" },\n  { id: \"returned\", label: \"Returned\" },\n];\n\nexport function OrderHistoryBlock({ orders = ORDERS, currency = \"$\", onBuyAgain, onReturn, theme = \"dark\", className }: OrderHistoryBlockProps) {\n  const p = PALETTES[theme];\n  const reduce = !!useReducedMotion();\n  const uid = React.useId();\n  const [tab, setTab] = React.useState<\"all\" | Status>(\"all\");\n  const [query, setQuery] = React.useState(\"\");\n  const [open, setOpen] = React.useState<string | null>(orders[0]?.id ?? null);\n  const [toast, setToast] = React.useState<string | null>(null);\n\n  React.useEffect(() => {\n    if (!toast) return;\n    const t = setTimeout(() => setToast(null), 2200);\n    return () => clearTimeout(t);\n  }, [toast]);\n\n  const money = (n: number) => `${currency}${n.toFixed(2)}`;\n  const color: Record<Status, string> = { processing: p.amber, shipped: p.blue, delivered: p.green, returned: p.grey };\n  const label: Record<Status, string> = { processing: \"Processing\", shipped: \"On the way\", delivered: \"Delivered\", returned: \"Returned\" };\n  const q = query.trim().toLowerCase();\n  const shown = orders.filter((o) => (tab === \"all\" || o.status === tab) && (!q || o.id.toLowerCase().includes(q) || o.lines.some((l) => l.title.toLowerCase().includes(q))));\n  const count = (t: \"all\" | Status) => (t === \"all\" ? orders.length : orders.filter((o) => o.status === t).length);\n\n  const ring = { [\"--tw-ring-color\" as string]: p.ring, [\"--tw-ring-offset-color\" as string]: p.card } as React.CSSProperties;\n  const focus = \"outline-none focus-visible:ring-2 focus-visible:ring-offset-2\";\n  const ghost = cn(\"flex h-9 cursor-pointer items-center justify-center rounded-full border px-4 text-[12.5px] font-medium\", focus);\n\n  return (\n    <section className={cn(\"@container relative w-full\", className)} style={{ background: p.bg, color: p.title }}>\n      <div className=\"mx-auto max-w-4xl px-4 py-10 @[640px]:px-8\">\n        <div className=\"flex flex-wrap items-end justify-between gap-3\">\n          <div>\n            <h2 className=\"m-0 text-[28px] font-semibold tracking-[-0.03em]\">Your orders</h2>\n            <p className=\"m-0 mt-1 text-[13.5px]\" style={{ color: p.muted }}>\n              Track, return or buy something again.\n            </p>\n          </div>\n          <label className=\"flex h-10 w-full items-center gap-2 rounded-full border px-4 focus-within:ring-2 @[640px]:w-64\" style={{ borderColor: p.line, background: p.input, color: p.muted, ...ring }}>\n            <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" aria-hidden=\"true\">\n              <path d=\"M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14zM21 21l-4.3-4.3\" />\n            </svg>\n            <input value={query} onChange={(e) => setQuery(e.target.value)} placeholder=\"Order number or product\" aria-label=\"Search orders\" className=\"h-full min-w-0 flex-1 border-0 bg-transparent text-[13px] outline-none\" style={{ color: p.title }} />\n          </label>\n        </div>\n\n        <div role=\"tablist\" aria-label=\"Order status\" className=\"mt-5 flex gap-1 overflow-x-auto [scrollbar-width:none]\">\n          {TABS.map((t) => (\n            <button key={t.id} type=\"button\" role=\"tab\" aria-selected={tab === t.id} onClick={() => setTab(t.id)} className={cn(\"relative h-9 shrink-0 cursor-pointer rounded-full border-0 bg-transparent px-3.5 text-[13px] font-medium whitespace-nowrap\", focus)} style={{ color: tab === t.id ? p.buttonText : p.body, ...ring }}>\n              {tab === t.id && <motion.span layoutId={reduce ? undefined : `${uid}-tab`} className=\"absolute inset-0 rounded-full\" style={{ background: p.buttonBg }} transition={{ type: \"spring\", stiffness: 500, damping: 38 }} />}\n              <span className=\"relative\">\n                {t.label} <span className=\"tabular-nums opacity-60\">{count(t.id)}</span>\n              </span>\n            </button>\n          ))}\n        </div>\n\n        <ul className=\"m-0 mt-5 flex list-none flex-col gap-3 p-0\">\n          {shown.map((o) => {\n            const isOpen = open === o.id;\n            const total = o.lines.reduce((a, l) => a + l.price * l.quantity, 0);\n            const items = o.lines.reduce((a, l) => a + l.quantity, 0);\n            return (\n              <motion.li key={o.id} initial={reduce ? false : { opacity: 0, y: 8 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.25 }} className=\"overflow-hidden rounded-2xl border\" style={{ borderColor: isOpen ? p.title : p.line, background: p.card }}>\n                <button type=\"button\" onClick={() => setOpen(isOpen ? null : o.id)} aria-expanded={isOpen} aria-controls={`${uid}-${o.id}`} className={cn(\"flex w-full cursor-pointer flex-wrap items-center gap-x-4 gap-y-3 border-0 bg-transparent p-4 text-left\", focus)} style={{ color: p.title, ...ring }}>\n                  <span className=\"flex shrink-0 -space-x-3\">\n                    {o.lines.slice(0, 3).map((l, i) => (\n                      <span key={i} className={cn(\"relative h-12 w-12 overflow-hidden rounded-xl border-2\", i > 0 && \"hidden @[480px]:block\")} style={{ background: p.photo, borderColor: p.card, zIndex: 3 - i }}>\n                        {/* eslint-disable-next-line @next/next/no-img-element */}\n                        {l.image && <img src={l.image} alt=\"\" className=\"h-full w-full object-cover\" />}\n                        {i === 0 && o.lines.length > 1 && (\n                          <span className=\"absolute right-0 bottom-0 rounded-tl-md px-1 text-[10px] font-semibold @[480px]:hidden\" style={{ background: p.buttonBg, color: p.buttonText }}>\n                            +{o.lines.length - 1}\n                          </span>\n                        )}\n                      </span>\n                    ))}\n                  </span>\n                  <span className=\"min-w-0 flex-1\">\n                    <span className=\"flex flex-wrap items-center gap-2\">\n                      <span className=\"font-mono text-[13.5px] font-semibold\">#{o.id}</span>\n                      <span className=\"inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-[11.5px] font-medium\" style={{ background: `${color[o.status]}1F`, color: color[o.status] }}>\n                        <span className=\"relative h-1.5 w-1.5 rounded-full\" style={{ background: color[o.status] }}>\n                          {o.status === \"shipped\" && !reduce && <motion.span className=\"absolute inset-0 rounded-full\" style={{ background: color[o.status] }} animate={{ scale: [1, 2.6], opacity: [0.7, 0] }} transition={{ repeat: Infinity, duration: 1.4 }} />}\n                        </span>\n                        {label[o.status]}\n                      </span>\n                    </span>\n                    <span className=\"mt-0.5 block text-[12.5px]\" style={{ color: p.muted }}>\n                      {o.date} · {items} {items === 1 ? \"item\" : \"items\"}\n                      {o.eta ? ` · ${o.eta}` : \"\"}\n                    </span>\n                  </span>\n                  <span className=\"text-[15px] font-semibold tabular-nums\">{money(total)}</span>\n                  <motion.svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke={p.muted} strokeWidth=\"2.2\" strokeLinecap=\"round\" animate={{ rotate: isOpen ? 180 : 0 }} aria-hidden=\"true\">\n                    <path d=\"m6 9 6 6 6-6\" />\n                  </motion.svg>\n                </button>\n                <AnimatePresence initial={false}>\n                  {isOpen && (\n                    <motion.div key=\"d\" id={`${uid}-${o.id}`} role=\"region\" aria-label={`Order ${o.id} details`} initial={reduce ? false : { height: 0, opacity: 0 }} animate={{ height: \"auto\", opacity: 1 }} exit={reduce ? undefined : { height: 0, opacity: 0 }} transition={{ duration: 0.28, ease: [0.22, 1, 0.36, 1] }} className=\"overflow-hidden\">\n                      <div className=\"border-t px-4 pt-4 pb-4\" style={{ borderColor: p.line }}>\n                        {/* Timeline */}\n                        <ol className=\"m-0 grid list-none grid-cols-4 gap-1 p-0\" aria-label=\"Delivery progress\">\n                          {o.steps.map((s, i) => {\n                            const done = i <= o.step;\n                            const tint = o.status === \"returned\" && i === 3 ? p.grey : p.green;\n                            return (\n                              <li key={s} className=\"min-w-0\" aria-current={i === o.step ? \"step\" : undefined}>\n                                <span className=\"block h-1.5 overflow-hidden rounded-full\" style={{ background: p.line }}>\n                                  <motion.span className=\"block h-full rounded-full\" style={{ background: tint }} initial={reduce ? false : { width: 0 }} animate={{ width: done ? \"100%\" : \"0%\" }} transition={{ duration: 0.5, delay: reduce ? 0 : 0.1 + i * 0.15 }} />\n                                </span>\n                                <span className=\"mt-2 block text-[11.5px] leading-tight\" style={{ color: done ? p.title : p.muted }}>\n                                  {s}\n                                </span>\n                              </li>\n                            );\n                          })}\n                        </ol>\n                        {o.carrier && (\n                          <p className=\"m-0 mt-3 text-[12px]\" style={{ color: p.muted }}>\n                            Tracking: <span className=\"font-mono\" style={{ color: p.body }}>{o.carrier}</span>\n                          </p>\n                        )}\n\n                        <ul className=\"m-0 mt-4 flex list-none flex-col gap-2.5 p-0\">\n                          {o.lines.map((l, i) => (\n                            <li key={i} className=\"flex items-center gap-3 rounded-xl p-2\" style={{ background: p.well }}>\n                              <span className=\"h-11 w-11 shrink-0 overflow-hidden rounded-lg\" style={{ background: p.photo }}>\n                                {/* eslint-disable-next-line @next/next/no-img-element */}\n                                {l.image && <img src={l.image} alt=\"\" className=\"h-full w-full object-cover\" />}\n                              </span>\n                              <span className=\"min-w-0 flex-1\">\n                                <span className=\"block truncate text-[13.5px] font-medium\">{l.title}</span>\n                                <span className=\"block text-[12px]\" style={{ color: p.muted }}>\n                                  {l.variant} · Qty {l.quantity}\n                                </span>\n                              </span>\n                              <span className=\"text-[13px] tabular-nums\">{money(l.price * l.quantity)}</span>\n                            </li>\n                          ))}\n                        </ul>\n\n                        <div className=\"mt-4 flex flex-wrap gap-2\">\n                          {o.status === \"shipped\" && (\n                            <button type=\"button\" onClick={() => setToast(`Opening tracking for #${o.id}`)} className={ghost} style={{ background: p.buttonBg, color: p.buttonText, borderColor: p.buttonBg, ...ring }}>\n                              Track package\n                            </button>\n                          )}\n                          {o.status !== \"processing\" && (\n                            <button\n                              type=\"button\"\n                              onClick={() => {\n                                onBuyAgain?.(o);\n                                setToast(`${o.lines.length === 1 ? o.lines[0].title : `${o.lines.length} items`} added to your bag`);\n                              }}\n                              className={ghost}\n                              style={{ borderColor: p.line, background: \"transparent\", color: p.title, ...ring }}\n                            >\n                              Buy again\n                            </button>\n                          )}\n                          {o.status === \"delivered\" && (\n                            <button\n                              type=\"button\"\n                              onClick={() => {\n                                onReturn?.(o);\n                                setToast(`Return started for #${o.id} · label sent by email`);\n                              }}\n                              className={ghost}\n                              style={{ borderColor: p.line, background: \"transparent\", color: p.title, ...ring }}\n                            >\n                              Return items\n                            </button>\n                          )}\n                          {o.status === \"processing\" && (\n                            <button type=\"button\" onClick={() => setToast(`#${o.id} cancelled · refund on its way`)} className={ghost} style={{ borderColor: p.line, background: \"transparent\", color: p.title, ...ring }}>\n                              Cancel order\n                            </button>\n                          )}\n                          <button type=\"button\" onClick={() => setToast(`Invoice for #${o.id} downloaded`)} className={cn(ghost, \"border-0\")} style={{ background: \"transparent\", color: p.body, ...ring }}>\n                            Invoice\n                          </button>\n                        </div>\n                      </div>\n                    </motion.div>\n                  )}\n                </AnimatePresence>\n              </motion.li>\n            );\n          })}\n          {shown.length === 0 && (\n            <li className=\"rounded-2xl border px-6 py-12 text-center text-[13.5px]\" style={{ borderColor: p.line, color: p.muted }}>\n              No orders match “{query || TABS.find((t) => t.id === tab)?.label}”.\n            </li>\n          )}\n        </ul>\n      </div>\n      <AnimatePresence>\n        {toast && (\n          <motion.div key={toast} role=\"status\" initial={reduce ? false : { opacity: 0, y: 8 }} animate={{ opacity: 1, y: 0 }} exit={reduce ? undefined : { opacity: 0 }} className=\"pointer-events-none absolute bottom-5 left-1/2 z-10 -translate-x-1/2 rounded-full border px-4 py-2 text-[12.5px] whitespace-nowrap shadow-xl\" style={{ background: p.card, borderColor: p.line }}>\n            {toast}\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </section>\n  );\n}\n\nexport default OrderHistoryBlock;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}