{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "invoice-document-viewer",
  "title": "Invoice Document Viewer",
  "description": "Read an invoice as the customer sees it: a printed page you can zoom, page through other invoices, download as PDF and mark paid, with reminders and an activity trail beside it.",
  "dependencies": [],
  "files": [
    {
      "path": "registry/new-york/invoice-document-viewer/invoice-document-viewer.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface InvoiceLine {\n  id: string;\n  description: string;\n  quantity: number;\n  /** Price for one, in currency units. */\n  price: number;\n}\n\nexport type InvoiceState = \"draft\" | \"sent\" | \"overdue\" | \"paid\";\n\nexport interface InvoiceEvent {\n  id: string;\n  text: string;\n  /** e.g. \"3 Nov\". */\n  when: string;\n}\n\nexport interface ViewerInvoice {\n  id: string;\n  number: string;\n  customer: string;\n  /** Who gets reminders. */\n  email: string;\n  address: string[];\n  /** YYYY-MM-DD. */\n  issued: string;\n  /** YYYY-MM-DD. */\n  due: string;\n  status: InvoiceState;\n  lines: InvoiceLine[];\n  /** From 0 to 100. */\n  taxRate?: number;\n  note?: string;\n  activity?: InvoiceEvent[];\n}\n\nexport interface InvoiceDocumentViewerProps extends Omit<\n  React.ComponentPropsWithoutRef<\"section\">,\n  \"title\"\n> {\n  theme?: \"dark\" | \"light\";\n  invoices?: ViewerInvoice[];\n  /** Your business, printed at the top of the page. */\n  seller?: { name: string; address: string[]; email: string };\n  currency?: string;\n  /** Used to count days overdue. YYYY-MM-DD. */\n  today?: string;\n  /** How long sending a reminder takes, in milliseconds. */\n  sendMs?: number;\n  onMarkPaid?: (invoice: ViewerInvoice) => void;\n  onRemind?: (invoice: ViewerInvoice) => void;\n  /** Replace the built-in PDF with your own download. */\n  onDownload?: (invoice: ViewerInvoice) => void;\n  /** The link Copy link puts on the clipboard. */\n  linkFor?: (invoice: ViewerInvoice) => string;\n}\n\nconst FONT =\n  '\"Inter Variable\", Inter, \"SF Pro Display\", -apple-system, BlinkMacSystemFont, sans-serif';\nconst ACCENT = \"#5E6AD2\";\nconst GREEN = \"#27A644\";\nconst ORANGE = \"#FC7840\";\nconst RING = \"outline-none focus-visible:ring-2 focus-visible:ring-[#5E6AD2]\";\nconst PAGE = 560;\nconst ZOOMS = [0.5, 0.67, 0.8, 1, 1.25, 1.5];\nconst ROW = 40;\nconst ROWS = 5;\nconst DAY = 864e5;\n\nconst PALETTES = {\n  dark: {\n    bg: \"#08090A\",\n    desk: \"#141516\",\n    cell: \"#0B0C0D\",\n    border: \"rgba(255,255,255,0.08)\",\n    text: \"#F7F8F8\",\n    soft: \"#D0D6E0\",\n    sub: \"#8A8F98\",\n    faint: \"#62666D\",\n    chip: \"rgba(255,255,255,0.05)\",\n    btn: \"#E5E5E6\",\n    btnText: \"#08090A\",\n    shadow: \"0 12px 40px rgba(0,0,0,0.5)\",\n  },\n  light: {\n    bg: \"#FFFFFF\",\n    desk: \"#F1F2F4\",\n    cell: \"#FFFFFF\",\n    border: \"rgba(8,9,10,0.08)\",\n    text: \"#08090A\",\n    soft: \"#3C3F44\",\n    sub: \"#62666D\",\n    faint: \"#8A8F98\",\n    chip: \"rgba(8,9,10,0.04)\",\n    btn: \"#08090A\",\n    btnText: \"#F7F8F8\",\n    shadow: \"0 12px 40px rgba(8,9,10,0.12)\",\n  },\n};\n\nconst DEFAULT_SELLER = {\n  name: \"Fieldnote Studio\",\n  address: [\"14 Canal Row\", \"Bristol BS1 4QA\"],\n  email: \"billing@fieldnote.studio\",\n};\n\nconst DEFAULT_INVOICES: ViewerInvoice[] = [\n  {\n    id: \"2047\",\n    number: \"INV-2047\",\n    customer: \"Halden Freight\",\n    email: \"ap@haldenfreight.com\",\n    address: [\"Dock Road 9\", \"Rotterdam 3011\"],\n    issued: \"2026-10-02\",\n    due: \"2026-11-01\",\n    status: \"overdue\",\n    taxRate: 20,\n    lines: [\n      {\n        id: \"a\",\n        description: \"Route planner, 40 seats\",\n        quantity: 40,\n        price: 45,\n      },\n      { id: \"b\", description: \"Driver app setup\", quantity: 1, price: 450 },\n      {\n        id: \"c\",\n        description: \"Priority support, October\",\n        quantity: 1,\n        price: 200,\n      },\n    ],\n    note: \"Bank transfer within 30 days. Use the invoice number as the reference.\",\n    activity: [\n      { id: \"1\", text: \"Invoice created\", when: \"2 Oct\" },\n      { id: \"2\", text: \"Sent to ap@haldenfreight.com\", when: \"2 Oct\" },\n      { id: \"3\", text: \"Opened by the customer\", when: \"4 Oct\" },\n      { id: \"4\", text: \"Due date passed\", when: \"1 Nov\" },\n    ],\n  },\n  {\n    id: \"2048\",\n    number: \"INV-2048\",\n    customer: \"Brightwater Clinic\",\n    email: \"accounts@brightwater.health\",\n    address: [\"2 Harbour Lane\", \"Cork T12 X70\"],\n    issued: \"2026-10-17\",\n    due: \"2026-11-16\",\n    status: \"sent\",\n    taxRate: 20,\n    lines: [\n      {\n        id: \"a\",\n        description: \"Booking site redesign\",\n        quantity: 1,\n        price: 3200,\n      },\n      { id: \"b\", description: \"Content pages\", quantity: 6, price: 150 },\n    ],\n    note: \"Bank transfer within 30 days. Use the invoice number as the reference.\",\n    activity: [\n      { id: \"1\", text: \"Invoice created\", when: \"17 Oct\" },\n      { id: \"2\", text: \"Sent to accounts@brightwater.health\", when: \"17 Oct\" },\n    ],\n  },\n  {\n    id: \"2041\",\n    number: \"INV-2041\",\n    customer: \"Marlow & Finch\",\n    email: \"finance@marlowfinch.co\",\n    address: [\"88 Weaver Street\", \"Leeds LS2 7HJ\"],\n    issued: \"2026-09-12\",\n    due: \"2026-10-12\",\n    status: \"paid\",\n    taxRate: 20,\n    lines: [\n      { id: \"a\", description: \"Brand workshop\", quantity: 2, price: 600 },\n      { id: \"b\", description: \"Logo files and guide\", quantity: 1, price: 800 },\n    ],\n    note: \"Paid in full. Thank you.\",\n    activity: [\n      { id: \"1\", text: \"Invoice created\", when: \"12 Sep\" },\n      { id: \"2\", text: \"Sent to finance@marlowfinch.co\", when: \"12 Sep\" },\n      { id: \"3\", text: \"Payment received\", when: \"9 Oct\" },\n    ],\n  },\n];\n\nconst fmtDate = (iso: string) =>\n  new Date(Date.parse(iso)).toLocaleDateString(\"en-GB\", {\n    timeZone: \"UTC\",\n    day: \"numeric\",\n    month: \"short\",\n    year: \"numeric\",\n  });\n\nconst totalsOf = (inv: ViewerInvoice) => {\n  const subtotal = inv.lines.reduce((s, l) => s + l.quantity * l.price, 0);\n  const tax = Math.round(subtotal * (inv.taxRate ?? 0)) / 100;\n  return { subtotal, tax, total: subtotal + tax };\n};\n\n/* A tiny one-page PDF so Download works without a library. ASCII text only. */\nfunction invoicePdf(\n  inv: ViewerInvoice,\n  status: InvoiceState,\n  seller: string,\n  currency: string,\n) {\n  const cur =\n    currency === \"$\"\n      ? \"USD \"\n      : currency === \"€\"\n        ? \"EUR \"\n        : currency === \"£\"\n          ? \"GBP \"\n          : `${currency} `;\n  const esc = (s: string) =>\n    s.replace(/[^\\x20-\\x7E]/g, \"-\").replace(/([()\\\\])/g, \"\\\\$1\");\n  const { subtotal, tax, total } = totalsOf(inv);\n  const lines: [number, number, number, string][] = [\n    [56, 780, 22, seller],\n    [56, 750, 11, `Invoice ${inv.number}`],\n    [56, 734, 11, `Issued ${fmtDate(inv.issued)}   Due ${fmtDate(inv.due)}`],\n    [56, 700, 11, \"Bill to\"],\n    [56, 684, 13, inv.customer],\n    ...inv.address.map(\n      (a, i) => [56, 668 - i * 14, 11, a] as [number, number, number, string],\n    ),\n    [56, 600, 11, \"Description\"],\n    [360, 600, 11, \"Qty\"],\n    [420, 600, 11, \"Price\"],\n    [490, 600, 11, \"Amount\"],\n  ];\n  let y = 576;\n  for (const l of inv.lines) {\n    lines.push(\n      [56, y, 11, l.description],\n      [360, y, 11, String(l.quantity)],\n      [420, y, 11, l.price.toFixed(2)],\n      [490, y, 11, (l.quantity * l.price).toFixed(2)],\n    );\n    y -= 18;\n  }\n  lines.push(\n    [360, y - 20, 11, \"Subtotal\"],\n    [460, y - 20, 11, subtotal.toFixed(2)],\n    [360, y - 38, 11, `Tax ${inv.taxRate ?? 0}%`],\n    [460, y - 38, 11, tax.toFixed(2)],\n    [360, y - 60, 13, \"Total\"],\n    [440, y - 60, 13, `${cur}${total.toFixed(2)}`],\n    [\n      56,\n      80,\n      9,\n      status === \"paid\" ? \"Paid in full. Thank you.\" : (inv.note ?? \"\"),\n    ],\n  );\n  const content =\n    `0.85 g 56 ${y - 6} 484 0.6 re f 0 g\\n` +\n    lines\n      .map(\n        ([x, yy, size, t]) =>\n          `BT /F1 ${size} Tf ${x} ${yy} Td (${esc(t)}) Tj ET`,\n      )\n      .join(\"\\n\");\n  const objs = [\n    \"<< /Type /Catalog /Pages 2 0 R >>\",\n    \"<< /Type /Pages /Kids [3 0 R] /Count 1 >>\",\n    \"<< /Type /Page /Parent 2 0 R /MediaBox [0 0 595 842] /Contents 4 0 R /Resources << /Font << /F1 5 0 R >> >> >>\",\n    `<< /Length ${content.length} >>\\nstream\\n${content}\\nendstream`,\n    \"<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>\",\n  ];\n  let pdf = \"%PDF-1.4\\n\";\n  const offsets: number[] = [];\n  objs.forEach((o, i) => {\n    offsets.push(pdf.length);\n    pdf += `${i + 1} 0 obj\\n${o}\\nendobj\\n`;\n  });\n  const xref = pdf.length;\n  pdf += `xref\\n0 ${objs.length + 1}\\n0000000000 65535 f \\n${offsets.map((o) => `${String(o).padStart(10, \"0\")} 00000 n \\n`).join(\"\")}trailer\\n<< /Size ${objs.length + 1} /Root 1 0 R >>\\nstartxref\\n${xref}\\n%%EOF`;\n  return new Blob([pdf], { type: \"application/pdf\" });\n}\n\nfunction useSize<T extends HTMLElement>(fallback: [number, number]) {\n  const ref = React.useRef<T>(null);\n  const [size, setSize] = React.useState(fallback);\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const ro = new ResizeObserver(() => {\n      setSize([el.offsetWidth, el.offsetHeight]);\n    });\n    ro.observe(el);\n    return () => ro.disconnect();\n  }, []);\n  return [ref, size] as const;\n}\n\n/** Drawn as SVG, because a tiny border-radius circle turns lumpy on 1x screens. */\nfunction Dot({ size, color }: { size: number; color: string }) {\n  const r = size / 2;\n  return (\n    <svg\n      aria-hidden=\"true\"\n      width={size}\n      height={size}\n      viewBox={`0 0 ${size} ${size}`}\n      className=\"block shrink-0\"\n    >\n      <circle cx={r} cy={r} r={r} style={{ fill: color }} />\n    </svg>\n  );\n}\n\nfunction Icon({ d, size = 16 }: { d: string; size?: number }) {\n  return (\n    <svg\n      aria-hidden=\"true\"\n      viewBox=\"0 0 16 16\"\n      width={size}\n      height={size}\n      fill=\"none\"\n      className=\"block shrink-0\"\n    >\n      <path\n        d={d}\n        stroke=\"currentColor\"\n        strokeWidth=\"1.4\"\n        strokeLinecap=\"round\"\n        strokeLinejoin=\"round\"\n      />\n    </svg>\n  );\n}\n\nconst STAMP: Record<InvoiceState, { text: string; color: string } | null> = {\n  draft: null,\n  sent: null,\n  overdue: { text: \"OVERDUE\", color: \"#D9480F\" },\n  paid: { text: \"PAID\", color: \"#2B8A3E\" },\n};\n\nexport function InvoiceDocumentViewer({\n  theme = \"dark\",\n  invoices = DEFAULT_INVOICES,\n  seller = DEFAULT_SELLER,\n  currency = \"£\",\n  today = \"2026-11-07\",\n  sendMs = 900,\n  onMarkPaid,\n  onRemind,\n  onDownload,\n  linkFor = (inv) => `https://pay.example.com/i/${inv.number.toLowerCase()}`,\n  className,\n  style,\n  ...rest\n}: InvoiceDocumentViewerProps) {\n  const c = PALETTES[theme];\n  const [index, setIndex] = React.useState(0);\n  const [zoom, setZoom] = React.useState<number | null>(null);\n  const [status, setStatus] = React.useState<Record<string, InvoiceState>>(() =>\n    Object.fromEntries(invoices.map((i) => [i.id, i.status])),\n  );\n  const [log, setLog] = React.useState<Record<string, InvoiceEvent[]>>(() =>\n    Object.fromEntries(\n      invoices.map((i) => [i.id, [...(i.activity ?? [])].reverse()]),\n    ),\n  );\n  const [sending, setSending] = React.useState(false);\n  const [flash, setFlash] = React.useState<\"\" | \"sent\" | \"copied\">(\"\");\n  const [viewRef, [viewW]] = useSize<HTMLDivElement>([560, 400]);\n  const [pageRef, [, pageH]] = useSize<HTMLDivElement>([PAGE, 760]);\n  const timers = React.useRef<number[]>([]);\n  const count = React.useRef(0);\n\n  React.useEffect(() => {\n    const list = timers.current;\n    return () => list.forEach((t) => window.clearTimeout(t));\n  }, []);\n\n  const inv = invoices[index] ?? invoices[0];\n  const state = status[inv.id] ?? inv.status;\n  const { subtotal, tax, total } = totalsOf(inv);\n  const paid = state === \"paid\";\n  const money = (v: number) =>\n    `${currency}${v.toLocaleString(\"en-GB\", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;\n\n  const fit = Math.max(0.4, Math.min(1, (viewW - 32) / PAGE));\n  const scale = zoom ?? fit;\n  const zoomStep = (dir: 1 | -1) => {\n    const now = scale;\n    const next =\n      dir > 0\n        ? ZOOMS.find((z) => z > now + 0.01)\n        : [...ZOOMS].reverse().find((z) => z < now - 0.01);\n    if (next) setZoom(next);\n  };\n\n  const daysLate = Math.round((Date.parse(today) - Date.parse(inv.due)) / DAY);\n  const daysLeft = -daysLate;\n  const summary = paid\n    ? { text: \"Paid in full\", color: GREEN }\n    : state === \"overdue\"\n      ? {\n          text: `Overdue by ${daysLate} ${daysLate === 1 ? \"day\" : \"days\"}`,\n          color: ORANGE,\n        }\n      : state === \"draft\"\n        ? { text: \"Draft, not sent\", color: c.faint }\n        : {\n            text: `Due in ${daysLeft} ${daysLeft === 1 ? \"day\" : \"days\"}`,\n            color: ACCENT,\n          };\n\n  const later = (fn: () => void, ms: number) => {\n    timers.current.push(window.setTimeout(fn, ms));\n  };\n\n  const push = (id: string, text: string) => {\n    count.current += 1;\n    const ev = { id: `new-${count.current}`, text, when: \"Just now\" };\n    setLog((l) => ({ ...l, [id]: [ev, ...(l[id] ?? [])] }));\n  };\n\n  const go = (dir: 1 | -1) => {\n    setIndex((i) => (i + dir + invoices.length) % invoices.length);\n    setFlash(\"\");\n  };\n\n  const markPaid = () => {\n    if (paid) return;\n    setStatus((s) => ({ ...s, [inv.id]: \"paid\" }));\n    push(inv.id, `Payment recorded, ${money(total)}`);\n    onMarkPaid?.(inv);\n  };\n\n  const remind = () => {\n    if (paid || sending) return;\n    const target = inv;\n    setSending(true);\n    later(() => {\n      setSending(false);\n      push(target.id, `Reminder sent to ${target.email}`);\n      setFlash(\"sent\");\n      later(() => setFlash((f) => (f === \"sent\" ? \"\" : f)), 1800);\n      onRemind?.(target);\n    }, sendMs);\n  };\n\n  const copy = () => {\n    navigator.clipboard?.writeText(linkFor(inv)).catch(() => {});\n    setFlash(\"copied\");\n    later(() => setFlash((f) => (f === \"copied\" ? \"\" : f)), 1600);\n  };\n\n  const download = () => {\n    if (onDownload) return onDownload(inv);\n    const url = URL.createObjectURL(\n      invoicePdf(inv, state, seller.name, currency),\n    );\n    const a = document.createElement(\"a\");\n    a.href = url;\n    a.download = `${inv.number}.pdf`;\n    a.click();\n    later(() => URL.revokeObjectURL(url), 1000);\n  };\n\n  const events = log[inv.id] ?? [];\n  const tool = `flex h-8 cursor-pointer items-center justify-center rounded-lg border-0 bg-transparent disabled:cursor-default ${RING}`;\n\n  return (\n    <section\n      aria-label={`Invoice ${inv.number}`}\n      className={`@container w-full ${className ?? \"\"}`}\n      style={{ background: c.bg, color: c.text, fontFamily: FONT, ...style }}\n      {...rest}\n    >\n      <div className=\"flex items-start justify-between gap-4 p-5 pb-4 @3xl:px-8 @3xl:pt-7\">\n        <header className=\"min-w-0\">\n          <h2 className=\"m-0 truncate text-[22px] leading-[28px] font-[590] tracking-[-0.018em] @3xl:text-[24px] @3xl:leading-[30px]\">\n            {inv.customer}\n          </h2>\n          <p\n            className=\"m-0 mt-0.5 truncate text-[13px] leading-[20px] tracking-[-0.011em] tabular-nums\"\n            style={{ color: c.sub }}\n          >\n            {inv.number}\n            <span className=\"hidden @md:inline\">, due {fmtDate(inv.due)}</span>\n          </p>\n        </header>\n        <div className=\"shrink-0 text-right\">\n          <p\n            aria-live=\"polite\"\n            className=\"m-0 text-[28px] leading-[32px] font-[510] tracking-[-0.022em] tabular-nums @3xl:text-[32px]\"\n          >\n            {money(paid ? 0 : total)}\n          </p>\n          <p className=\"m-0 mt-1 flex items-center justify-end gap-1.5 text-[13px] leading-[20px] whitespace-nowrap\">\n            <Dot size={7} color={summary.color} />\n            <span style={{ color: c.sub }}>{summary.text}</span>\n          </p>\n        </div>\n      </div>\n\n      <div\n        className=\"grid border-t @3xl:grid-cols-[minmax(0,1fr)_272px]\"\n        style={{ borderColor: c.border }}\n      >\n        <div className=\"min-w-0\">\n          <div\n            role=\"toolbar\"\n            aria-label=\"Document\"\n            className=\"flex items-center justify-between gap-2 border-b px-3 py-1.5 @3xl:px-5\"\n            style={{ borderColor: c.border, color: c.sub }}\n          >\n            <div className=\"flex items-center\">\n              <button\n                type=\"button\"\n                data-prev=\"\"\n                aria-label=\"Previous invoice\"\n                onClick={() => go(-1)}\n                className={`${tool} w-8`}\n                style={{ color: c.sub }}\n              >\n                <Icon d=\"M10 3.5 5.5 8l4.5 4.5\" />\n              </button>\n              <span\n                className=\"w-[52px] text-center text-[12.5px] leading-[18px] tabular-nums\"\n                aria-live=\"polite\"\n              >\n                {index + 1} of {invoices.length}\n              </span>\n              <button\n                type=\"button\"\n                data-next=\"\"\n                aria-label=\"Next invoice\"\n                onClick={() => go(1)}\n                className={`${tool} w-8`}\n                style={{ color: c.sub }}\n              >\n                <Icon d=\"m6 3.5 4.5 4.5L6 12.5\" />\n              </button>\n            </div>\n            <div className=\"flex items-center\">\n              <button\n                type=\"button\"\n                data-zoom-out=\"\"\n                aria-label=\"Zoom out\"\n                disabled={scale <= ZOOMS[0] + 0.01}\n                onClick={() => zoomStep(-1)}\n                className={`${tool} w-8`}\n                style={{ color: c.sub }}\n              >\n                <Icon d=\"M4 8h8\" />\n              </button>\n              <button\n                type=\"button\"\n                data-fit=\"\"\n                aria-label={\n                  zoom === null ? \"Zoom, fitted to width\" : \"Fit to width\"\n                }\n                onClick={() => setZoom(null)}\n                className={`${tool} w-[52px] text-[12.5px] leading-[18px] tabular-nums`}\n                style={{ color: zoom === null ? c.text : c.sub }}\n              >\n                {Math.round(scale * 100)}%\n              </button>\n              <button\n                type=\"button\"\n                data-zoom-in=\"\"\n                aria-label=\"Zoom in\"\n                disabled={scale >= ZOOMS[ZOOMS.length - 1] - 0.01}\n                onClick={() => zoomStep(1)}\n                className={`${tool} w-8`}\n                style={{ color: c.sub }}\n              >\n                <Icon d=\"M4 8h8M8 4v8\" />\n              </button>\n              <span\n                aria-hidden=\"true\"\n                className=\"mx-1.5 block h-4 w-px\"\n                style={{ background: c.border }}\n              />\n              <button\n                type=\"button\"\n                data-download=\"\"\n                aria-label={`Download ${inv.number} as PDF`}\n                title=\"Download PDF\"\n                onClick={download}\n                className={`${tool} w-8`}\n                style={{ color: c.sub }}\n              >\n                <Icon d=\"M8 2.5v8m0 0L5 7.5m3 3 3-3M3 13.5h10\" />\n              </button>\n            </div>\n          </div>\n\n          {/* Fixed height with its own scroll, so zooming never moves the rest of the block. */}\n          <div\n            ref={viewRef}\n            data-viewport=\"\"\n            tabIndex={0}\n            aria-label={`${inv.number}, page view. Scroll to read.`}\n            className={`h-[360px] overflow-auto overscroll-contain @3xl:h-[392px] ${RING} focus-visible:ring-inset`}\n            style={{ background: c.desk }}\n          >\n            <div\n              className=\"relative mx-auto my-4\"\n              style={{\n                width: Math.round(PAGE * scale),\n                height: Math.round(pageH * scale),\n              }}\n            >\n              <div\n                ref={pageRef}\n                className=\"absolute top-0 left-0 origin-top-left\"\n                style={{\n                  width: PAGE,\n                  transform: `scale(${scale})`,\n                  background: \"#FFFFFF\",\n                  color: \"#1B1C1E\",\n                  boxShadow: c.shadow,\n                  borderRadius: 4,\n                  padding: \"44px 48px 40px\",\n                }}\n              >\n                <div className=\"flex items-start justify-between gap-6\">\n                  <div>\n                    <svg\n                      aria-hidden=\"true\"\n                      width=\"28\"\n                      height=\"28\"\n                      viewBox=\"0 0 28 28\"\n                      className=\"block\"\n                    >\n                      <rect width=\"28\" height=\"28\" rx=\"7\" fill=\"#1B1C1E\" />\n                      <path\n                        d=\"M9 19V9h10M9 14h7\"\n                        stroke=\"#FFFFFF\"\n                        strokeWidth=\"2.2\"\n                        strokeLinecap=\"round\"\n                      />\n                    </svg>\n                    <p className=\"m-0 mt-3 text-[13px] leading-[18px] font-[600]\">\n                      {seller.name}\n                    </p>\n                    {seller.address.map((a) => (\n                      <p\n                        key={a}\n                        className=\"m-0 text-[11px] leading-[16px] text-[#6B6F76]\"\n                      >\n                        {a}\n                      </p>\n                    ))}\n                    <p className=\"m-0 text-[11px] leading-[16px] text-[#6B6F76]\">\n                      {seller.email}\n                    </p>\n                  </div>\n                  <div className=\"text-right\">\n                    <p className=\"m-0 text-[22px] leading-[28px] font-[600] tracking-[-0.02em]\">\n                      Invoice\n                    </p>\n                    <p className=\"m-0 text-[12px] leading-[18px] text-[#6B6F76] tabular-nums\">\n                      {inv.number}\n                    </p>\n                  </div>\n                </div>\n\n                <div className=\"mt-8 grid grid-cols-3 gap-4 text-[11px] leading-[16px]\">\n                  <div>\n                    <p className=\"m-0 text-[#8A8F98]\">Bill to</p>\n                    <p className=\"m-0 mt-1 text-[12px] font-[600]\">\n                      {inv.customer}\n                    </p>\n                    {inv.address.map((a) => (\n                      <p key={a} className=\"m-0 text-[#6B6F76]\">\n                        {a}\n                      </p>\n                    ))}\n                  </div>\n                  <div>\n                    <p className=\"m-0 text-[#8A8F98]\">Issued</p>\n                    <p className=\"m-0 mt-1 tabular-nums\">\n                      {fmtDate(inv.issued)}\n                    </p>\n                  </div>\n                  <div>\n                    <p className=\"m-0 text-[#8A8F98]\">Due</p>\n                    <p className=\"m-0 mt-1 tabular-nums\">{fmtDate(inv.due)}</p>\n                  </div>\n                </div>\n\n                <table className=\"mt-8 w-full border-collapse text-[11.5px] leading-[16px]\">\n                  <thead>\n                    <tr className=\"text-[#8A8F98]\">\n                      <th className=\"border-b border-[#E6E7EA] pb-2 text-left font-[500]\">\n                        Description\n                      </th>\n                      <th className=\"w-[44px] border-b border-[#E6E7EA] pb-2 text-right font-[500]\">\n                        Qty\n                      </th>\n                      <th className=\"w-[80px] border-b border-[#E6E7EA] pb-2 text-right font-[500]\">\n                        Price\n                      </th>\n                      <th className=\"w-[90px] border-b border-[#E6E7EA] pb-2 text-right font-[500]\">\n                        Amount\n                      </th>\n                    </tr>\n                  </thead>\n                  <tbody>\n                    {inv.lines.map((l) => (\n                      <tr key={l.id}>\n                        <td className=\"border-b border-[#F0F1F3] py-2.5 pr-2\">\n                          {l.description}\n                        </td>\n                        <td className=\"border-b border-[#F0F1F3] py-2.5 text-right tabular-nums\">\n                          {l.quantity}\n                        </td>\n                        <td className=\"border-b border-[#F0F1F3] py-2.5 text-right tabular-nums\">\n                          {money(l.price)}\n                        </td>\n                        <td className=\"border-b border-[#F0F1F3] py-2.5 text-right tabular-nums\">\n                          {money(l.quantity * l.price)}\n                        </td>\n                      </tr>\n                    ))}\n                  </tbody>\n                </table>\n\n                <div className=\"mt-4 ml-auto w-[220px] text-[11.5px] leading-[16px] tabular-nums\">\n                  <p className=\"m-0 flex justify-between py-1 text-[#6B6F76]\">\n                    <span>Subtotal</span>\n                    <span>{money(subtotal)}</span>\n                  </p>\n                  <p className=\"m-0 flex justify-between py-1 text-[#6B6F76]\">\n                    <span>Tax {inv.taxRate ?? 0}%</span>\n                    <span>{money(tax)}</span>\n                  </p>\n                  <p className=\"m-0 mt-1 flex justify-between border-t border-[#E6E7EA] pt-2 text-[13px] font-[600]\">\n                    <span>Total</span>\n                    <span>{money(total)}</span>\n                  </p>\n                  <p className=\"m-0 flex justify-between py-1 text-[#6B6F76]\">\n                    <span>Balance due</span>\n                    <span>{money(paid ? 0 : total)}</span>\n                  </p>\n                </div>\n\n                <p className=\"m-0 mt-10 border-t border-[#F0F1F3] pt-4 text-[10.5px] leading-[16px] text-[#8A8F98]\">\n                  {paid ? \"Paid in full. Thank you.\" : inv.note}\n                </p>\n\n                {/* Both stamps are always drawn, so switching between them only fades. */}\n                {([\"overdue\", \"paid\"] as const).map((k) => {\n                  const s = STAMP[k]!;\n                  const on = state === k;\n                  return (\n                    <svg\n                      key={k}\n                      aria-hidden={!on}\n                      role=\"img\"\n                      aria-label={on ? s.text : undefined}\n                      data-stamp={k}\n                      width=\"150\"\n                      height=\"56\"\n                      viewBox=\"0 0 150 56\"\n                      className=\"pointer-events-none absolute block motion-safe:transition-[opacity,transform] motion-safe:duration-300\"\n                      style={{\n                        left: 52,\n                        bottom: 92,\n                        opacity: on ? 0.85 : 0,\n                        transform: `rotate(-10deg) scale(${on ? 1 : 1.25})`,\n                      }}\n                    >\n                      <rect\n                        x=\"2\"\n                        y=\"2\"\n                        width=\"146\"\n                        height=\"52\"\n                        rx=\"8\"\n                        fill=\"none\"\n                        stroke={s.color}\n                        strokeWidth=\"3\"\n                      />\n                      <text\n                        x=\"75\"\n                        y=\"36\"\n                        textAnchor=\"middle\"\n                        fontSize={k === \"paid\" ? 26 : 21}\n                        fontWeight=\"800\"\n                        letterSpacing=\"3\"\n                        fill={s.color}\n                      >\n                        {s.text}\n                      </text>\n                    </svg>\n                  );\n                })}\n              </div>\n            </div>\n          </div>\n        </div>\n\n        <aside\n          aria-label=\"Invoice actions\"\n          className=\"min-w-0 border-t @3xl:border-t-0 @3xl:border-l\"\n          style={{ borderColor: c.border }}\n        >\n          <div className=\"grid gap-2 p-5 @3xl:p-5\">\n            <button\n              type=\"button\"\n              data-paid=\"\"\n              disabled={paid}\n              onClick={markPaid}\n              className={`flex h-9 cursor-pointer items-center justify-center gap-1.5 rounded-full border-0 text-[13px] leading-[20px] font-[510] tracking-[-0.011em] disabled:cursor-default ${RING}`}\n              style={{\n                background: paid ? \"rgba(39,166,68,0.14)\" : c.btn,\n                color: paid ? GREEN : c.btnText,\n              }}\n            >\n              {paid && <Icon d=\"m3.5 8.5 3 3 6-7\" size={14} />}\n              {paid ? \"Paid\" : \"Mark as paid\"}\n            </button>\n            <div className=\"grid grid-cols-2 gap-2\">\n              <button\n                type=\"button\"\n                data-remind=\"\"\n                disabled={paid || sending}\n                onClick={remind}\n                className={`h-9 cursor-pointer rounded-full border-0 text-[13px] leading-[20px] font-[510] tracking-[-0.011em] whitespace-nowrap disabled:cursor-default ${RING}`}\n                style={{\n                  background: c.chip,\n                  color: paid ? c.faint : flash === \"sent\" ? GREEN : c.soft,\n                }}\n              >\n                {sending ? \"Sending\" : flash === \"sent\" ? \"Sent\" : \"Remind\"}\n              </button>\n              <button\n                type=\"button\"\n                data-copy=\"\"\n                onClick={copy}\n                className={`h-9 cursor-pointer rounded-full border-0 text-[13px] leading-[20px] font-[510] tracking-[-0.011em] whitespace-nowrap ${RING}`}\n                style={{\n                  background: c.chip,\n                  color: flash === \"copied\" ? GREEN : c.soft,\n                }}\n              >\n                {flash === \"copied\" ? \"Copied\" : \"Copy link\"}\n              </button>\n            </div>\n          </div>\n          <div\n            className=\"border-t px-5 pt-3 pb-4\"\n            style={{ borderColor: c.border }}\n          >\n            <p\n              className=\"m-0 text-[12px] leading-[16px] font-[510] tracking-[-0.005em]\"\n              style={{ color: c.faint }}\n            >\n              Activity\n            </p>\n            <ol\n              aria-live=\"polite\"\n              className=\"relative m-0 mt-1 list-none overflow-hidden p-0\"\n              style={{ height: ROW * ROWS }}\n            >\n              {events.slice(0, ROWS).map((ev, i) => (\n                <li\n                  key={ev.id}\n                  data-event=\"\"\n                  className=\"flex items-center gap-2.5\"\n                  style={{\n                    height: ROW,\n                    borderTop: i ? `1px solid ${c.border}` : \"none\",\n                  }}\n                >\n                  <Dot\n                    size={6}\n                    color={ev.when === \"Just now\" ? ACCENT : c.faint}\n                  />\n                  <span\n                    className=\"min-w-0 flex-1 truncate text-[12.5px] leading-[18px] tracking-[-0.008em]\"\n                    style={{ color: c.soft }}\n                  >\n                    {ev.text}\n                  </span>\n                  <span\n                    className=\"shrink-0 text-[12px] leading-[16px] tabular-nums\"\n                    style={{ color: ev.when === \"Just now\" ? c.text : c.faint }}\n                  >\n                    {ev.when}\n                  </span>\n                </li>\n              ))}\n            </ol>\n          </div>\n        </aside>\n      </div>\n    </section>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}