Ergodicity-breaking and the unraveling dynamics of a polymer in linear and nonlinear extensional flows