Most insomnia, if not caused by something like apnea, boils down to an anxiety or depressive disorder. I developed my insomnia 4yrs ago from such, and it was utterly devastating. Like life changing PTSD shit. It destroyed my life and left me a shell of myself. It got so bad I would have an anxiety attack every time I laid down in bed or even laid back on the couch.
FF to now and it's 90% in remission. The answer was to solve the root anxiety and depressive problems. My life is much better.
ETA, I'm talking real chronic insomnia here, not the sort of stuff where you're a night owl or have a rough night every couple weeks. That's not insomnia.
I've been through similar times, but not as intense as you've described. My mind would race & keep me up all night. I'd toss & turn in bed, so it was the mental & the physical working together keeping me awake for hours & hours. I eventually learned to "control my thoughts", and instead of my mind racing in chaos I learned to entertain myself into creative, comforting thoughts. Instead of frantically trying to calm racing mind, I'd steer my thoughts into a creative design exercise that was enjoyable and soothing, and too detailed to ever fully complete. So, I'd eventually dose off to sleep in a peaceful frame of mind. As time went, I learned to get lost in pleasant thoughts quicker and quicker.
A few years later I found myself in a very stressful situation. I'd become my father's caregiver, and instead of helping me him for a few months until we found a permanent solution, I became the permanent solution. It wasn't my intention, but as his health conditions worsened it became more difficult for me to leave. I found myself in the most stressful mindset that I'd even encountered. It seemed that every emotion that the mind could experience was raging through my head all at the same time. At times it felt like I was on the edge of nervous breakdown, but at the same time it also felt almost superhuman. It was like a PhD level psychology program, with all the courses of each emotion being studied & examined at the same time. I had no idea that so many emotions could exist simultaneously. It was a fascinating experience.
In my earlier years this level of stress would have likely resulted in insomnia. Instead, I found that at night my mind chose interesting visual exercises to explore and enjoy. I'd imagine shapes in my mind, similar to cloud gazing. I would follow whatever shape happened to appear in my mind, and instead of watching it flow along I'd take control of it. I learned to reverse the forms that were emerging, I learned to choose their colors & patterns, and I learned to direct the forms as they morphed into something else. It was fascinating, but required quite a bit of focus to achieve. The amount of focus was tiring and I don't remember any of these visions lasting more than an hour, but time really didn't feel relevant as I explored my visions. It was sort of an "out-of-body" or drug-like experience.
My father passed away a few years ago, and the stress of it all is now long gone. I've lost most of the ability to chase & manipulate the visions in my head, but the fond memories of it often dance through my head as I close my eyes for the night.
I've shared this in hopes that it may be of help to others, perhaps with insomnia or other stressful emotions that they're experiencing "at the moment". That's something that I've learned is important to remember and embrace, everything is "in the moment" and life continues to evolve. That's an important "tool" for getting through whatever you happen to be facing today, or tonight.
Peace & sweet dreams.