import { decode } from "html-entities";
// Equality is checked on entity-DECODED values: inline editing surfaces
// (contenteditable textContent) produce decoded text while stored raw values
// are entity-encoded, so a revert to the original arrives as the decoded
// variant of the stored value. The tradeoff: an entity-escaped literal and
// real markup (e.g. "&lt;b&gt;" vs "<b>") compare equal even though they are
// different stored content. Callers making destructive decisions should also
// compare against the field's live raw value.
export function hasSuggestionContentChange(oldValue, newValue) {
    const oldRaw = oldValue ?? "";
    const newRaw = newValue ?? "";
    // Identical raw strings decode identically — skip the decode passes that
    // otherwise run on every keystroke/render for potentially large values.
    if (oldRaw === newRaw)
        return false;
    return decode(oldRaw) !== decode(newRaw);
}
export function shouldRemoveNoOpSuggestion(oldValue, newValue, suggestionCommentCount) {
    if (hasSuggestionContentChange(oldValue, newValue)) {
        return false;
    }
    // Counting comments can scan a large array — accept a thunk so callers only
    // pay for it when the content is actually unchanged.
    const count = typeof suggestionCommentCount === "function"
        ? suggestionCommentCount()
        : suggestionCommentCount;
    return count === 0;
}
//# sourceMappingURL=suggestionContentChange.js.map