import { useMemo as i } from "react";
import { $ as u } from "./LocalizedStringDictionary-rmcyf3BY.es.js";
import { $ as p } from "./context-BfHy4NgG.es.js";
function m(e) {
  if ((/* @__PURE__ */ new Set(["en", "de", "es", "fr-FR", "pt-BR"])).has(e)) return e;
  const n = {
    en: "en",
    de: "de",
    es: "es",
    fr: "fr-FR",
    pt: "pt-BR"
  }, t = e.split(/[-_]/)[0].toLowerCase();
  return n[t] ?? "en";
}
function g(e) {
  const { locale: r } = p();
  return i(() => {
    const t = new u(e), f = m(r);
    return {
      format(c, s) {
        try {
          const o = t.getStringForLocale(c, f);
          if (o == null)
            return "";
          if (typeof o == "function")
            return o(s ?? {});
          if (typeof o == "string")
            return o;
        } catch {
        }
        return "";
      }
    };
  }, [e, r]);
}
function y(e) {
  const r = {};
  for (const [n, t] of Object.entries(e))
    typeof t == "function" ? r[n] = ((f, c) => {
      if (!f) return t({});
      const s = {};
      for (const [o, a] of Object.entries(f))
        (typeof a == "string" || typeof a == "number") && (s[o] = a);
      return t(s);
    }) : r[n] = t;
  return r;
}
export {
  y as n,
  g as u
};
//# sourceMappingURL=normalize-messages-BN9BAFXe.es.js.map
