local dnf = require("dnf")
assert(dnf.api_version == "dnf/v1", "requires dnf/v1")
assert(dnf.hooks.catalog()["inventory.item_use"], "item use Hook is unavailable")

local blocked = dnf.config.blocked_item_ids or {}
assert(type(blocked) == "table", "blocked_item_ids must be a string-key set")
for id, enabled in pairs(blocked) do
    assert(type(id) == "string" and string.match(id, "^%d+$")
        and type(enabled) == "boolean", "use decimal string keys and boolean values")
end

dnf.hooks.before("inventory.item_use", function(ctx, plan, event)
    -- Bare context, and item_id is already a string. Never tonumber a character ID.
    -- Only the supported op27 UseStackable path reaches this Hook.
    return blocked[event.item_id] ~= true
end)
