export const DEFAULT_TAG_EMOJI = '📍'

const TAG_EMOJI: Record<string, string> = {
  // food
  pizza: '🍕',
  taco: '🌮',
  ramen: '🍜',
  noodle: '🍜',
  sushi: '🍣',
  burger: '🍔',
  burrito: '🌯',
  salad: '🥗',
  bento: '🍱',
  waffle: '🧇',
  pancake: '🥞',
  bakery: '🥐',
  bread: '🥖',
  pastry: '🥐',
  dessert: '🍰',
  cake: '🍰',
  'ice-cream': '🍦',
  gelato: '🍦',
  donut: '🍩',
  bbq: '🍖',
  steak: '🥩',
  seafood: '🦞',
  fish: '🐟',
  chicken: '🍗',
  breakfast: '🍳',
  brunch: '🍳',
  lunch: '🍽️',
  dinner: '🍽️',
  restaurant: '🍽️',
  food: '🍽️',
  street: '🥡',
  vegan: '🌱',
  vegetarian: '🌱',
  // drink
  coffee: '☕',
  cafe: '☕',
  espresso: '☕',
  boba: '🧋',
  tea: '🍵',
  matcha: '🍵',
  beer: '🍺',
  brewery: '🍺',
  pub: '🍺',
  cocktail: '🍹',
  bar: '🍸',
  martini: '🍸',
  wine: '🍷',
  winery: '🍷',
  juice: '🥤',
  smoothie: '🥤',
  // outdoors
  beach: '🏖️',
  hike: '🏔️',
  hiking: '🏔️',
  mountain: '🏔️',
  trail: '🥾',
  park: '🌳',
  garden: '🌷',
  forest: '🌲',
  camping: '🏕️',
  lake: '🏞️',
  river: '🏞️',
  sunset: '🌅',
  viewpoint: '🌄',
  view: '🌄',
  // city & culture
  city: '🏙️',
  bridge: '🌉',
  museum: '🖼️',
  gallery: '🖼️',
  art: '🎨',
  theatre: '🎭',
  theater: '🎭',
  cinema: '🎬',
  movie: '🎬',
  music: '🎵',
  concert: '🎤',
  gig: '🎤',
  festival: '🎪',
  club: '🪩',
  library: '📚',
  book: '📚',
  bookstore: '📚',
  arcade: '🎮',
  games: '🎮',
  temple: '⛩️',
  shrine: '⛩️',
  church: '⛪',
  castle: '🏰',
  monument: '🗿',
  landmark: '🗿',
  // activity
  shopping: '🛍️',
  market: '🛍️',
  thrift: '🛍️',
  vintage: '🛍️',
  barber: '💈',
  spa: '🧖',
  gym: '🏋️',
  yoga: '🧘',
  climbing: '🧗',
  cycling: '🚴',
  bike: '🚴',
  swim: '🏊',
  swimming: '🏊',
  surf: '🏄',
  ski: '⛷️',
  skate: '🛹',
  golf: '⛳',
  // travel & stay
  hotel: '🏨',
  hostel: '🛏️',
  airbnb: '🏠',
  airport: '✈️',
  train: '🚆',
  ferry: '⛴️',
  // misc
  dog: '🐶',
  cat: '🐱',
  zoo: '🦁',
  aquarium: '🐠',
  flower: '🌸',
  picnic: '🧺',
  date: '❤️',
  kids: '🧒',
  family: '🧒',
  free: '🆓',
  cheap: '💸',
  fancy: '✨',
}

const singulars = (word: string): string[] => {
  const out = [word]
  if (word.endsWith('es')) out.push(word.slice(0, -2))
  if (word.endsWith('s')) out.push(word.slice(0, -1))
  return out
}

const lookup = (word: string): string | undefined => {
  for (const candidate of singulars(word)) {
    const emoji = TAG_EMOJI[candidate]
    if (emoji) return emoji
  }
  return undefined
}

export const pickTagEmoji = (name: string): string => {
  const slug = name.trim().toLowerCase()
  const exact = lookup(slug)
  if (exact) return exact
  for (const part of slug.split('-')) {
    const emoji = lookup(part)
    if (emoji) return emoji
  }
  return DEFAULT_TAG_EMOJI
}
