Early last week, a friend who is generally supportive of President Trump offered his view that the president had only one move remaining — firing special counsel Robert Mueller.

By week’s end, my friend had a different view: The president is in a box without a clear escape hatch. “I’m not sure how he gets out of this,” he said wearily.

Those conversations bookend the worst week of the Trump presidency, which ended with another shake-up. By removing Reince Priebus as chief of staff and replacing him with Gen. John Kelly from Homeland Security, Trump aims to bring a semblance of military order and discipline to the White House.

Given Trump’s respect for Kelly, the move could mark an important turning point in focusing the president’s time and efforts. Too many days have been squandered by leaks and conflicting and even contradictory messages.

But to understand the complexity of Trump’s challenge and the limits of what Kelly can fix, it is useful to divide the president’s problems into two baskets.

The first basket includes the low moments of last week — the collapse of the ObamaCare repeal effort, Anthony Scaramucci’s profane attack on Priebus and Steve Bannon and the fact that Trump’s declaration of a ban on transgenders serving in the military caught the Pentagon off guard.

Kelly, if Trump lets him, could fix or prevent all that.

Yet as significant as those events were, the problems in the second basket are potentially more serious. They center on the rupture between Trump and leading Republicans over Mueller and the president’s battering of Attorney General Jeff Sessions.

Trump repeatedly calls the probe a “witch hunt” and has discussed firing Mueller, while most Republicans trust Mueller and are willing to let his investigation run its course.

Similarly, GOP leaders like and respect Sessions and believe Trump’s attacks on him are unfair. They don’t believe Sessions deserves to be fired.

One sign of the rupture came from Sen. Charles Grassley, chairman of the Judiciary committee, who said in a Wednesday tweet that the panel’s schedule is set for the year and there is no time to confirm a new Attorney General.

The point was clear: Trump shouldn’t even think about firing Sessions.

The next day, Sen. Lindsey Graham of South Carolina upped the ante, saying, “any effort to go after Mueller could be the beginning of the end of the Trump presidency unless Mueller did something wrong.”

He added that he will introduce legislation to block any attempts to fire the special counsel without judicial review — and said he was certain all Democrats and many Republicans would support him.

The sense that Trump is being curbed and isolated was bolstered when bipartisan, veto-proof majorities in both houses agreed on legislation that requires congressional approval to lift the latest round of sanctions imposed on Russia. Until now, the president could unilaterally remove them.

Trump’s predicament recalls a scene in Ernest Hemingway’s novel, “The Sun Also Rises.”

“How did you go bankrupt,” one character asks another, who responds: “Two ways. Gradually, then suddenly.”

So it is with Trump. Problems, some of them self-inflicted, that looked temporary and manageable have been compounded over time and are reaching a crisis point. Most important, he is losing flexibility to act just as Mueller expands his probe into Trump’s business empire as well as his 2016 campaign.

Various reports say the special counsel, who is amassing a small army of prosecutors, is going through Trump’s career, including his taxes and property sales, to find any connections with Russians that might indicate collusion in the election.

I believe Trump is rattled by those reports and by the fact that one of his sons, Donald Trump Jr., and son-in-law Jared Kushner have been dragged before congress; both also are likely to be summoned by Mueller.

I also believe Mueller’s aggressiveness helps explain Trump’s stepped-up attacks on Sessions, whose recusal led to Mueller’s appointment.

When Sessions, citing Justice Department regulations, stepped aside from any matter involving the 2016 campaign, he put the power in the hands of his deputy, Rod Rosenstein, who appointed Mueller after Trump fired FBI director James Comey.

More than a month ago, I urged Trump to replace Sessions so he could have someone to oversee Mueller and keep him from going beyond the initial assignment. But the revolt by the former Alabama’s Senator’s colleagues has blocked that path, and Sessions has rejected invitations to resign.

Hence, the conclusion that the president is trapped with no protection or escape from Mueller.

Trump, of course, has been counted out many times in the last two years, but always managed to bounce back. He could do it again because he retains enthusiastic support among most of those who voted for him, and less White House chaos and a big victory on tax reform could fuel another comeback.

As a bonus, strong public support would keep congressional Republicans in his corner.

But the uncertainty about where Mueller is going and what, if anything, he is finding adds a unique dimension to Trump’s troubles. That’s what makes this situation so perilous.

Chicago killing itself

The bloody stat of the week, from the Chicago Tribune:

“Chicago had 50 more homicides than New York and Los Angeles combined through mid-June, even though it is far less populous than both.”

‘Aisle’ be damned

Dueling headlines from America the confused:

“Americans aren’t getting married…”

“Support for polygamy at all time high”

Truth about DeB’s lies

This time, and this time only, you can trust him. Mayor de Blasio is telling the truth when he says: “Read my lips: I don’t care.”

That was his reaction when reporters caught him in yet another lie. After the Post reported that police had been ordered to sweep the homeless from subway stations before the mayor took a brief ride, he and his team denied it.

When The Post produced the NYPD memo to prove it, his press secretary said the memo was probably fake, and the mayor offered his “I don’t care” response.

Perhaps it was a Freudian slip that he began with “read my lips,” which was the phrase President George H.W. Bush used when he pledged “no new taxes.”

Of course, tax hikes soon followed.

De Blasio’s habit of dishonesty is becoming legendary. Reporters are still waiting for the list of donors who didn’t get what they wanted from his City Hall — a list he first promised in May of 2016 and several times since.

My guess is there is no list because there are no donors who didn’t get favors.

The mayor’s chronic deception presents the New York Times with a problem. The Gray Lady routinely calls President Trump a liar, but never uses the L-word for Democrats, including Hillary Clinton, Barack Obama and Andrew Cuomo.

Now that de Blasio clearly qualifies, will the Times play it straight and call him what he is?

Sure — when hell freezes over.