import u from "flat";
import c from "i18next";
import { initReactI18next as f } from "react-i18next";
import r from "./accelbyte-widgets344.mjs";
import l, { languageMap as o } from "./accelbyte-widgets345.mjs";
import { SSRHelper as i } from "./accelbyte-widgets242.mjs";
import { FeUtils as s } from "./accelbyte-widgets45.mjs";
import L from "./accelbyte-widgets346.mjs";
import m from "./accelbyte-widgets347.mjs";
const g = "i18nextLng", y = { "en-US": L, "zh-CN": m }, a = r.languageCodes, p = a.reduce((e, n) => (e[n] = {
  translation: u.unflatten(l[n])
}, e), {});
function S() {
  if (!i.isSSR()) {
    const e = localStorage.getItem(g);
    if (e && a.includes(e))
      return e;
  }
  return r.defaultLanguage;
}
function d(e) {
  i.isSSR() || localStorage.setItem(g, e);
}
const t = c.use(f);
t.on("languageChanged", (e) => {
  d(e);
});
t.init(
  {
    lng: S(),
    fallbackLng: r.fallbackLanguage,
    preload: a,
    resources: p,
    initImmediate: !1,
    returnObjects: !1,
    debug: !1,
    interpolation: {
      format: (e, n = "LL") => e instanceof Date && (n === "LL" || n === "LLLL") ? s.formatDate(e, { format: n, type: "dynamic" }) : e
    }
  },
  () => {
  }
);
function E(e, n) {
  return t.t(e, n);
}
function N() {
  return t.language;
}
async function k(e) {
  await new Promise((n) => {
    t.changeLanguage(e, n);
  });
}
function D() {
  return Object.keys(o).filter((e) => a.includes(e)).reduce((e, n) => ({
    ...e,
    [n]: o[n]
  }), {});
}
export {
  y as I18N_DATE_LOCALES,
  k as changeLanguage,
  D as getAvailableLanguageMap,
  N as getCurrentLanguage,
  t as i18nInstance,
  E as t
};
