{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "shop-checkout-steps",
  "type": "registry:component",
  "title": "Shop Checkout Steps",
  "description": "A three step checkout with an animated step header, a shipping form, delivery method cards with prices, payment options, a review screen and a live order summary.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "ecommerce",
    "ecommerce",
    "checkout",
    "stepper",
    "form",
    "delivery",
    "payment"
  ],
  "docs": "https://hyperblur.dev/effects/shop-checkout-steps",
  "files": [
    {
      "path": "registry/hyperblur/shop-checkout-steps.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/shop-checkout-steps.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface CheckoutItem {\n  name: string;\n  variant?: string;\n  price: number;\n  quantity: number;\n  tone?: string;\n}\n\nexport interface DeliveryOption {\n  id: string;\n  label: string;\n  eta: string;\n  price: number;\n}\n\nexport interface ShippingInfo {\n  email: string;\n  firstName: string;\n  lastName: string;\n  address: string;\n  city: string;\n  postal: string;\n  country: string;\n}\n\nexport interface CheckoutResult {\n  shipping: ShippingInfo;\n  delivery: DeliveryOption;\n  payment: \"card\" | \"bank\" | \"later\";\n  total: number;\n}\n\nexport interface ShopCheckoutStepsProps extends Omit<React.HTMLAttributes<HTMLElement>, \"title\"> {\n  title?: string;\n  items?: CheckoutItem[];\n  deliveryOptions?: DeliveryOption[];\n  defaultDelivery?: string;\n  defaultShipping?: Partial<ShippingInfo>;\n  countries?: string[];\n  currency?: string;\n  taxRate?: number;\n  orderNumber?: string;\n  onStepChange?: (step: number) => void;\n  onComplete?: (result: CheckoutResult) => void;\n  accent?: string;\n}\n\nconst steps = [\n  { label: \"Shipping\", hint: \"Address and delivery\" },\n  { label: \"Payment\", hint: \"How you pay\" },\n  { label: \"Review\", hint: \"Confirm the order\" },\n];\n\nconst payments: { id: CheckoutResult[\"payment\"]; label: string; hint: string }[] = [\n  { id: \"card\", label: \"Card\", hint: \"Debit or credit\" },\n  { id: \"bank\", label: \"Bank transfer\", hint: \"Ships after payment clears\" },\n  { id: \"later\", label: \"Pay in 4\", hint: \"Interest free, every 2 weeks\" },\n];\n\nconst emptyShipping: ShippingInfo = { email: \"\", firstName: \"\", lastName: \"\", address: \"\", city: \"\", postal: \"\", country: \"United States\" };\n\nfunction money(value: number, currency: string) {\n  const [whole, cents] = value.toFixed(2).split(\".\");\n  return `${currency}${whole.replace(/\\B(?=(\\d{3})+$)/g, \",\")}.${cents}`;\n}\n\nconst css = `\n.hb-ki8 {\n  --hb-ki8-accent: #7c5cff;\n  box-sizing: border-box;\n  width: 100%;\n  container-type: inline-size;\n  background: #0a0a0a;\n  color: #ededed;\n  font-family: inherit;\n  -webkit-font-smoothing: antialiased;\n}\n.hb-ki8 *, .hb-ki8 *::before, .hb-ki8 *::after { box-sizing: border-box; }\n.hb-ki8-inner {\n  max-width: 1120px;\n  margin: 0 auto;\n  padding: clamp(36px, 5.5cqi, 96px) clamp(16px, 4cqi, 40px) clamp(56px, 8cqi, 104px);\n}\n.hb-ki8-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; }\n.hb-ki8-title { margin: 0; font-size: clamp(24px, 3cqi, 30px); font-weight: 650; letter-spacing: -.03em; }\n.hb-ki8-secure { display: inline-flex; align-items: center; gap: 6px; color: #8f8f8f; font-size: 13px; }\n.hb-ki8-secure svg { width: 14px; height: 14px; color: #4ade80; }\n.hb-ki8-steps {\n  display: grid;\n  grid-template-columns: repeat(3, minmax(0, 1fr));\n  margin: 0 0 24px;\n  padding: 0;\n  list-style: none;\n}\n.hb-ki8-step { position: relative; min-width: 0; }\n.hb-ki8-step + .hb-ki8-step::before {\n  content: \"\";\n  position: absolute;\n  top: 17px;\n  left: calc(-50% + 26px);\n  right: calc(50% + 26px);\n  height: 2px;\n  border-radius: 2px;\n  background: rgba(255,255,255,.08);\n}\n.hb-ki8-step + .hb-ki8-step::after {\n  content: \"\";\n  position: absolute;\n  top: 17px;\n  left: calc(-50% + 26px);\n  right: calc(50% + 26px);\n  height: 2px;\n  border-radius: 2px;\n  background: var(--hb-ki8-accent);\n  transform-origin: left;\n  transform: scaleX(0);\n  transition: transform .6s cubic-bezier(.65,0,.25,1);\n}\n.hb-ki8-step[data-state=\"done\"] + .hb-ki8-step::after { transform: scaleX(1); }\n.hb-ki8-sbtn {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  gap: 8px;\n  width: 100%;\n  margin: 0;\n  padding: 0;\n  border: 0;\n  background: none;\n  color: inherit;\n  font: inherit;\n  text-align: center;\n  cursor: default;\n}\n.hb-ki8-sbtn:not(:disabled) { cursor: pointer; }\n.hb-ki8-sbtn:focus-visible { outline: none; }\n.hb-ki8-sbtn:focus-visible .hb-ki8-dot { outline: 2px solid var(--hb-ki8-accent); outline-offset: 3px; }\n.hb-ki8-dot {\n  position: relative;\n  display: grid;\n  place-items: center;\n  width: 36px;\n  height: 36px;\n  border-radius: 50%;\n  background: #111;\n  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);\n  color: #8f8f8f;\n  font-size: 13px;\n  font-weight: 600;\n  font-variant-numeric: tabular-nums;\n  transition: background-color .3s ease, box-shadow .3s ease, color .3s ease;\n}\n.hb-ki8-step[data-state=\"current\"] .hb-ki8-dot {\n  background: color-mix(in srgb, var(--hb-ki8-accent) 16%, #111);\n  box-shadow: inset 0 0 0 1.5px var(--hb-ki8-accent), 0 0 0 5px color-mix(in srgb, var(--hb-ki8-accent) 14%, transparent);\n  color: #fff;\n}\n.hb-ki8-step[data-state=\"done\"] .hb-ki8-dot { background: var(--hb-ki8-accent); box-shadow: none; color: #fff; }\n.hb-ki8-dot svg { width: 16px; height: 16px; }\n.hb-ki8-dot path { stroke-dasharray: 18; stroke-dashoffset: 18; animation: hb-ki8-draw .4s .15s ease forwards; }\n.hb-ki8-slabel { font-size: 13.5px; font-weight: 600; }\n.hb-ki8-step[data-state=\"upcoming\"] .hb-ki8-slabel { color: #8f8f8f; }\n.hb-ki8-shint { display: none; margin-top: -4px; color: #6b6b6b; font-size: 12px; }\n.hb-ki8-grid { display: grid; gap: 20px; }\n.hb-ki8-card {\n  min-width: 0;\n  border: 1px solid rgba(255,255,255,.08);\n  border-radius: 22px;\n  background: linear-gradient(180deg, #121212, #0e0e0e);\n  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);\n  padding: clamp(18px, 2.6cqi, 28px);\n}\n.hb-ki8-pane { animation: hb-ki8-in .45s cubic-bezier(.2,.7,.2,1) both; }\n.hb-ki8-h { margin: 0 0 16px; font-size: 15px; font-weight: 600; }\n.hb-ki8-h + .hb-ki8-fields { margin-top: 0; }\n.hb-ki8-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }\n.hb-ki8-field { display: grid; gap: 6px; min-width: 0; grid-column: span 2; }\n.hb-ki8-half { grid-column: span 1; }\n.hb-ki8-field span { color: #a1a1a1; font-size: 12.5px; font-weight: 500; }\n.hb-ki8-input {\n  width: 100%;\n  height: 42px;\n  padding: 0 13px;\n  border: 1px solid rgba(255,255,255,.1);\n  border-radius: 11px;\n  background: #0a0a0a;\n  color: #ededed;\n  font: inherit;\n  font-size: 14px;\n  outline: none;\n  transition: border-color .2s ease, box-shadow .2s ease;\n  appearance: none;\n}\n.hb-ki8-input::placeholder { color: #555; }\n.hb-ki8-input:focus { border-color: color-mix(in srgb, var(--hb-ki8-accent) 70%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--hb-ki8-accent) 20%, transparent); }\nselect.hb-ki8-input {\n  padding-right: 36px;\n  background-image: linear-gradient(45deg, transparent 50%, #8f8f8f 50%), linear-gradient(135deg, #8f8f8f 50%, transparent 50%);\n  background-position: calc(100% - 18px) 18px, calc(100% - 13px) 18px;\n  background-size: 5px 5px;\n  background-repeat: no-repeat;\n}\n.hb-ki8-sep { height: 1px; margin: 22px 0; background: rgba(255,255,255,.07); border: 0; }\n.hb-ki8-radios { display: grid; gap: 10px; }\n.hb-ki8-radio {\n  position: relative;\n  display: flex;\n  align-items: center;\n  gap: 12px;\n  padding: 14px 16px;\n  border: 1px solid rgba(255,255,255,.1);\n  border-radius: 14px;\n  background: #0b0b0b;\n  cursor: pointer;\n  transition: border-color .2s ease, background-color .2s ease, box-shadow .2s ease;\n}\n.hb-ki8-radio:hover { border-color: rgba(255,255,255,.2); }\n.hb-ki8-radio[data-checked=\"true\"] {\n  border-color: var(--hb-ki8-accent);\n  background: color-mix(in srgb, var(--hb-ki8-accent) 8%, #0b0b0b);\n  box-shadow: 0 0 0 1px var(--hb-ki8-accent);\n}\n.hb-ki8-radio input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }\n.hb-ki8-radio:has(input:focus-visible) { outline: 2px solid var(--hb-ki8-accent); outline-offset: 2px; }\n.hb-ki8-ring {\n  display: grid;\n  place-items: center;\n  flex: none;\n  width: 18px;\n  height: 18px;\n  border-radius: 50%;\n  box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.25);\n  transition: box-shadow .2s ease;\n}\n.hb-ki8-ring::after {\n  content: \"\";\n  width: 8px;\n  height: 8px;\n  border-radius: 50%;\n  background: #fff;\n  transform: scale(0);\n  transition: transform .25s cubic-bezier(.2,.9,.3,1.4);\n}\n.hb-ki8-radio[data-checked=\"true\"] .hb-ki8-ring { box-shadow: inset 0 0 0 9px var(--hb-ki8-accent); }\n.hb-ki8-radio[data-checked=\"true\"] .hb-ki8-ring::after { transform: scale(1); }\n.hb-ki8-rtext { display: grid; gap: 2px; flex: 1; min-width: 0; }\n.hb-ki8-rtext b { font-size: 14px; font-weight: 600; }\n.hb-ki8-rtext small { color: #8f8f8f; font-size: 12.5px; }\n.hb-ki8-rprice { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }\n.hb-ki8-free { color: #4ade80; }\n.hb-ki8-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 24px; }\n.hb-ki8-back {\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n  height: 44px;\n  margin: 0;\n  padding: 0 4px;\n  border: 0;\n  background: none;\n  color: #a1a1a1;\n  font: inherit;\n  font-size: 14px;\n  cursor: pointer;\n  border-radius: 8px;\n}\n.hb-ki8-back:hover { color: #ededed; }\n.hb-ki8-back:focus-visible { outline: 2px solid var(--hb-ki8-accent); outline-offset: 2px; }\n.hb-ki8-back svg { width: 14px; height: 14px; }\n.hb-ki8-next {\n  display: inline-flex;\n  align-items: center;\n  justify-content: center;\n  gap: 8px;\n  height: 48px;\n  margin: 0 0 0 auto;\n  padding: 0 22px;\n  border: 0;\n  border-radius: 14px;\n  background: var(--hb-ki8-accent);\n  box-shadow: inset 0 1px 0 rgba(255,255,255,.28), 0 12px 30px -14px var(--hb-ki8-accent);\n  color: #fff;\n  font: inherit;\n  font-size: 14.5px;\n  font-weight: 600;\n  cursor: pointer;\n  transition: filter .2s ease, transform .15s ease;\n}\n.hb-ki8-next svg { width: 15px; height: 15px; transition: transform .25s ease; }\n.hb-ki8-next:hover { filter: brightness(1.1); }\n.hb-ki8-next:hover svg { transform: translateX(3px); }\n.hb-ki8-next:active { transform: scale(.985); }\n.hb-ki8-next:disabled { opacity: .6; cursor: progress; }\n.hb-ki8-next:focus-visible { outline: 2px solid #ededed; outline-offset: 3px; }\n.hb-ki8-check { display: flex; align-items: center; gap: 10px; margin-top: 16px; color: #c9c9c9; font-size: 13.5px; cursor: pointer; }\n.hb-ki8-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--hb-ki8-accent); }\n.hb-ki8-review { margin: 0; padding: 0; list-style: none; }\n.hb-ki8-review li { display: flex; align-items: flex-start; gap: 16px; padding: 14px 0; border-bottom: 1px solid rgba(255,255,255,.06); }\n.hb-ki8-review li:first-child { padding-top: 0; }\n.hb-ki8-rk { width: 92px; flex: none; color: #8f8f8f; font-size: 13px; }\n.hb-ki8-rv { flex: 1; min-width: 0; margin: 0; color: #ededed; font-size: 14px; line-height: 1.5; }\n.hb-ki8-edit {\n  margin: 0;\n  padding: 2px 6px;\n  border: 0;\n  border-radius: 6px;\n  background: none;\n  color: color-mix(in srgb, var(--hb-ki8-accent) 70%, #fff);\n  font: inherit;\n  font-size: 13px;\n  cursor: pointer;\n}\n.hb-ki8-edit:hover { text-decoration: underline; text-underline-offset: 3px; }\n.hb-ki8-edit:focus-visible { outline: 2px solid var(--hb-ki8-accent); outline-offset: 1px; }\n.hb-ki8-spin { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: hb-ki8-rot .7s linear infinite; }\n.hb-ki8-done { display: grid; justify-items: center; gap: 12px; padding: 28px 8px; text-align: center; }\n.hb-ki8-badge {\n  display: grid;\n  place-items: center;\n  width: 64px;\n  height: 64px;\n  border-radius: 50%;\n  background: color-mix(in srgb, var(--hb-ki8-accent) 16%, transparent);\n  box-shadow: inset 0 0 0 1.5px var(--hb-ki8-accent), 0 0 40px -6px var(--hb-ki8-accent);\n  color: #fff;\n  animation: hb-ki8-pop .5s cubic-bezier(.2,.9,.3,1.3) both;\n}\n.hb-ki8-badge svg { width: 28px; height: 28px; }\n.hb-ki8-badge path { stroke-dasharray: 30; stroke-dashoffset: 30; animation: hb-ki8-draw .5s .3s ease forwards; }\n.hb-ki8-done h3 { margin: 4px 0 0; font-size: 22px; font-weight: 650; letter-spacing: -.02em; }\n.hb-ki8-done p { margin: 0; max-width: 380px; color: #8f8f8f; font-size: 14px; line-height: 1.6; }\n.hb-ki8-summary { align-self: start; }\n.hb-ki8-items { display: grid; gap: 14px; margin: 0 0 18px; padding: 0; list-style: none; }\n.hb-ki8-items li { display: flex; align-items: center; gap: 12px; }\n.hb-ki8-thumb {\n  position: relative;\n  flex: none;\n  width: 52px;\n  height: 52px;\n  border-radius: 12px;\n  box-shadow: inset 0 0 0 1px rgba(255,255,255,.1), inset 0 1px 0 rgba(255,255,255,.18);\n}\n.hb-ki8-qty {\n  position: absolute;\n  top: -6px;\n  right: -6px;\n  display: grid;\n  place-items: center;\n  min-width: 20px;\n  height: 20px;\n  padding: 0 5px;\n  border-radius: 999px;\n  background: #ededed;\n  color: #0a0a0a;\n  font-size: 11px;\n  font-weight: 700;\n}\n.hb-ki8-iname { flex: 1; min-width: 0; }\n.hb-ki8-iname b { display: block; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-ki8-iname small { color: #8f8f8f; font-size: 12px; }\n.hb-ki8-iprice { font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; }\n.hb-ki8-totals { display: grid; gap: 10px; margin: 0; padding: 16px 0 0; border-top: 1px solid rgba(255,255,255,.07); }\n.hb-ki8-totals div { display: flex; justify-content: space-between; color: #a1a1a1; font-size: 13.5px; }\n.hb-ki8-totals dt, .hb-ki8-totals dd { margin: 0; }\n.hb-ki8-totals dd { color: #ededed; font-variant-numeric: tabular-nums; }\n.hb-ki8-total { display: flex; align-items: baseline; justify-content: space-between; margin-top: 16px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.07); }\n.hb-ki8-total span { color: #a1a1a1; font-size: 14px; }\n.hb-ki8-total b { font-size: 24px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }\n.hb-ki8-total b span { color: #6b6b6b; font-size: 12px; font-weight: 500; margin-right: 6px; }\n.hb-ki8-perk { display: flex; align-items: center; gap: 8px; margin: 16px 0 0; padding: 12px 14px; border-radius: 12px; background: #0b0b0b; color: #a1a1a1; font-size: 12.5px; }\n.hb-ki8-perk svg { width: 16px; height: 16px; flex: none; color: var(--hb-ki8-accent); }\n.hb-ki8-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }\n@container (min-width: 600px) {\n  .hb-ki8-shint { display: block; }\n  .hb-ki8-radios-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }\n  .hb-ki8-radios-row .hb-ki8-radio { flex-direction: column; align-items: flex-start; }\n  .hb-ki8-radios-row .hb-ki8-ring { position: absolute; top: 14px; right: 14px; }\n  .hb-ki8-radios-row .hb-ki8-rtext { width: 100%; padding-right: 24px; }\n}\n@container (max-width: 480px) {\n  .hb-ki8-half { grid-column: span 2; }\n}\n@container (min-width: 880px) {\n  .hb-ki8-grid { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 20px; align-items: start; }\n}\n@keyframes hb-ki8-in {\n  from { opacity: 0; transform: translateX(16px); }\n  to { opacity: 1; transform: none; }\n}\n@keyframes hb-ki8-draw { to { stroke-dashoffset: 0; } }\n@keyframes hb-ki8-rot { to { transform: rotate(360deg); } }\n@keyframes hb-ki8-pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-ki8-pane, .hb-ki8-spin, .hb-ki8-badge { animation: none; }\n  .hb-ki8-dot path, .hb-ki8-badge path { animation: none; stroke-dashoffset: 0; }\n  .hb-ki8-step + .hb-ki8-step::after, .hb-ki8-dot, .hb-ki8-input, .hb-ki8-radio, .hb-ki8-ring, .hb-ki8-ring::after, .hb-ki8-next, .hb-ki8-next svg { transition: none; }\n}\n`;\n\nconst arrow = (\n  <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n    <path d=\"M3 8h10M9 4l4 4-4 4\" />\n  </svg>\n);\n\nconst backArrow = (\n  <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n    <path d=\"M13 8H3M7 4L3 8l4 4\" />\n  </svg>\n);\n\nexport function ShopCheckoutSteps({\n  title = \"Checkout\",\n  items = [\n    { name: \"Aero Pour-Over Kettle\", variant: \"Matte black, 1L\", price: 89, quantity: 1, tone: \"#3a3f4b\" },\n    { name: \"Single Origin Sampler\", variant: \"4 x 250g, whole bean\", price: 54, quantity: 1, tone: \"#7a4b2a\" },\n    { name: \"Stoneware Cup\", variant: \"Sand\", price: 18, quantity: 2, tone: \"#c8b69a\" },\n  ],\n  deliveryOptions = [\n    { id: \"standard\", label: \"Standard\", eta: \"5 to 7 business days\", price: 0 },\n    { id: \"express\", label: \"Express\", eta: \"2 to 3 business days\", price: 12 },\n    { id: \"overnight\", label: \"Overnight\", eta: \"Next business day\", price: 28 },\n  ],\n  defaultDelivery,\n  defaultShipping,\n  countries = [\"United States\", \"Canada\", \"United Kingdom\", \"Germany\", \"Australia\"],\n  currency = \"$\",\n  taxRate = 0.0725,\n  orderNumber = \"NW-20418\",\n  onStepChange,\n  onComplete,\n  accent = \"#7c5cff\",\n  className,\n  style,\n  ...rest\n}: ShopCheckoutStepsProps) {\n  const [step, setStep] = React.useState(0);\n  const [ship, setShip] = React.useState<ShippingInfo>({ ...emptyShipping, ...defaultShipping });\n  const [delivery, setDelivery] = React.useState(defaultDelivery ?? deliveryOptions[1]?.id ?? deliveryOptions[0]?.id ?? \"\");\n  const [payment, setPayment] = React.useState<CheckoutResult[\"payment\"]>(\"card\");\n  const [card, setCard] = React.useState({ name: \"\", number: \"\", expiry: \"\", cvc: \"\" });\n  const [billingSame, setBillingSame] = React.useState(true);\n  const [status, setStatus] = React.useState<\"idle\" | \"placing\" | \"placed\">(\"idle\");\n  const timer = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n  const uid = React.useId();\n\n  React.useEffect(() => () => {\n    if (timer.current) clearTimeout(timer.current);\n  }, []);\n\n  const option = deliveryOptions.find((o) => o.id === delivery) ?? deliveryOptions[0];\n  const subtotal = items.reduce((sum, item) => sum + item.price * item.quantity, 0);\n  const shippingCost = option?.price ?? 0;\n  const tax = Math.round(subtotal * taxRate * 100) / 100;\n  const total = subtotal + shippingCost + tax;\n\n  const go = (next: number) => {\n    setStep(next);\n    onStepChange?.(next);\n  };\n\n  const field = (key: keyof ShippingInfo) => ({\n    id: `${uid}-${key}`,\n    value: ship[key],\n    onChange: (event: React.ChangeEvent<HTMLInputElement | HTMLSelectElement>) => setShip((s) => ({ ...s, [key]: event.target.value })),\n  });\n\n  const place = () => {\n    if (status !== \"idle\" || !option) return;\n    setStatus(\"placing\");\n    timer.current = setTimeout(() => {\n      setStatus(\"placed\");\n      onComplete?.({ shipping: ship, delivery: option, payment, total });\n    }, 1100);\n  };\n\n  const formatCard = (value: string) =>\n    value\n      .replace(/\\D/g, \"\")\n      .slice(0, 16)\n      .replace(/(\\d{4})(?=\\d)/g, \"$1 \");\n\n  const formatExpiry = (value: string) => {\n    const digits = value.replace(/\\D/g, \"\").slice(0, 4);\n    return digits.length > 2 ? `${digits.slice(0, 2)} / ${digits.slice(2)}` : digits;\n  };\n\n  const last4 = card.number.replace(/\\D/g, \"\").slice(-4);\n  const paymentText =\n    payment === \"card\" ? (last4 ? `Card ending in ${last4}` : \"Card\") : payment === \"bank\" ? \"Bank transfer\" : \"Pay in 4 installments\";\n\n  return (\n    <section\n      className={className ? `hb-ki8 ${className}` : \"hb-ki8\"}\n      style={{ \"--hb-ki8-accent\": accent, ...style } as React.CSSProperties}\n      {...rest}\n    >\n      <style href=\"hb-shop-checkout-steps\" precedence=\"default\">{css}</style>\n      <div className=\"hb-ki8-inner\">\n        <div className=\"hb-ki8-top\">\n          <h2 className=\"hb-ki8-title\">{title}</h2>\n          <span className=\"hb-ki8-secure\">\n            <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n              <rect x=\"3\" y=\"7\" width=\"10\" height=\"7\" rx=\"1.5\" />\n              <path d=\"M5.5 7V5a2.5 2.5 0 0 1 5 0v2\" />\n            </svg>\n            Encrypted, secure checkout\n          </span>\n        </div>\n        <ol className=\"hb-ki8-steps\" aria-label=\"Checkout progress\">\n          {steps.map((s, i) => {\n            const state = status === \"placed\" || i < step ? \"done\" : i === step ? \"current\" : \"upcoming\";\n            return (\n              <li key={s.label} className=\"hb-ki8-step\" data-state={state}>\n                <button\n                  type=\"button\"\n                  className=\"hb-ki8-sbtn\"\n                  disabled={state !== \"done\" || status !== \"idle\"}\n                  aria-current={state === \"current\" ? \"step\" : undefined}\n                  onClick={() => go(i)}\n                >\n                  <span className=\"hb-ki8-dot\">\n                    {state === \"done\" ? (\n                      <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                        <path d=\"M3.5 8.5l3 3 6-7\" />\n                      </svg>\n                    ) : (\n                      i + 1\n                    )}\n                  </span>\n                  <span className=\"hb-ki8-slabel\">{s.label}</span>\n                  <span className=\"hb-ki8-shint\">{s.hint}</span>\n                  <span className=\"hb-ki8-sr\">{state === \"done\" ? \", completed\" : state === \"current\" ? \", current step\" : \"\"}</span>\n                </button>\n              </li>\n            );\n          })}\n        </ol>\n        <div className=\"hb-ki8-grid\">\n          <div className=\"hb-ki8-card\">\n            {status === \"placed\" ? (\n              <div className=\"hb-ki8-done hb-ki8-pane\" role=\"status\">\n                <span className=\"hb-ki8-badge\">\n                  <svg viewBox=\"0 0 28 28\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.4\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                    <path d=\"M7 14.5l4.5 4.5L21 9.5\" />\n                  </svg>\n                </span>\n                <h3>Order {orderNumber} confirmed</h3>\n                <p>\n                  Thanks{ship.firstName ? `, ${ship.firstName}` : \"\"}. A receipt is on its way{ship.email ? ` to ${ship.email}` : \"\"}, and we will email tracking as soon as it ships with {option?.label.toLowerCase()} delivery.\n                </p>\n              </div>\n            ) : step === 0 ? (\n              <form\n                className=\"hb-ki8-pane\"\n                key=\"ship\"\n                onSubmit={(event) => {\n                  event.preventDefault();\n                  go(1);\n                }}\n              >\n                <h3 className=\"hb-ki8-h\">Contact and address</h3>\n                <div className=\"hb-ki8-fields\">\n                  <label className=\"hb-ki8-field\" htmlFor={`${uid}-email`}>\n                    <span>Email</span>\n                    <input className=\"hb-ki8-input\" type=\"email\" required autoComplete=\"email\" placeholder=\"you@example.com\" {...field(\"email\")} />\n                  </label>\n                  <label className=\"hb-ki8-field hb-ki8-half\" htmlFor={`${uid}-firstName`}>\n                    <span>First name</span>\n                    <input className=\"hb-ki8-input\" required autoComplete=\"given-name\" placeholder=\"Jordan\" {...field(\"firstName\")} />\n                  </label>\n                  <label className=\"hb-ki8-field hb-ki8-half\" htmlFor={`${uid}-lastName`}>\n                    <span>Last name</span>\n                    <input className=\"hb-ki8-input\" required autoComplete=\"family-name\" placeholder=\"Reyes\" {...field(\"lastName\")} />\n                  </label>\n                  <label className=\"hb-ki8-field\" htmlFor={`${uid}-address`}>\n                    <span>Street address</span>\n                    <input className=\"hb-ki8-input\" required autoComplete=\"street-address\" placeholder=\"2150 Market Street, Apt 4\" {...field(\"address\")} />\n                  </label>\n                  <label className=\"hb-ki8-field hb-ki8-half\" htmlFor={`${uid}-city`}>\n                    <span>City</span>\n                    <input className=\"hb-ki8-input\" required autoComplete=\"address-level2\" placeholder=\"San Francisco\" {...field(\"city\")} />\n                  </label>\n                  <label className=\"hb-ki8-field hb-ki8-half\" htmlFor={`${uid}-postal`}>\n                    <span>Postal code</span>\n                    <input className=\"hb-ki8-input\" required autoComplete=\"postal-code\" placeholder=\"94114\" {...field(\"postal\")} />\n                  </label>\n                  <label className=\"hb-ki8-field\" htmlFor={`${uid}-country`}>\n                    <span>Country</span>\n                    <select className=\"hb-ki8-input\" autoComplete=\"country-name\" {...field(\"country\")}>\n                      {countries.map((c) => (\n                        <option key={c} value={c}>{c}</option>\n                      ))}\n                    </select>\n                  </label>\n                </div>\n                <hr className=\"hb-ki8-sep\" />\n                <h3 className=\"hb-ki8-h\" id={`${uid}-dlabel`}>Delivery method</h3>\n                <div className=\"hb-ki8-radios hb-ki8-radios-row\" role=\"radiogroup\" aria-labelledby={`${uid}-dlabel`}>\n                  {deliveryOptions.map((o) => (\n                    <label key={o.id} className=\"hb-ki8-radio\" data-checked={o.id === delivery}>\n                      <input type=\"radio\" name={`${uid}-delivery`} value={o.id} checked={o.id === delivery} onChange={() => setDelivery(o.id)} />\n                      <span className=\"hb-ki8-ring\" aria-hidden=\"true\" />\n                      <span className=\"hb-ki8-rtext\">\n                        <b>{o.label}</b>\n                        <small>{o.eta}</small>\n                      </span>\n                      <span className={o.price === 0 ? \"hb-ki8-rprice hb-ki8-free\" : \"hb-ki8-rprice\"}>{o.price === 0 ? \"Free\" : money(o.price, currency)}</span>\n                    </label>\n                  ))}\n                </div>\n                <div className=\"hb-ki8-actions\">\n                  <button type=\"submit\" className=\"hb-ki8-next\">\n                    Continue to payment\n                    {arrow}\n                  </button>\n                </div>\n              </form>\n            ) : step === 1 ? (\n              <form\n                className=\"hb-ki8-pane\"\n                key=\"pay\"\n                onSubmit={(event) => {\n                  event.preventDefault();\n                  go(2);\n                }}\n              >\n                <h3 className=\"hb-ki8-h\" id={`${uid}-plabel`}>Payment method</h3>\n                <div className=\"hb-ki8-radios hb-ki8-radios-row\" role=\"radiogroup\" aria-labelledby={`${uid}-plabel`}>\n                  {payments.map((p) => (\n                    <label key={p.id} className=\"hb-ki8-radio\" data-checked={p.id === payment}>\n                      <input type=\"radio\" name={`${uid}-payment`} value={p.id} checked={p.id === payment} onChange={() => setPayment(p.id)} />\n                      <span className=\"hb-ki8-ring\" aria-hidden=\"true\" />\n                      <span className=\"hb-ki8-rtext\">\n                        <b>{p.label}</b>\n                        <small>{p.hint}</small>\n                      </span>\n                    </label>\n                  ))}\n                </div>\n                {payment === \"card\" && (\n                  <>\n                    <hr className=\"hb-ki8-sep\" />\n                    <div className=\"hb-ki8-fields\">\n                      <label className=\"hb-ki8-field\" htmlFor={`${uid}-cname`}>\n                        <span>Name on card</span>\n                        <input id={`${uid}-cname`} className=\"hb-ki8-input\" required autoComplete=\"cc-name\" placeholder=\"Jordan Reyes\" value={card.name} onChange={(e) => setCard((c) => ({ ...c, name: e.target.value }))} />\n                      </label>\n                      <label className=\"hb-ki8-field\" htmlFor={`${uid}-cnum`}>\n                        <span>Card number</span>\n                        <input id={`${uid}-cnum`} className=\"hb-ki8-input\" required inputMode=\"numeric\" autoComplete=\"cc-number\" placeholder=\"1234 1234 1234 1234\" value={card.number} onChange={(e) => setCard((c) => ({ ...c, number: formatCard(e.target.value) }))} />\n                      </label>\n                      <label className=\"hb-ki8-field hb-ki8-half\" htmlFor={`${uid}-cexp`}>\n                        <span>Expiry</span>\n                        <input id={`${uid}-cexp`} className=\"hb-ki8-input\" required inputMode=\"numeric\" autoComplete=\"cc-exp\" placeholder=\"MM / YY\" value={card.expiry} onChange={(e) => setCard((c) => ({ ...c, expiry: formatExpiry(e.target.value) }))} />\n                      </label>\n                      <label className=\"hb-ki8-field hb-ki8-half\" htmlFor={`${uid}-ccvc`}>\n                        <span>Security code</span>\n                        <input id={`${uid}-ccvc`} className=\"hb-ki8-input\" required inputMode=\"numeric\" autoComplete=\"cc-csc\" placeholder=\"CVC\" value={card.cvc} onChange={(e) => setCard((c) => ({ ...c, cvc: e.target.value.replace(/\\D/g, \"\").slice(0, 4) }))} />\n                      </label>\n                    </div>\n                    <label className=\"hb-ki8-check\">\n                      <input type=\"checkbox\" checked={billingSame} onChange={(e) => setBillingSame(e.target.checked)} />\n                      Billing address is the same as shipping\n                    </label>\n                  </>\n                )}\n                <div className=\"hb-ki8-actions\">\n                  <button type=\"button\" className=\"hb-ki8-back\" onClick={() => go(0)}>\n                    {backArrow}\n                    Back to shipping\n                  </button>\n                  <button type=\"submit\" className=\"hb-ki8-next\">\n                    Review order\n                    {arrow}\n                  </button>\n                </div>\n              </form>\n            ) : (\n              <div className=\"hb-ki8-pane\" key=\"review\">\n                <h3 className=\"hb-ki8-h\">Review and place order</h3>\n                <ul className=\"hb-ki8-review\">\n                  <li>\n                    <span className=\"hb-ki8-rk\">Ship to</span>\n                    <span className=\"hb-ki8-rv\">\n                      {[ship.firstName, ship.lastName].filter(Boolean).join(\" \") || \"Name not set\"}\n                      <br />\n                      {[ship.address, ship.city, ship.postal].filter(Boolean).join(\", \") || \"Address not set\"}\n                      <br />\n                      {ship.country}\n                    </span>\n                    <button type=\"button\" className=\"hb-ki8-edit\" onClick={() => go(0)} aria-label=\"Edit shipping address\">Edit</button>\n                  </li>\n                  <li>\n                    <span className=\"hb-ki8-rk\">Delivery</span>\n                    <span className=\"hb-ki8-rv\">\n                      {option?.label}, {option?.eta.toLowerCase()} · {option && option.price === 0 ? \"Free\" : money(shippingCost, currency)}\n                    </span>\n                    <button type=\"button\" className=\"hb-ki8-edit\" onClick={() => go(0)} aria-label=\"Edit delivery method\">Edit</button>\n                  </li>\n                  <li>\n                    <span className=\"hb-ki8-rk\">Payment</span>\n                    <span className=\"hb-ki8-rv\">{paymentText}</span>\n                    <button type=\"button\" className=\"hb-ki8-edit\" onClick={() => go(1)} aria-label=\"Edit payment\">Edit</button>\n                  </li>\n                </ul>\n                <div className=\"hb-ki8-actions\">\n                  <button type=\"button\" className=\"hb-ki8-back\" onClick={() => go(1)}>\n                    {backArrow}\n                    Back to payment\n                  </button>\n                  <button type=\"button\" className=\"hb-ki8-next\" onClick={place} disabled={status !== \"idle\"}>\n                    {status === \"placing\" ? <span className=\"hb-ki8-spin\" aria-hidden=\"true\" /> : null}\n                    {status === \"placing\" ? \"Placing order\" : `Place order · ${money(total, currency)}`}\n                  </button>\n                </div>\n              </div>\n            )}\n          </div>\n          <aside className=\"hb-ki8-card hb-ki8-summary\" aria-label=\"Order summary\">\n            <h3 className=\"hb-ki8-h\">Order summary</h3>\n            <ul className=\"hb-ki8-items\">\n              {items.map((item) => {\n                const tone = item.tone ?? \"#3a3a3a\";\n                return (\n                  <li key={item.name}>\n                    <span\n                      className=\"hb-ki8-thumb\"\n                      style={{ background: `radial-gradient(circle at 30% 25%, color-mix(in srgb, ${tone} 55%, #fff) 0%, transparent 55%), linear-gradient(150deg, ${tone}, color-mix(in srgb, ${tone} 40%, #000))` }}\n                      aria-hidden=\"true\"\n                    >\n                      <span className=\"hb-ki8-qty\">{item.quantity}</span>\n                    </span>\n                    <span className=\"hb-ki8-iname\">\n                      <b>{item.name}</b>\n                      {item.variant && <small>{item.variant}</small>}\n                    </span>\n                    <span className=\"hb-ki8-iprice\">{money(item.price * item.quantity, currency)}</span>\n                  </li>\n                );\n              })}\n            </ul>\n            <dl className=\"hb-ki8-totals\">\n              <div>\n                <dt>Subtotal</dt>\n                <dd>{money(subtotal, currency)}</dd>\n              </div>\n              <div>\n                <dt>Shipping · {option?.label}</dt>\n                <dd>{shippingCost === 0 ? \"Free\" : money(shippingCost, currency)}</dd>\n              </div>\n              <div>\n                <dt>Tax</dt>\n                <dd>{money(tax, currency)}</dd>\n              </div>\n            </dl>\n            <div className=\"hb-ki8-total\">\n              <span>Total</span>\n              <b>\n                <span>USD</span>\n                {money(total, currency)}\n              </b>\n            </div>\n            <p className=\"hb-ki8-perk\">\n              <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.4\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n                <path d=\"M8 1.5l5 2v4c0 3.2-2.2 5.8-5 7-2.8-1.2-5-3.8-5-7v-4l5-2z\" />\n                <path d=\"M5.8 8l1.6 1.6L10.4 6.4\" />\n              </svg>\n              Free returns for 60 days. Pay only when it ships.\n            </p>\n          </aside>\n        </div>\n      </div>\n    </section>\n  );\n}\n"
    }
  ]
}