/**
 * i18n Type Definitions & Interfaces for Kord Bot.
 *
 * Designed with provider interface pattern for future infrastructure swap
 * (e.g. from static TS files to DB-backed or API-based translation service).
 */

// ── Supported Locales ──────────────────────────────────────

export type SupportedLocale = 'en' | 'ko';

export const SUPPORTED_LOCALES: readonly SupportedLocale[] = ['en', 'ko'] as const;
export const DEFAULT_LOCALE: SupportedLocale = 'en';

// ── Translation Structure ──────────────────────────────────

/** Error message translation shape */
export interface ErrorMessageTranslation {
  userMessage: string;
  resolution?: string;
}

/** Translation key structure — all user-facing strings */
export interface TranslationSchema {
  // ── Error Messages ──
  errors: Record<string, ErrorMessageTranslation>;

  // ── Error Category Titles ──
  errorTitles: {
    USER_INPUT: string;
    PERMISSION: string;
    BOT_INTERNAL: string;
    DISCORD_API: string;
  };

  // ── Error Embed Field Labels ──
  errorFields: {
    resolution: string;
  };

  // ── Voice Channel ──
  voice: {
    channelReady: string;
    defaultRoomName: string;
    controlPanel: {
      placeholder: string;
      rename: string;
      limit: string;
      lock: string;
      kick: string;
      ban: string;
      transfer: string;
    };
    responses: {
      channelLocked: string;
      channelUnlocked: string;
      channelRenamed: string;
      limitSet: string;
      limitUnlimited: string;
      kicked: string;
      banned: string;
      transferPrompt: string;
      transferDone: string;
      banPrompt: string;
    };
  };

  // ── Commands ──
  commands: {
    voiceSetup: {
      description: string;
      setDescription: string;
      createDescription: string;
      channelOptionDescription: string;
      categoryOptionDescription: string;
      nameOptionDescription: string;
      setSuccess: string;
      createSuccess: string;
    };
    voiceConfig: {
      description: string;
      setNameTitle: string;
      setNameDesc: string;
      setLimitTitle: string;
      setLimitDesc: string;
      statusTitle: string;
      templateLabel: string;
      limitLabel: string;
      setSuccess: string;
      limitValue: string;
    };
    language: {
      description: string;
      scopeDescription: string;
      localeDescription: string;
      scopeUser: string;
      scopeServer: string;
      userSet: string;
      serverSet: string;
      serverPermissionDenied: string;
    };
    event: {
      description: string;
      createDescription: string;
      listDescription: string;
      cancelDescription: string;
      announceDescription: string;
      titleDescription: string;
      dateDescription: string;
      timeDescription: string;
      descriptionOptionDescription: string;
      channelDescription: string;
      reminderDescription: string;
      remindersDescription: string;
      idDescription: string;
      createSuccessTitle: string;
      createSuccessBody: string;
      listTitle: string;
      listEmpty: string;
      listItemValue: string;
      cancelSuccess: string;
      cancelNotFound: string;
      announceSuccess: string;
      announceNotAvailable: string;
      startAnnouncementTitle: string;
      startAnnouncementLead: string;
      invalidDateTime: string;
      invalidDateTimeResolution: string;
      invalidReminderOffsets: string;
      invalidReminderOffsetsResolution: string;
      invalidPastDateTime: string;
      invalidPastDateTimeResolution: string;
      statusScheduled: string;
      statusCancelled: string;
      statusCompleted: string;
      reminderOn: string;
      reminderOff: string;
      reminderNone: string;
      announcementChannelNone: string;
      fields: {
        eventId: string;
        startsAt: string;
        reminder: string;
        announcementChannel: string;
        status: string;
      };
    };
    autorole: {
      description: string;
      statusTitle: string;
      userRoleLabel: string;
      botRoleLabel: string;
      statusLabel: string;
      botStatusLabel: string;
      userRolePlaceholder: string;
      botRolePlaceholder: string;
      toggleUserEnable: string;
      toggleUserDisable: string;
      toggleBotEnable: string;
      toggleBotDisable: string;
      notSet: string;
      enabled: string;
      disabled: string;
      updateSuccess: string;
      permissionsError: string;
      suspendNotice: string;
    };
    music: {
      description: string;
      addDescription: string;
      queueDescription: string;
      removeDescription: string;
      pauseDescription: string;
      resumeDescription: string;
      skipDescription: string;
      stopDescription: string;
      leaveDescription: string;
      queryDescription: string;
      urlDescription: string;
      indexDescription: string;
      addMutuallyExclusive: string;
      addMutuallyExclusiveResolution: string;
      notInVoice: string;
      notInVoiceResolution: string;
      differentVoiceChannel: string;
      differentVoiceChannelResolution: string;
      noSearchResults: string;
      noSearchResultsResolution: string;
      invalidUrl: string;
      invalidUrlResolution: string;
      noActiveSession: string;
      noActiveSessionResolution: string;
      queueAddedNowPlaying: string;
      queueAddedLater: string;
      playlistAddedNowPlaying: string;
      playlistAddedLater: string;
      queueTitle: string;
      queueEmpty: string;
      queueNowPlaying: string;
      queueUpcoming: string;
      queueMoreItems: string;
      queueRemoved: string;
      queueRemoveOutOfRange: string;
      queueRemoveOutOfRangeResolution: string;
      pauseSuccess: string;
      resumeSuccess: string;
      skipSuccess: string;
      leaveSuccess: string;
      stopSuccess: string;
      playbackStartedTitle: string;
      playbackIdleTitle: string;
      playbackIdleBody: string;
      playbackFailed: string;
      playbackFailedResolution: string;
      streamUnavailable: string;
      streamUnavailableResolution: string;
      requestedBy: string;
      duration: string;
      progress: string;
      source: string;
      status: string;
      queueLength: string;
      nextTrack: string;
      statusPlaying: string;
      statusPaused: string;
      unknownDuration: string;
      buttons: {
        pause: string;
        resume: string;
        skip: string;
        stop: string;
        leave: string;
      };
    };
    fishing: {
      description: string;
      enterDescription: string;
      castDescription: string;
      endDescription: string;
      statusDescription: string;
      dexDescription: string;
      rankingDescription: string;
      disabled: string;
      restrictedChannel: string;
      enterTextChannelOnly: string;
      enterExistingThread: string;
      enterCreated: string;
      castThreadOnly: string;
      startExistingSession: string;
      startCreated: string;
      noActiveSession: string;
      ownerOnly: string;
      wrongThread: string;
      endDeleted: string;
      profileTitle: string;
      profileEmpty: string;
      dexTitle: string;
      dexEmpty: string;
      rankingTitle: string;
      rankingEmpty: string;
      titleActive: string;
      titleEnded: string;
      status: string;
      rarity: string;
      size: string;
      catchCount: string;
      bestRarity: string;
      bestSize: string;
      targetFish: string;
      distance: string;
      tension: string;
      reward: string;
      successRate: string;
      totalCasts: string;
      totalGoldEarned: string;
      bestCatchReward: string;
      rarityBreakdown: string;
      lastCastAt: string;
      noRecord: string;
      threadHint: string;
      catchResultTitle: string;
      catchResultBody: string;
      states: {
        hooked: string;
        resting: string;
        tense: string;
        missed: string;
        success: string;
        failed: string;
      };
    };
    permissionAudit: {
      title: string;
      channel: string;
      noResults: string;
      summaryLabel: string;
      summaryOk: string;
      summaryIssue: string;
      hierarchyWarning: string;
      features: {
        BASIC: string;
        VOICE_GLOBAL: string;
        VOICE_GENERATOR_CHANNEL: string;
        VOICE_GENERATOR_CATEGORY: string;
        MIMIC_WEBHOOK: string;
      };
    };
    setup: {
      description: string;
      step0: { title: string; desc: string; startBtn: string; };
      step1: { title: string; desc: string; placeholder: string; nextBtn: string; skipBtn: string; };
      step2: { title: string; descOk: string; descFail: string; recheckBtn: string; nextBtn: string; };
      step3: { title: string; desc: string; placeholder: string; disableBtn: string; nextBtn: string; };
      step4: { title: string; desc: string; nextBtn: string; };
      step5: { title: string; desc: string; placeholder: string; autoBtn: string; skipBtn: string; nextBtn: string; };
      step6: { title: string; desc: string; finishBtn: string; };
      finished: string;
      expired: string;
      defaultCategoryName: string;
      defaultGeneratorName: string;
      auditCategories: {
        SYSTEM: string;
        BOOT: string;
        VOICE: string;
        PERMISSION: string;
      };
    };
    config: {
      title: string;
      noOptions: string;
      mimic: {
        label: string;
        enabled: string;
        disabled: string;
      };
      emoji: {
        label: string;
        enabled: string;
        disabled: string;
      };
    };
  };

  // ── Modals ──
  modals: {
    renameTitle: string;
    renameLabel: string;
    limitTitle: string;
    limitLabel: string;
  };

  // ── Select Menu Placeholders ──
  selects: {
    kickUser: string;
    banUser: string;
    transferOwner: string;
  };

  // ── Presence (Bot Status) ──
  presence: {
    servers: string;
    help: string;
    managing: string;
    version: string;
  };
}

// ── Provider Interface ─────────────────────────────────────

/**
 * Interface for translation providers.
 * Implement this to swap out the translation backend.
 *
 * Default: StaticI18nProvider (TypeScript object-based)
 * Future:  DbI18nProvider, ApiI18nProvider, etc.
 */
export interface I18nProvider {
  /** Get a translated string by dot-notation key */
  get(locale: SupportedLocale, key: string): string | undefined;

  /** Check if a locale is supported */
  isSupported(locale: string): locale is SupportedLocale;

  /** List all supported locales */
  getSupportedLocales(): readonly SupportedLocale[];
}

// ── Locale Resolution Options ──────────────────────────────

export interface LocaleResolutionOptions {
  /** User's personal locale setting from DB */
  userLocale?: string | null;
  /** Guild's locale setting from DB */
  guildLocale?: string | null;
  /** Discord client locale from interaction.locale */
  discordLocale?: string;
}
