class d {
  getStringForLocale(t, e) {
    let r = this.strings[e];
    r || (r = u(e, this.strings, this.defaultLocale), this.strings[e] = r);
    let n = r[t];
    if (!n)
      throw new Error(`Could not find intl message ${t} in ${e} locale`);
    return n;
  }
  constructor(t, e = "en-US") {
    this.strings = {
      ...t
    }, this.defaultLocale = e;
  }
}
function u(a, t, e = "en-US") {
  if (t[a])
    return t[a];
  let r = f(a);
  if (t[r])
    return t[r];
  for (let n in t)
    if (n.startsWith(r + "-"))
      return t[n];
  return t[e];
}
function f(a) {
  return Intl.Locale ? new Intl.Locale(a).language : a.split("-")[0];
}
const o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
class h {
  format(t, e) {
    let r = this.strings.getStringForLocale(t, this.locale);
    return typeof r == "function" ? r(e, this) : r;
  }
  plural(t, e, r = "cardinal") {
    let n = e["=" + t];
    if (n)
      return typeof n == "function" ? n() : n;
    let i = this.locale + ":" + r, l = o.get(i);
    l || (l = new Intl.PluralRules(this.locale, {
      type: r
    }), o.set(i, l));
    let c = l.select(t);
    return n = e[c] || e.other, typeof n == "function" ? n() : n;
  }
  number(t) {
    let e = s.get(this.locale);
    return e || (e = new Intl.NumberFormat(this.locale), s.set(this.locale, e)), e.format(t);
  }
  select(t, e) {
    let r = t[e] || t.other;
    return typeof r == "function" ? r() : r;
  }
  constructor(t, e) {
    this.locale = t, this.strings = e;
  }
}
export {
  d as LocalizedStringDictionary,
  h as LocalizedStringFormatter
};
//# sourceMappingURL=module.es.js.map
