Does anybody know how repair times are calculated? Unit type/level/rarity ? The enemy which defeated them?

It seems to go up as the level goes up but still seems different for each unit... I guess as the game moves on the repair times will go up to several hours to make you spend your resources or cores to use you units, right?