Hello bookishgardener, it still has potential for recovery. It looks like that soil is the initial soil it got, with more peat so it makes the media too dense, eventually suffocating the roots. This would be a good time to change it to a grittier cacti mix, keep it in same container for now after changing the media, no direct sun, just bright light and keep it warm. Don't water right away. It takes awhile for the plant to grow new roots and acclimate to the changes. Typically I like doing the repot in Spring, but your plant is keeling over, so got to do immediate remedial measures.
I do not know your location, ideally if your temps still warm and overnights not getting below 50F, then it can still enjoy being outdoors, but otherwise, if your weather is not conducive, then position in the bright light area you have indoors.