Anyone who has visited China over the past several decades has heard anguished stories from Chinese friends about the results of Mao Zedong’s social engineering in the Great Leap Forward and the Cultural Revolution. China spent 40 years recovering from those disasters to become a great, modern nation.

So, I can almost hear the gasps inside China, from the generation that lived through the nightmare years, as President Xi Jinping has moved down a Maoist path this year toward tighter state control of the economy — including “self-criticism” sessions for Chinese business and political leaders whose crime, it seems, was being too successful.

Xi’s leftward turn represents a major change in the management of the Chinese economy, in the view of a half-dozen experts I’ve consulted over the past week. It has the idealistic goal of “common prosperity” and a fairer distribution of China’s new wealth. But Xi will drive these changes using the ruthless instrument of an authoritarian, one-party state — and you can already see the purges and figurative “dunce caps” for those he views as obstacles.

The Chinese leader speaks internally of “amalgamation” of the public and private sectors, according to Christopher Johnson, a former top CIA China analyst who now heads the consulting firm China Strategies Group. Johnson describes an explanation often heard in elite circles: “Xi wants the state sector to have more market discipline, and the private sector to have more party discipline.” The result is a severe squeeze on what Xi views as “undisciplined” entrepreneurs.

The best account I’ve read of Xi’s plans was an article Monday in the Wall Street Journal by Lingling Wei, the paper’s senior China correspondent. She described a campaign that has included more than 100 regulatory and policy directives over the past year that have shattered the power of the companies that had dominated China’s new economy — the Internet giants Alibaba and Tencent, and a real estate behemoth called Evergrande. Xi has also attacked gaming and education companies that he thought were skewing the values of Chinese youth.

The most chilling detail in Wei’s account involved Vice Premier Liu He, a market advocate who has over the past decade been China’s most important contact with the West. The article noted that Liu offered “self-criticism” for allowing the ride-sharing company Didi to float a $4.4 billion IPO this summer. This humiliation of a senior official was an echo of Mao’s Cultural Revolution, which eviscerated China’s educated middle class in the 1970s.

Xi is a cunning and ruthlessly successful politician; since taking power in 2013, he has purged a generation of leaders in the Communist Party, the military, and the intelligence and security services to gain absolute control. His hubris is that, like Mao, he now seeks to become a man-God, whose thoughts are holy writ.

Xi’s unabated hunger for power is evident in his drive for a third term as party leader. That would break the two-term rule that has prevailed in China’s modern history and provided the checks and balances of group leadership. “China had solved the major problem of a one-party state — succession. Now they are un-solving it,” argues a former top-level U.S. national security official.

To drive his internal revolution, Xi has his own vanguard organizations. One is the party’s United Front Work Department, which earlier organized campaigns against Uyghurs, democrats in Taiwan, foreign critics in the West and other “threats.” Another is the party’s Central Commission for Discipline Inspection, which organized the purges of the past decade under its chief, Wang Qishan, who may be Xi’s most decisive deputy.

When Wang left that post in 2017 and became a vice president without portfolio, an intelligence source tells me, he was assigned the job of breaking dissent in Hong Kong; now, ominously, it’s said he has been assigned the Taiwan file.

Xi’s crackdown has rocked the Chinese economy. The top six technology stocks have lost more than $1.1 trillion in value over the past six months, according to Kevin Rudd, a China expert and former Australian prime minister. Jack Ma, the brilliant founder of Alibaba, has been humbled, and prevented from making public comments. Most destabilizing is the fragility of Evergrande, the debt-laden and wildly overexposed real estate developer. Fears that it might default on tens of billions of dollars in debt spooked global financial markets this week.

Xi’s campaign to remake China — from the video games people play to the ways children are educated — was explained in a Sept. 9 report by The Post’s Lily Kuo. The warning lights are blinking red, so to speak.

Xi is animated by what he has called his “China Dream,” of a nation of unparalleled wealth and power — and also the egalitarian ideals of socialism. His problem is that, like Mao and other visionaries, he has a messianic streak that could prove destabilizing for the world and downright toxic for China.