// test is located in test/extract-mentions
export function extractMentions(nodes) {
    const mentions = [];
    collectMentions(nodes, mentions);
    return mentions;
}
function collectMentions(nodes, mentions) {
    for(let i = 0; i < nodes.length; i++){
        const node = nodes[i];
        if (node.type === "mention" && !isWrappedUserEmojiMention(nodes, i)) {
            mentions.push(node.props);
        }
        if ("children" in node && Array.isArray(node.children)) {
            collectMentions(node.children, mentions);
        }
    }
}
function isWrappedUserEmojiMention(nodes, index) {
    const previous = nodes[index - 1];
    const next = nodes[index + 1];
    return previous?.type === "text" && next?.type === "text" && previous.props.text.endsWith(":") && next.props.text.startsWith(":");
}
