You are getting a lot of criticism but I am sympathetic because she sounds quite a lot like my eight year old. Who likely has ADHD and maybe some other stuff too. She is similarly very very difficult when it comes to anything demanding and can be very rude but can be incredibly lovely at other times.
As parents we certainly have all kinds of consequences and we absolutely stick to them but a lot of the recommendations made on this thread just don't work and actually make things worse.
For example, physically moving or restraining my child will often result in one or both of her and I getting hurt, inadvertently. It's horrible and an absolute last resort.
Getting into a big argument with her - well she even at 8 will throw a 2hr long screaming tantrum where she can't actually access logical thought and can't be reasoned with.
Taking her stuff away and constant punishments. We do this sometimes, but end up in a miserable situation where everything fun has gone and she's no better.
In essence, she needs to be treated as someone that needs help to improve. I believe a lot of it is coming out because she's anxious and often unhappy at school where she is struggling with focus and trying to fit in with others.
Plus if she's tired, hungry, frustrated about something...
My daughter is very impulsive and she struggles with thinking through the consequences of her emotional responses, so it's hard for her to learn to control these.
When she's upset, she lashes out, and we are trying to help her find better ways to deal with her emotions, but it's a hard thing even for adults to master.
However, we always make it clear that rudeness is unacceptable, and there are consequences. But we try and make these in the moment rather than long running. Some things we let go. I do find that pretending not to hear her when she's rude works well, because she really really wants our attention. I'll ask her to say it again politely so that I can hear her. We will mostly allow a reset and to forgot what's gone before, if it comes with an apology.