A professional assessment would probably be a good idea. But the first thing I’d suggest is sitting and talking with her about anxiety/panic attacks when she’s calm. Maybe make a date to go out and have pie, or sit and shell peas together or something. (Busy hands sometimes make the topic of conversation more incidental and therefore less threatening.)
I wouldn’t expect to solve the problem with one sit-down, but it would be an opportunity to ask her what it feels like when it happens. Ask if she can remember something that she was panicked about that turned out to be fine. Let her know that you’re concerned. That you don’t want her to be unhappy like that, and that you don’t want her to have her life limited by a temporary state.
The basic idea is to define the problem and discuss possible ways to address it. At twelve, it could be something that she’ll grow out of or something that she’ll develop the skills to deal with. Sometimes counseling can help the discussion, but I wouldn’t jump into that without talking it over with her. It may be that with coaching and advance planning, she can work through it. It sounds like she needs a strategy, though.
A professional assessment is different from counseling. They’re pricier and quite often medication is suggested. Consider whether you and your daughter would be open to medication before scheduling any assessment. I know at least one person who takes daily pills and has additional pills to take if she feels the panic coming on. You can tell if she has missed a dose.
I knew her before she got her prescription and the difference is huge. During a state of anxiety, her perception and reasoning were strongly affected. She could not track other people’s moods at all and misunderstood most of what was said to her. Everything had to filter through the panic.
But before she got her assessment and started trying different strategies and meds, her SO talked with her over and over (during calm times) about what she was doing. Because the reality she was experiencing was not the same reality as everyone else in the room.
Then there were months of “you’re doing it again” and “you’re not listening any more” and “what do you think I just said?” before she began to consider not trusting her internal state. Then when she was ready, she went and talked to someone about the problem.
The key seems to be learning to recognize the panic and having a strategy for dealing with it. I hope that this is a temporary thing for your daughter, and that you can find a way to minimize the effects of it. Maybe you could try practicing some key words and phrases. “You’re doing it again.” = “All right. It’s not the end of the world. Deep breaths. It’s not the end of the world.” (Your phrases may vary.)
Good Luck.