```
/** Total the base parts an order of a kit consumes. */
export function explodeKit(catalog: Record<string, { makes: number; parts: [string, number][] }>, kit: string, want: number): Record<string, number> {
  if (!Object.prototype.hasOwnProperty.call(catalog, kit)) {
    throw new Error(`the catalog does not define ${kit}`);
  }
  const totals: Record<string, number> = {};
  function explode(kit: string, want: number): void {
    if (want <= 0) return;
    const recipe = catalog[kit];
    const need = Math.ceil(want / recipe.makes);
    for (const [part, count] of recipe.parts) {
      totals[part] = (totals[part] || 0) + need * count;
      if (catalog.hasOwnProperty(part)) {
        explode(part, need * count);
      }
    }
  }
  explode(kit, want);
  return totals;
}
```