The answer depends upon the distance $d$.
First, recall that the brachistochrone is a cycloid, the curve traced by a point on a circle rolling along the directrix (dashed line, figures below), which is at the height of zero kinetic energy of the particle. Thus if the particle starts at rest (as it does in this problem), the directrix is at the height of $A$ above the "floor," denoted $h$. The radius of the circle depends upon the locations of the initial and final points.
If $d$ is small ($d < \pi h/2$... half the circumference of a circle that remains above the "floor"), then a single cycloid (brachistochrone) can go from $A$ to $B$ without needing to go through the floor and hence (as the Bernoulli brothers proved) is the optimal solution.

If $d$ is so large that a cycloid would have to pass "beneath the floor" (as the poser posits, i.e., $d>\pi h/2$), the solution is to take the cycloid that is tangent to the farthest possible point on the floor (the point at $(\pi h/2,0)$), then follow the floor to $(d,0)$.
To see this: Note that the brachistochrone is, by definition, the fastest route to $(\pi h/2,0)$. By the properties of a brachistochrone, it does not speed up the route to $(\pi h/2, 0)$ to get to the floor "sooner." Clearly, too, the floor is the fastest route from $(\pi h/2,0)$ to $(d,0)$ because the particle has the fastest possible speed (given the constraints) and also the fastest horizontal speed. Note that the optimal curve is continuous throughout because the cycloid has vanishing derivative at the transition point... the same as the horizontal "floor."

For any point $B$ beyond $\pi h/2$, the unconstrained brachistochrone would have to go "beneath" the "floor," and is hence unacceptable.
Closely related reference.