It is a hard one. Firstly, I suspect that you will find the first few weeks/months of being a mum harder than you are expecting, and also more rewarding than you ever dreamed. You might well feel very differently about leaving a young baby once you have one, than you do now.

I know that people have other experiences, but I know someone who was offered a job and turned it down explaining that she had just found out she pg. They said "so" and hired her anyway. If it were me, I would worry about it, but I would probably try to go with honesty. Explain that you still want the job, but have just had this surprise. That you want to work up until the birth and then play it by ear. Hopefully they will be understanding and then you can give yourself some time and flexibility to find out what will work for you. Legally they can't withdraw the offer, but they can make things difficult, I guess that it the chance you take. It is up to you what you do, but that is my advice FWIW. GL.