Compressed days of the week Given an input of a list of days of the week, output the shortest sorted
representation of the list.

The format of the input is a string consisting of one or more of the
two-character substrings Su (Sunday), Mo (Monday), Tu (etc.), We, Th,
Fr, and Sa. The input may not necessarily be given in sorted order.

To convert the input to the output format,


Sort the input by day of week, starting from Sunday (ex. ThMoSaSuFrTuWe ->
SuMoTuWeThFrSa).
Reduce the abbreviations down to one letter if it leaves no ambiguity. For
example, SuMoTuWe should become SMTW because the first S couldn't
possible be Saturday, as that would make the output unsorted (same for the
T). However, ThFrSa should become ThFS, as both Tuesday and Thursday come
before Friday and reducing it down to TFS would create ambiguity.
If the output is now MTWTF, output D instead (which stands for
"weekdays"). Similarly, SS should become E for weekend. Finally,
SMTWTFS should become A for all days.


The input and output must both be a single string.

Since this is code-golf, the shortest code in bytes wins.

Test cases:

In              Out    | In              Out
-----------------------|--------------------
SuTu            STu    | SuTuWe          STW
SuTuSa          STuS   | SuWeTh          SWT
TuThSa          TTS    | TuThSu          STT
Su              Su     | Sa              Sa
WeTh            WT     | FrTh            ThF
WeTu            TW     | FrTu            TuF
FrWeMo          MWF    | SaWeSu          SWS
ThTu            TT     | We              W
ThTuMoFrWe      D      | SaSu            E
SuMoWeTuThFr    SMTWTF | ThMoSaSuFrTuWe  A
Retina, 152 88
Massively golfed with @Martin's and @randomra's help!  Thanks both of you!
^
SuMoTuWeThFrSa
([A-Z].)(?!.*\1)

T`l``Su\B|\BSa|o|r|u?We.?.?|uTh
^MTWTF$
D
SS
E
.{7}
A

Try it online.  A couple of the lines start with m`  with this online interpreter link.  This is so the program works with multiple input lines (to run all tests in one shot).  However, multiple input lines is not a requirement, so these are not included above or in my score.