package behavior

import "time"

// PressHoldParams configures a press-and-hold gesture.
type PressHoldParams struct {
	// HoldDuration is how long the button should be held down.
	// Draw from PressHoldDuration() for human-realistic values.
	HoldDuration time.Duration

	// Approach is the mouse trajectory to move from the current cursor position
	// to the button before pressing. Generated by Mouse.MoveTo.
	Approach []Point
}

// PressHoldDuration returns a human-realistic hold duration drawn from a
// Weibull distribution (k=2.0, lambda=1.5, clamped to [0.8, 4.0] seconds).
//
// Weibull with k=2 produces a right-skewed distribution peaking around 1.3s,
// matching observed human interaction with "press and hold" challenges.
// The 0.8s floor prevents trivially short holds that PX detects as bot-like.
// The 4.0s ceiling prevents timeouts on PX's challenge widget (typically 10s).
func PressHoldDuration() time.Duration {
	seconds := WeibullClamped(2.0, 1.5, 0.8, 4.0)
	return time.Duration(seconds * float64(time.Second))
}

// PressHoldApproach generates a human-like Bézier mouse trajectory from
// start to the target button centre (end). Uses DefaultMouseConfig.
// Returns the waypoint list suitable for replaying via playwright mouse API.
func PressHoldApproach(start, end Point) []Point {
	m := NewMouse(DefaultMouseConfig())
	return m.MoveTo(start, end)
}
