function fieldTooltip(forActor, fieldName) {

    let tooltip = {}

    if (forActor) {
        Object.entries(forActor.getModificationsOn(fieldName)).forEach(([key, value]) => {
            tooltip[key] = value

        })
    }

    return tooltip
}

function registerHelper(hbs) {
    hbs?.registerHelper('fieldTooltip', (data) => {

        const [fieldName, actorId] = data
        const forActor = game.actors.find(p => p._id === actorId)
        const tooltip = fieldTooltip(forActor, fieldName)

        let template = ``

        Object.entries(tooltip).forEach(([key, value]) => {
            template += `${key}: ${value}<br/>`

        })

        return new Handlebars.SafeString(template)
    })
}

export {
    fieldTooltip,
    registerHelper
}