{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pay-order-summary",
  "type": "registry:component",
  "title": "Pay Order Summary",
  "description": "Line items with quantity steppers, subtotal, discount, tax and total. Amounts roll when they change and the list folds on narrow containers.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "payments",
    "order",
    "summary",
    "cart",
    "checkout",
    "total",
    "quantity"
  ],
  "docs": "https://hyperblur.dev/effects/pay-order-summary",
  "files": [
    {
      "path": "registry/hyperblur/pay-order-summary.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/pay-order-summary.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface PayOrderItem {\n  id: string;\n  name: string;\n  detail?: string;\n  price: number;\n  quantity?: number;\n  swatch?: string;\n}\n\nexport interface PayOrderSummaryProps\n  extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\"> {\n  items?: PayOrderItem[];\n  quantities?: Record<string, number>;\n  onQuantityChange?: (id: string, quantity: number) => void;\n  currency?: string;\n  discount?: number;\n  discountLabel?: string;\n  taxRate?: number;\n  shipping?: number;\n  title?: string;\n  defaultOpen?: boolean;\n  accent?: string;\n}\n\nconst defaultItems: PayOrderItem[] = [\n  { id: \"ceramic-mug\", name: \"Ceramic mug\", detail: \"Matte sand\", price: 1800, quantity: 2, swatch: \"#d9b98c\" },\n  { id: \"linen-apron\", name: \"Linen apron\", detail: \"Olive, one size\", price: 4200, quantity: 1, swatch: \"#6f8a5b\" },\n  { id: \"drip-kettle\", name: \"Drip kettle\", detail: \"0.9 L, black\", price: 6400, quantity: 1, swatch: \"#3b3f4a\" },\n];\n\nconst css = `\n.hb-qf7 {\n  box-sizing: border-box;\n  container-type: inline-size;\n  width: 100%;\n  color: #ededed;\n  font-family: inherit;\n  font-size: 13px;\n  line-height: 1.4;\n}\n.hb-qf7 *, .hb-qf7 *::before, .hb-qf7 *::after { box-sizing: border-box; }\n.hb-qf7-card { padding: 14px; background: #111111; border: 1px solid #262626; border-radius: 14px; }\n.hb-qf7-hd {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  gap: 10px;\n  width: 100%;\n  margin: 0;\n  padding: 0;\n  color: inherit;\n  font: inherit;\n  text-align: left;\n  background: none;\n  border: 0;\n}\nbutton.hb-qf7-hd { cursor: pointer; border-radius: 8px; }\nbutton.hb-qf7-hd:focus-visible { outline: 2px solid var(--hb-qf7-x); outline-offset: 4px; }\n.hb-qf7-ttl { display: flex; align-items: baseline; gap: 8px; min-width: 0; }\n.hb-qf7-ttl b { font-size: 13.5px; font-weight: 600; }\n.hb-qf7-ttl span { color: #8f8f8f; font-size: 12px; }\n.hb-qf7-peek { display: flex; align-items: center; gap: 8px; font-weight: 600; font-variant-numeric: tabular-nums; transition: opacity 0.25s ease; }\n.hb-qf7[data-open=\"true\"] .hb-qf7-peek { opacity: 0; }\n.hb-qf7-chev { width: 14px; height: 14px; fill: none; stroke: #8f8f8f; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.3s ease; }\n.hb-qf7[data-open=\"true\"] .hb-qf7-chev { transform: rotate(180deg); }\n.hb-qf7-fold { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.4s cubic-bezier(0.22, 1, 0.36, 1); }\n.hb-qf7[data-open=\"true\"] .hb-qf7-fold { grid-template-rows: 1fr; }\n.hb-qf7-fold > div { min-height: 0; overflow: hidden; }\n.hb-qf7-list { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 10px 0 0; list-style: none; }\n.hb-qf7-it { display: flex; align-items: center; gap: 10px; min-height: 32px; }\n.hb-qf7-sw { flex: none; width: 28px; height: 28px; border-radius: 8px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1) inset; }\n.hb-qf7-nm { display: flex; min-width: 0; flex: 1; flex-direction: column; }\n.hb-qf7-nm b { overflow: hidden; font-size: 13px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }\n.hb-qf7-nm span { overflow: hidden; color: #8f8f8f; font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }\n.hb-qf7-qty { display: inline-flex; flex: none; align-items: center; height: 24px; background: #0a0a0a; border: 1px solid #2a2a2a; border-radius: 999px; }\n.hb-qf7-qb {\n  display: grid;\n  place-items: center;\n  width: 24px;\n  height: 22px;\n  margin: 0;\n  padding: 0;\n  color: #a1a1a1;\n  background: none;\n  border: 0;\n  border-radius: 999px;\n  cursor: pointer;\n  transition: color 0.2s ease, background-color 0.2s ease;\n}\n.hb-qf7-qb:hover:not(:disabled) { color: #fff; background: #1f1f1f; }\n.hb-qf7-qb:disabled { opacity: 0.35; cursor: not-allowed; }\n.hb-qf7-qb:focus-visible { outline: 2px solid var(--hb-qf7-x); outline-offset: 1px; }\n.hb-qf7-qb svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }\n.hb-qf7-qn { min-width: 16px; font-size: 12px; font-variant-numeric: tabular-nums; text-align: center; }\n.hb-qf7-px { flex: none; min-width: 56px; font-weight: 500; text-align: right; }\n.hb-qf7-lines { margin: 10px 0 0; padding: 10px 0 0; border-top: 1px solid #262626; }\n.hb-qf7-ln { display: flex; align-items: center; justify-content: space-between; min-height: 18px; margin: 0; color: #a1a1a1; font-size: 12.5px; }\n.hb-qf7-ln dd { margin: 0; color: #ededed; }\n.hb-qf7-ln[data-kind=\"discount\"] dd { color: #3ddc97; }\n.hb-qf7-tt { display: flex; align-items: baseline; justify-content: space-between; margin: 8px 0 0; padding: 8px 0 0; border-top: 1px dashed #333333; }\n.hb-qf7-tt dt { font-size: 13.5px; font-weight: 600; }\n.hb-qf7-tt dd { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -0.02em; }\n.hb-qf7-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n.hb-qf7-roll { position: relative; display: inline-flex; align-items: flex-start; height: calc(var(--hb-qf7-lh) * 1em); font-variant-numeric: tabular-nums; line-height: var(--hb-qf7-lh); white-space: pre; --hb-qf7-lh: 1.25; }\n.hb-qf7-d { display: inline-block; height: calc(var(--hb-qf7-lh) * 1em); overflow: hidden; }\n.hb-qf7-dc { display: flex; flex-direction: column; transition: transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1); }\n.hb-qf7-dc > span { display: block; height: calc(var(--hb-qf7-lh) * 1em); }\n@container (min-width: 400px) {\n  .hb-qf7-fold { grid-template-rows: 1fr; }\n  .hb-qf7-peek, .hb-qf7-chev { display: none; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-qf7-fold, .hb-qf7-chev, .hb-qf7-peek, .hb-qf7-dc, .hb-qf7-qb { transition: none; }\n}\n`;\n\nfunction money(cents: number, currency: string) {\n  const abs = Math.abs(cents);\n  const whole = Math.floor(abs / 100)\n    .toString()\n    .replace(/\\B(?=(\\d{3})+(?!\\d))/g, \",\");\n  const frac = (abs % 100).toString().padStart(2, \"0\");\n  return `${cents < 0 ? \"-\" : \"\"}${currency}${whole}.${frac}`;\n}\n\nfunction Roll({ text }: { text: string }) {\n  const chars = text.split(\"\");\n  return (\n    <span className=\"hb-qf7-roll\">\n      <span className=\"hb-qf7-sr\">{text}</span>\n      {chars.map((ch, i) => {\n        const key = chars.length - i;\n        if (ch < \"0\" || ch > \"9\") {\n          return (\n            <span key={key} aria-hidden=\"true\">\n              {ch}\n            </span>\n          );\n        }\n        return (\n          <span key={key} className=\"hb-qf7-d\" aria-hidden=\"true\">\n            <span className=\"hb-qf7-dc\" style={{ transform: `translateY(calc(${Number(ch)} * var(--hb-qf7-lh) * -1em))` }}>\n              {\"0123456789\".split(\"\").map((d) => (\n                <span key={d}>{d}</span>\n              ))}\n            </span>\n          </span>\n        );\n      })}\n    </span>\n  );\n}\n\nexport function PayOrderSummary({\n  items = defaultItems,\n  quantities,\n  onQuantityChange,\n  currency = \"$\",\n  discount = 0,\n  discountLabel = \"Discount\",\n  taxRate = 0.08,\n  shipping,\n  title = \"Order summary\",\n  defaultOpen = false,\n  accent = \"#2f7bff\",\n  className = \"\",\n  style,\n  ...rest\n}: PayOrderSummaryProps) {\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const listId = React.useId();\n  const [open, setOpen] = React.useState(defaultOpen);\n  const [inner, setInner] = React.useState<Record<string, number>>({});\n  const [wide, setWide] = React.useState(false);\n\n  React.useEffect(() => {\n    const el = rootRef.current;\n    if (!el || typeof ResizeObserver === \"undefined\") return;\n    const ro = new ResizeObserver(([entry]) => setWide(entry.contentRect.width >= 400));\n    ro.observe(el);\n    return () => ro.disconnect();\n  }, []);\n\n  const qty = (item: PayOrderItem) => quantities?.[item.id] ?? inner[item.id] ?? item.quantity ?? 1;\n\n  function change(item: PayOrderItem, next: number) {\n    const clamped = Math.min(99, Math.max(1, next));\n    if (clamped === qty(item)) return;\n    if (quantities === undefined) setInner((s) => ({ ...s, [item.id]: clamped }));\n    onQuantityChange?.(item.id, clamped);\n  }\n\n  const count = items.reduce((n, item) => n + qty(item), 0);\n  const subtotal = items.reduce((sum, item) => sum + item.price * qty(item), 0);\n  const off = Math.min(subtotal, Math.max(0, discount));\n  const tax = Math.round((subtotal - off) * Math.max(0, taxRate));\n  const ship = shipping ?? 0;\n  const total = subtotal - off + tax + ship;\n  const vars = { \"--hb-qf7-x\": accent, ...style } as React.CSSProperties;\n\n  const head = (\n    <>\n      <span className=\"hb-qf7-ttl\">\n        <b>{title}</b>\n        <span>\n          {count} {count === 1 ? \"item\" : \"items\"}\n        </span>\n      </span>\n      <span className=\"hb-qf7-peek\">\n        <Roll text={money(total, currency)} />\n        <svg className=\"hb-qf7-chev\" viewBox=\"0 0 16 16\" aria-hidden=\"true\">\n          <path d=\"M3.5 6l4.5 4.5L12.5 6\" />\n        </svg>\n      </span>\n    </>\n  );\n\n  return (\n    <div ref={rootRef} className={`hb-qf7 ${className}`} style={vars} data-open={open} {...rest}>\n      <style href=\"hb-pay-order-summary\" precedence=\"default\">{css}</style>\n      <div className=\"hb-qf7-card\">\n        {wide ? (\n          <div className=\"hb-qf7-hd\">{head}</div>\n        ) : (\n          <button type=\"button\" className=\"hb-qf7-hd\" aria-expanded={open} aria-controls={listId} onClick={() => setOpen((v) => !v)}>\n            {head}\n          </button>\n        )}\n        <div className=\"hb-qf7-fold\">\n          <div id={listId}>\n            <ul className=\"hb-qf7-list\">\n              {items.map((item, i) => (\n                <li key={item.id} className=\"hb-qf7-it\">\n                  <span\n                    className=\"hb-qf7-sw\"\n                    aria-hidden=\"true\"\n                    style={{\n                      background: `linear-gradient(135deg, ${item.swatch ?? [\"#7fb3ff\", \"#c58fff\", \"#ffb36b\"][i % 3]}, color-mix(in srgb, ${item.swatch ?? \"#2f7bff\"} 55%, #000))`,\n                    }}\n                  />\n                  <span className=\"hb-qf7-nm\">\n                    <b>{item.name}</b>\n                    {item.detail && <span>{item.detail}</span>}\n                  </span>\n                  <span className=\"hb-qf7-qty\" role=\"group\" aria-label={`Quantity of ${item.name}`}>\n                    <button type=\"button\" className=\"hb-qf7-qb\" aria-label={`Decrease ${item.name}`} disabled={qty(item) <= 1} onClick={() => change(item, qty(item) - 1)}>\n                      <svg viewBox=\"0 0 12 12\" aria-hidden=\"true\">\n                        <path d=\"M2.5 6h7\" />\n                      </svg>\n                    </button>\n                    <span className=\"hb-qf7-qn\" aria-live=\"polite\">\n                      {qty(item)}\n                    </span>\n                    <button type=\"button\" className=\"hb-qf7-qb\" aria-label={`Increase ${item.name}`} disabled={qty(item) >= 99} onClick={() => change(item, qty(item) + 1)}>\n                      <svg viewBox=\"0 0 12 12\" aria-hidden=\"true\">\n                        <path d=\"M2.5 6h7M6 2.5v7\" />\n                      </svg>\n                    </button>\n                  </span>\n                  <span className=\"hb-qf7-px\">\n                    <Roll text={money(item.price * qty(item), currency)} />\n                  </span>\n                </li>\n              ))}\n            </ul>\n          </div>\n        </div>\n        <dl className=\"hb-qf7-lines\">\n          <div className=\"hb-qf7-ln\">\n            <dt>Subtotal</dt>\n            <dd>\n              <Roll text={money(subtotal, currency)} />\n            </dd>\n          </div>\n          {off > 0 && (\n            <div className=\"hb-qf7-ln\" data-kind=\"discount\">\n              <dt>{discountLabel}</dt>\n              <dd>\n                <Roll text={money(-off, currency)} />\n              </dd>\n            </div>\n          )}\n          {shipping !== undefined && (\n            <div className=\"hb-qf7-ln\">\n              <dt>Shipping</dt>\n              <dd>{ship === 0 ? \"Free\" : <Roll text={money(ship, currency)} />}</dd>\n            </div>\n          )}\n          {taxRate > 0 && (\n            <div className=\"hb-qf7-ln\">\n              <dt>Tax ({String(+(taxRate * 100).toFixed(2))}%)</dt>\n              <dd>\n                <Roll text={money(tax, currency)} />\n              </dd>\n            </div>\n          )}\n          <div className=\"hb-qf7-tt\">\n            <dt>Total</dt>\n            <dd>\n              <Roll text={money(total, currency)} />\n            </dd>\n          </div>\n        </dl>\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}