// ── Primitives ────────────────────────────────────────────────────────────────

export type Currency = 'USD' | 'EUR' | 'GBP' | 'SEK'

export interface Price {
  amount: number
  currency: Currency
  asOf: string   // ISO date — prices are a point-in-time snapshot
}

// ── Categories ────────────────────────────────────────────────────────────────

export type Category =
  | 'frame'
  | 'flight-controller'
  | 'esc'
  | 'motor'
  | 'camera'
  | 'vtx'
  | 'props'
  | 'battery'
  | 'charger'
  | 'radio'
  | 'receiver'
  | 'goggles'
  | 'complete-drone'
  | 'accessory'

// ── Products ──────────────────────────────────────────────────────────────────

export interface Product {
  id: string
  name: string
  brand?: string
  category: Category
  price: Price
  url?: string
  image?: string       // base64 data URI
  note?: string
}

// ── Drone builds ──────────────────────────────────────────────────────────────

export interface CompleteDrone {
  id: string
  buildType: 'complete'
  name: string
  brand?: string
  price: Price
  url?: string
  image?: string
  note?: string
}

export interface KitBuild {
  id: string
  buildType: 'kit'
  name: string
  url?: string         // build guide
  image?: string
  note?: string
  parts: Product[]     // total price is derived
}

export type Drone = CompleteDrone | KitBuild

// ── Sections ──────────────────────────────────────────────────────────────────
// Shared by both templates and carts.

export interface Section {
  id: string
  label: string
  required: boolean
  description?: string
  items: (Product | Drone)[]
}

// ── Curated catalog (fetched from /curated.json) ──────────────────────────────

export interface CuratedCatalog {
  version: string
  updatedAt: string
  templates: CartTemplate[]
}

export interface CartTemplate {
  id: string
  name: string
  description?: string
  currency: Currency
  sections: Section[]
}

// ── User carts (stored in localStorage) ──────────────────────────────────────

export interface Cart {
  id: string
  name: string
  createdAt: string
  templateId?: string  // which template it was seeded from
  sections: Section[]
}
