The part number is always closest to the logo or company name and the CWN1 = factory/date/batch codes.
Recommendation
I recommend the PC817X3NSZ1B or PC817X4NSZ1B replacement.
Then do a diode test on all other parts or use a conservatively limited CC limited lab supply to bring up DC power externally to locate defective parts.
CWN1 C means CTR = 2 to 4 = Ic=/If= 10~20mA / 5 mA = 2 to 4 @ Vce= 5V but as a switch CTR, like hFE, always reduces to << 10% CTR @ Vce(sat)
Proof: from datasheet ... Ic/If= 20mA/1mA= 0.05 @ Vce(sat)= 0.1 to 0.2V so at Vce=Vce(sat) @ Ic=1mA CTR= 0.05/2~4= 2.5% to 1.25% Although the new datasheets do not show any distinction for CTR saturated vs different ranks, they do exist and will be around 10% of the max linear CTR for a fixed Vce(sat) max. They just overdrive the LEDs to ensure low Vce(Sat) but you app might not.
W is the factory now made by LITE-ON in China
N1 is the date code for 2001 January
PC817
SHARP
still supplies them to Mouser, but they have new part numbers and they are most likely DIP for HV spacing of 5 kV could easily have been compromised by dust and humidity. over this period. No doubt this will cause a cascade of component secondary failures.
The new stock part number uses 3 for X as Rank C Ic= 10 to 20mA
PC817X3NSZ1B for DIP which are the only ones in stock at this time.
You could also use 4 as Rank D Ic= 15 to 30 mA both for If= 5mA which is slightly better and also cheaper a few cents perhaps due to high yield and more common, which is also stocked. PC817X4NSZ1B
https://www.mouser.ca/ProductDetail/Sharp-Microelectronics/PC817X3NSZ1B?qs=sGAEpiMZZMv0NwlthflBi%252B9cc83UOuhhP4dcSDiySOo%3D
other misc info
There are a few other Optos rated for 5kVrms but no others at Mouser are ranked as well for CTR, Onsemi= CTR= 1 to 6 , Everlight = 1 to 2, . Sharp makes some only in Japan also which are also good, maybe better quality PC123X5YFZ1B where 5 is Rank N 10 to 20 mA / 5mA similar to Rank C in the other p/n. but is non-stock. Nobody is better than Sharp in these IR optos. Sharp IR LEDs are now licensed to Vishay.