import { rcWindow as t } from "./index-window.store.js";
class u {
  translateArray(a) {
    return a.map((n) => {
      var s;
      return (s = this.get(n)) == null ? void 0 : s.value;
    });
  }
  justReplace(a, n) {
    let s = a;
    return n && typeof n == "object" && Object.keys(n).forEach((l) => {
      const o = n[l], e = new RegExp(`[%{]${l}[%}]`, "g");
      s = s.replace(e, `${o}`);
    }), s;
  }
  get(a, n, s, r, l) {
    let o = !1, e = a;
    const f = typeof t.TranslationsData < "u" && a in t.TranslationsData;
    return typeof t.TranslationsData < "u" && t.TranslationsData[a] && (o = !0, s === "other" && t.TranslationsData[`${a}_other`] ? r === "impersonal" && t.TranslationsData[`${a}_other_impersonal`] ? e = t.TranslationsData[`${a}_other_impersonal`] : e = t.TranslationsData[`${a}_other`] : r === "impersonal" && t.TranslationsData[`${a}_impersonal`] ? e = t.TranslationsData[`${a}_impersonal`] : e = t.TranslationsData[a]), n && typeof n == "object" && Object.keys(n).forEach((i) => {
      const T = n[i], c = new RegExp(`[%{]${i}[%}]`, "g");
      e = e.replace(c, `${T}`);
    }), e === null ? {
      value: a,
      wasTranslated: !1,
      hasTranslationKey: !1
    } : {
      value: e,
      wasTranslated: o,
      hasTranslationKey: f
    };
  }
  getTranslationKey(a) {
    var s;
    return t && !t.TranslationsData ? {
      key: a
    } : {
      key: Object.keys(((s = t) == null ? void 0 : s.TranslationsData) ?? {}).find((r) => t.TranslationsData[r] === a) ?? a
    };
  }
}
const $ = new u();
export {
  $ as translationService
};
