Lose durability but with respect to unbreaking enchantment

Good day! I have a custom mining enchantment that mines in a 3x3x3. I got it setup and ready to go and now I'm working on balancing its aspects. Right now, when I mine blocks, it only deducts 1 durability loss which is a normal vanilla thing, that's expected. But now I want it to dynamically deduct durability depending on how many blocks it broke. I could do a recursion 26 times and deduct durability by 1 every loop, but how do I make it so that it respects the tool's enchantments, for this case, the unbreaking enchantment, to go through the unbreaking chances first before it applies the final deduction points to the tool?
Continue to help post