function formatFieldLabel(field) {
  if (field.includes(".")) {
    const parts = field.split(".");
    if (parts[0] === "options" && parts.length === 3 && parts[2] === "label") {
      const optValue = parts[1];
      return `${optValue.charAt(0).toUpperCase()}${optValue.slice(1)} (option)`;
    }
    return parts.map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join(" > ");
  }
  return field.split("_").map((segment) => segment ? `${segment[0].toUpperCase()}${segment.slice(1)}` : "").join(" ").trim() || field;
}
function formatEntityLabel(entityId, label) {
  if (label && label !== entityId) return label;
  const parts = entityId.split(":");
  const name = parts.length > 1 ? parts[1] : parts[0];
  return formatFieldLabel(name);
}
const PLURAL_EXCEPTIONS = {
  category: "categories",
  entry: "entries",
  dictionary_entry: "dictionary_entries",
  currency: "currencies",
  company: "companies",
  activity: "activities",
  history: "histories",
  address: "addresses",
  tax: "taxes",
  status: "statuses"
};
function pluralize(word) {
  if (PLURAL_EXCEPTIONS[word]) return PLURAL_EXCEPTIONS[word];
  if (word.endsWith("s")) return word;
  if (word.endsWith("x") || word.endsWith("z") || word.endsWith("sh") || word.endsWith("ch")) return `${word}es`;
  if (word.endsWith("y") && !/[aeiou]y$/.test(word)) return `${word.slice(0, -1)}ies`;
  return `${word}s`;
}
function buildEntityListUrl(entityType) {
  const [module, entity] = entityType.split(":");
  if (!module || !entity) return null;
  const prefix = `${module}_`;
  const base = entity.startsWith(prefix) ? entity.slice(prefix.length) : entity;
  const resource = pluralize(base).replace(/_/g, "-");
  return `/api/${module}/${resource}`;
}
function getRecordLabel(item) {
  return String(item.title ?? item.name ?? item.label ?? item.display_name ?? item.id ?? "");
}
function resolveBaseValue(baseValues, fieldKey) {
  if (!baseValues) return "";
  const candidate = fieldKey in baseValues ? baseValues[fieldKey] : baseValues[`cf_${fieldKey}`];
  if (candidate === void 0 || candidate === null) return "";
  return typeof candidate === "string" ? candidate : String(candidate);
}
export {
  buildEntityListUrl,
  formatEntityLabel,
  formatFieldLabel,
  getRecordLabel,
  resolveBaseValue
};
//# sourceMappingURL=helpers.js.map
