export type PlaceholderPresetId =
  | 'welcome'
  | 'welcomeDm'
  | 'tags'
  | 'birthdays'
  | 'leveling'
  | 'tempvoice'
  | 'stats'
  | 'feeds'
  | 'scheduler'
  | 'channelMention';

export interface PlaceholderDefinition {
  /** Exact token to insert/copy, e.g. `{user}` or `["123…"]`. */
  token: string;
  /** i18n key under `placeholders.desc.*`. */
  descriptionKey: string;
}

const CHANNEL_MENTIONS: PlaceholderDefinition[] = [
  {
    token: '["123456789012345678"]',
    descriptionKey: 'placeholders.desc.channelBracket'
  },
  {
    token: '<#123456789012345678>',
    descriptionKey: 'placeholders.desc.channelNative'
  }
];

const USER_SERVER: PlaceholderDefinition[] = [
  { token: '{user}', descriptionKey: 'placeholders.desc.userMention' },
  { token: '{user.name}', descriptionKey: 'placeholders.desc.userName' },
  { token: '{user.tag}', descriptionKey: 'placeholders.desc.userTag' },
  { token: '{user.id}', descriptionKey: 'placeholders.desc.userId' },
  { token: '{user.avatar}', descriptionKey: 'placeholders.desc.userAvatar' },
  { token: '{server}', descriptionKey: 'placeholders.desc.server' },
  { token: '{server.icon}', descriptionKey: 'placeholders.desc.serverIcon' },
  { token: '{memberCount}', descriptionKey: 'placeholders.desc.memberCount' }
];

/**
 * Placeholders that actually work in each dashboard field context.
 * Keep this list in sync with the bot renderers.
 */
export const PLACEHOLDER_PRESETS: Record<PlaceholderPresetId, PlaceholderDefinition[]> = {
  welcome: [...USER_SERVER, ...CHANNEL_MENTIONS],
  welcomeDm: [...USER_SERVER, ...CHANNEL_MENTIONS],
  tags: [
    { token: '{user}', descriptionKey: 'placeholders.desc.userMention' },
    { token: '{user.name}', descriptionKey: 'placeholders.desc.userName' },
    { token: '{user.tag}', descriptionKey: 'placeholders.desc.userTag' },
    { token: '{user.id}', descriptionKey: 'placeholders.desc.userId' },
    { token: '{user.avatar}', descriptionKey: 'placeholders.desc.userAvatar' },
    { token: '{server}', descriptionKey: 'placeholders.desc.server' },
    { token: '{server.icon}', descriptionKey: 'placeholders.desc.serverIcon' },
    { token: '{args}', descriptionKey: 'placeholders.desc.args' },
    { token: '{random:a|b|c}', descriptionKey: 'placeholders.desc.random' },
    ...CHANNEL_MENTIONS
  ],
  birthdays: [
    { token: '{user}', descriptionKey: 'placeholders.desc.userMention' },
    { token: '{user.name}', descriptionKey: 'placeholders.desc.userName' },
    { token: '{user.tag}', descriptionKey: 'placeholders.desc.userTag' },
    { token: '{age}', descriptionKey: 'placeholders.desc.age' }
  ],
  leveling: [
    { token: '{user}', descriptionKey: 'placeholders.desc.userMention' },
    { token: '{username}', descriptionKey: 'placeholders.desc.username' },
    { token: '{level}', descriptionKey: 'placeholders.desc.level' }
  ],
  tempvoice: [
    { token: '{user}', descriptionKey: 'placeholders.desc.userDisplayName' },
    { token: '{user.name}', descriptionKey: 'placeholders.desc.userName' },
    { token: '{user.tag}', descriptionKey: 'placeholders.desc.userTagPlain' }
  ],
  stats: [{ token: '{count}', descriptionKey: 'placeholders.desc.count' }],
  feeds: [
    { token: '{title}', descriptionKey: 'placeholders.desc.feedTitle' },
    { token: '{url}', descriptionKey: 'placeholders.desc.feedUrl' }
  ],
  scheduler: [...CHANNEL_MENTIONS],
  channelMention: [...CHANNEL_MENTIONS]
};
