{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "receipt-80mm",
  "type": "registry:component",
  "title": "Receipt 80mm",
  "description": "An on-screen thermal receipt at real 80 mm or 58 mm width that feeds out of a printer slot and prints only itself with the matching page size.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "ordering",
    "receipt",
    "print",
    "thermal",
    "order",
    "kitchen",
    "pos"
  ],
  "docs": "https://hyperblur.dev/effects/receipt-80mm",
  "files": [
    {
      "path": "registry/hyperblur/receipt-80mm.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/receipt-80mm.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type ReceiptPaper = \"80mm\" | \"58mm\";\n\nexport interface ReceiptLine {\n  name: string;\n  price: number;\n  quantity?: number;\n  options?: string[];\n  note?: string;\n}\n\nexport interface ReceiptAdjustment {\n  label: string;\n  amount: number;\n}\n\nexport interface ReceiptCustomer {\n  name: string;\n  phone?: string;\n  address?: string;\n}\n\nexport interface ReceiptLabels {\n  print: string;\n  paper: string;\n  order: string;\n  date: string;\n  type: string;\n  customer: string;\n  phone: string;\n  address: string;\n  item: string;\n  amount: string;\n  subtotal: string;\n  total: string;\n  payment: string;\n  note: string;\n  scan: string;\n}\n\nexport interface Receipt80mmProps extends React.HTMLAttributes<HTMLDivElement> {\n  storeName?: string;\n  storeLines?: string[];\n  orderNumber?: string | number;\n  date?: string;\n  type?: string;\n  customer?: ReceiptCustomer | null;\n  items?: ReceiptLine[];\n  adjustments?: ReceiptAdjustment[];\n  total?: number;\n  payment?: string;\n  paymentNote?: string;\n  note?: string;\n  footer?: string;\n  qrValue?: string;\n  showQr?: boolean;\n  paper?: ReceiptPaper;\n  currency?: string;\n  locale?: string;\n  labels?: Partial<ReceiptLabels>;\n  showToolbar?: boolean;\n  showPrinter?: boolean;\n  animateIn?: boolean;\n  onPrint?: () => void;\n  accent?: string;\n}\n\nconst defaultLabels: ReceiptLabels = {\n  print: \"Print receipt\",\n  paper: \"{paper} thermal\",\n  order: \"Order\",\n  date: \"Date\",\n  type: \"Type\",\n  customer: \"Customer\",\n  phone: \"Phone\",\n  address: \"Address\",\n  item: \"Item\",\n  amount: \"Amount\",\n  subtotal: \"Subtotal\",\n  total: \"Total\",\n  payment: \"Payment\",\n  note: \"Note\",\n  scan: \"Scan to track your order\",\n};\n\nconst sampleItems: ReceiptLine[] = [\n  { name: \"Smash Double\", quantity: 2, price: 11.5, options: [\"Medium well\", \"Add bacon +2.00\"], note: \"No onions\" },\n  { name: \"Crinkle Fries\", quantity: 1, price: 4.25, options: [\"Large\"] },\n  { name: \"Vanilla Shake\", quantity: 1, price: 5.75 },\n  { name: \"Garlic Aioli\", quantity: 2, price: 0.75 },\n];\n\nconst css = `\n.hb-oc2 {\n  --hb-oc2-accent: #2f7bff;\n  container-type: inline-size;\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  box-sizing: border-box;\n  width: 100%;\n  color: #ededed;\n  font-family: inherit;\n}\n.hb-oc2 *, .hb-oc2 *::before, .hb-oc2 *::after { box-sizing: border-box; }\n.hb-oc2-bar {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  gap: 10px;\n  width: 100%;\n  max-width: 360px;\n  margin-bottom: 14px;\n}\n.hb-oc2-chip {\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n  height: 28px;\n  padding: 0 10px;\n  border: 1px solid #262626;\n  border-radius: 999px;\n  background: #141414;\n  color: #a1a1a1;\n  font-size: 12px;\n  white-space: nowrap;\n}\n.hb-oc2-chip svg, .hb-oc2-print svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }\n.hb-oc2-print {\n  display: inline-flex;\n  align-items: center;\n  gap: 7px;\n  height: 34px;\n  margin: 0;\n  padding: 0 14px;\n  border: 0;\n  border-radius: 999px;\n  background: var(--hb-oc2-accent);\n  color: #ffffff;\n  font: inherit;\n  font-size: 13px;\n  font-weight: 500;\n  white-space: nowrap;\n  cursor: pointer;\n  transition: filter 0.16s ease, transform 0.12s ease;\n}\n.hb-oc2-print:hover { filter: brightness(1.1); }\n.hb-oc2-print:active { transform: scale(0.97); }\n.hb-oc2-print:focus-visible { outline: 2px solid var(--hb-oc2-accent); outline-offset: 3px; }\n.hb-oc2-device { display: flex; flex-direction: column; align-items: center; width: 100%; }\n.hb-oc2-slot {\n  position: relative;\n  z-index: 2;\n  width: min(100%, calc(var(--hb-oc2-w) + 36px));\n  height: 22px;\n  border: 1px solid #2a2a2a;\n  border-radius: 12px;\n  background: linear-gradient(180deg, #2a2a2a, #161616);\n  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 10px 24px -10px rgba(0, 0, 0, 0.9);\n}\n.hb-oc2-slot::after {\n  content: \"\";\n  position: absolute;\n  right: 16px;\n  bottom: 5px;\n  left: 16px;\n  height: 3px;\n  border-radius: 3px;\n  background: #050505;\n}\n.hb-oc2-slot i {\n  position: absolute;\n  top: 6px;\n  left: 12px;\n  width: 5px;\n  height: 5px;\n  border-radius: 50%;\n  background: #3ccf91;\n  box-shadow: 0 0 6px #3ccf91;\n  font-style: normal;\n}\n.hb-oc2-feed {\n  width: 100%;\n  max-width: var(--hb-oc2-w);\n  margin-top: -9px;\n  padding: 0 0 14px;\n  overflow: hidden;\n}\n.hb-oc2-paper {\n  position: relative;\n  width: 100%;\n  padding: 22px 14px 26px;\n  background: #fbfaf6;\n  color: #151515;\n  font-family: var(--font-mono, ui-monospace), ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\n  font-size: 11.5px;\n  line-height: 1.5;\n  font-variant-numeric: tabular-nums;\n  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04), 0 14px 30px -14px rgba(0, 0, 0, 0.7);\n  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 10px 100%;\n  mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 10px 100%;\n}\n.hb-oc2-paper[data-paper=\"58mm\"] { padding: 20px 10px 24px; font-size: 10.5px; }\n.hb-oc2-paper[data-feed=\"true\"] { animation: hb-oc2-out 1.9s cubic-bezier(0.45, 0.05, 0.25, 1) both; }\n@keyframes hb-oc2-out {\n  0% { transform: translateY(-100%); }\n  12% { transform: translateY(-86%); }\n  24% { transform: translateY(-86%); }\n  100% { transform: translateY(0); }\n}\n.hb-oc2-paper p { margin: 0; }\n.hb-oc2-c { text-align: center; }\n.hb-oc2-store { font-size: 1.3em; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }\n.hb-oc2-sub { color: #4a4a4a; font-size: 0.92em; }\n.hb-oc2-rule { height: 0; margin: 10px 0; border: 0; border-top: 1.5px dashed #9a9a9a; }\n.hb-oc2-rule[data-double=\"true\"] { height: 4px; border-top: 1.5px solid #151515; border-bottom: 1.5px solid #151515; }\n.hb-oc2-num { margin: 2px 0 4px; font-size: 1.6em; font-weight: 700; letter-spacing: 0.02em; }\n.hb-oc2-kv { display: flex; justify-content: space-between; gap: 10px; }\n.hb-oc2-kv span:first-child { flex: none; color: #4a4a4a; }\n.hb-oc2-kv span:last-child { min-width: 0; text-align: right; overflow-wrap: anywhere; }\n.hb-oc2-head { display: flex; gap: 6px; color: #4a4a4a; font-size: 0.88em; text-transform: uppercase; letter-spacing: 0.06em; }\n.hb-oc2-head span:last-child, .hb-oc2-line b { margin-left: auto; }\n.hb-oc2-line { display: flex; align-items: baseline; gap: 6px; margin-top: 5px; }\n.hb-oc2-line span:first-child { flex: none; min-width: 2.4em; font-weight: 700; }\n.hb-oc2-line span:nth-child(2) { min-width: 0; overflow-wrap: anywhere; }\n.hb-oc2-line b { flex: none; font-weight: 700; white-space: nowrap; }\n.hb-oc2-opt { padding-left: 3em; color: #3d3d3d; font-size: 0.94em; }\n.hb-oc2-opt::before { content: \"+ \"; }\n.hb-oc2-opt[data-note=\"true\"]::before { content: \"> \"; }\n.hb-oc2-opt[data-note=\"true\"] { font-weight: 700; color: #151515; }\n.hb-oc2-tot { margin-top: 3px; font-size: 1.35em; font-weight: 700; }\n.hb-oc2-box { margin-top: 10px; padding: 7px 8px; border: 1.5px solid #151515; }\n.hb-oc2-box strong { display: block; font-size: 0.88em; letter-spacing: 0.06em; text-transform: uppercase; }\n.hb-oc2-qr { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 12px; }\n.hb-oc2-qr svg { width: 74px; height: 74px; shape-rendering: crispEdges; }\n.hb-oc2-foot { margin-top: 10px; font-weight: 700; }\n.hb-oc2-print-root { display: none; }\n@media print {\n  html.hb-oc2-printing body > *:not(.hb-oc2-print-root) { display: none !important; }\n  html.hb-oc2-printing, html.hb-oc2-printing body { margin: 0 !important; padding: 0 !important; background: #ffffff !important; }\n  html.hb-oc2-printing .hb-oc2-print-root { display: block; width: 100%; }\n  .hb-oc2-print-root .hb-oc2-paper {\n    width: 100% !important;\n    padding: 4mm 3mm 6mm;\n    background: #ffffff;\n    color: #000000;\n    box-shadow: none;\n    animation: none !important;\n    transform: none !important;\n    -webkit-mask: none;\n    mask: none;\n    -webkit-print-color-adjust: exact;\n    print-color-adjust: exact;\n  }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-oc2 *, .hb-oc2 *::before, .hb-oc2 *::after { animation: none !important; transition: none !important; }\n}\n`;\n\nfunction fill(template: string, values: Record<string, string | number>) {\n  return template.replace(/\\{(\\w+)\\}/g, (match, key: string) => (key in values ? String(values[key]) : match));\n}\n\nfunction seedOf(text: string) {\n  let h = 2166136261;\n  for (let i = 0; i < text.length; i++) {\n    h ^= text.charCodeAt(i);\n    h = Math.imul(h, 16777619);\n  }\n  return h >>> 0;\n}\n\nfunction qrPath(value: string) {\n  const size = 21;\n  const seed = seedOf(value);\n  const finder = (x: number, y: number) => {\n    const corners = [[0, 0], [size - 7, 0], [0, size - 7]];\n    for (const [cx, cy] of corners) {\n      const dx = x - cx;\n      const dy = y - cy;\n      if (dx >= 0 && dx < 7 && dy >= 0 && dy < 7) {\n        const edge = dx === 0 || dx === 6 || dy === 0 || dy === 6;\n        const core = dx >= 2 && dx <= 4 && dy >= 2 && dy <= 4;\n        return edge || core ? 1 : 0;\n      }\n      if (dx >= -1 && dx <= 7 && dy >= -1 && dy <= 7) return 0;\n    }\n    return -1;\n  };\n  let d = \"\";\n  for (let y = 0; y < size; y++) {\n    for (let x = 0; x < size; x++) {\n      const f = finder(x, y);\n      let on = f === 1;\n      if (f === -1) {\n        if (y === 6 || x === 6) on = (x + y) % 2 === 0;\n        else {\n          let h = Math.imul(seed ^ (y * size + x + 1), 2654435761) >>> 0;\n          h ^= h >>> 15;\n          h = Math.imul(h, 2246822519) >>> 0;\n          h ^= h >>> 13;\n          on = (h & 7) < 4;\n        }\n      }\n      if (on) d += `M${x} ${y}h1v1h-1z`;\n    }\n  }\n  return d;\n}\n\nexport function printReceipt(element: HTMLElement | null, paper: ReceiptPaper = \"80mm\") {\n  if (!element || typeof window === \"undefined\") return;\n  const root = document.createElement(\"div\");\n  root.className = \"hb-oc2-print-root\";\n  const clone = element.cloneNode(true) as HTMLElement;\n  clone.removeAttribute(\"data-feed\");\n  root.appendChild(clone);\n  document.body.appendChild(root);\n  const page = document.createElement(\"style\");\n  page.textContent = `@page { size: ${paper} auto; margin: 0; }`;\n  document.head.appendChild(page);\n  document.documentElement.classList.add(\"hb-oc2-printing\");\n  let cleaned = false;\n  let fallback = 0;\n  const cleanup = () => {\n    if (cleaned) return;\n    cleaned = true;\n    window.clearTimeout(fallback);\n    window.removeEventListener(\"afterprint\", cleanup);\n    document.documentElement.classList.remove(\"hb-oc2-printing\");\n    root.remove();\n    page.remove();\n  };\n  window.addEventListener(\"afterprint\", cleanup);\n  fallback = window.setTimeout(cleanup, 60000);\n  window.print();\n}\n\nexport function Receipt80mm({\n  storeName = \"Corner Kitchen\",\n  storeLines = [\"214 Bedford Ave, Brooklyn, NY 11249\", \"(718) 555-0199\"],\n  orderNumber = 1048,\n  date = \"Nov 5, 2026 · 7:42 PM\",\n  type = \"Delivery\",\n  customer = { name: \"Maya Thompson\", phone: \"(347) 555-0123\", address: \"88 N 6th St, Apt 4B\" },\n  items = sampleItems,\n  adjustments = [\n    { label: \"Delivery fee\", amount: 3.5 },\n    { label: \"Coupon WELCOME5\", amount: -5 },\n  ],\n  total,\n  payment = \"Card on delivery\",\n  paymentNote = \"Bring the card machine\",\n  note = \"Ring twice, side door on 6th St.\",\n  footer = \"Thank you! See you soon.\",\n  qrValue,\n  showQr = true,\n  paper = \"80mm\",\n  currency = \"USD\",\n  locale = \"en-US\",\n  labels,\n  showToolbar = true,\n  showPrinter = true,\n  animateIn = true,\n  onPrint,\n  accent = \"#2f7bff\",\n  className,\n  style,\n  ...rest\n}: Receipt80mmProps) {\n  const t = { ...defaultLabels, ...labels };\n  const paperRef = React.useRef<HTMLDivElement>(null);\n  const money = React.useMemo(() => new Intl.NumberFormat(locale, { style: \"currency\", currency }), [locale, currency]);\n  const subtotal = items.reduce((sum, it) => sum + it.price * (it.quantity ?? 1), 0);\n  const grand = total ?? subtotal + adjustments.reduce((sum, a) => sum + a.amount, 0);\n  const path = React.useMemo(() => qrPath(qrValue ?? `${storeName}-${orderNumber}`), [qrValue, storeName, orderNumber]);\n  const width = paper === \"58mm\" ? \"58mm\" : \"80mm\";\n\n  const handlePrint = () => {\n    onPrint?.();\n    printReceipt(paperRef.current, paper);\n  };\n\n  return (\n    <div className={[\"hb-oc2\", className].filter(Boolean).join(\" \")} style={{ \"--hb-oc2-accent\": accent, \"--hb-oc2-w\": width, ...style } as React.CSSProperties} {...rest}>\n      <style href=\"hb-receipt-80mm\" precedence=\"default\">{css}</style>\n      {showToolbar && (\n        <div className=\"hb-oc2-bar\">\n          <span className=\"hb-oc2-chip\">\n            <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n              <path d=\"M6 3h12v18l-2-1.4-2 1.4-2-1.4-2 1.4-2-1.4L6 21zM9 8h6M9 12h6M9 16h3\" />\n            </svg>\n            {fill(t.paper, { paper: width.replace(\"mm\", \" mm\") })}\n          </span>\n          <button type=\"button\" className=\"hb-oc2-print\" onClick={handlePrint}>\n            <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n              <path d=\"M7 9V4h10v5M7 17H5a1 1 0 0 1-1-1v-5a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v5a1 1 0 0 1-1 1h-2M7 14h10v6H7z\" />\n            </svg>\n            {t.print}\n          </button>\n        </div>\n      )}\n      <div className=\"hb-oc2-device\">\n        {showPrinter && (\n          <div className=\"hb-oc2-slot\" aria-hidden=\"true\">\n            <i />\n          </div>\n        )}\n        <div className=\"hb-oc2-feed\" style={showPrinter ? undefined : { marginTop: 0 }}>\n          <div ref={paperRef} className=\"hb-oc2-paper\" data-paper={paper} data-feed={animateIn ? \"true\" : undefined} role=\"document\" aria-label={`${t.order} #${orderNumber}`}>\n            <p className=\"hb-oc2-c hb-oc2-store\">{storeName}</p>\n            {storeLines.map((line) => (\n              <p key={line} className=\"hb-oc2-c hb-oc2-sub\">\n                {line}\n              </p>\n            ))}\n            <hr className=\"hb-oc2-rule\" />\n            <p className=\"hb-oc2-c hb-oc2-sub\">{t.order}</p>\n            <p className=\"hb-oc2-c hb-oc2-num\">#{orderNumber}</p>\n            <p className=\"hb-oc2-kv\">\n              <span>{t.date}</span>\n              <span>{date}</span>\n            </p>\n            <p className=\"hb-oc2-kv\">\n              <span>{t.type}</span>\n              <span>{type}</span>\n            </p>\n            {customer && (\n              <>\n                <hr className=\"hb-oc2-rule\" />\n                <p className=\"hb-oc2-kv\">\n                  <span>{t.customer}</span>\n                  <span>{customer.name}</span>\n                </p>\n                {customer.phone && (\n                  <p className=\"hb-oc2-kv\">\n                    <span>{t.phone}</span>\n                    <span>{customer.phone}</span>\n                  </p>\n                )}\n                {customer.address && (\n                  <p className=\"hb-oc2-kv\">\n                    <span>{t.address}</span>\n                    <span>{customer.address}</span>\n                  </p>\n                )}\n              </>\n            )}\n            <hr className=\"hb-oc2-rule\" />\n            <p className=\"hb-oc2-head\">\n              <span>{t.item}</span>\n              <span>{t.amount}</span>\n            </p>\n            {items.map((it, i) => (\n              <React.Fragment key={`${it.name}-${i}`}>\n                <p className=\"hb-oc2-line\">\n                  <span>{it.quantity ?? 1}x</span>\n                  <span>{it.name}</span>\n                  <b>{money.format(it.price * (it.quantity ?? 1))}</b>\n                </p>\n                {it.options?.map((opt) => (\n                  <p key={opt} className=\"hb-oc2-opt\">\n                    {opt}\n                  </p>\n                ))}\n                {it.note && (\n                  <p className=\"hb-oc2-opt\" data-note=\"true\">\n                    {it.note}\n                  </p>\n                )}\n              </React.Fragment>\n            ))}\n            <hr className=\"hb-oc2-rule\" />\n            <p className=\"hb-oc2-kv\">\n              <span>{t.subtotal}</span>\n              <span>{money.format(subtotal)}</span>\n            </p>\n            {adjustments.map((a) => (\n              <p key={a.label} className=\"hb-oc2-kv\">\n                <span>{a.label}</span>\n                <span>{money.format(a.amount)}</span>\n              </p>\n            ))}\n            <hr className=\"hb-oc2-rule\" data-double=\"true\" />\n            <p className=\"hb-oc2-kv hb-oc2-tot\">\n              <span>{t.total}</span>\n              <span>{money.format(grand)}</span>\n            </p>\n            {payment && (\n              <p className=\"hb-oc2-kv\">\n                <span>{t.payment}</span>\n                <span>{payment}</span>\n              </p>\n            )}\n            {paymentNote && <p className=\"hb-oc2-opt\" data-note=\"true\">{paymentNote}</p>}\n            {note && (\n              <div className=\"hb-oc2-box\">\n                <strong>{t.note}</strong>\n                {note}\n              </div>\n            )}\n            {showQr && (\n              <div className=\"hb-oc2-qr\">\n                <svg viewBox=\"-1 -1 23 23\" aria-hidden=\"true\">\n                  <rect x=\"-1\" y=\"-1\" width=\"23\" height=\"23\" fill=\"#fbfaf6\" />\n                  <path d={path} fill=\"#151515\" />\n                </svg>\n                <p className=\"hb-oc2-c hb-oc2-sub\">{t.scan}</p>\n              </div>\n            )}\n            {footer && <p className=\"hb-oc2-c hb-oc2-foot\">{footer}</p>}\n          </div>\n        </div>\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}