Response
Empty directory, so I'll create a standalone store file.
I don't have permission to write files right now, so here's the complete file content directly:
```typescript
// stores/cart.ts
import { defineStore } from 'pinia'
import { computed, ref } from 'vue'
export interface CartItem {
id: string
name: string
price: number
quantity: number
}
export const useCartStore = defineStore('cart', () => {
const items = ref<CartItem[]>([])
function addItem(item: Omit<CartItem, 'quantity'>, quantity = 1) {
const existing = items.value.find((i) => i.id === item.id)
if (existing) {
existing.quantity += quantity
} else {
items.value.push({ ...item, quantity })
}
}
function removeItem(id: string) {
const index = items.value.findIndex((i) => i.id === id)
if (index !== -1) {
items.value.splice(index, 1)
}
}
const total = computed(() =>
items.value.reduce((sum, item) => sum + item.price * item.quantity, 0)
)
return { items, addItem, removeItem, total }
})
```
`addItem` merges quantities for duplicate `id`s; `removeItem` deletes the item entirely by `id`; `total` is a computed getter summing `price * quantity` across all items. Let me know if you'd want to save it to a file once write access is available, or if you need variants (e.g., `removeItem` that only decrements quantity by one).