import { NODE_TYPE as t } from "../../constants.js"
const e = { [t.FILE_ANY]: 1, [t.FILE_IMAGE]: 1, [t.FILE_VIDEO]: 1 }
export const getNodeTextLength = (t) => {
if (t.isText) return t.text.length
const { name: n } = t.type
return "emoji" === n
? t.attrs["data-emoji"]?.length || 0
: "mention" === n
? (t.attrs.label?.length || 0) + 1
: (e[n] ?? 1)
}
export const getDocTextLength = (t) => {
let e = -1
return (
t.descendants((t) => {
e += getNodeTextLength(t)
}),
e
)
}