Closest point to a Bézier curve segment seems not to be possible analytically.
] So you will need to do some iteration.
Here's how I would tackle it. First, find the closest approach of the target point to each of the line segments, which is a well known algorithm. To quote myself
Point-line closest approach: to find the point on a line segment (p1 to p2) that is the closest to another point (q) in space. First, find how far along the line the point will be: f = [(q-p1).(p2-p1)]÷|p2-p1|². If f is less than zero, then q is off the 'beginning' of the line and the closest point is p1; likewise, if f>1, the closest point is p2. Otherwise, q is alongside the line segment and the closest point is p1+f(p2-p1).
Then, find the closest point on the bounding polygon of each of the curve segments (defined by the four control points). If the point is within the bounding polygon of a segment, give that segment a distance value of 0.
If the smallest value is for a line segment, you have the closest approach. If it is for a curve segment, walk along the curve to find the minimum, using a step size appropriate for your problem. If the smallest value is shared, you may need to walk more than one curve segment. But you won't need to walk the whole path.
Edit: In certain pathological cases, the point may be inside one or more curve bounding boxes, but closest to a line. So once you have found the real closest approach for each curve segment that has a lower distance value than the smallest line, by walking the segment, you need to check if the real distances are still lower than the smallest line.
In addition, the point can be close to the bounding box of a curve, but not to the curve itself. You should therefore also store the maximum
distance to a point in the curve's bounding box, and walk all curves with a minimum value less than (i) the smallest distance-to-line for a line segment and (ii) the maximum distance for the curve(s) with the smallest minimum value. In the extreme case of a path which is 100% curves, all of which have large bounding boxes and are near to each other, this may mean you will still have to walk the entire path.