Compositional Thermostatics