/**
 * Default dimensions for circle and rectangle pre-click follower previews (pixel mode only).
 *
 * In pixel mode the real cursor acts as pointB (the edge / corner of the annotation)
 * while pointA (the anchor) is offset from the cursor by these amounts.  This means
 * `getDistance(anchor, cursor) === DEFAULT_CIRCLE_RADIUS` (or the rect diagonal) at the
 * exact moment of the first click, eliminating any visual size jump.
 */
export const DEFAULT_CIRCLE_RADIUS = 30;
export const DEFAULT_RECT_WIDTH = 60;
export const DEFAULT_RECT_HEIGHT = 40;
/**
 * Minimum real-cursor travel (pixels) between mouseDown and mouseUp that counts as a drag.
 * Below this threshold the interaction is treated as a stationary click, keeping the
 * two-click workflow active instead of immediately confirming the annotation.
 */
export const DRAG_THRESHOLD = 5;
/**
 * For circle and rectangle in pixel mode, shifts the recorded anchor (pointA /
 * firstClickPosition) away from the real cursor by the default annotation size so that the
 * real cursor becomes pointB.  The distance between anchor and cursor then equals the
 * default size at the exact moment of the first click, giving a seamless transition from
 * the pre-click preview.
 *
 * Only applied in pixel mode (`snapMode === 'none'`) because data-snapped annotations
 * require their anchor to correspond to an actual data point.
 */
export function applyAnchorOffset(snap, type, snapMode) {
    if (snapMode !== 'none')
        return snap;
    const { x, y } = snap.interactionCoordinate;
    if (type === 'circle') {
        return {
            ...snap,
            interactionCoordinate: { x: x - DEFAULT_CIRCLE_RADIUS, y },
            snappedCoordinate: undefined,
            dataPoint: undefined,
        };
    }
    if (type === 'rectangle') {
        return {
            ...snap,
            interactionCoordinate: { x: x - DEFAULT_RECT_WIDTH, y: y - DEFAULT_RECT_HEIGHT },
            snappedCoordinate: undefined,
            dataPoint: undefined,
        };
    }
    return snap;
}
/**
 * Returns true when the real cursor travelled far enough between mouseDown and mouseUp
 * to be classified as a drag (rather than a stationary click).
 */
export function isDragInteraction(downPos, upPos) {
    const dx = upPos.x - downPos.x;
    const dy = upPos.y - downPos.y;
    return Math.sqrt(dx * dx + dy * dy) > DRAG_THRESHOLD;
}
