What happens if I'm laid off after my H1 is approved but not stamped?

I am currently working in the US on F1 OPT with 150 unemployment days remaining. I was picked in this year’s h1b lottery. My company will file the petition in the next two weeks under premium processing. There is a possibility of layoff in the June/July. I wanted to know if my petition is filed as consular processing and it gets approved before the layoff date, but if I lose my job during the layoffs, can I continue working on F1 status and find a job in 150 days and then have the H1b transferred to a new employer? Or will I lose the h1b petition entirely and have to enter the lottery again?

Once H1B is approved, USCIS may count you against the H1B cap even if you don’t work for the sponsoring employer. If approved with consular processing, you can keep working on OPT EAD till it is valid. A new H1B employer may file a cap-exempt petition with change of status from F1 to H1B ( if you are in the US) so that you dont have to go for stamping and once approved you can start working on H1B status.