A theory of deflagration-to-detonation transition in unconfined flames