export type StickerCategory = "motivation" | "nature" | "cute" | "productivity" | "decor" | "seasonal";

export interface Sticker {
  id: string;
  emoji: string;
  label: string;
  category: StickerCategory;
  origin: "builtin";
  price: number; // cents — 0 for every built-in sticker today
}

export const STICKER_CATEGORIES: StickerCategory[] = [
  "motivation",
  "productivity",
  "nature",
  "cute",
  "decor",
  "seasonal",
];

export const STICKER_CATEGORY_LABELS: Record<StickerCategory, string> = {
  motivation: "Motivation",
  productivity: "Productivity",
  nature: "Nature",
  cute: "Cute",
  decor: "Decor",
  seasonal: "Seasonal",
};

// First `freeCount` entries in a pack stay free; the rest cost 49 cents each.
// Motivation is kept entirely free as the baseline "essentials" pack, same
// idea as the 3 free note covers — a usable set before anyone has to pay.
function pack(category: StickerCategory, entries: [string, string][], freeCount = 1): Sticker[] {
  return entries.map(([emoji, label], index) => ({
    id: `${category}-${label.toLowerCase().replace(/[^a-z0-9]+/g, "-")}`,
    emoji,
    label,
    category,
    origin: "builtin",
    price: index < freeCount ? 0 : 49,
  }));
}

export const STICKERS: Sticker[] = [
  ...pack(
    "motivation",
    [
      ["⭐", "Star"],
      ["🔥", "Fire"],
      ["🚀", "Rocket"],
      ["💪", "Strong"],
      ["🏆", "Trophy"],
      ["✨", "Sparkle"],
      ["🎯", "Target"],
      ["⚡", "Lightning"],
    ],
    8
  ),
  ...pack("productivity", [
    ["✅", "Done"],
    ["📌", "Pin"],
    ["⏰", "Alarm"],
    ["💡", "Idea"],
    ["📎", "Clip"],
    ["🗂️", "Folder"],
    ["🔑", "Key"],
    ["📈", "Growth"],
  ]),
  ...pack("nature", [
    ["🌿", "Leaf"],
    ["🌸", "Blossom"],
    ["🌊", "Wave"],
    ["🌙", "Moon"],
    ["☀️", "Sun"],
    ["🍄", "Mushroom"],
    ["🦋", "Butterfly"],
    ["🌈", "Rainbow"],
  ]),
  ...pack("cute", [
    ["🐱", "Cat"],
    ["🐶", "Dog"],
    ["🐻", "Bear"],
    ["🐰", "Bunny"],
    ["🦊", "Fox"],
    ["🐼", "Panda"],
    ["🐨", "Koala"],
    ["🐧", "Penguin"],
  ]),
  ...pack("decor", [
    ["💛", "Heart"],
    ["🎀", "Ribbon"],
    ["🏷️", "Tag"],
    ["📍", "Marker"],
    ["🖇️", "Paperclip"],
    ["🔖", "Bookmark"],
    ["💫", "Swirl"],
    ["🪄", "Wand"],
  ]),
  ...pack("seasonal", [
    ["🎄", "Tree"],
    ["🎃", "Pumpkin"],
    ["🌷", "Tulip"],
    ["☕", "Coffee"],
    ["🍂", "Autumn"],
    ["❄️", "Snowflake"],
    ["🎉", "Party"],
    ["🎈", "Balloon"],
  ]),
];

export const DEFAULT_STICKER_ID = STICKERS[0].id;

export function getSticker(stickerId: string | null | undefined): Sticker {
  return STICKERS.find((sticker) => sticker.id === stickerId) ?? STICKERS[0];
}
