{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "order-item-drawer",
  "type": "registry:component",
  "title": "Order Item Drawer",
  "description": "A bottom sheet on narrow screens and a side drawer on wide ones for customizing one item: single and multiple choice groups, removable ingredients, quantity, a note and a live total on the add button.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "ordering",
    "drawer",
    "bottom-sheet",
    "options",
    "ordering",
    "cart",
    "food"
  ],
  "docs": "https://hyperblur.dev/effects/order-item-drawer",
  "files": [
    {
      "path": "registry/hyperblur/order-item-drawer.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/order-item-drawer.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface OrderItemOption {\n  id: string;\n  label: string;\n  price?: number;\n  hint?: string;\n}\n\nexport interface OrderItemGroup {\n  id: string;\n  title: string;\n  type: \"single\" | \"multiple\" | \"remove\";\n  required?: boolean;\n  min?: number;\n  max?: number;\n  options: OrderItemOption[];\n  defaultSelected?: string[];\n}\n\nexport interface OrderItemInfo {\n  id: string;\n  name: string;\n  description: string;\n  price: number;\n  badge?: string;\n  tint?: string;\n}\n\nexport interface OrderItemAddPayload {\n  itemId: string;\n  quantity: number;\n  selections: Record<string, string[]>;\n  note: string;\n  unitPrice: number;\n  total: number;\n}\n\nexport interface OrderItemDrawerLabels {\n  dialog: string;\n  close: string;\n  required: string;\n  optional: string;\n  done: string;\n  chooseOne: string;\n  chooseUpTo: string;\n  chooseBetween: string;\n  chooseAtLeast: string;\n  removeHint: string;\n  missing: string;\n  note: string;\n  notePlaceholder: string;\n  quantity: string;\n  decrease: string;\n  increase: string;\n  add: string;\n  added: string;\n}\n\nexport interface OrderItemDrawerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\" | \"onChange\"> {\n  item?: OrderItemInfo;\n  groups?: OrderItemGroup[];\n  image?: React.ReactNode;\n  open?: boolean;\n  defaultOpen?: boolean;\n  onOpenChange?: (open: boolean) => void;\n  onAdd?: (payload: OrderItemAddPayload) => void;\n  currency?: string;\n  locale?: string;\n  labels?: Partial<OrderItemDrawerLabels>;\n  accent?: string;\n  appearance?: \"dark\" | \"light\";\n  inline?: boolean;\n  defaultQuantity?: number;\n  maxQuantity?: number;\n  noteMaxLength?: number;\n  closeOnAdd?: boolean;\n}\n\nconst defaultLabels: OrderItemDrawerLabels = {\n  dialog: \"Customize item\",\n  close: \"Close\",\n  required: \"Required\",\n  optional: \"Optional\",\n  done: \"Done\",\n  chooseOne: \"Choose 1\",\n  chooseUpTo: \"Choose up to {max}\",\n  chooseBetween: \"Choose {min} to {max}\",\n  chooseAtLeast: \"Choose at least {min}\",\n  removeHint: \"Tap to leave out\",\n  missing: \"Please make a choice here\",\n  note: \"Special instructions\",\n  notePlaceholder: \"No onions, call me at the door\",\n  quantity: \"Quantity\",\n  decrease: \"Decrease quantity\",\n  increase: \"Increase quantity\",\n  add: \"Add to order\",\n  added: \"Added to order\",\n};\n\nconst defaultItem: OrderItemInfo = {\n  id: \"steakhouse-burger\",\n  name: \"Steakhouse Burger\",\n  description: \"7 oz chuck and brisket patty, aged cheddar, charred onion jam, brioche bun.\",\n  price: 15.5,\n  badge: \"Most ordered\",\n  tint: \"#ff8a3d\",\n};\n\nconst defaultGroups: OrderItemGroup[] = [\n  {\n    id: \"doneness\",\n    title: \"How should we cook it?\",\n    type: \"single\",\n    required: true,\n    options: [\n      { id: \"medium-rare\", label: \"Medium rare\", hint: \"Warm red center\" },\n      { id: \"medium\", label: \"Medium\", hint: \"Pink center\" },\n      { id: \"well-done\", label: \"Well done\", hint: \"Cooked through\" },\n    ],\n    defaultSelected: [\"medium\"],\n  },\n  {\n    id: \"side\",\n    title: \"Choose a side\",\n    type: \"single\",\n    required: true,\n    options: [\n      { id: \"fries\", label: \"Shoestring fries\" },\n      { id: \"sweet-potato\", label: \"Sweet potato fries\", price: 1.5 },\n      { id: \"rings\", label: \"Beer-battered onion rings\", price: 2 },\n      { id: \"salad\", label: \"Little gem salad\" },\n    ],\n  },\n  {\n    id: \"extras\",\n    title: \"Add extras\",\n    type: \"multiple\",\n    max: 3,\n    options: [\n      { id: \"bacon\", label: \"Applewood bacon\", price: 2 },\n      { id: \"patty\", label: \"Extra patty\", price: 4.5 },\n      { id: \"egg\", label: \"Fried egg\", price: 1.5 },\n      { id: \"avocado\", label: \"Avocado\", price: 2 },\n      { id: \"jalapeno\", label: \"Pickled jalapeños\", price: 0.75 },\n    ],\n    defaultSelected: [\"bacon\"],\n  },\n  {\n    id: \"remove\",\n    title: \"Remove ingredients\",\n    type: \"remove\",\n    options: [\n      { id: \"pickles\", label: \"Pickles\" },\n      { id: \"onion\", label: \"Onion jam\" },\n      { id: \"sauce\", label: \"House sauce\" },\n      { id: \"lettuce\", label: \"Lettuce\" },\n    ],\n  },\n];\n\nconst css = `\n.hb-oa2 {\n  --hb-oa2-accent: #ff6a3d;\n  --hb-oa2-panel: #111111;\n  --hb-oa2-raise: #171717;\n  --hb-oa2-line: rgba(255, 255, 255, 0.08);\n  --hb-oa2-line-strong: rgba(255, 255, 255, 0.16);\n  --hb-oa2-text: #ededed;\n  --hb-oa2-muted: #8f8f8f;\n  --hb-oa2-error: #ff5d5d;\n  --hb-oa2-ok: #3ddc84;\n  box-sizing: border-box;\n  container-name: hb-oa2-shell;\n  container-type: inline-size;\n  color: var(--hb-oa2-text);\n  font-family: var(--font-sans, ui-sans-serif, system-ui, sans-serif);\n  -webkit-font-smoothing: antialiased;\n}\n.hb-oa2[data-appearance=\"light\"] {\n  --hb-oa2-panel: #ffffff;\n  --hb-oa2-raise: #f4f2ed;\n  --hb-oa2-line: rgba(20, 16, 10, 0.09);\n  --hb-oa2-line-strong: rgba(20, 16, 10, 0.2);\n  --hb-oa2-text: #16130f;\n  --hb-oa2-muted: #6f685e;\n  --hb-oa2-error: #d92d2d;\n  --hb-oa2-ok: #13995a;\n}\n.hb-oa2 *, .hb-oa2 *::before, .hb-oa2 *::after { box-sizing: border-box; }\n.hb-oa2-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: flex-end; justify-content: center; height: 100dvh; }\n.hb-oa2-inline { position: relative; width: 100%; height: 100%; }\n.hb-oa2-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.56); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: hb-oa2-fade 0.3s ease both; }\n.hb-oa2-panel { position: relative; display: flex; flex-direction: column; width: 100%; max-height: min(92dvh, 820px); background: var(--hb-oa2-panel); border: 1px solid var(--hb-oa2-line); border-bottom: 0; border-radius: 24px 24px 0 0; box-shadow: 0 -24px 60px -20px rgba(0, 0, 0, 0.6); outline: none; overflow: hidden; animation: hb-oa2-up 0.42s cubic-bezier(0.2, 0.9, 0.2, 1) both; }\n.hb-oa2-inline .hb-oa2-panel { height: 100%; max-height: none; border-bottom: 1px solid var(--hb-oa2-line); border-radius: 20px; box-shadow: 0 30px 60px -36px rgba(0, 0, 0, 0.7); animation: none; }\n.hb-oa2-grab { flex: none; width: 40px; height: 4px; margin: 8px auto 0; border-radius: 99px; background: var(--hb-oa2-line-strong); }\n.hb-oa2-inline .hb-oa2-grab { display: none; }\n.hb-oa2-close { position: absolute; top: 12px; right: 12px; z-index: 3; display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--hb-oa2-line); border-radius: 50%; background: var(--hb-oa2-raise); color: var(--hb-oa2-text); cursor: pointer; transition: background 0.2s ease, transform 0.15s ease; }\n.hb-oa2-close:hover { background: var(--hb-oa2-line-strong); }\n.hb-oa2-close:active { transform: scale(0.92); }\n.hb-oa2-close:focus-visible, .hb-oa2-step button:focus-visible, .hb-oa2-cta:focus-visible { outline: 2px solid var(--hb-oa2-accent); outline-offset: 2px; }\n.hb-oa2-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; position: relative; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 14px 16px 8px; scroll-behavior: smooth; }\n.hb-oa2-hero { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 14px; align-items: center; padding-right: 40px; margin-bottom: 14px; }\n.hb-oa2-inline .hb-oa2-hero { padding-right: 0; }\n.hb-oa2-art { position: relative; display: grid; place-items: center; aspect-ratio: 1; border-radius: 16px; overflow: hidden; background: radial-gradient(circle at 50% 65%, color-mix(in srgb, var(--hb-oa2-tint) 42%, transparent), transparent 72%), var(--hb-oa2-raise); box-shadow: inset 0 0 0 1px var(--hb-oa2-line); }\n.hb-oa2-art svg { width: 90%; height: auto; filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.28)); }\n.hb-oa2-badge { display: inline-flex; margin-bottom: 4px; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--hb-oa2-accent) 16%, transparent); color: var(--hb-oa2-accent); font-size: 11px; font-weight: 600; }\n.hb-oa2-name { margin: 0; font-family: var(--font-grotesk, inherit); font-size: 18px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }\n.hb-oa2-desc { margin: 4px 0 0; color: var(--hb-oa2-muted); font-size: 12.5px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }\n.hb-oa2-base { margin-top: 6px; font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; }\n.hb-oa2-group { margin: 0 0 12px; padding: 12px; border: 1px solid var(--hb-oa2-line); border-radius: 16px; background: color-mix(in srgb, var(--hb-oa2-raise) 60%, transparent); transition: border-color 0.25s ease, background 0.25s ease; min-width: 0; }\n.hb-oa2-group[data-error=\"true\"] { border-color: color-mix(in srgb, var(--hb-oa2-error) 70%, transparent); background: color-mix(in srgb, var(--hb-oa2-error) 7%, transparent); animation: hb-oa2-nudge 0.42s cubic-bezier(0.3, 0.7, 0.4, 1); }\n.hb-oa2-legend { float: left; width: 100%; margin: 0 0 8px; padding: 0; }\n.hb-oa2-ghead { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }\n.hb-oa2-gtitle { display: block; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }\n.hb-oa2-grule { display: block; margin-top: 2px; color: var(--hb-oa2-muted); font-size: 12px; }\n.hb-oa2-group[data-error=\"true\"] .hb-oa2-grule { color: var(--hb-oa2-error); }\n.hb-oa2-pill { flex: none; display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; background: var(--hb-oa2-line); color: var(--hb-oa2-muted); font-size: 11px; font-weight: 600; }\n.hb-oa2-pill[data-tone=\"required\"] { background: color-mix(in srgb, var(--hb-oa2-accent) 16%, transparent); color: var(--hb-oa2-accent); }\n.hb-oa2-pill[data-tone=\"error\"] { background: color-mix(in srgb, var(--hb-oa2-error) 16%, transparent); color: var(--hb-oa2-error); }\n.hb-oa2-pill[data-tone=\"done\"] { background: color-mix(in srgb, var(--hb-oa2-ok) 14%, transparent); color: var(--hb-oa2-ok); }\n.hb-oa2-opts { clear: both; display: grid; gap: 2px; }\n.hb-oa2-opt { position: relative; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 10px; border-radius: 12px; cursor: pointer; transition: background 0.2s ease; }\n.hb-oa2-opt:hover { background: var(--hb-oa2-line); }\n.hb-oa2-opt[data-disabled=\"true\"] { cursor: not-allowed; opacity: 0.42; }\n.hb-oa2-opt[data-disabled=\"true\"]:hover { background: transparent; }\n.hb-oa2-input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }\n.hb-oa2-mark { flex: none; display: grid; place-items: center; width: 20px; height: 20px; border: 1.5px solid var(--hb-oa2-line-strong); border-radius: 6px; color: transparent; transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s cubic-bezier(0.3, 1.6, 0.5, 1); }\n.hb-oa2-mark[data-shape=\"radio\"] { border-radius: 50%; }\n.hb-oa2-mark[data-shape=\"radio\"]::after { content: \"\"; width: 8px; height: 8px; border-radius: 50%; background: #fff; transform: scale(0); transition: transform 0.22s cubic-bezier(0.3, 1.6, 0.5, 1); }\n.hb-oa2-input:checked + .hb-oa2-mark { background: var(--hb-oa2-accent); border-color: var(--hb-oa2-accent); color: #fff; transform: scale(1.06); }\n.hb-oa2-input:checked + .hb-oa2-mark[data-shape=\"radio\"]::after { transform: scale(1); }\n.hb-oa2-input:checked + .hb-oa2-mark[data-shape=\"remove\"] { background: var(--hb-oa2-error); border-color: var(--hb-oa2-error); }\n.hb-oa2-input:focus-visible + .hb-oa2-mark { outline: 2px solid var(--hb-oa2-accent); outline-offset: 2px; }\n.hb-oa2-otext { flex: 1 1 auto; min-width: 0; }\n.hb-oa2-olabel { display: block; font-size: 13.5px; line-height: 1.3; transition: color 0.2s ease; }\n.hb-oa2-ohint { display: block; margin-top: 1px; color: var(--hb-oa2-muted); font-size: 11.5px; }\n.hb-oa2-input:checked ~ .hb-oa2-otext .hb-oa2-olabel[data-strike=\"true\"] { color: var(--hb-oa2-muted); text-decoration: line-through; text-decoration-color: var(--hb-oa2-error); }\n.hb-oa2-oprice { flex: none; color: var(--hb-oa2-muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }\n.hb-oa2-input:checked ~ .hb-oa2-oprice { color: var(--hb-oa2-text); }\n.hb-oa2-note { display: block; margin: 4px 0 8px; }\n.hb-oa2-nhead { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 14px; font-weight: 600; }\n.hb-oa2-ncount { color: var(--hb-oa2-muted); font-size: 11.5px; font-weight: 500; font-variant-numeric: tabular-nums; }\n.hb-oa2-textarea { display: block; width: 100%; min-height: 72px; padding: 10px 12px; border: 1px solid var(--hb-oa2-line-strong); border-radius: 12px; background: var(--hb-oa2-raise); color: var(--hb-oa2-text); font: inherit; font-size: 16px; line-height: 1.45; resize: vertical; transition: border-color 0.2s ease, box-shadow 0.2s ease; }\n.hb-oa2-textarea::placeholder { color: var(--hb-oa2-muted); }\n.hb-oa2-textarea:focus { outline: none; border-color: var(--hb-oa2-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--hb-oa2-accent) 22%, transparent); }\n.hb-oa2-foot { flex: none; display: flex; align-items: center; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--hb-oa2-line); background: color-mix(in srgb, var(--hb-oa2-panel) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }\n.hb-oa2-inline .hb-oa2-foot { padding-bottom: 10px; }\n.hb-oa2-step { flex: none; display: inline-flex; align-items: center; height: 42px; padding: 3px; border: 1px solid var(--hb-oa2-line-strong); border-radius: 999px; }\n.hb-oa2-step button { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--hb-oa2-text); cursor: pointer; transition: background 0.2s ease; }\n.hb-oa2-step button:hover:not(:disabled) { background: var(--hb-oa2-line); }\n.hb-oa2-step button:disabled { opacity: 0.35; cursor: not-allowed; }\n.hb-oa2-qty { min-width: 22px; text-align: center; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }\n.hb-oa2-cta { position: relative; flex: 1 1 auto; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 44px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--hb-oa2-accent); color: #fff; font: inherit; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; cursor: pointer; transition: filter 0.2s ease, transform 0.15s ease, opacity 0.2s ease; }\n.hb-oa2-cta:hover { filter: brightness(1.08); }\n.hb-oa2-cta:active { transform: scale(0.98); }\n.hb-oa2-cta[aria-disabled=\"true\"] { opacity: 0.55; }\n.hb-oa2-cta[data-added=\"true\"] { background: var(--hb-oa2-ok); }\n.hb-oa2-total { display: inline-block; font-variant-numeric: tabular-nums; animation: hb-oa2-tick 0.35s cubic-bezier(0.2, 0.8, 0.2, 1); }\n.hb-oa2-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n@keyframes hb-oa2-fade { from { opacity: 0; } }\n@keyframes hb-oa2-up { from { transform: translateY(100%); } }\n@keyframes hb-oa2-side { from { transform: translateX(100%); } }\n@keyframes hb-oa2-tick { from { opacity: 0; transform: translateY(6px); } }\n@keyframes hb-oa2-nudge { 20% { transform: translateX(-5px); } 45% { transform: translateX(4px); } 70% { transform: translateX(-2px); } }\n@container hb-oa2-shell (min-width: 720px) {\n  .hb-oa2-overlay { justify-content: flex-end; align-items: stretch; }\n  .hb-oa2-overlay .hb-oa2-panel { width: min(460px, 100%); height: 100dvh; max-height: none; border: 0; border-left: 1px solid var(--hb-oa2-line); border-radius: 0; box-shadow: -24px 0 60px -20px rgba(0, 0, 0, 0.6); animation-name: hb-oa2-side; }\n  .hb-oa2-overlay .hb-oa2-grab { display: none; }\n  .hb-oa2-overlay .hb-oa2-body { padding: 20px 22px 10px; }\n  .hb-oa2-overlay .hb-oa2-hero { grid-template-columns: minmax(0, 1fr); padding-right: 0; }\n  .hb-oa2-overlay .hb-oa2-art { aspect-ratio: 16 / 9; }\n  .hb-oa2-overlay .hb-oa2-art svg { width: 52%; }\n  .hb-oa2-overlay .hb-oa2-name { font-size: 22px; }\n  .hb-oa2-overlay .hb-oa2-foot { padding: 14px 22px calc(14px + env(safe-area-inset-bottom, 0px)); }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-oa2-scrim, .hb-oa2-panel, .hb-oa2-total, .hb-oa2-group[data-error=\"true\"] { animation: none; }\n  .hb-oa2-overlay .hb-oa2-panel { animation: none; }\n  .hb-oa2-body { scroll-behavior: auto; }\n  .hb-oa2 * { transition: none; }\n}\n`;\n\nfunction BurgerArt({ uid }: { uid: string }) {\n  return (\n    <svg viewBox=\"0 0 120 96\" aria-hidden=\"true\">\n      <defs>\n        <linearGradient id={`${uid}-top`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n          <stop offset=\"0\" stopColor=\"#ffc06a\" />\n          <stop offset=\"1\" stopColor=\"#cc6f25\" />\n        </linearGradient>\n        <linearGradient id={`${uid}-meat`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n          <stop offset=\"0\" stopColor=\"#80421f\" />\n          <stop offset=\"1\" stopColor=\"#3b1a0a\" />\n        </linearGradient>\n      </defs>\n      <ellipse cx=\"60\" cy=\"86\" rx=\"44\" ry=\"5\" fill=\"rgba(0,0,0,0.3)\" />\n      <path d=\"M18 68 H102 a5 5 0 0 1 -4 8 C86 82 34 82 22 76 a5 5 0 0 1 -4 -8 Z\" fill=\"#c4692a\" />\n      <rect x=\"14\" y=\"54\" width=\"92\" height=\"15\" rx=\"7.5\" fill={`url(#${uid}-meat)`} />\n      <path d=\"M16 52 H104 L98 58 L92 66 L86 58 L74 63 L66 56 L54 64 L46 56 L34 62 L26 56 Z\" fill=\"#ffc53a\" />\n      <path d=\"M12 50 q7 -7 14 0 t14 0 t14 0 t14 0 t14 0 t14 0 t14 0 v4 H12 Z\" fill=\"#59c057\" />\n      <rect x=\"22\" y=\"43\" width=\"76\" height=\"6\" rx=\"3\" fill=\"#e5473a\" />\n      <path d=\"M14 45 C14 12 106 12 106 45 Z\" fill={`url(#${uid}-top)`} />\n      <path d=\"M28 32 C34 22 48 18 60 18\" stroke=\"rgba(255,255,255,0.35)\" strokeWidth=\"3.5\" strokeLinecap=\"round\" fill=\"none\" />\n      <g fill=\"#fff3d4\">\n        <ellipse cx=\"44\" cy=\"28\" rx=\"2.4\" ry=\"1.3\" transform=\"rotate(-18 44 28)\" />\n        <ellipse cx=\"58\" cy=\"24\" rx=\"2.4\" ry=\"1.3\" transform=\"rotate(8 58 24)\" />\n        <ellipse cx=\"72\" cy=\"26\" rx=\"2.4\" ry=\"1.3\" transform=\"rotate(-10 72 26)\" />\n        <ellipse cx=\"84\" cy=\"31\" rx=\"2.4\" ry=\"1.3\" transform=\"rotate(16 84 31)\" />\n        <ellipse cx=\"52\" cy=\"34\" rx=\"2.4\" ry=\"1.3\" transform=\"rotate(22 52 34)\" />\n        <ellipse cx=\"66\" cy=\"33\" rx=\"2.4\" ry=\"1.3\" transform=\"rotate(-4 66 33)\" />\n        <ellipse cx=\"78\" cy=\"38\" rx=\"2.4\" ry=\"1.3\" transform=\"rotate(12 78 38)\" />\n      </g>\n    </svg>\n  );\n}\n\nconst focusableSelector = 'button:not([disabled]), [href], input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex=\"-1\"])';\n\nfunction initialSelections(groups: OrderItemGroup[]) {\n  const out: Record<string, string[]> = {};\n  for (const g of groups) out[g.id] = g.defaultSelected ? [...g.defaultSelected] : [];\n  return out;\n}\n\nfunction minFor(group: OrderItemGroup) {\n  if (group.type === \"remove\") return 0;\n  if (group.type === \"single\") return group.required ? 1 : 0;\n  return group.min ?? (group.required ? 1 : 0);\n}\n\nfunction fill(template: string, values: Record<string, number>) {\n  return template.replace(/\\{(\\w+)\\}/g, (_, key: string) => String(values[key] ?? \"\"));\n}\n\nexport function OrderItemDrawer({\n  item = defaultItem,\n  groups = defaultGroups,\n  image,\n  open,\n  defaultOpen = false,\n  onOpenChange,\n  onAdd,\n  currency = \"USD\",\n  locale = \"en-US\",\n  labels: labelsProp,\n  accent = \"#ff6a3d\",\n  appearance = \"dark\",\n  inline = false,\n  defaultQuantity = 1,\n  maxQuantity = 20,\n  noteMaxLength = 140,\n  closeOnAdd = true,\n  className = \"\",\n  style,\n  ...rest\n}: OrderItemDrawerProps) {\n  const labels = { ...defaultLabels, ...labelsProp };\n  const uid = React.useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n  const overlayRef = React.useRef<HTMLDivElement>(null);\n  const panelRef = React.useRef<HTMLDivElement>(null);\n  const bodyRef = React.useRef<HTMLDivElement>(null);\n  const addedTimer = React.useRef(0);\n  const [innerOpen, setInnerOpen] = React.useState(defaultOpen);\n  const isOpen = inline ? true : open ?? innerOpen;\n  const [selections, setSelections] = React.useState(() => initialSelections(groups));\n  const [quantity, setQuantity] = React.useState(defaultQuantity);\n  const [note, setNote] = React.useState(\"\");\n  const [showErrors, setShowErrors] = React.useState(false);\n  const [added, setAdded] = React.useState(false);\n  const [announce, setAnnounce] = React.useState(\"\");\n  const [prev, setPrev] = React.useState({ open: isOpen, item: item.id });\n\n  if (prev.open !== isOpen || prev.item !== item.id) {\n    setPrev({ open: isOpen, item: item.id });\n    if (isOpen) {\n      setSelections(initialSelections(groups));\n      setQuantity(defaultQuantity);\n      setNote(\"\");\n      setShowErrors(false);\n      setAdded(false);\n    }\n  }\n\n  const money = React.useMemo(() => new Intl.NumberFormat(locale, { style: \"currency\", currency }), [locale, currency]);\n\n  const setOpen = React.useCallback(\n    (value: boolean) => {\n      if (open === undefined) setInnerOpen(value);\n      onOpenChange?.(value);\n    },\n    [open, onOpenChange],\n  );\n\n  const unitPrice = groups.reduce((sum, g) => {\n    if (g.type === \"remove\") return sum;\n    const picked = selections[g.id] ?? [];\n    return sum + g.options.reduce((s, o) => (picked.includes(o.id) ? s + (o.price ?? 0) : s), 0);\n  }, item.price);\n  const total = Math.round(unitPrice * quantity * 100) / 100;\n  const missing = groups.filter((g) => (selections[g.id]?.length ?? 0) < minFor(g));\n  const valid = missing.length === 0;\n\n  React.useEffect(() => () => window.clearTimeout(addedTimer.current), []);\n\n  React.useEffect(() => {\n    if (!isOpen || inline) return;\n    const overlay = overlayRef.current;\n    if (!overlay) return;\n    const opener = document.activeElement instanceof HTMLElement ? document.activeElement : null;\n    const html = document.documentElement;\n    const prevOverflow = html.style.overflow;\n    html.style.overflow = \"hidden\";\n    const inerted: HTMLElement[] = [];\n    let node: HTMLElement = overlay;\n    while (node.parentElement) {\n      const parent: HTMLElement = node.parentElement;\n      for (const sibling of Array.from(parent.children)) {\n        if (sibling === node || !(sibling instanceof HTMLElement)) continue;\n        if (sibling.inert || sibling.tagName === \"STYLE\" || sibling.tagName === \"SCRIPT\") continue;\n        sibling.inert = true;\n        inerted.push(sibling);\n      }\n      if (parent === document.body) break;\n      node = parent;\n    }\n    const target = panelRef.current?.querySelector<HTMLElement>(\"[data-hb-oa2-initial]\") ?? panelRef.current;\n    target?.focus({ preventScroll: true });\n    return () => {\n      html.style.overflow = prevOverflow;\n      inerted.forEach((el) => {\n        el.inert = false;\n      });\n      opener?.focus({ preventScroll: true });\n    };\n  }, [isOpen, inline]);\n\n  const onKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n    if (inline) return;\n    if (event.key === \"Escape\") {\n      event.stopPropagation();\n      setOpen(false);\n      return;\n    }\n    if (event.key !== \"Tab\" || !panelRef.current) return;\n    const nodes = Array.from(panelRef.current.querySelectorAll<HTMLElement>(focusableSelector)).filter((el) => el.offsetParent !== null || el === document.activeElement);\n    if (!nodes.length) return;\n    const first = nodes[0];\n    const last = nodes[nodes.length - 1];\n    if (event.shiftKey && (document.activeElement === first || document.activeElement === panelRef.current)) {\n      event.preventDefault();\n      last.focus();\n    } else if (!event.shiftKey && document.activeElement === last) {\n      event.preventDefault();\n      first.focus();\n    }\n  };\n\n  const toggle = (group: OrderItemGroup, optionId: string) => {\n    setSelections((current) => {\n      const picked = current[group.id] ?? [];\n      if (group.type === \"single\") return { ...current, [group.id]: [optionId] };\n      if (picked.includes(optionId)) return { ...current, [group.id]: picked.filter((id) => id !== optionId) };\n      if (group.type === \"multiple\" && group.max !== undefined && picked.length >= group.max) return current;\n      return { ...current, [group.id]: [...picked, optionId] };\n    });\n  };\n\n  const submit = () => {\n    if (!valid) {\n      setShowErrors(true);\n      const first = missing[0];\n      setAnnounce(`${labels.missing}: ${first.title}`);\n      const el = document.getElementById(`${uid}-g-${first.id}`);\n      const body = bodyRef.current;\n      if (el && body) {\n        const reduced = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n        body.scrollTo({ top: Math.max(0, el.offsetTop - 12), behavior: reduced ? \"auto\" : \"smooth\" });\n        el.querySelector<HTMLInputElement>(\"input:not([disabled])\")?.focus({ preventScroll: true });\n      }\n      return;\n    }\n    const payload: OrderItemAddPayload = {\n      itemId: item.id,\n      quantity,\n      selections: Object.fromEntries(groups.map((g) => [g.id, [...(selections[g.id] ?? [])]])),\n      note: note.trim(),\n      unitPrice: Math.round(unitPrice * 100) / 100,\n      total,\n    };\n    onAdd?.(payload);\n    setAnnounce(labels.added);\n    if (!inline && closeOnAdd) {\n      setOpen(false);\n      return;\n    }\n    setAdded(true);\n    window.clearTimeout(addedTimer.current);\n    addedTimer.current = window.setTimeout(() => setAdded(false), 1600);\n  };\n\n  const ruleFor = (g: OrderItemGroup) => {\n    if (g.type === \"remove\") return labels.removeHint;\n    if (g.type === \"single\") return labels.chooseOne;\n    const min = minFor(g);\n    if (g.max !== undefined && min > 0) return fill(labels.chooseBetween, { min, max: g.max });\n    if (g.max !== undefined) return fill(labels.chooseUpTo, { max: g.max });\n    if (min > 0) return fill(labels.chooseAtLeast, { min });\n    return labels.optional;\n  };\n\n  if (!isOpen) return null;\n\n  const vars = { \"--hb-oa2-accent\": accent, \"--hb-oa2-tint\": item.tint ?? accent, ...style } as React.CSSProperties;\n  const titleId = `${uid}-title`;\n\n  const panel = (\n    <div\n      ref={panelRef}\n      className=\"hb-oa2-panel\"\n      role={inline ? \"group\" : \"dialog\"}\n      aria-modal={inline ? undefined : true}\n      aria-labelledby={titleId}\n      tabIndex={-1}\n      onKeyDown={onKeyDown}\n    >\n      <div className=\"hb-oa2-grab\" aria-hidden=\"true\" />\n      {inline ? null : (\n        <button type=\"button\" className=\"hb-oa2-close\" aria-label={labels.close} onClick={() => setOpen(false)} data-hb-oa2-initial=\"\">\n          <svg width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" aria-hidden=\"true\">\n            <path d=\"M4 4l8 8M12 4l-8 8\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" />\n          </svg>\n        </button>\n      )}\n      <div className=\"hb-oa2-body\" ref={bodyRef}>\n        <div className=\"hb-oa2-hero\">\n          <div className=\"hb-oa2-art\">{image ?? <BurgerArt uid={uid} />}</div>\n          <div>\n            {item.badge ? <span className=\"hb-oa2-badge\">{item.badge}</span> : null}\n            <h2 className=\"hb-oa2-name\" id={titleId}>{item.name}</h2>\n            <p className=\"hb-oa2-desc\">{item.description}</p>\n            <div className=\"hb-oa2-base\">{money.format(item.price)}</div>\n          </div>\n        </div>\n        {groups.map((g) => {\n          const picked = selections[g.id] ?? [];\n          const min = minFor(g);\n          const satisfied = picked.length >= min;\n          const error = showErrors && !satisfied;\n          const atMax = g.type === \"multiple\" && g.max !== undefined && picked.length >= g.max;\n          const tone = error ? \"error\" : min > 0 ? (satisfied ? \"done\" : \"required\") : \"optional\";\n          const ruleId = `${uid}-r-${g.id}`;\n          return (\n            <fieldset\n              key={g.id}\n              id={`${uid}-g-${g.id}`}\n              className=\"hb-oa2-group\"\n              data-error={error}\n              aria-describedby={ruleId}\n              aria-invalid={error || undefined}\n            >\n              <legend className=\"hb-oa2-legend\">\n                <span className=\"hb-oa2-ghead\">\n                  <span>\n                    <span className=\"hb-oa2-gtitle\">{g.title}</span>\n                    <span className=\"hb-oa2-grule\" id={ruleId}>{error ? labels.missing : ruleFor(g)}</span>\n                  </span>\n                  <span className=\"hb-oa2-pill\" data-tone={tone}>\n                    {tone === \"done\" ? (\n                      <svg width=\"10\" height=\"10\" viewBox=\"0 0 12 12\" aria-hidden=\"true\">\n                        <path d=\"M2.5 6.5l2.2 2.2 4.8-5\" stroke=\"currentColor\" strokeWidth=\"1.8\" fill=\"none\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n                      </svg>\n                    ) : null}\n                    {tone === \"done\" ? labels.done : tone === \"optional\" ? labels.optional : labels.required}\n                  </span>\n                </span>\n              </legend>\n              <div className=\"hb-oa2-opts\">\n                {g.options.map((o) => {\n                  const checked = picked.includes(o.id);\n                  const disabled = !checked && atMax;\n                  const shape = g.type === \"single\" ? \"radio\" : g.type === \"remove\" ? \"remove\" : \"check\";\n                  return (\n                    <label key={o.id} className=\"hb-oa2-opt\" data-disabled={disabled}>\n                      <input\n                        className=\"hb-oa2-input\"\n                        type={g.type === \"single\" ? \"radio\" : \"checkbox\"}\n                        name={`${uid}-${g.id}`}\n                        value={o.id}\n                        checked={checked}\n                        disabled={disabled}\n                        onChange={() => toggle(g, o.id)}\n                      />\n                      <span className=\"hb-oa2-mark\" data-shape={shape} aria-hidden=\"true\">\n                        {shape === \"check\" ? (\n                          <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\">\n                            <path d=\"M2.5 6.5l2.2 2.2 4.8-5\" stroke=\"currentColor\" strokeWidth=\"1.8\" fill=\"none\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n                          </svg>\n                        ) : shape === \"remove\" ? (\n                          <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\">\n                            <path d=\"M3 6h6\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" />\n                          </svg>\n                        ) : null}\n                      </span>\n                      <span className=\"hb-oa2-otext\">\n                        <span className=\"hb-oa2-olabel\" data-strike={g.type === \"remove\"}>{o.label}</span>\n                        {o.hint ? <span className=\"hb-oa2-ohint\">{o.hint}</span> : null}\n                      </span>\n                      {o.price ? <span className=\"hb-oa2-oprice\">+{money.format(o.price)}</span> : null}\n                    </label>\n                  );\n                })}\n              </div>\n            </fieldset>\n          );\n        })}\n        <label className=\"hb-oa2-note\">\n          <span className=\"hb-oa2-nhead\">\n            {labels.note}\n            <span className=\"hb-oa2-ncount\">{note.length}/{noteMaxLength}</span>\n          </span>\n          <textarea\n            className=\"hb-oa2-textarea\"\n            value={note}\n            maxLength={noteMaxLength}\n            placeholder={labels.notePlaceholder}\n            onChange={(e) => setNote(e.target.value)}\n            rows={2}\n          />\n        </label>\n      </div>\n      <div className=\"hb-oa2-foot\">\n        <div className=\"hb-oa2-step\" role=\"group\" aria-label={labels.quantity}>\n          <button type=\"button\" aria-label={labels.decrease} disabled={quantity <= 1} onClick={() => setQuantity((q) => Math.max(1, q - 1))}>\n            <svg width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" aria-hidden=\"true\">\n              <path d=\"M3 8h10\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" />\n            </svg>\n          </button>\n          <span className=\"hb-oa2-qty\" aria-live=\"polite\">{quantity}</span>\n          <button type=\"button\" aria-label={labels.increase} disabled={quantity >= maxQuantity} onClick={() => setQuantity((q) => Math.min(maxQuantity, q + 1))}>\n            <svg width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" aria-hidden=\"true\">\n              <path d=\"M8 3v10M3 8h10\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" />\n            </svg>\n          </button>\n        </div>\n        <button type=\"button\" className=\"hb-oa2-cta\" aria-disabled={!valid} data-added={added} onClick={submit}>\n          {added ? (\n            labels.added\n          ) : (\n            <>\n              {labels.add} ·{\" \"}\n              <span key={total} className=\"hb-oa2-total\">{money.format(total)}</span>\n            </>\n          )}\n        </button>\n      </div>\n      <span className=\"hb-oa2-sr\" role=\"status\" aria-live=\"polite\">{announce}</span>\n    </div>\n  );\n\n  if (inline) {\n    return (\n      <div className={`hb-oa2 hb-oa2-inline ${className}`} style={vars} data-appearance={appearance} {...rest}>\n        <style href=\"hb-order-item-drawer\" precedence=\"default\">{css}</style>\n        {panel}\n      </div>\n    );\n  }\n\n  return (\n    <div ref={overlayRef} className={`hb-oa2 hb-oa2-overlay ${className}`} style={vars} data-appearance={appearance} {...rest}>\n      <style href=\"hb-order-item-drawer\" precedence=\"default\">{css}</style>\n      <div className=\"hb-oa2-scrim\" aria-hidden=\"true\" onClick={() => setOpen(false)} />\n      {panel}\n    </div>\n  );\n}\n"
    }
  ]
}