Measuring the Tolerance of the State: Theory and Application to Protest