It is an obligation on the thief to return the stolen item itself if it still has its appearance and is not changed, as it says “[It shall be if he sinned and is guilty,] that he will return the stolen item which he took by robbery[, or confiscated item that he got by oppression, or the deposited item that was deposited with him, or the lost thing which he found.]” (Devarim 5:23) This is [also] the law for a robber [see below for the difference between the two]. He does not fulfill his obligation by giving money, even if the owners have given up [on ever receiving compensation].
However, if the item is lost, or was altered in a change that can not be restored to its original, or was built into a building so that [the thief or robber] would incur a great loss to destroy the building, then he could fulfill his obligation by giving money, whatever [the stolen item] was worth at the time of the theft. If the one who was robbed is in another place, he does not have to send the money to his place, rather [just] tell him that he could come and he would repay him.
And if the theft victim died, he should return [it] to his heirs.
Gezeilah is taking an item from its owner. I have been translating it is “theft” or “stealing”. Geneivah is more like robbery; the item is removed from the owner’s domain (e.g. robbing a home), but without the owner’s knowledge.
The leniencies in the second paragraph dates back to a ruling by Beis Hillel (Gittin 58a). They were concerned that if returning the item itself were too onerous, thieves would avoid coming clean altogether. The obligations associated with teshuvah would become a barrier to doing it. Therefore if someone stole a beam and built it into his house, or returning the item would be too difficult, we allow the thief to repay the value of the item.