/** @since 5.0 */
export type MessageBundleLocale = "ar" | "bg" | "bs" | "ca" | "cs" | "da" | "de" | "el" | "en" | "es" | "et" | "fi" | "fr" | "he" | "hr" | "hu" | "id" | "it" | "ja" | "ko" | "lt" | "lv" | "nb" | "nl" | "no" | "nn" | "pl" | "pt" | "pt-BR" | "pt-PT" | "ro" | "ru" | "sk" | "sl" | "sr" | "sv" | "th" | "tr" | "uk" | "vi" | "zh" | "zh-CN" | "zh-HK" | "zh-TW";

/**
 * A message bundle loader is an object used to load translation strings in the user's locale.
 * It must be registered in `intl` using [registerMessageBundleLoader()](https://developers.arcgis.com/javascript/latest/references/core/intl/#registerMessageBundleLoader).
 * When loading message bundles in the API, the last registered loader is evaluated first.
 *
 * @since 4.18
 * @see [fetchMessageBundle()](https://developers.arcgis.com/javascript/latest/references/core/intl/#fetchMessageBundle)
 * @see [registerMessageBundleLoader()](https://developers.arcgis.com/javascript/latest/references/core/intl/#registerMessageBundleLoader)
 * @see [createJSONLoader()](https://developers.arcgis.com/javascript/latest/references/core/intl/#createJSONLoader)
 * @example
 * const loader = {
 *   // The loader matches all the bundle identifiers starting with "my-application/"
 *   pattern: "my-application/",
 *   // fetch the JSON file from a `translations` folder
 *   async fetchMessageBundle(bundleId, locale) {
 *     const url = new URL(`/assets/translations/${bundleId}_${locale}.json`, window.location.href);
 *     const response = await fetch(url);
 *     return response.json();
 *   }
 * };
 *
 * registerMessageBundleLoader(loader);
 *
 * // Fetch file `./translations/my-application/MyBundle_en-US.json`
 * const bundle = await fetchMessageBundle("my-application/translations/MyBundle");
 */
export interface MessageBundleLoader {
  /**
   * Used to check if the loader should be used to load a candidate message bundle.
   *
   * @since 5.0
   */
  pattern: string | RegExp;
  /**
   * Called to load the message bundle if the `pattern` matches the bundle identifier.
   *
   * @since 5.0
   */
  fetchMessageBundle: FetchMessageBundle;
}

/**
 * The function responsible for fetching a message bundle resource for a particular locale.
 *
 * @param bundleId - The identifier of the bundle to localize.
 * @param locale - The locale in which to load the bundle.
 * @returns Resolves to an object containing the localized message strings.
 * @since 4.18
 * @see [registerMessageBundleLoader()](https://developers.arcgis.com/javascript/latest/references/core/intl/#registerMessageBundleLoader)
 */
export type FetchMessageBundle = (bundleId: string, locale: string) => Promise<MessageBundle>;

/** @since 5.0 */
export type MessageBundle = any;