How do I deal with romantic rejection from a close friend?

I have a friend that I fell in love with, and months ago I found out second hand that they weren’t into me, but had been play flirting with me. I tried to stop being as flirty with them and it was a painful experience for both of us as they thought I was mad at them while I was trying to “relearn” how to be their friend without being flirty.

Eventually I just decided to try to act how I did originally and alter my behavior later if they started dating.

Well I went to a party with them and afterwards they texted me and told me that I had made them uncomfortable by being too flirty, where I had thought I was just acting how I was normally. I tried asking in what way specifically had I been too flirty but they just said it would be better to drop the subject. And then they told me that they wanted to make sure I knew we were just friends.

This is one of my closest friends I have, and I feel like I’ve really exposed every part of who I am to them, and to be told they don’t want anything to do with me romantically feels very hard for me. I don’t know how to process feeling like there’s just something wrong with me.

The second thing is I just don’t know how to adjust my behavior because I felt like I was just being normally friendly with her and nothing overly flirty.

Any help would be appreciated