Bifunctional enzyme that catalyzes the epimerization of the S- and R-forms of NAD(P)HX and the dehydration of the S-form of NAD(P)HX at the expense of ADP, which is converted to AMP. This allows the repair of both epimers of NAD(P)HX, a damaged form of NAD(P)H that is a result of enzymatic or heat-dependent hydration (By similarity). (6S)-NADHX + ADP = AMP + H(+) + NADH + phosphate (6S)-NADPHX + ADP = AMP + H(+) + NADPH + phosphate (6R)-NADHX = (6S)-NADHX (6R)-NADPHX = (6S)-NADPHX Binds 1 potassium ion per subunit. In the N-terminal section; belongs to the NnrE/AIBP family. In the C-terminal section; belongs to the NnrD/CARKD family.