function extractString(val, fallback, preferredLang = "en") {
  if (val === void 0 || val === null) {
    return fallback;
  }
  if (typeof val === "string") {
    return val || fallback;
  }
  if (typeof val === "object") {
    const preferred = val[preferredLang];
    if (typeof preferred === "string" && preferred) {
      return preferred;
    }
    const en = val.en || val["en-US"];
    if (typeof en === "string" && en) {
      return en;
    }
    const zhCN = val["zh-CN"] || val.zh || val["zh-Hans"];
    if (typeof zhCN === "string" && zhCN) {
      return zhCN;
    }
    const values = Object.values(val);
    for (const v of values) {
      if (typeof v === "string" && v) {
        return v;
      }
    }
  }
  return fallback;
}
function extractDisplayName(val, isZh = false, fallback = "Unknown") {
  return extractString(val, fallback, isZh ? "zh-CN" : "en");
}
function normalizeRecommendation(rec, preferredLang = "en") {
  return {
    ...rec,
    name: extractString(rec.name, rec.id || "Unknown", preferredLang),
    description: extractString(rec.description, "No description available", preferredLang)
  };
}
function normalizeRecommendations(recommendations, preferredLang = "en") {
  return recommendations.map((rec) => normalizeRecommendation(rec, preferredLang));
}

const i18nHelpers = {
  __proto__: null,
  extractDisplayName: extractDisplayName,
  extractString: extractString,
  normalizeRecommendation: normalizeRecommendation,
  normalizeRecommendations: normalizeRecommendations
};

export { extractDisplayName as a, normalizeRecommendations as b, extractString as e, i18nHelpers as i, normalizeRecommendation as n };
