Minecraft wiki entry for Anvil_mechanics, associated text: Prior Work penalties of both target and sacrifice.
If renaming, the extra cost of renaming
If the target item is not at full durability, the repair cost of 2 levels.
If the sacrifice has enchantments, the enchantment cost.