Nesting statistics in the $O(n)$ loop model on random maps of arbitrary topologies