import { NoPriceForCurrencyError } from './errors.js'
import type { Variant, VariantPrice } from './types.js'

export function resolvePrice(variant: Variant, currency: string): VariantPrice {
  const price = variant.prices.find((p) => p.currency === currency)
  if (!price) throw new NoPriceForCurrencyError(currency)
  return price
}
