If you are handy with the spanner’s it could be a good cost effective project R, if not you could be into a fair bit of money to sort it out.
With mention of the emissions and potential valve stem seals, Id be tempted to pull the head off and have it redone and de coked at that mileage with the noted issues. This could lead deeper, rings etc. Then on the way back together a full timing chain kit inc both vanos to sort the other mentioned problem.
Alternatively there is a white R listed that has half the miles but twice the money (seemingly no work to do) could work out cheaper in the long run.