const avatarPalette = [
    "bg-highlight-100 text-white",
    "bg-feedback-orange text-white",
    "bg-feedback-green text-white",
    "bg-feedback-blue text-white",
    "bg-feedback-red text-white",
];
export function formatFeedbackAccountName(userName) {
    const trimmed = userName?.trim();
    if (!trimmed)
        return "Unknown";
    const slashIndex = trimmed.lastIndexOf("\\");
    if (slashIndex >= 0 && slashIndex < trimmed.length - 1) {
        return trimmed.slice(slashIndex + 1);
    }
    return trimmed;
}
export function getFeedbackAuthorName(item, resolvedAuthorName) {
    const storedDisplayName = item.authorDisplayName?.trim();
    if (storedDisplayName &&
        storedDisplayName.localeCompare(item.author || "", undefined, {
            sensitivity: "accent",
        }) !== 0) {
        return storedDisplayName;
    }
    return resolvedAuthorName || formatFeedbackAccountName(item.author);
}
export function getFeedbackAuthorInitials(item, resolvedAuthorName) {
    const name = getFeedbackAuthorName(item, resolvedAuthorName);
    const parts = name.trim().split(/\s+/).filter(Boolean);
    if (parts.length === 0)
        return "?";
    return parts
        .slice(0, 2)
        .map((part) => part[0])
        .join("")
        .toUpperCase();
}
export function getFeedbackAvatarClassName(item) {
    const value = item.author?.trim() || item.authorDisplayName?.trim() || item.id;
    const index = Array.from(value).reduce((total, char) => total + char.charCodeAt(0), 0) %
        avatarPalette.length;
    return avatarPalette[index] ?? "bg-highlight-100 text-white";
}
//# sourceMappingURL=feedbackAvatar.js.map